From 1bf58cfa1758464b422d1d0cca808e528043e691 Mon Sep 17 00:00:00 2001
From: Eduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Date: Thu, 7 May 2009 15:35:46 +0000
Subject: [PATCH] BUG histogram

---
 .../widgets/pPlotter/HistogramWidget.cxx      | 26 ++++++++++++-------
 .../widgets/pPlotter/pGraphicalFunction.cxx   | 25 ++++++++++--------
 .../widgets/pPlotter/pPlotterWindow.cxx       | 13 +++++++---
 .../wxWindows/widgets/wxMPRBaseData.cxx       |  1 -
 .../wxWindows/widgets/wxMPRWidget.cxx         | 19 +++++++++++---
 .../widgets/wxMaracas_ViewerWidget.cxx        |  7 ++---
 6 files changed, 57 insertions(+), 34 deletions(-)

diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramWidget.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramWidget.cxx
index 8466cda..affe13c 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramWidget.cxx
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramWidget.cxx
@@ -145,6 +145,7 @@ HistogramWidget::HistogramWidget( wxWindow *parent, wxWindowID id, const wxPoint
 			yValues[4]=0;
 			
 			pGraphicalFunction * tf = plotter ->getFunctionForVectors( xValues, 5, yValues, 5 ); 
+		printf("EED %p HistogramWidget::drawTransferenceFunction %p\n", this , tf);		
 			// Including and drawing the created function in the plotter
 			if (tf)
 			{
@@ -266,8 +267,12 @@ HistogramWidget::HistogramWidget( wxWindow *parent, wxWindowID id, const wxPoint
 	*/
 	bool  HistogramWidget::addPointToTransferenceFunction(double x, double y)
 	{
+		bool result=false;
 		pGraphicalFunction* tf=plotter->getFunction(idTransferenceFunction);
-		return tf->AddPoint(x,y);
+printf("EED %p HistogramWidget::addPointToTransferenceFunction tp%p x%f y%f %d\n",this, tf, x ,y, idTransferenceFunction);
+		if (tf!=NULL) { result=tf->AddPoint(x,y); }
+		
+		return result;
 	}
 	/*
 		add a color point to the histogram
@@ -294,15 +299,16 @@ HistogramWidget::HistogramWidget( wxWindow *parent, wxWindowID id, const wxPoint
 		{
 			// we have to erase the points
 			pGraphicalFunction* tf=plotter->getFunction(idTransferenceFunction);
-			int numOfPoints=tf->getSizePoints();
-			int i=numOfPoints-1;//-2;
-			while(i>=0)
-			{
-				tf->deletePointAt(i);
-				i--;
-			}
-			
-		}
+			if (tf!=NULL){
+				int numOfPoints=tf->getSizePoints();
+				int i=numOfPoints-1;//-2;
+				while(i>=0)
+				{
+					tf->deletePointAt(i);
+					i--;
+				} // while
+			} // if tf
+		} // if transferenceFunctionHasPoints
 		
 	//we set for actual the histogram
 		//plotter->setActual()
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.cxx
index b04e17c..0eed1ed 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.cxx
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.cxx
@@ -159,15 +159,18 @@ bool pGraphicalFunction:: AddNewPoint(int x,int y)
 */
 bool pGraphicalFunction::AddPoint(int aX, int aY,bool order) 
 {	
-	
-	bool added=logicFunction -> AddPoint( aX, aY,order );
-	if(!fromWindow)
-	 setUp();
-	else
-	{
-		logicFunction->setEndPoints();
-		logicFunction->setStartPoints();
-	}
+	printf("EED %p pGraphicalFunction::AddPoint %p (%d %d) \n", this, logicFunction, aX, aY);	
+	bool added=false;
+	if (logicFunction!=NULL){
+		added=logicFunction -> AddPoint( aX, aY,order );
+		if(!fromWindow)
+			setUp();
+		else
+		{
+			logicFunction->setEndPoints();
+			logicFunction->setStartPoints();
+		} // if fromWindow
+	} // if logicFunction
 	return added;
 }
 
@@ -822,7 +825,7 @@ void pGraphicalFunction :: setColorPoints(std::vector<pColorPoint *> &colorVecto
 {
 	f_colorPoints.clear();
 	int i = 0;	
-	while(i<colorVector.size())
+	while(i<(int)(colorVector.size()))
 	{
 		f_colorPoints.push_back(colorVector[i]);		
 		i++;
@@ -836,7 +839,7 @@ void pGraphicalFunction :: setColorPoints(std::vector<pColorPoint *> &colorVecto
 void pGraphicalFunction :: getColorPoints(std::vector<pColorPoint *> &colorVector)
 {
 	int i = 0;	
-	while(i<f_colorPoints.size())
+	while(i<(int)(f_colorPoints.size()))
 	{
 		pColorPoint * originaslPoint = f_colorPoints[i];
 		pColorPoint * copyPoint = new pColorPoint(originaslPoint->getRealX(), originaslPoint->getColor(), originaslPoint->isTemporalColor());
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterWindow.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterWindow.cxx
index 7635f60..5bc7148 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterWindow.cxx
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterWindow.cxx
@@ -1387,10 +1387,15 @@ int pPlotterWindow:: addFunction(pGraphicalFunction * function)
 		function->initializeSplineVectors();
 		UpdateAll();
 	}
-	// bool added1= functions.Append(function)!=NULL; // JPRx
+	
+//	bool added1= functions.Append(function)!=NULL; // JPRx
+	functions.Append(function);  //EED	
 	
 	int id=functions.IndexOf(function);
-	/* bool added2= */ AddLayer(function);// JPRx
+	
+	// bool added2=  AddLayer(function);// JPRx
+	AddLayer(function); //EED
+	 
 	UpdateAll();
 	return id;//added1 && added2;
 }
@@ -1799,7 +1804,9 @@ void pPlotterWindow::moveFunctions( float porcentageMinX,float porcentageMaxX)
 */
 int pPlotterWindow::addFunctionToMove(pGraphicalFunction *function)
 {
-	// bool added1=  functionsToMove.Append(function)!=NULL; // JPRx
+	//bool added1=  functionsToMove.Append(function)!=NULL; // JPRx
+	functionsToMove.Append(function); // EED
+	
 	int id=functionsToMove.IndexOf(function);
 	UpdateAll();
 	return id;
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.cxx
index f3217a2..a46feff 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.cxx
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.cxx
@@ -341,7 +341,6 @@ void vtkMPR3DDataViewer::Refresh()
 	int x = (int)(_vtkmprbasedata->GetX());
 	int y = (int)(_vtkmprbasedata->GetY());
 	int z = (int)(_vtkmprbasedata->GetZ());
-	std::cout<<" vtkMPR3DDataViewer::Refresh() x="<<x<<" y= "<<y<<" z= "<<z;
 	SetPositionX( x );
 	SetPositionY( y );
 	SetPositionZ( z );
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRWidget.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRWidget.cxx
index f0a7040..da7729e 100644
--- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRWidget.cxx
+++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRWidget.cxx
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: wxMPRWidget.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/05/04 15:06:42 $
-  Version:   $Revision: 1.12 $
+  Date:      $Date: 2009/05/07 15:35:46 $
+  Version:   $Revision: 1.13 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -2687,6 +2687,13 @@ void wxVtkMPR3DViewCntrlPanel::OnEditColorTable(wxCommandEvent& event)
 	std::vector<double> *ctfunVectorGreen	= this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorGreen();
 	std::vector<double> *ctfunVectorBlue	=   this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorBlue();
 
+	printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfun %p\n", this, ctfun);	
+	printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfunVectorPoint %p\n", this, ctfunVectorPoint);	
+	printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfunVectorRed %p\n", this, ctfunVectorRed);	
+	printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfunVectorGreen %p\n", this, ctfunVectorGreen);	
+	printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfunVectorBlue %p\n", this, ctfunVectorBlue);	
+
+	
 	//void *p=this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer(); // JPRx
 
 
@@ -3383,6 +3390,8 @@ void wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& event)
 	std::vector<double>* bctf		= this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetBlueColorsOfColorTransferenceFVector();
 	vtkImageData *imagedata	= this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
 
+	
+	
 	//use for update in the refresh
 	/*
 	vtkVolumeRayCastMapper* volumeMapper = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVolumeMapper();
@@ -3612,10 +3621,12 @@ void wxVtkMPR3DView::ResetCamera(int* ext, double* origin,double* spc){
 }
 void wxVtkMPR3DView::Configure(){
 
-
 	_wxvtk3Dbaseview->Configure();
 	_wxvtkmpr3DviewCntrlPanel->UpdateControlPanel();
-	_wxvtk3Dbaseview->GetRenderer()->Clear();		
+	
+//EED ??????  07Mai2009	
+//	_wxvtk3Dbaseview->GetRenderer()->Clear();		
+	
 	
 	// Actors are added to the renderer. 
 	vtkActor* _outlineActor = _vtkmpr3Ddataviewer->GetOutlineActor();
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx
index 5d3233f..f9822d1 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/05/04 07:35:42 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2009/05/07 15:35:46 $
+  Version:   $Revision: 1.11 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -146,11 +146,8 @@
 
 			mwxvtkmpr3Dview							= new wxVtkMPR3DView( mwxvtk3Dbaseview_Clipping3D );
 
-
 			vtkmpr3Ddataviewer	= new vtkMPR3DDataViewer(); 	
 
-			
-
 			wxWindow	*window3D					= mwxvtk3Dbaseview_Clipping3D->GetWxVTKRenderWindowInteractor();
 
 			wxPanel			*panelControl			= new wxPanel(panelClipping3D,-1);	
-- 
2.49.0