From 7efcf8b7c62b77ababdaf2c52c2b862597b0b129 Mon Sep 17 00:00:00 2001
From: Juan Prieto <Juan.Prieto@creatis.insa-lyon.fr>
Date: Tue, 8 Sep 2009 08:14:23 +0000
Subject: [PATCH] Undo Redo

---
 bbtk/src/bbcreaMaracasVisuCutModule.cxx       |   8 +-
 .../src/bbmaracasvisuTransferFunctionView.cxx |   4 +-
 data/colorsfunction.txt                       | 110 ++++++++++++
 lib/maracasVisuLib/src/CMakeLists.txt         |   1 +
 .../CutModule/interface/CutModelMainPanel.cxx |  67 ++++++--
 .../CutModule/interface/CutModelMainPanel.h   |  21 ++-
 .../src/CutModule/kernel/CutModelData.cxx     | 157 +++++++++++++++---
 .../src/CutModule/kernel/CutModelData.h       |  28 +++-
 .../src/CutModule/kernel/CutModelManager.cxx  | 110 +++++++++++-
 .../src/CutModule/kernel/CutModelManager.h    |  28 +++-
 .../CutModule/kernel/CutModelSaveBinInfo.cxx  | 111 +++++++++++++
 .../CutModule/kernel/CutModelSaveBinInfo.h    | 111 +++++++++++++
 .../widgets/pPlotter/HistogramDialog.cxx      |  36 ++--
 .../widgets/pPlotter/HistogramDialog.h        |  10 +-
 .../widgets/vtkClipping3DDataViewer.cxx       |   6 +
 .../widgets/vtkClipping3DDataViewer.h         |   2 +
 .../wxWindows/widgets/vtkMPR3DDataViewer.cxx  |  10 +-
 .../wxWindows/widgets/vtkMPR3DDataViewer.h    |   2 +
 .../widgets/wxMaracas_ViewerWidget.cxx        |   7 +-
 .../widgets/wxVtkClipping3DViewCntrlPanel.cxx |   2 +-
 .../wxWindows/widgets/wxVtkMPR3DView.cxx      |   4 +-
 .../wxWindows/widgets/wxVtkMPR3DView.h        |   2 +
 .../widgets/wxVtkMPR3DViewCntrlPanel.cxx      |   2 +-
 23 files changed, 751 insertions(+), 88 deletions(-)
 create mode 100644 data/colorsfunction.txt
 create mode 100644 lib/maracasVisuLib/src/CMakeLists.txt
 create mode 100644 lib/maracasVisuLib/src/CutModule/kernel/CutModelSaveBinInfo.cxx
 create mode 100644 lib/maracasVisuLib/src/CutModule/kernel/CutModelSaveBinInfo.h

diff --git a/bbtk/src/bbcreaMaracasVisuCutModule.cxx b/bbtk/src/bbcreaMaracasVisuCutModule.cxx
index b5e9e2d..cc06cf6 100644
--- a/bbtk/src/bbcreaMaracasVisuCutModule.cxx
+++ b/bbtk/src/bbcreaMaracasVisuCutModule.cxx
@@ -1,5 +1,7 @@
 #include "bbcreaMaracasVisuCutModule.h"
 #include "bbcreaMaracasVisuPackage.h"
