]> Creatis software - bbtkGEditor.git/commitdiff
no message
authordavila <>
Mon, 20 Sep 2010 22:30:16 +0000 (22:30 +0000)
committerdavila <>
Mon, 20 Sep 2010 22:30:16 +0000 (22:30 +0000)
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/InterpreterBBS.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/InterpreterBBS.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h

index 7213b187e38ca2fac776273732396011927225a6..20088210306a3ead5603396abfc1b52601d9b55f 100644 (file)
@@ -46,16 +46,16 @@ Version:   $Revision$
 namespace bbtk
 {
 
-       
-
+       //=========================================================================
        InterpreterBBS::Pointer InterpreterBBS::New( wxVtkSceneManager* sceneManager,  Factory::Pointer factory )
        {
                     return MakePointer( new InterpreterBBS( sceneManager, factory) );
        }
+       //=========================================================================
 
        
+       
        //=========================================================================
-
        InterpreterBBS::InterpreterBBS( wxVtkSceneManager* sceneManager, Factory::Pointer factory )
        {               
                _factory                = factory;
@@ -64,58 +64,84 @@ namespace bbtk
                _xGeneral               = 10;
                _yGeneral               = 10;
                _zGeneral               = 900;   //  ?????
-               
+
+               _complexbox = false;
                bbtk::InterpreterVirtual::Init();
                
        }
-
        //=========================================================================
 
+       
+       //=========================================================================
        InterpreterBBS::~InterpreterBBS()
        {
        }
-
        //=========================================================================
        
        
+       //=========================================================================
        /// Creates a new black box in current complex box
-    void InterpreterBBS::commandNew( const std::string& boxType, const std::string& boxName)
+    void InterpreterBBS::commandNew( const std::string& boxType, const std::string& boxName) // virtual
        {
+               printf("EED InterpreterBBS::New\n");
                std::string packagename = _factory->GetPackageNameOfaBlackBox(boxType);
+               
                int idBox                               = _sceneManager->createGBlackBox( 0,0, packagename ,boxType);
                _sceneManager->configGBlackBox(idBox, _xGeneral,_yGeneral,_zGeneral,boxName, false , _xGeneral+100, _yGeneral-10 , _zGeneral );
+               
                _yGeneral = _yGeneral + 30;
        }
+       //=========================================================================
+
        
+       //=========================================================================
        /// Connects the output boxOutput to the input boxInput
-    void InterpreterBBS::commandConnect (const std::string &boxfrom,
+    void InterpreterBBS::commandConnection (const std::string &boxfrom,
                                                                  const std::string &output,
                                                                  const std::string &boxto,
-                                                                 const std::string &input)
+                                                                 const std::string &input)                     // virtual
        {
                printf("EED InterpreterBBS::Connect\n");
+               _sceneManager->configGConnetion(_complexbox, boxfrom,output,boxto,input);
        }
+       //=========================================================================
        
        
+       //=========================================================================
        /// sets the input of the box with the value
-    void InterpreterBBS::commandSet (const std::string &box, 
-                                                         const std::string &input, 
-                                                         const std::string &value)
+       void InterpreterBBS::commandSet(const std::string &box,const std::string &input,const std::string &value) // virtual
        {
                printf("EED InterpreterBBS::Set\n");
+               GBlackBoxModel *bbMod = _sceneManager->findGBox(box);
+               bbMod->setValueToInput(input,"\""+value+"\"");                                  
        }
+       //=========================================================================
        
 
+       //=========================================================================     
+       void InterpreterBBS::commandDefine(const std::string &name,const std::string &pack,const std::string &scriptfilename) // virtual
+       {
+               _complexbox=true;
+       }
+       //=========================================================================
+
        
-       /// Loads a package
-    void InterpreterBBS::commandLoad(const std::string &name )
+       //=========================================================================
+       void InterpreterBBS::commandEndDefine() // virtual
        {
+               _complexbox=false;
        }
+       //=========================================================================
+       
        
-    /// Unloads a package
-    void InterpreterBBS::commandInclude(const std::string &name )
+       //=========================================================================
+       void InterpreterBBS::commandExec(const std::string &word) // virtual 
        {
+               GBlackBoxModel *bbMod = _sceneManager->findGBox(word);
+               bbMod->setExecutable(true);                             
        }
+       //=========================================================================
+       
        
        
 }  // EO namespace bbtk
