]> Creatis software - bbtkGEditor.git/commitdiff
Organizing code, the state now is in the view and the general render was simplified...
authorcorredor <>
Fri, 16 Apr 2010 13:54:16 +0000 (13:54 +0000)
committercorredor <>
Fri, 16 Apr 2010 13:54:16 +0000 (13:54 +0000)
22 files changed:
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/Observable.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/Observable.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/Observer.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/Observer.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.h

index fa165c00025cb01af49b93ed80de4d5cad4abee5..bdaf53d5bdd86ff03422a2feb74dec78965c6c83 100644 (file)
@@ -97,35 +97,19 @@ namespace bbtk
                int i;
                for(i=0;i<_inputs.size();i++)
                {
-                       _inputs[i]->updatePortPosition(i);
+                       _inputs[i]->updatePortPosition();
                }
                
                //Refresh outputs position
                for(i=0;i<_outputs.size();i++)
                {
-                       _outputs[i]->updatePortPosition(i);
+                       _outputs[i]->updatePortPosition();
                }
 
        }
        
        //=========================================================================
 
-       GPortModel* GBlackBoxModel::getStartOutputPort()
-       {
-               GPortModel* temp = NULL;
-
-               for(int i=0; i<_inputs.size() && temp == NULL;i++)
-               {
-                       if(_outputs[i]->getState() == CREATING_CONTOUR)
-                       {
-                               temp = _outputs[i];
-                       }
-               }
-
-               return temp;
-       }
-
-       //=========================================================================
 
 
 }  // EO namespace bbtk
index 15d0d397a662bcbef673534f217f3995c184cb35..bd863cc2e686b836f123cc3bf2b52a51514d06c0 100644 (file)
@@ -50,7 +50,6 @@ namespace bbtk
                _xFin = 0;
                _yFin = 0;
                _zFin = 900;
-               _state = NOTHING_HAPPENS;
        }
 
        //=========================================================================
@@ -100,20 +99,6 @@ namespace bbtk
        }
        //=========================================================================
 
