]> Creatis software - bbtkGEditor.git/commitdiff
Stable version ... The connection is correctly painted :)
authorcorredor <>
Thu, 22 Apr 2010 07:55:54 +0000 (07:55 +0000)
committercorredor <>
Thu, 22 Apr 2010 07:55:54 +0000 (07:55 +0000)
14 files changed:
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/Observable.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/Observable.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorView.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorView.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourView.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourView.h

index 05ce3b8863b881b15cd139e877997468bacf571f..58f601bd1baabaff5b15955351e85b73eeb876b8 100644 (file)
@@ -79,6 +79,10 @@ namespace bbtk
                endPort->getInicPoint(xIport,yIport,zIport);
 
                setFinalPoint(xCenter,yIport,zCenter);
+
+               manualPoint* point = _model->GetManualPoint(_model->GetSizeLstPoints()-1);
+               point->SetPoint(xCenter,yIport,zCenter);
+               cout<<"RaC GConnectorModel::setEndPort size:"<<_model->GetSizeLstPoints()<<endl;
        }
 
        //=========================================================================
index 7cd922090d8942566e918bf94158adb28f4cc7f7..227b31320c26224f6fbd15ef31c97fb2b7a7c87c 100644 (file)
@@ -92,8 +92,7 @@ namespace bbtk
 
                setFinalPoint(posX,posY,posZ);          
                
-               setChanged();
-               notifyObservers();
+               //notifyObservers();
        }
 
        //=========================================================================
index cf21b32e9990b87f06c58d19d23c45c006d67203..a70219e52422dc8f71d51feb369fb87977194f8b 100644 (file)
@@ -43,42 +43,26 @@ namespace bbtk
        //=========================================================================
        Observable::Observable()
        {
-               _changed=false;
        }
 
        //=========================================================================
+
        Observable::~Observable()
        {
        }
-       //=========================================================================
-       
-       bool Observable::hasChanged()
-       {
-               return _changed;
-       }
 
        //=========================================================================
        
-       void Observable::notifyObservers(int idController,int command)
+       void Observable::notifyObservers(int idCaller,int command)
        {
-               if(_changed)
+               
+               int i;
+               for(i=0;i<_observers.size();i++)
                {
-                       int i;
-                       for(i=0;i<_observers.size();i++)
-                       {
-                               _observers[i]->update(idController,command);
-                       }
-                       _changed=false;
+                       _observers[i]->update(idCaller,command);
                }
        }
 
-    //=========================================================================                
-       
-       void Observable::setChanged()
-       {
-               _changed=true;
-       }
-
        //=========================================================================
 
        void Observable::addObserver(Observer *observer)
index 18fad74b5f1977ccf91a29a59d9f38b4adcea33d..c00e754814f4e76f59dc1c0900327dbcc9afa27a 100644 (file)
@@ -69,17 +69,11 @@ namespace bbtk
                //Public methods
                void addObserver(Observer *observer);
 
-               bool hasChanged();
-
-               void notifyObservers(int idController=-1,int command=REPAINT);
-                    
-               void setChanged();
+               void notifyObservers(int idCaller,int command=REPAINT);
 
        private:
 
-               //Private Attributes
-               bool _changed;
-               
+               //Private Attributes            
                std::vector<Observer*>  _observers;
                
                //Private Methods
index 4e337be93c3d97cc460fee84c9377324d2457934..daa6327c157cceea4e7cd481750fa60fa7654e82 100644 (file)
@@ -180,8 +180,7 @@ namespace bbtk
                controller->setModelAndView(model,view);
 
                //Resgiter change to the observers of the actual model
-               model->setChanged();
-               model->notifyObservers();
+               model->notifyObservers(_idManager);
                
                //Register the controller of the new object
                registerController((InteractorStyleMaracas*) controller);
@@ -233,7 +232,7 @@ namespace bbtk
                //Associates the controller with the correspondent model and view
                controller->setModelAndView(model,view);
 
-               model->notifyObservers();
+               model->notifyObservers(_idManager);
 
                //Register the controller of the new object
                registerController((InteractorStyleMaracas*) controller);
