From 4cc8c16ebb603620382420596473b1fa9d72747c Mon Sep 17 00:00:00 2001
From: Baptiste Mouginot <mouginot.baptiste@gmail.com>
Date: Thu, 24 Apr 2014 16:09:43 +0000
Subject: [PATCH] Adding XML format

git-svn-id: svn+ssh://svn.in2p3.fr/class@238 0e7d625b-0364-4367-a6be-d5be4a48d228
---
 gui/trunk/CLASSRead.cxx | 11 +++---
 gui/trunk/CLASSRead.hxx |  2 +-
 gui/trunk/CLASSWin.cxx  | 76 +++++++++++++++++++++++++++++++++++++++++
 gui/trunk/CLASSWin.hxx  |  1 +
 4 files changed, 82 insertions(+), 8 deletions(-)

diff --git a/gui/trunk/CLASSRead.cxx b/gui/trunk/CLASSRead.cxx
index 89076c007..dbad7e57d 100755
--- a/gui/trunk/CLASSRead.cxx
+++ b/gui/trunk/CLASSRead.cxx
@@ -824,7 +824,7 @@ void CLASSRead::ASCIIWrite(string filename)
 //________________________________________________________________________
 //________________________________________________________________________
 //________________________________________________________________________
-void CLASSRead::ConvertxmlTTreeMass(vector<CLASSPlotElement> toplot, string opt)
+void CLASSRead::ConvertxmlTTreeMass(vector<CLASSPlotElement> toplot, string filename)
 {
 
 
@@ -834,7 +834,6 @@ void CLASSRead::ConvertxmlTTreeMass(vector<CLASSPlotElement> toplot, string opt)
 
 
 
-	string out = opt;
 	Long64_t nentries = fData[toplot[0].fTreeId]->GetEntries();
 
 
@@ -1030,7 +1029,7 @@ void CLASSRead::ConvertxmlTTreeMass(vector<CLASSPlotElement> toplot, string opt)
 
 
 	// Beginning of the document XML
-	ofstream f ("test.xml");
+	ofstream f (filename.c_str());
 	cout << f.is_open();
 	if (!f.is_open())
 		cout << "Impossible d'ouvrir le fichier en ecriture !" << endl;
@@ -1212,7 +1211,7 @@ void CLASSRead::ConvertxmlTTreeMass(vector<CLASSPlotElement> toplot, string opt)
 }
 
 //________________________________________________________________________
-void CLASSRead::ConvertXmlMass(vector<CLASSPlotElement> toplot, string opt)
+void CLASSRead::ConvertXmlMass(vector<CLASSPlotElement> toplot, string filename)
 {
 	
 	vector<CLASSPlotElement> toplotTTree[fData.size()];
@@ -1225,12 +1224,10 @@ void CLASSRead::ConvertXmlMass(vector<CLASSPlotElement> toplot, string opt)
 		toplotTTree[toplot[i].fTreeId].push_back(toplot[i]);
 	}
 	
-	string out = opt;
 	for (int i = 0; i < (int)fData.size(); i++)
 	{
-		if(i == 1) out += " same";
 		if(toplotTTree[i].size() !=0)
-			ConvertxmlTTreeMass(toplotTTree[i], out);
+			ConvertxmlTTreeMass(toplotTTree[i], filename);
 		
 	}
 }
diff --git a/gui/trunk/CLASSRead.hxx b/gui/trunk/CLASSRead.hxx
index 7573a2c4e..ef7e78994 100755
--- a/gui/trunk/CLASSRead.hxx
+++ b/gui/trunk/CLASSRead.hxx
@@ -60,7 +60,7 @@ public :
 	void PlotPower(vector<CLASSPlotElement> toplot, string opt = "L");
 	void PlotTTreePower(vector<CLASSPlotElement> toplot, string opt = "L");
 
-	void ConvertxmlTTreeMass(vector<CLASSPlotElement> toplot, string opt = "L");
+	void ConvertxmlTTreeMass(vector<CLASSPlotElement> toplot, string filename);
 	void ConvertXmlMass(vector<CLASSPlotElement> toplot, string opt = "L");           
 	void ConvertxmlTTreePower(vector<CLASSPlotElement> toplotPower, string opt = "L");
 	void ConvertXmlPower(vector<CLASSPlotElement> toplotPower, string opt = "L");     