+#include "creaSystem.h"
+
 namespace bbcreaMaracasVisu
 {
 
@@ -28,8 +30,10 @@ void CutModule::Process()
 }
 void CutModule::CreateWidget(wxWindow* parent)
 {
- 
-	_mainpanel = CutModelMainPanel::getInstance(parent);
+
+	std::string path = crea::System::GetDllAppPath("bbcreaMaracasVisu.dll");
+	_mainpanel = CutModelMainPanel::getInstance(parent, path);
+	
    bbSetOutputWidget( _mainpanel); 
    Process(); 
   
diff --git a/bbtk/src/bbmaracasvisuTransferFunctionView.cxx b/bbtk/src/bbmaracasvisuTransferFunctionView.cxx
index 733b91d..4fab7db 100644
--- a/bbtk/src/bbmaracasvisuTransferFunctionView.cxx
+++ b/bbtk/src/bbmaracasvisuTransferFunctionView.cxx
@@ -36,12 +36,12 @@ void TransferFunctionView::Process()
 		_tfun->RemoveAllPoints();
 		for(int i = 0; i < greylevel.size();i++){
 			_tfun->AddPoint(greylevel[i], value[i]);
-			std::cout<<"TransferFunctionView::Process()transfer function "<<greylevel[i]<<" "<< value[i]<<std::endl;
+			//std::cout<<"TransferFunctionView::Process()transfer function "<<greylevel[i]<<" "<< value[i]<<std::endl;
 		}
 		_ctfun->RemoveAllPoints();
 		for(int i = 0; i < greylevelcolors.size();i++){
 			_ctfun->AddRGBPoint(greylevelcolors[i], red[i],green[i], blue[i]);
-		std::cout<<"TransferFunctionView::Process()transfer color function "<<greylevelcolors[i]<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
+		//std::cout<<"TransferFunctionView::Process()transfer color function "<<greylevelcolors[i]<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
 		}		
 
 
diff --git a/data/colorsfunction.txt b/data/colorsfunction.txt
new file mode 100644
index 0000000..7512588
--- /dev/null
+++ b/data/colorsfunction.txt
@@ -0,0 +1,110 @@
+<ComboBoxData>
+ <ComboBoxItem>
+ <TransferenceFunction>
+		<Transferencepoint>
+			<greyValue>0</greyValue>
+			<intensity>0</intensity> 
+		</Transferencepoint>
+		<Transferencepoint>
+			<greyValue>0.5</greyValue>
+			<intensity>1</intensity> 
+		</Transferencepoint>
+		<Transferencepoint>
+			<greyValue>1</greyValue>
+			<intensity>1</intensity> 
+		</Transferencepoint>
+ </TransferenceFunction>
+	<Colors>
+		<greyValueRGBpoint>
+			<RGBgreyValue>0</RGBgreyValue>
+			<red>0</red>
+			<green>0</green>
+			<blue>0</blue>
+		</greyValueRGBpoint>
+		<greyValueRGBpoint>
+			<RGBgreyValue>0.25</RGBgreyValue>
+			<red>1</red>
+			<green>0</green>
+			<blue>0</blue>
+		</greyValueRGBpoint>
+		<greyValueRGBpoint>
+			<RGBgreyValue>0.5</RGBgreyValue>
+			<red>0</red>
+			<green>0</green>
+			<blue>1</blue>
+		</greyValueRGBpoint>
+		<greyValueRGBpoint>
+			<RGBgreyValue>0.75</RGBgreyValue>
+			<red>0</red>
+			<green>1</green>
+			<blue>0</blue>
+		</greyValueRGBpoint>
+		<greyValueRGBpoint>
+			<RGBgreyValue>1</RGBgreyValue>
+			<red>0</red>
+			<green>0</green>
+			<blue>0.2</blue>
+		</greyValueRGBpoint>
+	</Colors>
+	</ComboBoxItem>
+ <ComboBoxItem>
+ <TransferenceFunction>
+		<Transferencepoint>
+			<greyValue>0.0507602</greyValue>
+			<intensity>0</intensity> 
+		</Transferencepoint>
+		<Transferencepoint>
+			<greyValue>0.486513</greyValue>
+			<intensity>1</intensity> 
+		</Transferencepoint>
+		<Transferencepoint>
+			<greyValue>0.932075</greyValue>
+			<intensity>1</intensity> 
+		</Transferencepoint>
+ </TransferenceFunction>
+	<Colors>
+		<greyValueRGBpoint>
+			<RGBgreyValue>0</RGBgreyValue>
+			<red>0</red>
+			<green>0</green>
+			<blue>0</blue>
+		</greyValueRGBpoint>
+		<greyValueRGBpoint>
+			<RGBgreyValue>0.83693</RGBgreyValue>
+			<red>1</red>
+			<green>0</green>
+			<blue>0</blue>
+		</greyValueRGBpoint>
+	</Colors>
+	</ComboBoxItem>
+ <ComboBoxItem>
+ <TransferenceFunction>
+		<Transferencepoint>
+			<greyValue>0.0701324</greyValue>
+			<intensity>1</intensity> 
+		</Transferencepoint>
+		<Transferencepoint>
+			<greyValue>0.491417</greyValue>
+			<intensity>1</intensity> 
+		</Transferencepoint>
+		<Transferencepoint>
+			<greyValue>0.888426</greyValue>
+			<intensity>1</intensity> 
+		</Transferencepoint>
+ </TransferenceFunction>
+	<Colors>
+		<greyValueRGBpoint>
+			<RGBgreyValue>0.00465915</RGBgreyValue>
+			<red>1</red>
+			<green>1</green>
+			<blue>1</blue>
+		</greyValueRGBpoint>
+		<greyValueRGBpoint>
+			<RGBgreyValue>0.997548</RGBgreyValue>
+			<red>0</red>
+			<green>0</green>
+			<blue>0</blue>
+		</greyValueRGBpoint>
+	</Colors>
+	</ComboBoxItem>
+</ComboBoxData>
diff --git a/lib/maracasVisuLib/src/CMakeLists.txt b/lib/maracasVisuLib/src/CMakeLists.txt
new file mode 100644
index 0000000..b3b3a69
--- /dev/null
+++ b/lib/maracasVisuLib/src/CMakeLists.txt
@@ -0,0 +1 @@
+SUBDIRS(CutModule)
diff --git a/lib/maracasVisuLib/src/CutModule/interface/CutModelMainPanel.cxx b/lib/maracasVisuLib/src/CutModule/interface/CutModelMainPanel.cxx
index f29854d..2991814 100644
--- a/lib/maracasVisuLib/src/CutModule/interface/CutModelMainPanel.cxx
+++ b/lib/maracasVisuLib/src/CutModule/interface/CutModelMainPanel.cxx
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: CutModelMainPanel.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/09/01 14:01:34 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2009/09/08 08:14:25 $
+  Version:   $Revision: 1.3 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -20,7 +20,8 @@
 // EOF - wxMaracasMPR.cxx
 
 #include "CutModelMainPanel.h"
-
+#include "HistogramDialog.h"
+#include "creaSystem.h"
 
 #include <wx/colordlg.h>
 #include <wx/bmpbuttn.h>
@@ -30,23 +31,26 @@
 #include <Redo.xpm>
 #include <OkAll.xpm>
 
+
+
 CutModelMainPanel* CutModelMainPanel::instance=NULL;
 
-CutModelMainPanel::CutModelMainPanel( wxWindow* parent)
+CutModelMainPanel::CutModelMainPanel( wxWindow* parent, std::string path)
 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){
 
 	cutmanager=NULL;
 
-	initialize();
+	initialize(path);
 
 }
 CutModelMainPanel::~CutModelMainPanel( ){
 	
-
+	delete cutmanager;
 }
 
