From e85b57e6b28466cc9cdf098abcd789b5004cc472 Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Sun, 18 Feb 2024 18:07:54 +0100 Subject: [PATCH] #3259 Export Format Python and JavaScript --- .../bbtkwxGUIEditorGraphicBBS.cxx | 43 +++++++++---- .../bbtkwxGUIEditorGraphicBBS.h | 2 + .../wxDiagramPropertiesEditionDialog.cxx | 50 +++++++++++---- .../wxDiagramPropertiesEditionDialog.h | 23 +++---- .../wxGEditorTabPanel.cxx | 12 +++- .../bbsWxGUIEditorGraphic/wxGEditorTabPanel.h | 2 + .../wxTabPanelsManager.cxx | 22 +++++-- .../wxTabPanelsManager.h | 2 + .../wxVtkSceneManager.cxx | 64 +++++++++++++++---- .../bbsWxGUIEditorGraphic/wxVtkSceneManager.h | 3 + 10 files changed, 168 insertions(+), 55 deletions(-) diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index 02c8c3f..48f80b9 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -107,7 +107,7 @@ wxGUIEditorGraphicBBS::wxGUIEditorGraphicBBS(wxFrame *parent) ///////////////////////////////// /// IMPORTANT!! FOR SAVE&LOAD PROCESSES THE VERSION IS VERY IMPORTANT. /// RaC 2012 2nd Hackfest - _currentBBGversion="1.5"; + _currentBBGversion="1.6"; } //========================================================================= @@ -948,7 +948,6 @@ void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event) { } else { std::string pathfilenamebbs = pathfilename; pathfilenamebbs[pathfilenamebbs.length() - 1] = 's'; - if (_tabsMgr->isActualDiagramComplexBox() == false) { std::string name = _tabsMgr->GetNameTabPanel(); if(name[name.length() - 1] == '*') @@ -963,17 +962,23 @@ void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event) { SaveActualDiagram(pathfilename); SaveActualComplexBox(pathfilenamebbs); } //if isActualDiagramComplexBox - std::string pathfilenamepy = pathfilenamebbs; - pathfilenamepy.replace( pathfilenamepy.length()-3, 3 , "py"); - std::string cmdPy("source ~/.bashrc; bbs2 "+pathfilenamebbs+" "+pathfilenamepy); - printf("EED wxGUIEditorGraphicBBS::OnSaveActualDiagram cmd:%s\n", cmdPy.c_str() ); - system( cmdPy.c_str() ); - std::string pathfilenamejs = pathfilenamebbs; - pathfilenamejs.replace( pathfilenamejs.length()-3, 3 , "js"); - std::string cmdjs("source ~/.bashrc; bbs2 "+pathfilenamebbs+" "+pathfilenamejs); - printf("EED wxGUIEditorGraphicBBS::OnSaveActualDiagram cmd:%s\n", cmdjs.c_str() ); - system( cmdjs.c_str() ); - } + if ((getCurrentDiagramExportFormat()==1) || (getCurrentDiagramExportFormat()==2) ) // 1:All 2:bbs,Python + { + std::string pathfilenamepy = pathfilenamebbs; + pathfilenamepy.replace( pathfilenamepy.length()-3, 3 , "py"); + std::string cmdPy("source ~/.bashrc; bbs2 "+pathfilenamebbs+" "+pathfilenamepy); + printf("EED wxGUIEditorGraphicBBS::OnSaveActualDiagram cmd:%s\n", cmdPy.c_str() ); + system( cmdPy.c_str() ); + } // ExportFormat 1 or 2 All and Python + if ((getCurrentDiagramExportFormat()==1) || (getCurrentDiagramExportFormat()==3) ) // 1:All 3:bbs,JavaScript + { + std::string pathfilenamejs = pathfilenamebbs; + pathfilenamejs.replace( pathfilenamejs.length()-3, 3 , "js"); + std::string cmdjs("source ~/.bashrc; bbs2 "+pathfilenamebbs+" "+pathfilenamejs); + printf("EED wxGUIEditorGraphicBBS::OnSaveActualDiagram cmd:%s\n", cmdjs.c_str() ); + system( cmdjs.c_str() ); + } // ExportFormat 1 or 3 All and JavaScript + } // if pathfilename empty } //========================================================================= //DFCH @@ -1481,6 +1486,12 @@ void wxGUIEditorGraphicBBS::setCurrentDiagramAuthor(std::string author) _tabsMgr->SetAuthor(author); } +//========================================================================= +void wxGUIEditorGraphicBBS::setCurrentDiagramExportFormat(int exportformat) +{ + _tabsMgr->SetExportFormat( exportformat ); +} + //========================================================================= void wxGUIEditorGraphicBBS::setCurrentDiagramCategory(std::string category) { @@ -1509,6 +1520,12 @@ std::string wxGUIEditorGraphicBBS::getCurrentDiagramAuthor() return _tabsMgr->GetAuthor(); } +//========================================================================= +int wxGUIEditorGraphicBBS::getCurrentDiagramExportFormat() +{ + return _tabsMgr->GetExportFormat(); +} + //========================================================================= std::string wxGUIEditorGraphicBBS::getCurrentDiagramCategory() { diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h index db79634..bee3528 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h @@ -212,12 +212,14 @@ namespace bbtk void setCurrentDiagramDescription(std::string description); void setCurrentDiagramAuthor(std::string author); + void setCurrentDiagramExportFormat(int exportformat); void setCurrentDiagramCategory(std::string category); void setCurrentDiagramMessageKind(std::string kind); void setCurrentDiagramMessageLevel(std::string level); std::string getCurrentDiagramDescription(); std::string getCurrentDiagramAuthor(); + int getCurrentDiagramExportFormat(); std::string getCurrentDiagramCategory(); std::string getCurrentDiagramMessageKind(); std::string getCurrentDiagramMessageLevel(); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxDiagramPropertiesEditionDialog.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxDiagramPropertiesEditionDialog.cxx index 800ab3c..04b47f7 100755 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxDiagramPropertiesEditionDialog.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxDiagramPropertiesEditionDialog.cxx @@ -103,7 +103,7 @@ namespace bbtk const int ID_COMBO = 1; wxPanel *panel = new wxPanel(this, -1); wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL); - wxFlexGridSizer *fgsizer = new wxFlexGridSizer(8, 2, 9, 25); + wxFlexGridSizer *fgsizer = new wxFlexGridSizer(9, 2, 9, 25); //CFT wxStaticText *tree = new wxStaticText(panel, -1, wxT("Tree of Box")); @@ -190,6 +190,16 @@ wx _diagramMessageLevel->Append (wxT("9")); _diagramMessageLevel->SetEditable(false); + + _exportFormatCB = new wxComboBox(panel, -1, wxT("bbs"), wxDefaultPosition, wxSize(100,-1) ); + _exportFormatCB->Append (wxT("bbs")); + _exportFormatCB->Append (wxT("All (bbs Pyyhon JavaScript)")); + _exportFormatCB->Append (wxT("bbs Python")); + _exportFormatCB->Append (wxT("bbs JavaScript")); + _exportFormatCB->SetEditable(false); + _exportFormatCB->Select( _parent->getCurrentDiagramExportFormat() ); + + //CFT END // SELECTION CONSTANTS @@ -247,6 +257,7 @@ wx _diagramMessageLevel->Select(currentLevel); wxStaticText *type = new wxStaticText(panel, -1, wxT("Type")); + wxStaticText *exportFormat = new wxStaticText(panel, -1, wxT("Export Format")); wxStaticText *author = new wxStaticText(panel, -1, wxT("Author")); wxStaticText *category = new wxStaticText(panel, -1, wxT("Categories")); wxStaticText *description = new wxStaticText(panel, -1, wxT("Description")); @@ -269,9 +280,11 @@ wx _txtDescription->SetValue(crea::std2wx(_parent->getCurrentDiagramDescription())); fgsizer->Add(type); - fgsizer->Add(_diagramType, 1, wxEXPAND); + fgsizer->Add(_diagramType , 1, wxEXPAND); fgsizer->Add(author); - fgsizer->Add(_txtAuthor, 1, wxEXPAND); + fgsizer->Add(_txtAuthor , 1, wxEXPAND); + fgsizer->Add(exportFormat); + fgsizer->Add(_exportFormatCB , 1, wxEXPAND); fgsizer->Add(category); fgsizer->Add(_txtCategory, 1, wxEXPAND); fgsizer->Add(description, 1, wxEXPAND); @@ -307,10 +320,9 @@ wx void wxDiagramPropertiesEditionDialog::onClickOk(wxCommandEvent& event) { - printf("RaC wxDiagramPropertiesEditionDialog::onClickOk\n"); - std::string txtAuthor = wx2std(_txtAuthor->GetValue()); - std::string txtCategory = wx2std(_txtCategory->GetValue()); - std::string txtDescription = wx2std(_txtDescription->GetValue()); + std::string txtAuthor = wx2std(_txtAuthor->GetValue()); + std::string txtCategory = wx2std(_txtCategory->GetValue()); + std::string txtDescription = wx2std(_txtDescription->GetValue()); _parent->setCurrentDiagramAuthor(txtAuthor); _parent->setCurrentDiagramCategory(txtCategory); _parent->setCurrentDiagramDescription(txtDescription); @@ -319,12 +331,24 @@ wx // 0 - Application // 1 - Complex box int selection = _diagramType->GetSelection(); - if(selection == 0) - _parent->disableComplexBox(); - else if (selection == 1) - _parent->enableComplexBox(); - - + if(selection == 0) + { + _parent->disableComplexBox(); + }else { + if (selection == 1) + { + _parent->enableComplexBox(); + } // if selection 1 + } // if selection 0 + + // Export Formats constants + // 0 - bbs + // 1 - ALL - bbs & py & js + // 2 - bbs & py + // 3 - bbs & js + _parent->setCurrentDiagramExportFormat( _exportFormatCB->GetSelection() ); + + //Message std::string kindSelected = wx2std(_diagramMessageKind->GetStringSelection()); std::string levelSelected = wx2std(_diagramMessageLevel->GetStringSelection()); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxDiagramPropertiesEditionDialog.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxDiagramPropertiesEditionDialog.h index 025c79f..348cf76 100755 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxDiagramPropertiesEditionDialog.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxDiagramPropertiesEditionDialog.h @@ -108,17 +108,18 @@ namespace bbtk void OnComboBoxSelected(wxCommandEvent& event); private: - wxAuiManager *_dialogAUIMgr; - wxPanel *_panel; - wxGUIEditorGraphicBBS *_parent; - wxTextCtrl *_txtAuthor; - wxTextCtrl *_txtCategory; - wxTextCtrl *_txtDescription; - wxComboBox *_diagramType; - wxComboBox *_diagramMessageKind; - wxComboBox *_diagramMessageLevel; - wxTreeCtrl *_treeBox; - NodeTreeC _tree; + wxAuiManager *_dialogAUIMgr; + wxPanel *_panel; + wxGUIEditorGraphicBBS *_parent; + wxTextCtrl *_txtAuthor; + wxTextCtrl *_txtCategory; + wxTextCtrl *_txtDescription; + wxComboBox *_diagramType; + wxComboBox *_diagramMessageKind; + wxComboBox *_diagramMessageLevel; + wxComboBox *_exportFormatCB; + wxTreeCtrl *_treeBox; + NodeTreeC _tree; protected: }; diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx index 098d888..ee1aec3 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx @@ -515,6 +515,12 @@ printf("EED wxGEditorTabPanel::getUndoState This mecanisme is not working ????? return _sceneManager->GetAuthor(); } + //========================================================================= + int wxGEditorTabPanel::GetExportFormat() + { + return _sceneManager->GetExportFormat(); + } + //========================================================================= std::string wxGEditorTabPanel::GetDescription() { @@ -549,13 +555,17 @@ printf("EED wxGEditorTabPanel::getUndoState This mecanisme is not working ????? _sceneManager->SetCbPackageName( packagename ); } - //========================================================================= void wxGEditorTabPanel::SetAuthor(std::string author) { _sceneManager->SetAuthor( author ); } + //========================================================================= + void wxGEditorTabPanel::SetExportFormat(int exportformat) + { + _sceneManager->SetExportFormat( exportformat ); + } //========================================================================= void wxGEditorTabPanel::SetCategory(std::string category) diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h index 824030a..8d2bbf5 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h @@ -181,6 +181,7 @@ namespace bbtk void SetCbName(std::string cbName); void SetCbPackageName(std::string packagename); void SetAuthor(std::string author); + void SetExportFormat(int exportformat); void SetCategory(std::string category); void SetDescription(std::string description); void SetMessageKind(std::string kind); @@ -191,6 +192,7 @@ namespace bbtk std::string GetCbName(); std::string GetCbPackageName(); std::string GetAuthor(); + int GetExportFormat(); std::string GetDescription(); std::string GetCategory(); std::string GetMessageKind(); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx index de51abc..6618b14 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx @@ -202,27 +202,26 @@ namespace bbtk { return _actual->getUndoState(stun); } - //========================================================================= + + //========================================================================= unsigned short wxTabPanelsManager::getRedoState(std::string &stre) //FCY { return _actual->getRedoState(stre); } - //========================================================================= + //========================================================================= bool wxTabPanelsManager::isActualDiagramComplexBox() { return _actual->isComplexBox(); } //========================================================================= - void wxTabPanelsManager::setActualDiagramComplexBox(bool val) { _actual->setComplexBox(val); } //========================================================================= - void wxTabPanelsManager::addActualDiagramComplexInputPort(std::string portName) { _actual->addComplexInputPort(portName); @@ -362,6 +361,13 @@ namespace bbtk return _actual->GetAuthor(); } + //========================================================================= + int wxTabPanelsManager::GetExportFormat() + { + return _actual->GetExportFormat(); + } + + //========================================================================= std::string wxTabPanelsManager::GetDescription() { @@ -398,13 +404,17 @@ namespace bbtk _actual->SetCbPackageName( packagename ); } - - //========================================================================= + //========================================================================= void wxTabPanelsManager::SetAuthor(std::string author) { _actual->SetAuthor( author ); } + //========================================================================= + void wxTabPanelsManager::SetExportFormat(int exportformat) + { + _actual->SetExportFormat( exportformat ); + } //========================================================================= void wxTabPanelsManager::SetCategory(std::string category) diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h index 6608c03..f226f95 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h @@ -139,6 +139,7 @@ namespace bbtk void SetCbName(std::string cbName); void SetCbPackageName(std::string packagename); void SetAuthor(std::string author); + void SetExportFormat(int exportformat); void SetCategory(std::string category); void SetDescription(std::string description); void SetMessageKind(std::string kind); @@ -146,6 +147,7 @@ namespace bbtk std::string GetCbName(); std::string GetCbPackageName(); std::string GetAuthor(); + int GetExportFormat(); std::string GetDescription(); std::string GetCategory(); std::string GetMessageKind(); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx index efb1439..9aac1c3 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx @@ -77,6 +77,7 @@ wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView _cbName = "ComplexBoxName"; _cbPackageName = "PackageName"; _Author = "Author ??"; + _ExportFormat = 0; _Category = ""; _Description = "Description ??"; _MessageKind = "-"; @@ -1869,6 +1870,11 @@ void wxVtkSceneManager::saveDiagram(std::string &content) content += GetAuthor(); content += "\n"; + content += "EXPORTFORMAT:"; + sprintf(buffer, "%d", GetExportFormat()) ; + content += buffer; + content += "\n"; + //Print info IF COMPLEX BOX content += "COMPLEXBOX:"; if (_isComplexBox) { @@ -2022,6 +2028,9 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) } if (line == "# - BBTKGEditor v 1.5 BBG BlackBox Diagram file") { version = line.substr(18, 3); + } + if (line == "# - BBTKGEditor v 1.6 BBG BlackBox Diagram file") { + version = line.substr(18, 3); } } else if (line == "APP_START") { start = true; @@ -2054,6 +2063,20 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) result = strtok(authorTmp, delims); result = strtok(NULL, delims); SetAuthor(result); + + if(version >= "1.6") + { + getCleanLine(inputStream, line);//EXPORTFORMAT:<0:bbs 1:ALL 2:bbs,Python 3:bbs,JavaScript> + char authorTmp[255]; + strcpy(authorTmp, line.c_str()); + result = strtok(authorTmp, delims); + result = strtok(NULL, delims); + int exportformatTMP; + std::istringstream inps(result); + inps >> exportformatTMP; + SetExportFormat( exportformatTMP ); + } + } //---------- @@ -3005,33 +3028,52 @@ void wxVtkSceneManager::SetCbPackageName(std::string packagename) { } //========================================================================= -std::string wxVtkSceneManager::GetCbPackageName() { +std::string wxVtkSceneManager::GetCbPackageName() +{ return _cbPackageName; } //========================================================================= -void wxVtkSceneManager::SetAuthor(std::string author) { - _Author = author; - if (_Author == "") { - _Author = ""; - } +void wxVtkSceneManager::SetAuthor(std::string author) +{ + _Author = author; + if (_Author == "") + { + _Author = ""; + } } //========================================================================= -std::string wxVtkSceneManager::GetAuthor() { - return _Author; +std::string wxVtkSceneManager::GetAuthor() +{ + return _Author; +} + +//========================================================================= +void wxVtkSceneManager::SetExportFormat(int exportformat) +{ + _ExportFormat = exportformat; +} + +//========================================================================= +int wxVtkSceneManager::GetExportFormat() +{ + return _ExportFormat; } //========================================================================= -void wxVtkSceneManager::SetCategory(std::string category) { +void wxVtkSceneManager::SetCategory(std::string category) +{ _Category = category; - if (_Category == "") { + if (_Category == "") + { _Category = ""; } } //========================================================================= -std::string wxVtkSceneManager::GetCategory() { +std::string wxVtkSceneManager::GetCategory() +{ return _Category; } diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h index 592ace2..0df261d 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h @@ -232,6 +232,7 @@ namespace bbtk void SetCbName(std::string cbNane); void SetCbPackageName(std::string packagename); void SetAuthor(std::string author); + void SetExportFormat(int exportformat); void SetCategory(std::string category); void SetDescription(std::string description); void SetMessageKind(std::string kind); @@ -239,6 +240,7 @@ namespace bbtk std::string GetCbName(); std::string GetCbPackageName(); std::string GetAuthor(); + int GetExportFormat(); std::string GetCategory(); std::string GetDescription(); std::string GetMessageKind(); @@ -260,6 +262,7 @@ namespace bbtk std::string _cbName; std::string _cbPackageName; std::string _Author; + int _ExportFormat; // 0:bbs 1:All: 2:bbs,Python 3:bbs,JavaScript std::string _Category; std::string _Description; std::string _MessageKind; -- 2.45.1