]> Creatis software - bbtkGEditor.git/commitdiff
Changes for saveAs button
authorcaceres <>
Tue, 26 Jul 2011 13:46:51 +0000 (13:46 +0000)
committercaceres <>
Tue, 26 Jul 2011 13:46:51 +0000 (13:46 +0000)
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h

index 57ef4b2ddb7227c2e99960907c2547cb50ba68db..f24749f35c9ff1b69dd4bbe700c4696074c601bc 100644 (file)
@@ -116,7 +116,8 @@ namespace bbtk
                //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_AS_DIAGRAM,_T("Save diagram"),bmp_save, wxNullBitmap, wxITEM_NORMAL,_T("Saves actual diagram"), _T("Saves actual 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
+               //toolbar->AddTool(ID_SAVE_AS_DIAGRAM,_T("Save Diagram As"),bmp_save, wxNullBitmap, wxITEM_NORMAL,_T("Saves the current diagram"), _T("Saves the current diagram")); //DFCH
                toolbar->AddTool(ID_RUN,_T("Run"),bmp_run, wxNullBitmap, wxITEM_NORMAL,_T("Execute actual diagram"), _T("Execute actual diagram"));
                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"));
@@ -137,7 +138,8 @@ namespace bbtk
                // connect command event handlers
                Connect(ID_NEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab));
                Connect(ID_OPEN,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnOpenDiagram));
-               Connect(ID_SAVE_AS_DIAGRAM,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram));
+               Connect(ID_SAVE_DIAGRAM,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram)); //DFCH
+               Connect(ID_SAVE_AS_DIAGRAM,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveAsActualDiagram)); //DFCH
                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));
@@ -162,14 +164,16 @@ namespace bbtk
                // Create File menu and its items
                wxMenu *fileMenu = new wxMenu();
                fileMenu->Append(ID_NEW, _T("New diagram"), _T("New"));
-               fileMenu->Append(ID_SAVE_AS_DIAGRAM, _T("Save diagram"), _T("Save diagram"));
+               fileMenu->Append(ID_SAVE_DIAGRAM, _T("Save Diagram"), _T("Save Diagram")); //DFCH
+               fileMenu->Append(ID_SAVE_AS_DIAGRAM, _T("Save Diagram As"), _T("Save Diagram As")); //DFCH
                fileMenu->Append(ID_OPEN_BBS, _T("Open BBS"), _T("Open BBS"));
                fileMenu->Append(ID_SAVE_AS_BBS, _T("Save BBS"), _T("Save BBS"));
                fileMenu->Append(ID_SAVE_AS_COMPLEXBOX, _T("Save complex box"), _T("Save complex box"));
                fileMenu->Append(wxID_EXIT, _T("E&xit"), _T("Exit"));
 
                Connect(ID_NEW,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab));
-               Connect(ID_SAVE_AS_DIAGRAM,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram));
+               Connect(ID_SAVE_DIAGRAM,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram)); //DFCH
+               Connect(ID_SAVE_AS_DIAGRAM,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveAsActualDiagram));
                Connect(ID_OPEN_BBS,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnOpenBBS));
                Connect(ID_SAVE_AS_BBS,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualBBS));
                Connect(ID_SAVE_AS_COMPLEXBOX,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualComplexBox));
@@ -568,20 +572,20 @@ namespace bbtk
         file.close();
     }
 
-
        //=========================================================================
