|
From: Markus R. <rol...@us...> - 2007-06-15 09:46:18
|
Update of /cvsroot/simspark/simspark/contrib/rsgedit In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv5769 Modified Files: mainframe.cpp mainframe.h rsgedit.wxg Log Message: - implement ability to single step a simulation Index: mainframe.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** mainframe.h 17 May 2007 17:49:23 -0000 1.13 --- mainframe.h 15 Jun 2007 09:46:07 -0000 1.14 *************** *** 63,67 **** protected: /** start and run simulation */ ! void StartSimulation(); /** pause a running simulation */ --- 63,67 ---- protected: /** start and run simulation */ ! void StartSimulation(bool singleStep); /** pause a running simulation */ *************** *** 83,86 **** --- 83,89 ---- void OnStartSimulation(wxCommandEvent& event); + void OnUpdateStepSimulation(wxUpdateUIEvent& event); + void OnStepSimulation(wxCommandEvent& event); + void OnUpdatePauseSimulation(wxUpdateUIEvent& event); void OnPauseSimulation(wxCommandEvent& event); Index: rsgedit.wxg =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/rsgedit.wxg,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** rsgedit.wxg 15 Jun 2007 09:02:51 -0000 1.7 --- rsgedit.wxg 15 Jun 2007 09:46:07 -0000 1.8 *************** *** 1,4 **** <?xml version="1.0"?> ! <!-- generated by wxGlade 0.4.1 on Fri Jun 15 11:01:22 2007 --> <application path="." name="" class="" option="1" language="C++" top_window="MainFrame" encoding="UTF-8" use_gettext="0" overwrite="0" use_new_namespace="1" for_version="2.6"> --- 1,4 ---- <?xml version="1.0"?> ! <!-- generated by wxGlade 0.4.1 on Fri Jun 15 11:45:09 2007 --> <application path="." name="" class="" option="1" language="C++" top_window="MainFrame" encoding="UTF-8" use_gettext="0" overwrite="0" use_new_namespace="1" for_version="2.6"> *************** *** 45,48 **** --- 45,52 ---- <menu name="" label="&Simulation"> <item> + <label>St&ep</label> + <id>ID_SIM_STEP</id> + </item> + <item> <label>&Start</label> <id>ID_SIM_START</id> Index: mainframe.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** mainframe.cpp 15 Jun 2007 09:27:13 -0000 1.19 --- mainframe.cpp 15 Jun 2007 09:46:07 -0000 1.20 *************** *** 31,34 **** --- 31,35 ---- #include <rsgedit/res/xpm_play.xpm> + #include <rsgedit/res/xpm_step.xpm> #include <rsgedit/res/xpm_pause.xpm> #include <rsgedit/res/xpm_open.xpm> *************** *** 60,63 **** --- 61,65 ---- EVT_UPDATE_UI(ID_SIM_START, mainframe::OnUpdateStartSimulation) EVT_MENU(ID_SIM_START, mainframe::OnStartSimulation) + EVT_MENU(ID_SIM_STEP, mainframe::OnStepSimulation) EVT_UPDATE_UI(ID_SIM_PAUSE, mainframe::OnUpdatePauseSimulation) *************** *** 130,133 **** --- 132,136 ---- MainFrame_menubar->Append(wxglade_tmp_menu_2, wxT("&View")); wxMenu* wxglade_tmp_menu_3 = new wxMenu(); + wxglade_tmp_menu_3->Append(ID_SIM_STEP, wxT("St&ep"), wxT(""), wxITEM_NORMAL); wxglade_tmp_menu_3->Append(ID_SIM_START, wxT("&Start"), wxT("Start simulation"), wxITEM_NORMAL); wxglade_tmp_menu_3->Append(ID_SIM_PAUSE, wxT("&Pause"), wxT("Pause Simulation"), wxITEM_NORMAL); *************** *** 154,157 **** --- 157,161 ---- mToolBar->AddTool(ID_AGENT_OPEN, wxT("Start Agent"), wxBitmap(xpm_agent)); mToolBar->AddSeparator(); + mToolBar->AddTool(ID_SIM_STEP, wxT("Step"), wxBitmap(xpm_step)); mToolBar->AddTool(ID_SIM_START, wxT("Start"), wxBitmap(xpm_play)); mToolBar->AddTool(ID_SIM_PAUSE, wxT("Pause"), wxBitmap(xpm_pause)); *************** *** 358,362 **** void mainframe::OnStartSimulation(wxCommandEvent& /*event*/) { ! StartSimulation(); } --- 362,378 ---- void mainframe::OnStartSimulation(wxCommandEvent& /*event*/) { ! bool singleStep = false; ! StartSimulation(singleStep); ! } ! ! void mainframe::OnUpdateStepSimulation(wxUpdateUIEvent& event) ! { ! event.Enable(GetSimState() == S_PAUSED); ! } ! ! void mainframe::OnStepSimulation(wxCommandEvent& /*event*/) ! { ! bool singleStep = true; ! StartSimulation(singleStep); } *************** *** 529,533 **** } ! void mainframe::StartSimulation() { mFPSTimer.Stop(); --- 545,549 ---- } ! void mainframe::StartSimulation(bool singleStep) { mFPSTimer.Stop(); *************** *** 557,579 **** UpdateWindowUI(wxUPDATE_UI_RECURSE); ! while (! sim->WantsToQuit()) { ! if (SIM_SIMSTEP > 0.0f) ! { ! AdvanceSimulation(sim, SIM_SIMSTEP); ! } else ! { ! wxLongLong tNow = wxGetLocalTimeMillis(); ! float tDeltaSec = (tNow - tLast).ToLong() / 1000.0; ! tLast = tNow; ! AdvanceSimulation(sim, tDeltaSec); ! } ! PrintSimState(); ! // pump the wxWidgets message loop ! wxGetApp().Yield(); ! } DoneSimulation(sim); --- 573,600 ---- UpdateWindowUI(wxUPDATE_UI_RECURSE); ! if (singleStep) { ! // leave simulation loop after first iteration ! sim->Quit(); ! } ! do { ! if (SIM_SIMSTEP > 0.0f) ! { ! AdvanceSimulation(sim, SIM_SIMSTEP); ! } else ! { ! wxLongLong tNow = wxGetLocalTimeMillis(); ! float tDeltaSec = (tNow - tLast).ToLong() / 1000.0; ! tLast = tNow; ! AdvanceSimulation(sim, tDeltaSec); ! } ! PrintSimState(); ! ! // pump the wxWidgets message loop ! wxGetApp().Yield(); ! } while (! sim->WantsToQuit()); DoneSimulation(sim); |