-       void GObjectModel::setState(int state)
-       {
-               _state = state;
-       }
-
-       //=========================================================================
-
-       int GObjectModel::getState()
-       {
-               return _state;
-       }
-
-       //=========================================================================
-
        void GObjectModel::setGObjectType(int gObjectType)
        {
                _gObjectType = gObjectType;
index 43f4591d206bc0e1e2a1fa294b46a76fdd0a588f..5c3deea3dd6361793a1af444f758c4920d3522a5 100644 (file)
@@ -74,8 +74,7 @@ namespace bbtk
                void getCenter(double& x, double& y, double& z);
                virtual void setInicPoint(double& x, double& y, double& z);
                virtual void setFinalPoint(double& x, double& y, double& z);
-               void setState(int state);
-               int getState();
+               
                virtual void move(double xx,double yy,double zz);
 
                virtual bool isPointInside(double x,double y, double z);
@@ -107,7 +106,6 @@ namespace bbtk
                double _yFin;
                double _zFin;
 
-               int  _state;
                int  _gObjectType;
 
                std::string _bbtkType;
index 8672eedafa918db517bcf5bbbcdf57f08269982a..50b0fd6c39c8aa4abc1ef6bd4900adde01ddb594 100644 (file)
@@ -45,6 +45,7 @@ namespace bbtk
        {               
                _parentBox = NULL;
                _portType=-1;
+               _posInBox=0;
        }
 
        //=========================================================================
@@ -57,14 +58,15 @@ namespace bbtk
        {
                _parentBox = blackBox;
                _portType = portType;
+               _posInBox = pos;
 
-               updatePortPosition(pos);
+               updatePortPosition();
 
        }
 
        //=========================================================================
 
-       void GPortModel::updatePortPosition(int pos)
+       void GPortModel::updatePortPosition()
        {
                double xInic, yInic,zInic,xFin,yFin,zFin;
                _parentBox->getInicPoint(xInic,yInic,zInic);
@@ -80,8 +82,8 @@ namespace bbtk
                        posY = yFin;
                }
 
-               //Variable 'pos' starts with value 0 and it represents the position of the port in the box from left to right
-               posX = xInic + PORT_WIDTH + pos*2*PORT_WIDTH;
+               //Attribute '_posInBox' starts with value 0 and it represents the position of the port in the box from left to right
+               posX = xInic + PORT_WIDTH + _posInBox*2*PORT_WIDTH;
                
                setInicPoint(posX,posY,posZ);
 
index 1a32e09cee6d3865c676cc04c920ccb9afc613b2..9f731cc6fb3f0df17a9f34cf230ccfe27af79e78 100644 (file)
@@ -70,7 +70,7 @@ namespace bbtk
                
                //Public methods                
                void registerInBox(GBlackBoxModel *blackBox,int portType, int pos);
-               void updatePortPosition(int pos);
+               void updatePortPosition();
                int getPortType();
 
        private:
@@ -80,6 +80,7 @@ namespace bbtk
                GBlackBoxModel *_parentBox;
 
                int _portType;
+               int _posInBox;
 
                //Private Methods
 
index 82c51961e7a57849474a958e523fdb37d6c83a12..c52934c2c3cfa1e1128a9a0f77811b2f69b5fb31 100644 (file)
@@ -59,14 +59,14 @@ namespace bbtk
 
        //=========================================================================
        
-       void Observable::notifyObservers(int command)
+       void Observable::notifyObservers(int idObservable,int command)
        {
                if(_changed)
                {
                        int i;
                        for(i=0;i<_observers.size();i++)
                        {
-                               _observers[i]->update(command);
+                               _observers[i]->update(idObservable,command);
                        }
                        _changed=false;
                }
index a55b17de2f01fead3dbf9a05a6afda2eb1df143c..a165b9eb0e41f84be363abcf83f5597341452b43 100644 (file)
@@ -71,7 +71,7 @@ namespace bbtk
 
                bool hasChanged();
 
-               void notifyObservers(int command=REPAINT);
+               void notifyObservers(int idObservable=-1,int command=REPAINT);
                     
                void setChanged();
 
index d80b07d74a2bae14eba94be65ff52812f377cafe..80dd23b1ff62fe49372a608ce21bf122f4b6cd41 100644 (file)
@@ -52,7 +52,7 @@ namespace bbtk
        }
        //=========================================================================
 
-       void Observer::update(int command) //virtual
+       void Observer::update(int idObservable,int command) //virtual
        {
                //virtual
        }
index bd0e34560f9772dc8e1e81136cd5ae65f680bad3..9b9fa8c26e93f0c41fc87d198d9180db14630c70 100644 (file)
@@ -59,7 +59,7 @@ namespace bbtk
                ~Observer();
                
                //Public methods
-               virtual void update(int command);
+               virtual void update(int idObservable,int command);
                
                
        private:
index 8592cc116e55f4abbc6d408bc4d4a7fa7fa82714..23ea678c0a0d21ca6bfe58265e8a10e5256724d4 100644 (file)
@@ -135,14 +135,18 @@ namespace bbtk
 
 
        //=========================================================================
+
        void wxVtkSceneManager::disconnectDrop()
        {
                _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget(NULL);
        }
+
        //=========================================================================
+
        wxVtkSceneManager::~wxVtkSceneManager()
        {
        }
+
        //=========================================================================
 
        void wxVtkSceneManager::configureBaseView()
@@ -158,9 +162,8 @@ namespace bbtk
                interactorstylebaseview->SetwxVtkBaseView(_baseView);
                
                _baseView->GetRenderer()->GetActiveCamera()->ParallelProjectionOn();
-               _baseView->GetRenderer()->ResetCamera(-100,100,-100,100,900,900);
+               _baseView->GetRenderer()->ResetCamera(-100,100,-100,100,900,1000);
                
-
                _baseView->GetRenderer()->SetBackground(0.9,0.9,0.9);
                _baseView->GetRenderer()->GradientBackgroundOff();
                _baseView->Refresh();
@@ -199,7 +202,15 @@ namespace bbtk
                int cantObjects = _objects.size();
                cantObjects++;
                std::stringstream stream;
-               stream << "Box:Algo " << cantObjects;
+               
+               if(cantObjects<10)
+               {
+                       stream << "Box0" << cantObjects;
+               }
+               else
+               {
+                       stream << "Box" << cantObjects;
+               }
                std::string arraystring = stream.str();
 
                model->setBBTKName(arraystring);
@@ -216,7 +227,7 @@ namespace bbtk
                for(itInput = descriptorInMap.begin(); itInput != descriptorInMap.end(); ++itInput)
                {
                        BlackBoxInputDescriptor *desc = itInput->second;
-                       createGInputPort(desc,model,i);
+                       createGInputPort(GINPUTPORT,i,model,desc);
                        i++;
                }
 
@@ -228,7 +239,7 @@ namespace bbtk
                for(itOutput = descriptorOutMap.begin();itOutput != descriptorOutMap.end(); ++itOutput)
                {
                        BlackBoxOutputDescriptor *desc = itOutput->second;
-                       createGOutputPort(desc,model,i);
+                       createGOutputPort(GOUTPUTPORT,i,model,desc);
                        i++;
                }
 
@@ -249,44 +260,32 @@ namespace bbtk
                //Register the controller of the new object
                registerController((InteractorStyleMaracas*) controller);
 
-               //Add the object to the objects list (only boxes and connectors)
-               _objects.push_back(model);
+               //Add the object to the objects list 
+               _objects.push_back(controller);
+
+               int newId = _controllers.size();
+               controller->setId(newId);
+               _controllers[newId] = controller;
 
        }
 
        //=========================================================================
 
-       void wxVtkSceneManager::createGOutputPort(BlackBoxOutputDescriptor *desc,GBlackBoxModel *blackBox, int pos)
+       void wxVtkSceneManager::createGInputPort(int portType, int posinBox,GBlackBoxModel *blackBox, BlackBoxInputDescriptor *desc)
        {
-               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,GOUTPUTPORT, pos);
-               blackBox->addOutputPort(model);
-               
-               model->addObserver(view);
-               model->addObserver(this);
+               createGPort(portType,posinBox,blackBox);
+       }
 
-               //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);
+       //=========================================================================
 
-               //Register the controller of the new object
-               registerController((InteractorStyleMaracas*) controller);
+       void wxVtkSceneManager::createGOutputPort(int portType, int posinBox,GBlackBoxModel *blackBox, BlackBoxOutputDescriptor *desc)
+       {
+               createGPort(portType,posinBox,blackBox);
        }
 
        //=========================================================================
 
