--- /dev/null
+/*=========================================================================
+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
+
--- /dev/null
+/*=========================================================================
+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 <manualContourModel.h>
+
+//Includes std
+#include <iostream>
+
+
+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
+
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
// 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;
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
//=========================================================================
- 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;
}
+
+
}
_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();
registerController((InteractorStyleMaracas*) controller);
//Add the object to the objects list
- _objects.push_back(controller);
-
int newId = _controllers.size();
controller->setId(newId);
_controllers[newId] = controller;
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 );
manViewerContour->SetWidthLine(1);
manContourControl->SetModelView( manContourModel , manViewerContour );
- manContourControl->Configure();
- int i,sizeLstPoints = manContourModel->GetSizeLstPoints();
-
- for ( i=0; i<sizeLstPoints; i++ )
- {
- manViewerContour->AddPoint();
- }
-
+
manContourControl->CreateNewManualContour();
manViewerContour->RefreshContour();
double x,y,z;
- startPort->getCenter(x,y,z);
+ connectorModel->getInicPoint(x,y,z);
manContourControl->SetState(1);
manContourModel->SetCloseContour(false);
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;
}
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);
+ }
}
}
#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 <bbtkBlackBoxInputDescriptor.h>
#include <vtkRenderer.h>
#include <vtkInteractorStyleImage.h>
-#include <vtkVectorText.h>
-#include <vtkLinearExtrusionFilter.h>
//Includes std
#include <iostream>
class wxVtkSceneManager : public InteractorStyleMaracas , public Observer
{
public:
- wxVtkSceneManager(wxDropTarget *parent, wxVtk3DBaseView *baseView, int id);
+ wxVtkSceneManager(wxDropTarget *parent, wxVtk3DBaseView *baseView, int idManager);
~wxVtkSceneManager();
void configureBaseView();
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<GObjectController*> _objects;
+ int _worldState;
+
std::map<int,GObjectController*> _controllers;
protected:
--- /dev/null
+/*=========================================================================
+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
+
--- /dev/null
+/*=========================================================================
+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 <manualContourControler.h>
+
+//Includes std
+#include <iostream>
+
+
+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
+
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
#define __GConnectorView_h__
//Includes same project
+#include "vtkGObjectView.h"
//Includes creaMaracasVisu
-#include <manualViewContour.h>
-
//Includes std
#include <iostream>
namespace bbtk
{
- class GConnectorView : public manualViewContour
+ class GConnectorView : public vtkGObjectView
{
public:
//=========================================================================
GPortController::GPortController()
{
-
+ _isLeftClickDown=false;
}
//=========================================================================
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
private:
//Attributes
+ bool _isLeftClickDown;
//Private Methods
--- /dev/null
+/*=========================================================================
+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
+
--- /dev/null
+/*=========================================================================
+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 <manualContourControler.h>
+
+
+//Includes std
+#include <iostream>
+
+
+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
+
--- /dev/null
+/*=========================================================================
+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
+
--- /dev/null
+/*=========================================================================
+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 <manualViewContour.h>
+
+
+//Includes std
+#include <iostream>
+
+
+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
+
// 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();
}
vtkPolyDataMapper* _bboxMapper=vtkPolyDataMapper::New();
_objectActor=vtkActor::New();
- _pts->SetNumberOfPoints(4);
+ _pts->SetNumberOfPoints(3);
double xInic, yInic,zInic,xFin, yFin,zFin;
_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 );