From 8fa663b7b47e797e6e23722d1fef41c40419a6d6 Mon Sep 17 00:00:00 2001 From: corredor <> Date: Wed, 14 Apr 2010 14:32:17 +0000 Subject: [PATCH] Important change in the project to visualize the contour when the output was selected... --- .../bbsKernelEditorGraphic/GBlackBoxModel.cxx | 7 +- .../bbsKernelEditorGraphic/GBlackBoxModel.h | 2 +- .../bbsKernelEditorGraphic/GlobalConstants.h | 8 +- .../wxVtkSceneManager.cxx | 75 +++++++++++----- .../wxVtkSceneManager.h | 2 +- .../bbsVtkGUIEditorGraphic/GConnectorView.cxx | 62 +++++++++++++ .../bbsVtkGUIEditorGraphic/GConnectorView.h | 87 +++++++++++++++++++ .../GPortController.cxx | 2 +- .../vtkGBlackBoxView.cxx | 29 ++++--- .../bbsVtkGUIEditorGraphic/vtkGObjectView.cxx | 6 +- .../bbsVtkGUIEditorGraphic/vtkGPortView.cxx | 19 ++-- 11 files changed, 243 insertions(+), 56 deletions(-) create mode 100644 lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorView.cxx create mode 100644 lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorView.h diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx index f2866f5..876dbb0 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx @@ -92,7 +92,6 @@ namespace bbtk void GBlackBoxModel::move(double xx,double yy,double zz) { setInicPoint(xx,yy,zz); - //std::cout<<"GBlackBoxModel::move xx:"<getState() == CREATING_CONTOUR) + if(_outputs[i]->getState() == CREATING_CONTOUR) { - temp = _inputs[i]; + temp = _outputs[i]; } } diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.h index f1c36cf..160ac37 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.h @@ -75,7 +75,7 @@ namespace bbtk int getNumInputPorts(); int getNumOutputPorts(); virtual void move(double xx,double yy,double zz); - GPortModel* getStartInputPort(); + GPortModel* getStartOutputPort(); private: diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h index 4fb178e..06afba2 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h @@ -59,10 +59,10 @@ namespace bbtk const int CREATING_CONTOUR=106; // Object dimensions - const double BOX_HEIGHT=0.15; - const double BOX_WIDTH=1.0; - const double PORT_HEIGHT=0.04; - const double PORT_WIDTH=0.04; + const double BOX_HEIGHT=15; + const double BOX_WIDTH=100; + const double PORT_HEIGHT=3; + const double PORT_WIDTH=3; // Commands const int REPAINT = 201; diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx index 005c52f..7370b19 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx @@ -54,10 +54,8 @@ namespace bbtk ///// ******* TO ERASE ******* //JUST TO TEST - // - - - + // + /* vtkConeSource *cone = vtkConeSource::New(); cone->SetResolution(10); @@ -72,10 +70,10 @@ namespace bbtk vtkPoints *_pts = vtkPoints::New(); _pts->SetNumberOfPoints(4); - _pts->SetPoint(0, -1 , -1 , 0 ); - _pts->SetPoint(1, 1 , -1 , 0 ); - _pts->SetPoint(2, 1 , 1 , 0 ); - _pts->SetPoint(3, -1 , 1 , 0 ); + _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); @@ -97,22 +95,45 @@ namespace bbtk getRenderer()->AddActor(_pointVtkActor); - // Create a vector text - vtkVectorText* vecText = vtkVectorText::New(); - vecText->SetText("vtkVectorText"); - - vtkPolyDataMapper* txtMapper = vtkPolyDataMapper::New(); - txtMapper->SetInputConnection( vecText->GetOutputPort()); - vtkActor* txtActor = vtkActor::New(); - txtActor->SetMapper(txtMapper); - //getRenderer()->AddActor(txtActor); + + + 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 ******* ///////////////////// } } + //========================================================================= void wxVtkSceneManager::disconnectDrop() { @@ -136,10 +157,17 @@ namespace bbtk iren->SetInteractorStyle(interactorstylebaseview); interactorstylebaseview->SetwxVtkBaseView(_baseView); + double posCamera[3]; + _baseView->GetRenderer()->GetActiveCamera()->ParallelProjectionOn(); + _baseView->GetRenderer()->GetActiveCamera()->SetPosition(0,0,1000); + _baseView->GetRenderer()->GetActiveCamera()->GetPosition(posCamera); + _baseView->GetRenderer()->ResetCamera(); + _baseView->GetRenderer()->ResetCameraClippingRange(); + + _baseView->GetRenderer()->SetBackground(0.9,0.9,0.9); _baseView->GetRenderer()->GradientBackgroundOff(); _baseView->Refresh(); - } //========================================================================= @@ -167,7 +195,7 @@ namespace bbtk double yy = windowHeight-y; //z value is not important yet, because it is only used a parallel projection - double zz = 0; + double zz = 900; _baseView->TransCoordScreenToWorld(xx,yy,zz); model->setInicPoint(xx,yy,zz); @@ -175,7 +203,7 @@ namespace bbtk int cantObjects = _objects.size(); cantObjects++; std::stringstream stream; - stream << "Object " << cantObjects; + stream << "Box " << cantObjects; std::string arraystring = stream.str(); model->setBBTKName(arraystring); @@ -295,7 +323,7 @@ namespace bbtk void wxVtkSceneManager::createGConnector(GPortModel* startPort) { manualContourControler* manContourControl = new manualContourControler(); - manualViewContour* manViewerContour = new manualViewContour(); + GConnectorView* manViewerContour = new GConnectorView(); manualContourModel* manContourModel = new manualContourModel(); @@ -312,6 +340,7 @@ namespace bbtk manContourControl->SetModelView( manContourModel , manViewerContour ); manContourControl->Configure(); int i,sizeLstPoints = manContourModel->GetSizeLstPoints(); + //std::cout<<"RaC wxVtkSceneManager::createGConnector "<AddPoint(); @@ -363,8 +392,8 @@ namespace bbtk if(_objects[i]->getGObjectType() == GBLACKBOX) { - GPortModel* startInputPort=((GBlackBoxModel*)_objects[i])->getStartInputPort(); - createGConnector(startInputPort); + GPortModel* startOutputPort=((GBlackBoxModel*)_objects[i])->getStartOutputPort(); + createGConnector(startOutputPort); } else diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h index 0692d82..e1dccfc 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h @@ -47,6 +47,7 @@ Version: $Revision$ #include "GObjectsMVCFactory.h" #include "Observer.h" #include "GPortModel.h" +#include "GConnectorView.h" //Includes bbtk #include @@ -57,7 +58,6 @@ Version: $Revision$ #include #include #include -#include #include //Includes vtk diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorView.cxx new file mode 100644 index 0000000..ee86d3d --- /dev/null +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorView.cxx @@ -0,0 +1,62 @@ +/*========================================================================= +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::GConnectorView +*/ + + +#include "GConnectorView.h" + +namespace bbtk +{ + + + //========================================================================= + GConnectorView::GConnectorView() + { + } + + //========================================================================= + GConnectorView::~GConnectorView() + { + } + //========================================================================= + + void GConnectorView::TransfromCoordViewWorld(double &X, double &Y, double &Z, int type) + { + _wxvtkbaseview->TransCoordScreenToWorld(X,Y,Z,type); + } + +} // EO namespace bbtk + +// EOF + diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorView.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorView.h new file mode 100644 index 0000000..3cd5c11 --- /dev/null +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorView.h @@ -0,0 +1,87 @@ +/*========================================================================= +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::GConnectorView : abstract black-box interface. +*/ + +/** +* \class bbtk::GConnectorView +* \brief +*/ + +#ifndef __GConnectorView_h__ +#define __GConnectorView_h__ + +//Includes same project + +//Includes creaMaracasVisu +#include + + +//Includes std +#include + + +namespace bbtk +{ + + class GConnectorView : public manualViewContour + { + + public: + + //Constructors + GConnectorView(); + ~GConnectorView(); + + //Public methods + virtual void TransfromCoordViewWorld(double &X, double &Y, double &Z, int type=2); + + private: + + //Attributes + + + //Private Methods + + protected: + //Protected methods + + }; + + +} +// namespace bbtk +#endif + diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.cxx index c9c196b..7e66a83 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.cxx @@ -67,7 +67,7 @@ namespace bbtk int portType = ((GPortModel*)_model)->getPortType(); //Evaluate new state - if(!_model->hasChanged() && state==HIGHLIGHTED && portType==GINPUTPORT ) + if(!_model->hasChanged() && state==HIGHLIGHTED && portType==GOUTPUTPORT ) { _model->setState(CREATING_CONTOUR); _model->setChanged(); diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx index 64d1cec..a354fd7 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx @@ -86,10 +86,12 @@ namespace bbtk _model->getInicPoint(xInic,yInic,zInic); _model->getFinalPoint(xFin, yFin,zFin); - _pts->SetPoint(0, xInic, yInic, 0 ); - _pts->SetPoint(1, xInic, yFin, 0 ); - _pts->SetPoint(2, xFin, yFin, 0 ); - _pts->SetPoint(3, xFin, yInic, 0 ); + // RaC In the actual version, zInic=zFin=900 + + _pts->SetPoint(0, xInic, yInic, zInic ); + _pts->SetPoint(1, xInic, yFin, zInic ); + _pts->SetPoint(2, xFin, yFin, zFin ); + _pts->SetPoint(3, xFin, yInic, zFin ); //----------- @@ -118,10 +120,12 @@ namespace bbtk _model->getInicPoint(xInic,yInic,zInic); _model->getFinalPoint(xFin, yFin,zFin); - _pts->SetPoint(0, xInic, yInic, 0 ); - _pts->SetPoint(1, xInic, yFin, 0 ); - _pts->SetPoint(2, xFin, yFin, 0 ); - _pts->SetPoint(3, xFin, yInic, 0 ); + // RaC In the actual version, zInic=zFin=900 + + _pts->SetPoint(0, xInic, yInic, zInic ); + _pts->SetPoint(1, xInic, yFin, zInic ); + _pts->SetPoint(2, xFin, yFin, zFin ); + _pts->SetPoint(3, xFin, yInic, zFin ); lines->InsertNextCell(5); lines->InsertCellPoint(0); @@ -163,6 +167,7 @@ namespace bbtk //------------ updatePositionTextActors( xInic, yInic, zInic); + _nameActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B); _typeActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B); @@ -182,11 +187,11 @@ namespace bbtk void vtkGBlackBoxView::updatePositionTextActors(double xInic, double yInic, double zInic) { - _nameActor->SetPosition(xInic+0.04,yInic-0.05,zInic); - _nameActor->SetScale(0.03,0.02,1); + _nameActor->SetPosition(xInic+4,yInic-5,zInic); + _nameActor->SetScale(3,2,1); - _typeActor->SetPosition(xInic+0.04,yInic-0.1,zInic); - _typeActor->SetScale(0.03,0.02,1); + _typeActor->SetPosition(xInic+4,yInic-10,zInic); + _typeActor->SetScale(3,2,1); } diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx index 4e92f74..98cfc85 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx @@ -100,7 +100,8 @@ namespace bbtk bool vtkGObjectView::isPointInside(int X,int Y) //virtual { - double xx=X,yy=Y,zz=0; + // RaC In the actual version, always z=900 + double xx=X,yy=Y,zz=900; _baseView->TransCoordScreenToWorld(xx,yy,zz); return _model->isPointInside(xx,yy,zz); } @@ -109,7 +110,8 @@ namespace bbtk void vtkGObjectView::moveObject(int X,int Y) //virtual { - double xx=X,yy=Y,zz=0; + // RaC In the actual version, always z=900 + double xx=X,yy=Y,zz=900; _baseView->TransCoordScreenToWorld(xx,yy,zz); diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx index d1ab127..d6bef81 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx @@ -67,10 +67,12 @@ namespace bbtk _model->getInicPoint(xInic,yInic,zInic); _model->getFinalPoint(xFin, yFin,zFin); - _pts->SetPoint(0, xInic, yInic, 0 ); - _pts->SetPoint(1, xInic, yFin, 0 ); - _pts->SetPoint(2, xFin, yFin, 0 ); - _pts->SetPoint(3, xFin, yInic, 0 ); + // RaC In the actual version, zInic=zFin=900 + + _pts->SetPoint(0, xInic, yInic, zInic ); + _pts->SetPoint(1, xInic, yFin, zInic ); + _pts->SetPoint(2, xFin, yFin, zFin ); + _pts->SetPoint(3, xFin, yInic, zFin ); _baseView->GetRenderer()->Render(); _baseView->GetRenWin()->Render(); @@ -94,10 +96,11 @@ namespace bbtk _model->getInicPoint(xInic,yInic,zInic); _model->getFinalPoint(xFin, yFin,zFin); - _pts->SetPoint(0, xInic, yInic, 0 ); - _pts->SetPoint(1, xInic, yFin, 0 ); - _pts->SetPoint(2, xFin, yFin, 0 ); - _pts->SetPoint(3, xFin, yInic, 0 ); + // RaC In the actual version, zInic=zFin=900 + _pts->SetPoint(0, xInic, yInic, zInic ); + _pts->SetPoint(1, xInic, yFin, zInic ); + _pts->SetPoint(2, xFin, yFin, zFin ); + _pts->SetPoint(3, xFin, yInic, zFin ); lines->InsertNextCell(5); lines->InsertCellPoint(0); -- 2.45.0