index af2626541ae8702125e59242f45fa47994bf1080..400c467201faccc3896e01219aba6007c9d83f17 100644 (file)
@@ -63,151 +63,20 @@ namespace bbtk
                
                //Public methods
 
-               void commandNew( const std::string& boxType, const std::string& boxName);
+               virtual void commandNew( const std::string& boxType, const std::string& boxName);
                
-               void commandConnect (const std::string &boxfrom,
+               virtual void commandConnection (const std::string &boxfrom,
                                      const std::string &output,
                                      const std::string &boxto,
                                      const std::string &input);
-               void commandSet (const std::string &box, 
-                                 const std::string &input, 
-                                 const std::string &value);
-               void commandLoad(const std::string &name );
-               void commandInclude(const std::string &name );
+               virtual void commandSet(const std::string &box,const std::string &input,const std::string &value);
 
 
-               /*
-//--EED
-               
-               /// Sets the inputs of the workspace : 
-               virtual void SetInputs(const std::map<std::string,std::string>& m);
-               
-               /// Puts the executer in "no exec" mode, 
-               /// which creates but does not execute pipelines 
-               virtual void SetNoExecMode(bool b);
-               
-               virtual bool GetNoExecMode() const;
-               
-               /// Sets the mode of dialog of the executer for Root inputs 
-               virtual void SetDialogMode(DialogModeType t);
-               
-               /// Puts the executer in "no error" mode, 
-               /// Errors do not stop execution (but warnings are produced)
-               virtual void SetNoErrorMode(bool b) ;
-               virtual bool GetNoErrorMode() const ;
-               //=================================================================
-               /// Loads a package
-               virtual void LoadPackage(const std::string &name ) ;
-               
-               /// Unloads a package
-               virtual void UnLoadPackage(const std::string &name );
-               
-               /// Starts a package block      
-               virtual void BeginPackage (const std::string &name );
-               
-               /// Ends a package block
-               virtual void EndPackage ();
-               
-               /// Starts the definition of a new ComplexBlackBox in package pack
-               /// scriptfilename is the file from which the def is read
-               virtual void Define (const std::string &name,
-                                                        const std::string& pack,
-                                                        const std::string &scriptfilename);
-               
-               /// Sets the file name to use for the current definition
-               /// (Used to set it after the Define command)
-               virtual void SetCurrentFileName (const std::string &name );
-               
-               /// End the definition of a ComplexBlackBox
-               virtual void EndDefine () ;
-               
-               /// Sets the kind of the currently defined ComplexBlackBox
-               virtual void Kind(const std::string& kind);
-               
-               /// Creates a new black box in current complex box
-               virtual void Create ( const std::string& boxType, const std::string&
-                                                        boxName);
-               
-               /// Destroys a black box
-               virtual void Destroy (const std::string &boxName);
-               
-               /// Clears the currently defined ComplexBlackBox
-               virtual void Clear() ;
-               
-               /// Connects the output boxOutput to the input boxInput
-               virtual void Connect (const std::string &boxfrom,
-                                                         const std::string &output,
-                                                         const std::string &boxto,
-                                                         const std::string &input) ;
-               
-               /// Executes the box 
-               virtual void Execute (const std::string &box) ;
-               
-               /// Defines an input of the current complex box
-               virtual void DefineInput (const std::string &name,
-                                                                 const std::string &box,
-                                                                 const std::string &input,
-                                                                 const std::string &help) ;
-       
-               /// Defines an output of the current complex box
-               virtual void DefineOutput (const std::string &name,
-                                                                  const std::string &box,
-                                                                  const std::string &output,
-                                                                  const std::string &help);
-               
-               /// sets the input of the box with the value
-               virtual void Set (const std::string &box, 
-                                                 const std::string &input, 
-                                                 const std::string &value);
-               
-               /// gets the output of the box
-               virtual std::string Get (const std::string &box, 
-                                                                const std::string &output) ;
-               
-               /// changes the workspace name
-               virtual void SetWorkspaceName( const std::string& n );
-               
-               ///Adds the authorName to the Box author list
-               virtual void Author(const std::string &authorName);
-               
-               ///Adds the categories to the Box categoris list
-               virtual void Category(const std::string &categories);
-               
-               /// The description string which explains what does the ComplexBox
-               virtual void Description(const std::string &d);
-               
-               /// prints the list of the boxes of the current box
-               virtual void PrintHelpListBoxes();
-               
-               /// Generate a HTML file with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
-               virtual std::string ShowGraph(const std::string &nameblackbox, 
-                                                                         const std::string &detailStr, 
-                                                                         const std::string &levelStr,
-                                                                         const std::string &output_file,
-                                                                         const std::string &custom_header,
-                                                                         const std::string &custom_title,
-                                                                         bool system_display = true);
-               
-               /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
-               virtual std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true) ;
-               
-               /// Prints help on a black box
-               virtual void PrintHelpBlackBox(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr);
-               
-               virtual void Reset();
-               
-               /// Sets the level of message for kind
-               virtual void SetMessageLevel(const std::string &kind, int level);
-               
-               /// Prints help on the messages
-               virtual void HelpMessages();
-               
-               /// Prints the string ... MORE : TO EXPLAIN 
-               virtual void Print(const std::string & message);
-               
-//--EED                
-*/
+               virtual void commandDefine(const std::string &name,const std::string &pack,const std::string &scriptfilename);
+               virtual void commandEndDefine();
                
+               virtual void commandExec(const std::string &word);
+
                double              _xGeneral;
                double              _yGeneral;
                double              _zGeneral;
@@ -217,7 +86,7 @@ namespace bbtk
        private:
 
                //Private Attributes
-
+               bool _complexbox;
 
                //Private Methods
 
index 1d3d1078e87b58048394ce7243525539baca6127..26deb1419775f151635a9fbe12aef97804854c84 100644 (file)
@@ -371,9 +371,9 @@ namespace bbtk
                int type = GPORT;
 
                //Create the MVC Objects
-               GPortModel *model = (GPortModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type);
-               vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
-               GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
+               GPortModel *model                               = (GPortModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type);
+               vtkGObjectView *view                    = GObjectsMVCFactory::getInstance()->createGObjectView(type);
+               GObjectController* controller   = GObjectsMVCFactory::getInstance()->createGObjectController(type);
 
                model->registerInBox(blackBox,portType, posInBox);
                
@@ -406,12 +406,12 @@ namespace bbtk
                int type = GCONNECTOR;
 
                manualConnectorContourController* manContourControl     = new manualConnectorContourController();
-               manualConnectorContourView* manContourView      = new manualConnectorContourView();
-               manualContourModel* manContourModel     = new manualContourModel();
+               manualConnectorContourView* manContourView                      = new manualConnectorContourView();
+               manualContourModel* manContourModel                                     = new manualContourModel();
 
-               GConnectorController* connectorcontroller = new GConnectorController();                         
-               GConnectorModel* connectorModel = new GConnectorModel();
-               vtkGConnectorView* connectorView = new vtkGConnectorView();
+               GConnectorController* connectorcontroller                       = new GConnectorController();                           
+               GConnectorModel* connectorModel                                         = new GConnectorModel();
+               vtkGConnectorView* connectorView                                        = new vtkGConnectorView();
                connectorModel->setGObjectType(type);
 
                manContourModel->SetCloseContour(false);
@@ -1639,9 +1639,10 @@ namespace bbtk
                                }
                                
                                int idBox                               = createGBlackBox(xIn,yIn,package,type);