diff --git a/gui/trunk/CLASSWin.cxx b/gui/trunk/CLASSWin.cxx
index e346e6691..7463be2eb 100755
--- a/gui/trunk/CLASSWin.cxx
+++ b/gui/trunk/CLASSWin.cxx
@@ -444,6 +444,82 @@ void MainWin::Plot()
 		fDATA->Plot(toplot);
 	
 }
+void MainWin::Conversionxml()
+{
+	int Nnucleus = fDATA->GetZAIvector().size();
+
+	vector<CLASSPlotElement> toplot;
+	vector<CLASSPlotElement> toplotPower;
+
+	for(int i=0; i < fNumberOfParc; i++)
+	{
+
+		for(int j=0; j < fNumberOfTOT-1; j++) //fNumberOfTOT -1 ?? ->All except power
+		{
+			if(fCheckArrayTotal[i][j]->GetState()==kButtonDown)
+				for(int k=0; k < Nnucleus; k++)
+				{
+					if(fCheckArrayNuc[k]->GetState()==kButtonDown)
+						toplot.push_back( CLASSPlotElement(i, 0, j,0, fDATA->GetZAIvector()[k]));
+				}
+		}
+
+		for(int j=0; j < fNumberOfReactor[i]; j++)
+		{
+			if(fCheckArrayReactor[i][j]->GetState()==kButtonDown)
+			{
+				for(int l =0;l<3;l++)
+					if (fCheckIVPlot[l]->GetState()==kButtonDown)
+						for(int k=0; k < Nnucleus; k++)
+						{
+							if(fCheckArrayNuc[k]->GetState()==kButtonDown)
+								toplot.push_back( CLASSPlotElement(i, 1, j,l, fDATA->GetZAIvector()[k]));
+						}
+			}
+		}
+
+		for(int j=0; j < fNumberOfStock[i]; j++)
+		{
+			if(fCheckArrayStock[i][j]->GetState()==kButtonDown)
+				for(int l =0;l<3;l++)
+					if (fCheckIVPlot[l]->GetState()==kButtonDown)
+						for(int k=0; k < Nnucleus; k++)
+						{
+							if(fCheckArrayNuc[k]->GetState()==kButtonDown)
+								toplot.push_back( CLASSPlotElement(i, 2, j,l, fDATA->GetZAIvector()[k]));
+						}
+		}
+
+		for(int j=0; j < fNumberOfPool[i]; j++)
+		{
+			if(fCheckArrayPool[i][j]->GetState()==kButtonDown)
+				for(int l =0;l<3;l++)
+					if (fCheckIVPlot[l]->GetState()==kButtonDown)
+						for(int k=0; k < Nnucleus; k++)
+						{
+							if(fCheckArrayNuc[k]->GetState()==kButtonDown)
+								toplot.push_back( CLASSPlotElement(i, 3, j,l, fDATA->GetZAIvector()[k]));
+						}
+		}
+
+		for(int j=0; j < fNumberOfFab[i]; j++)
+		{
+			if(fCheckArrayFab[i][j]->GetState()==kButtonDown)
+				for(int l =0;l<3;l++)
+					if (fCheckIVPlot[l]->GetState()==kButtonDown)
+						for(int k=0; k < Nnucleus; k++)
+						{
+							if(fCheckArrayNuc[k]->GetState()==kButtonDown)
+								toplot.push_back( CLASSPlotElement(i, 4, j,l, fDATA->GetZAIvector()[k]));
+						}
+		}
+	}
+
+	if(toplot.size() != 0)
+		fDATA->ConvertXmlMass(toplot);
+	
+}
+
 //_____________________________________________________________________________________________
 void MainWin::FillNucTab()		// fill the Inventory Tab foil
 {
diff --git a/gui/trunk/CLASSWin.hxx b/gui/trunk/CLASSWin.hxx
index e4f233df4..723dcd978 100755
--- a/gui/trunk/CLASSWin.hxx
+++ b/gui/trunk/CLASSWin.hxx
@@ -73,6 +73,7 @@ public:
 	bool ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2); //@- widget signal handler method
 	void CloseWindow();			//@- destroy the main window
 	void Plot();				//@- general Plot method
+        void Conversionxml();                   //@- general Conversionxml method
 
 
 	void FillItemTab(int i);
-- 
GitLab