From: Juan Prieto Date: Tue, 24 Mar 2009 10:47:52 +0000 (+0000) Subject: New version of viewerNV, MPR and STL module X-Git-Tag: EED.02Oct2009~119 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=393855ac9ccdd47bc738cc7c0af199b2b45d89db;p=creaMaracasVisu.git New version of viewerNV, MPR and STL module --- diff --git a/bbtk/src/bbcreaMaracasVisuSTL.cxx b/bbtk/src/bbcreaMaracasVisuSTL.cxx new file mode 100644 index 0000000..8217e9a --- /dev/null +++ b/bbtk/src/bbcreaMaracasVisuSTL.cxx @@ -0,0 +1,55 @@ +#include "bbcreaMaracasVisuSTL.h" +#include "bbcreaMaracasVisuPackage.h" + + +#include "wxSTLWidget_03.h" + +namespace bbcreaMaracasVisu +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,STL) +BBTK_BLACK_BOX_IMPLEMENTATION(STL,bbtk::WxBlackBox); +void STL::Process() +{ + + + vtkImageData* img = bbGetInputIn(); + if(img != NULL){ + ((wxSTLWidget_03*)bbGetOutputWidget())->setImage(img); + // mar->_experiment->initExperiment(img); + } + +} +void STL::CreateWidget(wxWindow* parent) +{ + + + //mar = new marInterface(); + + wxWindow* stl = new wxSTLWidget_03(parent);//, mar); + bbSetOutputWidget( stl ); + //Process(); + +} +void STL::bbUserConstructor() +{ + + bbSetInputIn(NULL); + +} +void STL::bbUserCopyConstructor(bbtk::BlackBox::Pointer) +{ + + + +} +void STL::bbUserDestructor() +{ + + + +} +} +// EO namespace bbcreaMaracasVisu + + diff --git a/bbtk/src/bbcreaMaracasVisuSTL.h b/bbtk/src/bbcreaMaracasVisuSTL.h new file mode 100644 index 0000000..1573928 --- /dev/null +++ b/bbtk/src/bbcreaMaracasVisuSTL.h @@ -0,0 +1,49 @@ +#ifdef _USE_WXWIDGETS_ +#ifndef __bbcreaMaracasVisuSTL_h_INCLUDED__ +#define __bbcreaMaracasVisuSTL_h_INCLUDED__ +#include "bbcreaMaracasVisu_EXPORT.h" +#include "bbtkWxBlackBox.h" + +#include "vtkImageData.h" + +//#include "marInterface.h" + +namespace bbcreaMaracasVisu +{ + +class bbcreaMaracasVisu_EXPORT STL + : + public bbtk::WxBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(STL,bbtk::WxBlackBox); +//================================================================== +/// User callback called in the box contructor +virtual void bbUserConstructor(); +/// User callback called in the box copy constructor +virtual void bbUserCopyConstructor(bbtk::BlackBox::Pointer); +/// User callback called in the box destructor +virtual void bbUserDestructor(); +//================================================================== + BBTK_DECLARE_INPUT(In,vtkImageData*); + BBTK_PROCESS(Process); + void Process(); + BBTK_CREATE_WIDGET(CreateWidget); + void CreateWidget(wxWindow*); + +private: + //marInterface* mar; +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(STL,bbtk::WxBlackBox); +BBTK_NAME("STL"); +BBTK_AUTHOR("car-prie@uniandes.edu.co"); +BBTK_DESCRIPTION("BB of the module STL in Maracas"); +BBTK_CATEGORY("__CategoryBlackBox__"); +BBTK_INPUT(STL,In,"Image to the STL",vtkImageData*,""); +BBTK_END_DESCRIBE_BLACK_BOX(STL); +} +// EO namespace bbcreaMaracasVisu + +#endif // __bbcreaMaracasVisuSTL_h_INCLUDED__ +#endif // _USE_WXWIDGETS_ + diff --git a/bbtk/src/bbmaracasvisuContourVOI.cxx b/bbtk/src/bbmaracasvisuContourVOI.cxx index 649cf0c..1717fcc 100644 --- a/bbtk/src/bbmaracasvisuContourVOI.cxx +++ b/bbtk/src/bbmaracasvisuContourVOI.cxx @@ -22,7 +22,26 @@ END_EVENT_TABLE( ); { wxPanel *panel = this; - mcontourvoiwidget = new ContourVOIWidget( panel, wxvtkbaseview, imagedata ); + if(wxvtkbaseview!=NULL&&imagedata!=NULL){ + + setBaseView(wxvtkbaseview); + setImageData(imagedata); + initializeVOIWidget(); + + } + + + } + + wxWidgetVOI::setBaseView(wxVtkBaseView * wxvtkbaseview){ + this->wxvtkbaseview = wxvtkbaseview; + } + wxWidgetVOI::setImageData(vtkImageData * imagedata){ + this->imagedata = imagedata; + } + + wxWidgetVOI::initializeVOIWidget(){ + mcontourvoiwidget = new ContourVOIWidget( this, wxvtkbaseview, imagedata ); mcontourvoiwidget->ConfigureVTK(); // wxwidget = new wxMPRWidget2( panel, marimagedata , 1 ); @@ -30,9 +49,10 @@ END_EVENT_TABLE( ); wxFlexGridSizer *sizer=new wxFlexGridSizer(1); sizer -> Add( mcontourvoiwidget,1,wxGROW ); sizer -> AddGrowableCol(0); - panel -> SetSizer(sizer); - panel -> SetAutoLayout(true); - panel -> Layout(); + this -> SetSizer(sizer); + this -> SetAutoLayout(true); + this -> Layout(); + this->Refresh(); } //-------------------------------------------------------------------------- wxWidgetVOI::~wxWidgetVOI() @@ -93,10 +113,36 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ContourVOI,bbtk::WxBlackBox); //------------------------------------------------------ void ContourVOI::Process() { + + /*if (bbGetInputwxVtkBaseView()==NULL) + { + wxMessageDialog(NULL, bbtk::std2wx("(ContourVOI) Input 'wxVtkBaseView' is not set"), bbtk::std2wx(bbGetFullName()) ).ShowModal(); + } + if (bbGetInputIn()==NULL) + { + wxMessageDialog(NULL, bbtk::std2wx("(ContourVOI) Input 'In' is not set"), bbtk::std2wx(bbGetFullName()) ).ShowModal(); + }*/ + + + vtkImageData* img = bbGetInputIn(); + wxVtkBaseView* base = bbGetInputwxVtkBaseView(); + wxWidgetVOI* wxwidgetvoi = (wxWidgetVOI*)bbGetOutputWidget(); + + if(base !=NULL && img != NULL && _img != img && _base != base){ + + _img = img; + _base = base; + + wxwidgetvoi->setBaseView(base); + wxwidgetvoi->setImageData(img); + wxwidgetvoi->initializeVOIWidget(); + } + + if (wxwidgetvoi!=NULL){ ContourVOIWidget* contourvoiwidget = wxwidgetvoi->GetContourVOIWidget(); - + int voi[6]; contourvoiwidget->GetVOI(voi); char buffer[40]; @@ -105,39 +151,44 @@ void ContourVOI::Process() sprintf(buffer,"%d %d %d ", voi[1]-voi[0]+1, voi[3]-voi[2]+1, voi[5]-voi[4]+1 ); std::string Size(buffer); + std::cout<<"ContourVOI index "<bbSignalOutputModification(); + + //Process(); } //------------------------------------------------------ void ContourVOI::bbUserConstructor() { + + _img = NULL; + _base = NULL; + bbSetInputwxVtkBaseView(NULL); + bbSetInputIn(NULL); + bbSetOutputWidget(NULL); + } //------------------------------------------------------ void ContourVOI::bbUserCopyConstructor(bbtk::BlackBox::Pointer) { + _img = NULL; + _base = NULL; + } //------------------------------------------------------ diff --git a/bbtk/src/bbmaracasvisuContourVOI.h b/bbtk/src/bbmaracasvisuContourVOI.h index 76d61c1..3c62dba 100644 --- a/bbtk/src/bbmaracasvisuContourVOI.h +++ b/bbtk/src/bbmaracasvisuContourVOI.h @@ -19,7 +19,7 @@ namespace bbcreaMaracasVisu class wxWidgetVOI : public wxPanel { public: - wxWidgetVOI(wxWindow* parent, wxVtkBaseView *wxvtkbaseview, vtkImageData *imagedata); + wxWidgetVOI(wxWindow* parent, wxVtkBaseView *wxvtkbaseview=NULL, vtkImageData *imagedata=NULL); ~wxWidgetVOI(); //if the MPR had generated the refresh event @@ -31,11 +31,21 @@ namespace bbcreaMaracasVisu ContourVOIWidget* GetContourVOIWidget(); + setBaseView(wxVtkBaseView * wxvtkbaseview); + setImageData(vtkImageData * imagedata); + + initializeVOIWidget(); + private: // ContourVOI *mbbViewerMPR; ContourVOIWidget *mcontourvoiwidget; + wxVtkBaseView * wxvtkbaseview; + vtkImageData * imagedata; + + + DECLARE_EVENT_TABLE( ); }; @@ -71,6 +81,10 @@ virtual void bbUserDestructor(); BBTK_CREATE_WIDGET(CreateWidget); void CreateWidget(wxWindow*); +private: + vtkImageData* _img; + wxVtkBaseView* _base; + }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(ContourVOI,bbtk::WxBlackBox); diff --git a/bbtk/src/bbmaracasvisuImageChangeInformation.cxx b/bbtk/src/bbmaracasvisuImageChangeInformation.cxx index 02e2ef9..568d2b1 100644 --- a/bbtk/src/bbmaracasvisuImageChangeInformation.cxx +++ b/bbtk/src/bbmaracasvisuImageChangeInformation.cxx @@ -8,24 +8,30 @@ BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ImageChangeInformation) BBTK_BLACK_BOX_IMPLEMENTATION(ImageChangeInformation,bbtk::AtomicBlackBox); void ImageChangeInformation::Process() { - int ext[6]; - bbGetInputIn()->GetExtent( ext ); - if (mchange!=NULL) { mchange->Delete(); } - mchange = vtkImageChangeInformation::New(); - mchange->SetInput( bbGetInputIn() ); - mchange->SetExtentTranslation( -ext[0], -ext[2], -ext[4] ); - mchange->Update(); //important + int ext[6]; + vtkImageData* img = bbGetInputIn(); + if(img!=NULL){ + img->GetExtent( ext ); + if (mchange!=NULL) { mchange->Delete(); } + mchange = vtkImageChangeInformation::New(); + mchange->SetInput( img ); + mchange->SetExtentTranslation( -ext[0], -ext[2], -ext[4] ); + mchange->Update(); //important + + bbSetOutputOut( mchange->GetOutput() ); + } - bbSetOutputOut( mchange->GetOutput() ); } void ImageChangeInformation::bbUserConstructor() { mchange=NULL; + bbSetOutputOut( NULL); + bbSetInputIn(NULL); } void ImageChangeInformation::bbUserCopyConstructor(bbtk::BlackBox::Pointer) { - + mchange=NULL; } void ImageChangeInformation::bbUserDestructor() { diff --git a/bbtk/src/bbmaracasvisuViewerMPR.cxx b/bbtk/src/bbmaracasvisuViewerMPR.cxx index 4e191ea..b260443 100644 --- a/bbtk/src/bbmaracasvisuViewerMPR.cxx +++ b/bbtk/src/bbmaracasvisuViewerMPR.cxx @@ -26,8 +26,12 @@ END_EVENT_TABLE( ); wxPanel *panel = this; mbbViewerMPR = box; + wxwidget = new wxMPRWidget2( panel, marimagedata , 1 ); - wxwidget->ConfigureVTK(); + + if(marimagedata != NULL){ + wxwidget->ConfigureVTK(); + } wxFlexGridSizer *sizer=new wxFlexGridSizer(1); sizer -> Add( wxwidget,0,wxGROW ); sizer -> AddGrowableCol(1); @@ -35,6 +39,15 @@ END_EVENT_TABLE( ); panel -> SetAutoLayout(true); panel -> Layout(); } + + void wxWidgetMPR::setMarImage(marImageData* marimagedata){ + wxwidget->setMarImage(marimagedata, 1); + + + } + void wxWidgetMPR::ConfigureVTK(){ + wxwidget->ConfigureVTK(); + } //-------------------------------------------------------------------------- wxWidgetMPR::~wxWidgetMPR() { @@ -110,6 +123,10 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ViewerMPR,bbtk::WxBlackBox); void ViewerMPR::Process() { if (wxwidget!=NULL){ + if(marimagedata==NULL){ + wxwidget->setMarImage(new marImageData(bbGetInputIn() )); + wxwidget->ConfigureVTK(); + } wxBusyCursor wait; bbSetOutputPoint( wxwidget->GetPoint() ); bbSetOutputRenderer( wxwidget->GetRenderer() ); @@ -119,20 +136,25 @@ void ViewerMPR::Process() void ViewerMPR::CreateWidget(wxWindow* parent) { bbtkDebugMessageInc("Core",9,"ViewerMPR::CreateWidget() " < point; @@ -72,6 +75,7 @@ virtual void bbUserDestructor(); private: wxWidgetMPR *wxwidget; + marImageData *marimagedata; }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(ViewerMPR,bbtk::WxBlackBox); diff --git a/bbtk/src/bbmaracasvisuViewerNV.cxx b/bbtk/src/bbmaracasvisuViewerNV.cxx index 8208643..bdce092 100644 --- a/bbtk/src/bbmaracasvisuViewerNV.cxx +++ b/bbtk/src/bbmaracasvisuViewerNV.cxx @@ -54,9 +54,23 @@ BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ViewerNV) BBTK_BLACK_BOX_IMPLEMENTATION(ViewerNV,bbtk::WxBlackBox); //------------------------------------------------------------- void ViewerNV::Process() -{ - if (mwxwidget != NULL) - { +{ + + vtkImageData* img = bbGetInputIn(); + std::vector type = bbGetInputnTypeView(); + + if(img != NULL && mwxwidget != NULL){// && !enter){ + + if(!compareVectors(type, currenttype)){ + mwxwidget->SetType(&type); + mwxwidget->UpdateLayout(img); + }else if (img != currentimg){ + mwxwidget->SetImage(img); + } + currenttype = type; + currentimg = img; + + point.clear(); point.push_back((int)mwxwidget->GetX()); point.push_back((int)mwxwidget->GetY()); @@ -64,7 +78,7 @@ void ViewerNV::Process() bbSetOutputPoint(point); // WxBlackBox::Process(); - mwxwidget->SetImage( bbGetInputIn() ); +// mwxwidget->SetImage(img ); wxVtkBaseView *wvbv1 = mwxwidget->GetwxVtkBaseView(1); wxVtkBaseView *wvbv2 = mwxwidget->GetwxVtkBaseView(2); wxVtkBaseView *wvbv3 = mwxwidget->GetwxVtkBaseView(3); @@ -80,21 +94,26 @@ void ViewerNV::Process() if (wvbv2!=NULL) { bbSetOutputRenderer2( wvbv2->GetRenderer() ); } if (wvbv3!=NULL) { bbSetOutputRenderer3( wvbv3->GetRenderer() ); } if (wvbv4!=NULL) { bbSetOutputRenderer4( wvbv4->GetRenderer() ); } - } // mwxwidget + } } //------------------------------------------------------------- void ViewerNV::CreateWidget(wxWindow* parent) { - bbtkDebugMessageInc("Core",9,"ViewerNV::CreateWidget()"<bbSignalOutputModification(); + //Process(); } //------------------------------------------------------------- void ViewerNV::bbUserConstructor() { + mwxwidget = NULL; bbSetInputIn(NULL); @@ -119,11 +138,34 @@ void ViewerNV::bbUserConstructor() //------------------------------------------------------------- void ViewerNV::bbUserCopyConstructor(bbtk::BlackBox::Pointer) { + + mwxwidget = NULL; + } //------------------------------------------------------------- void ViewerNV::bbUserDestructor() { +std::cout << "ViewerNV destroy "<()< type,std::vector currenttype){ + + bool ret = true; + + if(type.size()==currenttype.size()){ + for(int i = 0; i < type.size() && ret; i++){ + if(type[i]!=currenttype[i]){ + ret = false; + } + } + }else{ + ret=false; + } + return ret; + + } } diff --git a/bbtk/src/bbmaracasvisuViewerNV.h b/bbtk/src/bbmaracasvisuViewerNV.h index 71d159c..69ab166 100644 --- a/bbtk/src/bbmaracasvisuViewerNV.h +++ b/bbtk/src/bbmaracasvisuViewerNV.h @@ -21,7 +21,7 @@ namespace bbcreaMaracasVisu class bbwxMaracas_N_ViewersWidget : public wxMaracas_N_ViewersWidget { public: - bbwxMaracas_N_ViewersWidget(ViewerNV* box,wxWindow *parent, vtkImageData* imagedata, std::vector *nTypeView); + bbwxMaracas_N_ViewersWidget(ViewerNV* box,wxWindow *parent, vtkImageData* imagedata=NULL, std::vector *nTypeView=NULL); ~bbwxMaracas_N_ViewersWidget(); //if the MPR had generated the refresh event @@ -68,9 +68,14 @@ virtual void bbUserDestructor(); BBTK_CREATE_WIDGET(CreateWidget); void CreateWidget(wxWindow* parent); -private: - wxMaracas_N_ViewersWidget *mwxwidget; +private: + bool enter; std::vector point; + vtkImageData* currentimg; + std::vector currenttype; + wxMaracas_N_ViewersWidget *mwxwidget; + + bool compareVectors(std::vector type,std::vector currenttype); }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(ViewerNV,bbtk::WxBlackBox);