-       void wxVtkSceneManager::createGInputPort(BlackBoxInputDescriptor *desc,GBlackBoxModel *blackBox, int pos)
+       void wxVtkSceneManager::createGPort(int portType, int posInBox,GBlackBoxModel *blackBox)
        {
                int type = GPORT;
 
@@ -295,9 +294,9 @@ namespace bbtk
                vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
                GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
 
-               model->registerInBox(blackBox,GINPUTPORT,pos);
-               blackBox->addInputPort(model);
-
+               model->registerInBox(blackBox,portType, posInBox);
+               blackBox->addOutputPort(model);
+               
                model->addObserver(view);
                model->addObserver(this);
 
@@ -310,8 +309,14 @@ namespace bbtk
                //Associates the controller with the correspondent model and view
                controller->setModelAndView(model,view);
 
+               model->notifyObservers();
+
                //Register the controller of the new object
                registerController((InteractorStyleMaracas*) controller);
+               
+               int newId = _controllers.size();
+               controller->setId(newId);
+               _controllers[newId] = controller;
        }
 
        //=========================================================================
@@ -380,25 +385,25 @@ namespace bbtk
 
        //=========================================================================
        
-       void wxVtkSceneManager::update(int command)
+       void wxVtkSceneManager::update(int idObservable,int command)
        {
                
                if(command==INIT_CREATION_CONTOUR)
-               {
-                       for(int i = 0; i<_objects.size();i++)
+               {       
+                       GObjectController* cont = _controllers[idObservable];
+                       if(cont->getGObjectType() == GPORT)
                        {
-                               if(_objects[i]->getGObjectType() == GBLACKBOX)
-                               {
-                                       
-                                       GPortModel* startOutputPort=((GBlackBoxModel*)_objects[i])->getStartOutputPort();
-                                       createGConnector(startOutputPort);
+                               GPortController* controller = (GPortController*)cont;
+                               vtkGPortView* view = (vtkGPortView*)controller->getView();
 
-                               }
-                               else
+                               if(view->getState() == CREATING_CONTOUR)
                                {
-                                       // The others must not react to events
+                                       //pre: The port in this state is an output port                                 
+                                       GPortModel* startOutputPort = (GPortModel*)controller->getModel();
+                                       createGConnector(startOutputPort);
                                }
                        }
+                       
                }
        }
 
index e1dccfcfd45f8b357bc143f9e564cc084ddcc409..f539e92ea3732e2fa315c59baad635c6839b2d4e 100644 (file)
@@ -47,6 +47,7 @@ Version:   $Revision$
 #include "GObjectsMVCFactory.h"
 #include "Observer.h"
 #include "GPortModel.h"
+#include "vtkGPortView.h"
 #include "GConnectorView.h"
 
 //Includes bbtk
@@ -85,8 +86,9 @@ namespace bbtk
 
                void configureBaseView();
                void createGBlackBox(int x, int y,std::string packageName, std::string boxName);
-               void createGInputPort(BlackBoxInputDescriptor *desc,GBlackBoxModel *blackBox, int pos);
-               void createGOutputPort(BlackBoxOutputDescriptor *desc,GBlackBoxModel *blackBox, int pos);
+               void createGPort(int portType, int posinBox,GBlackBoxModel *blackBox);
+               void createGInputPort(int portType, int posinBox,GBlackBoxModel *blackBox, BlackBoxInputDescriptor *desc);
+               void createGOutputPort(int portType, int posinBox,GBlackBoxModel *blackBox, BlackBoxOutputDescriptor *desc);
                void createGConnector(GPortModel* startPort);
 
                void registerController(InteractorStyleMaracas *param);
@@ -98,15 +100,15 @@ namespace bbtk
                
                virtual bool OnMouseMove();
 
-               virtual void update(int command);
+               virtual void update(int idObservable,int command);
                
        private:
 
                int _id;
                wxVtk3DBaseView *_baseView;
 
-               std::vector<GObjectModel*> _objects;
-               std::vector<GObjectModel*> _selectedObjects;
+               std::vector<GObjectController*> _objects;
+               std::map<int,GObjectController*> _controllers;
 
        protected:
 
index cf4037ed249cf742a07c863e7117953f1cb5d9ae..952e9a908592691254924a9227969f3e096eca3e 100644 (file)
@@ -62,7 +62,7 @@ namespace bbtk
                        _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
                        _wxVTKiren->GetEventPosition( X , Y );
 
-                       int state  = _model->getState();
+                       int state  = _view->getState();
                        
                        //Evaluate new state
                        if(!_model->hasChanged() && state == DRAG)
@@ -75,7 +75,7 @@ namespace bbtk
                        {
                                if(_view->isPointInside(X,Y))
                                {
-                                       _model->setState(HIGHLIGHTED);
+                                       _view->setState(HIGHLIGHTED);
                                        _model->setChanged();                           
                                }                       
                        }
@@ -83,12 +83,13 @@ namespace bbtk
                        {
                                if(!_view->isPointInside(X,Y))
                                {
-                                       _model->setState(NOTHING_HAPPENS);
+                                       _view->setState(NOTHING_HAPPENS);
                                        _model->setChanged();
                                }
                        }
                        
-                       _model->notifyObservers();
+                       _model->notifyObservers(_id);
+                       
                }
                return true;
        }
@@ -105,13 +106,13 @@ namespace bbtk
                        wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
                        wxVTKiren->GetEventPosition(X,Y);
 
-                       int state  = _model->getState();
+                       int state  = _view->getState();
                        
                        //Evaluate new state
                        if(!_model->hasChanged() && state==HIGHLIGHTED)
                        {
                                _view->isStartDragging(true);
-                               _model->setState(DRAG);
+                               _view->setState(DRAG);
                                _model->setChanged();
                        }
 
