]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx
The buttons and the objects to create input and output complex box ports were added...
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsKernelEditorGraphic / wxVtkSceneManager.cxx
index 39f1237a99d7524167b9a6bff1e686a87ec91ffb..9b2dc954d20f4527528b5f693f07d63c9d03a18f 100644 (file)
@@ -100,7 +100,6 @@ namespace bbtk
 
        int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName, std::string boxType)
        {
-
                int windowWidth=_baseView->GetRenWin()->GetSize()[0];
                int windowHeight=_baseView->GetRenWin()->GetSize()[1];
 
@@ -196,7 +195,125 @@ namespace bbtk
 
        //=========================================================================
 
-       int wxVtkSceneManager::createGInputPort(int portType, int posinBox,GBlackBoxModel *blackBox, BlackBoxInputDescriptor *desc)
+       int wxVtkSceneManager::createGComplexBoxInputPort(std::string inputName)
+       {
+               int windowWidth=_baseView->GetRenWin()->GetSize()[0];
+               int windowHeight=_baseView->GetRenWin()->GetSize()[1];
+               
+               int type = GCOMPLEXINPUTPORT;
+
+               //Create the MVC Objects
+               
+               GComplexBoxPortModel *model = (GComplexBoxPortModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type);
+               vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
+               GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
+                               
+               //Prepares the initial model 
+
+               double xx = 5;
+               double yy = windowHeight-5;
+               
+               //z value is not important yet, because it is only used a parallel projection
+               double zz = 900;
+
+               _baseView->TransCoordScreenToWorld(xx,yy,zz);
+               model->setInicPoint(xx,yy,zz);
+                               
+               model->setBBTKName(inputName);
+               model->setBBTKType("ComplexInputPort");
+               model->setComplexPortType(type);
+                               
+               model->addObserver(view);
+               model->addObserver(this);
+               
+               //create the output port                
+               GPortController* portController = createGPort(GOUTPUTPORT,inputName,"ComplexInputPort",0,model);
+               model->addOutputPort((GPortModel*)portController->getModel());
+               
+               //Associates the view with the correspondent renderer and the  model.
+               //(NOTE: Refresh is only made by the view)
+               view->setModel(model);
+               view->setBaseView(_baseView);
+               view->initVtkObjects();
+               
+               //Associates the controller with the correspondent model and view
+               controller->setModelAndView(model,view);
+
+               //Resgiter change to the observers of the actual model
+               model->notifyObservers(_idManager);
+               
+               //Register the controller of the new object
+               registerController((InteractorStyleMaracas*) controller);
+
+               //Add the object to the objects list 
+               int newId = _controllers.size();
+               controller->setId(newId);
+               _controllers[newId] = controller;
+               return newId;
+       }
+
+       //=========================================================================
+       
+       int wxVtkSceneManager::createGComplexBoxOutputPort(std::string outputName)
+       {
+               int windowWidth=_baseView->GetRenWin()->GetSize()[0];
+               int windowHeight=_baseView->GetRenWin()->GetSize()[1];
+
+               int type = GCOMPLEXOUTPUTPORT;
+
+               //Create the MVC Objects
+               
+               GComplexBoxPortModel *model = (GComplexBoxPortModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type);
+               vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
+               GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
+                               
+               //Prepares the initial model 
+
+               double xx = 5;
+               double yy = windowHeight-5;
+               
+               //z value is not important yet, because it is only used a parallel projection
+               double zz = 900;
+
+               _baseView->TransCoordScreenToWorld(xx,yy,zz);
+               model->setInicPoint(xx,yy,zz);
+                               
+               model->setBBTKName(outputName);
+               model->setBBTKType("ComplexOutputPort");
+               model->setComplexPortType(type);
+                               
+               model->addObserver(view);
+               model->addObserver(this);
+               
+               //create the output port                
+               GPortController* portController = createGPort(GINPUTPORT,outputName,"ComplexInputPort",0,model);
+               model->addInputPort((GPortModel*)portController->getModel());
+               
+               //Associates the view with the correspondent renderer and the  model.
+               //(NOTE: Refresh is only made by the view)
+               view->setModel(model);
+               view->setBaseView(_baseView);
+               view->initVtkObjects();
+               
+               //Associates the controller with the correspondent model and view
+               controller->setModelAndView(model,view);
+
+               //Resgiter change to the observers of the actual model
+               model->notifyObservers(_idManager);
+               
+               //Register the controller of the new object
+               registerController((InteractorStyleMaracas*) controller);
+
+               //Add the object to the objects list 
+               int newId = _controllers.size();
+               controller->setId(newId);
+               _controllers[newId] = controller;
+               return newId;
+       }
+
+       //=========================================================================
+
+       int wxVtkSceneManager::createGInputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxInputDescriptor *desc)
        {
                GPortController* portController = createGPort(portType,desc->GetName(),desc->GetTypeName(),posinBox,blackBox);
                blackBox->addInputPort((GPortModel*)portController->getModel());
@@ -205,7 +322,7 @@ namespace bbtk
 
        //=========================================================================
 
-       int wxVtkSceneManager::createGOutputPort(int portType, int posinBox,GBlackBoxModel *blackBox, BlackBoxOutputDescriptor *desc)
+       int wxVtkSceneManager::createGOutputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxOutputDescriptor *desc)
        {
                GPortController* portController = createGPort(portType,desc->GetName(),desc->GetTypeName(),posinBox,blackBox);
                blackBox->addOutputPort((GPortModel*)portController->getModel());
@@ -214,7 +331,7 @@ namespace bbtk
 
        //=========================================================================
 
-       GPortController* wxVtkSceneManager::createGPort(int portType,std::string bbtkName, std::string bbtkType, int posInBox,GBlackBoxModel *blackBox)
+       GPortController* wxVtkSceneManager::createGPort(int portType,std::string bbtkName, std::string bbtkType, int posInBox,GBoxModel *blackBox)
        {
                int type = GPORT;