From: Eduardo DAVILA <davila@localhost.localdomain>
Date: Wed, 8 Jan 2020 08:34:27 +0000 (+0100)
Subject: #3335 creaMaracasVisu Feature New Normal  -  Manual Paint Model Undo Redo from box
X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=e711e5be5a37e8d67d9f18de0237310b589beee7;p=creaMaracasVisu.git

#3335 creaMaracasVisu Feature New Normal  -  Manual Paint Model Undo Redo from box
---

diff --git a/bbtk/bbs/boxes/ManualPaint2.bbg b/bbtk/bbs/boxes/ManualPaint2.bbg
index 13b331d..1f2c640 100644
--- a/bbtk/bbs/boxes/ManualPaint2.bbg
+++ b/bbtk/bbs/boxes/ManualPaint2.bbg
@@ -54,7 +54,7 @@ Image2_ManualPaint_Model
 FIN_COMPLEX_PORT
 COMPLEX_PORT
 BoxExecute_ManualPaint_Model
--167.528461:180.349965:-900.000000
+-201.995645:178.771315:-900.000000
 FIN_COMPLEX_PORT
 COMPLEX_PORT
 wxvtkbaseview1
@@ -74,14 +74,14 @@ Tolerance_Fill_ManualPaint_Model
 FIN_COMPLEX_PORT
 COMPLEX_PORT
 colorBarPosition
--192.926981:179.217332:-900.000000
+-180.034675:180.795982:-900.000000
 FIN_COMPLEX_PORT
-BOXES:24
+BOXES:31
 BOX
 creaMaracasVisu:ManualPaint_Model:Box00
 ISEXEC:FALSE
 -95.174180:-58.098371:-900.000000
--49.649180:-68.098371:-900.000000
+-34.534180:-68.098371:-900.000000
 PORT
 2D3D:"1"
 PORT
@@ -125,7 +125,7 @@ BOX
 creaMaracasVisu:ColorLayerImageView:Box03
 ISEXEC:FALSE
 64.897021:-66.295426:-900.000000
-112.822021:-76.295426:-900.000000
+134.777021:-76.295426:-900.000000
 PORT
 TypeControlsInterface:"2"
 PORT
@@ -160,8 +160,8 @@ FIN_BOX
 BOX
 wx:LayoutLine:Box09
 ISEXEC:FALSE
--96.465052:-132.072726:-900.000000
--59.890052:-142.072726:-900.000000
+-100.059182:-162.443123:-900.000000
+-42.499182:-172.443123:-900.000000
 FIN_BOX
 BOX
 std:GetVectorStringElement:Box11
@@ -214,8 +214,8 @@ FIN_BOX
 BOX
 wx:RadioButton:Box18
 ISEXEC:FALSE
--223.537738:36.072184:-900.000000
--130.692204:26.072184:-900.000000
+-242.357156:85.809216:-900.000000
+-178.637156:75.809216:-900.000000
 PORT
 In:"1"
 PORT
@@ -226,8 +226,8 @@ FIN_BOX
 BOX
 wx:LayoutLine:Box19
 ISEXEC:FALSE
--182.190843:-97.578092:-900.000000
--126.138628:-107.578092:-900.000000
+-137.264220:-139.449705:-900.000000
+-79.704220:-149.449705:-900.000000
 PORT
 Orientation:"H"
 FIN_BOX
@@ -262,8 +262,8 @@ FIN_BOX
 BOX
 std:MagicBox:Box24
 ISEXEC:FALSE
-70.058448:54.161651:-900.000000
-106.133448:44.161651:-900.000000
+66.284148:73.033149:-900.000000
+102.359148:63.033149:-900.000000
 FIN_BOX
 BOX
 std:MagicBox:Box25
@@ -293,7 +293,57 @@ ISEXEC:FALSE
 PORT
 Active:"true"
 FIN_BOX
-CONNECTIONS:69
+BOX
+wx:LayoutLine:Box29
+ISEXEC:FALSE
+-234.010495:-17.027092:-900.000000
+-176.450495:-27.027092:-900.000000
+FIN_BOX
+BOX
+wx:CommandButton:Box30
+ISEXEC:FALSE
+-220.568054:36.966713:-900.000000
+-177.793054:26.966713:-900.000000
+PORT
+Label:"Undo"
+FIN_BOX
+BOX
+wx:CommandButton:Box31
+ISEXEC:FALSE
+-211.322007:17.087471:-900.000000
+-168.547007:7.087471:-900.000000
+PORT
+Label:"Redo"
+FIN_BOX
+BOX
+creaMaracasVisu:ManualPaint_UndoRedo:Box32
+ISEXEC:FALSE
+-230.089322:-131.265167:-900.000000
+-180.614322:-141.265167:-900.000000
+PORT
+Type:"2"
+FIN_BOX
+BOX
+creaMaracasVisu:ManualPaint_UndoRedo:Box33
+ISEXEC:FALSE
+-295.989026:-131.212587:-900.000000
+-246.514026:-141.212587:-900.000000
+PORT
+Type:"1"
+FIN_BOX
+BOX
+vtk:UpdateRender:Box34
+ISEXEC:FALSE
+-245.364374:-89.573260:-900.000000
+-205.039374:-99.573260:-900.000000
+FIN_BOX
+BOX
+std:MagicBox:Box38
+ISEXEC:FALSE
+49.639480:114.047399:-900.000000
+85.714480:104.047399:-900.000000
+FIN_BOX
+CONNECTIONS:79
 CONNECTION
 Box01:Out:Box02:In
 NumberOfControlPoints:0
@@ -394,9 +444,6 @@ CONNECTION
 Box17:Out9:Box01:In9
 NumberOfControlPoints:0
 CONNECTION
-Box18:Widget:Box19:Widget1
-NumberOfControlPoints:0
-CONNECTION
 Box01:Widget:Box19:Widget2
 NumberOfControlPoints:0
 CONNECTION
@@ -427,9 +474,6 @@ CONNECTION
 MaxRange_ManualPaint_Model:MaxRange_ManualPaint_Model:Box04:In5
 NumberOfControlPoints:0
 CONNECTION
-Point_ManualPaint_Model:Point_ManualPaint_Model:Box00:Point
-NumberOfControlPoints:0
-CONNECTION
 Image_ManualPaint_Model:Image_ManualPaint_Model:Box00:Image
 NumberOfControlPoints:0
 CONNECTION
@@ -501,4 +545,40 @@ NumberOfControlPoints:0
 CONNECTION
 Box00:BoxChange:Box28:BoxExecute
 NumberOfControlPoints:0
+CONNECTION
+Box18:Widget:Box29:Widget1
+NumberOfControlPoints:0
+CONNECTION
+Box29:Widget:Box19:Widget1
+NumberOfControlPoints:0
+CONNECTION
+Box30:Widget:Box29:Widget2
+NumberOfControlPoints:0
+CONNECTION
+Box31:Widget:Box29:Widget3
+NumberOfControlPoints:0
+CONNECTION
+Box00:Manualpaintmodel:Box32:Manualpaintmodel
+NumberOfControlPoints:0
+CONNECTION
+Box31:BoxChange:Box32:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box30:BoxChange:Box33:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box00:Manualpaintmodel:Box33:Manualpaintmodel
+NumberOfControlPoints:0
+CONNECTION
+Point_ManualPaint_Model:Point_ManualPaint_Model:Box38:In
+NumberOfControlPoints:0
+CONNECTION
+Box38:Out:Box00:Point
+NumberOfControlPoints:0
+CONNECTION
+Box24:Out:Box33:wxvtkbaseview
+NumberOfControlPoints:0
+CONNECTION
+Box24:Out:Box32:wxvtkbaseview
+NumberOfControlPoints:0
 APP_END
diff --git a/bbtk/bbs/boxes/ManualPaint2.bbs b/bbtk/bbs/boxes/ManualPaint2.bbs
index 1f931bc..7ce9788 100644
--- a/bbtk/bbs/boxes/ManualPaint2.bbs
+++ b/bbtk/bbs/boxes/ManualPaint2.bbs
@@ -101,6 +101,24 @@ new vtk:UpdateRender Box27
 new vtk:UpdateRender Box28
   set Box28.Active "true"
 
+new wx:LayoutLine Box29
+
+new wx:CommandButton Box30
+  set Box30.Label "Undo"
+
+new wx:CommandButton Box31
+  set Box31.Label "Redo"
+
+new creaMaracasVisu:ManualPaint_UndoRedo Box32
+  set Box32.Type "2"
+
+new creaMaracasVisu:ManualPaint_UndoRedo Box33
+  set Box33.Type "1"
+
+new vtk:UpdateRender Box34
+
+new std:MagicBox Box38
+
 
 connect Box01.Out Box02.In
 connect Box04.Out0 Box02.In0
@@ -135,7 +153,6 @@ connect Box17.Out6 Box01.In6
 connect Box17.Out7 Box01.In7
 connect Box17.Out8 Box01.In8
 connect Box17.Out9 Box01.In9
-connect Box18.Widget Box19.Widget1
 connect Box01.Widget Box19.Widget2
 connect Box19.Widget Box09.Widget1
 connect Box18.Out Box00.Tool
@@ -155,6 +172,17 @@ connect Box25.Out Box27.Renderer
 connect Box26.Out Box28.Renderer
 connect Box00.BoxChange Box27.BoxExecute
 connect Box00.BoxChange Box28.BoxExecute
+connect Box18.Widget Box29.Widget1
+connect Box29.Widget Box19.Widget1
+connect Box30.Widget Box29.Widget2
+connect Box31.Widget Box29.Widget3
+connect Box00.Manualpaintmodel Box32.Manualpaintmodel
+connect Box31.BoxChange Box32.BoxExecute
+connect Box30.BoxChange Box33.BoxExecute
+connect Box00.Manualpaintmodel Box33.Manualpaintmodel
+connect Box38.Out Box00.Point
+connect Box24.Out Box33.wxvtkbaseview
+connect Box24.Out Box32.wxvtkbaseview
 
 # Complex input ports
 input TitleOptions Box20.In " "
