Update of /cvsroot/simspark/simspark/contrib/rsgedit
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv13728
Modified Files:
mainframe.cpp mainframe.h
Log Message:
- show the current simulation state and time in the toolbar
Index: mainframe.h
===================================================================
RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** mainframe.h 31 Mar 2007 13:28:50 -0000 1.9
--- mainframe.h 1 Apr 2007 16:10:13 -0000 1.10
***************
*** 123,126 ****
--- 123,129 ----
bool OpenSimulation(const wxString& fname);
+ /** Print the current simulation state on the toolbar */
+ void PrintSimState();
+
void InitTreeNodeProperties();
***************
*** 166,169 ****
--- 169,174 ----
wxToolBar* mToolBar;
+ wxTextCtrl* mSimState;
+
SparkTree mSparkTree;
PropertyList mPropList;
Index: mainframe.cpp
===================================================================
RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** mainframe.cpp 1 Apr 2007 15:14:09 -0000 1.11
--- mainframe.cpp 1 Apr 2007 16:10:13 -0000 1.12
***************
*** 145,148 ****
--- 145,152 ----
mToolBar->AddTool(ID_SIM_START, wxT("Start"), wxBitmap(xpm_play));
mToolBar->AddTool(ID_SIM_PAUSE, wxT("Pause"), wxBitmap(xpm_pause));
+ mToolBar->AddSeparator();
+
+ mSimState = new wxTextCtrl( mToolBar, wxID_ANY, _T(""), wxDefaultPosition, wxSize(120, -1), wxTE_READONLY );
+ mToolBar->AddControl(mSimState);
mToolBar->Realize();
***************
*** 167,170 ****
--- 171,175 ----
mTimer.Start(LOGWND_UPDATE_INTERVAL);
+ PrintSimState();
UpdateTitle();
}
***************
*** 436,440 ****
--- 441,447 ----
sim->Quit();
+ spark->SetSimState(S_PAUSED);
spark->GetLog()->Normal() << "(RsgEdit) pausing simulation\n";
+ PrintSimState();
}
***************
*** 545,548 ****
--- 552,557 ----
}
+ PrintSimState();
+
// pump the wxWidgets message loop
wxGetApp().Yield();
***************
*** 781,782 ****
--- 790,827 ----
frame->StartAgent(filename);
}
+
+ void mainframe::PrintSimState()
+ {
+ shared_ptr<SimSpark> spark = wxGetApp().GetSpark();
+
+ if (spark.get() == 0)
+ {
+ mSimState->SetValue("");
+ return;
+ }
+
+ shared_ptr<SimulationServer> sim = spark->GetSimulationServer();
+ if (sim.get() == 0)
+ {
+ mSimState->SetValue("");
+ return;
+ }
+
+ wxString state;
+ switch (spark->GetSimState())
+ {
+ default:
+ break;
+
+ case S_PAUSED:
+ state = "Paused ";
+ break;
+
+ case S_RUNNING:
+ state = "Running ";
+ break;
+ }
+
+ float now = sim->GetTime();
+ mSimState->SetValue(state + wxString::Format("t=%.1lf",now));
+ }
|