From: Markus R. <rol...@us...> - 2006-01-08 15:37:45
|
Update of /cvsroot/simspark/simspark/contrib/rsgedit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5373 Modified Files: mainframe.cpp mainframe.h rsgedit.wxg simspark.cpp simspark.h Log Message: - splitted the main window into two panes, using the lower pane to display log messages from the LogServer Index: simspark.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/simspark.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** simspark.cpp 8 Jan 2006 14:15:27 -0000 1.2 --- simspark.cpp 8 Jan 2006 15:37:37 -0000 1.3 *************** *** 20,29 **** --- 20,33 ---- #include "simspark.h" #include <zeitgeist/scriptserver/scriptserver.h> + #include <zeitgeist/logserver/logserver.h> #include <oxygen/simulationserver/simulationserver.h> using namespace std; using namespace boost; + using namespace zeitgeist; using namespace spark; + ostringstream SimSpark::mLogStream; + SimSpark::SimSpark(const string& relPathPrefix) : Spark(relPathPrefix) *************** *** 34,38 **** bool SimSpark::InitApp(int argc, char** argv) { ! GetSimulationServer()->SetSimStep(0.02); PrintGreeting(); --- 38,42 ---- bool SimSpark::InitApp(int argc, char** argv) { ! GetLog()->AddStream(&mLogStream, LogServer::eAll); PrintGreeting(); *************** *** 71,72 **** --- 75,91 ---- mState = state; } + + wxString SimSpark::GetLogBuffer() + { + return wxString(mLogStream.str().c_str()); + } + + void SimSpark::ClearLogBuffer() + { + mLogStream.str(string()); + } + + bool SimSpark::HasLogContents() + { + return (! mLogStream.str().empty()); + } Index: mainframe.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** mainframe.h 8 Jan 2006 14:15:27 -0000 1.3 --- mainframe.h 8 Jan 2006 15:37:36 -0000 1.4 *************** *** 1,3 **** ! /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ // -*- C++ -*- generated by wxGlade 0.4 on Wed Jan 4 20:26:10 2006 #include <wx/wx.h> --- 1,21 ---- ! /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- ! this file is part of rcssserver3D ! Fri May 9 2003 ! Copyright (C) 2003 Koblenz University ! $Id$ ! ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; version 2 of the License. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! */ // -*- C++ -*- generated by wxGlade 0.4 on Wed Jan 4 20:26:10 2006 #include <wx/wx.h> *************** *** 10,13 **** --- 28,32 ---- // begin wxGlade: ::dependencies + #include <wx/splitter.h> // end wxGlade *************** *** 44,47 **** --- 63,71 ---- void OnClose( wxCloseEvent& event ); + void OnLogTimer(wxTimerEvent& event); + + /** appends the accumulated log buffer to the log window pane */ + void UpdateLogWindow(); + /** returns true iff its safe to close this frame now */ bool CanClose(); *************** *** 52,56 **** wxStatusBar* MainFrame_statusbar; SparkGLCanvas* mCanvas; ! wxPanel* panel_1; // end wxGlade --- 76,83 ---- wxStatusBar* MainFrame_statusbar; SparkGLCanvas* mCanvas; ! wxPanel* window_1_pane_1; ! wxTextCtrl* mCtrLog; ! wxPanel* window_1_pane_2; ! wxSplitterWindow* mCtrVertSplitter; // end wxGlade Index: simspark.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/simspark.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** simspark.h 8 Jan 2006 14:15:27 -0000 1.2 --- simspark.h 8 Jan 2006 15:37:37 -0000 1.3 *************** *** 7,15 **** This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by ! the Free Software Founda shared_ptr<SimulationServer> sim = spark->GetSimulationServer(); ! if (sim.get() == 0) ! { ! return; ! tion; version 2 of the License. This program is distributed in the hope that it will be useful, --- 7,11 ---- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by ! the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, *************** *** 26,29 **** --- 22,27 ---- #include <spark/spark.h> + #include <wx/string.h> + #include <sstream> class SimSpark : public spark::Spark *************** *** 57,63 **** --- 55,73 ---- void SetSimState(ESimState state); + /** returns true iff the log buffer is filled */ + static bool HasLogContents(); + + /** returns the current log buffer */ + static wxString GetLogBuffer(); + + /** clears the log buffer */ + static void ClearLogBuffer(); + protected: //! the state of the current simulation ESimState mState; + + //! log buffer + static std::ostringstream mLogStream; }; Index: rsgedit.wxg =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/rsgedit.wxg,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** rsgedit.wxg 4 Jan 2006 20:31:58 -0000 1.1 --- rsgedit.wxg 8 Jan 2006 15:37:37 -0000 1.2 *************** *** 1,4 **** <?xml version="1.0"?> ! <!-- generated by wxGlade 0.4 on Wed Jan 4 21:31:51 2006 --> <application path="/home/markus/cvs/simspark/contrib/rsgedit" 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 on Sun Jan 8 16:37:09 2006 --> <application path="/home/markus/cvs/simspark/contrib/rsgedit" 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"> *************** *** 17,22 **** --- 17,39 ---- </item> </menu> + <menu name="" label="&Simulation"> + <item> + <label>&Start</label> + <id>ID_SIM_START</id> + <help_str>Start simulation</help_str> + </item> + <item> + <label>&Pause</label> + <id>ID_SIM_PAUSE</id> + <help_str>Pause Simulation</help_str> + </item> + </menu> </menus> </object> + <object class="wxStatusBar" name="MainFrame_statusbar" base="EditStatusBar"> + <fields> + <field width="0">Welcome to RsgEdit</field> + </fields> + </object> <object class="wxBoxSizer" name="sizer_1" base="EditBoxSizer"> <orient>wxVERTICAL</orient> *************** *** 25,41 **** <border>0</border> <option>1</option> ! <object class="wxPanel" name="panel_1" base="EditPanel"> ! <style>wxTAB_TRAVERSAL</style> ! <object class="wxBoxSizer" name="sizer_2" base="EditBoxSizer"> ! <orient>wxVERTICAL</orient> ! <object class="sizeritem"> ! <flag>wxEXPAND</flag> ! <border>0</border> ! <option>1</option> ! <object class="SparkGLCanvas" name="mCanvas" base="CustomWidget"> ! <arguments> ! <argument>$parent</argument> ! <argument>$id</argument> ! </arguments> </object> </object> --- 42,78 ---- <border>0</border> <option>1</option> ! <object class="wxSplitterWindow" name="mCtrVertSplitter" base="EditSplitterWindow"> ! <style>wxSP_3D|wxSP_BORDER|wxSP_LIVE_UPDATE</style> ! <orientation>wxSPLIT_HORIZONTAL</orientation> ! <window_2>window_1_pane_2</window_2> ! <window_1>window_1_pane_1</window_1> ! <object class="wxPanel" name="window_1_pane_1" base="EditPanel"> ! <style>wxTAB_TRAVERSAL</style> ! <object class="wxBoxSizer" name="sizer_3" base="EditBoxSizer"> ! <orient>wxHORIZONTAL</orient> ! <object class="sizeritem"> ! <flag>wxEXPAND</flag> ! <border>0</border> ! <option>1</option> ! <object class="SparkGLCanvas" name="mCanvas" base="CustomWidget"> ! <arguments> ! <argument>$parent</argument> ! <argument>$id</argument> ! </arguments> ! </object> ! </object> ! </object> ! </object> ! <object class="wxPanel" name="window_1_pane_2" base="EditPanel"> ! <style>wxTAB_TRAVERSAL</style> ! <object class="wxBoxSizer" name="sizer_4" base="EditBoxSizer"> ! <orient>wxVERTICAL</orient> ! <object class="sizeritem"> ! <flag>wxEXPAND</flag> ! <border>0</border> ! <option>1</option> ! <object class="wxTextCtrl" name="mCtrLog" base="EditTextCtrl"> ! <style>wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL|wxTE_LINEWRAP</style> ! </object> </object> </object> *************** *** 44,52 **** </object> </object> - <object class="wxStatusBar" name="MainFrame_statusbar" base="EditStatusBar"> - <fields> - <field width="0">Welcome to RsgEdit</field> - </fields> - </object> </object> </application> --- 81,84 ---- Index: mainframe.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** mainframe.cpp 8 Jan 2006 14:15:27 -0000 1.4 --- mainframe.cpp 8 Jan 2006 15:37:36 -0000 1.5 *************** *** 1,3 **** ! /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ // -*- C++ -*- generated by wxGlade 0.4 on Wed Jan 4 20:26:10 2006 #include "mainframe.h" --- 1,21 ---- ! /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- ! this file is part of rcssserver3D ! Fri May 9 2003 ! Copyright (C) 2003 Koblenz University ! $Id$ ! ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; version 2 of the License. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! */ // -*- C++ -*- generated by wxGlade 0.4 on Wed Jan 4 20:26:10 2006 #include "mainframe.h" *************** *** 11,14 **** --- 29,33 ---- #undef DECLARE_CLASS + #include <zeitgeist/logserver/logserver.h> #include <oxygen/simulationserver/simulationserver.h> #include <oxygen/sceneserver/sceneserver.h> *************** *** 25,28 **** --- 44,49 ---- EVT_UPDATE_UI(ID_SIM_PAUSE, mainframe::OnUpdatePauseSimulation) EVT_MENU(ID_SIM_PAUSE, mainframe::OnPauseSimulation) + + EVT_TIMER(1, mainframe::OnLogTimer) END_EVENT_TABLE() *************** *** 31,34 **** --- 52,61 ---- using namespace oxygen; + // the default height of the log window pane [pixel] + static const int LOGWND_DEFAULT_HEIGHT = 80; + + // the update interval of the log window [milliseconds} + static const int LOGWND_UPDATE_INTERVAL = 100; + mainframe::mainframe(wxWindow* parent, int id, const wxString& title, const wxPoint& pos, const wxSize& size, long style): wxFrame(parent, id, title, pos, size, wxDEFAULT_FRAME_STYLE), *************** *** 36,40 **** { // begin wxGlade: mainframe::mainframe ! panel_1 = new wxPanel(this, -1); MainFrame_menubar = new wxMenuBar(); SetMenuBar(MainFrame_menubar); --- 63,69 ---- { // begin wxGlade: mainframe::mainframe ! mCtrVertSplitter = new wxSplitterWindow(this, -1, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_BORDER|wxSP_LIVE_UPDATE); ! window_1_pane_2 = new wxPanel(mCtrVertSplitter, -1); ! window_1_pane_1 = new wxPanel(mCtrVertSplitter, -1); MainFrame_menubar = new wxMenuBar(); SetMenuBar(MainFrame_menubar); *************** *** 47,51 **** MainFrame_menubar->Append(wxglade_tmp_menu_2, wxT("&Simulation")); MainFrame_statusbar = CreateStatusBar(1, 0); ! mCanvas = new SparkGLCanvas(panel_1, -1); set_properties(); --- 76,81 ---- MainFrame_menubar->Append(wxglade_tmp_menu_2, wxT("&Simulation")); MainFrame_statusbar = CreateStatusBar(1, 0); ! mCanvas = new SparkGLCanvas(window_1_pane_1, -1); ! mCtrLog = new wxTextCtrl(window_1_pane_2, -1, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL|wxTE_LINEWRAP); set_properties(); *************** *** 53,56 **** --- 83,87 ---- // end wxGlade + // create toolbar mToolBar = new wxToolBar(this,-1); SetToolBar(mToolBar); *************** *** 60,63 **** --- 91,104 ---- mToolBar->Realize(); + + // init vertical splitterwindow + wxSize szClient = GetClientSize(); + mCtrVertSplitter->SetSashPosition(std::max<int>(1,szClient.y - LOGWND_DEFAULT_HEIGHT)); + + // only resize top pane, when window is resized + mCtrVertSplitter->SetSashGravity(1.0); + + // init log wnd timer + mTimer.Start(LOGWND_UPDATE_INTERVAL); } *************** *** 82,92 **** // begin wxGlade: mainframe::do_layout wxBoxSizer* sizer_1 = new wxBoxSizer(wxVERTICAL); ! wxBoxSizer* sizer_2 = new wxBoxSizer(wxVERTICAL); ! sizer_2->Add(mCanvas, 1, wxEXPAND, 0); ! panel_1->SetAutoLayout(true); ! panel_1->SetSizer(sizer_2); ! sizer_2->Fit(panel_1); ! sizer_2->SetSizeHints(panel_1); ! sizer_1->Add(panel_1, 1, wxEXPAND, 0); SetAutoLayout(true); SetSizer(sizer_1); --- 123,140 ---- // begin wxGlade: mainframe::do_layout wxBoxSizer* sizer_1 = new wxBoxSizer(wxVERTICAL); ! wxBoxSizer* sizer_4 = new wxBoxSizer(wxVERTICAL); ! wxBoxSizer* sizer_3 = new wxBoxSizer(wxHORIZONTAL); ! sizer_3->Add(mCanvas, 1, wxEXPAND, 0); ! window_1_pane_1->SetAutoLayout(true); ! window_1_pane_1->SetSizer(sizer_3); ! sizer_3->Fit(window_1_pane_1); ! sizer_3->SetSizeHints(window_1_pane_1); ! sizer_4->Add(mCtrLog, 1, wxEXPAND, 0); ! window_1_pane_2->SetAutoLayout(true); ! window_1_pane_2->SetSizer(sizer_4); ! sizer_4->Fit(window_1_pane_2); ! sizer_4->SetSizeHints(window_1_pane_2); ! mCtrVertSplitter->SplitHorizontally(window_1_pane_1, window_1_pane_2); ! sizer_1->Add(mCtrVertSplitter, 1, wxEXPAND, 0); SetAutoLayout(true); SetSizer(sizer_1); *************** *** 159,162 **** --- 207,228 ---- } + void mainframe::OnLogTimer(wxTimerEvent& /*event*/) + { + UpdateLogWindow(); + } + + void mainframe::UpdateLogWindow() + { + if (! SimSpark::HasLogContents()) + { + return; + } + + wxString buffer = SimSpark::GetLogBuffer(); + SimSpark::ClearLogBuffer(); + mCtrLog->AppendText(buffer); + mCtrLog->ShowPosition(mCtrLog->GetLastPosition() + 1); + } + void mainframe::PauseSimulation() { *************** *** 178,181 **** --- 244,248 ---- sim->Quit(); + spark->GetLog()->Normal() << "(RsgEdit) pausing simulation\n"; } *************** *** 207,213 **** --- 274,282 ---- } + sim->SetSimStep(0.0); sim->Init(0,0); sim->SetAutoTimeMode(false); + spark->GetLog()->Normal() << "(RsgEdit) starting simulation\n"; wxLongLong tLast = wxGetLocalTimeMillis(); *************** *** 231,234 **** --- 300,304 ---- sim->Done(); spark->SetSimState(SimSpark::S_PAUSED); + spark->GetLog()->Normal() << "(RsgEdit) simulation paused\n"; } *************** *** 236,237 **** --- 306,308 ---- + |