@@ -163,7 +191,6 @@ input SizeDistance_ManualPaint_Model Box04.In2 " "
 input GrayLevel_ManualPaint_Model Box04.In3 " "
 input MinRange_ManualPaint_Model Box04.In4 " "
 input MaxRange_ManualPaint_Model Box04.In5 " "
-input Point_ManualPaint_Model Box00.Point " "
 input Image_ManualPaint_Model Box00.Image " "
 input BoxExecute_ManualPaint_Model Box00.BoxExecute " "
 input Tolerance_Fill_ManualPaint_Model Box04.In6 " "
@@ -172,6 +199,7 @@ input Image2_ManualPaint_Model Box22.In " "
 input wxvtkbaseview1 Box24.In " "
 input wxvtkbaseview2 Box25.In " "
 input wxvtkbaseview3 Box26.In " "
+input Point_ManualPaint_Model Box38.In " "
 
 # Complex output ports
 output widgetOut Box09.Widget " "
diff --git a/bbtk/src/bbcreaMaracasVisuManualPaint.cxx b/bbtk/src/bbcreaMaracasVisuManualPaint.cxx
index ea86236..e463b82 100644
--- a/bbtk/src/bbcreaMaracasVisuManualPaint.cxx
+++ b/bbtk/src/bbcreaMaracasVisuManualPaint.cxx
@@ -52,83 +52,31 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ManualPaint,bbtk::WxBlackBox);
 //=====
 void ManualPaint::Process()
 {
-
-/*
-   std::string msg;
-    if (bbGetInputTitle()!="")
-      {
-	msg = bbGetInputTitle()+": " + bbGetInputIn();
-      }
-    else
-      {
-	msg = bbGetInputIn();
-      }
-   ((wxStaticText*)bbGetOutputWidget())->SetLabel( bbtk::std2wx( msg ) );
-  */
-
     if (bbGetInputWxVtkBaseView1()==NULL)
     {
       wxMessageDialog(NULL,  bbtk::std2wx("(ManualPaint) Input 'WxVtkBaseView' is not set"),  bbtk::std2wx(bbGetFullName()) ).ShowModal();
     }
-
     if (bbGetInputIn()==NULL)
     {
       wxMessageDialog(NULL,  bbtk::std2wx("(ManualPaint) Input 'vtkImageData' is not set"),  bbtk::std2wx(bbGetFullName()) ).ShowModal();
     }
-
-
     if (firsttime==true)
     {
         firsttime=false;
-
-        ManualPaintModel        *mpModel			= new ManualPaintModel();
+        ManualPaintModel        *mpModel		= new ManualPaintModel();
+        ManualPaintControler    *mpControler    = new ManualPaintControler();
         mpModel->SetImages( bbGetInputIn() , bbGetInputIn2() );
-
+        mpControler->SetManualPaintModel(mpModel);
+        mpControler->SetWxVtk2DBaseView( 1, (wxVtk2DBaseView*)bbGetInputWxVtkBaseView1() );
+        mpControler->SetWxVtk2DBaseView( 2, (wxVtk2DBaseView*)bbGetInputWxVtkBaseView2() );
+        mpControler->SetWxVtk2DBaseView( 3, (wxVtk2DBaseView*)bbGetInputWxVtkBaseView3() );
+        mpControler->SetWxVtk2DBaseView( 4, (wxVtk2DBaseView*)bbGetInputWxVtkBaseView4() );
+		mpControler->Config();
         wxManualPaintPanel       *mpPanel			= (wxManualPaintPanel*)bbGetOutputWidget();
-
-        if (bbGetInputWxVtkBaseView1()!=NULL)
-        {
-            ManualPaintControler    *mpControler    = new ManualPaintControler();
-            mpControler->SetManualPaintModel(mpModel);
-//            mpControler->SetManualPaintPanel(mpPanel);
-            mpControler->SetWxVtk2DBaseView( (wxVtk2DBaseView*)bbGetInputWxVtkBaseView1() );
-            mpControler->Config();
-	        mpPanel->SetManualPaintControler(mpControler);
-        }
-
-        if (bbGetInputWxVtkBaseView2()!=NULL)
-        {
-            ManualPaintControler    *mpControler    = new ManualPaintControler();
-            mpControler->SetManualPaintModel(mpModel);
-//            mpControler->SetManualPaintPanel(mpPanel);
-            mpControler->SetWxVtk2DBaseView( (wxVtk2DBaseView*)bbGetInputWxVtkBaseView2() );
-            mpControler->Config();
-	        mpPanel->SetManualPaintControler(mpControler);
-        }
-
-        if (bbGetInputWxVtkBaseView3()!=NULL)
-        {
-            ManualPaintControler    *mpControler    = new ManualPaintControler();
-            mpControler->SetManualPaintModel(mpModel);
-//            mpControler->SetManualPaintPanel(mpPanel);
-            mpControler->SetWxVtk2DBaseView( (wxVtk2DBaseView*)bbGetInputWxVtkBaseView3() );
-            mpControler->Config();
-	        mpPanel->SetManualPaintControler(mpControler);
-        }
-
-        if (bbGetInputWxVtkBaseView4()!=NULL)
-        {
-            ManualPaintControler    *mpControler    = new ManualPaintControler();
-            mpControler->SetManualPaintModel(mpModel);
-//            mpControler->SetManualPaintPanel(mpPanel);
-            mpControler->SetWxVtk2DBaseView( (wxVtk2DBaseView*)bbGetInputWxVtkBaseView4() );
-            mpControler->Config();
-	        mpPanel->SetManualPaintControler(mpControler);
-        }
-
+	    mpPanel->SetManualPaintControler(mpControler);
     } // firsttime
-
 }
+
 //=====
 // Don't edit this file. This file is generated from xml description..
 //=====
@@ -142,7 +90,7 @@ void ManualPaint::CreateWidget(wxWindow* parent)
 //=====
 void ManualPaint::bbUserSetDefaultValues()
 {
-    firsttime=true;
+    firsttime = true;
     bbSetInputIn(NULL);
     bbSetInputWxVtkBaseView1(NULL);
     bbSetInputWxVtkBaseView2(NULL);
diff --git a/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx b/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx
index 856a509..5ff2df7 100644
--- a/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx
+++ b/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx
@@ -51,6 +51,7 @@ void ManualPaint_Model::Process()
 		if (bbGetInputPoint().size()==3)
 		{
 			manualpaintmodel->PaintImage( bbGetInputPoint()[0] , bbGetInputPoint()[1] , bbGetInputPoint()[2] );
+			manualpaintmodel->SetUndoImage();
 		} // if Points
 		if ( bbGetInputByLstPointsX().size()!=0 )
 		{
@@ -58,6 +59,7 @@ void ManualPaint_Model::Process()
 			for (i=0;i<size;i++)
 			{
 				manualpaintmodel->PaintImage( bbGetInputByLstPointsX()[i] , bbGetInputByLstPointsY()[i] , bbGetInputByLstPointsZ()[i] );
+//			_manualPaintModel->SetUndoImage();     // Probably needed.   Here is ok.
 			} // for
 		}// if ByLstPointsX
 		if ((bbGetInputByImagePoints()!=NULL) && (bbGetInputImage2()!=NULL) )
@@ -95,6 +97,7 @@ void ManualPaint_Model::Process()
 							if (vI2==0)
 							{
 								manualpaintmodel->PaintImage(i,j,k);
+//								manualpaintmodel->SetUndoImage();     // Probably needed.   Here is ok.
 							} // vI2		
 						} // vBIP 
 						pBIP = pBIP + sSBIP;				
@@ -116,6 +119,7 @@ void ManualPaint_Model::Process()
 	} else { 
 		bbSetOutputOut( NULL );
 	} 
+	bbSetOutputManualpaintmodel( manualpaintmodel );
 }
 //===== 
 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
diff --git a/bbtk/src/bbcreaMaracasVisuManualPaint_Model.h b/bbtk/src/bbcreaMaracasVisuManualPaint_Model.h
index ddeb4fa..4e7e008 100644
--- a/bbtk/src/bbcreaMaracasVisuManualPaint_Model.h
+++ b/bbtk/src/bbcreaMaracasVisuManualPaint_Model.h
@@ -38,6 +38,7 @@ class bbcreaMaracasVisu_EXPORT ManualPaint_Model
   BBTK_DECLARE_INPUT(ByLstPointsZ,std::vector<int>);
   BBTK_DECLARE_INPUT(Range,std::vector<double>);
   BBTK_DECLARE_OUTPUT(Out,vtkImageData*);
+  BBTK_DECLARE_OUTPUT(Manualpaintmodel,ManualPaintModel*);
   BBTK_PROCESS(Process);
   void Process();
 
@@ -73,6 +74,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ManualPaint_Model,bbtk::AtomicBlackBox);
   BBTK_INPUT(ManualPaint_Model,ByLstPointsZ,"Z Lst of points to run the Manual Paint",std::vector<int>,"");
   BBTK_INPUT(ManualPaint_Model,Range,"min-max range [0 200] default",std::vector<double>,"");
   BBTK_OUTPUT(ManualPaint_Model,Out,"Output image. Is the same pointer of input Image or Image2 with the modifications",vtkImageData*,"");
+  BBTK_OUTPUT(ManualPaint_Model,Manualpaintmodel,"ManualPaintModel",ManualPaintModel*,"");
 
 BBTK_END_DESCRIBE_BLACK_BOX(ManualPaint_Model);
 //===== 