@@ -250,7 +249,7 @@ namespace bbtk
                int type = GCONNECTOR;
 
                manualConnectorContourController* manContourControl     = new manualConnectorContourController();
-               manualConnectorContourView* manViewerContour    = new manualConnectorContourView();
+               manualConnectorContourView* manContourView      = new manualConnectorContourView();
                manualContourModel* manContourModel     = new manualContourModel();
 
                GConnectorController* connectorcontroller = new GConnectorController();                         
@@ -261,21 +260,21 @@ namespace bbtk
                manContourModel->SetCloseContour(false);
                connectorModel->setStartPort(startPort);
 
-               manViewerContour->SetModel( manContourModel );
-               manViewerContour->SetWxVtkBaseView( _baseView );
-               manViewerContour->SetRange( 0.5 );
-               manViewerContour->SetZ( 900 );
+               manContourView->SetModel( manContourModel );
+               manContourView->SetWxVtkBaseView( _baseView );
+               manContourView->SetRange( 0.5 );
+               manContourView->SetZ( 900 );
 
-               manViewerContour->SetColorNormalContour(0, 0, 1);
-               manViewerContour->SetColorEditContour(0.5, 0.5, 0.5);
-               manViewerContour->SetColorSelectContour(1, 0.8, 0);
-               manViewerContour->SetWidthLine(1);
+               manContourView->SetColorNormalContour(0, 0, 1);
+               manContourView->SetColorEditContour(0.5, 0.5, 0.5);
+               manContourView->SetColorSelectContour(1, 0.8, 0);
+               manContourView->SetWidthLine(1);
 
-               manContourControl->SetModelView( manContourModel , manViewerContour );
+               manContourControl->SetModelView( manContourModel , manContourView );
                
                manContourControl->CreateNewManualContour();
 
-               manViewerContour->RefreshContour();
+               manContourView->RefreshContour();
 
 
                double x,y,z;
@@ -285,14 +284,14 @@ namespace bbtk
                manContourModel->SetCloseContour(false);
                
                manContourModel->AddPoint(x,y,z);
-               manViewerContour->AddPoint();
+               manContourView->AddPoint();
 
                manContourModel->AddPoint(x,y,z);
-               manViewerContour->AddPoint();
+               manContourView->AddPoint();
 
                int bak= manContourControl->GetNumberOfPointsManualContour() - 1;
                manContourControl->_bakIdPoint=bak;
-               manViewerContour->Refresh();
+               manContourView->Refresh();
 
                manContourControl->SetMoving( false );
 
@@ -300,7 +299,8 @@ namespace bbtk
 
                connectorcontroller->setManualContourController(manContourControl);             
                connectorModel->setManualContourModel(manContourModel);
-               connectorcontroller->setModelAndView(connectorModel,NULL);
+               connectorView->setManualContourView(manContourView);
+               connectorcontroller->setModelAndView(connectorModel,connectorView);
 
                int newId = _controllers.size();
                connectorcontroller->setId(newId);