-void CutModelMainPanel::initialize(){
-	cutmanager = new CutModelManager();
+void CutModelMainPanel::initialize(std::string path){
+	
+	cutmanager = new CutModelManager(path);
 
 	_panelid = 0;
 	_wxauimanager = new wxAuiManager(this);	
@@ -57,16 +61,19 @@ void CutModelMainPanel::initialize(){
 	_wxauimanager->Update();
 }
 
-CutModelMainPanel* CutModelMainPanel::getInstance(wxWindow* parent){
+CutModelMainPanel* CutModelMainPanel::getInstance(wxWindow* parent, std::string path){
 	if(instance==NULL){
-		instance = new CutModelMainPanel(parent);
+		if(parent == NULL){
+			parent = new wxFrame();
+		}
+		instance = new CutModelMainPanel(parent, path);
 	}
 	return instance;
 }
 
-CutModelMainPanel* CutModelMainPanel::getInstance(){
+/*CutModelMainPanel* CutModelMainPanel::getInstance(){
 	return instance;
-}
+}*/
 
 void CutModelMainPanel::setImageData(vtkImageData* img){
 	try{
@@ -183,11 +190,26 @@ CutModelView* CutModelMainPanel::getModelView(int id)throw( CutModelException){
 	return current;
 }
 void CutModelMainPanel::onUndo(){
+	try{
+		checkInvariant();		
+		int result = cutmanager->Undo();
 
+	}catch(CutModelException e){
+		showErrorDialog(e.getCause());
+	}
+	
 }
 
 void CutModelMainPanel::onRedo(){
 
+	try{
+		checkInvariant();		
+		int result = cutmanager->Redo();
+
+	}catch(CutModelException e){
+		showErrorDialog(e.getCause());
+	}
+	
 }
 
 void CutModelMainPanel::changeOpacity(int id,int opacity){
@@ -246,7 +268,8 @@ void CutModelMainPanel::updateActorDirection(int id){
 
 void CutModelMainPanel::ExecuteCut(int id, double* range, bool isinside){
 	try{
-		checkInvariant();
+		checkInvariant();		
+
 		cutmanager->ExecuteCut(id, range, isinside);
 	}catch(CutModelException e){
 		showErrorDialog(e.getCause());
@@ -270,7 +293,23 @@ vtkImageData* CutModelMainPanel::GetResultImage(){
 }
 
 void CutModelMainPanel::ShowStatistics(int id){
-    
+
+	checkInvariant();
+	HistogramDialog *histo = new HistogramDialog(this, _T("Statistics"));
+
+	histo->initializeHistogram(cutmanager->GetResultImage());
+
+	histo->ShowModal();
+
+	delete histo;
+}
+
+void CutModelMainPanel::SaveCutModelData(std::string filename){
+	cutmanager->SaveCutModelData(filename);
+}
+
+void CutModelMainPanel::LoadCutModelData(std::string filename){
+    cutmanager->LoadCutModelData(filename);
 }
 /**
 **
diff --git a/lib/maracasVisuLib/src/CutModule/interface/CutModelMainPanel.h b/lib/maracasVisuLib/src/CutModule/interface/CutModelMainPanel.h
index 5caaa70..92f30cd 100644
--- a/lib/maracasVisuLib/src/CutModule/interface/CutModelMainPanel.h
+++ b/lib/maracasVisuLib/src/CutModule/interface/CutModelMainPanel.h
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: CutModelMainPanel.h,v $
   Language:  C++
-  Date:      $Date: 2009/09/01 14:01:35 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2009/09/08 08:14:25 $
+  Version:   $Revision: 1.3 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -39,12 +39,12 @@ class  creaMaracasVisu_EXPORT  CutModelMainPanel : public wxPanel
 {
 
 public:
-	CutModelMainPanel( wxWindow* parent);
+	
     ~CutModelMainPanel( );
 
-	static CutModelMainPanel* getInstance(wxWindow* parent);
+	static CutModelMainPanel* getInstance(wxWindow* parent=NULL, std::string path ="");
 
-	static CutModelMainPanel* getInstance();
+	//static CutModelMainPanel* getInstance();
 
 	void setImageData(vtkImageData* img);
 
@@ -52,7 +52,7 @@ public:
 
 	void setRenderer(vtkRenderer* renderer);
 
-	void initialize();
+	void initialize(std::string path);
 
 	void onAddCutModel();
 
@@ -83,7 +83,12 @@ public:
 	void ShowPopUpMenu(int id);
 
 	void ShowStatistics(int id);
+
+	
 private:
+
+	CutModelMainPanel( wxWindow* parent, std::string path);
+
 	static CutModelMainPanel* instance;
 
 	CutModelManager* cutmanager;	
@@ -92,6 +97,10 @@ private:
 
 	void showErrorDialog(std::string str);
 
+	void SaveCutModelData(std::string filename);
+
+	void LoadCutModelData(std::string filename);
+
 	std::vector<CutModelView*> viewpanels;
 
 	wxAuiManager* _wxauimanager;
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModelData.cxx b/lib/maracasVisuLib/src/CutModule/kernel/CutModelData.cxx
index d340ec6..ef0806c 100644
--- a/lib/maracasVisuLib/src/CutModule/kernel/CutModelData.cxx
+++ b/lib/maracasVisuLib/src/CutModule/kernel/CutModelData.cxx
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: CutModelData.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/09/01 14:01:36 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2009/09/08 08:14:27 $
+  Version:   $Revision: 1.3 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -20,6 +20,14 @@
 **	Start of the manager class
 **/
 CutModelData::CutModelData(int id, vtkRenderWindowInteractor* interactor, vtkCommand* observer, vtkImageData* img){
+	
+	initializeData(id, interactor, observer, img);
+	
+}
+CutModelData::CutModelData(){
+
+}
+void CutModelData::initializeData(int id, vtkRenderWindowInteractor* interactor, vtkCommand* observer, vtkImageData* img){
 	_id = id;
 	_currentshape=0;
 	createBoxWidget(interactor, observer);
@@ -28,8 +36,6 @@ CutModelData::CutModelData(int id, vtkRenderWindowInteractor* interactor, vtkCom
 	createShapes();
 	ChangeShape(0);
 	checkInvariant();
-
-	
 }
 CutModelData::~CutModelData(){
 	checkInvariant();
@@ -50,9 +56,10 @@ void CutModelData::createBoxWidget(vtkRenderWindowInteractor* interactor, vtkCom
 
 	_boxWidgetVolume = vtkBoxWidget::New();
 	_boxWidgetVolume->SetInteractor( interactor );
-	//_boxWidgetVolume->SetPlaceFactor(2);
+	//_boxWidgetVolume->SetPlaceFactor(1);
 	//_boxWidgetVolume->SetInput( img );	
 	//_boxWidgetVolume->PlaceWidget();
+
 	_boxWidgetVolume->AddObserver( vtkCommand::InteractionEvent		 , observer );
 	_boxWidgetVolume->AddObserver( vtkCommand::StartInteractionEvent		 , observer );
 	_boxWidgetVolume->AddObserver( vtkCommand::RightButtonReleaseEvent		 , observer );
@@ -73,13 +80,20 @@ void CutModelData::setTransform(vtkImageData* img)throw( CutModelException){
 	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]);		
-	matrix->SetElement(0,3,(ext[1]-ext[0])/2*spc[0]);
-	matrix->SetElement(1,3,(ext[3]-ext[2])/2*spc[1]);
-	matrix->SetElement(2,3,(ext[5]-ext[4])/2*spc[2]);
+	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);	
 		
@@ -178,14 +192,16 @@ CutModelFigure* CutModelData::getCurentCuttingModel(){
 		throw CutModelException("Shape type not found");
 	}	
 }
-void CutModelData::ExecuteCut( double* range, bool isinside, vtkImageData* copyimage)
+void CutModelData::ExecuteCut( double* range, bool isinside, vtkImageData* copyimage)throw( CutModelException)
 {
 
 	wxBusyCursor wait;
 
 	CutModelFigure* actualCuttingModel = getCurentCuttingModel();
 
+	//_boxWidgetVolume->GetTransform(currentmatrix);	
 	actualCuttingModel->SetVtkTransform(getModelTransform(copyimage));
+	//actualCuttingModel->SetVtkTransform(currentmatrix);
 	actualCuttingModel->SetInversVtkTransform(getModelTransformInvers());	
 
 	bool			inside;
@@ -229,25 +245,59 @@ void CutModelData::ExecuteCut( double* range, bool isinside, vtkImageData* copyi
 	
 }
 
-vtkTransform* CutModelData::getModelTransform(vtkImageData* copyimage){
+void CutModelData::ExecuteUnCut(bool isinside, vtkImageData* image, vtkImageData* copyimage)throw( CutModelException)
+{
 
-	vtkMatrix4x4* matrix = currentmatrix->GetMatrix();
-	vtkMatrix4x4* matrixmodel = modeltransform->GetMatrix();
+	wxBusyCursor wait;
 
-	double *spc = copyimage->GetSpacing();
+	CutModelFigure* actualCuttingModel = getCurentCuttingModel();
+	
+	actualCuttingModel->SetVtkTransform(getModelTransform(copyimage));
+	
+	actualCuttingModel->SetInversVtkTransform(getModelTransformInvers());	
 
-	modeltransform->Identity();
+	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;
+	
 
-	double* orient = currentmatrix->GetOrientationWXYZ();
-	modeltransform->RotateWXYZ(orient[0],orient[1],orient[2],orient[3]);	
+		
+	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<<"CutModelData::ExecuteUnCut() "<<value<<" "<<*pOrg<<std::endl;
+					*pOrg=(unsigned short)value;
+				} // if inside
+			} // for zz
+		} // for yy
+	} // for xx
+	
+}
 
-	double* pos = currentmatrix->GetPosition();
-	modeltransform->Translate(pos[0]/spc[0],pos[1]/spc[1],pos[2]/spc[2]);
+vtkTransform* CutModelData::getModelTransform(vtkImageData* copyimage){
 
-	double* scal = currentmatrix->GetScale();	
-	modeltransform->Scale(scal[0]/spc[0],scal[1]/spc[1],scal[2]/spc[2]);
+	double *spc = copyimage->GetSpacing();
+	modeltransform->Identity();
 
-	/*matrixmodel->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]);
@@ -259,20 +309,79 @@ vtkTransform* CutModelData::getModelTransform(vtkImageData* copyimage){
 	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]);*/
+	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]);	
 
-	//modeltransform->SetMatrix(matrixmodel);
+	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 CutModelData::setTransform(vtkTransform* transform, vtkImageData* img)throw( CutModelException){
+		
+
+	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* CutModelData::getModelTransformInvers(){
 	inversModel->Identity ();
 	inversModel->Concatenate ( modeltransform );
 	inversModel->Inverse();	
 	return inversModel;
+}
+
+vtkPolyData* CutModelData::getPolyData()throw( CutModelException){
+	return _Mapper->GetInput();
 }
\ No newline at end of file
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModelData.h b/lib/maracasVisuLib/src/CutModule/kernel/CutModelData.h
index 84d4e0b..eb82e8d 100644
--- a/lib/maracasVisuLib/src/CutModule/kernel/CutModelData.h
+++ b/lib/maracasVisuLib/src/CutModule/kernel/CutModelData.h
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: CutModelData.h,v $
   Language:  C++
-  Date:      $Date: 2009/09/01 14:01:36 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2009/09/08 08:14:27 $
+  Version:   $Revision: 1.3 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -42,8 +42,11 @@
 class CutModelData  {
 
 public:
+	CutModelData();
 	CutModelData(int id, vtkRenderWindowInteractor* interactor, vtkCommand* observer, vtkImageData* img);
 	~CutModelData();
+	void initializeData(int id, vtkRenderWindowInteractor* interactor, vtkCommand* observer, vtkImageData* img);
+
 
 	int getId(){
 		return _id;
@@ -56,6 +59,8 @@ public:
 	void ChangeShape(int selection)throw( CutModelException);
 
 	vtkActor* getActor()throw( CutModelException);
+
+	vtkPolyData* getPolyData()throw( CutModelException);
 	
 	void changeColor(double r,double g,double b)throw( CutModelException);
 
@@ -63,7 +68,23 @@ public:
 
 	void ExecuteCut( double* range, bool isinside, vtkImageData* copyimage)throw( CutModelException);
 
+	void ExecuteUnCut(  bool isinside, vtkImageData* image, vtkImageData* copyimage)throw( CutModelException);
+
 	void RefreshViewBox();
+
+	vtkTransform* getCurrentMatrix(){
+		return currentmatrix;
+	}
+
+	int getCurrentShape(){
+		return _currentshape;
+	}
+
+	void setCurrentShape(int currentshape){
+		_currentshape = currentshape;
+	}
+
+	void setTransform(vtkTransform* transform,vtkImageData* img)throw( CutModelException);
 private:	
 	
 	void checkInvariant()throw( CutModelException);
@@ -71,7 +92,7 @@ private:
 	void createBoxWidget(vtkRenderWindowInteractor* interactor, vtkCommand* observer);
 	void createActor();
 	void setTransform(vtkImageData* img)throw( CutModelException);
-	void createShapes();
+	void createShapes();	
 
 	vtkBoxWidget* _boxWidgetVolume;
 	vtkPolyDataMapper* _Mapper;	
@@ -87,6 +108,7 @@ private:
 	vtkTransform* modeltransform;
 	vtkTransform* inversModel;
 
+
 	CutModelFigure* getCurentCuttingModel();
 
 	vtkTransform* getModelTransform(vtkImageData* copyimage);
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModelManager.cxx b/lib/maracasVisuLib/src/CutModule/kernel/CutModelManager.cxx
index 796932d..652faa7 100644
--- a/lib/maracasVisuLib/src/CutModule/kernel/CutModelManager.cxx
+++ b/lib/maracasVisuLib/src/CutModule/kernel/CutModelManager.cxx
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: CutModelManager.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/09/01 14:01:36 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2009/09/08 08:14:27 $
+  Version:   $Revision: 1.3 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -19,13 +19,18 @@
 /**
 **	Start of the manager class
 **/
-CutModelManager::CutModelManager(){
+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());
 }
 
 
@@ -156,9 +161,18 @@ void CutModelManager::RemoveActor(int id)throw( CutModelException){
 
 void CutModelManager::ExecuteCut(int id, double* range, bool isinside)throw( CutModelException){
     checkInvariant();
+		
 	CutModelData* current = getCutModelData(id);
 	current->ExecuteCut(range, isinside,_copyimg);
 
+
+	/*
+	Setting extra information for the undo
+	*/
+	CutModelSaveBinInfo* undoaction = this->AddActionUndo(id, CUTMODEL_CUT);
+	undoaction->setRange(range);
+	undoaction->setIsInside(isinside);
+
 }
 
 vtkImageData* CutModelManager::GetResultImage(){
@@ -173,4 +187,94 @@ void CutModelManager::RefreshActor(int id){
 	_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
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModelManager.h b/lib/maracasVisuLib/src/CutModule/kernel/CutModelManager.h
index 280e85c..14907c5 100644
--- a/lib/maracasVisuLib/src/CutModule/kernel/CutModelManager.h
+++ b/lib/maracasVisuLib/src/CutModule/kernel/CutModelManager.h
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: CutModelManager.h,v $
   Language:  C++
-  Date:      $Date: 2009/09/01 14:01:36 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2009/09/08 08:14:27 $
+  Version:   $Revision: 1.3 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -22,19 +22,24 @@
 #define __CutModelManagerH__
 
 #include <iostream>
+#include <stdio.h>
 #include <vector>
 
 #include "vtkImageData.h"
 #include "vtkRenderWindowInteractor.h"
 #include "vtkRenderer.h"
+#include <vtkPolyDataWriter.h>
 
 #include "CutModelException.h"
 #include "CutModelData.h"
+#include "CutModelSaveBinInfo.h"
+
+
 
 class CutModelManager  {
 
 public:
-	CutModelManager();
+	CutModelManager(std::string path);
 	~CutModelManager();
 
 	void setImageData(vtkImageData* img);
@@ -64,14 +69,29 @@ public:
 	vtkImageData* GetResultImage();
 
 	void RefreshActor(int id);
-private:	
+
+	void SaveCutModelData(std::string filename)throw( CutModelException);
+
+	void LoadCutModelData(std::string filename)throw( CutModelException);
+
+	CutModelSaveBinInfo* AddActionUndo(int id, UNDOTYPE type)throw( CutModelException);
+
+	int Undo()throw( CutModelException);
+
+	int Redo()throw( CutModelException);
+private:
+	
+	int _currentaction;
+
 	void checkInvariant() throw( CutModelException);
+	std::string _path;
 	vtkImageData* _img;
 	vtkImageData* _copyimg;
 	vtkRenderer* _render;
 	vtkRenderWindowInteractor* _interactor;
 
 	std::vector<CutModelData*> _vectordata;
+	std::vector<CutModelSaveBinInfo*> _undoredo;
 	CutModelData* getCutModelData(int id)throw( CutModelException);
 	
 };
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModelSaveBinInfo.cxx b/lib/maracasVisuLib/src/CutModule/kernel/CutModelSaveBinInfo.cxx
new file mode 100644
index 0000000..75cc799
--- /dev/null
+++ b/lib/maracasVisuLib/src/CutModule/kernel/CutModelSaveBinInfo.cxx
@@ -0,0 +1,111 @@
+/*=========================================================================
+
+  Program:   wxMaracas
+  Module:    $RCSfile: CutModelSaveBinInfo.cxx,v $
+  Language:  C++
+  Date:      $Date: 2009/09/08 08:14:27 $
+  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 "CutModelSaveBinInfo.h"
+
+/**
+**	Start of the manager class
+**/
+CutModelSaveBinInfo::CutModelSaveBinInfo(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;	
+
+	
+}
+CutModelSaveBinInfo::~CutModelSaveBinInfo(){
+	
+}
+void CutModelSaveBinInfo::savePolyData(vtkPolyData* polydata){
+	vtkPolyDataWriter * writer = vtkPolyDataWriter ::New();
+	writer->SetFileName(_stdFilename.c_str());	
+	writer->SetInput(polydata);
+	writer->SetFileTypeToBinary();
+	writer->Write();
+	writer->Delete();
+}
+
+vtkTransform* CutModelSaveBinInfo::getPolyDataTransform()throw( CutModelException){
+	vtkPolyDataReader* reader = vtkPolyDataReader::New();
+	//std::cout<<"filename vtkTransform* CutModelSaveBinInfo::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* CutModelSaveBinInfo::getPolyDataTransform() Actor "<<actor<<std::endl;
+	std::cout<<"tkTransform* CutModelSaveBinInfo::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 CutModelSaveBinInfo::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* CutModelSaveBinInfo::getTransformFromMatrixFile()throw( CutModelException){
+	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;
+}
\ No newline at end of file
diff --git a/lib/maracasVisuLib/src/CutModule/kernel/CutModelSaveBinInfo.h b/lib/maracasVisuLib/src/CutModule/kernel/CutModelSaveBinInfo.h
new file mode 100644
index 0000000..fa275aa
--- /dev/null
+++ b/lib/maracasVisuLib/src/CutModule/kernel/CutModelSaveBinInfo.h
@@ -0,0 +1,111 @@
+/*=========================================================================
+
+  Program:   wxMaracas
+  Module:    $RCSfile: CutModelSaveBinInfo.h,v $
+  Language:  C++
+  Date:      $Date: 2009/09/08 08:14:27 $
+  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 __CutModelSaveBinInfoH__
+#define __CutModelSaveBinInfoH__
+
+#include <iostream>
+#include <vector>
+#include "CutModelException.h"
+
+#include <vtkPolyData.h>
+#include <vtkPolyDataWriter.h>
+#include <vtkPolyDataReader.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkTransform.h>
+#include <vtkMatrix4x4.h>
+#include <vtkActor.h>
+
+enum UNDOTYPE
+{
+    CUTMODEL_ADD = 0,	
+	CUTMODEL_REMOVE = 10,
+	CUTMODEL_CUT= 20,
+	
+};
+
+class CutModelSaveBinInfo  {
+
+public:
+	
+	CutModelSaveBinInfo(int id, int currentaction,UNDOTYPE actiontype, std::string path);
+	~CutModelSaveBinInfo();
+
+	int getId(){
+		return _id;
+	}	
+
+	UNDOTYPE getActionType(){
+		return _actiontype;
+	}
+	std::string getSTDFileName()throw( CutModelException){
+		if(_stdFilename==""){
+			throw new CutModelException("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( CutModelException);	
+
+	void saveMatrix4x4(vtkMatrix4x4* matrix);
+	vtkTransform* getTransformFromMatrixFile()throw( CutModelException);
+
+	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/interface/wxWindows/widgets/pPlotter/HistogramDialog.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramDialog.cxx
index 2a23323..1a2c140 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramDialog.cxx
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramDialog.cxx
@@ -53,8 +53,8 @@ void HistogramDialog::initializeHistogramDialog(bool extracontrols){
 	/*
 	Pointers
 	*/
-	wxvtkmpr3Dview=NULL;
-	wxvtkclipping3Dview=NULL;
+	//wxvtkmpr3Dview=NULL;
+	//wxvtkclipping3Dview=NULL;
 	
 	/*
 	 Histogram
@@ -576,16 +576,16 @@ void HistogramDialog::OnRefreshBtn(wxCommandEvent &event)
 	 NOTE I NEED THE UPDATE
 	*/
 	//if it was call from the clipping ctnrl panel
-	if(wxvtkclipping3Dview!=NULL)
-	{
-		wxvtkclipping3Dview->Refresh();
+	//if(wxvtkclipping3Dview!=NULL)
+	//{
+	//	wxvtkclipping3Dview->Refresh();
 
-	}
-	else if(wxvtkmpr3Dview!=NULL)
-	{
-		wxvtkmpr3Dview->Refresh();
+	//}
+	//else if(wxvtkmpr3Dview!=NULL)
+	//{
+	//	wxvtkmpr3Dview->Refresh();
 
-	}
+	//}
 }
 
 
@@ -708,14 +708,14 @@ void HistogramDialog::OnRefreshBtn(wxCommandEvent &event)
 	{
 		newvol=vol;	
 	}
-	void HistogramDialog::setMPR3Dview(wxVtkMPR3DView *wxvtkmpr3Dview1)
-	{
-		wxvtkmpr3Dview=wxvtkmpr3Dview1;
-	}
-	void HistogramDialog::setClipping3DView(wxVtkClipping3DView *wxvtkclipping3Dview1)
-	{
-		wxvtkclipping3Dview=wxvtkclipping3Dview1;
-	}
+	//void HistogramDialog::setMPR3Dview(wxVtkMPR3DView *wxvtkmpr3Dview1)
+	//{
+	//	wxvtkmpr3Dview=wxvtkmpr3Dview1;
+	//}
+	//void HistogramDialog::setClipping3DView(wxVtkClipping3DView *wxvtkclipping3Dview1)
+	//{
+	//	wxvtkclipping3Dview=wxvtkclipping3Dview1;
+	//}
 
 
 	void  HistogramDialog::setTransferenceFunctionHasPoints(bool hasPoints)
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramDialog.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramDialog.h
index 8e9ece3..13f7f3d 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramDialog.h
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramDialog.h
@@ -25,7 +25,7 @@
  #include <vtkColorTransferFunction.h>
  #include <vtkVolumeRayCastMapper.h>
  #include <vtkVolume.h>
- #include "../wxMPRWidget.h"
+ //#include "../wxMPRWidget.h"
 
 #include "HistogramDialogComboBoxItem.h"
 #include <wx/checkbox.h>
@@ -118,8 +118,8 @@ public:
 	void setTF(vtkPiecewiseFunction* tf);
 	void setVolumeMapper(vtkVolumeRayCastMapper* volMapper);
 	void setVolume(vtkVolume* vol);
-	void setMPR3Dview(wxVtkMPR3DView *wxvtkmpr3Dview1);
-	void setClipping3DView(wxVtkClipping3DView *wxvtkclipping3Dview1);
+	//void setMPR3Dview(wxVtkMPR3DView *wxvtkmpr3Dview1);
+	//void setClipping3DView(wxVtkClipping3DView *wxvtkclipping3Dview1);
 
 	//--------------------
 	// plotter Information
@@ -213,8 +213,8 @@ private:
 	vtkVolume							*newvol;
 
 	//things to refresh
-	wxVtkMPR3DView						*wxvtkmpr3Dview;
-	wxVtkClipping3DView					*wxvtkclipping3Dview;
+	//wxVtkMPR3DView						*wxvtkmpr3Dview;
+	//wxVtkClipping3DView					*wxvtkclipping3Dview;
 
 	
 	wxSizer* getControls(bool extracontrols = false);
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.cxx
index d1104df..2af7d10 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.cxx
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.cxx
@@ -620,4 +620,10 @@ void vtkClipping3DDataViewer::ReadMeshVTK(char *namefile)
 	reader->SetFileName(namefile);
 	reader->Update();
 	_tissueStripper[3]->SetInput( reader->GetPolyDataOutput()  );
+}
+
+void vtkClipping3DDataViewer::setColorTransferFunction(vtkColorTransferFunction* colortable){
+	
+	_volumeProperty->SetColor(colortable);
+	
 }
\ No newline at end of file
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.h
index 55c27d9..8a54048 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.h
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.h
@@ -84,6 +84,8 @@ public:
 	std::vector<double>*					GetBlueColorsOfColorTransferenceFVector();
 	std::vector<double>*					GetGreyValueColorsOfColorTransferenceFVector();
 
+	void setColorTransferFunction(vtkColorTransferFunction* colortable);
+
 	//--------------------------------------
 	//Getters transference function
 	//and color of the transference function
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.cxx
index acbeb2f..9e0daaf 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.cxx
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.cxx
@@ -209,7 +209,6 @@ void vtkMPR3DDataViewer::Configure()
 //    _saggitalColors->SetLookupTable(_bwLut);
 	
     _saggitalColors->SetLookupTable(_ctfun);
-
 	
 
 	if(_saggital==NULL){
@@ -332,4 +331,11 @@ void vtkMPR3DDataViewer::SetVisiblePosition(int idPosition, bool visible)
 bool vtkMPR3DDataViewer::GetVisiblePosition(int idPosition)
 {
 	return _visiblePosition[idPosition];
-}
\ No newline at end of file
+}
+
+void vtkMPR3DDataViewer::setColorTransferFunction(vtkColorTransferFunction* colortable){
+	_saggitalColors->SetLookupTable(colortable);
+	 _coronalColors->SetLookupTable(colortable);
+	_axialColors->SetLookupTable(colortable);
+}
+ 
\ No newline at end of file
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.h
index 3eb0216..ebb3132 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.h
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.h
@@ -35,6 +35,8 @@ public:
 	std::vector<double >	   *GetctFunVectorGreen();
 	std::vector<double >	   *GetctFunVectorBlue();
 
+	void setColorTransferFunction(vtkColorTransferFunction* colortable);
+
 private:
 	
 	bool								_visiblePosition[3];
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx
index 7e68a75..987b0b1 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: wxMaracas_ViewerWidget.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/07/27 07:58:20 $
-  Version:   $Revision: 1.15 $
+  Date:      $Date: 2009/09/08 08:14:30 $
+  Version:   $Revision: 1.16 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -397,4 +397,7 @@
 		if(mvtkmpr2Dview_Z!=NULL){
 			mvtkmpr2Dview_Z->setColorTransferFunction(colortable);
 		}
+		if(mwxvtkmpr3Dview!=NULL){
+			mwxvtkmpr3Dview->setColorTransferFunction(colortable);
+		}
 	}
\ No newline at end of file
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DViewCntrlPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DViewCntrlPanel.cxx
index ab9803c..61c5ea5 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DViewCntrlPanel.cxx
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DViewCntrlPanel.cxx
@@ -577,7 +577,7 @@ void wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& event)
 	//setting variables if the user wants to do refresh
 	hDlg->setCTF(ctfun);
 	hDlg->setTF(tfun);
-	hDlg->setClipping3DView(_wxvtkclipping3Dview);
+	//hDlg->setClipping3DView(_wxvtkclipping3Dview);
 	/*
 	hDlg->setVolume(newvol);
 	hDlg->setVolumeMapper(volumeMapper);
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx
index 28c4ca7..d6e88bb 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx
@@ -202,7 +202,9 @@ wxVtkMPR3DView::~wxVtkMPR3DView()
 	}
 
 }
-
+void wxVtkMPR3DView::setColorTransferFunction(vtkColorTransferFunction* colortable){
+	GetVtkMPR3DDataViewer ()->setColorTransferFunction(colortable);	
+}
 //-------------------------------------------------------------------
 void wxVtkMPR3DView::Refresh()   // virtual
 {
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.h
index 338e401..a704ac8 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.h
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.h
@@ -42,6 +42,8 @@ public:
 	void RemoveActor(vtkActor* actor);
 	void ResetCamera(int *ext=NULL, double* origin=NULL,double* spc=NULL);
 
+	void setColorTransferFunction(vtkColorTransferFunction* colortable);
+
 private:
 	wxVtk3DBaseView					*_wxvtk3Dbaseview;
 	vtkMPR3DDataViewer				*_vtkmpr3Ddataviewer;
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DViewCntrlPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DViewCntrlPanel.cxx
index 8665e09..7e8d4a6 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DViewCntrlPanel.cxx
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DViewCntrlPanel.cxx
@@ -232,7 +232,7 @@ hDlg->addColorPoint(gr,(int)(r*255),(int)(g*255),(int)(b*255));
 	//setting variables if the user wants to do refresh
 	
 	hDlg->setCTF(ctfun);
-	hDlg->setMPR3Dview(_wxvtkmpr3Dview);
+	//hDlg->setMPR3Dview(_wxvtkmpr3Dview);
 	
 	if(hDlg->ShowModal()== wxID_OK )
 	{	
-- 
2.49.0