diff --git a/bbtk/src/bbcreaMaracasVisuManualPaint_UndoRedo.cxx b/bbtk/src/bbcreaMaracasVisuManualPaint_UndoRedo.cxx
new file mode 100644
index 0000000..11c935b
--- /dev/null
+++ b/bbtk/src/bbcreaMaracasVisuManualPaint_UndoRedo.cxx
@@ -0,0 +1,105 @@
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+#include "bbcreaMaracasVisuManualPaint_UndoRedo.h"
+#include "bbcreaMaracasVisuPackage.h"
+
+#include <wxMPRBaseData.h>
+
+namespace bbcreaMaracasVisu
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ManualPaint_UndoRedo)
+BBTK_BLACK_BOX_IMPLEMENTATION(ManualPaint_UndoRedo,bbtk::AtomicBlackBox);
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+void ManualPaint_UndoRedo::Process()
+{
+
+// THE MAIN PROCESSING METHOD BODY
+//   Here we simply set the input 'In' value to the output 'Out'
+//   And print out the output value
+// INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
+//    void bbSet{Input|Output}NAME(const TYPE&)
+//    const TYPE& bbGet{Input|Output}NAME() const 
+//    Where :
+//    * NAME is the name of the input/output
+//      (the one provided in the attribute 'name' of the tag 'input')
+//    * TYPE is the C++ type of the input/output
+//      (the one provided in the attribute 'type' of the tag 'input')
+//    bbSetOutputOut( bbGetInputIn() );
+//    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
+  
+	if (bbGetInputManualpaintmodel()!=NULL)
+	{
+		if ( bbGetInputType()==1 )
+		{	
+			bbGetInputManualpaintmodel()->Undo();
+		} // if Type 1
+		if ( bbGetInputType()==2 )
+		{	
+			bbGetInputManualpaintmodel()->Redo();
+		} // if Type 2
+
+
+   		if (bbGetInputwxvtkbaseview()!=NULL)
+		{
+
+		   	vtkMPRBaseData* vtkmprbasedata = (vtkMPRBaseData*) (bbGetInputwxvtkbaseview()->GetVtkBaseData());
+			vtkmprbasedata->SetX( bbGetInputManualpaintmodel()->GetRestorBaseInitialPointX() );
+			vtkmprbasedata->SetY( bbGetInputManualpaintmodel()->GetRestorBaseInitialPointY() );
+			vtkmprbasedata->SetZ( bbGetInputManualpaintmodel()->GetRestorBaseInitialPointZ() );
+			wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
+			//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+			#if wxMAJOR_VERSION <= 2
+					bbGetInputwxvtkbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent( newevent );
+			#else
+					bbGetInputwxvtkbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent( newevent );
+			#endif				
+		} // if bbGetInputwxvtkbaseview()
+
+
+	} // if bbGetInputManualpaintmodel()
+
+
+
+
+}
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+void ManualPaint_UndoRedo::bbUserSetDefaultValues()
+{
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
+//    Here we initialize the input 'In' to 0
+   bbSetInputType(1);
+   bbSetInputManualpaintmodel(NULL);
+   bbSetInputwxvtkbaseview(NULL);
+}
+
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+void ManualPaint_UndoRedo::bbUserInitializeProcessing()
+{
+//  THE INITIALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should allocate the internal/output pointers 
+//    if any 
+}
+
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+void ManualPaint_UndoRedo::bbUserFinalizeProcessing()
+{
+//  THE FINALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should desallocate the internal/output pointers 
+//    if any 
+}
+
+} // EO namespace bbcreaMaracasVisu
+
+
diff --git a/bbtk/src/bbcreaMaracasVisuManualPaint_UndoRedo.h b/bbtk/src/bbcreaMaracasVisuManualPaint_UndoRedo.h
new file mode 100644
index 0000000..90831b3
--- /dev/null
+++ b/bbtk/src/bbcreaMaracasVisuManualPaint_UndoRedo.h
@@ -0,0 +1,55 @@
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+#ifndef __bbcreaMaracasVisuManualPaint_UndoRedo_h_INCLUDED__
+#define __bbcreaMaracasVisuManualPaint_UndoRedo_h_INCLUDED__
+
+#include "bbcreaMaracasVisu_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+#include "wxVtkBaseView.h"
+#include <ManualPaintModel.h>
+
+
+namespace bbcreaMaracasVisu
+{
+
+class bbcreaMaracasVisu_EXPORT ManualPaint_UndoRedo
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(ManualPaint_UndoRedo,bbtk::AtomicBlackBox);
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+  BBTK_DECLARE_INPUT(Manualpaintmodel,ManualPaintModel*);
+  BBTK_DECLARE_INPUT(Type,int);
+  BBTK_DECLARE_INPUT(wxvtkbaseview,wxVtkBaseView*);
+
+//  BBTK_DECLARE_OUTPUT(Out,double);
+  BBTK_PROCESS(Process);
+  void Process();
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(ManualPaint_UndoRedo,bbtk::AtomicBlackBox);
+  BBTK_NAME("ManualPaint_UndoRedo");
+  BBTK_AUTHOR("InfoDev");
+  BBTK_DESCRIPTION("No Description.");
+  BBTK_CATEGORY("empty");
+  BBTK_INPUT(ManualPaint_UndoRedo,Manualpaintmodel,"ManualPaintModel",ManualPaintModel*,"");
+  BBTK_INPUT(ManualPaint_UndoRedo,Type,"(Default 1) 1:Undo  2:Redo",int,"");
+  BBTK_INPUT(ManualPaint_UndoRedo,wxvtkbaseview,"wxVtkBaseView",wxVtkBaseView*,"");
+//  BBTK_OUTPUT(ManualPaint_UndoRedo,Out,"First output",double,"");
+BBTK_END_DESCRIBE_BLACK_BOX(ManualPaint_UndoRedo);
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+}
+// EO namespace bbcreaMaracasVisu
+
+#endif // __bbcreaMaracasVisuManualPaint_UndoRedo_h_INCLUDED__
+
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx
index ab6b614..a9bc413 100755
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx
@@ -39,6 +39,11 @@
 // ----------------------------------------------------------------------------------
 Image3DDequeUR::Image3DDequeUR( )
 {
+	const void * address = static_cast<const void*>(this);
+	std::stringstream ss;
+	ss << address;  
+	m_PrivateID = ss.str(); 
+
 #ifdef _WIN32
 	this->m_GlobalPath = std::getenv("TEMP");
 #endif
@@ -69,6 +74,7 @@ void Image3DDequeUR::AddImagesToURContainer( VTKImageDataPointerType imgUndo,
 	imageInfo->SetImageName( this->GetImageName( this->m_ImgURDeque.size( ) ) );
 	imageInfo->SetImages( imgUndo, imgRedo );
 	imageInfo->SetImageMManager( imMManager );
+	
 	//Adding to deque
 	this->m_ImgURDeque.push_back( imageInfo );
 	this->m_CurrentURPos = this->m_ImgURDeque.size( ) - 1;
@@ -177,9 +183,9 @@ Image3DDequeUR::StringType Image3DDequeUR::GetImageName( const int & pos )
 //Giving a name to an image using the date and time
 	if( this->m_IDImages.empty( ) )
 	{
-		time_t rawtime;
-		struct tm * timeinfo;
-		char buffer[ 80 ];
+		time_t 		rawtime;
+		struct tm 	*timeinfo;
+		char 		buffer[ 80 ];
 		time( &rawtime );
 		timeinfo = localtime( &rawtime );
 		strftime( buffer, 80, "%H%M%S_%a_%d_%b_%y_", timeinfo );
@@ -189,7 +195,7 @@ Image3DDequeUR::StringType Image3DDequeUR::GetImageName( const int & pos )
 	}
 	std::stringstream ss; //create a stringstream
 	ss << pos; //add number to the stream
-	StringType imageName = this->m_IDImages + ss.str( );
+	StringType imageName = this->m_IDImages + ss.str( )+ "_"+m_PrivateID;
 	return ( imageName );
 }
 
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.h
index b013172..416ce6b 100755
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.h
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.h
@@ -128,6 +128,7 @@ protected:
 	int 			m_CurrentURPos; //!<This is the index where is located the undo and redo state.
 	StringType 		m_GlobalPath; 	//!<This is the string with the global path.
 	StringType 		m_IDImages; 	//!<This is the string with the ID of the images (For the filenames).
+	StringType 		m_PrivateID; 	//!<This is the string with the private ID of the images (For the filenames).
 };
 
 #endif /* IMAGE3DDEQUEUR_H_ */
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageDequeUR.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageDequeUR.h
index 121b37f..5af276a 100755
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageDequeUR.h
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageDequeUR.h
@@ -36,12 +36,6 @@
 
 #include "imageInfoUR.h"
 
-//#include <iostream>
-//#include <string>
-//#include <vtkImageData.h>
-//#include <vtkSmartPointer.h>
-//#include "imageModificationManager.h"
-
 /*! @class ImageDequeUR imageDequeUR.h "imageDequeUR.cxx"
  *	@brief This class contains the management of the undo/redo - Abstract Class
  */
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx
index ca2f435..109b1f2 100755
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx
@@ -104,11 +104,10 @@ void ImageInfoUR::SetImages(VTKImageDataPointerType imgUndo, VTKImageDataPointer
 // ----------------------------------------------------------------------------------
 void ImageInfoUR::LoadImagesToMemory(const StringType& gPath) 
 {
-printf("EED ImageInfoUR::LoadImagesToMemory Start\n");
 	//setting paths
-	StringType filename = gPath + this->m_ImageName;
-	StringType undoImagePath = filename + "_Undo.mhd";
-	StringType redoImagePath = filename + "_Redo.mhd";
+	StringType filename 		= gPath + this->m_ImageName;
+	StringType undoImagePath 	= filename + "_Undo.mhd";
+	StringType redoImagePath 	= filename + "_Redo.mhd";
 	//Loading Undo Image
 	VTKMetaImageReaderPointerType readerUndo = VTKMetaImageReaderPointerType::New();
 	readerUndo->SetFileName(undoImagePath.c_str());
@@ -145,9 +144,6 @@ printf("EED ImageInfoUR::LoadImagesToMemory Start\n");
 #endif
 	//Updating status
 	this->m_OnMemory = true;
-
-printf("EED ImageInfoUR::LoadImagesToMemory End\n");
-
 }
 
 // ----------------------------------------------------------------------------------
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.h
index aa80003..8002f5f 100755
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.h
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.h
@@ -181,13 +181,12 @@ public:
 	bool GetStatus();
 	// ----------------------------------------------------------------------------------
 private:
-	VTKImageDataPointerType m_UndoImage; //!<This is the undo image.
-	VTKImageDataPointerType m_RedoImage; //!<This is the redo image
-	StringType m_ImageName; //!<This is the base name of the images.
-	ImageMManagerType* m_ImageMManager; //!<This is the modification manager of the images.
-	bool m_OnMemory; //!<This is true if the images are in memory.
-	bool m_OnDisk; //!<This is true if the images are in disk.
-
+	VTKImageDataPointerType m_UndoImage; 		//!<This is the undo image.
+	VTKImageDataPointerType m_RedoImage; 		//!<This is the redo image
+	StringType 				m_ImageName; 		//!<This is the base name of the images.
+	ImageMManagerType		*m_ImageMManager; 	//!<This is the modification manager of the images.
+	bool 					m_OnMemory; 		//!<This is true if the images are in memory.
+	bool 					m_OnDisk; 			//!<This is true if the images are in disk.
 };
 
 #endif /* IMAGEINFO_H_ */
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.cxx
index 32b0f69..d8a7dc0 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.cxx
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.cxx
@@ -36,17 +36,19 @@
 // ----------------------------------------------------------------------------------
 ImageMManager::ImageMManager() 
 {
+	baseInitialPointX=-9999;
+	baseInitialPointY=-9999;
+	baseInitialPointZ=-9999;
 }
