]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx
Basic functionnality adition showing the black box input ports
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsKernelEditorGraphic / wxVtkSceneManager.cxx
index d9fbd6ce5fb565821c63e2f9a9862ed33abf6257..73dcda3d84d0856026e6eda7b2dce6c55391ee62 100644 (file)
@@ -139,7 +139,7 @@ namespace bbtk
                int type = GBLACKBOX;
 
                //Create the MVC Objects
-               GObjectModel *model = GObjectsMVCFactory::getInstance()->createGObjectModel(type);
+               GBlackBoxModel *model = (GBlackBoxModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type);
                vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
                GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
                
@@ -151,7 +151,23 @@ namespace bbtk
                double zz = 0;
                _baseView->TransCoordScreenToWorld(xx,yy,zz);
                model->setInicPoint(xx,yy,zz);
-               model->updateBlackBox(descriptor);
+               //model->addObserver(view);
+
+               //Iterate and create the input ports
+               std::map<std::string, BlackBoxInputDescriptor*> descriptorMap = descriptor->GetInputDescriptorMap();
+               std::map<std::string, BlackBoxInputDescriptor*>::iterator it;
+
+               //ERASE
+               cantTemp=0;
+
+               for(it = descriptorMap.begin(); it != descriptorMap.end(); ++it)
+               {
+                       BlackBoxInputDescriptor *desc = it->second;
+                       createGInputPort(desc,model);
+                       
+                       //ERASE
+                       cantTemp+=2;
+               }
 
 
                //Associates the view with the correspondent renderer and the  model.
@@ -172,6 +188,56 @@ namespace bbtk
 
        //=========================================================================
 
+       void wxVtkSceneManager::createGInputPort(BlackBoxInputDescriptor *desc,GBlackBoxModel *blackBox)
+       {
+               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);
+
+               model->registerInBox(blackBox);
+               blackBox->addInputPort(model);
+
+               
+               //Prepares the initial model
+               double xx = 0;
+               double yy = 0;
+               double zz = 0;
+               blackBox->getInicPoint(xx,yy,zz);
+
+               xx++;
+               yy+=cantTemp;
+               model->setInicPoint(xx,yy,zz);
+
+               //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);
+       }
+
+       //=========================================================================
+
+       void wxVtkSceneManager::createGOutputPort(BlackBoxOutputDescriptor *desc,GBlackBoxModel *blackBox)
+       {
+               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);
+
+               model->registerInBox(blackBox);
+               blackBox->addOutputPort(model);
+       }
+
+       //=========================================================================
+
        void wxVtkSceneManager::registerController(InteractorStyleMaracas *param)
        {
                vtkInteractorStyleBaseView* baseViewControlManager = (vtkInteractorStyleBaseView*)_baseView->GetInteractorStyleBaseView();