@@ -120,12 +121,12 @@ namespace bbtk
                                if(_view->isPointInside(X,Y))
                                {
                                        _view->isStartDragging(true);
-                                       _model->setState(DRAG);
+                                       _view->setState(DRAG);
                                        _model->setChanged();
                                }       
                        }
                        
-                       _model->notifyObservers();
+                       _model->notifyObservers(_id);
                }
                return true;
        }
@@ -141,22 +142,22 @@ namespace bbtk
                        wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
                        wxVTKiren->GetEventPosition(X,Y);
 
-                       int state  = _model->getState();
+                       int state  = _view->getState();
                        
                        //Evaluate new state
                        if(!_model->hasChanged() && state==CLICKED)
                        {
-                               _model->setState(SELECTED);
+                               _view->setState(SELECTED);
                                _model->setChanged();
                        }
 
                        if( !_model->hasChanged() && state == DRAG)
                        {
-                               _model->setState(SELECTED);
+                               _view->setState(SELECTED);
                                _model->setChanged();
                        }
 
-                       _model->notifyObservers();
+                       _model->notifyObservers(_id);
 
                }
                return true;
@@ -173,7 +174,7 @@ namespace bbtk
                        wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
                        wxVTKiren->GetEventPosition(X,Y);
 
-                       _model->notifyObservers();
+                       _model->notifyObservers(_id);
                }
                return true;
        }
@@ -189,19 +190,19 @@ namespace bbtk
                        wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
                        wxVTKiren->GetEventPosition(X, Y);
                        
-                       int state  = _model->getState();
+                       int state  = _view->getState();
                        
                        //Evaluate new state
                        if( !_model->hasChanged() && state == SELECTED)
                        {
-                               _model->setState(NOTHING_HAPPENS);
+                               _view->setState(NOTHING_HAPPENS);
                                _model->setChanged();                   
                        }
 
-                       _model->notifyObservers();
+                       _model->notifyObservers(_id);
                }
                return true;
-}
+       }
 
        //=========================================================================
 
index b6baee4803b35f4c9499e85dd7269ae376263b02..66ca3659aa0155b224bb58c53bbed4e2174cb25a 100644 (file)
@@ -72,6 +72,7 @@ namespace bbtk
                virtual bool  OnLeftDClick();
                virtual bool  OnRightButtonDown();
 
+
        private:
 
                //Attributes
index 6b1174ff43faa6425f71f49d1a29e053ceaa1fbc..0dffa0ec1a4d4d929ca092bde21663c4445e8e50 100644 (file)
@@ -47,9 +47,11 @@ namespace bbtk
        }
 
        //=========================================================================
+       
        GObjectController::~GObjectController()
        {
        }
+
        //=========================================================================
 
        void GObjectController::setModelAndView(GObjectModel* model, vtkGObjectView* view)
@@ -57,183 +59,228 @@ namespace bbtk
                _model = model;
                _view = view;
        }
-       //=========================================================================
 
-bool GObjectController::OnMouseMove()
-{
-       
-       /**********************   VIRTUAL *************************/
+       //=========================================================================
 
-       if ( _vtkInteractorStyleBaseView!=NULL)
+       bool GObjectController::OnMouseMove()
        {
-               int X,Y;
-               wxVTKRenderWindowInteractor *_wxVTKiren;
-               _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
-               _wxVTKiren->GetEventPosition( X , Y );
-
-               int state  = _model->getState();
                
-               //Evaluate new state
-               if(!_model->hasChanged() && state == DRAG)
-               {
-                       moveObject(X,Y);
-                       _model->setChanged();
-               }
+               /**********************   VIRTUAL *************************/
 
-               if(!_model->hasChanged() && state == NOTHING_HAPPENS)
-               {
-                       if(_view->isPointInside(X,Y))
-                       {
-                               _model->setState(HIGHLIGHTED);
-                               _model->setChanged();                           
-                       }                       
-               }
-               if(!_model->hasChanged() && state==HIGHLIGHTED)
+               if ( _vtkInteractorStyleBaseView!=NULL)
                {
-                       if(!_view->isPointInside(X,Y))
+                       int X,Y;
+                       wxVTKRenderWindowInteractor *_wxVTKiren;
+                       _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+                       _wxVTKiren->GetEventPosition( X , Y );
+
+                       int state  = _view->getState();
+                       
+                       //Evaluate new state
+                       if(!_model->hasChanged() && state == DRAG)
                        {
-                               _model->setState(NOTHING_HAPPENS);
+                               moveObject(X,Y);
                                _model->setChanged();
                        }
+
+                       if(!_model->hasChanged() && state == NOTHING_HAPPENS)
+                       {
+                               if(_view->isPointInside(X,Y))
+                               {
+                                       _view->setState(HIGHLIGHTED);
+                                       _model->setChanged();                           
+                               }                       
+                       }
+                       if(!_model->hasChanged() && state==HIGHLIGHTED)
+                       {
+                               if(!_view->isPointInside(X,Y))
+                               {
+                                       _view->setState(NOTHING_HAPPENS);
+                                       _model->setChanged();
+                               }
+                       }
+                       
+                       _model->notifyObservers(_id);
+                       
                }
-               
-               _model->notifyObservers();
-       }
 
-       /**/
+               /**/
 
-       return true;
-}
-//=========================================================================
-bool GObjectController::OnLeftButtonDown()
-{
-       /**********************   VIRTUAL *************************
+               return true;
+       }
+
+       //=========================================================================
        
-       if ( _vtkInteractorStyleBaseView!=NULL )
+       bool GObjectController::OnLeftButtonDown()
        {
-               int X,Y;
-               wxVTKRenderWindowInteractor *wxVTKiren;
-               wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
-               wxVTKiren->GetEventPosition(X,Y);
-
-               int state  = _model->getState();
+               /**********************   VIRTUAL *************************
                
-               //Evaluate new state
-               if(!_model->hasChanged() && state==HIGHLIGHTED)
-               {
-                       _view->isStartDragging(true);
-                       _model->setState(DRAG);
-                       _model->setChanged();
-               }
-
-               if( !_model->hasChanged() && state == SELECTED)
+               if ( _vtkInteractorStyleBaseView!=NULL )
                {
-                       if(_view->isPointInside(X,Y))
+                       int X,Y;
+                       wxVTKRenderWindowInteractor *wxVTKiren;
+                       wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+                       wxVTKiren->GetEventPosition(X,Y);
+
+                       int state  = _model->getState();
+                       
+                       //Evaluate new state
+                       if(!_model->hasChanged() && state==HIGHLIGHTED)
                        {
                                _view->isStartDragging(true);
                                _model->setState(DRAG);
                                _model->setChanged();
-                       }       
+                       }
+
+                       if( !_model->hasChanged() && state == SELECTED)
+                       {
+                               if(_view->isPointInside(X,Y))
+                               {
+                                       _view->isStartDragging(true);
+                                       _model->setState(DRAG);
+                                       _model->setChanged();
+                               }       
+                       }
+                       
+                       _model->notifyObservers();
                }
-               
-               _model->notifyObservers();
+
+               */
+
+               return true;
        }
 