+
 // ----------------------------------------------------------------------------------
 ImageMManager::ImageMManager(ImageMManager* manager) 
 {
-printf("EED ImageMManager::ImageMManager  Start\n");
-	this->m_RegionStruct = manager->GetModifiedRegion();
-	this->m_ValidRegion  = manager->ValidateRegion();
-
-if (manager->ValidateRegion()==true) printf("EED ImageMManager::ImageMManager  manager->ValidateRegion true \n");
-if (manager->ValidateRegion()==false) printf("EED ImageMManager::ImageMManager  manager->ValidateRegion false \n");
-printf("EED ImageMManager::ImageMManager  End\n");
+	this->m_RegionStruct 	= manager->GetModifiedRegion();
+	this->m_ValidRegion  	= manager->ValidateRegion();
+	this->baseInitialPointX = manager->GetBaseInitialPointX();
+	this->baseInitialPointY = manager->GetBaseInitialPointY();
+	this->baseInitialPointZ = manager->GetBaseInitialPointZ();
 }
 // ----------------------------------------------------------------------------------
 ImageMManager::~ImageMManager() 
@@ -90,7 +92,6 @@ void ImageMManager::CalculateMinMaxRegion(const int& i, const int& j, const int&
 // ----------------------------------------------------------------------------------
 void ImageMManager::AddModifiedPixel(const int& i, const int& j, const int& k) 
 {
-//printf("EED ImageMManager::AddModifiedPixel \n");
 	this->CalculateMinMaxRegion(i, j, k);
 }
 // ----------------------------------------------------------------------------------
@@ -104,3 +105,26 @@ RegionStructUR ImageMManager::GetModifiedRegion()
 	return (this->m_RegionStruct);
 }
 // ----------------------------------------------------------------------------------
+
+void ImageMManager::BaseInitialPoint(int x, int y, int z)
+{
+	baseInitialPointX = x;	
+	baseInitialPointY = y;	
+	baseInitialPointZ = z;	
+}
+
+int ImageMManager::GetBaseInitialPointX()
+{
+	return baseInitialPointX;
+}
+
+int ImageMManager::GetBaseInitialPointY()
+{
+	return baseInitialPointY;
+}
+
+int ImageMManager::GetBaseInitialPointZ()
+{
+	return baseInitialPointZ;
+}
+
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.h
index 24ae8f7..d9796de 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.h
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.h
@@ -85,6 +85,12 @@ public:
 	 */
 	RegionStructUR GetModifiedRegion();
 	// ----------------------------------------------------------------------------------
+
+	void BaseInitialPoint(int x, int y, int z);
+	int GetBaseInitialPointX();
+	int GetBaseInitialPointY();
+	int GetBaseInitialPointZ();
+	
 private:
 	// ----------------------------------------------------------------------------------
 	/*! @fn
@@ -93,8 +99,12 @@ private:
 	void CalculateMinMaxRegion(const int& i, const int& j, const int& k);
 	// ----------------------------------------------------------------------------------
 private:
-	RegionStructUR m_RegionStruct; //!< This is the Region structure.
-	bool m_ValidRegion; //!< This is true if the region is valid.
+	RegionStructUR 	m_RegionStruct; //!< This is the Region structure.
+	bool 			m_ValidRegion; //!< This is true if the region is valid.
+	int 			baseInitialPointX;
+	int 			baseInitialPointY;
+	int 			baseInitialPointZ;
+	
 };
 
 #endif /* IMAGEMANAGEMENT_H_ */
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx
index 0054735..cba183c 100755
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx
@@ -34,29 +34,27 @@
 #include "imageUndoRedo.h"
 
 // ----------------------------------------------------------------------------------
-ImageUndoRedo::ImageUndoRedo( )
+ImageUndoRedo::ImageUndoRedo()
 {
 	this->m_ImagesDeque = new IDequeType( );
 }
+
 // ----------------------------------------------------------------------------------
 //virtual
 ImageUndoRedo::~ImageUndoRedo( )
 {
-
 }
+
 // ----------------------------------------------------------------------------------
 //virtual
 void ImageUndoRedo::Undo( )
 {
-printf("EED ImageUndoRedo::Undo Start\n");
 	ImageInfoUR* imageInfo = this->m_ImagesDeque->Undo( );
 	if( imageInfo != NULL)
 	{
 		this->DrawUR( imageInfo, true );
 		this->UpdateUndoImage( );
 	} //if  imageInfo
-printf("EED ImageUndoRedo::Undo End\n");
-
 }
 // ----------------------------------------------------------------------------------
 //virtual
@@ -73,7 +71,6 @@ void ImageUndoRedo::Redo( )
 void ImageUndoRedo::SetImage( VTKImageDataPointerType image )
 {
 	this->m_CurrentImage = image;
-
 //EED 2017-01-01 Migration VTK7
 #if VTK_MAJOR_VERSION <= 5
 	this->m_CurrentImage->Update( );
@@ -123,12 +120,8 @@ void ImageUndoRedo::UpdateUndoImage( )
 // ----------------------------------------------------------------------------------
 ImageUndoRedo::VTKImageDataPointerType ImageUndoRedo::GetImageRegion( const RegionSType& region, VTKImageDataPointerType img )
 {
-printf("EED ImageUndoRedo::GetImageRegion Start\n");
 	VTKExtractVOIPointerType extract = VTKExtractVOIPointerType::New( );
 	extract->SetVOI( region.minX, region.maxX, region.minY, region.maxY,region.minZ, region.maxZ );
-
-printf("EED ImageUndoRedo::GetImageRegion region %d %d   %d %d   %d %d\n", region.minX, region.maxX, region.minY, region.maxY,region.minZ, region.maxZ );
-
 	extract->SetSampleRate( 1, 1, 1 );
 //EED 2017-01-01 Migration VTK7
 #if VTK_MAJOR_VERSION <= 5
@@ -138,15 +131,12 @@ printf("EED ImageUndoRedo::GetImageRegion region %d %d   %d %d   %d %d\n", regio
 	extract->Update();
 #endif
 	VTKImageDataPointerType imgResult = extract->GetOutput( );
-
 //EED 2017-01-01 Migration VTK7
 #if VTK_MAJOR_VERSION <= 5
 	imgResult->Update( );
 #else
 	imgResult->Modified( );
 #endif
-
-printf("EED ImageUndoRedo::GetImageRegion End\n");
 	return ( imgResult );
 }
 // ----------------------------------------------------------------------------------
@@ -158,7 +148,6 @@ void ImageUndoRedo::SetCurrentImage( VTKImageDataPointerType img )
 //virtual
 void ImageUndoRedo::DrawUR( ImageInfoUR* imageInfo, const bool& undo )
 {
-printf("EED ImageUndoRedo::DrawUR Start\n");
 	VTKImageDataPointerType img;
 	if( undo )
 	{
@@ -166,14 +155,14 @@ printf("EED ImageUndoRedo::DrawUR Start\n");
 	} else {
 		img = imageInfo->GetRedoImage( );
 	} //else
-	RegionSType region = imageInfo->GetImageMManager( )->GetModifiedRegion( );
+	RegionSType region 			= imageInfo->GetImageMManager()->GetModifiedRegion();
+	m_RestorBaseInitialPointX 	= imageInfo->GetImageMManager()->GetBaseInitialPointX();
+	m_RestorBaseInitialPointY 	= imageInfo->GetImageMManager()->GetBaseInitialPointY();
+	m_RestorBaseInitialPointZ 	= imageInfo->GetImageMManager()->GetBaseInitialPointZ();
+
 	if( img != NULL)
 	{
-		int *dim 			= img->GetDimensions( );
-printf("EED ImageUndoRedo::DrawUR dim = %d %d %d\n", dim[0],dim[1],dim[2]);
-		int ext[6]; img->GetExtent( ext );
-printf("EED ImageUndoRedo::DrawUR ext = %d %d   %d %d    %d %d\n", ext[0],ext[1],ext[2],ext[3],ext[4],ext[5] );
-	
+		int *dim 			= img->GetDimensions( );	
 		int sizeXImageIn 	= dim[ 0 ];
 		size_t linesize 	= sizeXImageIn * sizeof(unsigned short);
 		for( int j = region.minY, y = 0; j <= region.maxY; j++, y++ )
@@ -188,6 +177,21 @@ printf("EED ImageUndoRedo::DrawUR ext = %d %d   %d %d    %d %d\n", ext[0],ext[1]
 		this->m_CurrentImage->Modified( );
 	} // if img
 	this->m_ImagesDeque->ManageMemory( );
-printf("EED ImageUndoRedo::DrawUR End\n");
 }
 // ----------------------------------------------------------------------------------
+
+int ImageUndoRedo::GetRestorBaseInitialPointX() 
+{
+	return 	m_RestorBaseInitialPointX;
+}
+
+int ImageUndoRedo::GetRestorBaseInitialPointY() 
+{
+	return  m_RestorBaseInitialPointY;
+}
+
+int ImageUndoRedo::GetRestorBaseInitialPointZ() 
+{
+	return 	m_RestorBaseInitialPointZ;
+}
+
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.h
index defc487..38414d7 100755
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.h
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.h
@@ -96,8 +96,12 @@ public:
 	 VTKImageDataPointerType img);
 	 * @brief This method extract from an image the region of interest (In the undo/redo returns the volume of the modified or t-1 image).
 	 */
-	VTKImageDataPointerType GetImageRegion(const RegionSType& region,
-			VTKImageDataPointerType img);
+	VTKImageDataPointerType GetImageRegion(const RegionSType& region,VTKImageDataPointerType img);
+
+	int GetRestorBaseInitialPointX();
+	int GetRestorBaseInitialPointY();
+	int GetRestorBaseInitialPointZ();
+
 protected:
 	// ----------------------------------------------------------------------------------
 	/*! @fn virtual void DrawUR(ImageInfoUR* imageInfo, const bool& undo);
@@ -105,12 +109,17 @@ protected:
 	 */
 	virtual void DrawUR(ImageInfoUR* imageInfo, const bool& undo);
 	// ----------------------------------------------------------------------------------
+
 protected:
 
 	IDequeType					*m_ImagesDeque; 	//!<The manager of the ImagesDeque.
 	VTKImageDataPointerType 	m_UndoImage; 		//!< This is the image for undo t(m_CurrentImage - 1).
 	VTKImageDataPointerType 	m_CurrentImage; 	//!< This is the current image (The modification image).
 
+	int 						m_RestorBaseInitialPointX;
+	int 						m_RestorBaseInitialPointY;
+	int 						m_RestorBaseInitialPointZ;
+
 };
 
 #endif /* IMAGEUNDOREDO_H_ */
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp
index b9f970c..f7feac9 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp
@@ -87,6 +87,8 @@ void BrushFilter::Run() // virtual
 {
 	if (_image != NULL)
 	{
+		this->_IMManager->BaseInitialPoint(_px, _py ,_pz);
+
 		float value = (float) _graylevel;
 		int i, j, k;
 
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp
index d584e3a..0bf97b9 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp
@@ -34,9 +34,6 @@ FillFilter::FillFilter()
 {
 	_tolerancefill 		= 125;
 	_distancefill 		= 5;
-/*
-	_limitRecursionFill = 50000;
-*/
 	_auxImageFill 		= NULL;
 	_maxXback			= 0;
 	_maxYback			= 0;
@@ -49,7 +46,7 @@ FillFilter::~FillFilter()
 	if (_auxImageFill != NULL)
 	{
 		_auxImageFill->Delete();
-	}
+	}//_auxImageFill
 }
 
 //---------------------------------------------------------------------------
@@ -92,22 +89,9 @@ void FillFilter::Run() // virtual
 	if ((_px >= _minX) && (_px <= _maxX) && (_py >= _minY) && (_py <= _maxY)
 			&& (_pz >= _minZ) && (_pz <= _maxZ)) 
 	{
+		this->_IMManager->BaseInitialPoint(_px, _py ,_pz);
 		_graylevelbasefill 			= _image->GetScalarComponentAsDouble(_px, _py, _pz,0);
 		_distbasefill 				= _distancefill * _distancefill;
-/*
-		_pxfill 					= _px;
-		_pyfill 					= _py;
-		_pzfill 					= _pz;
-		_countRecursiveFill 		= 0;
-		_countRecursiveFillProblem 	= 0;
-		_countProgressingFill 		= 0;
-		DEF_POINTER_IMAGE_VTK_CREA_set(v_image,ss_image,p_image,st_image,_image)		
-		if (_image2!=NULL)
-		{
-			DEF_POINTER_IMAGE_VTK_CREA_set(v_image2,ss_image2,p_image2,st_image2,_image2)		
-		} // if _image2
-*/
-//		_usingAuxImageFill 			= false;
 		ivi 						= _px + _py*(_maxX+1) + _pz*(_maxX+1)*(_maxY+1);  // index vector image
 		FillToolLoop(_px, _py, _pz, ivi);
 	} //if _minX _maxX _minY _maxY _minZ _maxZ
@@ -263,286 +247,23 @@ void FillFilter::FillToolLoop(int px, int py, int pz,long int iviA)
 	} // while _lstX.size
 }
 
