]> Creatis software - bbtkGEditor.git/commitdiff
It is possible to execute the simplest diagram :) Perfect !!!
authorcorredor <>
Mon, 26 Apr 2010 14:26:11 +0000 (14:26 +0000)
committercorredor <>
Mon, 26 Apr 2010 14:26:11 +0000 (14:26 +0000)
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h
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 acef109612295c56b8a24831a0ffa5eba3c9a68c..5a31568bb1aef6ec1664f3a2a9b92025fb6536e7 100644 (file)
@@ -126,6 +126,13 @@ namespace bbtk
 
        //=========================================================================
 
+       GBlackBoxModel* GPortModel::getParentBox()
+       {
+               return _parentBox;
+       }
+
+       //=========================================================================
+
 }  // EO namespace bbtk
 
 // EOF
index c18e225d0b277d63a0e1cb9d479e099bf5504b48..fd455719a09f25244cf8f200bcbd1b27714cf69c 100644 (file)
@@ -72,6 +72,7 @@ namespace bbtk
                void registerInBox(GBlackBoxModel *blackBox,int portType, int pos);
                void updatePortPosition();
                int getPortType();
+               GBlackBoxModel* getParentBox();
                virtual std::string getStatusText();
 
        private:
index 22d89775f66482ed7e0434caa6e5351cb1ef2649..0420aa3356d8901b591cfa0e8f30e933055cb348 100644 (file)
@@ -576,6 +576,122 @@ namespace bbtk
 
        //=========================================================================
 
+       std::string wxVtkSceneManager::getDiagramScript()
+       {
+               bool existsExec=false;
+
+               std::vector<std::string> packages;
+               std::vector<int> boxes;
+               std::vector<int> connections;
+               std::vector<int> execBoxes;
+
+               std::map<int, GObjectController*>::iterator it;
+
+               for(it = _controllers.begin(); it != _controllers.end(); ++it)
+               {
+                       GObjectController *desc = it->second;
+                       int type = desc->getGObjectType();
+
+                       if(type==GBLACKBOX)
+                       {
+                               GBlackBoxModel *mod = (GBlackBoxModel*)desc->getModel();
+                               
+                               std::string pkg = mod->getBBTKPackage();
+                               bool existsPkg = false;
+                               for(int t = 0;t<packages.size() && existsPkg == false;t++)
+                               {
+                                       if(packages[t]==pkg)
+                                       {
+                                               existsPkg=true;
+                                       }
+                               }
+                               if(!existsPkg)
+                               {
+                                       packages.push_back(pkg);
+                               }
+
+
+                               boxes.push_back(it->first);
+                               if(mod->isExecutable())
+                               {
+                                       execBoxes.push_back(it->first);
+                                       existsExec=true;
+                               }
+                       }
+                       else if(type==GCONNECTOR)
+                       {
+                               connections.push_back(it->first);
+                       }
+               }
+
+               std::string script = "";
+               script+="# BBTK GEditor Script\n";
+               script+="# ----------------------\n";
+               if(existsExec)
+               {
+                       int i;
+                       for(i = 0; i<packages.size();i++)
+                       {
+                               script+="load ";
+                               script+=packages[i];
+                               script+="\n";
+                       }
+
+                       for(i = 0; i<boxes.size();i++)
+                       {
+                               script+="new ";
+                               int id = boxes[i];
+                               GObjectController *control = _controllers[id];
+                               GBlackBoxModel *model = (GBlackBoxModel*)control->getModel();
+
+                               script+=model->getBBTKType();
+                               script+=" ";
+                               script+=model->getBBTKName();
+                               script+="\n";
+                       }
+
+                       for(i = 0; i<connections.size();i++)
+                       {
+                               script+="connect ";
+                               int id = connections[i];
+                               GObjectController *control = _controllers[id];
+                               GConnectorModel *model = (GConnectorModel*)control->getModel();
+
+                               //Start Connection info
+                               GPortModel *start = model->getStartPort();
+                               script+=start->getParentBox()->getBBTKName();
+                               script+=".";
+                               script+=start->getBBTKName();
+
+                               script+=" ";
+
+                               //End Connection info
+                               GPortModel *end = model->getEndPort();
+                               script+=end->getParentBox()->getBBTKName();
+                               script+=".";
+                               script+=end->getBBTKName();
+
+                               script+="\n";
+                       }
+
+                       for(i = 0; i<execBoxes.size();i++)
+                       {
+                               script+="exec ";
+                               int id = execBoxes[i];
+                               GObjectController *control = _controllers[id];
+                               GBlackBoxModel *model = (GBlackBoxModel*)control->getModel();
+
+                               script+=model->getBBTKName();
+                               script+="\n";
+                       }
+
+               }
+
+               return script;
+       }
+
+       //=========================================================================
+
 }  // EO namespace bbtk
 
 // EOF
index 5f1fcc50402b7617c7eb4b7770d491c2fbd49184..3c8c061cd8f8b064c6627b1408e29e1507a42338 100644 (file)
@@ -111,6 +111,8 @@ namespace bbtk
 
                void displayBlackBoxInfo(std::string packageName, std::string boxName);
                void updateStatusBar(std::string textStatus);
+               std::string getDiagramScript();
+
                
        private:
 