-       */
+       //=========================================================================
+       
+       bool GObjectController::OnLeftButtonUp()
+       {
 
-       return true;
-}
-//=========================================================================
-bool GObjectController::OnLeftButtonUp()
-{
+               /**********************   VIRTUAL *************************
+
+               if ( _vtkInteractorStyleBaseView!=NULL )
+               {
+                       int X,Y;
+                       wxVTKRenderWindowInteractor *wxVTKiren;
+                       wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+                       wxVTKiren->GetEventPosition(X,Y);
+
+                       int state  = _model->getState();
+                       
+                       //Evaluate new state
+                       if(!_model->hasChanged() && state==CLICKED)
+                       {
+                               _model->setState(SELECTED);
+                               _model->setChanged();
+                       }
+
+                       if( !_model->hasChanged() && state == DRAG)
+                       {
+                               _model->setState(SELECTED);
+                               _model->setChanged();
+                       }
+
+                       _model->notifyObservers();
+
+               }
 
-       /**********************   VIRTUAL *************************
+               */
+               return true;
+       }
 
-       if ( _vtkInteractorStyleBaseView!=NULL )
+       //=========================================================================
+       
+       bool GObjectController::OnLeftDClick()
        {
-               int X,Y;
-               wxVTKRenderWindowInteractor *wxVTKiren;
-               wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
-               wxVTKiren->GetEventPosition(X,Y);
+               /**********************   VIRTUAL *************************
 
-               int state  = _model->getState();
-               
-               //Evaluate new state
-               if(!_model->hasChanged() && state==CLICKED)
+               if ( _vtkInteractorStyleBaseView!=NULL )
                {
-                       _model->setState(SELECTED);
-                       _model->setChanged();
+                       int X,Y;
+                       wxVTKRenderWindowInteractor *wxVTKiren;
+                       wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+                       wxVTKiren->GetEventPosition(X,Y);
+
+                       _model->notifyObservers();
                }
 
-               if( !_model->hasChanged() && state == DRAG)
+               */
+               return true;
+       }
+
+       //=========================================================================
+
+       bool GObjectController::OnRightButtonDown()
+       {
+               /**********************   VIRTUAL *************************/
+
+               if( _vtkInteractorStyleBaseView!= NULL )
                {
-                       _model->setState(SELECTED);
-                       _model->setChanged();
+                       int X,Y;
+                       wxVTKRenderWindowInteractor *wxVTKiren;
+                       wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+                       wxVTKiren->GetEventPosition(X, Y);
+                       
+                       int state  = _view->getState();
+                       
+                       //Evaluate new state
+                       if( !_model->hasChanged() && state == SELECTED)
+                       {
+                               _view->setState(NOTHING_HAPPENS);
+                               _model->setChanged();                   
+                       }
+
+                       _model->notifyObservers(_id);
                }
+               
+               /**/
 
-               _model->notifyObservers();
+               return true;
 
        }
 
-       */
-       return true;
-}
-//=========================================================================
-bool GObjectController::OnLeftDClick()
-{
-       /**********************   VIRTUAL *************************
+       //=========================================================================
 
-       if ( _vtkInteractorStyleBaseView!=NULL )
+       void GObjectController::moveObject(int X,int Y)
        {
-               int X,Y;
-               wxVTKRenderWindowInteractor *wxVTKiren;
-               wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
-               wxVTKiren->GetEventPosition(X,Y);
-
-               _model->notifyObservers();
+               _view->moveObject(X,Y); 
        }
 
-       */
-       return true;
-}
-//=========================================================================
-bool GObjectController::OnRightButtonDown()
-{
-       /**********************   VIRTUAL *************************/
+       //=========================================================================
 
-       if( _vtkInteractorStyleBaseView!= NULL )
+       int GObjectController::getGObjectType()
        {
-               int X,Y;
-               wxVTKRenderWindowInteractor *wxVTKiren;
-               wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
-               wxVTKiren->GetEventPosition(X, Y);
-               
-               int state  = _model->getState();
-               
-               //Evaluate new state
-               if( !_model->hasChanged() && state == SELECTED)
-               {
-                       _model->setState(NOTHING_HAPPENS);
-                       _model->setChanged();                   
-               }
-
-               _model->notifyObservers();
+               return _model->getGObjectType();
        }
+
+       //=========================================================================
        
-       /**/
+       GObjectModel* GObjectController::getModel()
+       {
+               return _model;
+       }
 
-       return true;
+       //=========================================================================
 
-}
+       vtkGObjectView* GObjectController::getView()
+       {
+               return _view;
+       }
 