-
-/*
-
-
-//---------------------------------------------------------------------------
-void FillFilter::Run2() // virtual
-{
-
-	long int ivi;
-	if ((_px >= _minX) && (_px <= _maxX) && (_py >= _minY) && (_py <= _maxY)
-			&& (_pz >= _minZ) && (_pz <= _maxZ)) 
-	{
-		_graylevelbasefill 			= _image->GetScalarComponentAsDouble(_px, _py, _pz,0);
-		_pxfill 					= _px;
-		_pyfill 					= _py;
-		_pzfill 					= _pz;
-		_distbasefill 				= _distancefill * _distancefill;
-		_countRecursiveFill 		= 0;
-		_countRecursiveFillProblem 	= 0;
-		_countProgressingFill 		= 0;
-		_usingAuxImageFill 			= false;
-
-		ivi 						= _px + _py*(_maxX+1) + _pz*(_maxX+1)*(_maxY+1);  // index vector image
-
-DEF_POINTER_IMAGE_VTK_CREA_set(v_image,ss_image,p_image,st_image,_image)		
-if (_image2!=NULL)
-{
-	DEF_POINTER_IMAGE_VTK_CREA_set(v_image2,ss_image2,p_image2,st_image2,_image2)		
-}
-
-//EED01
-//		FillToolRecursive(_px, _py, _pz);
-		FillToolRecursive(_px, _py, _pz, ivi);
-		unsigned char *pImage;
- 		pImage 						= (unsigned char *) _auxImageFill->GetScalarPointer();
-		int ii, jj, kk;
-		ivi							= 0;
-
-		while (_countRecursiveFillProblem != 0) 
-		{
-			_countRecursiveFillProblem  = 0;
-			_usingAuxImageFill			= true;
-			for (kk = 0; kk <= _maxZ; kk++) 
-			{
-				for (jj = 0; jj <= _maxY; jj++) 
-				{
-					for (ii = 0; ii <= _maxX; ii++) 
-					{
-						if (pImage[ivi] == 1) 
-						{
-//EED01
-//							FillToolRecursive(ii, jj, kk);
-							FillToolRecursive(ii, jj, kk, ivi);
-						}  // if
-						ivi++;
-					} // for ii
-				} // for jj
-			} //for kk
-//			printf("-\n");
-		} // while
-	} //if _minX _maxX _minY _maxY _minZ _maxZ
-}
-
-
-
 //---------------------------------------------------------------------------
-void FillFilter::FillToolRecursive(int px, int py, int pz,long int ivi) 
+void FillFilter::SetToleranceFill(double tolerancefill) 
 {
-//ups ??EED   DEF_POINTER_IMAGE_VTK_CREA(v_image,ss_image,p_image,st_image,_image)		
-//ups ??EED   DEF_POINTER_IMAGE_VTK_CREA(v_image2,ss_image2,p_image2,st_image2,_image2)		
-
-	_countRecursiveFill++;
-	_countProgressingFill++;
-	if (_countProgressingFill > 200000) 
-	{
-		printf("R %ld \n", _countRecursiveFill);
-		_countProgressingFill = 0;
-	}
-
-	if ((px >= _minX) && (px <= _maxX) && (py >= _minY) && (py <= _maxY)
-			&& (pz >= _minZ) && (pz <= _maxZ)) 
-	{
-		if (_usingAuxImageFill == true) 
-		{
-//UPS ??EED			this->_IMManager->AddModifiedPixel(px, py, pz); //DFCH
-//EED01
-//			_auxImageFill->SetScalarComponentFromFloat(px, py, pz, 0, 0);
-			_ptrAuxImageFill[ ivi ]=0;
-		}
-		difX=px-_pxfill;
-		difY=py-_pyfill;
-		difZ=pz-_pzfill;
-		_tmpDistfill = difX*difX + difY*difY + difZ*difZ;
-//		_tmpDistfill = (px-_pxfill)*(px-_pxfill)
-//					+  (py-_pyfill)*(py-_pyfill)
-//					+  (pz-_pzfill)*(pz-_pzfill);
-
-//if (_countRecursiveFill >1 )
-//{
-//	printf("   -> %d %d %d   cr=%ld  r=%f\n", px,py,pz,_countRecursiveFill , _tmpDistfill);
-//}
- 
-
-//EED01 
-//		_tmpiglfill 	= _image->GetScalarComponentAsDouble(px, py, pz, 0);
-GETVALUE2_VTK_CREA(_tmpiglfill,p_image,st_image,ivi) 	
-
-		if (_image2!=NULL)
-		{
-//EED01
-//			_tmpiglfill2 	= 	_image2->GetScalarComponentAsDouble(px, py, pz, 0);
-GETVALUE2_VTK_CREA(_tmpiglfill2,p_image2,st_image2,ivi) 	
-		} else {
-			_tmpiglfill2	=	_tmpiglfill;
-		}
-
-		float grayLBFMTOL 	= _graylevelbasefill - _tolerancefill;
-		float grayLBFPTOL 	= _graylevelbasefill + _tolerancefill;
-		bool isInRange 		= false;
-		//DFCH
-		if (_RangeMin <= grayLBFMTOL && _RangeMax >= grayLBFPTOL) {
-			isInRange 		= true;
-		} //fi esle
-		else if (_RangeMin > grayLBFMTOL && _RangeMax >= grayLBFPTOL) {
-			grayLBFMTOL 	= _RangeMin;
-			isInRange 		= true;
-		} //fi esle
-		else if (_RangeMin <= grayLBFMTOL && _RangeMax < grayLBFPTOL) {
-			grayLBFPTOL 	= _RangeMax;
-			isInRange 		= true;
-		} //fi esle
-		else if ((_RangeMin <= _graylevelbasefill) && (_graylevelbasefill <= _RangeMax)) {
-			grayLBFMTOL 	= _RangeMin;
-			grayLBFPTOL 	= _RangeMax;
-			isInRange 		= true;
-		} //fi Range
-
-		if (isInRange) 
-		{
-			_auxGrayLevelValidationFill = (_tmpiglfill != _graylevel)
-					&& (_tmpiglfill2 != _graylevel)
-					&& (_tmpiglfill >= grayLBFMTOL)
-					&& (_tmpiglfill <= grayLBFPTOL)
-					&& (_tmpDistfill <= _distbasefill); //DFCH
-		} else {
-			_auxGrayLevelValidationFill = false;
-		} // if isInRange
-
-
-		if (_auxGrayLevelValidationFill == true) 
-		{
-//UPS ??EED			this->_IMManager->AddModifiedPixel(px, py, pz); //DFCH
-			if (_image2!=NULL)
-			{
-//EED01
-//				_image2->SetScalarComponentFromFloat(px, py, pz, 0,(float) _graylevel);
-SETVALUE2_VTK_CREA(_graylevel,p_image2,st_image2,ivi)
-			} else {
-//EED01
-//				_image->SetScalarComponentFromFloat(px, py, pz, 0,(float) _graylevel);
-SETVALUE2_VTK_CREA(_graylevel,p_image,st_image,ivi)
-			}
-
-			if (_countRecursiveFill < _limitRecursionFill) 
-			{
-
-				if (_2D3D == 0) //2D
-				{
-					if (_direction == 0) // YZ
-					{
-						//FillToolRecursive(px+1,py,pz);
-						//FillToolRecursive(px-1,py,pz);
-						FillToolRecursive(px, py + 1, pz, ivi+_OneLine 	);
-						FillToolRecursive(px, py - 1, pz, ivi-_OneLine 	);
-						FillToolRecursive(px, py, pz - 1, ivi-_OnePlane );
-						FillToolRecursive(px, py, pz + 1, ivi+_OnePlane );
-					}
-					if (_direction == 1) // XZ
-							{
-						FillToolRecursive(px + 1, py, pz, ivi+_OneColumn);
-						FillToolRecursive(px - 1, py, pz, ivi-_OneColumn);
-						//FillToolRecursive(px,py+1,pz);
-						//FillToolRecursive(px,py-1,pz);
-						FillToolRecursive(px, py, pz - 1, ivi-_OnePlane	);
-						FillToolRecursive(px, py, pz + 1, ivi+_OnePlane	);
-					}
-					if (_direction == 2) // XY
-							{
-						FillToolRecursive(px + 1, py, pz, ivi+_OneColumn);
-						FillToolRecursive(px, py + 1, pz, ivi+_OneLine);
-						FillToolRecursive(px - 1, py, pz, ivi-_OneColumn);
-						FillToolRecursive(px, py - 1, pz, ivi-_OneLine);
-						//FillToolRecursive(px,py,pz-1);
-						//FillToolRecursive(px,py,pz+1);
-					}
-				} else { // 3D
-					FillToolRecursive(px + 1, py, pz, ivi+_OneColumn );
-					FillToolRecursive(px - 1, py, pz, ivi-_OneColumn );
-					FillToolRecursive(px, py + 1, pz, ivi+_OneLine );
-					FillToolRecursive(px, py - 1, pz, ivi-_OneLine );
-					FillToolRecursive(px, py, pz - 1, ivi-_OnePlane );
-					FillToolRecursive(px, py, pz + 1, ivi+_OnePlane );
-				} // 2D 3D
-
-			} //_countRecursiveFill
-		} // _graylevel
-
-		if ((_auxGrayLevelValidationFill == true) && (_countRecursiveFill >= _limitRecursionFill)) 
-		{
-			_countRecursiveFillProblem++;
-			if (_2D3D == 0) //2D
-			{
-				if (_direction == 0) // YZ
-				{
-					//SetAuxImageFill(px+1,py,pz);
-					//SetAuxImageFill(px-1,py,pz);
-					SetAuxImageFill(px, py + 1, pz,ivi+_OneLine);
-					SetAuxImageFill(px, py - 1, pz,ivi-_OneLine);
-					SetAuxImageFill(px, py, pz - 1,ivi-_OnePlane);
-					SetAuxImageFill(px, py, pz + 1,ivi+_OnePlane);
-				}
-				if (_direction == 1) // XZ
-				{
-					SetAuxImageFill(px + 1, py, pz,ivi+_OneColumn);
-					SetAuxImageFill(px - 1, py, pz,ivi-_OneColumn);
-					//SetAuxImageFill(px,py+1,pz);
-					//SetAuxImageFill(px,py-1,pz);
-					SetAuxImageFill(px, py, pz - 1,ivi-_OnePlane);
-					SetAuxImageFill(px, py, pz + 1,ivi+_OnePlane);
-				}
-				if (_direction == 2) // XY
-				{
-					SetAuxImageFill(px + 1, py, pz,ivi+_OneColumn);
-					SetAuxImageFill(px - 1, py, pz,ivi-_OneColumn);
-					SetAuxImageFill(px, py + 1, pz,ivi+_OneLine);
-					SetAuxImageFill(px, py - 1, pz,ivi-_OneLine);
-					//SetAuxImageFill(px,py,pz-1);
-					//SetAuxImageFill(px,py,pz+1);
-				}
-			} else { // 3D
-				SetAuxImageFill(px + 1, py, pz,ivi+_OneColumn);
-				SetAuxImageFill(px - 1, py, pz,ivi-_OneColumn);
-				SetAuxImageFill(px, py + 1, pz,ivi+_OneLine);
-				SetAuxImageFill(px, py - 1, pz,ivi-_OneLine);
-				SetAuxImageFill(px, py, pz - 1,ivi-_OnePlane);
-				SetAuxImageFill(px, py, pz + 1,ivi+_OnePlane);
-			} // 2D 3D
-
-		} // _graylevel   //_limitRecursionFill
-
-	} //if _minX _maxX _minY _maxY _minZ _maxZ
-	_countRecursiveFill--;
+	_tolerancefill = tolerancefill;
 }
 
-
 //---------------------------------------------------------------------------
-void FillFilter::SetAuxImageFill(int px, int py, int pz, long int ivi) 
+void FillFilter::SetDistanceFill(int distancefill) 
 {
-	if ((px >= _minX) && (px <= _maxX) && (py >= _minY) && (py <= _maxY)
-			&& (pz >= _minZ) && (pz <= _maxZ)) 
-	{
-		this->_IMManager->AddModifiedPixel(px, py, pz); //DFCH
-//EED01
-//		_auxImageFill->SetScalarComponentFromFloat(px, py, pz, 0, 1);
-			_ptrAuxImageFill[ ivi ]=1;
-	} // if px py pz
+	_distancefill = distancefill;
 }
-*/
-
 
 //---------------------------------------------------------------------------
