]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx
The actual version updates the status bar with the highlighted object ... Also it...
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsKernelEditorGraphic / wxVtkSceneManager.cxx
index 78ece891bb13c29bcdf5cd1ba7c2fc752074978e..f1f1fed1e047a0ab667d5f178a6c9842c147b749 100644 (file)
@@ -98,7 +98,7 @@ namespace bbtk
 
        //=========================================================================
 
-       void wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName, std::string boxName)
+       void wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName, std::string boxType)
        {
 
                int windowWidth=_baseView->GetRenWin()->GetSize()[0];
@@ -112,7 +112,7 @@ namespace bbtk
                vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
                GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
                
-               BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxName);
+               BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxType);
                
                //Prepares the initial model
                //The coordinates obtained are the following. Top-Left:x=0,y=0 Bottom-Right:x=width,y=height  
@@ -140,7 +140,7 @@ namespace bbtk
                std::string arraystring = stream.str();
 
                model->setBBTKName(arraystring);
-               model->setBBTKType(boxName);
+               model->setBBTKType(boxType);
                model->setBBTKPackage(packageName);
                                
                model->addObserver(view);
@@ -197,19 +197,19 @@ namespace bbtk
 
        void wxVtkSceneManager::createGInputPort(int portType, int posinBox,GBlackBoxModel *blackBox, BlackBoxInputDescriptor *desc)
        {
-               createGPort(portType,posinBox,blackBox);
+               createGPort(portType,desc->GetName(),desc->GetTypeName(),posinBox,blackBox);
        }
 
        //=========================================================================
 
        void wxVtkSceneManager::createGOutputPort(int portType, int posinBox,GBlackBoxModel *blackBox, BlackBoxOutputDescriptor *desc)
        {
-               createGPort(portType,posinBox,blackBox);
+               createGPort(portType,desc->GetName(),desc->GetTypeName(),posinBox,blackBox);
        }
 
        //=========================================================================
 
-       void wxVtkSceneManager::createGPort(int portType, int posInBox,GBlackBoxModel *blackBox)
+       void wxVtkSceneManager::createGPort(int portType,std::string bbtkName, std::string bbtkType, int posInBox,GBlackBoxModel *blackBox)
        {
                int type = GPORT;
 
@@ -221,6 +221,9 @@ namespace bbtk
                model->registerInBox(blackBox,portType, posInBox);
                blackBox->addOutputPort(model);
                
+               model->setBBTKType(bbtkType);
+               model->setBBTKName(bbtkName);
+
                model->addObserver(view);
                model->addObserver(this);
 
@@ -333,65 +336,7 @@ namespace bbtk
        }
        //=========================================================================
 
-       bool wxVtkSceneManager::OnMouseMove()
-       {
-               int X,Y;
-               wxVTKRenderWindowInteractor *wxVTKiren;
-               wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
-               wxVTKiren->GetEventPosition(X,Y);
-       
                
-               if(_worldState == DRAG_OBJECTS)
-               {                       
-                       for (int i=0; i<_selectedObjects.size(); i++)
-                       {
-                               int id = _selectedObjects[i];
-                               GObjectController* cont = _controllers[id];
-                               if(_startDragging)
-                               {
-                                       cont->getView()->setStartDragging(true);
-                               }
-                               cont->getView()->moveObject(X,Y);
-                               cont->getView()->setState(DRAG);
-                               cont->getModel()->notifyObservers(_idManager);
-                       }
-
-                       std::map<int, GObjectController*>::iterator it;
-
-                       for(it = _controllers.begin(); it != _controllers.end(); ++it)
-                       {
-                               GObjectController *desc = it->second;
-                               if(desc->getGObjectType()==GCONNECTOR)
-                               {
-                                       GConnectorView* vconn = (GConnectorView*)desc->getView();
-                                       vconn->updateStartEndPoints();
-                               }
-                       }
-                       
-                       _startDragging=false;
-
-               }
-               else if(_worldState == NOTHING_HAPPENS)
-               {
-                       std::map<int, GObjectController*>::iterator it;
-
-                       for(it = _controllers.begin(); it != _controllers.end(); ++it)
-                       {
-                               GObjectController *desc = it->second;
-                               if(desc->getGObjectType()==GBLACKBOX && desc->getView()->getState() == HIGHLIGHTED)
-                               {
-                                       GBlackBoxModel *mod = (GBlackBoxModel*)desc->getModel();
-                                       _parent->displayBlackBoxInfo(mod->getBBTKPackage(),mod->getBBTKType());
-                               }
-                       }
-               }
-
-
-               return true;
-       }
-
-       //=========================================================================
-       
        void wxVtkSceneManager::update(int idController,int command)
        {
                if(command != NO_COMMAND)
@@ -488,6 +433,73 @@ namespace bbtk
 
        //=========================================================================
 
+       bool wxVtkSceneManager::OnMouseMove()
+       {
+               int X,Y;
+               wxVTKRenderWindowInteractor *wxVTKiren;
+               wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+               wxVTKiren->GetEventPosition(X,Y);
+       
+               
+               if(_worldState == DRAG_OBJECTS)
+               {                       
+                       for (int i=0; i<_selectedObjects.size(); i++)
+                       {
+                               int id = _selectedObjects[i];
+                               GObjectController* cont = _controllers[id];
+                               if(_startDragging)
+                               {
+                                       cont->getView()->setStartDragging(true);
+                               }
+                               cont->getView()->moveObject(X,Y);
+                               cont->getView()->setState(DRAG);
+                               cont->getModel()->notifyObservers(_idManager);
+                       }
+
+                       std::map<int, GObjectController*>::iterator it;
+
+                       for(it = _controllers.begin(); it != _controllers.end(); ++it)
+                       {
+                               GObjectController *desc = it->second;
+                               if(desc->getGObjectType()==GCONNECTOR)
+                               {
+                                       GConnectorView* vconn = (GConnectorView*)desc->getView();
+                                       vconn->updateStartEndPoints();
+                               }
+                       }
+                       
+                       _startDragging=false;
+
+               }
+               else if(_worldState == NOTHING_HAPPENS || _worldState == INIT_CREATION_CONTOUR)
+               {
+                       std::map<int, GObjectController*>::iterator it;
+
+                       for(it = _controllers.begin(); it != _controllers.end(); ++it)
+                       {
+                               GObjectController *desc = it->second;
+                               int type = desc->getGObjectType();
+                               int state = desc->getView()->getState();
+                               
+                               if(state == HIGHLIGHTED){
+
+                                       updateStatusBar(desc->getStatusText());
+                                       if(type==GBLACKBOX)
+                                       {
+                                               GBlackBoxModel *mod = (GBlackBoxModel*)desc->getModel();
+                                               _parent->displayBlackBoxInfo(mod->getBBTKPackage(),mod->getBBTKType());
+                                       }
+                               }
+                       }
+               }
+               
+               
+
+
+               return true;
+       }
+
+       //=========================================================================
        
        bool wxVtkSceneManager::OnLeftButtonDown()
        {
@@ -555,6 +567,15 @@ namespace bbtk
                _parent->displayBlackBoxInfo(packageName,boxName);
        }
 
+       //=========================================================================
+
+       void wxVtkSceneManager::updateStatusBar(std::string textStatus)
+       {
+               _parent->updateStatusBar(textStatus);
+       }
+
+       //=========================================================================
+
 }  // EO namespace bbtk
 
 // EOF