Salome HOME
Merge remote-tracking branch 'remotes/origin/BR_2017' into HEAD
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_AISTrihedron.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
20 #ifndef HYDROGUI_AISTRIHEDRON_H
21 #define HYDROGUI_AISTRIHEDRON_H
22
23 #include <AIS_Trihedron.hxx>
24 #include <Prs3d_LineAspect.hxx>
25
26 #include <gp_Pnt.hxx>
27 #include <gp_Dir.hxx>
28
29 /**
30  * \class HYDROGUI_AISTrihedron
31  * \brief AIS trihedron is redefined in order to show U text on the OX axis
32  * and Z text on the OY axis.
33  */
34
35 class HYDROGUI_AISTrihedron : public AIS_Trihedron
36 {
37 public:
38   /**
39    * The struct to contain axis parameters. Save them in order to do not extract them
40    * on each compute call
41    */
42   struct AxisParameters
43   {
44     gp_Pnt myPfirst; // the first point of the axis
45     gp_Pnt myPlast;  // the last point of the axis
46     Standard_Real myVal; // the axis length
47     Handle(Prs3d_LineAspect) myLineAspect; // the line aspect
48     gp_Dir myDir; // the axis direction
49     Standard_CString myText; // the axis text. This is the main parameter,
50                              // that leads to the trihedron redefine
51   };
52
53 public:
54   HYDROGUI_AISTrihedron( const Handle(Geom_Axis2Placement)& thePlacement );
55
56   ~HYDROGUI_AISTrihedron() {}
57
58   /**
59    * The static method to create filled trihedron. It makes some additional settings
60    * to the trihedron: resize and set color to the axis
61    */
62   static Handle(AIS_Trihedron) createTrihedron( double theSize );
63
64   /**
65    * Updates the internal axis parameters. Should be called after the axis parameters change
66    * e.g. axis resize
67    */
68   void SetAxis2Placement();
69
70   /**
71    * AIS trihedron compute method. It removes the parent compute functionality.
72    * It add to the presentation only oX, oY axis with the corrected text, that contains
73    * "U"/"Z" labels
74    * \param thePresentationManager the prs manager
75    * \param thePresentationManager the presentation
76    * \param theMode the mode
77    */
78   void Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
79                 const Handle(Prs3d_Presentation)& thePresentation, 
80                 const Standard_Integer theMode);
81
82   /**
83    * AIS trihedron compute method. It is empty. We do not apply the transformation.
84    * \param thePresentationManager the prs manager
85    * \param theTransformation the transformation
86    * \param thePresentationManager the presentation
87    */
88   void Compute( const Handle(Prs3d_Projector)& theProjector,
89                 const Handle(Geom_Transformation)& theTransformation,
90                 const Handle(Prs3d_Presentation)& thePresentation );
91
92   /**
93    * AIS trihedron compute selection method. It is empty. We do not select the trihedron
94    * \param theSelection the selection
95    * \param theMode the mode
96    */
97   void ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
98                          const Standard_Integer theMode );
99
100 private:
101   /**
102    * It adds the presentation to the DsgPrs_XYZAxisPresentation. It should be called in
103    * compute for displayed axis
104    * \param thePresentation the 3D presentation
105    * \param theParams the axis params, such as text, direction, stand and last points
106    */
107   void ComputeAxis( const Handle(Prs3d_Presentation)& thePresentation,
108                     const AxisParameters& theParams );
109   void ComputeFields();
110
111   AxisParameters myUParams; // the parameters for U axis
112   AxisParameters myZParams; // the parameters for Z axis
113 };
114
115
116 #endif