-void FillFilter::SetToleranceFill(double tolerancefill) 
+vtkImageData* FillFilter::GetAuxImageFill() 
 {
-	_tolerancefill = tolerancefill;
+	return _auxImageFill;
 }
 
-//---------------------------------------------------------------------------
-void FillFilter::SetDistanceFill(int distancefill) 
-{
-	_distancefill = distancefill;
-}
 
 
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.h
index 415e682..03ac7a3 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.h
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.h
@@ -33,70 +33,38 @@ class FillFilter : public baseFilterManualPaint {
 public:
 	FillFilter();
 	virtual ~FillFilter();
-
     void 			Run();
 	void 			FillToolLoop(int px, int py, int pz,long int iviA) ;
-
-/*
-    void 			Run2();
-    void 			FillToolRecursive(int px,int py, int pz, long int ivi);
-    void    		SetAuxImageFill(int px,int py, int pz,long int ivi);
-*/
-
     void 			SetToleranceFill(double tolerancefill);
     void 			SetDistanceFill(int distancefill);
     virtual void 	SetImages(vtkImageData *image,vtkImageData *image2);
-
+	vtkImageData*	GetAuxImageFill();
 private:
     double          _tolerancefill;
     int             _distancefill;
     double          _graylevelbasefill;
-
     double          _distbasefill;
     double          _tmpiglfill;
     double          _tmpiglfill2;
     vtkImageData    *_auxImageFill;
-
     bool            _auxGrayLevelValidationFill;
-
-
 	int 			_maxXback;
 	int 			_maxYback;
 	int 			_maxZback;
-
-/*
-//EED01
-    int             _pxfill;
-    int             _pyfill;
-    int             _pzfill;
-    long int        _countRecursiveFill;
-    long int        _countRecursiveFillProblem;
-	unsigned char 	*_ptrAuxImageFill;
-    long int        _countProgressingFill;
-    long int        _limitRecursionFill;
-    bool            _usingAuxImageFill;
-    double          _tmpDistfill;
-	int 			difX;
-	int 			difY;
-	int 			difZ;
-*/
-
-
 protected:
 
-
 //DEF_POINTER_IMAGE_VTK_CREA_definition( v_image , ss_image , p_image , st_image )		
-	double 	v_image			;
-	int 	ss_image 		;
-	char 	*p_image 		;
-	int		st_image		;
+	double 			v_image;
+	int 			ss_image;
+	char 			*p_image;
+	int				st_image;
 
 //macro not working ???    
 //   DEF_POINTER_IMAGE_VTK_CREA_definition(v_image2,ss_image2,p_image2,st_image2)		
-	double 	v_image2		;
-	int 	ss_image2 		;
-	char 	*p_image2 		;
-	int		st_image2		;
+	double 			v_image2;
+	int 			ss_image2;
+	char 			*p_image2;
+	int				st_image2;
 
 };
 
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.cpp
index 4674d2d..4e841be 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.cpp
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.cpp
@@ -33,7 +33,11 @@
 ManualPaintControler::ManualPaintControler() 
 {
 	auxZ 				= 0;
-	_wxvtk2Dbaseview 	= NULL;
+//	_wxvtk2Dbaseview 	= NULL;
+	_wxvtk2Dbaseview1	= NULL;
+	_wxvtk2Dbaseview2	= NULL;
+	_wxvtk2Dbaseview3	= NULL;
+	_wxvtk2Dbaseview4	= NULL;
 }
 
 //---------------------------------------------------------------------------
@@ -54,31 +58,43 @@ ManualPaintModel* ManualPaintControler::GetManualPaintModel( )
 }
 
 //---------------------------------------------------------------------------