-//=========================================================================
+       //=========================================================================
 
-void GObjectController::moveObject(int X,int Y)
-{
-       _view->moveObject(X,Y); 
-}
+       int GObjectController::getId()
+       {
+               return _id;
+       }
 
-//=========================================================================
+       //=========================================================================
+       
+       void GObjectController::setId(int id)
+       {
+               _id = id;
+       }
+
+       //=========================================================================
 
 }  // EO namespace bbtk
 
index a490e635007d4b7c0c6c9342bda14909021d459e..873396e762f2f09cc939838652c5c3e34fbd13d5 100644 (file)
@@ -69,6 +69,12 @@ namespace bbtk
                //Public methods
 
                void setModelAndView(GObjectModel* model, vtkGObjectView* view);
+               int getGObjectType();
+               GObjectModel* getModel();
+               vtkGObjectView* getView();
+
+               int getId();
+               void setId(int id);
 
        private:
 
@@ -83,6 +89,7 @@ namespace bbtk
                //Protected Attributes 
                GObjectModel* _model;
                vtkGObjectView* _view;
+               int _id;
 
                //Protected Methods
                virtual bool  OnMouseMove();
index 7e66a83ecfe11dbe44a366f80583dfc4c0b15d83..b2f863be11d9c522f89e343c1e2a4b70b3e138f4 100644 (file)
@@ -62,18 +62,18 @@ namespace bbtk
                        wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
                        wxVTKiren->GetEventPosition(X,Y);
 
-                       int state  = _model->getState();
+                       int state  = _view->getState();
                        
                        int portType = ((GPortModel*)_model)->getPortType();
 
                        //Evaluate new state
                        if(!_model->hasChanged() && state==HIGHLIGHTED && portType==GOUTPUTPORT )
                        {
-                               _model->setState(CREATING_CONTOUR);
+                               _view->setState(CREATING_CONTOUR);
                                _model->setChanged();
                        }
 
-                       _model->notifyObservers();
+                       _model->notifyObservers(_id);
 
                }
                return true;
@@ -88,21 +88,22 @@ namespace bbtk
                        wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
                        wxVTKiren->GetEventPosition(X,Y);
 
-                       int state  = _model->getState();
+                       int state  = _view->getState();
                        
                        //Evaluate new state
                        if(!_model->hasChanged() && state==CREATING_CONTOUR)
                        {
                                if(_view->isPointInside(X,Y))
                                {
+                                       _view->setState(CREATING_CONTOUR);
                                        _model->setChanged();
-                                       _model->notifyObservers(INIT_CREATION_CONTOUR);
+                                       _model->notifyObservers(_id,INIT_CREATION_CONTOUR);
                                }
                                else
                                {
-                                       _model->setState(NOTHING_HAPPENS);
+                                       _view->setState(NOTHING_HAPPENS);
                                        _model->setChanged();
-                                       _model->notifyObservers();
+                                       _model->notifyObservers(_id);
                                }
                        }
 
index e509662f64fdbdf9b64fcf135671889eeecc9ad7..fbdd9524ce5652cd95c5635b7da3a7598cb3dc4e 100644 (file)
@@ -51,39 +51,11 @@ namespace bbtk
        }
 
        //=========================================================================
-       void vtkGBlackBoxView::update(int command)
+       void vtkGBlackBoxView::update(int idObservable,int command)
        {
-               _objectActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
-
-               if(_model->getState()==NOTHING_HAPPENS)
-               {
-                       _objectActor->GetProperty()->SetLineWidth(1);
-                       _objectActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
-                       //_nameActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
-                       _typeActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
-               }
-               else if(_model->getState()==HIGHLIGHTED)
-               {
-                       _objectActor->GetProperty()->SetLineWidth(2);
-                       _objectActor->GetProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
-                       //_nameActor->GetProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
-                       _typeActor->GetProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
-               }
-               else if(_model->getState()==DRAG)
-               {
-                       _objectActor->GetProperty()->SetLineWidth(1.2);
-                       _objectActor->GetProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
-                       //_nameActor->GetProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
-                       _typeActor->GetProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
-               }
-               else if(_model->getState()==SELECTED)
-               {
-                       _objectActor->GetProperty()->SetLineWidth(2);
-                       _objectActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
-                       //_nameActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
-                       _typeActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
-               }
 
+               updateColors();
+               
                double xInic, yInic,zInic,xFin, yFin,zFin;
                _model->getInicPoint(xInic,yInic,zInic);
                _model->getFinalPoint(xFin, yFin,zFin);
@@ -100,9 +72,7 @@ namespace bbtk
                updatePositionTextActors(xInic, yInic,zInic);
 
                //-----------
-
-               _baseView->RefreshView();
-               _baseView->Refresh();
+               setRefreshWaiting();
        }
 
        //=========================================================================
@@ -147,53 +117,30 @@ namespace bbtk
 
                //------------
 
