Salome HOME
Merge from V6_main 01/04/2013
[modules/visu.git] / src / VISU_I / VISU_Table_i.hh
index 5863cf2880b60ff56c557b22c8ac567aff18eb57..d8e753cd7ebe917175867c5314e4b7139dee93af 100644 (file)
-//  Copyright (C) 2003  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
 //
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  VISU OBJECT : interactive object for VISU entities implementation
 //  File   : VISU_Table_i.hh
 //  Author : Vadim SANDLER
 //  Module : VISU
-
+//
 #ifndef VISU_Table_i_HeaderFile
 #define VISU_Table_i_HeaderFile
 
 #include "VISU_PrsObject_i.hh"
-#include <qstringlist.h>
-#include "Plot2d_Curve.h"
 
-namespace VISU{
+#include <QStringList>
+#include <QSet>
+#include <QMap>
+
+class SPlot2d_Curve;
+
+namespace VISU {
+  typedef enum {NoneDvtn = 0, 
+                AbsoluteDvtn,               // min, max
+                PercentageDvtn,             // min%, max%
+                ErrorDvtn,                  // errmin, errmax
+                ErrorPercentageDvtn,        // errmin%, errmax%
+                SimpleErrorDvtn,            // error
+                SimpleErrorPercentageDvtn   // error%
+               } DeviationType;
+
+  class VISU_I_EXPORT DeviationData {
+  public:
+    DeviationData(){
+      _minRow = -1;_maxRow = -1;
+      _minType = NoneDvtn;_maxType = NoneDvtn;
+    }
+    DeviationData(const int minC, const int maxC, 
+                  const DeviationType minT, const DeviationType maxT) {
+           _minRow = minC; _maxRow = maxC;
+           _minType = minT ; _maxType = maxT;
+    }
+    int minRow() const {return _minRow;}
+    int maxRow() const {return _maxRow;}
+    DeviationType minDeviation() const {return _minType;}
+    DeviationType maxDeviation() const {return _maxType;}
+
+  private:
+    int _minRow;
+    int _maxRow;
+    DeviationType _minType;
+    DeviationType _maxType;
+  };
+
+  typedef QMap<int, DeviationData> DeviationMap;
+
   //==============================================================================
-  class Table_i : public virtual POA_VISU::Table,
+  class VISU_I_EXPORT Table_i : public virtual POA_VISU::Table,
                   public virtual PrsObject_i
   {
     static int myNbPresent;
-    Table_i();
     Table_i( const Table_i& );
   public:
     Table_i( SALOMEDS::Study_ptr theStudy, const char* theObject );
     virtual ~Table_i();
     virtual VISU::VISUType GetType() { return VISU::TTABLE;};
 
-    virtual void SetTitle( const char* theName ) { SetName( theName ); }
-    virtual char* GetTitle() { return CORBA::string_dup( GetName() ); }
+    virtual void SetTitle( const char* theTitle );
+    virtual char* GetTitle();
 
-    virtual void SetOrientation( VISU::Table::Orientation theOrientation ) { myOrientation = theOrientation; }
-    virtual VISU::Table::Orientation GetOrientation() { return myOrientation; }
+    virtual void SetOrientation( VISU::Table::Orientation theOrientation );
+    virtual VISU::Table::Orientation GetOrientation();
 
     virtual CORBA::Long GetNbRows();
     virtual CORBA::Long GetNbColumns();
 
+    virtual void SortRow(CORBA::Long theRow, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy);
+    virtual void SortColumn(CORBA::Long theColumn, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy);
+    virtual void SortByRow(CORBA::Long theRow, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy);
+    virtual void SortByColumn(CORBA::Long theColumn, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy);
+
+    virtual bool            hasDeviationData(const int);
+    virtual bool            isDeviationRow(const int);
+    virtual DeviationData*  getDeviationInfo(const int);
+    virtual void RemoveFromStudy();
+
   protected:
     Storable* Build(int theRestoring);
+    void      UpdateCurves(std::map<int, int> theMixData);
+    void      BuildDeviationMap();
 
   protected:
     VISU::Table::Orientation myOrientation;
-    string myTitle;
-    string myObjectEntry;
+    std::string myTitle;
+    SALOMEDS::SObject_var mySObj;
+    DeviationMap          myDeviationMap;
 
   public:
     virtual Storable* Create();
-    virtual Storable* Restore( const Storable::TRestoringMap& theMap )
-      throw(std::logic_error&);
+    SALOMEDS::SObject_var GetSObject() const;
+
+    virtual Storable* Restore( const Storable::TRestoringMap& theMap,
+                              SALOMEDS::SObject_ptr SO);
+
+    static Storable* StorableEngine(SALOMEDS::SObject_ptr theSObject,
+                                   const Storable::TRestoringMap& theMap,
+                                   const std::string& thePrefix,
+                                   CORBA::Boolean theIsMultiFile);
+
+    static bool parseTitle(const QString theTitle, 
+                           QString& theOutTitle,
+                           DeviationType& theType, 
+                           bool& isMin);
+
+    static double calculateDeviation(DeviationType theType, double value,double deviationValue, bool isMin);
+
+    static QString deviationLabel(DeviationData* );
+
     virtual void ToStream( std::ostringstream& theStr );
-    static const string myComment;
+    static const std::string myComment;
     virtual const char* GetComment() const;
-    virtual const char* GenerateName();
-    virtual const char* GetTableTitle();
+    virtual QString GenerateName();
+    virtual QString GetTableTitle();
 
-    virtual char* GetObjectEntry() { return CORBA::string_dup( myObjectEntry.c_str() ); }
+    virtual std::string GetObjectEntry();
   };
-  Storable* TableRestore(SALOMEDS::SObject_ptr theSObject, 
-                        const string& thePrefix, const Storable::TRestoringMap& theMap);
-  SALOMEDS::SObject_var ImportTables(const char* theFileName, SALOMEDS::Study_ptr theStudy);
-
+  SALOMEDS::SObject_var ImportTables(const char* theFileName, SALOMEDS::Study_ptr theStudy,
+                                     bool theFirstStrAsTitle = false);
+  bool ExportTableToFile(SALOMEDS::SObject_ptr theTable, const char* theFileName);
   //==============================================================================
-  class Curve_i : public virtual POA_VISU::Curve,
+
+  typedef QSet<QString> ContainerSet;
+
+  class VISU_I_EXPORT Curve_i : public virtual POA_VISU::Curve,
                   public virtual PrsObject_i
   {
     static int myNbPresent;
     Curve_i();
     Curve_i( const Curve_i& );
   public:
-    Curve_i( SALOMEDS::Study_ptr theStudy, Table_i* theTable, CORBA::Long theHRow, CORBA::Long theVRow );
+    Curve_i( SALOMEDS::Study_ptr theStudy, Table_i* theTable,
+            CORBA::Long theHRow, CORBA::Long theVRow, CORBA::Long theZRow,
+             CORBA::Boolean theIsV2 );
     virtual ~Curve_i();
     virtual VISU::VISUType GetType() { return VISU::TCURVE;};
 
-    virtual void SetTitle( const char* theName ) { SetName( theName ); }
-    virtual char* GetTitle() { return CORBA::string_dup( GetName() ); }
+    virtual void SetTitle( const char* theTitle );
+    virtual char* GetTitle();
 
-    virtual void SetColor( const SALOMEDS::Color& theColor ) { myColor = theColor; myAuto = false; }
-    virtual SALOMEDS::Color GetColor() { return myColor; }
-    
-    virtual void SetMarker( VISU::Curve::MarkerType theType ) { myMarker = theType; myAuto = false; }
-    virtual VISU::Curve::MarkerType GetMarker() { return myMarker; }
+    virtual void SetColor( const SALOMEDS::Color& theColor );
+    virtual SALOMEDS::Color GetColor();
+
+    virtual void SetMarker( VISU::Curve::MarkerType theType );
+    virtual VISU::Curve::MarkerType GetMarker();
+
+    virtual void SetLine( VISU::Curve::LineType theType, CORBA::Long theWidth );
+    virtual VISU::Curve::LineType GetLine();
+    virtual CORBA::Long GetLineWidth();
+
+    virtual void SetScale( CORBA::Double theCoef );
+    virtual CORBA::Double GetScale();
+    virtual void RemoveScale();
+
+    virtual void addContainer(const QString& id);
+    virtual void removeContainer(const QString& id);
+    virtual ContainerSet getContainers() const;
+
+    virtual void RemoveFromStudy();
 
-    virtual void SetLine( VISU::Curve::LineType theType, CORBA::Long theWidth ) 
-                                                { myLine = theType; myLineWidth = theWidth; myAuto = false; }
-    virtual VISU::Curve::LineType GetLine() { return myLine; }
-    virtual CORBA::Long GetLineWidth() { return myLineWidth; }
+    virtual SALOMEDS::SObject_var GetSObject();
+
+    virtual void ShowDeviation(CORBA::Boolean);
+    virtual bool isDeviationShown();
+    virtual bool hasDeviation();
 
   protected:
     Storable* Build(int theRestoring);
@@ -92,38 +197,63 @@ namespace VISU{
     Table_i*                myTable;
     int                     myHRow;
     int                     myVRow;
+    int                     myZRow;
+    bool                    myIsV2;
+    double                  myScale;
     struct SALOMEDS::Color  myColor;
     VISU::Curve::MarkerType myMarker;
     VISU::Curve::LineType   myLine;
     int                     myLineWidth;
-    string                  myTitle;
+    std::string             myTitle;
     bool                    myAuto;
+    SALOMEDS::SObject_var   mySObj;
+    ContainerSet            myContainers;
+    bool                    myDeviationEnabled;
 
   public:
     virtual Storable* Create();
-    virtual Storable* Restore( const Storable::TRestoringMap& theMap )
-      throw(std::logic_error&);
+    
+    Table_i* getTable() const {return myTable;}
+
+    int  GetHRow() const { return myHRow; }
+    void SetHRow( const int theHRow ) { myHRow = theHRow; }
+
+    int  GetVRow() const { return myVRow; }
+    void SetVRow( const int theVRow ) { myVRow = theVRow; }
+
+    int  GetZRow() const { return myZRow; }
+    void SetZRow( const int theZRow ) { myZRow = theZRow; }
+
+    int  GetIsV2() const { return myIsV2; }
+    void SetIsV2( const int theIsV2 ) { myIsV2 = theIsV2; }
+
+    virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr theSO);
+
+    static Storable* StorableEngine(SALOMEDS::SObject_ptr theSObject,
+                                   const Storable::TRestoringMap& theMap,
+                                   const std::string& thePrefix,
+                                   CORBA::Boolean theIsMultiFile);
+
     virtual void ToStream( std::ostringstream& theStr );
-    static const string myComment;
+    static const std::string myComment;
     virtual const char* GetComment() const;
-    virtual const char* GenerateName();
-    virtual const char* GetTableID();
+    virtual QString GenerateName();
+    virtual std::string GetTableID();
 
     virtual CORBA::Boolean IsAuto() { return myAuto; }
     virtual CORBA::Boolean IsValid();
-    virtual string GetHorTitle();
-    virtual string GetVerTitle();
-    virtual string GetHorUnits();
-    virtual string GetVerUnits();
-    virtual int    GetData( double*& theHorList, double*& theVerList );
+    virtual std::string GetHorTitle();
+    virtual std::string GetVerTitle();
+    virtual std::string GetHorUnits();
+    virtual std::string GetVerUnits();
+    virtual int GetData( double*& theHorList, double*& theVerList, QStringList& );
+    virtual int GetDeviationData( double*& theMin, double*& theMax, QList<int>& );
 
-    virtual Plot2d_Curve* CreatePresentation();
+    virtual SPlot2d_Curve* CreatePresentation();
   };
-  Storable* CurveRestore(SALOMEDS::SObject_ptr theSObject, 
-                        const string& thePrefix, const Storable::TRestoringMap& theMap);
 
   //==============================================================================
-  class Container_i : public virtual POA_VISU::Container,
+  class VISU_I_EXPORT Container_i : public virtual POA_VISU::Container,
                       public virtual PrsObject_i
   {
     static int myNbPresent;
@@ -140,28 +270,35 @@ namespace VISU{
     virtual CORBA::Long GetNbCurves();
     virtual void Clear();
 
+    virtual void RemoveFromStudy();
+
+    virtual SALOMEDS::SObject_var GetSObject();
+
   protected:
     Storable* Build(int theRestoring);
-    
+
   protected:
     QStringList myCurves;
-    
+    SALOMEDS::SObject_var mySObj;
+
   public:
     virtual Storable* Create();
-    virtual Storable* Restore( const Storable::TRestoringMap& theMap )
-      throw(std::logic_error&);
+    virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO );
+
+    static Storable* StorableEngine(SALOMEDS::SObject_ptr theSObject,
+                                   const Storable::TRestoringMap& theMap,
+                                   const std::string& thePrefix,
+                                   CORBA::Boolean theIsMultiFile);
+
     virtual void ToStream( std::ostringstream& theStr );
-    static const string myComment;
+    static const std::string myComment;
     virtual const char* GetComment() const;
-    virtual const char* GenerateName();
+    virtual QString GenerateName();
 
     void Update();
     VISU::Curve_i* GetCurve( CORBA::Long theIndex );
 
   };
-  Storable* ContainerRestore(SALOMEDS::SObject_ptr theSObject, 
-                            const string& thePrefix, const Storable::TRestoringMap& theMap);
 }
-#endif // (#ifndef VISU_Table_i_HeaderFile)
-
 
+#endif