-//void ManualPaintControler::SetManualPaintPanel( ManualPaintPanel* manualPaintPanel ) 
-//{
-//	_manualPaintPanel 	= manualPaintPanel;
-//}
-
-//---------------------------------------------------------------------------
-void ManualPaintControler::SetWxVtk2DBaseView( wxVtk2DBaseView *wxvtk2Dbaseview )
+void ManualPaintControler::SetWxVtk2DBaseView( int id, wxVtk2DBaseView *wxvtk2Dbaseview )
 {
-	_wxvtk2Dbaseview 	= wxvtk2Dbaseview;
+	if (id==1) { _wxvtk2Dbaseview1 	= wxvtk2Dbaseview; }
+	if (id==2) { _wxvtk2Dbaseview2 	= wxvtk2Dbaseview; }
+	if (id==3) { _wxvtk2Dbaseview3 	= wxvtk2Dbaseview; }
+	if (id==4) { _wxvtk2Dbaseview4 	= wxvtk2Dbaseview; }
 }
 
 //---------------------------------------------------------------------------
 void ManualPaintControler::Config() 
 {
-	if (_wxvtk2Dbaseview != NULL) 
+	if (_wxvtk2Dbaseview1 != NULL) 
+	{
+		vtkInteractorStyleBaseView *isbv = (vtkInteractorStyleBaseView*) (_wxvtk2Dbaseview1->GetInteractorStyleBaseView());
+		isbv->AddInteractorStyleMaracas(new vtkInteractorManualPaint(this));
+	} // if _wxvtk2Dbaseview
+	if (_wxvtk2Dbaseview2 != NULL) 
+	{
+		vtkInteractorStyleBaseView *isbv = (vtkInteractorStyleBaseView*) (_wxvtk2Dbaseview2->GetInteractorStyleBaseView());
+		isbv->AddInteractorStyleMaracas(new vtkInteractorManualPaint(this));
+	} // if _wxvtk2Dbaseview
+	if (_wxvtk2Dbaseview3 != NULL) 
+	{
+		vtkInteractorStyleBaseView *isbv = (vtkInteractorStyleBaseView*) (_wxvtk2Dbaseview3->GetInteractorStyleBaseView());
+		isbv->AddInteractorStyleMaracas(new vtkInteractorManualPaint(this));
+	} // if _wxvtk2Dbaseview
+	if (_wxvtk2Dbaseview4 != NULL) 
 	{
-		vtkInteractorStyleBaseView *isbv = (vtkInteractorStyleBaseView*) (_wxvtk2Dbaseview->GetInteractorStyleBaseView());
+		vtkInteractorStyleBaseView *isbv = (vtkInteractorStyleBaseView*) (_wxvtk2Dbaseview4->GetInteractorStyleBaseView());
 		isbv->AddInteractorStyleMaracas(new vtkInteractorManualPaint(this));
 	} // if _wxvtk2Dbaseview
 }
 
 //---------------------------------------------------------------------------
-void ManualPaintControler::PaintImage(int px, int py, int pz) 
+void ManualPaintControler::PaintImage(int px, int py, int pz,int direction) 
 {
-	_manualPaintModel->SetDirection(_wxvtk2Dbaseview->GetDirection());
+	_manualPaintModel->SetDirection( direction );
 	_manualPaintModel->PaintImage(px, py, pz);
 	// The refresh mechanisme is made in the vtkInteractorManualPaint
 	//    RefreshView();
@@ -90,40 +106,39 @@ void ManualPaintControler::SetImageUndo()
 	_manualPaintModel->SetUndoImage();
 }
 
-
-
 //---------------------------------------------------------------------------
 void ManualPaintControler::Undo()
 {
 	_manualPaintModel->Undo();
-	Refresh();
+	Refresh_UndoRedo();
 }
 
 void ManualPaintControler::Redo()
 {
 	_manualPaintModel->Redo();
-	Refresh();
+	Refresh_UndoRedo();
 }
 
-
-void ManualPaintControler::Refresh()
+void ManualPaintControler::Refresh_UndoRedo()
 {
-	if (_wxvtk2Dbaseview!=NULL)
+	wxVtk2DBaseView *wxvtk2Dbaseview = NULL;
+	if (_wxvtk2Dbaseview1!=NULL){ wxvtk2Dbaseview=_wxvtk2Dbaseview1; }
+	if (_wxvtk2Dbaseview2!=NULL){ wxvtk2Dbaseview=_wxvtk2Dbaseview2; }
+	if (_wxvtk2Dbaseview3!=NULL){ wxvtk2Dbaseview=_wxvtk2Dbaseview3; }
+	if (_wxvtk2Dbaseview4!=NULL){ wxvtk2Dbaseview=_wxvtk2Dbaseview4; }
+	if (wxvtk2Dbaseview!=NULL)
 	{
-	   	vtkMPRBaseData* vtkmprbasedata = (vtkMPRBaseData*) (_wxvtk2Dbaseview->GetVtkBaseData());
-//		if (bbGetInputPoint().size()==3)
-//		{
-//			vtkmprbasedata->SetX( bbGetInputPoint()[0] );
-//			vtkmprbasedata->SetY( bbGetInputPoint()[1] );
-//			vtkmprbasedata->SetZ( bbGetInputPoint()[2] );
-			wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
+	   	vtkMPRBaseData* vtkmprbasedata = (vtkMPRBaseData*) (wxvtk2Dbaseview->GetVtkBaseData());
+		vtkmprbasedata->SetX( _manualPaintModel->GetRestorBaseInitialPointX() );
+		vtkmprbasedata->SetY( _manualPaintModel->GetRestorBaseInitialPointY() );
+		vtkmprbasedata->SetZ( _manualPaintModel->GetRestorBaseInitialPointZ() );
+		wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
 #if wxMAJOR_VERSION <= 2
-			_wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor ()->GetParent()->ProcessEvent( newevent );
+		wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor ()->GetParent()->ProcessEvent( newevent );
 #else
-			_wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor ()->GetParent()->ProcessWindowEvent( newevent );
+		wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor ()->GetParent()->ProcessWindowEvent( newevent );
 #endif				
-//		} // if Position
 	} // _wxvtk2Dbaseview
 }
 
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.h
index 9a9993b..e3c5c0f 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.h
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.h
@@ -38,20 +38,21 @@ public:
 
     void 				SetManualPaintModel(ManualPaintModel* manualPaintModel);
     ManualPaintModel*	GetManualPaintModel();
-//    void 				SetManualPaintPanel(ManualPaintPanel* manualPaintPanel);
-    void 				SetWxVtk2DBaseView(wxVtk2DBaseView *wxvtk2Dbaseview);
+    void 				SetWxVtk2DBaseView(int id, wxVtk2DBaseView *wxvtk2Dbaseview);
     void 				Config();
-    void 				PaintImage(int px,int py, int pz);
+    void 				PaintImage(int px,int py, int pz, int direction);
     void 				SetImageUndo();
     void 				Undo();
     void 				Redo();
-    void 				Refresh();
+    void 				Refresh_UndoRedo();
 
 private:
     int                 auxZ;
 	ManualPaintModel	*_manualPaintModel;
-//	ManualPaintPanel	*_manualPaintPanel;
-	wxVtk2DBaseView     *_wxvtk2Dbaseview;
+	wxVtk2DBaseView     *_wxvtk2Dbaseview1;
+	wxVtk2DBaseView     *_wxvtk2Dbaseview2;
+	wxVtk2DBaseView     *_wxvtk2Dbaseview3;
+	wxVtk2DBaseView     *_wxvtk2Dbaseview4;
 
 protected:
 
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp
index 8736b83..e57d3eb 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp
@@ -27,11 +27,12 @@
 
 ManualPaintModel::ManualPaintModel() 
 {
-	_active 		= true;
-	_tool 			= 0; // 0 pencil         ,   1 fill
-	_brushfilter 	= new BrushFilter();
-	_fillfilter 	= new FillFilter();
-	_imageUndoRedo 	= new ImageUndoRedo();
+	_active 				= true;
+	_tool 					= 0; // 0 pencil         ,   1 fill
+	_brushfilter 			= new BrushFilter();
+	_fillfilter 			= new FillFilter();
+	_imageUndoRedo 			= new ImageUndoRedo();
+	_imageUndoRedo_visited	= new ImageUndoRedo();
 }
 
 //---------------------------------------------------------------------------
@@ -75,8 +76,8 @@ void ManualPaintModel::SetTool(int tool)
 //---------------------------------------------------------------------------
 void ManualPaintModel::Set2D3D(int dim2D3D) 
 {
-	_brushfilter->Set2D3D(dim2D3D);
-	_fillfilter->Set2D3D(dim2D3D);
+	_brushfilter -> Set2D3D(dim2D3D);
+	_fillfilter  -> Set2D3D(dim2D3D);
 }
 
 //---------------------------------------------------------------------------
@@ -86,7 +87,13 @@ void ManualPaintModel::SetImages(vtkImageData *image,vtkImageData *image2)
 	{
 		_brushfilter -> SetImages(image,image2);
 		_fillfilter  -> SetImages(image,image2);
-		_imageUndoRedo->SetImage(image);
+		if (image2!=NULL)
+		{
+			_imageUndoRedo->SetImage(image2);
+		} else {
+			_imageUndoRedo->SetImage(image);
+		}
+		_imageUndoRedo_visited->SetImage( _fillfilter->GetAuxImageFill() );
 	} else {
 		printf("EED Warning image=NULL in ManualPaintModel::SetImage(image)\n ");
 	}
@@ -162,18 +169,38 @@ void ManualPaintModel::SetUndoImage()
 	{
 		imMManager = this->_fillfilter->GetImageMManager();
 	} // if 1
-	this->_imageUndoRedo->SetURImages(imMManager);
-	this->_brushfilter->CleanImageMManager();
-	this->_fillfilter->CleanImageMManager();
+	this->_imageUndoRedo			-> SetURImages(imMManager);
+	this->_imageUndoRedo_visited	-> SetURImages(imMManager);
+	this->_brushfilter				-> CleanImageMManager();
+	this->_fillfilter				-> CleanImageMManager();
 }
 //---------------------------------------------------------------------------
 
 void ManualPaintModel::Undo() 
 {
 	this->_imageUndoRedo->Undo();
+	this->_imageUndoRedo_visited->Undo();
 }
 
 void ManualPaintModel::Redo() 
 {
 	this->_imageUndoRedo->Redo();
+	this->_imageUndoRedo_visited->Redo();
 }