-       void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event)
+       
+       //The following method allows to save the current diagram asking the filename
+       //DFCH
+       void wxGUIEditorGraphicBBS::SaveCurrentDiagramAs( )
        {
-               wxFileDialog * saveFileDialog = new wxFileDialog(this,wxT("Save  actual diagram"),wxEmptyString,wxT("NewDiagram"),wxT("*.bbg"),wxSAVE|wxOVERWRITE_PROMPT);
+               wxFileDialog * saveFileDialog = new wxFileDialog(this,wxT("Save current diagram"),wxEmptyString,wxT("NewDiagram"),wxT("*.bbg"),wxSAVE|wxOVERWRITE_PROMPT);
                if (saveFileDialog->ShowModal() == wxID_OK)
                {
-            _tabsMgr->SetNameTabPanel( saveFileDialog->GetFilename() );
-
+                       _tabsMgr->SetNameTabPanel( saveFileDialog->GetFilename() );
                        wxString pathfileName       = saveFileDialog->GetPath();
                        std::string pathfilename    = (const char*) (pathfileName.mb_str());
             std::string pathfilenamebbs = pathfilename;
             pathfilenamebbs[pathfilenamebbs.length()-1]='s';
-
             if (_tabsMgr->isActualDiagramComplexBox()==false)
             {
                 SaveActualDiagram( pathfilename );
@@ -593,7 +597,37 @@ namespace bbtk
             } //if isActualDiagramComplexBox
                } // if saveFileDialog
        }
+       //=========================================================================
+       //DFCH
+       void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event)
+       {
+               std::string pathfilename = _tabsMgr->GetCurrentTabPanelPath();
+               if( pathfilename.empty() )
+               {
+                       SaveCurrentDiagramAs();
+               }
+               else
+               {
+                       std::string pathfilenamebbs = pathfilename;
+            pathfilenamebbs[pathfilenamebbs.length()-1]='s';
 
+            if (_tabsMgr->isActualDiagramComplexBox()==false)
+            {
+                SaveActualDiagram( pathfilename );
+                SaveActualBBS(pathfilenamebbs);
+            } else {
+                AskComplexBoxConfiguration();
+                SaveActualDiagram( pathfilename );
+                SaveActualComplexBox(pathfilenamebbs);
+            } //if isActualDiagramComplexBox
+               }               
+       }
+       //=========================================================================
+       //DFCH
+       void wxGUIEditorGraphicBBS::OnSaveAsActualDiagram(wxCommandEvent& event)
+       {
+               SaveCurrentDiagramAs();
+       }
        //=========================================================================
 
        void wxGUIEditorGraphicBBS::refreshGUIControls()
index 3a0b44069e0e3154f27ca078e3fdffa65b0bb693..2cbd7c9163c2e66895906064bf2bb0e7f2d31e45 100644 (file)
@@ -104,7 +104,6 @@ namespace bbtk
                        void initTabPanelsManager();
                        void initPackageBrowser();
                        void initHelpHTMLBrowser();
-
                        wxAuiNotebook* getAuiNotebook();
 
                        // Display the info of the black box highlighted in the PackageBrowser
@@ -127,18 +126,19 @@ namespace bbtk
 
                        // Refresh the state of buttons and menus when changing for example the mode to edit complex box
                        void refreshGUIControls();
-
+                       
             void SaveActualBBS(std::string filename);
             void AskComplexBoxConfiguration();
             void SaveActualComplexBox(std::string filename);
             void SaveActualDiagram(std::string filename);
-
+                       void SaveCurrentDiagramAs( ); //DFCH
 
 
                        // File menu and toolbar events
                        void OnCreateNewTab(wxCommandEvent& event);
                        void OnOpenDiagram(wxCommandEvent& event);
-                       void OnSaveActualDiagram(wxCommandEvent& event);
+                       void OnSaveActualDiagram(wxCommandEvent& event); //DFCH
+                       void OnSaveAsActualDiagram(wxCommandEvent& event); //DFCH
                        void OnOpenBBS(wxCommandEvent& event);
                        void OnSaveActualBBS(wxCommandEvent& event);
                        void OnSaveActualComplexBox(wxCommandEvent& event);
