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