index bafa007f88e0dc97733875493bc1da8fca77d973..9c63350ffa8a46baedc00a0693f337a46ef478ca 100644 (file)
@@ -91,14 +91,16 @@ namespace bbtk
                wxToolBar  *_toolbar = new wxToolBar(this, wxID_ANY);
 
                //Adds a tool btn to the toolbar
-               _toolbar->AddTool(wxID_NEW,_T("New"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New tab"), _T("Create a new panel tab"));
+               _toolbar->AddTool(1000,_T("New"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New tab"), _T("Create a new panel tab"));
+               _toolbar->AddTool(1001,_T("Execute"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("Execute actual diagram"), _T("Execute actual diagram"));
 
                _toolbar->SetMargins( 2, 2 );
                _toolbar->Realize();
                SetToolBar(_toolbar);
 
                // connect command event handlers
-               Connect(wxID_NEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnToolLeftClick));
+               Connect(1000,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnToolLeftClick));
+               Connect(1001,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnToolLeftClick));
 
        }
        //=========================================================================
@@ -283,6 +285,50 @@ namespace bbtk
 
        //=========================================================================
 
+       void wxGUIEditorGraphicBBS::executeActualDiagram()
+       {
+               std::string script = _tabsMgr->getActualDiagramScript();
+               cout<<"RaC wxGUIEditorGraphicBBS::executeActualDiagram SCRIPT"<<endl;
+               cout<<script<<endl;
+
+
+               std::string separator = ConfigurationFile::GetInstance().Get_file_separator ();
+               std::string dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
+               std::string filename = dir + separator + "tmp_bbtk.bbs";
+               
+               ofstream tempFile;
+               tempFile.open(filename.c_str());
+               tempFile << script;
+               tempFile.close();
+               
+               std::string command = "\"";
+
+               #ifdef WIN32
+                       command += "\"";
+               #endif
+
+               //command += ConfigurationFile::GetInstance().Get_bin_path();
+               command +="C:/RaC/CREATIS/bbtkBIN/RelWithDebInfo//";
+
+               #ifdef MACOSX
+                       command += separator + "bbi.app/Contents/MacOS/bbi\" ";
+               #else 
+                       command += separator + "bbi\" ";
+               #endif
+               command += "\""+filename + "\"";
+
+               #ifdef WIN32
+                       command += "\"";
+               #endif
+
+               command += " & ";
+                 
+               printf ("RaC wxGUIEditorGraphicBBS::executeActualDiagram %s \n" , command.c_str() );
+               system( command.c_str() );
+       }
+
+       //=========================================================================
+
        /*****************************************************
        /* HANDLERS 
        /*****************************************************/
@@ -291,9 +337,13 @@ namespace bbtk
        {
                switch (event.GetId())
                {
-               case wxID_NEW :
-                       _tabsMgr->addNewTab();
-                       break;                  
+                       case 1000 :
+                               _tabsMgr->addNewTab();
+                       break;  
+
+                       case 1001 :
+                               executeActualDiagram();
+                       break;  
                }
        }
 
index 997f4d3368ea9eefb6cb109c482929a0abcd2d66..d0044ff408117de1582a850164d3b28ddb68862e 100644 (file)
@@ -70,6 +70,8 @@
 #include <wx/grid.h>
 
 //Includes std
+#include <iostream>
+#include <fstream>
 
 namespace bbtk
 {
@@ -91,6 +93,7 @@ namespace bbtk
                wxAuiNotebook* getAuiNotebook();
                void displayBlackBoxInfo(std::string packageName, std::string boxName);
                void updateStatusBar(std::string textStatus);
+               void executeActualDiagram();
 
                void RegenerateAll();
                void DoRegeneratePackageDoc(const std::string& pack);   
index 3171eb227cb86bdcf9563d09c860c36acdded80d..494aa2a75b3afdd89948d438594dccb57c538bbb 100644 (file)
@@ -120,6 +120,13 @@ namespace bbtk
 
        //=========================================================================
 
+       std::string wxGEditorTabPanel::getDiagramScript()
+       {
+               return _sceneManager->getDiagramScript();
+       }
+
+       //=========================================================================
+
 }  // EO namespace bbtk
 
 // EOF
index e3affc59c3597992d38915f734d2283adadba467..507408421157e153629242e7e5613d9b63834148 100644 (file)
@@ -81,6 +81,7 @@ namespace bbtk
 
                void displayBlackBoxInfo(std::string packageName, std::string boxName);
                void updateStatusBar(std::string textStatus);
+               std::string getDiagramScript();
                
        private:
 
index c9e748d3f854c32adb0f6fb57d52d696d47442fc..a8d966ad04659bfc2d73a684bb4042206206c170 100644 (file)
@@ -96,6 +96,13 @@ namespace bbtk
 
        //=========================================================================
 
+       std::string wxTabPanelsManager::getActualDiagramScript()
+       {
+               return _actual->getDiagramScript();
+       }
+
+       //=========================================================================
+
 
 
 }  // EO namespace bbtk
index edf4ca19ec6a86475ad051310091ed91bac91b93..4b5c3beb7ec3e1ba51f0a5d631a85c0cf89e1350 100644 (file)
@@ -74,6 +74,7 @@ namespace bbtk
 
                void displayBlackBoxInfo(std::string packageName, std::string boxName);
                void updateStatusBar(std::string textStatus);
+               std::string getActualDiagramScript();
                
 
        private: