From 00df19537a906618e3d2db26a49833040a7eb7ca Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 3 Feb 2012 18:04:08 +0000
Subject: [PATCH] better yet

---
 Fltk/onelabWindow.cpp  |  4 +++-
 Post/PView.cpp         |  5 ++++-
 Post/PViewData.h       |  3 +--
 Post/PViewDataList.cpp | 46 ++++++++++--------------------------------
 Post/PViewDataList.h   |  6 +-----
 5 files changed, 20 insertions(+), 44 deletions(-)

diff --git a/Fltk/onelabWindow.cpp b/Fltk/onelabWindow.cpp
index 548ec01145..eaeb2c0129 100644
--- a/Fltk/onelabWindow.cpp
+++ b/Fltk/onelabWindow.cpp
@@ -583,7 +583,9 @@ static bool updateOnelabGraph(const std::string &snum)
   }
   if(x.size() && y.size()){
     if(view){
-      view->getData()->setXY(xName, yName, x, y);
+      view->getData()->setXY(x, y);
+      view->getData()->setName(yName);
+      view->getOptions()->axesLabel[0] = xName;
       view->setChanged(true);
     }
     else{
diff --git a/Post/PView.cpp b/Post/PView.cpp
index 0832f5c488..99dd1084b2 100644
--- a/Post/PView.cpp
+++ b/Post/PView.cpp
@@ -84,7 +84,10 @@ PView::PView(const std::string &xname, const std::string &yname,
              std::vector<double> &x, std::vector<double> &y)
 {
   _init();
-  _data = new PViewDataList(xname, yname, x, y);
+  _data = new PViewDataList();
+  _data->setXY(x, y);
+  _data->setName(yname);
+  _data->setFileName(yname + ".pos");
   _options = new PViewOptions(PViewOptions::reference);
   _options->type = PViewOptions::Plot2D;
   _options->axes = 2;
diff --git a/Post/PViewData.h b/Post/PViewData.h
index 8dff3f040b..353d72532f 100644
--- a/Post/PViewData.h
+++ b/Post/PViewData.h
@@ -219,8 +219,7 @@ class PViewData {
   virtual bool combineSpace(nameData &nd);
 
   // set simple X-Y data
-  virtual void setXY(const std::string &xname, const std::string &yname,
-                     std::vector<double> &x, std::vector<double> &y){}
+  virtual void setXY(std::vector<double> &x, std::vector<double> &y){}
 
   // ask to fill vertex arrays remotely
   virtual bool isRemote(){ return false; }
diff --git a/Post/PViewDataList.cpp b/Post/PViewDataList.cpp
index e13867712e..80e3360757 100644
--- a/Post/PViewDataList.cpp
+++ b/Post/PViewDataList.cpp
@@ -11,43 +11,21 @@
 #include "SmoothData.h"
 #include "Context.h"
 
-void PViewDataList::_init(bool isAdapted)
+PViewDataList::PViewDataList(bool isAdapted)
+  : PViewData(), NbTimeStep(0), Min(VAL_INF), Max(-VAL_INF),
+    NbSP(0), NbVP(0), NbTP(0), NbSL(0), NbVL(0), NbTL(0),
+    NbST(0), NbVT(0), NbTT(0), NbSQ(0), NbVQ(0), NbTQ(0),
+    NbSS(0), NbVS(0), NbTS(0), NbSH(0), NbVH(0), NbTH(0),
+    NbSI(0), NbVI(0), NbTI(0), NbSY(0), NbVY(0), NbTY(0),
+    NbT2(0), NbT3(0), _lastElement(-1), _lastDimension(-1),
+    _lastNumNodes(-1), _lastNumComponents(-1), _lastNumValues(-1),
+    _lastNumEdges(-1), _lastType(-1), _lastXYZ(0), _lastVal(0),
+    _isAdapted(isAdapted)
 {
-  NbTimeStep = 0;
-  Min = VAL_INF;
-  Max = -VAL_INF;
-  NbSP = NbVP = NbTP = 0;
-  NbSL = NbVL = NbTL = 0;
-  NbST = NbVT = NbTT = 0;
-  NbSQ = NbVQ = NbTQ = 0;
-  NbSS = NbVS = NbTS = 0;
-  NbSH = NbVH = NbTH = 0;
-  NbSI = NbVI = NbTI = 0;
-  NbSY = NbVY = NbTY = 0;
-  NbT2 = NbT3 = 0;
-  _lastElement = _lastDimension = _lastNumNodes = -1;
-  _lastNumComponents = _lastNumValues = _lastNumEdges = -1;
-  _lastType = -1;
-  _lastXYZ = _lastVal = 0;
-  _isAdapted = isAdapted;
   for(int i = 0; i < 24; i++) _index[i] = 0;
 }
 
-PViewDataList::PViewDataList(bool isAdapted) : PViewData()
-{
-  _init(isAdapted);
-}
-
-PViewDataList::PViewDataList(const std::string &xname, const std::string &yname,
-                             std::vector<double> &x, std::vector<double> &y)
-  : PViewData()
-{
-  _init(false);
-  setXY(xname, yname, x, y);
-}
-
-void PViewDataList::setXY(const std::string &xname, const std::string &yname,
-                          std::vector<double> &x, std::vector<double> &y)
+void PViewDataList::setXY(std::vector<double> &x, std::vector<double> &y)
 {
   NbSP = 0;
   SP.clear();
@@ -58,8 +36,6 @@ void PViewDataList::setXY(const std::string &xname, const std::string &yname,
     SP.push_back(y[i]);
     NbSP++;
   }
-  setName(yname);
-  setFileName(yname + ".pos");
   finalize();
 }
 
diff --git a/Post/PViewDataList.h b/Post/PViewDataList.h
index fd1944dada..593285819f 100644
--- a/Post/PViewDataList.h
+++ b/Post/PViewDataList.h
@@ -48,7 +48,6 @@ class PViewDataList : public PViewData {
   int _lastNumNodes, _lastNumComponents, _lastNumValues, _lastNumEdges, _lastType;
   double *_lastXYZ, *_lastVal;
   bool _isAdapted;
-  void _init(bool isAdapted);
   void _stat(std::vector<double> &D, std::vector<char> &C, int nb);
   void _stat(std::vector<double> &list, int nbcomp, int nbelm, int nbnod, int type);
   void _setLast(int ele);
@@ -59,8 +58,6 @@ class PViewDataList : public PViewData {
   int _getRawData(int idxtype, std::vector<double> **l, int **ne, int *nc, int *nn);
  public:
   PViewDataList(bool isAdapted=false);
-  PViewDataList(const std::string &xname, const std::string &yname,
-                std::vector<double> &x, std::vector<double> &y);
   ~PViewDataList(){}
   bool isAdapted(){ return _isAdapted; }
   bool finalize(bool computeMinMax=true, const std::string &interpolationScheme="");
@@ -108,8 +105,7 @@ class PViewDataList : public PViewData {
   void smooth();
   bool combineTime(nameData &nd);
   bool combineSpace(nameData &nd);
-  void setXY(const std::string &xname, const std::string &yname,
-             std::vector<double> &x, std::vector<double> &y);
+  void setXY(std::vector<double> &x, std::vector<double> &y);
 
   // specific to list-based data sets
   void setOrder2(int type);
-- 
GitLab