Salome HOME
Final version of "Profile interpolation".
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Displayer.h
1 // Copyright (C) 2007-2015  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, or (at your option) any later version.
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
24 #ifndef HYDROGUI_DISPLAYER_H
25 #define HYDROGUI_DISPLAYER_H
26
27 #include "HYDROGUI_AbstractDisplayer.h"
28
29 #include <QMap>
30 #include <QPoint>
31 #include <vtkNew.h>
32
33 class HYDROGUI_PrsDriver;
34 class SUIT_ViewWindow;
35 class vtkWorldPointPicker;
36
37 /**
38  * \class HYDROGUI_Displayer
39  * \brief Class intended to create, display and update the presentations in 2D graphics viewer.
40  */
41 class HYDROGUI_Displayer : public HYDROGUI_AbstractDisplayer
42 {
43 public:
44   /**
45    * \brief Constructor.
46    * \param theModule module object
47    */
48   HYDROGUI_Displayer( HYDROGUI_Module* theModule );
49
50   /**
51    * \brief Destructor.
52    */
53   virtual ~HYDROGUI_Displayer();
54
55 public:
56   /**
57    * \brief Force the specified objects to be updated.
58    * \param theObjs sequence of objects to update
59    * \param theViewerId viewer identifier
60    */
61   void             SetToUpdate( const HYDROData_SequenceOfObjects& theObjs,
62                                 const int theViewerId );
63
64   /**
65    * \brief Get the applicable viewer type.
66    */
67   virtual QString  GetType() const;
68
69   /*
70    * Get the current cursor view position and save it in the displayer
71    * to be used in the obtaining the view coordinates of the cursor.
72    * \param theViewWindow a view window. If a view window is null, an active view is used
73    * only OCC and VTK views are processed
74    */
75   void             SaveCursorViewPosition( SUIT_ViewWindow* theViewWindow = 0 );
76   /**
77    * \brief Get the coodinates from the view window, projected on XOY plane
78    * \param theViewWindow a view window
79    * \param theXCoordinate a X coordinate
80    * \param theXCoordinate an Y coordinate
81    * \param theXCoordinate a Z coordinate, has a zero value because of the plane
82    * \return true if the coordinates are got
83    */
84   bool             GetCursorViewCoordinates( SUIT_ViewWindow* theViewWindow,
85                                              double& theXCoordinate,
86                                              double& theYCoordinate,
87                                              double& theZCoordinate );
88 protected:
89   /**
90    * \brief Erase all viewer objects.
91    * \param theViewerId viewer identifier
92    */
93   void             EraseAll( const int theViewerId );
94
95   /**
96    * \brief Erase the specified viewer objects.
97    * \param theObjs sequence of objects to erase
98    * \param theViewerId viewer identifier
99    */
100   void             Erase( const HYDROData_SequenceOfObjects& theObjs,
101                           const int theViewerId );
102
103   /**
104    * \brief Display the specified viewer objects.
105    * \param theObjs sequence of objects to display
106    * \param theViewerId viewer identifier
107    * \param theIsForced flag used to update all objects, including the unchanged ones
108    * \param theDoFitAll flag used to fit the view to all visible objects; do not fit by default
109    */
110   void             Display( const HYDROData_SequenceOfObjects& theObjs,
111                             const int theViewerId,
112                             const bool theIsForced,
113                             const bool theDoFitAll );
114
115 protected:
116   /**
117    * \brief Purge all invalid objects in the viewer.
118    * \param theViewerId viewer identifier
119    */
120   void             purgeObjects( const int theViewerId );
121
122 private:
123   /**
124    * \brief Get the presentation driver for the specified data object.
125    * \param theObj data object
126    */
127   HYDROGUI_PrsDriver*             getDriver( const Handle(HYDROData_Entity)& theObj );
128
129 private:
130   typedef QMap< ObjectKind, HYDROGUI_PrsDriver* > PrsDriversMap;
131   PrsDriversMap                   myPrsDriversMap;
132   vtkNew<vtkWorldPointPicker>     myPicker;
133   int                             myXPosition;
134   int                             myYPosition;
135   bool                            myIsPositionSaved;
136 };
137
138 #endif