-               /*
-               _vectorNameText = vtkVectorText::New();
+               _nameActor = vtkTextActor3D::New();
                std::string temp = _model->getBBTKName();
-               _vectorNameText->SetText(temp.c_str());
-
-               vtkPolyDataMapper* txtMapper = vtkPolyDataMapper::New();
-               txtMapper->SetInputConnection( _vectorNameText->GetOutputPort());
-               _nameActor = vtkActor::New();
-               _nameActor->SetMapper(txtMapper);
-               */
-
-               _vectorNameText = vtkTextActor3D::New();
-               std::string temp = _model->getBBTKName();
-               _vectorNameText->SetInput( temp.c_str()  );
-
+               _nameActor->GetTextProperty()->SetFontSize(80);
+               _nameActor->GetTextProperty()->BoldOn();
+               _nameActor->SetInput(temp.c_str());
 
                //------------
 
-               _vectorTypeText = vtkVectorText::New();
+               _typeActor = vtkTextActor3D::New();
                temp = _model->getBBTKType();
-               _vectorTypeText->SetText(temp.c_str());
-
-               vtkPolyDataMapper* txtMapper = vtkPolyDataMapper::New();
-               txtMapper->SetInputConnection( _vectorTypeText->GetOutputPort());
-               _typeActor = vtkActor::New();
-               _typeActor->SetMapper(txtMapper);
+               _typeActor->GetTextProperty()->SetFontSize(80);
+               _typeActor->GetTextProperty()->BoldOn();
+               _typeActor->SetInput(temp.c_str());
 
                //------------
 
                updatePositionTextActors( xInic,  yInic,  zInic);
-
-               //_nameActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
-               _vectorNameText->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
-               _vectorNameText->GetTextProperty()->SetFontSize(75);//SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
-               _vectorNameText->GetTextProperty()->BoldOn();
-               _vectorNameText->SetScale(0.05,0.05,1);
-               _typeActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
-
        }
 
        //=========================================================================
 
        void vtkGBlackBoxView::addVtkActors()//virtual
        {
-               //_baseView->GetRenderer()->AddActor(_nameActor);
-
-               _baseView->GetRenderer()->AddActor(_vectorNameText);
+               _baseView->GetRenderer()->AddActor(_nameActor);
 
                _baseView->GetRenderer()->AddActor(_typeActor);
 
@@ -204,12 +151,49 @@ namespace bbtk
 
        void vtkGBlackBoxView::updatePositionTextActors(double xInic, double yInic, double zInic)
        {
-               //_nameActor->SetPosition(xInic+4,yInic-5,zInic);
-               //_nameActor->SetScale(2,2,1);
-               _vectorNameText->SetPosition(xInic+4,yInic-5,zInic);
+               _nameActor->SetPosition(xInic+4,yInic-5,zInic);
+               _nameActor->SetScale(0.04,0.04,1);
                                        
                _typeActor->SetPosition(xInic+4,yInic-10,zInic);
-               _typeActor->SetScale(2,2,1);
+               _typeActor->SetScale(0.04,0.04,1);
+       }
+
+       //=========================================================================
+
+       void vtkGBlackBoxView::updateColors()
+       {
+               _objectActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
+               _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
+               _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
+
+               if(_state==NOTHING_HAPPENS)
+               {
+                       _objectActor->GetProperty()->SetLineWidth(1);
+                       _objectActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
+                       _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
+                       _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
+               }
+               else if(_state==HIGHLIGHTED)
+               {
+                       _objectActor->GetProperty()->SetLineWidth(2);
+                       _objectActor->GetProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
+                       _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
+                       _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
+               }
+               else if(_state==DRAG)
+               {
+                       _objectActor->GetProperty()->SetLineWidth(1.2);
+                       _objectActor->GetProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
+                       _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
+                       _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
+               }
+               else if(_state==SELECTED)
+               {
+                       _objectActor->GetProperty()->SetLineWidth(2);
+                       _objectActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
+                       _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
+                       _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
+               }
        }
 
        //=========================================================================
index 8114f51809a33761b1f9b3ae7a3f7252261a15d0..b64ce178d010cf228cff1eac2b258780f95b0cd2 100644 (file)
@@ -49,6 +49,8 @@ Version:   $Revision$
 
 //Includes creaMaracasVisu
 
+#include "vtkInteractorStyleBaseView.h"
+
 //Includes vtk
 
 #include "vtkPolyDataMapper.h"
@@ -83,13 +85,8 @@ namespace bbtk
 
                //Private Attributes
                vtkPoints *_pts;
-               vtkActor* _nameActor;
-               vtkActor* _typeActor;
-
-               //vtkVectorText* _vectorNameText;
-               vtkTextActor3D* _vectorNameText;
-
-               vtkVectorText* _vectorTypeText;
+               vtkTextActor3D* _nameActor;
+               vtkTextActor3D* _typeActor;
 
                //Private Methods
                void updatePositionTextActors(double xInic, double yInic, double zInic);
@@ -101,7 +98,8 @@ namespace bbtk
                //Protected Methods
                virtual void addVtkActors();
                virtual void createVtkObjects();
-               virtual void update(int command);
+               virtual void update(int idObservable,int command);
+               virtual void updateColors();
        };
 
 
index 51761e7210662c5b37bc56f32012ab1f7144da4f..db905de37425c75e0cf4bce7efa68893e5fd6353 100644 (file)
@@ -46,6 +46,8 @@ namespace bbtk
                _baseView=NULL;
                _objectActor=NULL;
                _isStartDragging=false;
