From 24937478048aca664712bb708240bff79879e0d9 Mon Sep 17 00:00:00 2001 From: Eduardo Davila Date: Mon, 18 Oct 2010 19:28:52 +0000 Subject: [PATCH] *** empty log message *** --- bbtk/src/bbcreaMaracasVisuManualPaint.cxx | 187 ++++++++++++++++++ bbtk/src/bbcreaMaracasVisuManualPaint.h | 83 ++++++++ .../manualContourBaseControler.cpp | 6 +- .../manualContour/manualContourControler.cpp | 7 +- .../manualContour/manualRoiControler.cpp | 15 +- 5 files changed, 286 insertions(+), 12 deletions(-) create mode 100644 bbtk/src/bbcreaMaracasVisuManualPaint.cxx create mode 100644 bbtk/src/bbcreaMaracasVisuManualPaint.h diff --git a/bbtk/src/bbcreaMaracasVisuManualPaint.cxx b/bbtk/src/bbcreaMaracasVisuManualPaint.cxx new file mode 100644 index 0000000..3bde3b5 --- /dev/null +++ b/bbtk/src/bbcreaMaracasVisuManualPaint.cxx @@ -0,0 +1,187 @@ +//===== +// Don't edit this file. This file is generated from xml description.. +//===== +#include "bbcreaMaracasVisuManualPaint.h" +#include "bbcreaMaracasVisuPackage.h" + +#include "wxVtk2DBaseView.h" +#include "wxVTKRenderWindowInteractor.h" + +namespace bbcreaMaracasVisu +{ + + + +vtkInteractorManualPaint::vtkInteractorManualPaint() +{ + _state = false; + _image = NULL; + _auxZ = 0; +} + +//--------------------------------------------------------------------------- +vtkInteractorManualPaint::~vtkInteractorManualPaint() +{ +} + +//--------------------------------------------------------------------------- +bool vtkInteractorManualPaint::OnLeftButtonDown() +{ + vtkRenderWindowInteractor *interactor = _vtkInteractorStyleBaseView->GetInteractor(); + if ((interactor->GetControlKey()==1) || (interactor->GetShiftKey()==1) ){ + _state = true; + wxVtk2DBaseView *wxvtk2Dbaseview = (wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView(); + _Z = wxvtk2Dbaseview->GetActualSlice(); +// _sliceZ = ((wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView())->GetActualSlice(); + } + return true; +} + +//--------------------------------------------------------------------------- +bool vtkInteractorManualPaint::OnLeftButtonUp() +{ + _state = false; + return true; +} + +//--------------------------------------------------------------------------- +bool vtkInteractorManualPaint::OnMouseMove () +{ + printf("EED vtkInteractorManualPaint::OnMouseMove \n"); + if (_state==true) + { + int px,py; + wxVtk2DBaseView *wxvtk2Dbaseview = (wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView(); + wxVTKRenderWindowInteractor *wxVTKiren = wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor(); + + wxVTKiren->GetEventPosition(px,py); + + double X = (double)px; + double Y = (double)py; + double Z = _Z; + int typeView = 2; + wxvtk2Dbaseview->TransFromCoordScreenToWorld(X, Y, Z,false, typeView); + +// int px = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0]; +// int py = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1]; + printf("EED vtkInteractorManualPaint::OnMouseMove ----------------- %f %f %f\n", X,Y,Z); + + PaintImage((int)X,(int)Y,(int)Z); + + wxvtk2Dbaseview->Refresh(); + wxvtk2Dbaseview->RefreshView(); +// wxvtk2Dbaseview->SetActualSlice(_Z+_auxZ); + _auxZ=(_auxZ+1)%2; + wxvtk2Dbaseview->_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->Render(); + this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting(); +// wxvtk2Dbaseview->SetActualSlice(Z); + }// if _state + return true; +} + +//--------------------------------------------------------------------------- +void vtkInteractorManualPaint::SetImage(vtkImageData *image) +{ + _image = image; +} + + +void vtkInteractorManualPaint::PaintImage(int px,int py, int pz) +{ + if (_image!=NULL) + { + float value=0; + printf("EED vtkInteractorManualPaint::PaintImage %d %d %d\n", px,py,pz); + _image->SetScalarComponentFromFloat (px,py,pz, 0, value ); + _image->Modified(); + } else { + printf("ERROR : bbcreaMaracasvisu::vtkInteractorManualPaint::PaintImage : Image not set. \n"); + } +} + + + +//--------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------- + + + + + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ManualPaint) +BBTK_BLACK_BOX_IMPLEMENTATION(ManualPaint,bbtk::WxBlackBox); +//===== +// Don't edit this file. This file is generated from xml description.. +//===== +void ManualPaint::Process() +{ + +/* + std::string msg; + if (bbGetInputTitle()!="") + { + msg = bbGetInputTitle()+": " + bbGetInputIn(); + } + else + { + msg = bbGetInputIn(); + } + ((wxStaticText*)bbGetOutputWidget())->SetLabel( bbtk::std2wx( msg ) ); + */ + + if (bbGetInputWxVtkBaseView()==NULL) + { + printf("WARNING : package creaMaracasVisu box ManualPaint : input WxVtkBaseView have to be defferent of NULL\n"); + } + + if (bbGetInputIn()==NULL) + { + printf("WARNING : package creaMaracasVisu box ManualPaint : input In (vtkImageData*) have to be defferent of NULL\n"); + } + + + if (imp==NULL) + { + imp=new vtkInteractorManualPaint(); + imp->SetImage( bbGetInputIn() ); + vtkInteractorStyleBaseView *isbv = (vtkInteractorStyleBaseView*)(bbGetInputWxVtkBaseView()->GetInteractorStyleBaseView()); + isbv->AddInteractorStyleMaracas(imp); + } + +} +//===== +// Don't edit this file. This file is generated from xml description.. +//===== +void ManualPaint::CreateWidget(wxWindow* parent) +{ + + bbSetOutputWidget( new wxStaticText ( parent , -1 , _T("UPS") ) ); + +} +//===== +// Don't edit this file. This file is generated from xml description.. +//===== +void ManualPaint::bbUserSetDefaultValues() +{ + imp=NULL; + bbSetInputIn(NULL); +} +//===== +// Don't edit this file. This file is generated from xml description.. +//===== +void ManualPaint::bbUserInitializeProcessing() +{ + +} +//===== +// Don't edit this file. This file is generated from xml description.. +//===== +void ManualPaint::bbUserFinalizeProcessing() +{ + +} + +} // EO namespace bbcreaMaracasVisu + + diff --git a/bbtk/src/bbcreaMaracasVisuManualPaint.h b/bbtk/src/bbcreaMaracasVisuManualPaint.h new file mode 100644 index 0000000..cb3b6bf --- /dev/null +++ b/bbtk/src/bbcreaMaracasVisuManualPaint.h @@ -0,0 +1,83 @@ +//===== +// Don't edit this file. This file is generated from xml description.. +//===== +#ifdef _USE_WXWIDGETS_ +#ifndef __bbcreaMaracasVisuManualPaint_h_INCLUDED__ +#define __bbcreaMaracasVisuManualPaint_h_INCLUDED__ +#include "bbcreaMaracasVisu_EXPORT.h" +#include "bbtkWxBlackBox.h" + +#include "wxVtkBaseView.h" +#include "vtkImageData.h" + +#include "InteractorStyleMaracas.h" + +namespace bbcreaMaracasVisu +{ + + + +class vtkInteractorManualPaint : public InteractorStyleMaracas { +public: + vtkInteractorManualPaint(); + virtual ~vtkInteractorManualPaint(); + + virtual bool OnMouseMove(); + virtual bool OnLeftButtonDown(); + virtual bool OnLeftButtonUp(); + void SetImage(vtkImageData *image); + +private: + double _Z; + int _auxZ; + bool _state; + vtkImageData *_image; + void PaintImage( int px, int py, int pz ); + +protected: + +}; + + + + + + +class bbcreaMaracasVisu_EXPORT ManualPaint + : + public bbtk::WxBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(ManualPaint,bbtk::WxBlackBox); +//===== +// Don't edit this file. This file is generated from xml description.. +//===== + BBTK_DECLARE_INPUT(In,vtkImageData*); + BBTK_DECLARE_INPUT(WxVtkBaseView,wxVtkBaseView*); + BBTK_PROCESS(Process); + void Process(); + BBTK_CREATE_WIDGET(CreateWidget); + void CreateWidget(wxWindow*); + + vtkInteractorManualPaint *imp; +//===== +// Don't edit this file. This file is generated from xml description.. +//===== +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(ManualPaint,bbtk::WxBlackBox); +BBTK_NAME("ManualPaint"); +BBTK_AUTHOR("eduardo davila (Creatis)"); +BBTK_DESCRIPTION("Voxel manual paint"); +BBTK_CATEGORY("__CategoryBlackBox__"); +BBTK_INPUT(ManualPaint,In,"Input image to be modified",vtkImageData*,""); +BBTK_INPUT(ManualPaint,WxVtkBaseView,"creaMaracasVisu viewer",wxVtkBaseView*,""); +BBTK_END_DESCRIBE_BLACK_BOX(ManualPaint); +//===== +// Don't edit this file. This file is generated from xml description.. +//===== +} +// EO namespace bbcreaMaracasVisu + +#endif // __bbcreaMaracasVisuManualPaint_h_INCLUDED__ +#endif // _USE_WXWIDGETS_ + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.cpp index c32d569..f96fb48 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.cpp @@ -137,7 +137,6 @@ bool manualContourBaseControler::OnChar() // ---------------------------------------------------------------------------- bool manualContourBaseControler::OnMouseMove() { - if ( _vtkInteractorStyleBaseView!=NULL) { int X,Y; @@ -145,6 +144,7 @@ bool manualContourBaseControler::OnMouseMove() _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor(); _wxVTKiren->GetEventPosition( X , Y ); + printf("EED manualContourBaseControler::OnMouseMove %d %d\n",X,Y); if ( (_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) && (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) ) { @@ -290,7 +290,7 @@ void manualContourBaseControler::MouseDLeft(int x, int y ) { if (_state==0) { - + int z=GetZ(); /*bool temp = */ _manViewBaseCont->SelectPosibleContour(x,y,z); @@ -457,7 +457,7 @@ void manualContourBaseControler::AddPoint(int x, int y, int z) // virtual double xx = x; double yy = y; double zz = z; - + GetManualViewBaseContour()->TransfromCoordViewWorld(xx,yy,zz); GetManualContourModel()->AddPoint(xx,yy,zz); GetManualViewBaseContour()->AddPoint(); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.cpp index 33665fb..845f3c9 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.cpp @@ -41,7 +41,8 @@ void manualContourControler::Configure() //virtual } // ---------------------------------------------------------------------------- -void manualContourControler::MouseClickLeft(int x, int y){ +void manualContourControler::MouseClickLeft(int x, int y) +{ bool ok = false; int z = GetZ(); @@ -99,7 +100,7 @@ void manualContourControler::MouseClickLeft(int x, int y){ SetPosibleToMove( true ); GetManualViewBaseContour()->SetSelected( GetManualViewBaseContour()->GetPosibleSelected() ); } // IsEditable - + if ( GetState() == 0 && GetManualViewBaseContour()->GetPosibleSelected() ) { SetMoving( true ); @@ -144,7 +145,7 @@ void manualContourControler::MouseDLeft( int x, int y)//virtual manualContourBaseControler::MouseDLeft( x, y); if ( IsEditable() ) { - + GetManualViewBaseContour()->AddControlPoints(); GetManualViewBaseContour()->AddTextActor(); GetManualViewBaseContour()->Refresh(); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualRoiControler.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualRoiControler.cpp index 85f2068..cbcdbd0 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualRoiControler.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualRoiControler.cpp @@ -41,7 +41,7 @@ void manualRoiControler::Configure() //virtual void manualRoiControler::MouseClickLeft(int x, int y){ int z = GetZ(); - + if( IsEditable() ) { // move control point if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ){ @@ -49,13 +49,13 @@ void manualRoiControler::MouseClickLeft(int x, int y){ SetState(5); } } // IsEditable - + // Move contour if ((GetState()==0) && (GetManualViewBaseContour()->GetPosibleSelected()==true)) { GetManualViewBaseContour()->InitMove(x,y,z); SetState(6); } - + // if the firs time create 4 control points and move one point int size=GetManualViewBaseContour()->GetNumberOfPoints(); if (GetState()==0) { @@ -68,7 +68,7 @@ void manualRoiControler::MouseClickLeft(int x, int y){ SetState(1); } } - + /*EED 21 Avril 2009 if (GetState()==0) { if (size==0){ @@ -86,18 +86,21 @@ void manualRoiControler::MouseClickLeft(int x, int y){ SetState(5); } */ - + GetManualViewBaseContour()->Refresh(); } // ---------------------------------------------------------------------------- void manualRoiControler::MouseMove(int x, int y) // virtual { + + printf("manualRoiControler::MouseClickLeft %d %d\n",x ,y); + int z=GetZ(); // this->_vtkInteractorStyleBaseView-> - + GetManualViewBaseContour()->SelectPosibleContour(x,y,z); GetManualViewBaseContour()->SelectPosiblePoint(x,y,z); -- 2.45.1