]> Creatis software - creaMaracasVisu.git/commitdiff
New version of viewerNV, MPR and STL module
authorJuan Prieto <Juan.Prieto@creatis.insa-lyon.fr>
Tue, 24 Mar 2009 10:47:52 +0000 (10:47 +0000)
committerJuan Prieto <Juan.Prieto@creatis.insa-lyon.fr>
Tue, 24 Mar 2009 10:47:52 +0000 (10:47 +0000)
bbtk/src/bbcreaMaracasVisuSTL.cxx [new file with mode: 0644]
bbtk/src/bbcreaMaracasVisuSTL.h [new file with mode: 0644]
bbtk/src/bbmaracasvisuContourVOI.cxx
bbtk/src/bbmaracasvisuContourVOI.h
bbtk/src/bbmaracasvisuImageChangeInformation.cxx
bbtk/src/bbmaracasvisuViewerMPR.cxx
bbtk/src/bbmaracasvisuViewerMPR.h
bbtk/src/bbmaracasvisuViewerNV.cxx
bbtk/src/bbmaracasvisuViewerNV.h

diff --git a/bbtk/src/bbcreaMaracasVisuSTL.cxx b/bbtk/src/bbcreaMaracasVisuSTL.cxx
new file mode 100644 (file)
index 0000000..8217e9a
--- /dev/null
@@ -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 (file)
index 0000000..1573928
--- /dev/null
@@ -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_
+
index 649cf0cffe20d56573b5b123d0c7cd8a1e319d88..1717fcc1275b6ee366e11b2e6560e023215751c3 100644 (file)
@@ -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 "<<Index<<" size "<<Size<<std::endl;
+
                bbSetOutputIndex( Index );
                bbSetOutputSize( Size );
-       } //wxwidgetvoi
+       } 
+
 }
 
 //------------------------------------------------------
 void ContourVOI::CreateWidget(wxWindow*  parent)
 {  
        bbtkDebugMessageInc("Core",9,"ContourVOI::CreateWidget()"<<std::endl);
-  
-       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();
-    }
-
-       wxWidgetVOI *mwxwidget = new wxWidgetVOI( parent, bbGetInputwxVtkBaseView(), bbGetInputIn() );
-
+       wxWidgetVOI *mwxwidget = new wxWidgetVOI( parent );
        bbSetOutputWidget(mwxwidget);
        bbtkDebugDecTab("Core",9);
+       this->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;
+
 }
 
 //------------------------------------------------------
index 76d61c171de40a8b8f584bf18db5c4f552255ac5..3c62dba69f0b1eb5962c00afa199dbc8fd8228d4 100644 (file)
@@ -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);
index 02e2ef9336386e215371642d7abd534a22adc3ba..568d2b1835d5f9b3197d617851895258c31c524d 100644 (file)
@@ -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()
 {
index 4e191ea98a4c8fe37df0f9e758c9fb7a2d0d9764..b260443c583206812d3c387bdfa95cb82814487a 100644 (file)
@@ -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() " <<std::endl);
-       marImageData    *marimagedata = new marImageData(bbGetInputIn() );
+       //JCP 10 - 03 - 09 marImageData *marimagedata = new marImageData(bbGetInputIn() );
        bbtkDebugDecTab("Core",9);
-       wxwidget = new wxWidgetMPR(this , parent ,marimagedata);
+       wxwidget = new wxWidgetMPR(this , parent);//JCP  10 - 03 - 09,marimagedata);
        bbSetOutputWidget( wxwidget );
 }
 
 void ViewerMPR::bbUserConstructor()
 {
+               marimagedata =  NULL;
                wxwidget = NULL;
                bbSetInputIn(NULL);
 }
 void ViewerMPR::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
 {
 
+       marimagedata =  NULL;
+               wxwidget = NULL;
+               bbSetInputIn(NULL);
+
 }
 void ViewerMPR::bbUserDestructor()
 {
index 6fca3cd64d9843ae0e791b7282ed9722d1ba39b7..af3673a55f61a9af80a1a8b6fb5e39a40ea4af8a 100644 (file)
@@ -17,7 +17,7 @@ namespace bbcreaMaracasVisu
   class wxWidgetMPR : public wxPanel
   {
        public:
-               wxWidgetMPR(ViewerMPR* box,wxWindow* parent, marImageData       *marimagedata);
+               wxWidgetMPR(ViewerMPR* box,wxWindow* parent, marImageData       *marimagedata=NULL);
                ~wxWidgetMPR();
            
                //if the MPR had generated the refresh event
@@ -31,9 +31,12 @@ namespace bbcreaMaracasVisu
 
                //refreshView
                void Refresh();
+
+               void setMarImage(marImageData* marimagedata);
+               void ConfigureVTK();
                
        private:
-
+               
                ViewerMPR                       *mbbViewerMPR;
                wxMPRWidget2            *wxwidget;
                std::vector<int>        point;
@@ -72,6 +75,7 @@ virtual void bbUserDestructor();
 
 private:
   wxWidgetMPR *wxwidget;
+  marImageData *marimagedata;
 };
 
 BBTK_BEGIN_DESCRIBE_BLACK_BOX(ViewerMPR,bbtk::WxBlackBox);
index 8208643ef4abcfa735efbada1a4567b616eb1ec4..bdce092c9dd96fa61f88503c2ae4ecdf6d9aec48 100644 (file)
@@ -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<int> 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()"<<std::endl);
-   mwxwidget = new bbwxMaracas_N_ViewersWidget( this, parent , bbGetInputIn() , &(bbGetInputnTypeView())       );
-   bbtkDebugDecTab("Core",9);
-   bbSetOutputWidget( mwxwidget );
+    bbtkDebugMessageInc("Core",9,"ViewerNV::CreateWidget()"<<std::endl);
+       mwxwidget = new bbwxMaracas_N_ViewersWidget( this, parent );    
+       bbtkDebugDecTab("Core",9);
+    bbSetOutputWidget( mwxwidget );    
+
+       
+       this->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 "<<this<<" vs "<<GetThisPointer<void>()<<std::endl;
+
+}
+
+bool ViewerNV::compareVectors(std::vector<int> type,std::vector<int> 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;
+
+
 }
 
 }
index 71d159c42e072954f19c9ce7eb2598cbd6b5be2b..69ab166681ad99b3330564018b3beb2b5a9e0c86 100644 (file)
@@ -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<int> *nTypeView);
+               bbwxMaracas_N_ViewersWidget(ViewerNV* box,wxWindow *parent, vtkImageData* imagedata=NULL, std::vector<int> *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<int>                        point;
+       vtkImageData* currentimg;
+       std::vector<int>  currenttype;
+       wxMaracas_N_ViewersWidget       *mwxwidget;
+
+       bool compareVectors(std::vector<int> type,std::vector<int> currenttype);
 };
 
 BBTK_BEGIN_DESCRIBE_BLACK_BOX(ViewerNV,bbtk::WxBlackBox);