]> Creatis software - bbtkGEditor.git/commitdiff
#3259 Export Format Python and JavaScript vtk9itk5wx3-macos
authoreduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Sun, 18 Feb 2024 17:07:54 +0000 (18:07 +0100)
committereduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Sun, 18 Feb 2024 17:07:54 +0000 (18:07 +0100)
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxDiagramPropertiesEditionDialog.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxDiagramPropertiesEditionDialog.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h

index 02c8c3f1d0e70f91667a081101e9430018bc82e3..48f80b994cc648b58a4aade2a10a3e91a570c30a 100644 (file)
@@ -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()
 {
index db79634cf4a750c6871fcd88842fb10b76973283..bee3528bc7943bc2ae4b5dd31c59d6bdd33e8cc3 100644 (file)
@@ -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();
index 800ab3c9df88fe581969056abca5383aba444cd1..04b47f74b28371bb1857b724129f1af8bff13cbd 100755 (executable)
@@ -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());
index 025c79fcbe4e12815eafffd4dbf3e389031c9f2f..348cf7652bdd09627a02c9d80d76181983e0f874 100755 (executable)
@@ -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:
 
        };
index 098d888a014d3203b1b06dd02b42af7b8e87189b..ee1aec3cab94e154b19d8ff915a00f47cdb0c73e 100644 (file)
@@ -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)
index 824030ae67ebd5ba6ae327a83fa0120c4f9747bd..8d2bbf59a4b35ec0d3ede92b6d06d02731fc8ba3 100644 (file)
@@ -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();
index de51abcf4a57e4b43dfa66ef6a5968c1838a7ab2..6618b14448e994dcffb48a8be4061103194c6805 100644 (file)
@@ -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)
index 6608c0325995966c8c11cf1c970fa8bee49e361e..f226f95aba6fa086e5e3cb88f281ccd4240b2225 100644 (file)
@@ -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();
index efb1439428e855a87277153dd4c4bef69c5aedbd..9aac1c3b0350d6da01270f3a96ed44618cf6a9a6 100644 (file)
@@ -77,6 +77,7 @@ wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView
        _cbName                                 = "ComplexBoxName";
        _cbPackageName                  = "PackageName";
        _Author                                 = "Author ??";
+    _ExportFormat           = 0;
        _Category                               = "<VOID>";
        _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 = "<author of the box>";
-       }
+void wxVtkSceneManager::SetAuthor(std::string author) 
+{
+    _Author = author;
+    if (_Author == "") 
+    {
+        _Author = "<author of the box>";
+    }
 }
 
 //=========================================================================
-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 = "<category of the box>";
        }
 }
 
 //=========================================================================
-std::string wxVtkSceneManager::GetCategory() {
+std::string wxVtkSceneManager::GetCategory() 
+{
        return _Category;
 }
 
index 592ace2948c7b52591af508705907aea53cb5dc8..0df261de6d2ca59c5a333425c0b6086375378707 100644 (file)
@@ -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;