Salome HOME
Copyright update 2022
[modules/shaper.git] / src / PartSet / PartSet_PreviewPlanes.h
1 // Copyright (C) 2014-2022  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef PartSet_PreviewPlanes_H
21 #define PartSet_PreviewPlanes_H
22
23 #include <GeomAPI_AISObject.h>
24
25 #include <GeomAPI_Pnt.h>
26 #include <GeomAPI_Dir.h>
27 #include <GeomAPI_AISObject.h>
28
29 class ModuleBase_IWorkshop;
30
31 /**
32 * \class PartSet_PreviewPlanes
33 * \ingroup Modules
34 * A class to show/hide sketch preview planes
35 */
36 class PartSet_PreviewPlanes
37 {
38 public:
39   /// Constructor
40   PartSet_PreviewPlanes();
41
42   ~PartSet_PreviewPlanes() {};
43
44   /// Returns true if there is body visualized in the viewer
45   /// \param theWorkshop the application workshop
46   /// \return boolean value
47   static bool hasVisualizedBodies(ModuleBase_IWorkshop* theWorkshop);
48
49   /// Returns true if there is at least one Sketch visualized in the viewer
50   /// \param theWorkshop the application workshop
51   /// \return boolean value
52   static bool hasVisualizedSketch(ModuleBase_IWorkshop* theWorkshop);
53
54   /// Returns if the preview was displayed
55   /// \return boolean value
56   bool isPreviewDisplayed() const { return myPreviewDisplayed; }
57
58   /// Returns true if the shape is one of the preview shapes
59   /// \param theShape a shape to be checked
60   /// \return boolean value
61   bool isPreviewShape(std::shared_ptr<GeomAPI_Shape> theShape);
62
63   /// Erase preview planes
64   /// \param theWorkshop the application workshop
65   void erasePreviewPlanes(ModuleBase_IWorkshop* theWorkshop);
66
67   /// Show preview planes
68   /// \param theWorkshop the application workshop
69   void showPreviewPlanes(ModuleBase_IWorkshop* theWorkshop);
70
71 private:
72      /// Create preview of planes for sketch plane selection
73    /// \param theOrigin an origin of the plane
74    /// \param theNorm a normal vector of the plane
75    /// \param theRGB a color of plane presentation [r, g, b] array
76   AISObjectPtr createPreviewPlane(std::shared_ptr<GeomAPI_Pnt> theOrigin,
77                                   std::shared_ptr<GeomAPI_Dir> theNorm,
78                                   const int theRGB[3]);
79
80 private:
81   bool myPreviewDisplayed;
82
83   AISObjectPtr myYZPlane;
84   AISObjectPtr myXZPlane;
85   AISObjectPtr myXYPlane;
86 };
87
88 #endif