+
+
+int ManualPaintModel::GetRestorBaseInitialPointX() 
+{
+	return 	this->_imageUndoRedo->GetRestorBaseInitialPointX();
+}
+
+int ManualPaintModel::GetRestorBaseInitialPointY() 
+{
+	return 	this->_imageUndoRedo->GetRestorBaseInitialPointY();
+}
+
+int ManualPaintModel::GetRestorBaseInitialPointZ() 
+{
+	return 	this->_imageUndoRedo->GetRestorBaseInitialPointZ();
+}
+
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h
index eb6f10a..a99749a 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h
@@ -29,18 +29,13 @@
 #include "BrushFilter.h"
 #include "FillFilter.h"
 
-//#include "regionStructUR.h"
-//#include "imageUndoRedo.h"
-
 #include "imageModificationManager.h"
 #include "imageUndoRedo.h"
 
-
 class ManualPaintModel {
 public:
 	ManualPaintModel();
 	virtual ~ManualPaintModel();
-
 	void SetActive(bool active);
 	void SetTool(int tool);
 	void Set2D3D(int dim2D3D);
@@ -55,9 +50,13 @@ public:
 	void SetRangeMin(int min);
 	void SetRangeMax(int max);
 	void GetScalarRange(double * range);
-	void SetUndoImage(); //DFCH
-	void Undo(); //DFCH
-	void Redo(); //DFCH
+	void SetUndoImage(); 	//DFCH
+	void Undo(); 			//DFCH
+	void Redo(); 			//DFCH
+
+	int GetRestorBaseInitialPointX();
+	int GetRestorBaseInitialPointY();
+	int GetRestorBaseInitialPointZ();
 
 private:
 	int 			_tool;
@@ -65,9 +64,8 @@ private:
 	BrushFilter 	*_brushfilter;
 	FillFilter 		*_fillfilter;
 	ImageUndoRedo 	*_imageUndoRedo;
-
+	ImageUndoRedo 	*_imageUndoRedo_visited;
 protected:
-
 };
 
 #endif // _MANUAL_PAINT_MODEL_H_
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h
index f24066a..4bd2c34 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h
@@ -38,7 +38,6 @@ class baseFilterManualPaint {
 public:
 	baseFilterManualPaint();
 	virtual ~baseFilterManualPaint();
-
 	virtual void SetImages(vtkImageData *image,vtkImageData *image2);
 	void SetPoint(int px, int py, int pz);
 	void Set2D3D(int dim2D3D);
@@ -47,18 +46,14 @@ public:
 	void ResetGeneralMinMax();
 	void SetGeneralMinMax(int minX, int maxX, int minY, int maxY, int minZ, int maxZ);
 	void GetScalarRange(double * range);
-
     void SetRangeMin( int min );//DFCH
     void SetRangeMax( int max );//DFCH
     int GetRangeMin( ); //DFCH
     int GetRangeMax( ); //DFCH
-
 	ImageMManager* GetImageMManager(); //DFCH
 	void CleanImageMManager(); //DFCH
 	virtual void Run();
-
 private:
-
 protected:
 	ImageMManager 	*_IMManager; //Saves the last modified region (MinX, MaxX, MinY, MaxY, MinZ, MaxZ).
 	vtkImageData 	*_image;
@@ -86,8 +81,6 @@ protected:
 	double 			_graylevel;
     int    			_RangeMin;
     int    			_RangeMax;
-
-
 };
 
 #endif // _BASE_FILTER_MANUAL_PAINT_H_
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.cpp
index e7b081d..609acfe 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.cpp
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.cpp
@@ -44,7 +44,6 @@ vtkInteractorManualPaint::~vtkInteractorManualPaint()
 //---------------------------------------------------------------------------
 bool vtkInteractorManualPaint::OnChar() 
 {
-printf("EED vtkInteractorManualPaint::OnChar \n");
 	vtkRenderWindowInteractor *interactor = _vtkInteractorStyleBaseView->GetInteractor();
 	if (interactor->GetKeyCode() == 97) 
 	{
@@ -59,8 +58,8 @@ bool vtkInteractorManualPaint::OnLeftButtonDown()
 	vtkRenderWindowInteractor *interactor = _vtkInteractorStyleBaseView->GetInteractor();
 	if (interactor->GetControlKey() == 1) {
 		_state = true;
-//        wxVtk2DBaseView             *wxvtk2Dbaseview    = (wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView();
-//        _Z      =   wxvtk2Dbaseview->GetActualSlice();
+//      wxVtk2DBaseView             *wxvtk2Dbaseview    = (wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView();
+//      _Z      =   wxvtk2Dbaseview->GetActualSlice();
 	}
 	return true;
 }
@@ -68,7 +67,6 @@ bool vtkInteractorManualPaint::OnLeftButtonDown()
 //---------------------------------------------------------------------------
 bool vtkInteractorManualPaint::OnLeftButtonUp() 
 {
-printf("EED vtkInteractorManualPaint::OnLeftButtonUp \n");
     if((_state == true) || (_stateKey == true))
 	{
 //    	_manualPaintControler->SetImageUndo();
@@ -90,11 +88,9 @@ bool vtkInteractorManualPaint::OnMouseMove()
 		double Y = (double) py;
 		double Z = wxvtk2Dbaseview->GetActualSlice();
 		wxvtk2Dbaseview->TransFromCoordScreenToWorld(X, Y, Z, true);
-		_manualPaintControler->PaintImage((int) X, (int) Y, (int) Z);
+		_manualPaintControler->PaintImage((int) X, (int) Y, (int) Z,  wxvtk2Dbaseview->GetDirection() );
 		this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
-
     	_manualPaintControler->SetImageUndo();
-
 	} // if _state
 	return true;
 }
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp
index 0fb3c37..9276f59 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp
@@ -378,7 +378,6 @@ void wxManualPaintPanel::ConnectComponents( ) //DFCH
 			_activeCB->GetId(),
 	     		wxEVT_COMMAND_CHECKBOX_CLICKED, 
 	     		(wxObjectEventFunction) (void (wxPanel::*)(wxCommandEvent&))&wxManualPaintPanel::OnActive);
-
 	}
 
 
@@ -402,7 +401,6 @@ void wxManualPaintPanel::OnBrushSize( wxScrollEvent& event )
 void wxManualPaintPanel::OnSldGrayLevel( wxScrollEvent& event )
 {
 	SetGrayLevel( (double) ( _sldGrayLevel->GetValue( )) );
-
 	wxString text;
 	text.Printf( wxT("%d"), _sldGrayLevel->GetValue( ) );
 	_graylevelCtrl->SetValue( text );
@@ -420,7 +418,6 @@ void wxManualPaintPanel::OnCtrTxtGrayLevel( wxCommandEvent &event )
 void wxManualPaintPanel::OnSldDistanceFill( wxScrollEvent& event )
 {
 	SetDistanceFill( (double) ( _sldDistanceFill->GetValue( )) );
-
 	wxString text;
 	text.Printf( wxT("%d"), _sldDistanceFill->GetValue( ) );
 	_distancefillCtrl->SetValue( text );
@@ -445,7 +442,6 @@ void wxManualPaintPanel::OnCtrBrushSize( wxCommandEvent &event )
 void wxManualPaintPanel::OnSldToleranceFill( wxScrollEvent& event )
 {
 	SetToleranceFill( (double) ( _sldToleranceFill->GetValue( )) );
-
 	wxString text;
 	text.Printf( wxT("%d"), _sldToleranceFill->GetValue( ) );
 	_tolerancefillCtrl->SetValue( text );
@@ -490,7 +486,6 @@ void wxManualPaintPanel::OnBrushForm( wxCommandEvent &event )
 //---------------------------------------------------------------------------
 void wxManualPaintPanel::OnTool( wxCommandEvent &event )
 {
-printf("EED wxManualPaintPanel::OnTool Start\n");
 	DisableControls( );
 	SetTool( _rbBrushTool->GetSelection( ) );
 
@@ -506,26 +501,15 @@ printf("EED wxManualPaintPanel::OnTool Start\n");
 
 	if( _rbBrushTool->GetSelection( ) == 1 ) //Fill tool
 	{
-printf("EED wxManualPaintPanel::OnTool 1\n");
 		_txtToleranceFill->Enable( );
-printf("EED wxManualPaintPanel::OnTool 2\n");
 		_sldToleranceFill->Enable( );
-printf("EED wxManualPaintPanel::OnTool 3\n");
 		_tolerancefillCtrl->Enable( );
-
-printf("EED wxManualPaintPanel::OnTool 4\n");
 		_txtDistanceFill->Enable( );
-printf("EED wxManualPaintPanel::OnTool 5\n");
 		_sldDistanceFill->Enable( );
-printf("EED wxManualPaintPanel::OnTool 6\n");
 		_distancefillCtrl->Enable( );
-printf("EED wxManualPaintPanel::OnTool 7\n");
 		_FillSizer->Show( true );
-printf("EED wxManualPaintPanel::OnTool 8\n");
 		_brushSizer->Show( false );
-printf("EED wxManualPaintPanel::OnTool 9\n");
 		this->Layout( );
-printf("EED wxManualPaintPanel::OnTool 10\n");
 	}
 }
 
@@ -552,11 +536,13 @@ void wxManualPaintPanel::OnRedo( wxCommandEvent &event )
 void wxManualPaintPanel::onBarrange( wxCommandEvent& event )
 {
 }
+
 void wxManualPaintPanel::onActualChange_Bar( wxCommandEvent& event )
 {
 	/*mbbtkSliderMinMax->bbSetOutputOutActual(modBarRange->GetActual());
 	 mbbtkSliderMinMax->bbSignalOutputModification(std::string("OutActual"));*/
 }
+
 void wxManualPaintPanel::onStartChange_Bar( wxCommandEvent& event )
 {
 	SetRangeMin( _mBarSlices->GetStart( ) );