From ee78ea5e5132aa8e24b525dfa92fd0a355e8245a Mon Sep 17 00:00:00 2001 From: corredor <> Date: Wed, 5 May 2010 09:02:19 +0000 Subject: [PATCH] Added the possibility to delete all the boxes in the scene --- data/icons/wxart_delete.xpm | 42 +++++++++++++++ .../wxVtkSceneManager.cxx | 27 +++++++++- .../wxVtkSceneManager.h | 5 +- .../bbtkwxGUIEditorGraphicBBS.cxx | 54 ++++++++++--------- .../bbtkwxGUIEditorGraphicBBS.h | 7 ++- .../wxGEditorTabPanel.cxx | 7 +++ .../bbsWxGUIEditorGraphic/wxGEditorTabPanel.h | 1 + .../wxTabPanelsManager.cxx | 5 ++ .../wxTabPanelsManager.h | 1 + 9 files changed, 120 insertions(+), 29 deletions(-) create mode 100644 data/icons/wxart_delete.xpm diff --git a/data/icons/wxart_delete.xpm b/data/icons/wxart_delete.xpm new file mode 100644 index 0000000..c2e7ca3 --- /dev/null +++ b/data/icons/wxart_delete.xpm @@ -0,0 +1,42 @@ +/* XPM */ +static const char *delete_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 21 1", +"2 c #A5AEBD", +"* c #5478B4", +"< c #95A3BB", +"O c #9AA7BC", +"; c #758EB7", +"$ c #6986B6", +"# c #4971B2", +"& c #8A9CBA", +"X c #8598B9", +" c None", +"o c #ABB2BE", +"- c #7F95B9", +"= c #4E74B3", +"1 c #A0ABBC", +"+ c #6F8AB7", +". c #B5B9BF", +"@ c #3E69B1", +", c #90A0BA", +": c #6483B5", +"> c #5A7BB4", +"% c #5F7FB5", +/* pixels */ +" ", +" .Xo OO ", +" +@#. $@% ", +" &@@X .*@*o ", +" =@= .*@*. ", +" -@@X*@*. ", +" .#@@@$. ", +" ;@@: ", +" ;@@@+ ", +" .>@#%@@. ", +" o*@*oO@@, ", +" <#@*. .@@= ", +"&@@$ :@@1 ", +";#& 2#>. ", +" " +}; diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx index 3a5c196..1e32532 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx @@ -688,7 +688,7 @@ namespace bbtk for(int i=0;i<_selectedObjects.size();i++) { int id = _selectedObjects[i]; - removeObject(id); + deleteObject(id); } _selectedObjects.clear(); } @@ -699,7 +699,7 @@ namespace bbtk //========================================================================= - void wxVtkSceneManager::removeObject(int id) + void wxVtkSceneManager::deleteObject(int id) { GObjectController *control = _controllers[id]; std::vector controllersToRemove; @@ -920,6 +920,29 @@ namespace bbtk //========================================================================= + void wxVtkSceneManager::deleteAllBoxes() + { + std::map::iterator it; + for(it = _controllers.begin(); it != _controllers.end(); ++it) + { + GObjectController *cont = it->second; + cont->removeFromScene(); + unregisterController((InteractorStyleMaracas*)cont); + } + _selectedObjects.clear(); + _controllers.clear(); + refreshScene(); + } + + //========================================================================= + + void wxVtkSceneManager::refreshScene() + { + _baseView->RefreshView(); + } + + //========================================================================= + } // EO namespace bbtk // EOF diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h index 172aaf7..0f795e8 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h @@ -115,7 +115,10 @@ namespace bbtk void displayBlackBoxInfo(std::string packageName, std::string boxName); void updateStatusBar(std::string textStatus); std::string getDiagramScript(); - void removeObject(int id); + void deleteObject(int id); + void deleteAllBoxes(); + + void refreshScene(); private: diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index 71ae3df..7f8e8ac 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -84,24 +84,26 @@ namespace bbtk //========================================================================= void wxGUIEditorGraphicBBS::initToolbar() - { - //std::string filename= _dataDir + "/data/icons/wxart_new.xpm"; + { wxBitmap bmp_new(new_xpm); wxBitmap bmp_run(run_xpm); + wxBitmap bmp_delete(delete_xpm); wxToolBar *_toolbar = new wxToolBar(this, wxID_ANY); //Adds a tool btn to the toolbar _toolbar->AddTool(1000,_T("New"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New tab"), _T("Create a new panel tab")); _toolbar->AddTool(1001,_T("Execute"),bmp_run, wxNullBitmap, wxITEM_NORMAL,_T("Execute actual diagram"), _T("Execute actual diagram")); + _toolbar->AddTool(1002,_T("Delete all"),bmp_delete, wxNullBitmap, wxITEM_NORMAL,_T("Delete all boxes"), _T("Delete all boxes")); _toolbar->SetMargins( 2, 2 ); _toolbar->Realize(); SetToolBar(_toolbar); // connect command event handlers - Connect(1000,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnToolLeftClick)); - Connect(1001,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnToolLeftClick)); + Connect(1000,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab)); + Connect(1001,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExecuteActualDiagram)); + Connect(1002,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram)); } //========================================================================= @@ -294,13 +296,8 @@ namespace bbtk //========================================================================= - void wxGUIEditorGraphicBBS::executeActualDiagram() + void wxGUIEditorGraphicBBS::executeScript(std::string script) { - std::string script = _tabsMgr->getActualDiagramScript(); - cout<<"RaC wxGUIEditorGraphicBBS::executeActualDiagram SCRIPT"<addNewTab(); + } - void wxGUIEditorGraphicBBS::OnToolLeftClick(wxCommandEvent& event) + //========================================================================= + + void wxGUIEditorGraphicBBS::OnExecuteActualDiagram(wxCommandEvent& event) { - switch (event.GetId()) - { - case 1000 : - _tabsMgr->addNewTab(); - break; + std::string script = _tabsMgr->getActualDiagramScript(); + cout<<"RaC wxGUIEditorGraphicBBS::executeActualDiagram SCRIPT"<deleteAllBoxesActualDiagram(); + } + + //========================================================================= + void wxGUIEditorGraphicBBS::OnExit(wxCommandEvent& event) { Close(true); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h index 80d02cb..2994c61 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h @@ -50,6 +50,7 @@ //#include "C:\RaC\CREATIS\bbtkGEditor\data\icons\wxart_new.xpm" // JPR #include "wxart_new.xpm" // JPR #include "wxart_run.xpm" +#include "wxart_delete.xpm" //Includes creaMaracasVisu @@ -97,7 +98,7 @@ namespace bbtk wxAuiNotebook* getAuiNotebook(); void displayBlackBoxInfo(std::string packageName, std::string boxName); void updateStatusBar(std::string textStatus); - void executeActualDiagram(); + void executeScript(std::string script); void editBlackBox(GBlackBoxModel *bbmodel); void editDiagramParameters(wxVtkSceneManager* scene); @@ -106,7 +107,9 @@ namespace bbtk void DoRegeneratePackageDoc(const std::string& pack); void DoRegenerateBoxesLists(); - void OnToolLeftClick(wxCommandEvent& event); + void OnCreateNewTab(wxCommandEvent& event); + void OnExecuteActualDiagram(wxCommandEvent& event); + void OnDeleteAllBoxesActualDiagram(wxCommandEvent& event); void OnExit(wxCommandEvent& event); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx index e2ead8f..66dd7b0 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx @@ -140,6 +140,13 @@ namespace bbtk //========================================================================= + void wxGEditorTabPanel::deleteAllBoxes() + { + _sceneManager->deleteAllBoxes(); + } + + //========================================================================= + } // EO namespace bbtk // EOF diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h index 6d6c39a..a50bda3 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h @@ -84,6 +84,7 @@ namespace bbtk std::string getDiagramScript(); void editBlackBox(GBlackBoxModel *bbmodel); void editDiagramParameters(wxVtkSceneManager* scene); + void deleteAllBoxes(); private: diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx index 1e9061e..6f6b9e9 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx @@ -117,7 +117,12 @@ namespace bbtk //========================================================================= + void wxTabPanelsManager::deleteAllBoxesActualDiagram() + { + _actual->deleteAllBoxes(); + } + //========================================================================= } // EO namespace bbtk diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h index 556a504..b41f027 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h @@ -77,6 +77,7 @@ namespace bbtk std::string getActualDiagramScript(); void editBlackBox(GBlackBoxModel *bbmodel); void editDiagramParameters(wxVtkSceneManager* scene); + void deleteAllBoxesActualDiagram(); private: -- 2.45.1