X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=inline;f=lib%2FEditorGraphicBBS%2FbbsWxGUIEditorGraphic%2FbbtkwxGUIEditorGraphicBBS.cxx;h=4b9c0e5f0abcaefa0877995d2aff861386b46297;hb=refs%2Fheads%2Fvtk7itk4wx3;hp=ca7bb43a364a791e5c626c73cc711543c96bb975;hpb=782cadf1306a646406ed7a089907f73a5f12c4e5;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index ca7bb43..4b9c0e5 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -111,22 +111,19 @@ wxGUIEditorGraphicBBS::wxGUIEditorGraphicBBS(wxFrame *parent) } //========================================================================= -wxGUIEditorGraphicBBS::~wxGUIEditorGraphicBBS() { - - printf("EED %p ~wxGUIEditorGraphicBBS()\n", this); - +wxGUIEditorGraphicBBS::~wxGUIEditorGraphicBBS() +{ //EED02JUIN2010 delete _tabsMgr; - _frameAUIMgr->UnInit(); // FCY memory leaks delete _frameAUIMgr; delete _notebook; delete _tabsMgr; - } //========================================================================= -void wxGUIEditorGraphicBBS::initToolbar() { +void wxGUIEditorGraphicBBS::initToolbar() +{ wxBitmap bmp_new(new_xpm); wxBitmap bmp_open(open_xpm); wxBitmap bmp_save(save_xpm); @@ -141,13 +138,16 @@ void wxGUIEditorGraphicBBS::initToolbar() { wxBitmap bmp_undo(undo_xpm); wxBitmap bmp_redo(redo_xpm); wxBitmap bmp_editProperties(editProperties_xpm); + wxBitmap bmp_showTree(showTree_xpm); wxToolBar *toolbar = new wxToolBar(this, wxID_ANY); //Adds a tool btn to the toolbar toolbar->AddTool(ID_NEW, _T("New"), bmp_new, wxNullBitmap, wxITEM_NORMAL, _T("New tab"), _T("Create a new panel tab")); + toolbar->AddTool(ID_OPEN, _T("Open diagram"), bmp_open, wxNullBitmap, wxITEM_NORMAL, _T("Open a diagram"), _T("Open a diagram")); + toolbar->AddTool(ID_SAVE_DIAGRAM, _T("Save Diagram"), bmp_save, wxNullBitmap, wxITEM_NORMAL, _T("Saves the current diagram"), _T("Saves the current diagram")); //DFCH @@ -168,7 +168,14 @@ void wxGUIEditorGraphicBBS::initToolbar() { toolbar->AddSeparator(); toolbar->AddTool(ID_BTNCOMPLEXBOX, _T("Complex box"), complexbox_xpm, wxNullBitmap, wxITEM_NORMAL, _T("Complex box"), _T("Complex box")); + +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 toolbar->SetToggle(ID_BTNCOMPLEXBOX, true); +#else + printf ("EED Warnning. wxGUIEditorGraphicBBS::initToolbar >>> toolbar->SetToggle \n "); + // .. +#endif // RaC 2012 2nd HackFest - Now Complex inputs are any external input // toolbar->AddTool(ID_ADDCOMPLEXBOXINPUT, _T("Add input to Complex box"), @@ -192,6 +199,9 @@ void wxGUIEditorGraphicBBS::initToolbar() { toolbar->AddSeparator(); toolbar->AddTool(ID_EDITPROPERTIES, _T("Edit diagram properties"),bmp_editProperties, wxNullBitmap, wxITEM_NORMAL, _T("Edit diagram properties"), _T("Edit diagram properties")); toolbar->EnableTool(ID_EDITPROPERTIES, false); + + toolbar->AddTool(ID_SHOWTREE, _T("Show tree"),bmp_showTree, wxNullBitmap, wxITEM_NORMAL, _T("Show tree"), _T("Show tree")); + toolbar->EnableTool(ID_UNDO, false); toolbar->EnableTool(ID_REDO, false); @@ -199,6 +209,7 @@ void wxGUIEditorGraphicBBS::initToolbar() { toolbar->Realize(); SetToolBar(toolbar); + // connect command event handlers @@ -238,6 +249,8 @@ void wxGUIEditorGraphicBBS::initToolbar() { Connect(ID_REDO,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnRedo)); Connect(ID_CHANGENAME, wxEVT_COMMAND_RIGHT_CLICK, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnChangeName)); Connect(ID_EDITPROPERTIES,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnEditDiagramProperties)); + Connect(ID_SHOWTREE,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnShowTree)); + } //========================================================================= @@ -453,18 +466,50 @@ void wxGUIEditorGraphicBBS::displayBlackBoxInfo(std::string packageName, std::st { if (_actualPkgBrowserPkgName != packageName || _actualPkgBrowserBoxName != boxName) { + _actualPkgBrowserPkgName = packageName; _actualPkgBrowserBoxName = boxName; //EED 15 oct 2012 BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxName); Package::Pointer k; +//EED ComplexBlackBoxDescriptor::Pointer descriptor; + BlackBoxDescriptor::Pointer descriptor; + + std::map< std::string, BlackBoxDescriptor::Pointer> mapDesc; + k = _pkgBrowser->GetFactory()->GetPackage(_actualPkgBrowserPkgName); + mapDesc = k->GetDescriptorMap(); + descriptor = mapDesc[_actualPkgBrowserBoxName]; +/* + tree.treeTour(0); + + tree.deleteTree(); + + descriptor->GetBoxesInside(tree, 0); + + //tree.treeTour(0); + //std::vector boxesDiagram = _sceneM->boxesDiagram; + //for(int i=0;i mapDesc; k = _pkgBrowser->GetFactory()->GetPackage(packageName); + std::vector temp; + _pkgBrowser->GetFactory()->GetPackagesList(temp); + for(int ii = 0 ; ii < temp.size() ; ii++) + { + std::cout << " packs "<< temp[ii]<< std::endl; + } mapDesc = k->GetDescriptorMap(); descriptor = mapDesc[boxName]; - + */ _pkgBrowser->WxGUIBlackBoxListUserOnSelected(descriptor.get()); } } @@ -590,13 +635,42 @@ void wxGUIEditorGraphicBBS::OnRedo(wxCommandEvent& event) { void wxGUIEditorGraphicBBS::OnChangeName(wxCommandEvent& event){ } +//========================================================================= + +void wxGUIEditorGraphicBBS::OnShowTree(wxCommandEvent& event){ + std::cout << "wxGUIEditorGraphicBBS::OnShowTree"< mapDesc; + k = _pkgBrowser->GetFactory()->GetPackage(_actualPkgBrowserPkgName); + mapDesc = k->GetDescriptorMap(); + descriptor = mapDesc[_actualPkgBrowserBoxName]; + + tree.treeTour(0); + + tree.deleteTree(); + + descriptor->GetBoxesInside(tree, 0); + + _actualPkgBrowserPkgName = ""; + _actualPkgBrowserBoxName = ""; + } +else + { + std::cout<<"Select a Box"<Show(); } @@ -630,7 +704,12 @@ void wxGUIEditorGraphicBBS::OpenBBS(std::string filePathName, std::string fileNa //========================================================================= void wxGUIEditorGraphicBBS::OnOpenBBS(wxCommandEvent& event) { +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 wxFileDialog * openFileDialog = new wxFileDialog(this, wxT("Open BBS"), wxEmptyString, wxT("NewBBS"), wxT("*.bbs"), wxOPEN); +#else + wxFileDialog * openFileDialog = new wxFileDialog(this, wxT("Open BBS"), wxEmptyString, wxT("NewBBS"), wxT("*.bbs"), wxFD_OPEN); +#endif if (openFileDialog->ShowModal() == wxID_OK) { @@ -675,9 +754,18 @@ void wxGUIEditorGraphicBBS::SaveActualBBS(std::string filename) { } void wxGUIEditorGraphicBBS::OnSaveActualBBS(wxCommandEvent& event) { + +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 wxFileDialog * saveFileDialog = new wxFileDialog(this, wxT("Save actual BBS"), wxEmptyString, wxT("NewBBS"), wxT("*.bbs"), wxSAVE | wxOVERWRITE_PROMPT); +#else + wxFileDialog * saveFileDialog = new wxFileDialog(this, + wxT("Save actual BBS"), wxEmptyString, wxT("NewBBS"), + wxT("*.bbs"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT); +#endif + if (saveFileDialog->ShowModal() == wxID_OK) { wxString fileName = saveFileDialog->GetPath(); std::string filename = (const char*) (fileName.mb_str()); @@ -738,11 +826,21 @@ void wxGUIEditorGraphicBBS::SaveActualComplexBox(std::string filename) { //========================================================================= -void wxGUIEditorGraphicBBS::OnSaveActualComplexBox(wxCommandEvent& event) { +void wxGUIEditorGraphicBBS::OnSaveActualComplexBox(wxCommandEvent& event) +{ +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 wxFileDialog * saveFileDialog = new wxFileDialog(this, wxT("Save Complex Box BBS"), wxEmptyString, _T("ComplexBoxName"), wxT("*.bbs"), wxSAVE | wxOVERWRITE_PROMPT); +#else + wxFileDialog * saveFileDialog = new wxFileDialog(this, + wxT("Save Complex Box BBS"), wxEmptyString, + _T("ComplexBoxName"), wxT("*.bbs"), wxFD_SAVE + | wxFD_OVERWRITE_PROMPT); +#endif + if (saveFileDialog->ShowModal() == wxID_OK) { wxString fileName = saveFileDialog->GetPath(); std::string filename = (const char*) (fileName.mb_str()); @@ -797,10 +895,20 @@ void wxGUIEditorGraphicBBS::SaveTempActualDiagram(const std::string &action) //The following method allows to save the current diagram asking the filename //DFCH -void wxGUIEditorGraphicBBS::SaveCurrentDiagramAs() { +void wxGUIEditorGraphicBBS::SaveCurrentDiagramAs() +{ + +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 wxFileDialog * saveFileDialog = new wxFileDialog(this, wxT("Save current diagram"), wxEmptyString, wxT("NewDiagram"), wxT("*.bbg"), wxSAVE | wxOVERWRITE_PROMPT); +#else + wxFileDialog * saveFileDialog = new wxFileDialog(this, + wxT("Save current diagram"), wxEmptyString, wxT("NewDiagram"), + wxT("*.bbg"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT); +#endif + if (saveFileDialog->ShowModal() == wxID_OK) { //_tabsMgr->SetNameTabPanel(saveFileDialog->GetFilename()); wxString pathfileName = saveFileDialog->GetPath(); @@ -860,9 +968,17 @@ void wxGUIEditorGraphicBBS::OnSaveAsActualDiagram(wxCommandEvent& event) { //========================================================================= void wxGUIEditorGraphicBBS::OnExportConsoleExecCommand(wxCommandEvent& event) { +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 wxFileDialog * saveFileDialog = new wxFileDialog(this, wxT("Export console command"), wxEmptyString, wxT("ConsoleApp.txt"), wxT("*.txt;*.bbs;*.bbg;*.sh;*.bat"), wxSAVE | wxOVERWRITE_PROMPT); +#else + wxFileDialog * saveFileDialog = new wxFileDialog(this, + wxT("Export console command"), wxEmptyString, wxT("ConsoleApp.txt"), + wxT("*.txt;*.bbs;*.bbg;*.sh;*.bat"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT); +#endif + if (saveFileDialog->ShowModal() == wxID_OK) { @@ -952,12 +1068,14 @@ void wxGUIEditorGraphicBBS::OnExportConsoleExecCommand(wxCommandEvent& event) //========================================================================= -void wxGUIEditorGraphicBBS::refreshGUIControls() { +void wxGUIEditorGraphicBBS::refreshGUIControls() +{ std::string stundo; std::string stredo; //RaC2012 2ndHackFest Next line seems weird ... To keep in mind for other devels wxToolBar* toolbar = GetToolBar(); - if (_tabsMgr->isActualDiagramComplexBox()) { + if (_tabsMgr->isActualDiagramComplexBox()) + { toolbar->ToggleTool(ID_BTNCOMPLEXBOX, true); //toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, true); RaC2012 2nd HackFest toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT, true); @@ -1025,6 +1143,7 @@ void wxGUIEditorGraphicBBS::OpenDiagram(std::string filePathName, std::string fi } _tabsMgr->addNewTab( crea::std2wx(fileName) ); _tabsMgr->loadDiagram(inputStream, filePathName); + _tabsMgr->saveTempActualDiagram("load diagram"); GetToolBar()->EnableTool(ID_UNDO, false); GetToolBar()->EnableTool(ID_UNDO, false); @@ -1036,7 +1155,14 @@ void wxGUIEditorGraphicBBS::OpenDiagram(std::string filePathName, std::string fi void wxGUIEditorGraphicBBS::OnOpenDiagram(wxCommandEvent& event) { + +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 wxFileDialog * openFileDialog = new wxFileDialog(this, wxT("Open diagram"), wxEmptyString, wxT(""), wxT("*.bbg"), wxOPEN | wxFILE_MUST_EXIST); +#else + wxFileDialog * openFileDialog = new wxFileDialog(this, wxT("Open diagram"), wxEmptyString, wxT(""), wxT("*.bbg"), wxFD_OPEN | wxFD_FILE_MUST_EXIST); +#endif + if (openFileDialog->ShowModal() == wxID_OK) { wxString filePath = openFileDialog->GetPath(); @@ -1048,6 +1174,7 @@ void wxGUIEditorGraphicBBS::OnOpenDiagram(wxCommandEvent& event) //========================================================================= void wxGUIEditorGraphicBBS::OnClickBtnBox(wxCommandEvent& event) { + std::cout<<"wxGUIEditorGraphicBBS::OnClickBtnBox"<GetActualSelected(); if (bbDes != NULL) { std::string typeName = bbDes->GetTypeName(); @@ -1084,6 +1211,7 @@ void wxGUIEditorGraphicBBS::OnClickBtnExecutableBox(wxCommandEvent& event) //========================================================================= void wxGUIEditorGraphicBBS::OnClickBtnComplexBox(wxCommandEvent& event) { + std::cout<<"wxGUIEditorGraphicBBS::OnClickBtnComplexBox"<GetToolState(ID_BTNCOMPLEXBOX); if (temp) { @@ -1094,18 +1222,28 @@ void wxGUIEditorGraphicBBS::OnClickBtnComplexBox(wxCommandEvent& event) } //========================================================================= - +//EED01 void wxGUIEditorGraphicBBS::OnAddComplexBoxInput(wxCommandEvent& event) { wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this, wxT("Name of input port")); - if (nameDialog->ShowModal() == wxID_OK) { + if (nameDialog->ShowModal() == wxID_OK) + { wxString fileName = nameDialog->GetValue(); - if (!fileName.IsEmpty()) { + if (!fileName.IsEmpty()) + { std::string portName = (const char*) (fileName.mb_str()); - _tabsMgr->addActualDiagramComplexInputPort(portName); - } - } + if ( !boxNameExists(portName) ) + { + _tabsMgr->addActualDiagramComplexInputPort(portName); + } else { + wxMessageDialog *dial = new wxMessageDialog(NULL, + wxT("Impossible to create Box. The name already exists. Please provide another name"), + wxT("Change name: name already exists"), wxOK | wxICON_EXCLAMATION | wxSTAY_ON_TOP); + dial->ShowModal(); + } + } // if !fileName + } // if namaDialog } //========================================================================= @@ -1113,13 +1251,24 @@ void wxGUIEditorGraphicBBS::OnAddComplexBoxOutput(wxCommandEvent& event) { wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this, wxT("Name of output port")); - if (nameDialog->ShowModal() == wxID_OK) { + if (nameDialog->ShowModal() == wxID_OK) + { wxString fileName = nameDialog->GetValue(); - if (!fileName.IsEmpty()) { + if (!fileName.IsEmpty()) + { std::string portName = (const char*) (fileName.mb_str()); + if ( !boxNameExists(portName) ) + { _tabsMgr->addActualDiagramComplexOutputPort(portName); - } - } + } else { + wxMessageDialog *dial = new wxMessageDialog(NULL, + wxT("Impossible to create Box. The name already exists. Please provide another name"), + wxT("Change name: name already exists"), wxOK | wxICON_EXCLAMATION | wxSTAY_ON_TOP); + dial->ShowModal(); + } + + } // if !filename + } // namaDialog } //========================================================================= @@ -1164,7 +1313,12 @@ void wxGUIEditorGraphicBBS::OnPlugPackage(wxCommandEvent& event) if(userResponse==wxID_OK) { std::string path = wx2std (FD->GetPath()) ; + #ifdef WIN32 + std::string fname = path + "\\bbtkPackage"; + #else std::string fname = path + "/bbtkPackage"; + #endif + std::cout << "Path chosen = \"" << FD->GetPath() << "\"" << std::endl; if ( Utilities::FileExists( fname ) ) { @@ -1172,6 +1326,11 @@ void wxGUIEditorGraphicBBS::OnPlugPackage(wxCommandEvent& event) f.open(fname.c_str()); std::string pname; f >> pname; + while(pname[0] == '#') + { + getline(f, pname, '\n'); + f >> pname; + } f.close(); bbtk::ConfigurationFile::GetInstance().AddPackagePathsAndWrite( path ); @@ -1304,6 +1463,16 @@ void wxGUIEditorGraphicBBS::setCurrentDiagramCategory(std::string category) _tabsMgr->SetCategory(category); } +//========================================================================= +void wxGUIEditorGraphicBBS::setCurrentDiagramMessageKind(std::string kind){ + _tabsMgr->SetMessageKind(kind); +} + +//========================================================================= +void wxGUIEditorGraphicBBS::setCurrentDiagramMessageLevel(std::string level){ + _tabsMgr->SetMessageLevel(level); +} + //========================================================================= std::string wxGUIEditorGraphicBBS::getCurrentDiagramDescription() { @@ -1322,7 +1491,16 @@ std::string wxGUIEditorGraphicBBS::getCurrentDiagramCategory() return _tabsMgr->GetCategory(); } - +//========================================================================= +std::string wxGUIEditorGraphicBBS::getCurrentDiagramMessageKind(){ + return _tabsMgr->GetMessageKind(); +} + +//========================================================================= +std::string wxGUIEditorGraphicBBS::getCurrentDiagramMessageLevel(){ + return _tabsMgr->GetMessageLevel(); +} + //========================================================================= bool wxGUIEditorGraphicBBS::isCurrentDiagramComplexBox() {