]> Creatis software - creaMaracasVisu.git/commitdiff
*** empty log message ***
authorperez <perez>
Thu, 19 Nov 2009 15:00:30 +0000 (15:00 +0000)
committerperez <perez>
Thu, 19 Nov 2009 15:00:30 +0000 (15:00 +0000)
35 files changed:
bbtk/src/bbcreaMaracasVisuCutModule2.cxx [new file with mode: 0644]
bbtk/src/bbcreaMaracasVisuCutModule2.h [new file with mode: 0644]
bbtk/src/bbcreaMaracasVisuVolumeRendering.cxx
bbtk/src/bbcreaMaracasVisuVolumeRendering.h
data/colorsfunction2.txt [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/CMakeLists.txt
lib/maracasVisuLib/src/CutModule/interface/CMakeLists.txt
lib/maracasVisuLib/src/CutModule/interface/CutModel2MainPanel.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/interface/CutModel2MainPanel.h [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/interface/CutModel2View.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/interface/CutModel2View.h [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/kernel/CMakeLists.txt
lib/maracasVisuLib/src/CutModule/kernel/CutModel2Data.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/kernel/CutModel2Data.h [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/kernel/CutModel2Exception.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/kernel/CutModel2Exception.h [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/kernel/CutModel2Figure.cxx__ [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/kernel/CutModel2Figure.h [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/kernel/CutModel2FigureCube.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/kernel/CutModel2FigureCube.h [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/kernel/CutModel2FigureCylinder.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/kernel/CutModel2FigureCylinder.h [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/kernel/CutModel2FigureSphere.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/kernel/CutModel2FigureSphere.h [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/kernel/CutModel2Manager.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/kernel/CutModel2Manager.h [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/kernel/CutModel2SaveBinInfo.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/kernel/CutModel2SaveBinInfo.h [new file with mode: 0644]
lib/maracasVisuLib/src/CutModule/kernel/CutModelManager2.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererView.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererView.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasRenderImageManagementPanel.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasRenderImageManagementPanel.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasRenderImageTransformation.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasRenderTabbedPanel.cpp

diff --git a/bbtk/src/bbcreaMaracasVisuCutModule2.cxx b/bbtk/src/bbcreaMaracasVisuCutModule2.cxx
new file mode 100644 (file)
index 0000000..bfc09ac
--- /dev/null
@@ -0,0 +1,59 @@
+#include "bbcreaMaracasVisuCutModule2.h"
+#include "bbcreaMaracasVisuPackage.h"
+#include "creaSystem.h"
+
+namespace bbcreaMaracasVisu
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,CutModule2)
+BBTK_BLACK_BOX_IMPLEMENTATION(CutModule2,bbtk::WxBlackBox);
+void CutModule2::Process()
+{
+       vtkImageData* img = bbGetInputIn();
+       vtkRenderWindowInteractor* interactor = bbGetInputInteractor();
+       vtkRenderer* render = bbGetInputRenderer();
+
+       if(img != NULL && interactor != NULL && render != NULL && _mainpanel!=NULL){
+
+               if(_currentimage!=img){
+            _currentimage=img;
+                       _mainpanel->setImageData(img);
+               }
+               
+               _mainpanel->setInteractor(interactor);
+               _mainpanel->setRenderer(render);
+               //bbSetOutputOut(_mainpanel->GetResultImage());
+
+       }   
+  
+}
+void CutModule2::CreateWidget(wxWindow* parent)
+{
+
+       std::string path = crea::System::GetDllAppPath("bbcreaMaracasVisu.dll");
+       _mainpanel = CutModel2MainPanel::getInstance(parent, path);
+       
+   bbSetOutputWidget( _mainpanel); 
+   Process(); 
+  
+}
+void CutModule2::bbUserSetDefaultValues()
+{      
+       _mainpanel = NULL;
+       _currentimage=NULL;
+}
+void CutModule2::bbUserInitializeProcessing()
+{
+       bbSetInputIn(0);
+       bbSetInputInteractor(0);
+       bbSetInputRenderer(0);  
+}
+void CutModule2::bbUserFinalizeProcessing()
+{
+
+}
+}
+// EO namespace bbcreaMaracasVisu
+
+
diff --git a/bbtk/src/bbcreaMaracasVisuCutModule2.h b/bbtk/src/bbcreaMaracasVisuCutModule2.h
new file mode 100644 (file)
index 0000000..3f5e1b2
--- /dev/null
@@ -0,0 +1,46 @@
+#ifdef _USE_WXWIDGETS_
+#ifndef __bbcreaMaracasVisuCutModule2_h_INCLUDED__
+#define __bbcreaMaracasVisuCutModule2_h_INCLUDED__
+#include "bbcreaMaracasVisu_EXPORT.h"
+#include "bbtkWxBlackBox.h"
+#include "CutModel2MainPanel.h"
+
+namespace bbcreaMaracasVisu
+{
+
+class bbcreaMaracasVisu_EXPORT CutModule2
+ : 
+   public bbtk::WxBlackBox
+{
+       
+  BBTK_BLACK_BOX_INTERFACE(CutModule2,bbtk::WxBlackBox);
+  BBTK_DECLARE_INPUT(In,vtkImageData*);
+  BBTK_DECLARE_INPUT(Interactor,vtkRenderWindowInteractor*);
+  BBTK_DECLARE_INPUT(Renderer,vtkRenderer*);
+  //BBTK_DECLARE_OUTPUT(Out,vtkImageData*);
+  BBTK_PROCESS(Process);
+  void Process();
+  BBTK_CREATE_WIDGET(CreateWidget);
+  void CreateWidget(wxWindow*);
+
+private:
+       CutModel2MainPanel* _mainpanel;
+       vtkImageData* _currentimage;
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(CutModule2,bbtk::WxBlackBox);
+BBTK_NAME("CutModule2");
+BBTK_AUTHOR("perez@creatis.insa-lyon.fr");
+BBTK_DESCRIPTION("extracts");
+BBTK_CATEGORY("__CategoryBlackBox__");
+BBTK_INPUT(CutModule2,In,"Image",vtkImageData*,"");
+BBTK_INPUT(CutModule2,Interactor,"WindowInteractor",vtkRenderWindowInteractor*,"");
+BBTK_INPUT(CutModule2,Renderer,"Renderer",vtkRenderer*,"");
+//BBTK_OUTPUT(CutModule2,Out,"Image output",vtkImageData*,"");
+BBTK_END_DESCRIBE_BLACK_BOX(CutModel2);
+}
+// EO namespace bbcreaMaracasVisu
+
+#endif // __bbcreaMaracasVisuCutModule2_h_INCLUDED__
+#endif // _USE_WXWIDGETS_
+
index ea08e9b3869e76adfcb8831269ef6cbe41b293b6..5e1015afe9a08f2603080d86cd6edbeb148f8edd 100644 (file)
@@ -23,10 +23,10 @@ void VolumeRendering::Process()
 //    * TYPE is the C++ type of the input/output 
 //      (the one provided in the attribute 'type' of the tag 'input') 
        wxMaracasMultipleVolumeRendererView* volview = (wxMaracasMultipleVolumeRendererView*)bbGetOutputWidget();
-       vtkImageData* _img1 = bbGetInputIn1();
-       vtkImageData* _img2 = bbGetInputIn2();
-       vtkImageData* _img3 = bbGetInputIn3();
-       vtkImageData* _img4 = bbGetInputIn4();
+       vtkImageData* _img1 = bbGetInputIn0();
+       vtkImageData* _img2 = bbGetInputIn1();
+       vtkImageData* _img3 = bbGetInputIn2();
+       vtkImageData* _img4 = bbGetInputIn3();
        vtkRenderer* renderer = bbGetInputRenderer();
 
        if(volview!=NULL){
@@ -48,7 +48,14 @@ void VolumeRendering::Process()
                                volview->addVolume(_img4, "INPUT 4");
                        }
                }               
-       }  
+       } 
+       
+       bbSetOutputOut0(volview->GetOutputImages()[0]);
+       bbSetOutputOut1(volview->GetOutputImages()[1]);
+       bbSetOutputOut2(volview->GetOutputImages()[2]);
+       bbSetOutputOut3(volview->GetOutputImages()[3]);
+       
+
 }
 void VolumeRendering::CreateWidget(wxWindow* parent)
 {
@@ -60,10 +67,10 @@ void VolumeRendering::bbUserSetDefaultValues()
  
 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX  
 //  Here we initialize the input 'In' to 0 
+    bbSetInputIn0(0); 
     bbSetInputIn1(0); 
     bbSetInputIn2(0); 
     bbSetInputIn3(0); 
-    bbSetInputIn4(0); 
     bbSetInputRenderer(0);  
   
 }
index 5d1146a9ff3f778e2c5c1571efb27547d5127e9a..b860dd5fd5dc2130acbd70a8b720111390942cb3 100644 (file)
@@ -20,16 +20,16 @@ class bbcreaMaracasVisu_EXPORT VolumeRendering
 
   
   
+  BBTK_DECLARE_INPUT(In0,vtkImageData*);
   BBTK_DECLARE_INPUT(In1,vtkImageData*);
   BBTK_DECLARE_INPUT(In2,vtkImageData*);
   BBTK_DECLARE_INPUT(In3,vtkImageData*);
-  BBTK_DECLARE_INPUT(In4,vtkImageData*);
   BBTK_DECLARE_INPUT(Renderer,vtkRenderer*);
 
+  BBTK_DECLARE_OUTPUT(Out0,vtkImageData*);
   BBTK_DECLARE_OUTPUT(Out1,vtkImageData*);
   BBTK_DECLARE_OUTPUT(Out2,vtkImageData*);
   BBTK_DECLARE_OUTPUT(Out3,vtkImageData*);
-  BBTK_DECLARE_OUTPUT(Out4,vtkImageData*);
   
   
   /*BBTK_DECLARE_INPUT(GreyLevel, std::vector<double> );
@@ -55,15 +55,15 @@ BBTK_AUTHOR("car-prie@uniandes.edu.co");
 BBTK_DESCRIPTION("Volume Rendering of a given image");
 BBTK_CATEGORY("__CATEGORY__");
 
+BBTK_INPUT(VolumeRendering,In0,"Image to create the volume rendering",vtkImageData*,"");
 BBTK_INPUT(VolumeRendering,In1,"Image to create the volume rendering",vtkImageData*,"");
 BBTK_INPUT(VolumeRendering,In2,"Image to create the volume rendering",vtkImageData*,"");
 BBTK_INPUT(VolumeRendering,In3,"Image to create the volume rendering",vtkImageData*,"");
-BBTK_INPUT(VolumeRendering,In4,"Image to create the volume rendering",vtkImageData*,"");
 BBTK_INPUT(VolumeRendering,Renderer,"Image to create the volume rendering",vtkRenderer*,"");
+BBTK_OUTPUT(VolumeRendering,Out0,"Output resulting image",vtkImageData*,"");
 BBTK_OUTPUT(VolumeRendering,Out1,"Output resulting image",vtkImageData*,"");
 BBTK_OUTPUT(VolumeRendering,Out2,"Output resulting image",vtkImageData*,"");
 BBTK_OUTPUT(VolumeRendering,Out3,"Output resulting image",vtkImageData*,"");
-BBTK_OUTPUT(VolumeRendering,Out4,"Output resulting image",vtkImageData*,"");
 
 
 //BBTK_OUTPUT(VolumeRendering,Out,"Prop3D resulting from the volume rendering",vtkProp3D*,"");
diff --git a/data/colorsfunction2.txt b/data/colorsfunction2.txt
new file mode 100644 (file)
index 0000000..ff767e3
--- /dev/null
@@ -0,0 +1,44 @@
+<histogram Data>
+ <TransferenceFunction>
+               <Transferencepoint>
+                       <greyValue>0</greyValue>
+                       <intensity>0</intensity> 
+               </Transferencepoint>
+               <Transferencepoint>
+                       <greyValue>60</greyValue>
+                       <intensity>36</intensity> 
+               </Transferencepoint>
+               <Transferencepoint>
+                       <greyValue>129</greyValue>
+                       <intensity>26</intensity> 
+               </Transferencepoint>
+               <Transferencepoint>
+                       <greyValue>211</greyValue>
+                       <intensity>99</intensity> 
+               </Transferencepoint>
+               <Transferencepoint>
+                       <greyValue>234</greyValue>
+                       <intensity>0</intensity> 
+               </Transferencepoint>
+       </TransferenceFunction>
+       <Colors>
+               <greyValueRGBpoint>
+                       <RGBgreyValue>43</RGBgreyValue>
+                       <red>255</red>
+                       <green>0</green>
+                       <blue>0</blue>
+               </greyValueRGBpoint>
+               <greyValueRGBpoint>
+                       <RGBgreyValue>117</RGBgreyValue>
+                       <red>0</red>
+                       <green>255</green>
+                       <blue>128</blue>
+               </greyValueRGBpoint>
+               <greyValueRGBpoint>
+                       <RGBgreyValue>193</RGBgreyValue>
+                       <red>0</red>
+                       <green>0</green>
+                       <blue>255</blue>
+               </greyValueRGBpoint>
+       </Colors>
+</histogram Data>
index a52a32a5a92032a795b2febb484340c5353a3507..cece67664cd6d910207b58f6f44ad83d6d8e085b 100644 (file)
@@ -2,7 +2,7 @@
 # SET THE NAME OF YOUR LIBRARY
 
 
-SET ( LIBRARY_NAME   creaMaracasVisu_CutModule  )
+SET ( LIBRARY_NAME   creaMaracasVisu_CutModule2  )
 #----------------------------------------------------------------------------
 
 #----------------------------------------------------------------------------
index 2a594649b9ab794bba891ff55761ded0f2ccc627..21c1ca20615ff5dbb49abad18e5bacda30a9dcba 100644 (file)
@@ -1,6 +1,6 @@
 #----------------------------------------------------------------------------
 # SET THE NAME OF YOUR LIBRARY
-SET ( LIBRARY_NAME   creaMaracasVisu_CutModule_interface  )
+SET ( LIBRARY_NAME   creaMaracasVisu_CutModule2_interface  )
 #----------------------------------------------------------------------------
 #----------------------------------------------------------------------------
 
diff --git a/lib/maracasVisuLib/src/CutModule/interface/CutModel2MainPanel.cxx b/lib/maracasVisuLib/src/CutModule/interface/CutModel2MainPanel.cxx
new file mode 100644 (file)
index 0000000..a953a03
--- /dev/null
@@ -0,0 +1,378 @@
+/*=========================================================================
+
+  Program:   wxMaracas
+  Module:    $RCSfile: CutModel2MainPanel.cxx,v $
+  Language:  C++
+  Date:      $Date: 2009/11/19 15:00:32 $
+  Version:   $Revision: 1.1 $
+
+  Copyright: (c) 2002, 2003
+  License:
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+
+
+
+// EOF - wxMaracasMPR.cxx
+
+#include "CutModel2MainPanel.h"
+#include "HistogramDialog.h"
+#include "creaSystem.h"
+
+#include <wx/colordlg.h>
+#include <wx/bmpbuttn.h>
+
+#include <Add.xpm>
+#include <Undo.xpm>
+#include <Redo.xpm>
+#include <OkAll.xpm>
+
+
+
+CutModel2MainPanel* CutModel2MainPanel::instance=NULL;
+
+CutModel2MainPanel::CutModel2MainPanel( wxWindow* parent, std::string path)
+: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){
+
+       cutmanager=NULL;
+
+       initialize(path);
+
+}
+CutModel2MainPanel::~CutModel2MainPanel( ){
+       
+       delete cutmanager;
+}
+
+void CutModel2MainPanel::initialize(std::string path){
+       
+       cutmanager = new CutModel2Manager(path);
+
+       _panelid = 0;
+       _wxauimanager = new wxAuiManager(this); 
+       
+       wxAuiPaneInfo paneinfo;
+       _wxauimanager->AddPane(new ToolBarCutModel2(this),paneinfo.ToolbarPane().Top());                
+
+       _wxauimanager->Update();
+}
+
+CutModel2MainPanel* CutModel2MainPanel::getInstance(wxWindow* parent, std::string path){
+       if(instance==NULL){
+               if(parent == NULL){
+                       parent = new wxFrame();
+               }
+               instance = new CutModel2MainPanel(parent, path);
+       }
+       return instance;
+}
+
+/*CutModel2MainPanel* CutModel2MainPanel::getInstance(){
+       return instance;
+}*/
+
+void CutModel2MainPanel::setImageData(vtkImageData* img){
+       try{
+               checkInvariant();
+               cutmanager->setImageData(img);
+       }catch(CutModel2Exception e){
+               showErrorDialog(e.getCause());
+       }
+}
+
+void CutModel2MainPanel::setInteractor(vtkRenderWindowInteractor* interactor){
+       try{
+               checkInvariant();
+               cutmanager->setInteractor(interactor);
+       }catch(CutModel2Exception e){
+               showErrorDialog(e.getCause());
+       }
+}
+
+void CutModel2MainPanel::setRenderer(vtkRenderer* renderer){
+    try{
+               checkInvariant();
+               cutmanager->setRenderer(renderer);
+       }catch(CutModel2Exception e){
+               showErrorDialog(e.getCause());
+       }
+}
+
+void CutModel2MainPanel::checkInvariant()throw (CutModel2Exception){
+       if(cutmanager==NULL){
+               throw CutModel2Exception("The manager is not initialize");
+       }       
+}
+
+void CutModel2MainPanel::showErrorDialog(std::string str){     
+       wxMessageDialog* diag = new wxMessageDialog(this, wxString(str.c_str(),wxConvUTF8 ), wxString(str.c_str(),wxConvUTF8 ), wxICON_ERROR);
+       diag->ShowModal();
+}
+
+void CutModel2MainPanel::RemoveActor(int id){
+     try{
+               checkInvariant();
+
+               for(int i = 0; i < viewpanels.size()-1;i++){
+                       if(viewpanels[i]->getId()==id){
+                               for(int j = i; j < viewpanels.size()-1;j++){
+                    viewpanels[j]=viewpanels[j+1];
+                               }
+                               i = viewpanels.size();
+                       }
+               }
+               viewpanels.pop_back();
+
+
+               cutmanager->RemoveActor(id);
+
+       }catch(CutModel2Exception e){
+               showErrorDialog(e.getCause());
+       }
+}
+
+void CutModel2MainPanel::onAddCutModel2(){
+    try{
+               checkInvariant();
+
+               int id = addNewViewPanel();             
+               cutmanager->onAddCutModel2(id, getModelView(id));
+
+               _panelid++;
+
+               ShowCurrentPanel(id);
+
+       }catch(CutModel2Exception e){
+               showErrorDialog(e.getCause());
+       }
+}
+void CutModel2MainPanel::ShowCurrentPanel(int id){
+       for(int i = 0; i < viewpanels.size();i++){              
+               if(viewpanels[i]->getId()==id){
+                       _wxauimanager->GetPane(viewpanels[i]).Show(true);
+            cutmanager->RefreshActor(id);
+               }else{
+                       _wxauimanager->GetPane(viewpanels[i]).Show(false);
+               }
+       }
+       _wxauimanager->Update();
+}
+int CutModel2MainPanel::addNewViewPanel()throw( CutModel2Exception){
+       
+       CutModel2View* viewpanel = new CutModel2View(this,cutmanager->getImageRange());
+
+       wxAuiPaneInfo paneinfo0;
+       _wxauimanager->AddPane(viewpanel, paneinfo0.DefaultPane().DestroyOnClose().Centre());   
+       _wxauimanager->Update();
+
+       viewpanel->setId(_panelid);
+       viewpanels.push_back(viewpanel);        
+
+       return viewpanel->getId();
+       
+       
+}
+CutModel2View* CutModel2MainPanel::getModelView(int id)throw( CutModel2Exception){
+
+       CutModel2View* current = NULL;
+       for(int i = 0; i < viewpanels.size();i++){
+               if(viewpanels[i]->getId()==id){
+            current = viewpanels[i];
+               }
+       }
+       if(current == NULL){
+               std::string s = "Id not found";
+               throw CutModel2Exception(s);
+       }
+       return current;
+}
+void CutModel2MainPanel::onUndo(){
+       try{
+               checkInvariant();               
+               int result = cutmanager->Undo();
+
+       }catch(CutModel2Exception e){
+               showErrorDialog(e.getCause());
+       }
+       
+}
+
+void CutModel2MainPanel::onRedo(){
+
+       try{
+               checkInvariant();               
+               int result = cutmanager->Redo();
+
+       }catch(CutModel2Exception e){
+               showErrorDialog(e.getCause());
+       }
+       
+}
+
+void CutModel2MainPanel::changeOpacity(int id,int opacity){
+       try{
+               checkInvariant();               
+               cutmanager->changeOpacity(id, opacity);
+
+       }catch(CutModel2Exception e){
+               showErrorDialog(e.getCause());
+       }
+}
+
+void CutModel2MainPanel::ShowViewBox(int id,bool check){
+    try{
+               checkInvariant();               
+               cutmanager->ShowViewBox(id, check);
+
+       }catch(CutModel2Exception e){
+               showErrorDialog(e.getCause());
+       }
+}
+void CutModel2MainPanel::ShowPopUpMenu(int id){
+       showErrorDialog("test");
+}
+void CutModel2MainPanel::changeColor(int id,double r,double g,double b){
+
+       try{
+               checkInvariant();               
+               cutmanager->changeColor(id, r, g, b);
+
+       }catch(CutModel2Exception e){
+               showErrorDialog(e.getCause());
+       }
+       
+}
+void CutModel2MainPanel::ChangeShape(int id,int selection){
+       try{
+               checkInvariant();
+               
+               cutmanager->ChangeShape(id, selection);
+
+       }catch(CutModel2Exception e){
+               showErrorDialog(e.getCause());
+       }
+}
+void CutModel2MainPanel::updateActorDirection(int id){
+    try{
+               checkInvariant();
+               
+               cutmanager->updateActorDirection(id);
+
+       }catch(CutModel2Exception e){
+               showErrorDialog(e.getCause());
+       }
+}
+
+void CutModel2MainPanel::ExecuteCut(int id, double* range, bool isinside){
+       try{
+               checkInvariant();               
+
+               cutmanager->ExecuteCut(id, range, isinside);
+       }catch(CutModel2Exception e){
+               showErrorDialog(e.getCause());
+       }
+}
+
+void CutModel2MainPanel::ExecuteAll(){
+       for(int i = 0; i < viewpanels.size();i++){
+               viewpanels[i]->ExecuteCut();
+       }
+
+}
+vtkImageData* CutModel2MainPanel::GetResultImage(){
+    try{
+               checkInvariant();
+               return cutmanager->GetResultImage();
+       }catch(CutModel2Exception e){
+               showErrorDialog(e.getCause());
+       }
+       return NULL;
+}
+
+void CutModel2MainPanel::ShowStatistics(int id){
+
+       checkInvariant();
+       HistogramDialog *histo = new HistogramDialog(this, _T("Statistics"));
+
+       histo->initializeHistogram(cutmanager->GetResultImage());
+
+       histo->ShowModal();
+
+       delete histo;
+}
+
+void CutModel2MainPanel::SaveCutModel2Data(std::string filename){
+       cutmanager->SaveCutModel2Data(filename);
+}
+
+void CutModel2MainPanel::LoadCutModel2Data(std::string filename){
+    cutmanager->LoadCutModel2Data(filename);
+}
+/**
+**
+**/
+
+ToolBarCutModel2::ToolBarCutModel2(wxWindow * parent)
+: wxToolBar(parent, -1, wxDefaultPosition, wxDefaultSize)
+{
+
+       wxBitmap bitmap10(Add_xpm);
+       this->AddTool(10, wxString(_T("Add")),bitmap10);
+
+       this->AddSeparator();
+
+       wxBitmap bitmap20(Undo_xpm);
+       this->AddTool(20, wxString(_T("Undo")),bitmap20);
+
+       wxBitmap bitmap30(Redo_xpm);
+       this->AddTool(30, wxString(_T("Redo")),bitmap30);       
+
+       this->AddSeparator();
+
+       wxBitmap bitmap40(OkAll_xpm);
+       this->AddTool(40, wxString(_T("Ok All")),bitmap40);     
+
+       this->Realize();
+
+       _evthand = new ToolBarEventHandlerCutModel2();
+       this->SetEventHandler(_evthand);
+
+}
+
+ToolBarCutModel2::~ToolBarCutModel2(void){
+}
+
+ToolBarEventHandlerCutModel2::ToolBarEventHandlerCutModel2()
+: wxEvtHandler(){
+}
+ToolBarEventHandlerCutModel2::~ToolBarEventHandlerCutModel2(){
+}
+
+void ToolBarEventHandlerCutModel2::onAdd(wxCommandEvent& event){
+       CutModel2MainPanel::getInstance()->onAddCutModel2();
+}
+
+void ToolBarEventHandlerCutModel2::onUndo(wxCommandEvent& event){
+       CutModel2MainPanel::getInstance()->onUndo();    
+}
+
+void ToolBarEventHandlerCutModel2::onRedo(wxCommandEvent& event){
+       CutModel2MainPanel::getInstance()->onRedo();
+}
+
+void ToolBarEventHandlerCutModel2::onExecuteAll(wxCommandEvent& event){
+       CutModel2MainPanel::getInstance()->ExecuteAll();
+}
+
+
+BEGIN_EVENT_TABLE(ToolBarEventHandlerCutModel2, wxEvtHandler)
+       EVT_MENU(10, ToolBarEventHandlerCutModel2::onAdd)
+       EVT_MENU(20, ToolBarEventHandlerCutModel2::onUndo)
+       EVT_MENU(30, ToolBarEventHandlerCutModel2::onRedo)
+       EVT_MENU(40, ToolBarEventHandlerCutModel2::onExecuteAll)
+END_EVENT_TABLE()
+
diff --git a/lib/maracasVisuLib/src/CutModule/interface/CutModel2MainPanel.h b/lib/maracasVisuLib/src/CutModule/interface/CutModel2MainPanel.h
new file mode 100644 (file)
index 0000000..589106a
--- /dev/null
@@ -0,0 +1,151 @@
+/*=========================================================================
+
+  Program:   wxMaracas
+  Module:    $RCSfile: CutModel2MainPanel.h,v $
+  Language:  C++
+  Date:      $Date: 2009/11/19 15:00:32 $
+  Version:   $Revision: 1.1 $
+
+  Copyright: (c) 2002, 2003
+  License:
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+
+#ifndef __CutModel2MainPanelPanelH__
+#define __CutModel2MainPanelPanelH__
+
+#include <vector>
+#include <wx/wx.h>
+#include <wx/treebook.h>
+#include "wx/aui/aui.h"
+#include <wx/toolbar.h>
+#include <iostream>
+#include "marTypes.h"
+
+
+#include "CutModel2Manager.h"
+#include "CutModel2Exception.h"
+#include "CutModel2View.h"
+
+#include "vtkImageData.h"
+#include "vtkRenderWindowInteractor.h"
+
+
+class  creaMaracasVisu_EXPORT  CutModel2MainPanel : public wxPanel
+{
+
+public:
+       
+    ~CutModel2MainPanel( );
+
+       static CutModel2MainPanel* getInstance(wxWindow* parent=NULL, std::string path ="");
+
+       //static CutModel2MainPanel* getInstance();
+
+       void setImageData(vtkImageData* img);
+
+       void setInteractor(vtkRenderWindowInteractor* interactor);
+
+       void setRenderer(vtkRenderer* renderer);
+
+       void initialize(std::string path);
+
+       void onAddCutModel2();
+
+       void onUndo();
+
+       void onRedo();
+
+       void changeOpacity(int id,int opacity);
+
+       void ShowViewBox(int id,bool check);
+
+       void ChangeShape(int id,int selection);
+       
+       void changeColor(int id,double r,double g,double b);
+
+       void updateActorDirection(int id);
+
+       void RemoveActor(int id);
+
+       void ExecuteCut(int id, double* range, bool isinside);
+
+       void ExecuteAll();
+
+       vtkImageData* GetResultImage();
+
+       void ShowCurrentPanel(int id);
+
+       void ShowPopUpMenu(int id);
+
+       void ShowStatistics(int id);
+
+       
+private:
+
+       CutModel2MainPanel( wxWindow* parent, std::string path);
+
+       static CutModel2MainPanel* instance;
+
+       CutModel2Manager* cutmanager;   
+
+       void checkInvariant() throw( CutModel2Exception);
+
+       void showErrorDialog(std::string str);
+
+       void SaveCutModel2Data(std::string filename);
+
+       void LoadCutModel2Data(std::string filename);
+
+       std::vector<CutModel2View*> viewpanels;
+
+       wxAuiManager* _wxauimanager;
+
+
+        int addNewViewPanel()throw( CutModel2Exception);
+
+        CutModel2View* getModelView(int id)throw( CutModel2Exception);
+
+        int _panelid;
+};
+
+
+class ToolBarEventHandlerCutModel2 : public wxEvtHandler{
+
+       public:
+               ToolBarEventHandlerCutModel2();
+               ~ToolBarEventHandlerCutModel2();
+
+               void onAdd(wxCommandEvent& event);
+
+               void onUndo(wxCommandEvent& event);
+
+               void onRedo(wxCommandEvent& event);
+
+               void onExecuteAll(wxCommandEvent& event);
+
+       private:
+
+               DECLARE_EVENT_TABLE()
+       };
+
+class ToolBarCutModel2 : public wxToolBar{
+
+       
+public:
+       ToolBarCutModel2(wxWindow * parent);
+       ~ToolBarCutModel2(void);
+
+
+private:
+
+       ToolBarEventHandlerCutModel2* _evthand;
+
+};
+
+#endif
+
diff --git a/lib/maracasVisuLib/src/CutModule/interface/CutModel2View.cxx b/lib/maracasVisuLib/src/CutModule/interface/CutModel2View.cxx
new file mode 100644 (file)
index 0000000..7f636cb
--- /dev/null
@@ -0,0 +1,250 @@
+/*=========================================================================
+
+  Program:   wxMaracas
+  Module:    $RCSfile: CutModel2View.cxx,v $
+  Language:  C++
+  Date:      $Date: 2009/11/19 15:00:32 $
+  Version:   $Revision: 1.1 $
+
+  Copyright: (c) 2002, 2003
+  License:
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+
+
+
+// EOF - wxMaracasMPR.cxx
+
+#include "CutModel2View.h"
+
+
+#include <wx/colordlg.h>
+#include <wx/bmpbuttn.h>
+
+#include <OpenImage.xpm>
+#include <Color.xpm>
+#include <Ok1.xpm>
+#include <Statistics.xpm>
+
+#include "vtkBoxWidget.h"
+
+#include "CutModel2MainPanel.h"
+
+CutModel2View::CutModel2View( wxWindow* parent, double* range)
+: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){
+
+       wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
+
+       this->SetSizer(sizer);  
+       
+       sizer->Add(getBoxControls(this, range),wxSizerFlags().FixedMinSize());  
+
+       sizer->AddSpacer(5);
+
+       sizer->Add(getActorProperties(this),wxSizerFlags().FixedMinSize());     
+
+
+       wxBitmap bitmapok(Ok1_xpm);
+       wxBitmapButton* okbutton = new wxBitmapButton(this, -1, bitmapok,wxDefaultPosition,wxSize(30,30));                      
+       Connect(okbutton->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)(&CutModel2ViewEventHandler::onExecute));       
+       
+       sizer->AddSpacer(5);
+       sizer->Add(okbutton,wxSizerFlags().FixedMinSize());
+
+
+       
+
+
+}
+CutModel2View::~CutModel2View( ){
+       CutModel2MainPanel::getInstance()->RemoveActor(this->getId());
+}
+
+wxSizer* CutModel2View::getBoxControls(wxWindow* parent,double* range){
+
+       wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
+       wxCheckBox* checkbox = new wxCheckBox(parent,-1,_T("View Box"));
+       sizer->Add(checkbox,wxSizerFlags().FixedMinSize());
+       checkbox->SetValue(true);
+       Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)(&CutModel2ViewEventHandler::onViewBoxChecked));
+
+       wxString choices1[3];
+       //choices1[0] = _T("Select a shape...");
+       choices1[0] = _T("Sphere");
+       choices1[1] = _T("Cylinder");
+       choices1[2] = _T("Cube");
+       wxComboBox* combo = new wxComboBox(parent, -1,_T(""),wxDefaultPosition,wxDefaultSize,3,choices1);
+       combo->SetValue(_T("Sphere"));
+       sizer->Add(combo,wxSizerFlags().FixedMinSize());
+       Connect(combo->GetId(), wxEVT_COMMAND_COMBOBOX_SELECTED,(wxObjectEventFunction)(&CutModel2ViewEventHandler::onShapeChange));
+
+       wxStaticText* labelgreyv = new wxStaticText(parent, -1, wxString(_T("Grey value range")));      
+       _sliderrange = new wxSlider(parent, -1, range[0],range[0],range[1],wxDefaultPosition,wxDefaultSize,wxSL_LABELS|wxSL_SELRANGE);
+       wxBoxSizer* sizergreyv = new wxBoxSizer(wxVERTICAL);
+       sizergreyv->Add(labelgreyv,wxSizerFlags().FixedMinSize());
+       sizergreyv->Add(_sliderrange,wxSizerFlags().FixedMinSize());
+       sizer->Add(sizergreyv,wxSizerFlags().FixedMinSize().Border());
+       
+       wxString choices0[2];
+       choices0[0] = _T("inside");
+       choices0[1] = _T("outside");
+       _radioinsideout = new  wxRadioBox(parent,-1,_T(""), wxDefaultPosition, wxDefaultSize,2,choices0);
+       sizer->Add(_radioinsideout,wxSizerFlags().FixedMinSize());
+
+       /*wxString choices[2];
+       choices[0] = _T("Cut");
+       choices[1] = _T("Statistics");
+       _radiocutstat = new  wxRadioBox(parent,-1,_T(""), wxDefaultPosition, wxDefaultSize,2,choices);
+       sizer->Add(_radiocutstat,wxSizerFlags().FixedMinSize());*/
+
+       wxBitmap bitmap(Statistics_xpm);
+       wxBitmapButton* statbut = new wxBitmapButton(parent, -1, bitmap,wxDefaultPosition,wxSize(30,30));                       
+       Connect(statbut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)(&CutModel2ViewEventHandler::onStatistics));     
+    sizer->Add(statbut,wxSizerFlags().FixedMinSize());
+
+       
+
+       return sizer;
+}
+wxSizer* CutModel2View::getActorProperties(wxWindow* parent){
+
+       wxBoxSizer* sizeractorproperties = new wxBoxSizer(wxVERTICAL);  
+
+       wxStaticText* labelshapeactor = new wxStaticText(parent, -1, wxString(_T("Actor's properties")));
+
+       sizeractorproperties->Add(labelshapeactor,wxSizerFlags().FixedMinSize());
+
+       sizeractorproperties->Add(getColorChooseActor(parent),wxSizerFlags().FixedMinSize());
+
+       sizeractorproperties->Add(getOpacityActor(parent),wxSizerFlags().FixedMinSize());
+
+       return sizeractorproperties;
+       
+}
+
+wxSizer* CutModel2View::getOpacityActor(wxWindow* parent){
+       wxBoxSizer* sizeropacity = new wxBoxSizer(wxVERTICAL);  
+
+       wxStaticText* labelopacity = new wxStaticText(parent, -1, wxString(_T("Opacity")));
+       wxSlider* slider0 = new wxSlider(parent, -1, 60,0,100,wxDefaultPosition,wxDefaultSize,wxSL_LABELS);
+       Connect(slider0->GetId(), wxEVT_SCROLL_THUMBRELEASE,(wxObjectEventFunction)(&CutModel2ViewEventHandler::onOpacityChange));      
+       
+       sizeropacity->Add(labelopacity,wxSizerFlags().FixedMinSize());
+       sizeropacity->Add(slider0,wxSizerFlags().FixedMinSize());
+
+       return sizeropacity;
+}
+
+wxSizer* CutModel2View::getColorChooseActor(wxWindow* parent){
+    wxBoxSizer* sizercolor = new wxBoxSizer(wxHORIZONTAL);
+       wxBitmap bitmap(Color_xpm);
+       wxBitmapButton* colorchoose = new wxBitmapButton(parent, -1, bitmap,wxDefaultPosition,wxSize(30,30));            
+       wxObjectEventFunction f = (wxObjectEventFunction)(&CutModel2ViewEventHandler::onColorChange);   
+       Connect(colorchoose->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, f); 
+
+       _currentcolor = new wxStaticText(parent,-1,_T(""),wxDefaultPosition,wxSize(20,20));
+       this->SetCurrentColor(wxColour(255.0,0.0,0.0));
+
+       sizercolor->Add(colorchoose,wxSizerFlags().FixedMinSize());
+       sizercolor->AddSpacer(5);
+       sizercolor->Add(_currentcolor,wxSizerFlags().FixedMinSize().Centre());
+       return sizercolor;
+}
+
+void CutModel2View::checkInvariant()throw (CutModel2Exception){
+       
+}
+
+void CutModel2View::Execute(vtkObject *wdg, unsigned long eventId, void* calldata) {  // virtual
+       //vtkBoxWidget *boxwidget = reinterpret_cast<vtkBoxWidget*>(wdg);
+
+       if(eventId==vtkCommand::StartInteractionEvent){
+        CutModel2MainPanel::getInstance()->ShowCurrentPanel(this->getId());
+       }else if(eventId==vtkCommand::InteractionEvent){
+               CutModel2MainPanel::getInstance()->updateActorDirection(this->getId());
+       }else if(eventId==vtkCommand::RightButtonReleaseEvent){
+               //  =(
+        CutModel2MainPanel::getInstance()->ShowPopUpMenu(this->getId());
+       }
+}
+
+void CutModel2View::ExecuteCut(){      
+       if(this->isCut()){
+               CutModel2MainPanel::getInstance()->ExecuteCut(this->getId(),this->getRange(),this->isInside());
+       }else{
+       }
+       
+}
+
+double* CutModel2View::getRange(){
+       double* x = new double[3];
+       x[0] = 0;
+       x[1] = _sliderrange->GetValue();
+       x[2] = 100000;
+
+       return x;
+}
+bool CutModel2View::isCut(){
+       return true;
+       //return _radiocutstat->GetSelection()==0;
+}
+bool CutModel2View::isInside(){
+       return _radioinsideout->GetSelection()==0;
+}
+void CutModel2View::SetCurrentColor(wxColour colour){
+       _currentcolor->SetBackgroundColour(colour);
+
+       this->Refresh();
+       this->Layout();
+}
+
+void CutModel2ViewEventHandler::onColorChange(wxCommandEvent& event){
+       CutModel2View* parent = (CutModel2View*)((wxWindow*)event.GetEventObject())->GetParent();
+       wxColourDialog* colourdiag = new wxColourDialog(parent);
+       if(colourdiag->ShowModal()==wxID_OK){
+               wxColour colour = colourdiag->GetColourData().GetColour();
+               
+               parent->SetCurrentColor(colour);
+
+               double r = (double)(colour.Red())/255.0;
+               double g = (double)(colour.Green())/255.0;
+               double b = (double)(colour.Blue())/255.0;               
+               CutModel2MainPanel::getInstance()->changeColor(parent->getId(),r,g,b);
+
+
+       }
+       delete colourdiag;
+}
+
+void CutModel2ViewEventHandler::onOpacityChange(wxScrollEvent& event){
+       CutModel2View* parent = (CutModel2View*)((wxWindow*)event.GetEventObject())->GetParent();
+
+       CutModel2MainPanel::getInstance()->changeOpacity(parent->getId(),event.GetInt());
+}
+void CutModel2ViewEventHandler::onViewBoxChecked(wxCommandEvent& event){
+    CutModel2View* parent = (CutModel2View*)((wxWindow*)event.GetEventObject())->GetParent();
+
+       CutModel2MainPanel::getInstance()->ShowViewBox(parent->getId(),event.IsChecked());
+}
+void CutModel2ViewEventHandler::onShapeChange(wxCommandEvent& event){
+       CutModel2View* parent = (CutModel2View*)((wxWindow*)event.GetEventObject())->GetParent();
+
+       //if(event.GetSelection()>0){
+               //std::cout<<"id in CutModel2ViewEventHandler:: "<<parent->getId()<<std::endl;
+       CutModel2MainPanel::getInstance()->ChangeShape(parent->getId(),event.GetSelection());
+       //}
+}
+void CutModel2ViewEventHandler::onStatistics(wxCommandEvent& event){
+       CutModel2View* parent = (CutModel2View*)((wxWindow*)event.GetEventObject())->GetParent();
+       CutModel2MainPanel::getInstance()->ShowStatistics(parent->getId());
+}
+void CutModel2ViewEventHandler::onExecute(wxCommandEvent& event){
+     CutModel2View* parent = (CutModel2View*)((wxWindow*)event.GetEventObject())->GetParent();
+
+        parent->ExecuteCut();
+        
+}
diff --git a/lib/maracasVisuLib/src/CutModule/interface/CutModel2View.h b/lib/maracasVisuLib/src/CutModule/interface/CutModel2View.h
new file mode 100644 (file)
index 0000000..3acd567
--- /dev/null
@@ -0,0 +1,103 @@
+/*=========================================================================
+
+  Program:   wxMaracas
+  Module:    $RCSfile: CutModel2View.h,v $
+  Language:  C++
+  Date:      $Date: 2009/11/19 15:00:32 $
+  Version:   $Revision: 1.1 $
+
+  Copyright: (c) 2002, 2003
+  License:
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+
+#ifndef __CutModel2ViewPanelH__
+#define __CutModel2ViewPanelH__
+
+#include <vector>
+#include <wx/wx.h>
+#include <wx/radiobut.h>
+#include "wx/aui/aui.h"
+#include <iostream>
+#include "marTypes.h"
+
+
+#include "CutModel2Manager.h"
+#include "CutModel2Exception.h"
+
+#include "vtkObject.h"
+#include "vtkCommand.h"
+
+
+class  creaMaracasVisu_EXPORT  CutModel2View : public wxPanel, public vtkCommand
+{
+
+public:
+       CutModel2View( wxWindow* parent,double* range);
+    ~CutModel2View( );
+
+       virtual void Execute(vtkObject *wdg, unsigned long eventId, void* calldata) ;
+       
+       int getId(){
+               return _id;
+       }
+       void setId(int id){
+               _id = id;
+       }
+       
+       void ExecuteCut();
+
+       void SetCurrentColor(wxColour colour);
+       
+private:       
+
+       int _id;
+
+       wxSlider* _sliderrange;
+       wxRadioBox* _radioinsideout;
+       //wxRadioBox* _radiocutstat;
+       wxStaticText* _currentcolor;
+
+       double* getRange();
+       bool isCut();
+       bool isInside();
+
+
+
+       wxSizer* getBoxControls(wxWindow* parent, double* range);
+
+
+       wxSizer* getActorProperties(wxWindow* parent);
+       wxSizer* getColorChooseActor(wxWindow* parent);
+       wxSizer* getOpacityActor(wxWindow* parent);
+
+       void checkInvariant() throw( CutModel2Exception);
+
+};
+
+class CutModel2ViewEventHandler : public wxEvtHandler{
+
+       public:
+               CutModel2ViewEventHandler(): wxEvtHandler(){};
+               ~CutModel2ViewEventHandler(){};
+
+               void onColorChange(wxCommandEvent& event);                      
+               void onOpacityChange(wxScrollEvent& event);
+               void onViewBoxChecked(wxCommandEvent& event);
+               void onShapeChange(wxCommandEvent& event);
+               void onStatistics(wxCommandEvent& event);
+               void onExecute(wxCommandEvent& event);
+               
+
+
+       private:
+               
+};
+
+
+#endif
+
index 96115d860915a1f57160791f5ec27f71812b5c51..1a4aecfe31ff8fcd78a5148923d179bc265858e7 100644 (file)
@@ -1,6 +1,6 @@
 #----------------------------------------------------------------------------
 # SET THE NAME OF YOUR LIBRARY
-SET ( LIBRARY_NAME   creaMaracasVisu_CutModule_kernel  )
+SET ( LIBRARY_NAME   creaMaracasVisu_CutModule2_kernel  )
 #----------------------------------------------------------------------------
 #----------------------------------------------------------------------------
 
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModel2Data.cxx b/lib/maracasVisuLib/src/CutModule/kernel/CutModel2Data.cxx
new file mode 100644 (file)
index 0000000..a48ff5e
--- /dev/null
@@ -0,0 +1,388 @@
+/*=========================================================================
+
+  Program:   wxMaracas
+  Module:    $RCSfile: CutModel2Data.cxx,v $
+  Language:  C++
+  Date:      $Date: 2009/11/19 15:00:33 $
+  Version:   $Revision: 1.1 $
+
+  Copyright: (c) 2002, 2003
+  License:
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+#include "CutModel2Data.h"
+
+/**
+**     Start of the manager class
+**/
+CutModel2Data::CutModel2Data(int id, vtkRenderWindowInteractor* interactor, vtkCommand* observer, vtkImageData* img){
+       
+       initializeData(id, interactor, observer, img);
+       
+}
+CutModel2Data::CutModel2Data(){
+
+}
+void CutModel2Data::initializeData(int id, vtkRenderWindowInteractor* interactor, vtkCommand* observer, vtkImageData* img){
+       _id = id;
+       _currentshape=0;
+       createBoxWidget(interactor, observer);
+       setTransform(img);
+       createActor();
+       createShapes();
+       ChangeShape(0);
+       checkInvariant();
+}
+CutModel2Data::~CutModel2Data(){
+       checkInvariant();
+       _boxWidgetVolume->Off();
+       _boxWidgetVolume->Delete();     
+       _Mapper->Delete();      
+       _Actor->Delete();       
+       delete _cubefigure;
+       delete _cylinderfigure;
+       delete _spherefigure;
+       currentmatrix->Delete();
+       inversModel->Delete();
+}
+void CutModel2Data::RefreshViewBox(){
+               
+}
+void CutModel2Data::createBoxWidget(vtkRenderWindowInteractor* interactor, vtkCommand* observer){
+
+       _boxWidgetVolume = vtkBoxWidget::New();
+       _boxWidgetVolume->SetInteractor( interactor );
+       //_boxWidgetVolume->SetPlaceFactor(1);
+       //_boxWidgetVolume->SetInput( img );    
+       //_boxWidgetVolume->PlaceWidget();
+
+       _boxWidgetVolume->AddObserver( vtkCommand::InteractionEvent              , observer );
+       _boxWidgetVolume->AddObserver( vtkCommand::StartInteractionEvent                 , observer );
+       _boxWidgetVolume->AddObserver( vtkCommand::RightButtonReleaseEvent               , observer );
+       
+       _boxWidgetVolume->HandlesOn ();
+       _boxWidgetVolume->On();
+       //_boxWidgetVolume->GetHandleProperty()->SetOpacity(0.5);       
+       //_boxWidgetVolume->GetOutlineProperty()->SetOpacity(0.5);      
+}
+void CutModel2Data::setTransform(vtkImageData* img)throw( CutModel2Exception){
+       
+       currentmatrix = vtkTransform::New();
+       modeltransform = vtkTransform::New();
+       inversModel     = vtkTransform::New();    
+
+       vtkMatrix4x4* matrix = vtkMatrix4x4::New();  
+       matrix->Identity();     
+       int *ext = img->GetExtent();
+       double *spc = img->GetSpacing();
+
+       
+       matrix->SetElement(0,0,(ext[1]-ext[0])/4*spc[0]);
+       matrix->SetElement(1,1,(ext[3]-ext[2])/4*spc[1]);       
+       matrix->SetElement(2,2,(ext[5]-ext[4])/4*spc[2]);
+
+       double orgx = (ext[1]-ext[0])/2*spc[0];
+       double orgy = (ext[3]-ext[2])/2*spc[1];
+       double orgz = (ext[5]-ext[4])/2*spc[2];
+
+       matrix->SetElement(0,3,orgx);
+       matrix->SetElement(1,3,orgy);
+       matrix->SetElement(2,3,orgz);
+
+       
+       currentmatrix->SetMatrix(matrix);
+       _boxWidgetVolume->SetTransform(currentmatrix);  
+               
+}
+void CutModel2Data::createActor(){     
+
+       _Mapper = vtkPolyDataMapper::New();     
+       _Actor  = vtkActor::New();
+       _Actor->SetMapper(_Mapper);     
+       _Actor->GetProperty()->SetColor(1, 0, 0);
+       _Actor->GetProperty()->SetOpacity(0.5); 
+       
+}
+void CutModel2Data::udapteActorDirection()throw( CutModel2Exception){
+       checkInvariant();
+       
+       _boxWidgetVolume->GetTransform(currentmatrix);          
+       _Actor->SetUserMatrix(currentmatrix->GetMatrix());//SetUserTransform(currentmatrix );
+}
+void CutModel2Data::createShapes(){
+       _cubefigure = new CutModel2FigureCube();
+       _cylinderfigure = new CutModel2FigureCylinder();
+       _spherefigure = new CutModel2FigureSphere();
+}
+void CutModel2Data::changeOpacity(int opacity)throw( CutModel2Exception){
+       checkInvariant();       
+       _Actor->GetProperty()->SetOpacity((double)opacity/100.0);
+}
+
+void CutModel2Data::ShowViewBox(bool check)throw( CutModel2Exception){
+       checkInvariant();
+       if(check){
+               _boxWidgetVolume->On();
+       }else{
+               _boxWidgetVolume->Off();
+       }    
+}
+
+void CutModel2Data::ChangeShape(int selection)throw( CutModel2Exception){
+       checkInvariant();
+       
+       if(selection == 0){
+               _Mapper->SetInput(_spherefigure->getPolyData());
+       }else if(selection == 1){
+               _Mapper->SetInput(_cylinderfigure->getPolyData());
+       }else if(selection == 2){
+               _Mapper->SetInput(_cubefigure->getPolyData());
+       }else{
+               throw CutModel2Exception("Shape type not found");
+       }
+
+       _currentshape=selection;
+}
+
+void CutModel2Data::checkInvariant()throw( CutModel2Exception){
+       if(_boxWidgetVolume==NULL){
+               throw CutModel2Exception("Box Widget not created");
+       }
+       if(_Mapper==NULL){
+               throw CutModel2Exception("Mapper not created");
+       }
+       if(_Actor==NULL){
+               throw CutModel2Exception("Actor not created");
+       }
+       if(_cubefigure==NULL){
+               throw CutModel2Exception("Cube not created");
+       }
+       if(_cylinderfigure==NULL){
+               throw CutModel2Exception("Cylinder not created");
+       }
+       if(_spherefigure==NULL){
+               throw CutModel2Exception("Sphere not created");
+       }        
+       
+}
+
+vtkActor* CutModel2Data::getActor()throw( CutModel2Exception){
+       checkInvariant();
+       return _Actor;
+}
+
+void CutModel2Data::changeColor(double r,double g,double b)throw( CutModel2Exception){
+       checkInvariant();               
+       _Actor->GetProperty()->SetColor( r, g, b );     
+}
+CutModel2Figure* CutModel2Data::getCurentCuttingModel(){
+    checkInvariant();
+       
+       if(_currentshape == 0){
+               return _spherefigure;
+       }else if(_currentshape == 1){
+               return _cylinderfigure;
+       }else if(_currentshape == 2){
+               return _cubefigure;
+       }else{
+               throw CutModel2Exception("Shape type not found");
+       }       
+}
+void CutModel2Data::ExecuteCut( double* range, bool isinside, vtkImageData* copyimage)throw( CutModel2Exception)
+{
+
+       wxBusyCursor wait;
+
+       CutModel2Figure* actualCuttingModel = getCurentCuttingModel();
+
+       //_boxWidgetVolume->GetTransform(currentmatrix);        
+       actualCuttingModel->SetVtkTransform(getModelTransform(copyimage));
+       //actualCuttingModel->SetVtkTransform(currentmatrix);
+       actualCuttingModel->SetInversVtkTransform(getModelTransformInvers());   
+
+       bool                    inside;
+       bool                    volInt, volExt;
+       int                             xx,yy,zz;
+       unsigned short* pOrg;   
+       int                             ext[6];
+       double                  spc[3];
+       long int                contAfter = 0;
+       long int                contBefor = 0;
+       
+       double minvalue = range[0]; 
+       double value    = range[1];
+       double maxvalue = range[2]; 
+
+               
+       copyimage->GetExtent(ext);        
+       
+       for (xx=ext[0];xx<ext[1]; xx++)
+       {
+               for (yy=ext[2];yy<ext[3]; yy++)
+               {
+                       for (zz=ext[4];zz<ext[5];zz++)
+                       {
+                               inside=actualCuttingModel->IfPointInside(xx,yy,zz);
+                               if (  ((inside==true)&&(isinside==true)) || ((!inside==true)&&(!isinside)) )
+                               {
+                                       pOrg=(unsigned short*)copyimage->GetScalarPointer (xx,yy,zz); 
+
+                                       //std::cout<<"xx,yy,zz "<<xx<<","<<yy<<","<<zz<<" "<<*pOrg<<std::endl;
+                                       if ((unsigned short)minvalue <=(*pOrg)&&(*pOrg)<=(unsigned short)maxvalue)
+                                       {       
+                                               
+                                               *pOrg=(unsigned short)value;
+                                               
+                                       }                                       
+                               } // if inside
+                       } // for zz
+               } // for yy
+       } // for xx
+       
+}
+
+void CutModel2Data::ExecuteUnCut(bool isinside, vtkImageData* image, vtkImageData* copyimage)throw( CutModel2Exception)
+{
+
+       wxBusyCursor wait;
+
+       CutModel2Figure* actualCuttingModel = getCurentCuttingModel();
+       
+       actualCuttingModel->SetVtkTransform(getModelTransform(copyimage));
+       
+       actualCuttingModel->SetInversVtkTransform(getModelTransformInvers());   
+
+       bool                    inside;
+       bool                    volInt, volExt;
+       int                             xx,yy,zz;
+       unsigned short* pOrg;   
+       int                             ext[6];
+       double                  spc[3];
+       long int                contAfter = 0;
+       long int                contBefor = 0;  
+       
+       double value;
+       
+
+               
+       copyimage->GetExtent(ext);        
+       
+       for (xx=ext[0];xx<ext[1]; xx++)
+       {
+               for (yy=ext[2];yy<ext[3]; yy++)
+               {
+                       for (zz=ext[4];zz<ext[5];zz++)
+                       {
+                               inside=actualCuttingModel->IfPointInside(xx,yy,zz);
+                               if (  ((inside==true)&&(isinside==true)) || ((!inside==true)&&(!isinside)) )
+                               {
+                                       value = *((unsigned short*)image->GetScalarPointer (xx,yy,zz));
+                                       pOrg=(unsigned short*)copyimage->GetScalarPointer (xx,yy,zz); 
+                                       //std::cout<<"CutModel2Data::ExecuteUnCut() "<<value<<" "<<*pOrg<<std::endl;
+                                       *pOrg=(unsigned short)value;
+                               } // if inside
+                       } // for zz
+               } // for yy
+       } // for xx
+       
+}
+
+vtkTransform* CutModel2Data::getModelTransform(vtkImageData* copyimage){
+
+       double *spc = copyimage->GetSpacing();
+       modeltransform->Identity();
+
+    vtkMatrix4x4* matrix = currentmatrix->GetMatrix();
+       vtkMatrix4x4* matrixmodel = modeltransform->GetMatrix();
+       matrixmodel->SetElement(0,0,matrix->GetElement(0,0)/spc[0]);
+       matrixmodel->SetElement(1,0,matrix->GetElement(1,0)/spc[0]);
+       matrixmodel->SetElement(2,0,matrix->GetElement(2,0)/spc[0]);
+       matrixmodel->SetElement(0,1,matrix->GetElement(0,1)/spc[1]);
+       matrixmodel->SetElement(1,1,matrix->GetElement(1,1)/spc[1]);
+       matrixmodel->SetElement(2,1,matrix->GetElement(2,1)/spc[1]);
+       matrixmodel->SetElement(0,2,matrix->GetElement(0,2)/spc[2]);
+       matrixmodel->SetElement(1,2,matrix->GetElement(1,2)/spc[2]);
+       matrixmodel->SetElement(2,2,matrix->GetElement(2,2)/spc[2]);            
+       matrixmodel->SetElement(0,3,matrix->GetElement(0,3)/spc[0]);
+       matrixmodel->SetElement(1,3,matrix->GetElement(1,3)/spc[1]);
+       matrixmodel->SetElement(2,3,matrix->GetElement(2,3)/spc[2]);    
+
+       /*
+       
+       double* pos = currentmatrix->GetPosition();
+       modeltransform->Translate(pos[0]/spc[0],pos[1]/spc[1],pos[2]/spc[2]);   
+
+       double* scal = currentmatrix->GetScale();       
+       modeltransform->Scale(scal[0]/spc[0],scal[1]/spc[1],scal[2]/spc[2]);
+
+       //double* orient = currentmatrix->GetOrientation();
+       //modeltransform->RotateZ(orient[2]);   
+       //modeltransform->RotateY(orient[1]);   
+       //modeltransform->RotateX(orient[0]);   
+       double* orient = currentmatrix->GetOrientationWXYZ();   
+       modeltransform->RotateWXYZ(orient[0],orient[1],orient[2],orient[3]);    
+       
+       */
+               
+
+       modeltransform->Update();
+
+       return modeltransform;
+
+       
+}
+void CutModel2Data::setTransform(vtkTransform* transform, vtkImageData* img)throw( CutModel2Exception){
+               
+
+       double *spc = img->GetSpacing();
+
+       currentmatrix->Identity();      
+
+       /*double* orient = transform->GetOrientationWXYZ();
+       currentmatrix->RotateWXYZ(orient[0],orient[1],orient[2],orient[3]);     
+
+       double* pos = transform->GetPosition();
+       currentmatrix->Translate(pos[0]/spc[0],pos[1]/spc[1],pos[2]/spc[2]);
+
+       double* scal = transform->GetScale();   
+       currentmatrix->Scale(scal[0]/spc[0],scal[1]/spc[1],scal[2]/spc[2]);
+
+       currentmatrix->Update();        */
+               
+       _boxWidgetVolume->SetTransform(transform);
+
+    /*vtkMatrix4x4* matrix = transform->GetMatrix();
+       vtkMatrix4x4* matrixcurrent = currentmatrix->GetMatrix();
+       matrixcurrent->SetElement(0,0,matrix->GetElement(0,0)/spc[0]);
+       matrixcurrent->SetElement(1,0,matrix->GetElement(1,0)/spc[0]);
+       matrixcurrent->SetElement(2,0,matrix->GetElement(2,0)/spc[0]);
+       matrixcurrent->SetElement(0,1,matrix->GetElement(0,1)/spc[1]);
+       matrixcurrent->SetElement(1,1,matrix->GetElement(1,1)/spc[1]);
+       matrixcurrent->SetElement(2,1,matrix->GetElement(2,1)/spc[1]);
+       matrixcurrent->SetElement(0,2,matrix->GetElement(0,2)/spc[2]);
+       matrixcurrent->SetElement(1,2,matrix->GetElement(1,2)/spc[2]);
+       matrixcurrent->SetElement(2,2,matrix->GetElement(2,2)/spc[2]);          
+       matrixcurrent->SetElement(0,3,matrix->GetElement(0,3)/spc[0]);
+       matrixcurrent->SetElement(1,3,matrix->GetElement(1,3)/spc[1]);
+       matrixcurrent->SetElement(2,3,matrix->GetElement(2,3)/spc[2]);  */
+
+
+       udapteActorDirection();
+       getModelTransform(img);
+
+}
+vtkTransform* CutModel2Data::getModelTransformInvers(){
+       inversModel->Identity ();
+       inversModel->Concatenate ( modeltransform );
+       inversModel->Inverse(); 
+       return inversModel;
+}
+
+vtkPolyData* CutModel2Data::getPolyData()throw( CutModel2Exception){
+       return _Mapper->GetInput();
+}
+
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModel2Data.h b/lib/maracasVisuLib/src/CutModule/kernel/CutModel2Data.h
new file mode 100644 (file)
index 0000000..40904e1
--- /dev/null
@@ -0,0 +1,118 @@
+/*=========================================================================
+
+  Program:   wxMaracas
+  Module:    $RCSfile: CutModel2Data.h,v $
+  Language:  C++
+  Date:      $Date: 2009/11/19 15:00:33 $
+  Version:   $Revision: 1.1 $
+
+  Copyright: (c) 2002, 2003
+  License:
+  
+     This software is distributed WITHOUT ANY WARRANTY; without even 
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+
+
+
+
+#ifndef __CutModel2DataH__
+#define __CutModel2DataH__
+
+#include <iostream>
+#include <vector>
+
+#include "vtkImageData.h"
+#include "vtkRenderWindowInteractor.h"
+#include "vtkCommand.h"
+#include "vtkBoxWidget.h"
+#include "vtkPolyDataMapper.h"
+#include "vtkActor.h"
+#include "vtkProperty.h"
+#include "CutModel2Exception.h"
+#include "CutModel2Figure.h"
+#include "CutModel2FigureCube.h"
+#include "CutModel2FigureSphere.h"
+#include "CutModel2FigureCylinder.h"
+
+#include <wx/utils.h>
+
+class CutModel2Data  {
+
+public:
+       CutModel2Data();
+       CutModel2Data(int id, vtkRenderWindowInteractor* interactor, vtkCommand* observer, vtkImageData* img);
+       ~CutModel2Data();
+       void initializeData(int id, vtkRenderWindowInteractor* interactor, vtkCommand* observer, vtkImageData* img);
+
+
+       int getId(){
+               return _id;
+       }
+
+       void changeOpacity(int opacity)throw( CutModel2Exception);
+
+       void ShowViewBox(bool check)throw( CutModel2Exception);
+
+       void ChangeShape(int selection)throw( CutModel2Exception);
+
+       vtkActor* getActor()throw( CutModel2Exception);
+
+       vtkPolyData* getPolyData()throw( CutModel2Exception);
+       
+       void changeColor(double r,double g,double b)throw( CutModel2Exception);
+
+       void udapteActorDirection()throw( CutModel2Exception);
+
+       void ExecuteCut( double* range, bool isinside, vtkImageData* copyimage)throw( CutModel2Exception);
+
+       void ExecuteUnCut(  bool isinside, vtkImageData* image, vtkImageData* copyimage)throw( CutModel2Exception);
+
+       void RefreshViewBox();
+
+       vtkTransform* getCurrentMatrix(){
+               return currentmatrix;
+       }
+
+       int getCurrentShape(){
+               return _currentshape;
+       }
+
+       void setCurrentShape(int currentshape){
+               _currentshape = currentshape;
+       }
+
+       void setTransform(vtkTransform* transform,vtkImageData* img)throw( CutModel2Exception);
+private:       
+       
+       void checkInvariant()throw( CutModel2Exception);
+
+       void createBoxWidget(vtkRenderWindowInteractor* interactor, vtkCommand* observer);
+       void createActor();
+       void setTransform(vtkImageData* img)throw( CutModel2Exception);
+       void createShapes();    
+
+       vtkBoxWidget* _boxWidgetVolume;
+       vtkPolyDataMapper* _Mapper;     
+       vtkActor* _Actor;       
+       int _id;
+
+       int _currentshape;
+
+       CutModel2FigureCube* _cubefigure;
+       CutModel2FigureCylinder* _cylinderfigure;
+       CutModel2FigureSphere* _spherefigure;
+       vtkTransform* currentmatrix;
+       vtkTransform* modeltransform;
+       vtkTransform* inversModel;
+
+
+       CutModel2Figure* getCurentCuttingModel();
+
+       vtkTransform* getModelTransform(vtkImageData* copyimage);
+       vtkTransform* getModelTransformInvers();
+};
+
+#endif 
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModel2Exception.cxx b/lib/maracasVisuLib/src/CutModule/kernel/CutModel2Exception.cxx
new file mode 100644 (file)
index 0000000..b77dcab
--- /dev/null
@@ -0,0 +1,31 @@
+/*=========================================================================
+
+  Program:   wxMaracas
+  Module:    $RCSfile: CutModel2Exception.cxx,v $
+  Language:  C++
+  Date:      $Date: 2009/11/19 15:00:33 $
+  Version:   $Revision: 1.1 $
+
+  Copyright: (c) 2002, 2003
+  License:
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+#include "CutModel2Exception.h"
+
+/**
+**     Start of the manager class
+**/
+CutModel2Exception::CutModel2Exception(std::string cause)
+:std::exception(){
+    _cause = cause;    
+}
+CutModel2Exception::~CutModel2Exception()throw(){
+}
+
+
+
+
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModel2Exception.h b/lib/maracasVisuLib/src/CutModule/kernel/CutModel2Exception.h
new file mode 100644 (file)
index 0000000..cf3ae14
--- /dev/null
@@ -0,0 +1,44 @@
+/*=========================================================================
+
+  Program:   wxMaracas
+  Module:    $RCSfile: CutModel2Exception.h,v $
+  Language:  C++
+  Date:      $Date: 2009/11/19 15:00:33 $
+  Version:   $Revision: 1.1 $
+
+  Copyright: (c) 2002, 2003
+  License:
+  
+     This software is distributed WITHOUT ANY WARRANTY; without even 
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+
+
+
+
+#ifndef __CutModel2ExceptionH__
+#define __CutModel2ExceptionH__
+
+#include <iostream>
+#include <vector>
+
+
+class CutModel2Exception  : public std::exception{
+
+public:
+       CutModel2Exception(std::string cause);
+       ~CutModel2Exception() throw();
+
+       std::string getCause(){
+               return _cause;
+       }
+       
+private:       
+       
+       std::string _cause;
+       
+};
+
+#endif 
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModel2Figure.cxx__ b/lib/maracasVisuLib/src/CutModule/kernel/CutModel2Figure.cxx__
new file mode 100644 (file)
index 0000000..6be77f5
--- /dev/null
@@ -0,0 +1,152 @@
+
+#include "CutModelFigure.h"
+
+//----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+CutModelFigure::CutModelFigure()
+{
+       _inversModel    = vtkTransform::New();
+       _matrixModel    = vtkTransform::New();
+       _matrixVisual   = vtkTransform::New();
+
+       _spcX=1;
+       _spcY=1;
+       _spcZ=1;
+}
+//----------------------------------------------------------------------------
+CutModelFigure::~CutModelFigure() // virtual
+{
+       _inversModel->Delete();
+}
+//----------------------------------------------------------------------------
+void CutModelFigure::SetPosition(double x,double y, double z)
+{
+       _px=x;
+       _py=y;
+       _pz=z;
+}
+//----------------------------------------------------------------------------
+void CutModelFigure::SetScale(double sx,double sy, double sz)
+{
+       _sx=sx;
+       _sy=sy;
+       _sz=sz;
+}
+//----------------------------------------------------------------------------
+void CutModelFigure::SetRotation(double alfa,double beta, double teta)
+{
+       _alfa=alfa;
+       _beta=beta;
+       _teta=teta;
+}
+
+//----------------------------------------------------------------------------
+void CutModelFigure::CalculeMatrix()
+{
+       _matrixModel->Identity();
+       _matrixModel->Translate(_px,_py,_pz);
+       _matrixModel->RotateY(_beta);
+       _matrixModel->RotateX(_alfa);
+       _matrixModel->RotateY(_teta);
+       _matrixModel->Scale(_sx,_sy,_sz);
+
+       _matrixVisual->Identity();
+       _matrixVisual->Translate( _px*_spcX  ,  _py*_spcY  ,  _pz*_spcZ  );
+       _matrixVisual->RotateY(_beta);
+       _matrixVisual->RotateX(_alfa);
+       _matrixVisual->RotateY(_teta);
+       _matrixVisual->Scale( _sx*_spcX  ,  _sy*_spcY  ,  _sz*_spcZ  );
+
+}
+
+
+//----------------------------------------------------------------------------
+void CutModelFigure::CalculeInversMatrix()
+{
+       _inversModel->Identity ();
+       _inversModel->Concatenate ( _matrixModel );
+       _inversModel->Inverse();
+}
+//----------------------------------------------------------------------------
+bool CutModelFigure::IfPointInside(double x, double y, double z) // virtual
+{
+       return true;
+}
+
+//----------------------------------------------------------------------------
+vtkTransform *CutModelFigure::GetVtkTransform()
+{
+       return _matrixVisual;
+}
+
+//----------------------------------------------------------------------------
+//void CutModelFigure::SetVtkTransform(vtkTransform *matrix)
+//{
+//     _matrixModel = matrix;
+//}
+
+//----------------------------------------------------------------------------
+double CutModelFigure::GetTheoricVolume() // virtual
+{
+       return 0;
+}
+
+//----------------------------------------------------------------------------
+double CutModelFigure::GetPositionX()
+{
+       return _px;
+}
+//----------------------------------------------------------------------------
+double CutModelFigure::GetPositionY()
+{
+       return _py;
+}
+//----------------------------------------------------------------------------
+double CutModelFigure::GetPositionZ()
+{
+       return _pz;
+}
+//----------------------------------------------------------------------------
+double CutModelFigure::GetScaleX()
+{
+       return _sx;
+}
+//----------------------------------------------------------------------------
+double CutModelFigure::GetScaleY()
+{
+       return _sy;
+}
+//----------------------------------------------------------------------------
+double CutModelFigure::GetScaleZ()
+{
+       return _sz;
+}
+//----------------------------------------------------------------------------
+double CutModelFigure::GetAngleAlfa()
+{
+       return _alfa;
+}
+//----------------------------------------------------------------------------
+double CutModelFigure::GetAngleBeta()
+{
+       return _beta;
+}
+//----------------------------------------------------------------------------
+double CutModelFigure::GetAngleTeta()
+{
+       return _teta;
+}
+//----------------------------------------------------------------------------
+char *CutModelFigure::GetName() // virtual
+{
+       return "--";
+}
+
+//----------------------------------------------------------------------------
+void CutModelFigure::SetSpacing(double spcX,double spcY, double spcZ)
+{
+       _spcX = spcX;
+       _spcY = spcY;
+       _spcZ = spcZ;
+}
\ No newline at end of file
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModel2Figure.h b/lib/maracasVisuLib/src/CutModule/kernel/CutModel2Figure.h
new file mode 100644 (file)
index 0000000..82c5b8f
--- /dev/null
@@ -0,0 +1,83 @@
+#ifndef FIGURECUTTINGMODEL_H_
+#define FIGURECUTTINGMODEL_H_
+
+#include "vtkTransform.h"
+#include "vtkPolyData.h"
+
+class CutModel2Figure
+{
+public:
+       CutModel2Figure(){}     
+       
+       //~CutModel2Figure();
+
+       virtual void SetPosition(double x,double y, double z){
+               _px = x;
+               _py = y;
+               _pz = z;
+       }
+
+       virtual void    SetScale(double sx,double sy, double sz){
+               _sx = sx;
+               _sy = sy;
+               _sz = sz;
+       }
+
+       virtual void    SetRotation(double alfa,double beta, double teta){
+        _alfa = alfa;
+               _beta = beta;
+               _teta = teta;
+       }
+
+       virtual void    SetSpacing(double spcX,double spcY, double spcZ){
+               _spcX = spcX;
+               _spcY = spcY;
+               _spcZ = spcZ;
+       }               
+
+       virtual void SetVtkTransform(vtkTransform *transform){
+               double *orient = transform->GetOrientation();
+               _alfa = orient[0];
+               _beta = orient[1];
+               _teta = orient[2];
+
+               double *scale = transform->GetScale();
+               _sx = scale[0];
+               _sy = scale[1];
+               _sz = scale[2];
+
+               double *position = transform->GetPosition();
+               _px = position[0];
+               _py = position[1];
+               _pz = position[2];
+
+
+       }
+       virtual void SetInversVtkTransform(vtkTransform *inverstransform){
+               _inversModel = inverstransform;
+       }
+
+       virtual bool IfPointInside(double x, double y, double z) = 0;
+       virtual double  GetTheoricVolume()=0;   
+       virtual vtkPolyData* getPolyData()=0;
+
+private:
+       double                  _px;
+       double                  _py;
+       double                  _pz;
+       double                  _alfa;
+       double                  _beta;
+       double                  _teta;
+       double                  _spcX;
+       double                  _spcY;
+       double                  _spcZ;
+       char *GetName;
+protected:
+       double                  _sx;
+       double                  _sy;
+       double                  _sz;
+       vtkTransform    *_inversModel;
+       vtkTransform    *_matrixModel;  
+};
+
+#endif /*FIGURECUTTINGMODEL_H_*/
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModel2FigureCube.cxx b/lib/maracasVisuLib/src/CutModule/kernel/CutModel2FigureCube.cxx
new file mode 100644 (file)
index 0000000..53aa395
--- /dev/null
@@ -0,0 +1,52 @@
+
+#include "CutModel2FigureCube.h"
+
+//----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+CutModel2FigureCube::CutModel2FigureCube()
+: CutModel2Figure()
+{
+       _vtkcube = vtkCubeSource::New();
+       _vtkcube->SetXLength (1);
+       _vtkcube->SetYLength (1);
+       _vtkcube->SetZLength (1);
+}
+//----------------------------------------------------------------------------
+CutModel2FigureCube::~CutModel2FigureCube()  // virtual
+{
+       _vtkcube->Delete();
+}
+//----------------------------------------------------------------------------
+bool CutModel2FigureCube::IfPointInside(double x, double y, double z) // virtual
+{
+       double in[4],out[4];
+       in[0]=x;
+       in[1]=y;
+       in[2]=z;
+       in[3]=1;
+       _inversModel->MultiplyPoint (in, out);
+
+       bool result=false;
+       if ((out[0]>-0.5) && (out[0]<0.5) && (out[1]>-0.5) && (out[1]<0.5)  && (out[2]>-0.5) && (out[2]<0.5)  )
+       {
+               result=true;
+       }
+       return result;
+}
+//----------------------------------------------------------------------------
+double CutModel2FigureCube::GetTheoricVolume() // virtual
+{
+       return _sx * _sy * _sz;
+}
+
+//----------------------------------------------------------------------------
+char *CutModel2FigureCube::GetName() // virtual
+{
+       return "Cube";
+}
+
+vtkPolyData* CutModel2FigureCube::getPolyData(){
+    return _vtkcube->GetOutput();
+}
+
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModel2FigureCube.h b/lib/maracasVisuLib/src/CutModule/kernel/CutModel2FigureCube.h
new file mode 100644 (file)
index 0000000..8f23fc8
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef CutModel2FigureCube_H_
+#define CutModel2FigureCube_H_
+
+#include "CutModel2Figure.h"
+#include "vtkCubeSource.h"
+
+class CutModel2FigureCube : public CutModel2Figure
+{
+public:
+       CutModel2FigureCube();
+       virtual ~CutModel2FigureCube();
+       virtual bool    IfPointInside(double x, double y, double z);
+       virtual double  GetTheoricVolume();             
+       virtual vtkPolyData* getPolyData();
+       virtual char *GetName();
+private:
+       vtkCubeSource* _vtkcube;
+protected:
+};
+
+#endif /*FIGURECUTTINGCUBEMODEL_H_*/
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModel2FigureCylinder.cxx b/lib/maracasVisuLib/src/CutModule/kernel/CutModel2FigureCylinder.cxx
new file mode 100644 (file)
index 0000000..21a746c
--- /dev/null
@@ -0,0 +1,45 @@
+
+#include "CutModel2FigureCylinder.h"
+
+CutModel2FigureCylinder::CutModel2FigureCylinder()
+{
+       _vtkcylinder    = vtkCylinderSource::New();
+       _vtkcylinder->SetResolution(20);
+}
+//----------------------------------------------------------------------------
+CutModel2FigureCylinder::~CutModel2FigureCylinder()  // virtual
+{
+       _vtkcylinder->Delete();
+}
+//----------------------------------------------------------------------------
+bool CutModel2FigureCylinder::IfPointInside(double x, double y, double z) // virtual
+{
+       double in[4],out[4];
+       in[0]=x;
+       in[1]=y;
+       in[2]=z;
+       in[3]=1;
+       _inversModel->MultiplyPoint (in, out);
+
+       bool result=false;
+       if ((sqrt( out[0]*out[0] + out[2]*out[2] )<0.5 )  && (out[1]>-0.5) && (out[1]<0.5)  )
+       {
+               result=true;
+       }
+       return result;
+}
+//----------------------------------------------------------------------------
+double CutModel2FigureCylinder::GetTheoricVolume() // virtual
+{
+       double piTMP=3.14159265;
+       return piTMP*(_sx/2)*(_sz/2)*_sy;
+}
+//----------------------------------------------------------------------------
+char *CutModel2FigureCylinder::GetName() // virtual
+{
+       return "Cylinder";
+}
+vtkPolyData* CutModel2FigureCylinder::getPolyData(){
+       return _vtkcylinder->GetOutput();
+}
+//----------------------------------------------------------------------------
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModel2FigureCylinder.h b/lib/maracasVisuLib/src/CutModule/kernel/CutModel2FigureCylinder.h
new file mode 100644 (file)
index 0000000..2468984
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef CutModel2FigureCylinder_H_
+#define CutModel2FigureCylinder_H_
+
+#include "CutModel2Figure.h"
+#include "vtkCylinderSource.h"
+
+class CutModel2FigureCylinder : public CutModel2Figure
+{
+public:
+       CutModel2FigureCylinder();
+       virtual ~CutModel2FigureCylinder();
+       virtual bool    IfPointInside(double x, double y, double z);
+       virtual double  GetTheoricVolume();
+       virtual vtkPolyData* getPolyData();
+       virtual char *GetName();
+       
+private:
+       vtkCylinderSource* _vtkcylinder;
+protected:
+};
+
+#endif /*FIGURECUTTINGCYLINDERMODEL_H_*/
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModel2FigureSphere.cxx b/lib/maracasVisuLib/src/CutModule/kernel/CutModel2FigureSphere.cxx
new file mode 100644 (file)
index 0000000..19d21de
--- /dev/null
@@ -0,0 +1,49 @@
+#include "CutModel2FigureSphere.h"
+
+//----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+CutModel2FigureSphere::CutModel2FigureSphere()
+{
+       _vtksphere              = vtkSphereSource::New();
+       _vtksphere->SetThetaResolution (20);
+       _vtksphere->SetPhiResolution (20);
+}
+//----------------------------------------------------------------------------
+CutModel2FigureSphere::~CutModel2FigureSphere() // virtual
+{
+       _vtksphere->Delete();
+}
+//----------------------------------------------------------------------------
+bool CutModel2FigureSphere::IfPointInside(double x, double y, double z) // virtual
+{
+       double in[4],out[4];
+       in[0]=x;
+       in[1]=y;
+       in[2]=z;
+       in[3]=1;
+       _inversModel->MultiplyPoint (in, out);
+
+       bool result=false;
+       if (sqrt( out[0]*out[0] + out[1]*out[1] + out[2]*out[2] )<0.5 )
+       {
+               result=true;
+       }
+       return result;
+}
+//----------------------------------------------------------------------------
+double CutModel2FigureSphere::GetTheoricVolume() // virtual
+{
+       double piTMP=3.14159265;
+       return (4.0/3.0) * piTMP * (_sx/2)*(_sy/2)*(_sz/2);
+}
+//----------------------------------------------------------------------------
+char *CutModel2FigureSphere::GetName() // virtual
+{
+       return "Sphere";
+}
+
+vtkPolyData* CutModel2FigureSphere::getPolyData(){
+       return _vtksphere->GetOutput();
+}
+
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModel2FigureSphere.h b/lib/maracasVisuLib/src/CutModule/kernel/CutModel2FigureSphere.h
new file mode 100644 (file)
index 0000000..f6cdff9
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef CutModel2FigureSphere_H_
+#define CutModel2FigureSphere_H_
+
+#include "CutModel2Figure.h"
+#include "vtkSphereSource.h"
+
+class CutModel2FigureSphere : public CutModel2Figure
+{
+public:
+       CutModel2FigureSphere();
+       virtual ~CutModel2FigureSphere();
+       virtual bool IfPointInside(double x, double y, double z);
+       virtual double  GetTheoricVolume();
+       virtual char *GetName();
+       virtual vtkPolyData* getPolyData();
+private:
+       vtkSphereSource* _vtksphere;
+protected:
+};
+
+#endif /*FIGURECUTTINGSPHEREMODEL_H_*/
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModel2Manager.cxx b/lib/maracasVisuLib/src/CutModule/kernel/CutModel2Manager.cxx
new file mode 100644 (file)
index 0000000..e472bec
--- /dev/null
@@ -0,0 +1,280 @@
+/*=========================================================================
+
+  Program:   wxMaracas
+  Module:    $RCSfile: CutModel2Manager.cxx,v $
+  Language:  C++
+  Date:      $Date: 2009/11/19 15:00:33 $
+  Version:   $Revision: 1.1 $
+
+  Copyright: (c) 2002, 2003
+  License:
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+#include "CutModel2Manager.h"
+
+/**
+**     Start of the manager class
+**/
+CutModel2Manager::CutModel2Manager(std::string path){
+       _path = path;
+       _img = NULL;
+       _copyimg = NULL;
+       _interactor = NULL;     
+       _render = NULL;
+       _currentaction=0;
+}
+CutModel2Manager::~CutModel2Manager(){
+       std::string files = _path;
+    files+="/infounrd_0_fig_0.info";   
+       remove(files.c_str());
+}
+
+
+void CutModel2Manager::setImageData(vtkImageData* img){
+    _img = img;
+       if(_copyimg!=NULL){
+               _copyimg->Delete();
+       }
+       _copyimg = vtkImageData::New();
+       _copyimg->SetExtent(_img->GetExtent());
+       _copyimg->SetSpacing(_img->GetSpacing());
+       _copyimg->AllocateScalars();
+
+       _copyimg->DeepCopy(_img);
+
+}
+
+void CutModel2Manager::setInteractor(vtkRenderWindowInteractor* interactor){
+       _interactor = interactor;
+}
+
+void CutModel2Manager::setRenderer(vtkRenderer* renderer){
+       _render = renderer;
+}
+
+void CutModel2Manager::onAddCutModel2(int id, vtkCommand* observer) throw( CutModel2Exception){
+       checkInvariant();
+
+       CutModel2Data* data = new CutModel2Data(id,_interactor, observer, _copyimg);
+       _vectordata.push_back(data);
+
+       _render->AddActor(data->getActor());
+
+       //_render->UpdateCamera();
+       _render->Render();
+}
+
+void CutModel2Manager::checkInvariant() throw( CutModel2Exception){
+       if(_img==NULL){
+               throw CutModel2Exception("The image is not set");
+       }
+       if(_copyimg==NULL){
+               throw CutModel2Exception("The image is not set");
+       }
+       if(_interactor==NULL){
+               throw CutModel2Exception("Interactor not set");
+       }
+       if(_render==NULL){
+               throw CutModel2Exception("Render not set");
+       }
+}
+
+double* CutModel2Manager::getImageRange()throw( CutModel2Exception){
+       checkInvariant();
+       return _copyimg->GetScalarRange();
+}
+
+void CutModel2Manager::changeOpacity(int id,int opacity)throw( CutModel2Exception){
+       checkInvariant();
+       CutModel2Data* current = getCutModel2Data(id);
+       current->changeOpacity(opacity);
+}
+
+void CutModel2Manager::ShowViewBox(int id,bool check)throw( CutModel2Exception){
+       checkInvariant();
+       CutModel2Data* current = getCutModel2Data(id);
+       current->ShowViewBox(check);
+}
+
+void CutModel2Manager::ChangeShape(int id,int selection)throw( CutModel2Exception){
+       checkInvariant();
+       CutModel2Data* current = getCutModel2Data(id);
+       current->ChangeShape(selection);                        
+       _render->Render();
+}
+
+CutModel2Data* CutModel2Manager::getCutModel2Data(int id)throw( CutModel2Exception){
+
+       CutModel2Data* current = NULL;
+       for(int i= 0; i < _vectordata.size();i++){
+               std::cout<<"id in CutModel2Manager:: "<<id<<std::endl;
+               std::cout<<"vectordataid in CutModel2Manager:: "<<_vectordata[i]->getId()<<std::endl;
+
+               if(_vectordata[i]->getId()==id){
+                       current =  _vectordata[i];
+               }
+       }
+       if(current ==NULL){
+               
+               throw CutModel2Exception("Data not found");
+       }
+       return current;
+}
+
+void CutModel2Manager::updateActorDirection(int id)throw( CutModel2Exception){
+       checkInvariant();
+       CutModel2Data* current = getCutModel2Data(id);
+       current->udapteActorDirection();
+       
+}
+
+void CutModel2Manager::changeColor(int id,double r,double g,double b)throw( CutModel2Exception){
+
+       checkInvariant();
+       CutModel2Data* current = getCutModel2Data(id);
+       current->changeColor(r,g,b);
+       _render->Render();
+}
+void CutModel2Manager::RemoveActor(int id)throw( CutModel2Exception){
+       
+               checkInvariant();
+
+               CutModel2Data* current = getCutModel2Data(id);
+               for(int i = 0; i < _vectordata.size()-1;i++){
+                       if(_vectordata[i]->getId()==id){                                
+                               for(int j = i; j < _vectordata.size()-1;j++){
+                    _vectordata[j]=_vectordata[j+1];
+                               }
+                               i = _vectordata.size();
+                       }
+               }
+               _render->RemoveActor(current->getActor());              
+               delete current;
+               _vectordata.pop_back();
+               _render->Render();
+       
+}
+
+void CutModel2Manager::ExecuteCut(int id, double* range, bool isinside)throw( CutModel2Exception){
+    checkInvariant();
+               
+       CutModel2Data* current = getCutModel2Data(id);
+       current->ExecuteCut(range, isinside, _img);
+
+
+       /*
+       Setting extra information for the undo
+       */
+       CutModel2SaveBinInfo* undoaction = this->AddActionUndo(id, CUTMODEL2_CUT);
+       undoaction->setRange(range);
+       undoaction->setIsInside(isinside);
+
+}
+
+vtkImageData* CutModel2Manager::GetResultImage(){
+        checkInvariant();
+     return _copyimg;
+}
+
+void CutModel2Manager::RefreshActor(int id){
+     checkInvariant();
+       CutModel2Data* current = getCutModel2Data(id);  
+       _render->RemoveActor(current->getActor());
+       _render->AddActor(current->getActor()); 
+       current->RefreshViewBox();
+       _render->Render();
+}
+
+void CutModel2Manager::SaveCutModel2Data(std::string filename)throw( CutModel2Exception){      
+
+       
+       throw CutModel2Exception("not implemented");
+       
+       
+       
+       
+}
+
+
+
+void CutModel2Manager::LoadCutModel2Data(std::string filename)throw( CutModel2Exception){
+       
+       throw CutModel2Exception("not implemented");
+       
+}
+
+CutModel2SaveBinInfo* CutModel2Manager::AddActionUndo(int idc, UNDOTYPE type)throw( CutModel2Exception){
+       
+       for(int i = _undoredo.size()-1; i > _currentaction;i--){
+               delete _undoredo[i];
+               _undoredo.pop_back();           
+       }
+
+       CutModel2SaveBinInfo* cutmodel = new CutModel2SaveBinInfo(idc, _currentaction, type, _path);
+       if(type == CUTMODEL2_CUT){
+               cutmodel->saveMatrix4x4(this->getCutModel2Data(idc)->getCurrentMatrix()->GetMatrix());
+               cutmodel->setCurrentShape(this->getCutModel2Data(idc)->getCurrentShape());
+       }
+
+       _undoredo.push_back(cutmodel);
+
+       _currentaction++;// = _undoredo.size();
+       //std::cout<<"current index "<<_currentaction;
+               
+       return cutmodel;
+}
+
+int CutModel2Manager::Undo()   throw( CutModel2Exception){
+ //&& _currentaction < _undoredo.size()
+       if(_currentaction > 0){
+               int tempaction = _currentaction-1;
+               CutModel2SaveBinInfo* currentundo = _undoredo[tempaction];
+               CutModel2Data* currentmodel;
+
+               if(currentundo->getActionType()==CUTMODEL2_CUT){
+                       //Undo the cut
+                       vtkTransform* transform = currentundo->getTransformFromMatrixFile();
+
+                       currentmodel = getCutModel2Data(currentundo->getId());
+
+                       currentmodel->setTransform(transform, _img);
+
+                       currentmodel->setCurrentShape(currentundo->getCurrentShape());
+
+                       currentmodel->ExecuteUnCut(currentundo->getIsInside(), _copyimg, _img);
+
+               }
+               //Every thing ok
+               _currentaction--;
+               return 0;
+       }
+       return -1;
+}
+
+int CutModel2Manager::Redo()   throw( CutModel2Exception){
+
+       if(_currentaction >= 0 && _currentaction < _undoredo.size()){
+               
+
+               CutModel2SaveBinInfo* currentundo = _undoredo[_currentaction];
+               CutModel2Data* currentmodel;
+
+               if(currentundo->getActionType()==CUTMODEL2_CUT){
+                       //Redo the cut
+                       vtkTransform* transform = currentundo->getTransformFromMatrixFile();
+                       currentmodel = getCutModel2Data(currentundo->getId());
+                       currentmodel->setTransform(transform, _copyimg);
+                       currentmodel->setCurrentShape(currentundo->getCurrentShape());
+                       currentmodel->ExecuteCut(currentundo->getRange(), currentundo->getIsInside(), _copyimg);
+               }
+
+               _currentaction++;
+
+               return 0;
+       }
+       return -1;
+}
\ No newline at end of file
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModel2Manager.h b/lib/maracasVisuLib/src/CutModule/kernel/CutModel2Manager.h
new file mode 100644 (file)
index 0000000..e5c3f63
--- /dev/null
@@ -0,0 +1,99 @@
+/*=========================================================================
+
+  Program:   wxMaracas
+  Module:    $RCSfile: CutModel2Manager.h,v $
+  Language:  C++
+  Date:      $Date: 2009/11/19 15:00:33 $
+  Version:   $Revision: 1.1 $
+
+  Copyright: (c) 2002, 2003
+  License:
+  
+     This software is distributed WITHOUT ANY WARRANTY; without even 
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+
+
+
+
+#ifndef __CutModel2ManagerH__
+#define __CutModel2ManagerH__
+
+#include <iostream>
+#include <stdio.h>
+#include <vector>
+
+#include "vtkImageData.h"
+#include "vtkRenderWindowInteractor.h"
+#include "vtkRenderer.h"
+#include <vtkPolyDataWriter.h>
+
+#include "CutModel2Exception.h"
+#include "CutModel2Data.h"
+#include "CutModel2SaveBinInfo.h"
+
+
+
+class CutModel2Manager  {
+
+public:
+       CutModel2Manager(std::string path);
+       ~CutModel2Manager();
+
+       void setImageData(vtkImageData* img);
+
+       void setInteractor(vtkRenderWindowInteractor* interactor);
+
+       void setRenderer(vtkRenderer* renderer);
+       
+       void onAddCutModel2(int id, vtkCommand* observer) throw( CutModel2Exception);
+
+       double* getImageRange()throw( CutModel2Exception);
+
+       void changeOpacity(int id,int opacity)throw( CutModel2Exception);
+
+       void ShowViewBox(int id,bool check)throw( CutModel2Exception);
+
+       void ChangeShape(int id,int selection)throw( CutModel2Exception);
+
+       void changeColor(int id,double r,double g,double b)throw( CutModel2Exception);
+
+       void updateActorDirection(int id)throw( CutModel2Exception);
+
+       void RemoveActor(int id)throw( CutModel2Exception);
+
+       void ExecuteCut(int id, double* range, bool isinside)throw( CutModel2Exception);
+
+       vtkImageData* GetResultImage();
+
+       void RefreshActor(int id);
+
+       void SaveCutModel2Data(std::string filename)throw( CutModel2Exception);
+
+       void LoadCutModel2Data(std::string filename)throw( CutModel2Exception);
+
+       CutModel2SaveBinInfo* AddActionUndo(int id, UNDOTYPE type)throw( CutModel2Exception);
+
+       int Undo()throw( CutModel2Exception);
+
+       int Redo()throw( CutModel2Exception);
+private:
+       
+       int _currentaction;
+
+       void checkInvariant() throw( CutModel2Exception);
+       std::string _path;
+       vtkImageData* _img;
+       vtkImageData* _copyimg;
+       vtkRenderer* _render;
+       vtkRenderWindowInteractor* _interactor;
+
+       std::vector<CutModel2Data*> _vectordata;
+       std::vector<CutModel2SaveBinInfo*> _undoredo;
+       CutModel2Data* getCutModel2Data(int id)throw( CutModel2Exception);
+       
+};
+
+#endif 
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModel2SaveBinInfo.cxx b/lib/maracasVisuLib/src/CutModule/kernel/CutModel2SaveBinInfo.cxx
new file mode 100644 (file)
index 0000000..a5ce4cb
--- /dev/null
@@ -0,0 +1,112 @@
+/*=========================================================================
+
+  Program:   wxMaracas
+  Module:    $RCSfile: CutModel2SaveBinInfo.cxx,v $
+  Language:  C++
+  Date:      $Date: 2009/11/19 15:00:33 $
+  Version:   $Revision: 1.1 $
+
+  Copyright: (c) 2002, 2003
+  License:
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+#include "CutModel2SaveBinInfo.h"
+
+/**
+**     Start of the manager class
+**/
+CutModel2SaveBinInfo::CutModel2SaveBinInfo(int id, int currentaction, UNDOTYPE actiontype, std::string path){
+
+       _id = id;
+
+       char c[100];
+       sprintf(c,"/infounrd_%d_fig_%d.info",currentaction,id);
+
+       _stdFilename = path;    
+    _stdFilename+=c;
+       _stdFilename+=".poly";
+
+       _matrixFilename = path; 
+       _matrixFilename+=c;
+       _actiontype = actiontype;       
+
+       
+}
+CutModel2SaveBinInfo::~CutModel2SaveBinInfo(){
+       
+}
+void CutModel2SaveBinInfo::savePolyData(vtkPolyData* polydata){
+       vtkPolyDataWriter * writer = vtkPolyDataWriter ::New();
+       writer->SetFileName(_stdFilename.c_str());      
+       writer->SetInput(polydata);
+       writer->SetFileTypeToBinary();
+       writer->Write();
+       writer->Delete();
+}
+
+vtkTransform* CutModel2SaveBinInfo::getPolyDataTransform()throw( CutModel2Exception){
+       vtkPolyDataReader* reader = vtkPolyDataReader::New();
+       //std::cout<<"filename vtkTransform* CutModel2SaveBinInfo::getPolyDataTransform()"<<this->getSTDFileName()<<std::endl;
+       reader->SetFileName(this->getSTDFileName().c_str());
+       vtkPolyData* poly = reader->GetOutput();
+
+       vtkPolyDataMapper* mapper       = vtkPolyDataMapper::New();     
+       mapper->SetInput(poly);
+       vtkActor* actor = vtkActor::New();
+       actor->SetMapper(mapper);
+       vtkMatrix4x4* actmatrix = actor->GetMatrix();
+
+       std::cout<<"tkTransform* CutModel2SaveBinInfo::getPolyDataTransform() Actor "<<actor<<std::endl;
+       std::cout<<"tkTransform* CutModel2SaveBinInfo::getPolyDataTransform() Actor Matrix "<<actmatrix<<std::endl;
+
+       mapper->Update();
+
+       vtkTransform* transform = vtkTransform::New();
+
+       transform->Identity();
+
+       transform->GetMatrix()->SetElement(0,0,actmatrix->GetElement(0,0));
+       transform->GetMatrix()->SetElement(1,0,actmatrix->GetElement(1,0));
+       transform->GetMatrix()->SetElement(2,0,actmatrix->GetElement(2,0));
+       transform->GetMatrix()->SetElement(0,1,actmatrix->GetElement(0,1));
+       transform->GetMatrix()->SetElement(1,1,actmatrix->GetElement(1,1));
+       transform->GetMatrix()->SetElement(2,1,actmatrix->GetElement(2,1));
+       transform->GetMatrix()->SetElement(0,2,actmatrix->GetElement(0,2));
+       transform->GetMatrix()->SetElement(1,2,actmatrix->GetElement(1,2));
+       transform->GetMatrix()->SetElement(2,2,actmatrix->GetElement(2,2));             
+       transform->GetMatrix()->SetElement(0,3,actmatrix->GetElement(0,3));
+       transform->GetMatrix()->SetElement(1,3,actmatrix->GetElement(1,3));
+       transform->GetMatrix()->SetElement(2,3,actmatrix->GetElement(2,3));
+
+       actor->Delete();
+       mapper->Delete();
+       reader->Delete();
+       //poly->Delete();
+       
+
+       return transform;
+       
+}
+
+
+void CutModel2SaveBinInfo::saveMatrix4x4(vtkMatrix4x4* matrix){
+       fstream binary_file(_matrixFilename.c_str(),ios::out|ios::binary);
+       binary_file.write(reinterpret_cast<char *>(matrix),sizeof(vtkMatrix4x4));
+       binary_file.close();
+}
+vtkTransform* CutModel2SaveBinInfo::getTransformFromMatrixFile()throw( CutModel2Exception){
+       vtkMatrix4x4* matrix = vtkMatrix4x4::New();
+       fstream binary_file(_matrixFilename.c_str(),ios::binary|ios::in);
+       binary_file.read(reinterpret_cast<char *>(matrix),sizeof(vtkMatrix4x4));
+       binary_file.close();
+
+       vtkTransform* transform = vtkTransform::New();
+       transform->SetMatrix(matrix);
+
+       return transform;
+}
+
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModel2SaveBinInfo.h b/lib/maracasVisuLib/src/CutModule/kernel/CutModel2SaveBinInfo.h
new file mode 100644 (file)
index 0000000..06283ed
--- /dev/null
@@ -0,0 +1,111 @@
+/*=========================================================================
+
+  Program:   wxMaracas
+  Module:    $RCSfile: CutModel2SaveBinInfo.h,v $
+  Language:  C++
+  Date:      $Date: 2009/11/19 15:00:33 $
+  Version:   $Revision: 1.1 $
+
+  Copyright: (c) 2002, 2003
+  License:
+  
+     This software is distributed WITHOUT ANY WARRANTY; without even 
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+
+
+
+
+#ifndef __CutModel2SaveBinInfoH__
+#define __CutModel2SaveBinInfoH__
+
+#include <iostream>
+#include <vector>
+#include "CutModel2Exception.h"
+
+#include <vtkPolyData.h>
+#include <vtkPolyDataWriter.h>
+#include <vtkPolyDataReader.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkTransform.h>
+#include <vtkMatrix4x4.h>
+#include <vtkActor.h>
+
+enum UNDOTYPE
+{
+    CUTMODEL2_ADD = 0, 
+       CUTMODEL2_REMOVE = 10,
+       CUTMODEL2_CUT= 20,
+       
+};
+
+class CutModel2SaveBinInfo  {
+
+public:
+       
+       CutModel2SaveBinInfo(int id, int currentaction,UNDOTYPE actiontype, std::string path);
+       ~CutModel2SaveBinInfo();
+
+       int getId(){
+               return _id;
+       }       
+
+       UNDOTYPE getActionType(){
+               return _actiontype;
+       }
+       std::string getSTDFileName()throw( CutModel2Exception){
+               if(_stdFilename==""){
+                       throw new CutModel2Exception("Filename undoredo does not exists");
+               }
+               return _stdFilename;
+       }
+
+       /*void setSTDFileName(std::string filename){
+               _stdFilename = filename;
+       }*/
+
+       int getCurrentShape(){
+               return _currentshape;
+       }
+
+       void setCurrentShape(int currentshape){
+               _currentshape=currentshape;
+       }
+
+       void savePolyData(vtkPolyData* polydata);
+
+       vtkTransform* getPolyDataTransform()throw( CutModel2Exception); 
+
+       void saveMatrix4x4(vtkMatrix4x4* matrix);
+       vtkTransform* getTransformFromMatrixFile()throw( CutModel2Exception);
+
+       void setRange(double* range){
+               _range = range;
+       }
+       void setIsInside(bool isinside){
+               _isinside = isinside;
+       }
+
+       double* getRange(){
+               return _range;
+       }
+       bool getIsInside(){
+               return _isinside;
+       }
+       
+private:               
+       
+       int _id;
+       UNDOTYPE _actiontype;
+       int _currentshape;
+       double* _range;
+       bool _isinside;
+       std::string _stdFilename;               
+       std::string _matrixFilename;    
+};
+
+
+
+#endif 
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModelManager2.cxx b/lib/maracasVisuLib/src/CutModule/kernel/CutModelManager2.cxx
new file mode 100644 (file)
index 0000000..97e02a3
--- /dev/null
@@ -0,0 +1,280 @@
+/*=========================================================================
+
+  Program:   wxMaracas
+  Module:    $RCSfile: CutModelManager2.cxx,v $
+  Language:  C++
+  Date:      $Date: 2009/11/19 15:01:30 $
+  Version:   $Revision: 1.1 $
+
+  Copyright: (c) 2002, 2003
+  License:
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+#include "CutModelManager.h"
+
+/**
+**     Start of the manager class
+**/
+CutModelManager::CutModelManager(std::string path){
+       _path = path;
+       _img = NULL;
+       _copyimg = NULL;
+       _interactor = NULL;     
+       _render = NULL;
+       _currentaction=0;
+}
+CutModelManager::~CutModelManager(){
+       std::string files = _path;
+    files+="/infounrd_0_fig_0.info";   
+       remove(files.c_str());
+}
+
+
+void CutModelManager::setImageData(vtkImageData* img){
+    _img = img;
+       if(_copyimg!=NULL){
+               _copyimg->Delete();
+       }
+       _copyimg = vtkImageData::New();
+       _copyimg->SetExtent(_img->GetExtent());
+       _copyimg->SetSpacing(_img->GetSpacing());
+       _copyimg->AllocateScalars();
+
+       _copyimg->DeepCopy(_img);
+
+}
+
+void CutModelManager::setInteractor(vtkRenderWindowInteractor* interactor){
+       _interactor = interactor;
+}
+
+void CutModelManager::setRenderer(vtkRenderer* renderer){
+       _render = renderer;
+}
+
+void CutModelManager::onAddCutModel(int id, vtkCommand* observer) throw( CutModelException){
+       checkInvariant();
+
+       CutModelData* data = new CutModelData(id,_interactor, observer, _img);
+       _vectordata.push_back(data);
+
+       _render->AddActor(data->getActor());
+
+       //_render->UpdateCamera();
+       _render->Render();
+}
+
+void CutModelManager::checkInvariant() throw( CutModelException){
+       if(_img==NULL){
+               throw CutModelException("The image is not set");
+       }
+       if(_copyimg==NULL){
+               throw CutModelException("The image is not set");
+       }
+       if(_interactor==NULL){
+               throw CutModelException("Interactor not set");
+       }
+       if(_render==NULL){
+               throw CutModelException("Render not set");
+       }
+}
+
+double* CutModelManager::getImageRange()throw( CutModelException){
+       checkInvariant();
+       return _img->GetScalarRange();
+}
+
+void CutModelManager::changeOpacity(int id,int opacity)throw( CutModelException){
+       checkInvariant();
+       CutModelData* current = getCutModelData(id);
+       current->changeOpacity(opacity);
+}
+
+void CutModelManager::ShowViewBox(int id,bool check)throw( CutModelException){
+       checkInvariant();
+       CutModelData* current = getCutModelData(id);
+       current->ShowViewBox(check);
+}
+
+void CutModelManager::ChangeShape(int id,int selection)throw( CutModelException){
+       checkInvariant();
+       CutModelData* current = getCutModelData(id);
+       current->ChangeShape(selection);                        
+       _render->Render();
+}
+
+CutModelData* CutModelManager::getCutModelData(int id)throw( CutModelException){
+
+       CutModelData* current = NULL;
+       for(int i= 0; i < _vectordata.size();i++){
+               std::cout<<"id in CutModelManager:: "<<id<<std::endl;
+               std::cout<<"vectordataid in CutModelManager:: "<<_vectordata[i]->getId()<<std::endl;
+
+               if(_vectordata[i]->getId()==id){
+                       current =  _vectordata[i];
+               }
+       }
+       if(current ==NULL){
+               
+               throw CutModelException("Data not found");
+       }
+       return current;
+}
+
+void CutModelManager::updateActorDirection(int id)throw( CutModelException){
+       checkInvariant();
+       CutModelData* current = getCutModelData(id);
+       current->udapteActorDirection();
+       
+}
+
+void CutModelManager::changeColor(int id,double r,double g,double b)throw( CutModelException){
+
+       checkInvariant();
+       CutModelData* current = getCutModelData(id);
+       current->changeColor(r,g,b);
+       _render->Render();
+}
+void CutModelManager::RemoveActor(int id)throw( CutModelException){
+       
+               checkInvariant();
+
+               CutModelData* current = getCutModelData(id);
+               for(int i = 0; i < _vectordata.size()-1;i++){
+                       if(_vectordata[i]->getId()==id){                                
+                               for(int j = i; j < _vectordata.size()-1;j++){
+                    _vectordata[j]=_vectordata[j+1];
+                               }
+                               i = _vectordata.size();
+                       }
+               }
+               _render->RemoveActor(current->getActor());              
+               delete current;
+               _vectordata.pop_back();
+               _render->Render();
+       
+}
+
+void CutModelManager::ExecuteCut(int id, double* range, bool isinside)throw( CutModelException){
+    checkInvariant();
+               
+       CutModelData* current = getCutModelData(id);
+       current->ExecuteCut(range, isinside, _img);
+
+
+       /*
+       Setting extra information for the undo
+       */
+       CutModelSaveBinInfo* undoaction = this->AddActionUndo(id, CUTMODEL_CUT);
+       undoaction->setRange(range);
+       undoaction->setIsInside(isinside);
+
+}
+
+vtkImageData* CutModelManager::GetResultImage(){
+        checkInvariant();
+     return _copyimg;
+}
+
+void CutModelManager::RefreshActor(int id){
+     checkInvariant();
+       CutModelData* current = getCutModelData(id);    
+       _render->RemoveActor(current->getActor());
+       _render->AddActor(current->getActor()); 
+       current->RefreshViewBox();
+       _render->Render();
+}
+
+void CutModelManager::SaveCutModelData(std::string filename)throw( CutModelException){ 
+
+       
+       throw CutModelException("not implemented");
+       
+       
+       
+       
+}
+
+
+
+void CutModelManager::LoadCutModelData(std::string filename)throw( CutModelException){
+       
+       throw CutModelException("not implemented");
+       
+}
+
+CutModelSaveBinInfo* CutModelManager::AddActionUndo(int idc, UNDOTYPE type)throw( CutModelException){
+       
+       for(int i = _undoredo.size()-1; i > _currentaction;i--){
+               delete _undoredo[i];
+               _undoredo.pop_back();           
+       }
+
+       CutModelSaveBinInfo* cutmodel = new CutModelSaveBinInfo(idc, _currentaction, type, _path);
+       if(type == CUTMODEL_CUT){
+               cutmodel->saveMatrix4x4(this->getCutModelData(idc)->getCurrentMatrix()->GetMatrix());
+               cutmodel->setCurrentShape(this->getCutModelData(idc)->getCurrentShape());
+       }
+
+       _undoredo.push_back(cutmodel);
+
+       _currentaction++;// = _undoredo.size();
+       //std::cout<<"current index "<<_currentaction;
+               
+       return cutmodel;
+}
+
+int CutModelManager::Undo()    throw( CutModelException){
+ //&& _currentaction < _undoredo.size()
+       if(_currentaction > 0){
+               int tempaction = _currentaction-1;
+               CutModelSaveBinInfo* currentundo = _undoredo[tempaction];
+               CutModelData* currentmodel;
+
+               if(currentundo->getActionType()==CUTMODEL_CUT){
+                       //Undo the cut
+                       vtkTransform* transform = currentundo->getTransformFromMatrixFile();
+
+                       currentmodel = getCutModelData(currentundo->getId());
+
+                       currentmodel->setTransform(transform, _copyimg);
+
+                       currentmodel->setCurrentShape(currentundo->getCurrentShape());
+
+                       currentmodel->ExecuteUnCut(currentundo->getIsInside(), _img, _copyimg);
+
+               }
+               //Every thing ok
+               _currentaction--;
+               return 0;
+       }
+       return -1;
+}
+
+int CutModelManager::Redo()    throw( CutModelException){
+
+       if(_currentaction >= 0 && _currentaction < _undoredo.size()){
+               
+
+               CutModelSaveBinInfo* currentundo = _undoredo[_currentaction];
+               CutModelData* currentmodel;
+
+               if(currentundo->getActionType()==CUTMODEL_CUT){
+                       //Redo the cut
+                       vtkTransform* transform = currentundo->getTransformFromMatrixFile();
+                       currentmodel = getCutModelData(currentundo->getId());
+                       currentmodel->setTransform(transform, _copyimg);
+                       currentmodel->setCurrentShape(currentundo->getCurrentShape());
+                       currentmodel->ExecuteCut(currentundo->getRange(), currentundo->getIsInside(), _copyimg);
+               }
+
+               _currentaction++;
+
+               return 0;
+       }
+       return -1;
+}
\ No newline at end of file
index e062749ff9841b8df0e402525e6922d583723613..56b3015d74915269b8736916bcbc55a0eaf60d85 100644 (file)
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: wxMaracasMultipleVolumeRendererView.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/11/17 10:23:35 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2009/11/19 15:01:18 $
+  Version:   $Revision: 1.8 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -166,6 +166,11 @@ vtkPiecewiseFunction* wxMaracasMultipleVolumeRendererView::GetTransferFunction(i
 vtkColorTransferFunction* wxMaracasMultipleVolumeRendererView::GetColorFunction(int volumeid){
     return volmanager->GetColorFunction(volumeid);
 }
+
+std::vector<vtkImageData*> wxMaracasMultipleVolumeRendererView::GetOutputImages(){
+       return imgVect;
+}
+
 /**
 **
 **/
index 2c34e9155e0c4b8f4f4f182dca52df97acc9b7ec..6c3f5969bf34007db62fa647a453f1d5fc59c0a9 100644 (file)
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: wxMaracasMultipleVolumeRendererView.h,v $
   Language:  C++
-  Date:      $Date: 2009/10/15 11:56:43 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2009/11/19 15:01:18 $
+  Version:   $Revision: 1.4 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -62,20 +62,19 @@ public:
 
        void addVolumeViewPanel(wxMaracasMultipleVolumeRendererPanel* irmview, std::string dataname);
 
-        vtkPiecewiseFunction* GetTransferFunction(int volumeid);
-        vtkColorTransferFunction* GetColorFunction(int volumeid);
+       vtkPiecewiseFunction* GetTransferFunction(int volumeid);
+       vtkColorTransferFunction* GetColorFunction(int volumeid);
+
+       std::vector<vtkImageData*> GetOutputImages();
 
 private:
        static wxMaracasMultipleVolumeRendererView* instance;
 
        wxMaracasMultipleVolumeRendererManager* volmanager;
-
        wxAuiManager* wxauimanager;
+       wxToolBar* _toolb;
        
        std::string _path;
-
-       wxToolBar* _toolb;
-
     std::vector<vtkImageData*> imgVect;
 };
 
index 94eed6af650946137f84bd43f648d29fc64c6585..85f4066b94c5cc690006549890901e2427cf9c98 100644 (file)
@@ -23,63 +23,63 @@ void wxMaracasRenderImageManagementPanel::createControls()
        wxStaticText* tx = new wxStaticText(this, -1, wxString(_T("  Translate X  ")));
        sliderTranslateX = new wxSlider(this, -1, 0, -200, 200, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
        sliderTranslateX->SetLineSize(1);
-       Connect(sliderTranslateX->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&wxMaracasRenderImageManagementPanel::Translate);
+       Connect(sliderTranslateX->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&wxMaracasRenderImageManagementPanel::Transform);
        sizersliders->Add(tx, wxFIXED_MINSIZE);
        sizersliders->Add(sliderTranslateX,wxSizerFlags().Expand().Center());
 
        wxStaticText* ty = new wxStaticText(this, -1, wxString(_T("  Translate Y  ")));
        sliderTranslateY = new wxSlider(this, -1, 0, -200, 200, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
        sliderTranslateY->SetLineSize(1);
-       Connect(sliderTranslateY->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&wxMaracasRenderImageManagementPanel::Translate);
+       Connect(sliderTranslateY->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&wxMaracasRenderImageManagementPanel::Transform);
        sizersliders->Add(ty, wxFIXED_MINSIZE);
        sizersliders->Add(sliderTranslateY,wxSizerFlags().Expand().Center());
 
        wxStaticText* tz = new wxStaticText(this, -1, wxString(_T("  Translate Z  ")));
        sliderTranslateZ = new wxSlider(this, -1, 0, -200, 200, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
        sliderTranslateZ->SetLineSize(1);
-       Connect(sliderTranslateZ->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&wxMaracasRenderImageManagementPanel::Translate);
+       Connect(sliderTranslateZ->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&wxMaracasRenderImageManagementPanel::Transform);
        sizersliders->Add(tz, wxFIXED_MINSIZE);
        sizersliders->Add(sliderTranslateZ,wxSizerFlags().Expand().Center());
 
        wxStaticText* rx = new wxStaticText(this, -1, wxString(_T("  Rotate X  ")));
        sliderRotateX = new wxSlider(this, -1, 0, -360, 360, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
        sliderRotateX->SetLineSize(1);
-       Connect(sliderRotateX->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&wxMaracasRenderImageManagementPanel::Rotate);
+       Connect(sliderRotateX->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&wxMaracasRenderImageManagementPanel::Transform);
        sizersliders->Add(rx, wxFIXED_MINSIZE);
        sizersliders->Add(sliderRotateX,wxSizerFlags().Expand().Center());
 
        wxStaticText* ry = new wxStaticText(this, -1, wxString(_T("  Rotate Y  ")));
        sliderRotateY = new wxSlider(this, -1, 0, -360, 360, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
        sliderRotateY->SetLineSize(1);
-       Connect(sliderRotateY->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&wxMaracasRenderImageManagementPanel::Rotate);
+       Connect(sliderRotateY->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&wxMaracasRenderImageManagementPanel::Transform);
        sizersliders->Add(ry, wxFIXED_MINSIZE);
        sizersliders->Add(sliderRotateY,wxSizerFlags().Expand().Center());
 
        wxStaticText* rz = new wxStaticText(this, -1, wxString(_T("  Rotate Z  ")));
        sliderRotateZ = new wxSlider(this, -1, 0, -360, 360, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
        sliderRotateZ->SetLineSize(1);
-       Connect(sliderRotateZ->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&wxMaracasRenderImageManagementPanel::Rotate);
+       Connect(sliderRotateZ->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&wxMaracasRenderImageManagementPanel::Transform);
        sizersliders->Add(rz, wxFIXED_MINSIZE);
        sizersliders->Add(sliderRotateZ,wxSizerFlags().Expand().Center());
 
        wxStaticText* sx = new wxStaticText(this, -1, wxString(_T("  Scale X  ")));
        sliderScaleX = new wxSlider(this, -1, 100, 1, 200, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
        sliderScaleX->SetLineSize(1);
-       Connect(sliderScaleX->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&wxMaracasRenderImageManagementPanel::Scale);
+       Connect(sliderScaleX->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&wxMaracasRenderImageManagementPanel::Transform);
        sizersliders->Add(sx, wxFIXED_MINSIZE);
        sizersliders->Add(sliderScaleX,wxSizerFlags().Expand().Center());
 
        wxStaticText* sy = new wxStaticText(this, -1, wxString(_T("  Scale Y  ")));
        sliderScaleY = new wxSlider(this, -1, 100, 1, 200, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
        sliderScaleY->SetLineSize(1);
-       Connect(sliderScaleY->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&wxMaracasRenderImageManagementPanel::Scale);
+       Connect(sliderScaleY->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&wxMaracasRenderImageManagementPanel::Transform);
        sizersliders->Add(sy, wxFIXED_MINSIZE);
        sizersliders->Add(sliderScaleY,wxSizerFlags().Expand().Center());
 
        wxStaticText* sz = new wxStaticText(this, -1, wxString(_T("  Scale Z  ")));
        sliderScaleZ = new wxSlider(this, -1, 100, 1, 200, wxDefaultPosition, this->GetSize(), wxSL_LABELS);
        sliderScaleZ->SetLineSize(1);
-       Connect(sliderScaleZ->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&wxMaracasRenderImageManagementPanel::Scale);
+       Connect(sliderScaleZ->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&wxMaracasRenderImageManagementPanel::Transform);
        sizersliders->Add(sz, wxFIXED_MINSIZE);
        sizersliders->Add(sliderScaleZ,wxSizerFlags().Expand().Center());
        
@@ -128,13 +128,15 @@ wxMaracasRenderImageManagementPanel::~wxMaracasRenderImageManagementPanel()
 /**
 ** Transforms a volume by the given value for the X axis
 **/
-void wxMaracasRenderImageManagementPanel::Translate(wxCommandEvent& event)
+void wxMaracasRenderImageManagementPanel::Transform(wxCommandEvent& event)
 {
        //printf("wxMaracasRenderImageManagementPanel::Translate translateX = %d \n", sliderTranslateX->GetValue());
        //printf("wxMaracasRenderImageManagementPanel::Translate translatey = %d \n", sliderTranslateY->GetValue());
        //printf("wxMaracasRenderImageManagementPanel::Translate translatez = %d \n", sliderTranslateZ->GetValue());
        try{
-               wxtrasform->Translate(sliderTranslateX->GetValue(), sliderTranslateY->GetValue(), sliderTranslateZ->GetValue());
+               wxtrasform->Translate( sliderTranslateX->GetValue(), sliderTranslateY->GetValue(), sliderTranslateZ->GetValue() );
+               wxtrasform->Rotate( sliderRotateX->GetValue(), sliderRotateY->GetValue(), sliderRotateZ->GetValue() );
+               wxtrasform->Scale( sliderScaleX->GetValue(), sliderScaleY->GetValue(), sliderScaleZ->GetValue());
        }
        catch(char* str){
                std::cout << "Exception : " << str << '\n';
@@ -145,7 +147,7 @@ void wxMaracasRenderImageManagementPanel::Translate(wxCommandEvent& event)
 
 /**
 ** Rotates a volume by the given degree for the X axis
-**/
+*
 void wxMaracasRenderImageManagementPanel::Rotate(wxCommandEvent& event)
 {
        //printf("wxMaracasRenderImageManagementPanel::Rotate rotateX = %d \n", sliderRotateX->GetValue());
@@ -160,11 +162,11 @@ void wxMaracasRenderImageManagementPanel::Rotate(wxCommandEvent& event)
                wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
                diag->ShowModal();
        }
-}
+}*/
 
 /**
 ** Scales a volume by the given value for the X axis
-**/
+*
 void wxMaracasRenderImageManagementPanel::Scale(wxCommandEvent& event)
 {
        //printf("wxMaracasRenderImageManagementPanel::Rotate rotateX = %d \n", sliderScaleX->GetValue());
@@ -179,5 +181,5 @@ void wxMaracasRenderImageManagementPanel::Scale(wxCommandEvent& event)
                wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
                diag->ShowModal();
        }
-}
+}*/
 
index c3d19a707f27796c95b809b039b0cac3787d5156..a1b665ffcaf21eef0c5ec6da770dda9c893076b3 100644 (file)
@@ -16,9 +16,9 @@ public:
 
        void createControls();
 
-       void Translate(wxCommandEvent& event);
-       void Rotate(wxCommandEvent& event);
-       void Scale(wxCommandEvent& event);
+       void Transform(wxCommandEvent& event);
+       /*void Rotate(wxCommandEvent& event);
+       void Scale(wxCommandEvent& event);*/
 
 private:
 
index ada5c497fd1ba52f027fe948549444ad747509ae..1960caa2c9def3d9f4370af4af815ee51ce1da0d 100644 (file)
@@ -25,6 +25,10 @@ wxMaracasRenderImageTransformation::wxMaracasRenderImageTransformation(wxMaracas
 **/
 wxMaracasRenderImageTransformation::~wxMaracasRenderImageTransformation()
 {      
+       transformV->Identity();
+       transformS1->Identity();
+       transformS2->Identity();
+       transformS3->Identity();
 }
 
 /**
@@ -32,11 +36,6 @@ wxMaracasRenderImageTransformation::~wxMaracasRenderImageTransformation()
 **/
 void wxMaracasRenderImageTransformation::Translate(int x, int y, int z)
 {
-       transformV->Identity();
-       transformS1->Identity();
-       transformS2->Identity();
-       transformS3->Identity();
-
        transformV->Translate( x, y, z );
        transformS1->Translate( x, y, z );
        transformS2->Translate( x, y, z );
@@ -50,11 +49,6 @@ void wxMaracasRenderImageTransformation::Translate(int x, int y, int z)
 **/
 void wxMaracasRenderImageTransformation::Rotate(int x, int y, int z)
 {
-       transformV->Identity();
-       transformS1->Identity();
-       transformS2->Identity();
-       transformS3->Identity();
-       
        transformV->RotateX( x );
        transformS1->RotateX( x );
        transformS2->RotateX( x );
@@ -90,11 +84,6 @@ void wxMaracasRenderImageTransformation::Scale(int x, int y, int z)
        //printf("wxMaracasRenderImageManagementPanel::Rotate float:scaleY = %f \n", resultY);
        //printf("wxMaracasRenderImageManagementPanel::Rotate float:scaleZ = %f \n", resultZ);
 
-       transformV->Identity();
-       transformS1->Identity();
-       transformS2->Identity();
-       transformS3->Identity();
-
        transformV->Scale( (x/100.0), (y/100.0), (z/100.0) );
        transformS1->Scale( (x/100.0), (y/100.0), (z/100.0) );
        transformS2->Scale( (x/100.0), (y/100.0), (z/100.0) );
@@ -123,5 +112,5 @@ void wxMaracasRenderImageTransformation::Refresh()throw(char*)
        //surface2->getRenderer()->Render();
 
        surface3->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
-       surface3->getRenderer()->Render();
+       //surface3->getRenderer()->Render();
 }
index 83c26f26f1ac306e141b6a69a48095a76907bac0..5c9d88afc19fac2b00fe672ec8ef5663233f1a15 100644 (file)
@@ -82,15 +82,15 @@ void wxMaracasRenderTabbedPanel::createControls(vtkImageData* inImg, std::string
        if(inImg == NULL)
        {
                vtkImageData* img = volmanager->getImageData(pathfile);
-               vtkImageData* img1 = surrendmanager1->getImageData(pathfile);
-               vtkImageData* img2 = surrendmanager2->getImageData(pathfile);
-               vtkImageData* img3 = surrendmanager3->getImageData(pathfile);
-               if(img!=NULL && img1!=NULL && img2!=NULL && img3!=NULL)
+               //vtkImageData* img1 = surrendmanager1->getImageData(pathfile);
+               //vtkImageData* img2 = surrendmanager2->getImageData(pathfile);
+               //vtkImageData* img3 = surrendmanager3->getImageData(pathfile);
+               if(img!=NULL /*&& img1!=NULL && img2!=NULL && img3!=NULL*/)
                {
                        addVolume(img, filename);
-                       addSurface1(img1, filename);
-                       addSurface2(img2, filename);
-                       addSurface3(img3, filename);    
+                       addSurface1(img, filename);
+                       addSurface2(img, filename);
+                       addSurface3(img, filename);     
                        wxtabs->Refresh();
                }
        }       
@@ -520,9 +520,10 @@ void wxMaracasRenderTabbedPanel::onCheckBoxSCChange(wxCommandEvent& event)
 **
 **/
 void wxMaracasRenderTabbedPanel::onOpenParameters(wxCommandEvent& event){      
-       
-       dialog = new wxMaracasRenderImageManagementPanel(this, volmanager, surrendmanager1, surrendmanager2, surrendmanager3, this->getPropIdV());
-       dialog->SetSize(400, 580);
+       if(dialog == NULL){
+               dialog = new wxMaracasRenderImageManagementPanel(this, volmanager, surrendmanager1, surrendmanager2, surrendmanager3, this->getPropIdV());
+               dialog->SetSize(400, 580);
+       }
        dialog->Show();
 }