From: corredor <> Date: Wed, 21 Apr 2010 14:20:03 +0000 (+0000) Subject: Vestion inestable .... It works but it must be changed the connector creation ... X-Git-Tag: v1_0_0~105 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=4339183c287d12a0b68265ec017cb51e6b24e89a;p=bbtkGEditor.git Vestion inestable .... It works but it must be changed the connector creation ... --- diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx new file mode 100644 index 0000000..05ce3b8 --- /dev/null +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx @@ -0,0 +1,117 @@ +/*========================================================================= +Program: bbtk +Module: $RCSfile$ +Language: C++ +Date: $Date$ +Version: $Revision$ +=========================================================================*/ + +/* --------------------------------------------------------------------- + +* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) +* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux +* +* This software is governed by the CeCILL-B license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL-B +* license as circulated by CEA, CNRS and INRIA at the following URL +* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +* or in the file LICENSE.txt. +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited +* liability. +* +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL-B license and that you accept its terms. +* ------------------------------------------------------------------------ */ + +/** +* \file +* \brief Class bbtk::GConnectorModel +*/ + + +#include "GConnectorModel.h" + +namespace bbtk +{ + + //========================================================================= + + GConnectorModel::GConnectorModel() + { + //_startPort = NULL; + //_endPort = NULL; + } + + //========================================================================= + + GConnectorModel::~GConnectorModel() + { + } + + //========================================================================= + + void GConnectorModel::setStartPort(GPortModel* startPort) + { + _startPort = startPort; + + double xCenter,yCenter,zCenter; + startPort->getCenter(xCenter,yCenter,zCenter); + double xFport,yFport,zFport; + startPort->getFinalPoint(xFport,yFport,zFport); + + setInicPoint(xCenter,yFport,zCenter); + } + + //========================================================================= + + void GConnectorModel::setEndPort(GPortModel* endPort) + { + _endPort = endPort; + + double xCenter,yCenter,zCenter; + endPort->getCenter(xCenter,yCenter,zCenter); + double xIport,yIport,zIport; + endPort->getInicPoint(xIport,yIport,zIport); + + setFinalPoint(xCenter,yIport,zCenter); + } + + //========================================================================= + + GPortModel* GConnectorModel::getStartPort() + { + return _startPort; + } + + //========================================================================= + + GPortModel* GConnectorModel::getEndPort() + { + return _endPort; + } + + //========================================================================= + + manualContourModel* GConnectorModel::getManualContourModel() + { + return _model; + } + + //========================================================================= + + void GConnectorModel::setManualContourModel(manualContourModel* model) + { + _model = model; + } + + //========================================================================= + +} // EO namespace bbtk + +// EOF + diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.h new file mode 100644 index 0000000..b6495c3 --- /dev/null +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.h @@ -0,0 +1,97 @@ +/*========================================================================= +Program: bbtk +Module: $RCSfile$ +Language: C++ +Date: $Date$ +Version: $Revision$ +=========================================================================*/ + +/* --------------------------------------------------------------------- + +* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) +* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux +* +* This software is governed by the CeCILL-B license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL-B +* license as circulated by CEA, CNRS and INRIA at the following URL +* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +* or in the file LICENSE.txt. +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited +* liability. +* +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL-B license and that you accept its terms. +* ------------------------------------------------------------------------ */ + + + +/** +* \file +* \brief Class bbtk::GConnectorModel : abstract black-box interface. +*/ + +/** +* \class bbtk::GConnectorModel +* \brief +*/ + +#ifndef __GConnectorModel_h__ +#define __GConnectorModel_h__ + +//Includes same project +#include "GlobalConstants.h" +#include "GObjectModel.h" +#include "GPortModel.h" + +//Includes creaMaracasVisu +#include + +//Includes std +#include + + +namespace bbtk +{ + + class GConnectorModel : public GObjectModel + { + + public: + + //Constructors + GConnectorModel(); + ~GConnectorModel(); + + //Public methods + void setStartPort(GPortModel* startPort); + void setEndPort(GPortModel* endPort); + void setManualContourModel(manualContourModel* model); + + GPortModel* getStartPort(); + GPortModel* getEndPort(); + manualContourModel* getManualContourModel(); + + private: + + //Attributes + GPortModel* _startPort; + GPortModel* _endPort; + manualContourModel* _model; + + //Private Methods + + protected: + //Protected methods + + }; + + +} +// namespace bbtk +#endif + diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx index 50b0fd6..7cd9220 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx @@ -75,11 +75,11 @@ namespace bbtk double posX=xInic,posY=yInic,posZ=zInic; if(_portType==GOUTPUTPORT) { - posY = yInic+PORT_HEIGHT; + posY = yFin; } else if(_portType==GINPUTPORT) { - posY = yFin; + posY = yInic+PORT_HEIGHT; } //Attribute '_posInBox' starts with value 0 and it represents the position of the port in the box from left to right diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h index 3d8d755..50770b8 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h @@ -61,12 +61,13 @@ namespace bbtk // Object dimensions const double BOX_HEIGHT = 15; const double BOX_WIDTH = 100; - const double PORT_HEIGHT = 2; - const double PORT_WIDTH = 2; + const double PORT_HEIGHT = 2.5; + const double PORT_WIDTH = 2.5; // Commands const int REPAINT = 201; const int INIT_CREATION_CONTOUR= 202; + const int FIN_CREATION_CONTOUR= 203; // Colors (object_state_(R|G|B)) const double BOXCONTOUR_NH_R=0.0; @@ -84,6 +85,8 @@ namespace bbtk const double BOXCONTOUR_SELECTED_R=0.65; const double BOXCONTOUR_SELECTED_G=0.65; const double BOXCONTOUR_SELECTED_B=0.05; + + // Id's } // namespace bbtk #endif diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx index a95d229..4e337be 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx @@ -41,96 +41,23 @@ namespace bbtk //========================================================================= - wxVtkSceneManager::wxVtkSceneManager(wxDropTarget *parent, wxVtk3DBaseView *baseView,int id) + wxVtkSceneManager::wxVtkSceneManager(wxDropTarget *parent, wxVtk3DBaseView *baseView,int idManager) { - _id=id; + _numBoxes=0; + _idManager=idManager; _baseView=baseView; + _idLastController=0; + if( _baseView!=NULL ) { - _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget(parent); registerController(this); configureBaseView(); - - ///// ******* TO ERASE ******* - //JUST TO TEST - // - /* - vtkConeSource *cone = vtkConeSource::New(); - - cone->SetResolution(10); - - vtkPolyDataMapper *map = vtkPolyDataMapper::New(); - map->SetInput(cone->GetOutput()); - - vtkActor *act = vtkActor::New(); - - act->SetMapper(map); - - vtkPoints *_pts = vtkPoints::New(); - _pts->SetNumberOfPoints(4); - - _pts->SetPoint(0, -100 , -100 , 900 ); - _pts->SetPoint(1, 100 , -100 , 900 ); - _pts->SetPoint(2, 100 , 100 , 900 ); - _pts->SetPoint(3, -100 , 100 , 900 ); - - vtkCellArray *lines = vtkCellArray::New(); - lines->InsertNextCell(5); - lines->InsertCellPoint(0); - lines->InsertCellPoint(1); - lines->InsertCellPoint(2); - lines->InsertCellPoint(3); - lines->InsertCellPoint(0); - - vtkPolyData *_pd = vtkPolyData::New(); - _pd->SetPoints( _pts ); - _pd->SetLines( lines ); - - vtkActor *_pointVtkActor = vtkActor::New(); - vtkPolyDataMapper* _bboxMapper = vtkPolyDataMapper::New(); - - _bboxMapper->SetInput(_pd); - _pointVtkActor->SetMapper(_bboxMapper); - - getRenderer()->AddActor(_pointVtkActor); - - - - - vtkPoints *_pts2 = vtkPoints::New(); - _pts2->SetNumberOfPoints(4); - - _pts2->SetPoint(0, -105 , -100 , -50 ); - _pts2->SetPoint(1, 100 , -100 , -50 ); - _pts2->SetPoint(2, 100 , 100 , -50 ); - _pts2->SetPoint(3, -105 , 100 , -50 ); - - vtkCellArray *lines2 = vtkCellArray::New(); - lines2->InsertNextCell(5); - lines2->InsertCellPoint(0); - lines2->InsertCellPoint(1); - lines2->InsertCellPoint(2); - lines2->InsertCellPoint(3); - lines2->InsertCellPoint(0); - - vtkPolyData *_pd2 = vtkPolyData::New(); - _pd2->SetPoints( _pts2 ); - _pd2->SetLines( lines2 ); - - vtkActor *_pointVtkActor2 = vtkActor::New(); - vtkPolyDataMapper* _bboxMapper2 = vtkPolyDataMapper::New(); - - _bboxMapper2->SetInput(_pd2); - _pointVtkActor2->SetMapper(_bboxMapper2); - - getRenderer()->AddActor(_pointVtkActor2); - - */ - // ******* TO ERASE ******* - ///////////////////// + _worldState=NOTHING_HAPPENS; } + + } @@ -199,17 +126,16 @@ namespace bbtk _baseView->TransCoordScreenToWorld(xx,yy,zz); model->setInicPoint(xx,yy,zz); - int cantObjects = _objects.size(); - cantObjects++; + _numBoxes++; std::stringstream stream; - if(cantObjects<10) + if(_numBoxes<10) { - stream << "Box0" << cantObjects; + stream << "Box0" << _numBoxes; } else { - stream << "Box" << cantObjects; + stream << "Box" << _numBoxes; } std::string arraystring = stream.str(); @@ -261,8 +187,6 @@ namespace bbtk registerController((InteractorStyleMaracas*) controller); //Add the object to the objects list - _objects.push_back(controller); - int newId = _controllers.size(); controller->setId(newId); _controllers[newId] = controller; @@ -323,10 +247,19 @@ namespace bbtk void wxVtkSceneManager::createGConnector(GPortModel* startPort) { - manualContourControler* manContourControl = new manualContourControler(); - GConnectorView* manViewerContour = new GConnectorView(); + int type = GCONNECTOR; + + manualConnectorContourController* manContourControl = new manualConnectorContourController(); + manualConnectorContourView* manViewerContour = new manualConnectorContourView(); manualContourModel* manContourModel = new manualContourModel(); + + GConnectorController* connectorcontroller = new GConnectorController(); + GConnectorModel* connectorModel = new GConnectorModel(); + GConnectorView* connectorView = new GConnectorView(); + connectorModel->setGObjectType(type); + manContourModel->SetCloseContour(false); + connectorModel->setStartPort(startPort); manViewerContour->SetModel( manContourModel ); manViewerContour->SetWxVtkBaseView( _baseView ); @@ -339,21 +272,14 @@ namespace bbtk manViewerContour->SetWidthLine(1); manContourControl->SetModelView( manContourModel , manViewerContour ); - manContourControl->Configure(); - int i,sizeLstPoints = manContourModel->GetSizeLstPoints(); - - for ( i=0; iAddPoint(); - } - + manContourControl->CreateNewManualContour(); manViewerContour->RefreshContour(); double x,y,z; - startPort->getCenter(x,y,z); + connectorModel->getInicPoint(x,y,z); manContourControl->SetState(1); manContourModel->SetCloseContour(false); @@ -370,7 +296,15 @@ namespace bbtk manContourControl->SetMoving( false ); - registerController((InteractorStyleMaracas*) manContourControl); + registerController((InteractorStyleMaracas*) connectorcontroller); + + connectorcontroller->setManualContourController(manContourControl); + connectorModel->setManualContourModel(manContourModel); + connectorcontroller->setModelAndView(connectorModel,NULL); + + int newId = _controllers.size(); + connectorcontroller->setId(newId); + _controllers[newId] = connectorcontroller; } @@ -407,22 +341,71 @@ namespace bbtk void wxVtkSceneManager::update(int idController,int command) { - if(command==INIT_CREATION_CONTOUR) + if(command == INIT_CREATION_CONTOUR) { GObjectController* cont = _controllers[idController]; if(cont->getGObjectType() == GPORT) { - GPortController* controller = (GPortController*)cont; - vtkGPortView* view = (vtkGPortView*)controller->getView(); - - if(view->getState() == CREATING_CONTOUR) + 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++) + { + GObjectController* cont = _controllers[i]; + if(cont->getGObjectType() == GPORT ) { - //pre: The port in this state is an output port - GPortModel* startOutputPort = (GPortModel*)controller->getModel(); - createGConnector(startOutputPort); + GPortModel* port = (GPortModel*)cont->getModel(); + if(port->getPortType()==GINPUTPORT) + { + cont->SetActive(true); + } + else + { + cont->getView()->setState(NOTHING_HAPPENS); + cont->SetActive(false); + } } + else + { + cont->getView()->setState(NOTHING_HAPPENS); + cont->SetActive(false); + } } + _worldState = CREATING_CONTOUR; + } + 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) + { + 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); + + for(int i=0;i<_controllers.size();i++) + { + GObjectController* cont = _controllers[i]; + if(cont->getView()!=NULL) + { + cont->getView()->setState(NOTHING_HAPPENS); + } + cont->SetActive(true); + } } } diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h index 38552db..4a3f7e1 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h @@ -47,8 +47,12 @@ Version: $Revision$ #include "GObjectsMVCFactory.h" #include "Observer.h" #include "GPortModel.h" -#include "vtkGPortView.h" #include "GConnectorView.h" +#include "GConnectorModel.h" +#include "GConnectorController.h" +#include "vtkGPortView.h" +#include "manualConnectorContourView.h" +#include "manualConnectorContourController.h" //Includes bbtk #include @@ -67,8 +71,6 @@ Version: $Revision$ #include #include -#include -#include //Includes std #include @@ -81,7 +83,7 @@ namespace bbtk class wxVtkSceneManager : public InteractorStyleMaracas , public Observer { public: - wxVtkSceneManager(wxDropTarget *parent, wxVtk3DBaseView *baseView, int id); + wxVtkSceneManager(wxDropTarget *parent, wxVtk3DBaseView *baseView, int idManager); ~wxVtkSceneManager(); void configureBaseView(); @@ -104,10 +106,19 @@ namespace bbtk private: - int _id; + // Last controller created + int _idLastController; + + // Id of the manager, the same of the panel + int _idManager; + + // Boxes number in the scene + int _numBoxes; + wxVtk3DBaseView *_baseView; - std::vector _objects; + int _worldState; + std::map _controllers; protected: diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx new file mode 100644 index 0000000..02c5fed --- /dev/null +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx @@ -0,0 +1,195 @@ +/*========================================================================= +Program: bbtk +Module: $RCSfile$ +Language: C++ +Date: $Date$ +Version: $Revision$ +=========================================================================*/ + +/* --------------------------------------------------------------------- + +* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) +* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux +* +* This software is governed by the CeCILL-B license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL-B +* license as circulated by CEA, CNRS and INRIA at the following URL +* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +* or in the file LICENSE.txt. +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited +* liability. +* +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL-B license and that you accept its terms. +* ------------------------------------------------------------------------ */ + +/** +* \file +* \brief Class bbtk::GConnectorController +*/ + + +#include "GConnectorController.h" + +namespace bbtk +{ + + + //========================================================================= + GConnectorController::GConnectorController() + { + + } + + //========================================================================= + + GConnectorController::~GConnectorController() + { + } + + //========================================================================= + + bool GConnectorController::OnMouseMove() + { + + if ( _vtkInteractorStyleBaseView!=NULL) + { + int X,Y; + wxVTKRenderWindowInteractor *_wxVTKiren; + _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); + _wxVTKiren->GetEventPosition( X , Y ); + + if ( (_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) &&(_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) ) + { + _controller->MouseMove(X,Y); + } + + } + return true; + } + + //========================================================================= + + bool GConnectorController::OnLeftButtonDown() + { + + if ( _vtkInteractorStyleBaseView!=NULL ) + { + int X,Y; + wxVTKRenderWindowInteractor *wxVTKiren; + wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren->GetEventPosition(X,Y); + + _controller->SetKeyBoardMoving( false ); + _controller->MouseClickLeft(X,Y); + + } + return true; + } + + //========================================================================= + + bool GConnectorController::OnLeftButtonUp() + { + if( _vtkInteractorStyleBaseView!= NULL ) + { + int X,Y; + wxVTKRenderWindowInteractor *wxVTKiren; + wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren->GetEventPosition(X, Y); + + _controller->MouseReleaseLeft(X,Y); + + } + return true; + + } + + //========================================================================= + + bool GConnectorController::OnLeftDClick() + { + + if ( _vtkInteractorStyleBaseView!=NULL ) + { + int X,Y; + wxVTKRenderWindowInteractor *wxVTKiren; + wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren->GetEventPosition(X,Y); + + _controller->MouseDLeft(X,Y); + + } + return true; + } + + //========================================================================= + + bool GConnectorController::OnRightButtonDown() + { + if( _vtkInteractorStyleBaseView!= NULL ) + { + int X,Y; + wxVTKRenderWindowInteractor *wxVTKiren; + wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren->GetEventPosition(X, Y); + + _controller->MouseClickRight(X,Y); + + } + return true; + } + + //========================================================================= + + bool GConnectorController::OnRightButtonUp() + { + return true; + } + + //========================================================================= + + bool GConnectorController::OnMiddleButtonDown() + { + if ( _vtkInteractorStyleBaseView!=NULL ) + { + int X,Y,Z=900; + wxVTKRenderWindowInteractor *wxVTKiren; + wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren->GetEventPosition(X, Y); + _controller->GetManualViewBaseContour()->InitMove( X, Y,Z); + } + return true; + } + //========================================================================= + bool GConnectorController::OnMiddleButtonUp() + { + return true; + } + + //========================================================================= + + manualContourControler* GConnectorController::getManualContourController() + { + return _controller; + } + + //========================================================================= + + void GConnectorController::setManualContourController(manualContourControler* controller) + { + _controller = controller; + _controller->SetVtkInteractorStyleBaseView(_vtkInteractorStyleBaseView); + } + + //========================================================================= + +} // EO namespace bbtk + +// EOF + diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.h new file mode 100644 index 0000000..fa92fc1 --- /dev/null +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.h @@ -0,0 +1,97 @@ +/*========================================================================= +Program: bbtk +Module: $RCSfile$ +Language: C++ +Date: $Date$ +Version: $Revision$ +=========================================================================*/ + +/* --------------------------------------------------------------------- + +* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) +* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux +* +* This software is governed by the CeCILL-B license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL-B +* license as circulated by CEA, CNRS and INRIA at the following URL +* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +* or in the file LICENSE.txt. +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited +* liability. +* +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL-B license and that you accept its terms. +* ------------------------------------------------------------------------ */ + + + +/** +* \file +* \brief Class bbtk::GConnectorController : abstract black-box interface. +*/ + +/** +* \class bbtk::GConnectorController +* \brief +*/ + +#ifndef __GConnectorController_h__ +#define __GConnectorController_h__ + +//Includes same project +#include "GObjectController.h" + +//Includes creaMaracasVisu +#include + +//Includes std +#include + + +namespace bbtk +{ + + class GConnectorController : public GObjectController + { + + public: + + //Constructors + GConnectorController(); + ~GConnectorController(); + + //Public methods + virtual bool OnMouseMove(); + virtual bool OnLeftButtonDown(); + virtual bool OnLeftButtonUp(); + virtual bool OnLeftDClick(); + virtual bool OnRightButtonDown(); + virtual bool OnRightButtonUp(); + virtual bool OnMiddleButtonDown(); + virtual bool OnMiddleButtonUp(); + + manualContourControler* getManualContourController(); + void setManualContourController(manualContourControler* controller); + + private: + + //Attributes + manualContourControler* _controller; + + //Private Methods + + protected: + //Protected methods + + }; + + +} +// namespace bbtk +#endif + diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorView.cxx index ee86d3d..9c2388f 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorView.cxx @@ -53,7 +53,7 @@ namespace bbtk void GConnectorView::TransfromCoordViewWorld(double &X, double &Y, double &Z, int type) { - _wxvtkbaseview->TransCoordScreenToWorld(X,Y,Z,type); + //_wxvtkbaseview->TransCoordScreenToWorld(X,Y,Z,type); } } // EO namespace bbtk diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorView.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorView.h index 3cd5c11..fb98251 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorView.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorView.h @@ -44,10 +44,9 @@ Version: $Revision$ #define __GConnectorView_h__ //Includes same project +#include "vtkGObjectView.h" //Includes creaMaracasVisu -#include - //Includes std #include @@ -56,7 +55,7 @@ Version: $Revision$ namespace bbtk { - class GConnectorView : public manualViewContour + class GConnectorView : public vtkGObjectView { public: diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.cxx index b2f863b..6610608 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.cxx @@ -43,7 +43,7 @@ namespace bbtk //========================================================================= GPortController::GPortController() { - + _isLeftClickDown=false; } //========================================================================= @@ -64,57 +64,54 @@ namespace bbtk int state = _view->getState(); - int portType = ((GPortModel*)_model)->getPortType(); - //Evaluate new state - if(!_model->hasChanged() && state==HIGHLIGHTED && portType==GOUTPUTPORT ) + if(state == HIGHLIGHTED) { - _view->setState(CREATING_CONTOUR); - _model->setChanged(); + _isLeftClickDown=true; } - _model->notifyObservers(_id); - } return true; } //========================================================================= bool GPortController::OnLeftButtonUp() { - if ( _vtkInteractorStyleBaseView!=NULL ) + int state = _view->getState(); + if(state == HIGHLIGHTED && _isLeftClickDown) { - int X,Y; - wxVTKRenderWindowInteractor *wxVTKiren; - wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); - wxVTKiren->GetEventPosition(X,Y); + _isLeftClickDown=false; - int state = _view->getState(); - - //Evaluate new state - if(!_model->hasChanged() && state==CREATING_CONTOUR) + if ( _vtkInteractorStyleBaseView!=NULL ) { - if(_view->isPointInside(X,Y)) + int X,Y; + wxVTKRenderWindowInteractor *wxVTKiren; + wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren->GetEventPosition(X,Y); + + int portType = ((GPortModel*)_model)->getPortType(); + + //Evaluate new state + if(portType==GOUTPUTPORT) { - _view->setState(CREATING_CONTOUR); _model->setChanged(); _model->notifyObservers(_id,INIT_CREATION_CONTOUR); } - else + else if (portType==GINPUTPORT) { - _view->setState(NOTHING_HAPPENS); _model->setChanged(); - _model->notifyObservers(_id); + _model->notifyObservers(_id,FIN_CREATION_CONTOUR); } + } - - - } + return true; } //========================================================================= + + } // EO namespace bbtk // EOF diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.h index fdc8a24..de343ea 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.h @@ -74,6 +74,7 @@ namespace bbtk private: //Attributes + bool _isLeftClickDown; //Private Methods diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourController.cxx new file mode 100644 index 0000000..6a7c068 --- /dev/null +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourController.cxx @@ -0,0 +1,162 @@ +/*========================================================================= +Program: bbtk +Module: $RCSfile$ +Language: C++ +Date: $Date$ +Version: $Revision$ +=========================================================================*/ + +/* --------------------------------------------------------------------- + +* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) +* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux +* +* This software is governed by the CeCILL-B license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL-B +* license as circulated by CEA, CNRS and INRIA at the following URL +* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +* or in the file LICENSE.txt. +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited +* liability. +* +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL-B license and that you accept its terms. +* ------------------------------------------------------------------------ */ + +/** +* \file +* \brief Class bbtk::manualConnectorContourController +*/ + + +#include "manualConnectorContourController.h" + +namespace bbtk +{ + + + //========================================================================= + manualConnectorContourController::manualConnectorContourController() + { + } + + //========================================================================= + manualConnectorContourController::~manualConnectorContourController() + { + } + //========================================================================= + + void manualConnectorContourController::MouseClickRight(int x, int y) + { + SetCompleteCreation( true ); + SetKeyBoardMoving( false ); + GetManualContourModel()->SetCloseContour(false); + + SetEditable( false ); + SetPosibleToMove( false ); + SetState(0); + + if(!_created) + { + //DeleteContour(); + } + } + + //========================================================================= + void manualConnectorContourController::MouseClickLeft(int x, int y){ + + bool ok = false; + int z = GetZ(); + int size= GetManualViewBaseContour()->GetNumberOfPoints(); + + // Insert a Control Point with shift+ClickLeft + vtkRenderWindowInteractor *vtkrenderwindowinteractor = _vtkInteractorStyleBaseView->GetInteractor(); + if( IsEditable() ) + { + if ( (_vtkInteractorStyleBaseView!=NULL) && (GetState()==0) && ( (vtkrenderwindowinteractor!=NULL) && (vtkrenderwindowinteractor->GetShiftKey()==1) ) ) + { + ok=true; + InsertPoint(x,y,z); + size++; + } + // Start to Insert Control Points with ClickLeft (Empty contour) + if ((GetState()==0) && (size==0) && (_easyCreation==true) ) + { + ok=true; + SetState(1); + GetManualContourModel()->SetCloseContour(false); + AddPoint(x,y,z); + } + + // RaC Just create 2 points + if ((GetState()==1) && (_easyCreation==true) && GetNumberOfPointsManualContour()==2) + { + ok=true; + + SetCompleteCreation( true ); + SetKeyBoardMoving( false ); + GetManualContourModel()->SetCloseContour(false); + + SetEditable( false ); + SetPosibleToMove( false ); + SetState(0); + } + + // Continue to Insert Control Points with ClickLeft (After being empty the contour) + if ((GetState()==1) && (_easyCreation==true) ) + { + ok=true; + AddPoint(x,y,z); + _bakIdPoint=GetNumberOfPointsManualContour() - 1; + } + + // Insert Control Points IF Contour si Selected + if ((GetState()==0) && GetManualViewBaseContour()->GetPosibleSelected() ) + { + ok=true; + InsertPoint(x,y,z); + _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z); + SetState(6); + } + // Chose id of Control Point to be move + if ( (GetState()==0 || GetState()==6) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ) + { + ok=true; + _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z); + SetState(5); + } + // If nothing selected _state=7 + if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)==-1 ) ) + { + //ok=true; + _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z); + SetState(7); + } + }else{ + SetPosibleToMove( true ); + GetManualViewBaseContour()->SetSelected( GetManualViewBaseContour()->GetPosibleSelected() ); + } // IsEditable + + if ( GetState() == 0 && GetManualViewBaseContour()->GetPosibleSelected() ) + { + SetMoving( true ); + ok=true; + GetManualViewBaseContour()->InitMove(x,y,z); + SetState(6); + } + if (ok==true) + { + GetManualViewBaseContour()->Refresh(); + } + } + //========================================================================= + +} // EO namespace bbtk + +// EOF + diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourController.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourController.h new file mode 100644 index 0000000..cb404e0 --- /dev/null +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourController.h @@ -0,0 +1,89 @@ +/*========================================================================= +Program: bbtk +Module: $RCSfile$ +Language: C++ +Date: $Date$ +Version: $Revision$ +=========================================================================*/ + +/* --------------------------------------------------------------------- + +* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) +* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux +* +* This software is governed by the CeCILL-B license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL-B +* license as circulated by CEA, CNRS and INRIA at the following URL +* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +* or in the file LICENSE.txt. +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited +* liability. +* +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL-B license and that you accept its terms. +* ------------------------------------------------------------------------ */ + + + +/** +* \file +* \brief Class bbtk::manualConnectorContourController : abstract black-box interface. +*/ + +/** +* \class bbtk::manualConnectorContourController +* \brief +*/ + +#ifndef __manualConnectorContourController_h__ +#define __manualConnectorContourController_h__ + +//Includes same project +#include "manualContourControler.h" + +//Includes creaMaracasVisu +#include + + +//Includes std +#include + + +namespace bbtk +{ + + class manualConnectorContourController : public manualContourControler + { + + public: + + //Constructors + manualConnectorContourController(); + ~manualConnectorContourController(); + + //Public methods + virtual void MouseClickRight(int x, int y); + virtual void MouseClickLeft(int x, int y); + + private: + + //Attributes + + + //Private Methods + + protected: + //Protected methods + + }; + + +} +// namespace bbtk +#endif + diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourView.cxx new file mode 100644 index 0000000..e361e63 --- /dev/null +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourView.cxx @@ -0,0 +1,74 @@ +/*========================================================================= +Program: bbtk +Module: $RCSfile$ +Language: C++ +Date: $Date$ +Version: $Revision$ +=========================================================================*/ + +/* --------------------------------------------------------------------- + +* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) +* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux +* +* This software is governed by the CeCILL-B license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL-B +* license as circulated by CEA, CNRS and INRIA at the following URL +* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +* or in the file LICENSE.txt. +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited +* liability. +* +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL-B license and that you accept its terms. +* ------------------------------------------------------------------------ */ + +/** +* \file +* \brief Class bbtk::manualConnectorContourView +*/ + + +#include "manualConnectorContourView.h" + +namespace bbtk +{ + + + //========================================================================= + manualConnectorContourView::manualConnectorContourView() + { + } + + //========================================================================= + manualConnectorContourView::~manualConnectorContourView() + { + } + //========================================================================= + + void manualConnectorContourView::TransfromCoordViewWorld(double &X, double &Y, double &Z, int type) + { + _wxvtkbaseview->TransCoordScreenToWorld(X,Y,Z,type); + } + + //========================================================================= + + void manualConnectorContourView::removeStartAndEnd() + { + _wxvtkbaseview->GetRenderer()->RemoveActor( _lstViewPoints[0]->GetVtkActor() ); + + _wxvtkbaseview->GetRenderer()->RemoveActor( _lstViewPoints[_lstViewPoints.size()-1]->GetVtkActor() ); + } + + //========================================================================= + + +} // EO namespace bbtk + +// EOF + diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourView.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourView.h new file mode 100644 index 0000000..bcc076f --- /dev/null +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourView.h @@ -0,0 +1,88 @@ +/*========================================================================= +Program: bbtk +Module: $RCSfile$ +Language: C++ +Date: $Date$ +Version: $Revision$ +=========================================================================*/ + +/* --------------------------------------------------------------------- + +* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) +* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux +* +* This software is governed by the CeCILL-B license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL-B +* license as circulated by CEA, CNRS and INRIA at the following URL +* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +* or in the file LICENSE.txt. +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited +* liability. +* +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL-B license and that you accept its terms. +* ------------------------------------------------------------------------ */ + + + +/** +* \file +* \brief Class bbtk::manualConnectorContourView : abstract black-box interface. +*/ + +/** +* \class bbtk::manualConnectorContourView +* \brief +*/ + +#ifndef __manualConnectorContourView_h__ +#define __manualConnectorContourView_h__ + +//Includes same project + +//Includes creaMaracasVisu +#include + + +//Includes std +#include + + +namespace bbtk +{ + + class manualConnectorContourView : public manualViewContour + { + + public: + + //Constructors + manualConnectorContourView(); + ~manualConnectorContourView(); + + //Public methods + virtual void TransfromCoordViewWorld(double &X, double &Y, double &Z, int type=2); + void removeStartAndEnd(); + + private: + + //Attributes + + + //Private Methods + + protected: + //Protected methods + + }; + + +} +// namespace bbtk +#endif + diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx index 0359978..b4f631d 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx @@ -62,10 +62,11 @@ namespace bbtk // RaC In the actual version, zInic=zFin=900 + double mid = (xInic+xFin)/2; + _pts->SetPoint(0, xInic, yInic, zInic ); - _pts->SetPoint(1, xInic, yFin, zInic ); - _pts->SetPoint(2, xFin, yFin, zFin ); - _pts->SetPoint(3, xFin, yInic, zFin ); + _pts->SetPoint(1, mid, yFin, zInic ); + _pts->SetPoint(2, xFin, yInic, zFin ); setRefreshWaiting(); } @@ -80,7 +81,7 @@ namespace bbtk vtkPolyDataMapper* _bboxMapper=vtkPolyDataMapper::New(); _objectActor=vtkActor::New(); - _pts->SetNumberOfPoints(4); + _pts->SetNumberOfPoints(3); double xInic, yInic,zInic,xFin, yFin,zFin; @@ -88,16 +89,17 @@ namespace bbtk _model->getFinalPoint(xFin, yFin,zFin); // RaC In the actual version, zInic=zFin=900 + + double mid = (xInic+xFin)/2; + _pts->SetPoint(0, xInic, yInic, zInic ); - _pts->SetPoint(1, xInic, yFin, zInic ); - _pts->SetPoint(2, xFin, yFin, zFin ); - _pts->SetPoint(3, xFin, yInic, zFin ); + _pts->SetPoint(1, mid, yFin, zInic ); + _pts->SetPoint(2, xFin, yInic, zFin ); - lines->InsertNextCell(5); + lines->InsertNextCell(4); lines->InsertCellPoint(0); lines->InsertCellPoint(1); lines->InsertCellPoint(2); - lines->InsertCellPoint(3); lines->InsertCellPoint(0); _pd->SetPoints( _pts );