]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.cxx
Stable version ... The connection is correctly painted :)
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsVtkGUIEditorGraphic / GPortController.cxx
index c9c196b2ad776da0d7103006618c9234291cd4f0..e2203ce8fd09136b278347d8de868a9f7244496b 100644 (file)
@@ -43,7 +43,7 @@ namespace bbtk
        //=========================================================================
        GPortController::GPortController()
        {
-               
+               _isLeftClickDown=false;
        }
 
        //=========================================================================
@@ -62,58 +62,51 @@ 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==GINPUTPORT )
+                       if(state == HIGHLIGHTED)
                        {
-                               _model->setState(CREATING_CONTOUR);
-                               _model->setChanged();
+                               _isLeftClickDown=true;
                        }
 
-                       _model->notifyObservers();
-
                }
                return true;
        }
        //=========================================================================
        bool GPortController::OnLeftButtonUp()
        {
-               if ( _vtkInteractorStyleBaseView!=NULL )
+               int state  = _view->getState();
+               if(_isLeftClickDown)
                {
-                       int X,Y;
-                       wxVTKRenderWindowInteractor *wxVTKiren;
-                       wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
-                       wxVTKiren->GetEventPosition(X,Y);
-
-                       int state  = _model->getState();
-                       
-                       //Evaluate new state
-                       if(!_model->hasChanged() && state==CREATING_CONTOUR)
+                       if(state==HIGHLIGHTED)
                        {
-                               if(_view->isPointInside(X,Y))
+                               int portType = ((GPortModel*)_model)->getPortType();
+
+                               //Evaluate new state
+                               if(portType==GOUTPUTPORT)
                                {
-                                       _model->setChanged();
-                                       _model->notifyObservers(INIT_CREATION_CONTOUR);
+                                       _model->notifyObservers(_id,INIT_CREATION_CONTOUR);
                                }
-                               else
+                               else if (portType==GINPUTPORT)
                                {
-                                       _model->setState(NOTHING_HAPPENS);
-                                       _model->setChanged();
-                                       _model->notifyObservers();
+                                       _model->notifyObservers(_id,FIN_CREATION_CONTOUR);
                                }
                        }
-
-                       
-
+                       else
+                       {
+                               _view->setState(NOTHING_HAPPENS);
+                       }
+                       _isLeftClickDown=false; 
                }
+
                return true;
        }
 
        //=========================================================================
 
+       
+
 }  // EO namespace bbtk
 
 // EOF