+                               configGBlackBox(idBox, xIn,yIn,zIn,name, boxExecutable,xEn,yEn,zEn);
+                               
                                GObjectController *cont = _controllers[idBox];
                                GBlackBoxModel *bbmod   = (GBlackBoxModel*)cont->getModel();
-                               configGBlackBox(idBox, xIn,yIn,zIn,name, boxExecutable,xEn,yEn,zEn);
                                
                                
 //ups2 eed                             
@@ -1704,11 +1705,14 @@ namespace bbtk
                                result = strtok( NULL, delims );
                                std::string nameEndPort(result);
 
-                               std::vector<int> lstB = getBlackBoxes();
-                               
-                               GPortModel *startP=NULL;
-                               GPortModel *endP=NULL;                          
-                               for(int j = 0;j<lstB.size();j++)
+                               configGConnetion(_isComplexBox, nameStartBox, nameStartPort, nameEndBox, nameEndPort);
+//ups 3 EED Borrame
+/*                             
+                               std::vector<int> lstB   = getBlackBoxes();                              
+                               GPortModel *startP              = NULL;
+                               GPortModel *endP                = NULL;
+                               int j;
+                               for(j = 0;j<lstB.size();j++)
                                {
                                        int idB = lstB[j];
                                        GBlackBoxModel *bbMod = (GBlackBoxModel*)_controllers[idB]->getModel();
@@ -1727,30 +1731,30 @@ namespace bbtk
                                        if(startP==NULL)
                                        {
                                                std::vector<int> lstInputs = getComplexInputPorts();
-                                               for(int j = 0;j<lstInputs.size();j++)
+                                               for(j = 0;j<lstInputs.size();j++)
                                                {
                                                        int idB = lstInputs[j];
                                                        GBoxModel *cbMod = (GBoxModel*)_controllers[idB]->getModel();
                                                        if(_controllers[idB]->getModel()->getBBTKName()==nameStartBox)
                                                        {                                               
                                                                startP = cbMod->getOutputPort(nameStartPort);
-                                                       }
-                                               }
-                                       }
+                                                       } // if 
+                                               } // for
+                                       } // if 
 
                                        if(endP==NULL)
                                        {
                                                std::vector<int> lstOutputs = getComplexOutputPorts();
-                                               for(int j = 0;j<lstOutputs.size();j++)
+                                               for(j = 0;j<lstOutputs.size();j++)
                                                {
                                                        int idB = lstOutputs[j];
                                                        GBoxModel *cbMod = (GBoxModel*)_controllers[idB]->getModel();
                                                        if(_controllers[idB]->getModel()->getBBTKName()==nameEndBox)
                                                        {                                               
                                                                endP = cbMod->getInputPort(nameEndPort);
-                                                       }
-                                               }
-                                       }
+                                                       } // if
+                                               } // for
+                                       } // if endP
                                } // complex box
                                                                
                                int idCon = createGConnector(startP);
@@ -1762,12 +1766,104 @@ namespace bbtk
                                tempp->endContourCreation();
                                conMod->setEndPort(endP);                                       
                                conView->updateStartEndPoints();
-
+ */
                        } // for numConns
