Salome HOME
merge BR_hydro_v_1_0_4 on BR_quadtree
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_VTKPrsDisplayer.h
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef HYDROGUI_VTKPRSDISPLAYER_H
24 #define HYDROGUI_VTKPRSDISPLAYER_H
25
26 #include "HYDROGUI_AbstractDisplayer.h"
27 #include <vtkSmartPointer.h>
28 #include <vtkScalarBarActor.h>
29 #include <QMap>
30
31 class HYDROGUI_VTKPrsDriver;
32
33 /**
34  * \class HYDROGUI_VTKPrsDisplayer
35  * \brief Class intended to create, display and update the presentations in VTK viewer.
36  */
37 class HYDROGUI_VTKPrsDisplayer : public HYDROGUI_AbstractDisplayer
38 {
39 public:
40   /**
41    * \brief Constructor.
42    * \param theModule module object
43    */
44   HYDROGUI_VTKPrsDisplayer( HYDROGUI_Module* theModule );
45
46   /**
47    * \brief Destructor.
48    */
49   virtual ~HYDROGUI_VTKPrsDisplayer();
50
51   /**
52    * \brief Force the specified objects to be updated.
53    * \param theObjs sequence of objects to update
54    * \param theViewerId viewer identifier
55    */
56   void             SetToUpdate( const HYDROData_SequenceOfObjects& theObjs,
57                                 const int theViewerId );
58
59   /**
60    * \brief Get the applicable viewer type.
61    */
62   virtual QString  GetType() const;
63
64   /**
65    * \brief Set the range of Z values for the color legend bar.
66    */
67   void             SetZRange( const int theViewerId, double theRange[] );
68
69   /**
70    * \brief Get the range of Z values for the color legend bar.
71    */
72   double*          GetZRange( const int theViewerId ) const;
73
74   /**
75    * \brief Delete scalar bar for the given viewer id.
76    * \param theViewerId viewer identifier
77    */
78   void             EraseScalarBar( const int theViewerId, const bool theIsDelete = false );
79
80 protected:
81
82   virtual void     DisplayAll( const int theViewerId,
83                                const bool theIsForced,
84                                const bool theDoFitAll );
85
86   /**
87    * \brief Erase all viewer objects.
88    * \param theViewerId viewer identifier
89    */
90   void             EraseAll( const int theViewerId );
91
92   /**
93    * \brief Erase the specified viewer objects.
94    * \param theObjs sequence of objects to erase
95    * \param theViewerId viewer identifier
96    */
97   void             Erase( const HYDROData_SequenceOfObjects& theObjs,
98                           const int theViewerId );
99
100   /**
101    * \brief Display the specified viewer objects.
102    * \param theObjs sequence of objects to display
103    * \param theViewerId viewer identifier
104    * \param theIsForced flag used to update all objects, including the unchanged ones
105    * \param theDoFitAll flag used to fit the view to all visible objects; do not fit by default
106    */
107   void             Display( const HYDROData_SequenceOfObjects& theObjs,
108                             const int theViewerId,
109                             const bool theIsForced,
110                             const bool theDoFitAll );
111
112 protected:
113   /**
114    * \brief Purge all invalid objects in the viewer.
115    * \param theViewerId viewer identifier
116    */
117   void             purgeObjects( const int theViewerId );
118
119 private:
120
121   /**
122    * \brief Create a new scalar bar for the given view id.
123    * \param theViewId view identifier
124    */
125   void             createScalarBar( const int theViewId );
126
127   /**
128    * \brief Get the presentation driver for the specified data object.
129    * \param theObj data object
130    */
131   HYDROGUI_VTKPrsDriver* getDriver( const int theViewId, const Handle(HYDROData_Entity)& theObj );
132
133   HYDROGUI_VTKPrsDriver*       myDriver;
134   HYDROGUI_VTKPrsDriver*       myShapeDriver;
135
136   QMap<int, vtkSmartPointer<vtkScalarBarActor> > myScalarBars; //!< Colors legend presentations
137 };
138
139 #endif