From: corredor <> Date: Sat, 27 Mar 2010 17:39:01 +0000 (+0000) Subject: Changes to manage the events capturing in the vtkWorld. Some problems with that .... X-Git-Tag: v1_0_0~118 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=522d684c97b10743148e2fbf2371cd02ff1fa42e;p=bbtkGEditor.git Changes to manage the events capturing in the vtkWorld. Some problems with that .... --- diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx index d871e06..47008da 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx @@ -50,6 +50,7 @@ namespace bbtk _xFin = 0; _yFin = 0; _zFin = 900; + _state = NOTHING_HAPPENS; } //========================================================================= @@ -69,7 +70,7 @@ namespace bbtk void GObjectModel::getFinalPoint(double& x, double& y, double& z) { x = _xInic+BOX_SIDE; - y = _yInic+BOX_SIDE; + y = _yInic-BOX_SIDE; z = _zFin; } //========================================================================= @@ -91,7 +92,29 @@ namespace bbtk } //========================================================================= + void GObjectModel::setState(int state) + { + _state = state; + } + + //========================================================================= + + int GObjectModel::getState() + { + return _state; + } + //========================================================================= + + bool GObjectModel::isPointInside(double x,double y, double z)//virtual + { + if(x>=_xInic && x<=_xFin && y<=_yInic && y>=_yFin) + return true; + else + return false; + } + + //========================================================================= } // EO namespace bbtk diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h index 9f7a265..ed0a3e2 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h @@ -69,6 +69,9 @@ namespace bbtk void getFinalPoint(double& x, double& y, double& z); void setInicPoint(double& x, double& y, double& z); void setFinalPoint(double& x, double& y, double& z); + void setState(int state); + int getState(); + virtual bool isPointInside(double x,double y, double z); private: @@ -87,8 +90,10 @@ namespace bbtk double _yFin; double _zFin; - //Protected methods + int _state; + //Protected methods + }; diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx index e476c03..659856b 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx @@ -122,11 +122,12 @@ namespace bbtk { vtkInteractorStyleImage *temp = vtkInteractorStyleImage::New(); _baseView->GetWxVTKRenderWindowInteractor()->SetInteractorStyle(temp); - _baseView->GetRenderer()->SetActiveCamera(_baseView->GetCamera()); - _baseView->GetRenderer()->ResetCamera (); - _baseView->GetCamera()->SetParallelProjection(true); + //_baseView->GetRenderer()->SetActiveCamera(_baseView->GetCamera()); + //_baseView->GetRenderer()->ResetCamera (); + //_baseView->GetCamera()->SetParallelProjection(true); + + _baseView->GetRenderer()->SetBackground(1,1,1); _baseView->Refresh(); - } //========================================================================= @@ -141,9 +142,10 @@ namespace bbtk GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type); //Prepares the initial model + cout<<"RaC Size:"<<_baseView->GetRenWin()->GetSize()[1]<GetRenWin()->GetSize()[1]-y; + double zz = 0; _baseView->TransCoordScreenToWorld(xx,yy,zz); @@ -151,7 +153,7 @@ namespace bbtk //(NOTE: Refresh is only made by the view) model->setInicPoint(xx,yy,zz); view->setModel(model); - view->setRenderer(_baseView->GetRenderer()); + view->setBaseView(_baseView); view->initVtkObjects(); //Refresh renderwindow with new objects @@ -167,6 +169,7 @@ namespace bbtk void wxVtkSceneManager::registerController(InteractorStyleMaracas *param) { + cout<<"RaC wxVtkSceneManager::registerController param:"<GetInteractorStyleBaseView(); baseViewControlManager->AddInteractorStyleMaracas( param ); } @@ -192,6 +195,11 @@ namespace bbtk } //========================================================================= + bool wxVtkSceneManager::OnMouseMove() + { + cout<<"RaC wxVtkSceneManager::OnMouseMove "<GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor(); + _wxVTKiren->GetEventPosition( X , Y ); + + int state = _model->getState(); + + //Evaluate new state + if(state == CLICKED) + { + _model->setState(DRAG); + //MoveObject(X,Y); + + } + if(state == DRAG) + { + //MoveObject(X,Y); + + } + if(state == NOTHING_HAPPENS) + { + if(_view->isPointInside(X,Y)) + { + _model->setState(HIGHLIGHTED); + } + } + + _view->refresh(); + } + return true; +} +//========================================================================= +bool GObjectController::OnLeftButtonDown() +{ + + if ( _vtkInteractorStyleBaseView!=NULL ) + { + int X,Y; + wxVTKRenderWindowInteractor *wxVTKiren; + wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren->GetEventPosition(X,Y); + + //MouseClickLeft(X,Y); + } + return true; +} +//========================================================================= +bool GObjectController::OnLeftButtonUp() +{ + if ( _vtkInteractorStyleBaseView!=NULL ) + { + int X,Y; + wxVTKRenderWindowInteractor *wxVTKiren; + wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren->GetEventPosition(X,Y); + //MouseReleaseLeft(X,Y); + } + return true; +} +//========================================================================= +bool GObjectController::OnLeftDClick() +{ + if ( _vtkInteractorStyleBaseView!=NULL ) + { + int X,Y; + wxVTKRenderWindowInteractor *wxVTKiren; + wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren->GetEventPosition(X,Y); + + //this->MouseDLeft(X,Y); + } + return true; +} +//========================================================================= +bool GObjectController::OnMiddleButtonDown() +{ + if ( _vtkInteractorStyleBaseView!=NULL ) + { + int X,Y; + wxVTKRenderWindowInteractor *wxVTKiren; + wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren->GetEventPosition(X,Y); + //GetManualViewBaseContour()->InitMove( X, Y,GetZ()); + } + return true; +} +//========================================================================= +bool GObjectController::OnMiddleButtonUp() +{ + return true; +} +//========================================================================= +bool GObjectController::OnRightButtonDown() +{ + if( _vtkInteractorStyleBaseView!= NULL ) + { + int X,Y; + wxVTKRenderWindowInteractor *wxVTKiren; + wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren->GetEventPosition(X, Y); + + //SetCompleteCreation( true ); + //SetKeyBoardMoving( false ); + //this->GetManualContourModel()->SetCloseContour(true); + //MouseClickRight(X,Y); + } + return true; +} +//========================================================================= +bool GObjectController::OnRightButtonUp() +{ + return true; +} +//========================================================================= + } // EO namespace bbtk // EOF diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h index aea9ab9..9c5403b 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h @@ -81,6 +81,19 @@ namespace bbtk protected: + //Protected Attributes + + + //Protected Methods + virtual bool OnMouseMove(); + virtual bool OnLeftButtonDown(); + virtual bool OnLeftButtonUp(); + virtual bool OnLeftDClick(); + virtual bool OnMiddleButtonDown(); + virtual bool OnMiddleButtonUp(); + virtual bool OnRightButtonDown(); + virtual bool OnRightButtonUp(); + }; diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h index 35a8c51..72e6819 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h @@ -48,10 +48,8 @@ Version: $Revision$ #include "vtkGObjectView.h" //Includes creaMaracasVisu -#include //Includes vtk -#include #include "vtkPolyDataMapper.h" #include "vtkActor.h" diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx index 0f748b8..7e4d139 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx @@ -43,7 +43,7 @@ namespace bbtk //========================================================================= vtkGObjectView::vtkGObjectView() { - _renderer=NULL; + _baseView=NULL; _objectActor=NULL; } @@ -55,6 +55,16 @@ namespace bbtk void vtkGObjectView::refresh() { + if(_model->getState()==NOTHING_HAPPENS) + { + _objectActor->GetProperty()->SetColor(0,0,0); + } + + if(_model->getState()==HIGHLIGHTED) + { + _objectActor->GetProperty()->SetColor(1,0,0); + } + //paint(); } @@ -67,9 +77,9 @@ namespace bbtk //========================================================================= - void vtkGObjectView::setRenderer(vtkRenderer* renderer) + void vtkGObjectView::setBaseView(wxVtkBaseView* baseView) { - _renderer=renderer; + _baseView=baseView; } //========================================================================= @@ -91,8 +101,17 @@ namespace bbtk void vtkGObjectView::addVtkActors()//virtual { - _renderer->AddActor(_objectActor); - _renderer->Render(); + _baseView->GetRenderer()->AddActor(_objectActor); + _baseView->GetRenderer()->Render(); + } + + //========================================================================= + + bool vtkGObjectView::isPointInside(int X,int Y) + { + double xx=X,yy=Y,zz=0; + _baseView->TransCoordScreenToWorld(xx,yy,zz); + return _model->isPointInside(xx,yy,zz); } //========================================================================= diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h index d314081..5c15592 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h @@ -48,7 +48,7 @@ Version: $Revision$ #include "GObjectModel.h" //Includes creaMaracasVisu -#include +#include //Includes vtk #include @@ -76,8 +76,10 @@ namespace bbtk //Public methods void setModel(GObjectModel *model); - void setRenderer(vtkRenderer* renderer); + void setBaseView(wxVtkBaseView* baseView); void initVtkObjects(); + + bool isPointInside(int X,int Y); virtual void refresh(); @@ -90,7 +92,7 @@ namespace bbtk protected: //Protected Attributes - vtkRenderer *_renderer; + wxVtkBaseView *_baseView; GObjectModel *_model; vtkActor *_objectActor;