+                       
         } // start
 
        }
 
+       //=========================================================================
+       
+       GBlackBoxModel* wxVtkSceneManager::findGBox(std::string boxname)
+       {       
+               GBlackBoxModel *boxModel        = NULL;
+               GBlackBoxModel *bbMod;
+               std::vector<int> lstB           = getBlackBoxes();                              
+               int idB;
+               int j;
+               for(j = 0;j<(int)lstB.size();j++)
+               {
+                       idB = lstB[j];
+                       bbMod = (GBlackBoxModel*)_controllers[idB]->getModel();
+                       if(_controllers[idB]->getModel()->getBBTKName()==boxname)
+                       {                                               
+                               boxModel = bbMod;
+                       }
+               } // for
+               return boxModel;
+       }
+       
+       //=========================================================================
+
+
+       void wxVtkSceneManager::configGConnetion(bool _isComplexBox, 
+                                                                                        std::string nameStartBox, std::string  nameStartPort, std::string  
+                                                                                        nameEndBox, std::string  nameEndPort)
+       {
+               GPortModel *startP              = findGBox(nameStartBox)->getOutputPort(nameStartPort);
+               GPortModel *endP                = findGBox(nameEndBox)->getInputPort(nameEndPort);
+
+/*ups5 EED Borrame
+               std::vector<int> lstB   = getBlackBoxes();                              
+               int j;
+               for(j = 0;j<(int)lstB.size();j++)
+               {
+                       int idB = lstB[j];
+                       GBlackBoxModel *bbMod = (GBlackBoxModel*)_controllers[idB]->getModel();
+                       if(_controllers[idB]->getModel()->getBBTKName()==nameStartBox)
+                       {                                               
+                               startP = bbMod->getOutputPort(nameStartPort);
+                       }
+                       else if(_controllers[idB]->getModel()->getBBTKName()==nameEndBox)
+                       {
+                               endP = bbMod->getInputPort(nameEndPort);
+                       }
+               } // for
+*/             
+               int j;
+               if(_isComplexBox)
+               {
+                       if(startP==NULL)
+                       {
+                               std::vector<int> lstInputs = getComplexInputPorts();
+                               for(j = 0;j<(int)lstInputs.size();j++)
+                               {
+                                       int idB = lstInputs[j];
+                                       GBoxModel *cbMod = (GBoxModel*)_controllers[idB]->getModel();
+                                       if(_controllers[idB]->getModel()->getBBTKName()==nameStartBox)
+                                       {                                               
+                                               startP = cbMod->getOutputPort(nameStartPort);
+                                       } // if 
+                               } // for
+                       } // if 
+                       
+                       if(endP==NULL)
+                       {
+                               std::vector<int> lstOutputs = getComplexOutputPorts();
+                               for(j = 0;j<(int)lstOutputs.size();j++)
+                               {
+                                       int idB = lstOutputs[j];
+                                       GBoxModel *cbMod = (GBoxModel*)_controllers[idB]->getModel();
+                                       if(_controllers[idB]->getModel()->getBBTKName()==nameEndBox)
+                                       {                                               
+                                               endP = cbMod->getInputPort(nameEndPort);
+                                       } // if
+                               } // for
+                       } // if endP
+               } // complex box
+               
+               int idCon = createGConnector(startP);
+               _worldState = NOTHING_HAPPENS;
+               GConnectorController *tempp = (GConnectorController*)_controllers[idCon]; 
+               
+               GConnectorModel *conMod = (GConnectorModel*)tempp->getModel();
+               vtkGConnectorView *conView = (vtkGConnectorView*)tempp->getView();
+               tempp->endContourCreation();
+               conMod->setEndPort(endP);                                       
+               conView->updateStartEndPoints();                
+       }
+
        //=========================================================================
 
        bool wxVtkSceneManager::boxExist(std::string boxname)
index 1c05f16d646c56509b1d3d310f8bd99e8511dc42..03af4240638d6fd8b3f16667233e53bf96364987 100644 (file)
@@ -115,8 +115,13 @@ namespace bbtk
                int createGConnector(GPortModel* startPort);
 
                void configGBlackBox(int idBox, double xIn, double yIn, double zIn, std::string name, bool boxExecutable,double xEn,double yEn,double zEn);
+               void configGConnetion(bool _isComplexBox, 
+                                                         std::string nameStartBox, std::string  nameStartPort, std::string  
+                                                         nameEndBox, std::string  nameEndPort);
+               GBlackBoxModel* findGBox(std::string boxname);
 
                
+               
                vtkRenderWindow* getRenderWindow();
                vtkRenderer* getRenderer();