@@ -344,11 +344,9 @@ namespace bbtk
                if(command == INIT_CREATION_CONTOUR)
                {       
                        GObjectController* cont = _controllers[idController];
-                       if(cont->getGObjectType() == GPORT)
-                       {
-                               GPortModel* startOutputPort = (GPortModel*)cont->getModel();
-                               createGConnector(startOutputPort);
-                       }
+                       GPortModel* startOutputPort = (GPortModel*)cont->getModel();
+                       createGConnector(startOutputPort);
+
                        // The last one is the controller of the connector
                        for(int i=0;i<_controllers.size()-1;i++)
                        {
@@ -376,26 +374,22 @@ namespace bbtk
                }
                else if(command == FIN_CREATION_CONTOUR && _worldState == CREATING_CONTOUR)
                {
+                       
                        _worldState = NOTHING_HAPPENS;
                        int id = _controllers.size()-1;
                        GObjectController* cont = _controllers[id];                     
                        GConnectorModel* modelContour = (GConnectorModel*)cont->getModel();
 
                        GObjectController* finPort = _controllers[idController];
-                       if(cont->getGObjectType() == GPORT)
+                       if(finPort->getGObjectType() == GPORT)
                        {
                                GPortModel* modelPort = (GPortModel*)finPort->getModel();
                                modelContour->setEndPort(modelPort);
                        }                       
 
-                       manualContourControler* manCont = ((GConnectorController*)cont)->getManualContourController();
-                       
-                       //manCont->SetCompleteCreation( true );
-                       //manCont->SetKeyBoardMoving( false );
-                       //manCont->GetManualContourModel()->SetCloseContour(false);
-                       //manCont->SetEditable( false );
-                       //manCont->SetPosibleToMove( false );
-                       //manCont->SetState(0);
+                       manualConnectorContourController* manCont = ((GConnectorController*)cont)->getManualContourController();                        
+                       manualConnectorContourView* connView = (manualConnectorContourView*)manCont->GetManualViewBaseContour();
+                       connView->Refresh();
 
                        for(int i=0;i<_controllers.size();i++)
                        {
index 952e9a908592691254924a9227969f3e096eca3e..4554e541c77c02809c61f285c1b748d57b230f97 100644 (file)
@@ -65,26 +65,23 @@ namespace bbtk
                        int state  = _view->getState();
                        
                        //Evaluate new state
-                       if(!_model->hasChanged() && state == DRAG)
+                       if( state == DRAG)
                        {
                                moveObject(X,Y);
-                               _model->setChanged();
                        }
 
-                       if(!_model->hasChanged() && state == NOTHING_HAPPENS)
+                       if(state == NOTHING_HAPPENS)
                        {
                                if(_view->isPointInside(X,Y))
                                {
-                                       _view->setState(HIGHLIGHTED);
-                                       _model->setChanged();                           
+                                       _view->setState(HIGHLIGHTED);           
                                }                       
                        }
-                       if(!_model->hasChanged() && state==HIGHLIGHTED)
+                       if( state==HIGHLIGHTED)
                        {
                                if(!_view->isPointInside(X,Y))
                                {
                                        _view->setState(NOTHING_HAPPENS);
-                                       _model->setChanged();
                                }
                        }
                        
@@ -109,20 +106,18 @@ namespace bbtk
                        int state  = _view->getState();
                        
                        //Evaluate new state
-                       if(!_model->hasChanged() && state==HIGHLIGHTED)
+                       if( state==HIGHLIGHTED)
                        {
                                _view->isStartDragging(true);
                                _view->setState(DRAG);
-                               _model->setChanged();
                        }
 
-                       if( !_model->hasChanged() && state == SELECTED)
+                       if(  state == SELECTED)
                        {
                                if(_view->isPointInside(X,Y))
                                {
                                        _view->isStartDragging(true);
                                        _view->setState(DRAG);
-                                       _model->setChanged();
                                }       
                        }
                        
@@ -145,16 +140,14 @@ namespace bbtk
                        int state  = _view->getState();
                        
                        //Evaluate new state
-                       if(!_model->hasChanged() && state==CLICKED)
+                       if(state==CLICKED)
                        {
                                _view->setState(SELECTED);
-                               _model->setChanged();
                        }
 
-                       if( !_model->hasChanged() && state == DRAG)
+                       if( state == DRAG)
                        {
                                _view->setState(SELECTED);
-                               _model->setChanged();
                        }
 
                        _model->notifyObservers(_id);
@@ -193,10 +186,9 @@ namespace bbtk
                        int state  = _view->getState();
                        
                        //Evaluate new state
-                       if( !_model->hasChanged() && state == SELECTED)
+                       if(  state == SELECTED)
                        {
                                _view->setState(NOTHING_HAPPENS);
-                               _model->setChanged();                   
                        }
 
                        _model->notifyObservers(_id);
index 02c5fedd20a30d615400acb853ad710ebc03fe7d..3f97b7c2a4433fee6af03b7b5833c1018e670664 100644 (file)
@@ -174,14 +174,14 @@ namespace bbtk
 
        //=========================================================================
 
-       manualContourControler* GConnectorController::getManualContourController()
+       manualConnectorContourController* GConnectorController::getManualContourController()
        {
                return _controller;
        }
 
        //=========================================================================
        
-       void GConnectorController::setManualContourController(manualContourControler* controller)
+       void GConnectorController::setManualContourController(manualConnectorContourController* controller)
        {
                _controller = controller;
                _controller->SetVtkInteractorStyleBaseView(_vtkInteractorStyleBaseView);
index fa92fc1c6650d8c9e380065ff0968071aea60663..bc3308b8e80ad06ac26022cecee1548d5199f811 100644 (file)
@@ -45,9 +45,10 @@ Version:   $Revision$
 
 //Includes same project
 #include "GObjectController.h"
+#include "manualConnectorContourView.h"
+#include "manualConnectorContourController.h"
 
 //Includes creaMaracasVisu
-#include <manualContourControler.h>
 
 //Includes std
 #include <iostream>
@@ -75,13 +76,13 @@ namespace bbtk
                virtual bool  OnMiddleButtonDown();
                virtual bool  OnMiddleButtonUp();
 
-               manualContourControler* getManualContourController();
-               void setManualContourController(manualContourControler* controller);
+               manualConnectorContourController* getManualContourController();
+               void setManualContourController(manualConnectorContourController* controller);
 
        private:
 
                //Attributes
-               manualContourControler* _controller;
+               manualConnectorContourController* _controller;
 
                //Private Methods
 
index 9c2388fc5262b6f02be4a77b07e51026b4eaecad..6617b1f67f69b18fba0b8dfb0ee149e4daba8f58 100644 (file)
@@ -41,19 +41,29 @@ namespace bbtk
 
 
        //=========================================================================
+       
        GConnectorView::GConnectorView()
        {               
        }
 
        //=========================================================================
+       
        GConnectorView::~GConnectorView()
        {
        }
+       
        //=========================================================================
+       
+       void GConnectorView::setManualContourView(manualViewContour *viewContour)
+       {
+               manViewContour = viewContour;
+       }
 
-       void GConnectorView::TransfromCoordViewWorld(double &X, double &Y, double &Z, int type)
+       //=========================================================================
+       
+       manualViewContour* GConnectorView::getManualContourView()
        {
-               //_wxvtkbaseview->TransCoordScreenToWorld(X,Y,Z,type);
+               return manViewContour;
        }
 
 }  // EO namespace bbtk
index fb9825150557bd6df5465b121980311a9afabf34..ade0a5046ff9d125d41bc9b847a4135e288e15e2 100644 (file)
@@ -47,6 +47,7 @@ Version:   $Revision$
 #include "vtkGObjectView.h"
 
 //Includes creaMaracasVisu
+#include <manualViewContour.h>
 
 //Includes std
 #include <iostream>
@@ -64,13 +65,14 @@ namespace bbtk
                GConnectorView();
                ~GConnectorView();
                
-               //Public methods                
-               virtual void TransfromCoordViewWorld(double &X, double &Y, double &Z, int type=2);
+               //Public methods
+               void setManualContourView(manualViewContour* viewContour);
+               manualViewContour* getManualContourView();
 
        private:
 
                //Attributes
-               
+               manualViewContour* manViewContour;
 
                //Private Methods
 
index 0dffa0ec1a4d4d929ca092bde21663c4445e8e50..2c90897a2a4bebb8fdfdaf6c6c60f1d678fa9b6c 100644 (file)
@@ -77,26 +77,23 @@ namespace bbtk
                        int state  = _view->getState();
                        
                        //Evaluate new state
-                       if(!_model->hasChanged() && state == DRAG)
+                       if( state == DRAG)
                        {
                                moveObject(X,Y);
-                               _model->setChanged();
                        }
 
-                       if(!_model->hasChanged() && state == NOTHING_HAPPENS)
+                       if( state == NOTHING_HAPPENS)
                        {
                                if(_view->isPointInside(X,Y))
                                {
-                                       _view->setState(HIGHLIGHTED);
-                                       _model->setChanged();                           
+                                       _view->setState(HIGHLIGHTED);   
                                }                       
                        }
-                       if(!_model->hasChanged() && state==HIGHLIGHTED)
+                       if( state==HIGHLIGHTED)
                        {
                                if(!_view->isPointInside(X,Y))
                                {
                                        _view->setState(NOTHING_HAPPENS);
-                                       _model->setChanged();
                                }
                        }
                        
@@ -129,7 +126,6 @@ namespace bbtk
                        {
                                _view->isStartDragging(true);
                                _model->setState(DRAG);
-                               _model->setChanged();
                        }
 
                        if( !_model->hasChanged() && state == SELECTED)
@@ -138,7 +134,6 @@ namespace bbtk
                                {
                                        _view->isStartDragging(true);
                                        _model->setState(DRAG);
-                                       _model->setChanged();
                                }       
                        }
                        
@@ -170,13 +165,11 @@ namespace bbtk
                        if(!_model->hasChanged() && state==CLICKED)
                        {
                                _model->setState(SELECTED);
-                               _model->setChanged();
                        }
 
                        if( !_model->hasChanged() && state == DRAG)
                        {
                                _model->setState(SELECTED);
-                               _model->setChanged();
                        }
 
                        _model->notifyObservers();
@@ -223,10 +216,9 @@ namespace bbtk
                        int state  = _view->getState();
                        
                        //Evaluate new state
-                       if( !_model->hasChanged() && state == SELECTED)
+                       if( state == SELECTED)
                        {
                                _view->setState(NOTHING_HAPPENS);
-                               _model->setChanged();                   
                        }
 
                        _model->notifyObservers(_id);
index 66106085a683f60769a45836828ee37fd2c217f4..e2203ce8fd09136b278347d8de868a9f7244496b 100644 (file)
@@ -77,32 +77,27 @@ namespace bbtk
        bool GPortController::OnLeftButtonUp()
        {
                int state  = _view->getState();
-               if(state == HIGHLIGHTED && _isLeftClickDown)
+               if(_isLeftClickDown)
                {
-                       _isLeftClickDown=false;                 
-
-                       if ( _vtkInteractorStyleBaseView!=NULL )
+                       if(state==HIGHLIGHTED)
                        {
-                               int X,Y;
-                               wxVTKRenderWindowInteractor *wxVTKiren;
-                               wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
-                               wxVTKiren->GetEventPosition(X,Y);
-
                                int portType = ((GPortModel*)_model)->getPortType();
 
                                //Evaluate new state
                                if(portType==GOUTPUTPORT)
                                {
-                                       _model->setChanged();
                                        _model->notifyObservers(_id,INIT_CREATION_CONTOUR);
                                }
                                else if (portType==GINPUTPORT)
                                {
-                                       _model->setChanged();
                                        _model->notifyObservers(_id,FIN_CREATION_CONTOUR);
                                }
-                                       
                        }
+                       else
+                       {
+                               _view->setState(NOTHING_HAPPENS);
+                       }
+                       _isLeftClickDown=false; 
                }
 
                return true;
index e361e634c8a44c4e0bad790637523cf242513046..4bbaecb809fcb2ee2d40fe9653ea3ff18d39514a 100644 (file)
@@ -58,11 +58,12 @@ namespace bbtk
 
        //=========================================================================
 
-       void manualConnectorContourView::removeStartAndEnd()
+       void manualConnectorContourView::updateStartAndEnd(double* start , double* end)
        {
-               _wxvtkbaseview->GetRenderer()->RemoveActor( _lstViewPoints[0]->GetVtkActor() );
+               _manContModel->MovePoint(0,start[0],start[1],start[2]);
+               _manContModel->MovePoint(_manContModel->GetSizeLstPoints()-1,end[0],end[1],end[2]);
 
-               _wxvtkbaseview->GetRenderer()->RemoveActor( _lstViewPoints[_lstViewPoints.size()-1]->GetVtkActor() );
+               Refresh();
        }
 
        //=========================================================================
index bcc076fb4c2838428c7c4c09400d6d42786865c7..43fd4286f0c2dfdae44c70bf666f02f58e31e4ce 100644 (file)
@@ -67,7 +67,7 @@ namespace bbtk
                
                //Public methods                
                virtual void TransfromCoordViewWorld(double &X, double &Y, double &Z, int type=2);
-               void removeStartAndEnd();
+               void updateStartAndEnd(double* start , double* end);
 
        private: