From a69eb7bc322b854970d4a837cc422e023dd825b3 Mon Sep 17 00:00:00 2001 From: corredor <> Date: Fri, 14 May 2010 11:41:04 +0000 Subject: [PATCH] Buttons to define a complexbox --- data/icons/wxart_complexbox.xpm | 22 ++++++ .../bbsKernelEditorGraphic/GlobalConstants.h | 2 + .../wxVtkSceneManager.cxx | 15 ++++ .../wxVtkSceneManager.h | 5 ++ .../bbtkwxGUIEditorGraphicBBS.cxx | 73 +++++++++++++++++-- .../bbtkwxGUIEditorGraphicBBS.h | 7 +- .../wxGEditorTabPanel.cxx | 14 ++++ .../bbsWxGUIEditorGraphic/wxGEditorTabPanel.h | 2 + .../wxTabPanelsManager.cxx | 17 ++++- .../wxTabPanelsManager.h | 2 + 10 files changed, 151 insertions(+), 8 deletions(-) create mode 100644 data/icons/wxart_complexbox.xpm diff --git a/data/icons/wxart_complexbox.xpm b/data/icons/wxart_complexbox.xpm new file mode 100644 index 0000000..6f0d5e3 --- /dev/null +++ b/data/icons/wxart_complexbox.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * complexbox_xpm[] = { +"17 15 3 1", +" c None", +". c #101010", +"+ c #404040", +" ............... ", +" . . ", +" . . ", +" . +++++++++ . ", +" . +++++++++ . ", +" . ++ . ", +" . ++ . ", +" . ++ . ", +" . ++ . ", +" . ++ . ", +" . +++++++++ . ", +" . +++++++++ . ", +" . . ", +" . . ", +" ............... ", +}; diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h index 7b53977..7405a96 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h @@ -139,6 +139,8 @@ namespace bbtk const int ID_DELETEALL = 1004; const int ID_CENTERVIEW = 1005; const int ID_BTNCOMPLEXBOX = 1006; + const int ID_ADDCOMPLEXBOXINPUT = 1007; + const int ID_ADDCOMPLEXBOXOUTPUT = 1008; const int wxID_NOTEBOOK = 1010; } diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx index 2b081d8..39f1237 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx @@ -48,6 +48,7 @@ namespace bbtk _idManager=idManager; _baseView=baseView; _startDragging=false; + _isComplexBox=false; if( _baseView!=NULL ) { @@ -1233,6 +1234,20 @@ namespace bbtk } //========================================================================= + + bool wxVtkSceneManager::isComplexBox() + { + return _isComplexBox; + } + + //========================================================================= + + void wxVtkSceneManager::setComplexBox(bool val) + { + _isComplexBox=val; + } + + //========================================================================= } // EO namespace bbtk diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h index 36a2168..3479c2a 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h @@ -125,6 +125,9 @@ namespace bbtk std::vector getBoxes(); std::vector getConnections(); + bool isComplexBox(); + void setComplexBox(bool val); + private: @@ -148,6 +151,8 @@ namespace bbtk //Saves the id's of the selected objects in the controllers map std::vector _selectedObjects; + bool _isComplexBox; + protected: }; diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index 5a7d831..871160a 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -91,6 +91,7 @@ namespace bbtk wxBitmap bmp_run(run_xpm); wxBitmap bmp_delete(delete_xpm); wxBitmap bmp_centerview(centerview_xpm); + wxBitmap bmp_complexbox(complexbox_xpm); wxToolBar *toolbar = new wxToolBar(this, wxID_ANY); @@ -102,8 +103,12 @@ namespace bbtk toolbar->AddTool(ID_DELETEALL,_T("Delete all"),bmp_delete, wxNullBitmap, wxITEM_NORMAL,_T("Delete all boxes"), _T("Delete all boxes")); toolbar->AddTool(ID_CENTERVIEW,_T("Center view"),bmp_centerview, wxNullBitmap, wxITEM_NORMAL,_T("Center view"), _T("Center view")); toolbar->AddSeparator(); - toolbar->AddTool(ID_BTNCOMPLEXBOX,_T("Complex box"),bmp_centerview, wxNullBitmap, wxITEM_NORMAL,_T("Complex box"), _T("Complex box")); + toolbar->AddTool(ID_BTNCOMPLEXBOX,_T("Complex box"),complexbox_xpm, wxNullBitmap, wxITEM_NORMAL,_T("Complex box"), _T("Complex box")); toolbar->SetToggle(ID_BTNCOMPLEXBOX,true); + toolbar->AddTool(ID_ADDCOMPLEXBOXINPUT,_T("Add input to Complex box"),bmp_centerview, wxNullBitmap, wxITEM_NORMAL,_T("Add input to Complex box"), _T("Add input to Complex box")); + toolbar->AddTool(ID_ADDCOMPLEXBOXOUTPUT,_T("Add output to Complex box"),bmp_centerview, wxNullBitmap, wxITEM_NORMAL,_T("Add output Complex box"), _T("Add output Complex box")); + toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,false); + toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,false); toolbar->SetMargins( 2, 2 ); toolbar->Realize(); @@ -116,7 +121,9 @@ namespace bbtk Connect(ID_RUN,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExecuteActualDiagram)); Connect(ID_DELETEALL,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram)); Connect(ID_CENTERVIEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCenterViewActualDiagram)); - Connect(ID_BTNCOMPLEXBOX,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnActivateComplexBox)); + Connect(ID_BTNCOMPLEXBOX,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnClickBtnComplexBox)); + Connect(ID_ADDCOMPLEXBOXINPUT,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnAddComplexBoxInput)); + Connect(ID_ADDCOMPLEXBOXOUTPUT,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnAddComplexBoxOutput)); } //========================================================================= @@ -352,7 +359,8 @@ namespace bbtk void wxGUIEditorGraphicBBS::OnCreateNewTab(wxCommandEvent& event) { - _tabsMgr->addNewTab(); + _tabsMgr->addNewTab(); + refreshToolbar(); } //========================================================================= @@ -402,6 +410,33 @@ namespace bbtk //========================================================================= + void wxGUIEditorGraphicBBS::refreshToolbar() + { + wxToolBar* toolbar = GetToolBar(); + if(_tabsMgr->isActualDiagramComplexBox()) + { + toolbar->ToggleTool(ID_BTNCOMPLEXBOX,true); + } + else + { + toolbar->ToggleTool(ID_BTNCOMPLEXBOX,false); + } + + bool temp = toolbar->GetToolState(ID_BTNCOMPLEXBOX); + if(temp) + { + toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,true); + toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,true); + } + else + { + toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,false); + toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,false); + } + } + + //========================================================================= + void wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram(wxCommandEvent& event) { wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Are you sure to delete all boxes of the diagram?"), wxT("Delete all boxes"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION); @@ -442,10 +477,36 @@ namespace bbtk //========================================================================= - void wxGUIEditorGraphicBBS::OnActivateComplexBox(wxCommandEvent& event) - { + void wxGUIEditorGraphicBBS::OnClickBtnComplexBox(wxCommandEvent& event) + { + wxToolBar* toolbar = GetToolBar(); + bool temp = toolbar->GetToolState(ID_BTNCOMPLEXBOX); + if(temp) + { + toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,true); + toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,true); + _tabsMgr->setActualDiagramComplexBox(true); + } + else + { + toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,false); + toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,false); + _tabsMgr->setActualDiagramComplexBox(false); + } + + } + + //========================================================================= + + void wxGUIEditorGraphicBBS::OnAddComplexBoxInput(wxCommandEvent& event) + { + } + + //========================================================================= + + void wxGUIEditorGraphicBBS::OnAddComplexBoxOutput(wxCommandEvent& event) + { } - //========================================================================= diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h index aa8ad2a..1e472ad 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h @@ -56,6 +56,7 @@ #include "wxart_run.xpm" #include "wxart_delete.xpm" #include "wxart_centerview.xpm" +#include "wxart_complexbox.xpm" //Includes creaMaracasVisu @@ -112,13 +113,17 @@ namespace bbtk void DoRegeneratePackageDoc(const std::string& pack); void DoRegenerateBoxesLists(); + void refreshToolbar(); + void OnCreateNewTab(wxCommandEvent& event); void OnOpenDiagram(wxCommandEvent& event); void OnSaveActualDiagram(wxCommandEvent& event); void OnExecuteActualDiagram(wxCommandEvent& event); void OnDeleteAllBoxesActualDiagram(wxCommandEvent& event); void OnCenterViewActualDiagram(wxCommandEvent& event); - void OnActivateComplexBox(wxCommandEvent& event); + void OnClickBtnComplexBox(wxCommandEvent& event); + void OnAddComplexBoxInput(wxCommandEvent& event); + void OnAddComplexBoxOutput(wxCommandEvent& event); void OnExit(wxCommandEvent& event); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx index 4cfa95d..3c4081e 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx @@ -175,6 +175,20 @@ namespace bbtk //========================================================================= + bool wxGEditorTabPanel::isComplexBox() + { + return _sceneManager->isComplexBox(); + } + + //========================================================================= + + void wxGEditorTabPanel::setComplexBox(bool val) + { + _sceneManager->setComplexBox(val); + } + + //========================================================================= + } // EO namespace bbtk // EOF diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h index c3a9a77..af9897a 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h @@ -89,6 +89,8 @@ namespace bbtk void saveDiagram(std::string &content); void loadDiagram(ifstream &inputStream); int getPanelId(); + bool isComplexBox(); + void setComplexBox(bool val); //========================================================================= diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx index 97fa011..4b06456 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx @@ -144,12 +144,27 @@ namespace bbtk //========================================================================= + bool wxTabPanelsManager::isActualDiagramComplexBox() + { + return _actual->isComplexBox(); + } + + //========================================================================= + + void wxTabPanelsManager::setActualDiagramComplexBox(bool val) + { + _actual->setComplexBox(val); + } + + //========================================================================= + void wxTabPanelsManager::OnTabChanged(wxAuiNotebookEvent& event) { int index = event.GetSelection(); wxGEditorTabPanel* tab =(wxGEditorTabPanel*)_notebook->GetPage(index); int id = tab->getPanelId(); - _actual = _panels[id]; + _actual = _panels[id]; + _parent->refreshToolbar(); } //========================================================================= diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h index 3cdfcde..5ac62f4 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h @@ -81,6 +81,8 @@ namespace bbtk void centerViewActualDiagram(); void saveActualDiagram(std::string &content); void loadDiagram(ifstream &inputStream); + bool isActualDiagramComplexBox(); + void setActualDiagramComplexBox(bool val); void OnTabChanged(wxAuiNotebookEvent& event); -- 2.47.1