+               
+               _state = NOTHING_HAPPENS;
        }
 
        //=========================================================================
@@ -54,7 +56,7 @@ namespace bbtk
        }
        //=========================================================================
 
-       void vtkGObjectView::update(int command)//virtual
+       void vtkGObjectView::update(int idObservable,int command)//virtual
        {
                //virtual
        }
@@ -90,6 +92,13 @@ namespace bbtk
 
        //=========================================================================
 
+       void vtkGObjectView::updateColors() //virtual
+       {
+               //virtual
+       }
+
+       //=========================================================================
+
        void vtkGObjectView::addVtkActors()//virtual
        {
                _baseView->GetRenderer()->AddActor(_objectActor);
@@ -141,6 +150,28 @@ namespace bbtk
 
        //=========================================================================
 
+       void vtkGObjectView::setState(int state)
+       {
+               _state = state;
+       }
+
+       //=========================================================================
+
+       int vtkGObjectView::getState()
+       {
+               return _state;
+       }
+
+       //=========================================================================
+
+       void vtkGObjectView::setRefreshWaiting()
+       {
+               ((vtkInteractorStyleBaseView*)_baseView->GetInteractorStyleBaseView())->SetRefresh_waiting();
+       }
+
+       //=========================================================================
+
+
 }  // EO namespace bbtk
 
 // EOF
index e15232f4bf16368250bd8bfc4af2361eef00a51f..ce1e4ce8f432875bfc7378d71f473a1578f811a3 100644 (file)
@@ -50,6 +50,7 @@ Version:   $Revision$
 
 //Includes creaMaracasVisu
 #include <wxVtkBaseView.h>
+#include <vtkInteractorStyleBaseView.h>
 
 //Includes vtk
 #include <vtkRenderer.h>
@@ -82,9 +83,13 @@ namespace bbtk
                virtual bool isPointInside(int X,int Y);
                virtual void moveObject(int X, int Y);
 
-               virtual void update(int command);
+               virtual void update(int idObservable,int command);
                void isStartDragging(bool param);
 
+               void setState(int state);
+               int getState();
+               void setRefreshWaiting();
+
        private:
 
                //Private Attributes
@@ -101,10 +106,12 @@ namespace bbtk
                wxVtkBaseView *_baseView;
                GObjectModel *_model;
                vtkActor *_objectActor;
+               int  _state;
                
                //Protected Methods
                virtual void createVtkObjects();
                virtual void addVtkActors();
+               virtual void updateColors();
        };
 
 
index adbe0caac36e9cfe2402ab37c80c1b18d7a8cbf3..42dcd2129435116f877e273e0821bc528510728a 100644 (file)
@@ -42,7 +42,7 @@ namespace bbtk
 
        //=========================================================================
        vtkGPortView::vtkGPortView()
-       {                       
+       {               
        }
 
        //=========================================================================
@@ -51,18 +51,10 @@ namespace bbtk
        }
 
        //=========================================================================
-       void vtkGPortView::update(int command)
+       void vtkGPortView::update(int idObservable,int command)
        {
-               _objectActor->GetProperty()->SetColor(0.8,0.2,0.5);
-               if(_model->getState()==HIGHLIGHTED)
-               {
-                       _objectActor->GetProperty()->SetColor(0.8,0.2,0.5);
-               }
-               else
-               {
-                       _objectActor->GetProperty()->SetColor(0.3,0.2,0.2);
-               }
-
+               updateColors();
+               
                double xInic, yInic,zInic,xFin, yFin,zFin;
 
                _model->getInicPoint(xInic,yInic,zInic);
@@ -74,10 +66,8 @@ namespace bbtk
                _pts->SetPoint(1, xInic, yFin, zInic );
                _pts->SetPoint(2, xFin, yFin, zFin );
                _pts->SetPoint(3, xFin, yInic, zFin );
-
-               //_baseView->GetRenderer()->Render();
-               //_baseView->GetRenWin()->Render();
-
+               
+               setRefreshWaiting();
        }
 
        //=========================================================================
@@ -116,8 +106,25 @@ namespace bbtk
                _bboxMapper->SetInput(_pd);
                _objectActor->SetMapper(_bboxMapper);
 
+               updateColors();
+
+
+       }
+
+       //=========================================================================
+
+       void vtkGPortView::updateColors()
+       {
                _objectActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
 
+               if(_state==HIGHLIGHTED)
+               {
+                       _objectActor->GetProperty()->SetColor(0.8,0.2,0.5);
+               }
+               else
+               {
+                       _objectActor->GetProperty()->SetColor(0.3,0.2,0.2);
+               }
        }
 
        //=========================================================================
index d06e066d9d5509b9818ff7465c41d78dd98a4072..acbf772d0e860372d487d67bdc01b1ef66e9c867 100644 (file)
@@ -48,6 +48,7 @@ Version:   $Revision$
 #include "vtkGObjectView.h"
 
 //Includes creaMaracasVisu
+#include "vtkInteractorStyleBaseView.h"
 
 //Includes vtk
 
@@ -74,7 +75,8 @@ namespace bbtk
                vtkGPortView();
                ~vtkGPortView();
                
-               //Public methods                        
+               //Public methods
+               virtual void update(int idObservable,int command);
 
        private:
 
@@ -89,7 +91,7 @@ namespace bbtk
                
                //Protected Methods
                virtual void createVtkObjects();
-               virtual void update(int command);
+               virtual void updateColors();
        };