index 6ce48ef3ba30c01c6e209e19cfeac171b717ab51..c44979971df2db8c622a96829e34ebe89070aecb 100644 (file)
@@ -175,6 +175,9 @@ printf("EED wxGEditorTabPanel::initWxVtkCanvas 1\n");
 
        void wxGEditorTabPanel::saveDiagram(std::string &content)
        {
+               this->SetFullPath(content);
+               std::cout<<"wxGEditorTabPanel: " << content <<std::endl;
+               //std::cout<<"wxGEditorTabPanel Real: " << this->_fullPath <<std::endl;
                _sceneManager->saveDiagram(content);
        }
 
@@ -312,10 +315,30 @@ printf("EED wxGEditorTabPanel::initWxVtkCanvas 1\n");
     {
         _sceneManager->SetDescription( description );
     }
-
-
-
-
+    //=========================================================================
+       //DFCH
+       void wxGEditorTabPanel::SetFullPath( const std::string& fullpath )
+       {
+               this->_fullPath = fullpath;
+       }
+       //=========================================================================
+       //DFCH
+       void wxGEditorTabPanel::SetFileName( const std::string& filename )
+       {
+               this->_fileName = filename;
+       }
+       //=========================================================================
+       //DFCH
+       std::string wxGEditorTabPanel::GetFullPath( )
+       {
+               return( this->_fullPath );
+       }
+       //=========================================================================
+       //DFCH
+    std::string wxGEditorTabPanel::GetFileName( )
+    {
+               return( this->_fileName );
+       }
 
 
 
index 43d4a193877e86e4c1ed32f782fc73d03cff366f..e7eb55338344e9ebbb92b4f8b1d31c2cf4ac174f 100644 (file)
@@ -134,12 +134,17 @@ namespace bbtk
 
                wxVtkSceneManager* getSceneManager();
 
-
+               void SetFullPath( const std::string& );
+               void SetFileName( const std::string& );
                void SetCbName(std::string cbName);
         void SetCbPackageName(std::string packagename);
         void SetAuthor(std::string author);
         void SetCategory(std::string category);
         void SetDescription(std::string description);
+        //Getters
+        std::string GetFullPath( );
+        std::string GetFileName( );
+        
         std::string GetCbName();
         std::string GetCbPackageName();
         std::string GetAuthor();
@@ -156,6 +161,8 @@ namespace bbtk
                wxAuiManager                    *_panelAUIMgr;
                wxVtkSceneManager               *_sceneManager;
                wxTabPanelsManager              *_panelsManager;
+               std::string                             _fullPath;
+               std::string                             _fileName;
 
        protected:
 
index 33ad462b69e23b2ad2a1582be76ae18d9de5a0a3..e00c12e9ba1f6ce229886c89765462ef9450e5ff 100644 (file)
@@ -217,13 +217,23 @@ printf("wxTabPanelsManager::VerifyActualTabPanel  %d \n", this->_notebook->GetPa
        {
            return _actual->GetCbName();
        }
-
+       
+       //=========================================================================
        void wxTabPanelsManager::SetNameTabPanel(wxString tabpanelname)
        {
            int id          = _notebook->GetSelection();
            _notebook->SetPageText( id , tabpanelname );
        }
 
+       //=========================================================================
+       //DFCH
+       std::string wxTabPanelsManager::GetCurrentTabPanelPath( )
+       {
+               int id          = _notebook->GetSelection();
+               wxGEditorTabPanel* auxPanel = (wxGEditorTabPanel*) _notebook->GetPage(id);
+               return( auxPanel->GetFullPath( ) );
+           //return ( (wxGEditorTabPanel) _notebook->GetPage(id)->GetFullPath( ) );
+       }
 
 
        //=========================================================================
index 7247d2ac92975a33955c2a4567bfd01966233b94..9d710cdc5020cebb099fa0c441e950a7200a6878 100644 (file)
@@ -108,6 +108,7 @@ namespace bbtk
         std::string GetCategory();
 
            void SetNameTabPanel(wxString tabpanelname);
+           std::string GetCurrentTabPanelPath( ); //DFCH