Salome HOME
Redisplay sketch features only for the active sketch (on appearance of the "Fully...
[modules/shaper.git] / src / PartSet / PartSet_PreviewPlanes.h
1 // Copyright (C) 2014-2017  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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef PartSet_PreviewPlanes_H
22 #define PartSet_PreviewPlanes_H
23
24 #include <GeomAPI_AISObject.h>
25
26 #include <GeomAPI_Pnt.h>
27 #include <GeomAPI_Dir.h>
28 #include <GeomAPI_AISObject.h>
29
30 class ModuleBase_IWorkshop;
31
32 /**
33 * \class PartSet_PreviewPlanes
34 * \ingroup Modules
35 * A class to show/hide sketch preview planes
36 */
37 class PartSet_PreviewPlanes
38 {
39 public:
40   /// Constructor
41   PartSet_PreviewPlanes();
42
43   ~PartSet_PreviewPlanes() {};
44
45   /// Returns true if there is body visualized in the viewer
46   /// \param theWorkshop the application workshop
47   /// \return boolean value
48   static bool hasVisualizedBodies(ModuleBase_IWorkshop* theWorkshop);
49
50   /// Returns true if there is at least one Sketch visualized in the viewer
51   /// \param theWorkshop the application workshop
52   /// \return boolean value
53   static bool hasVisualizedSketch(ModuleBase_IWorkshop* theWorkshop);
54
55   /// Returns if the preview was displayed
56   /// \return boolean value
57   bool isPreviewDisplayed() const { return myPreviewDisplayed; }
58
59   /// Returns true if the shape is one of the preview shapes
60   /// \param theShape a shape to be checked
61   /// \return boolean value
62   bool isPreviewShape(std::shared_ptr<GeomAPI_Shape> theShape);
63
64   /// Erase preview planes
65   /// \param theWorkshop the application workshop
66   void erasePreviewPlanes(ModuleBase_IWorkshop* theWorkshop);
67
68   /// Show preview planes
69   /// \param theWorkshop the application workshop
70   void showPreviewPlanes(ModuleBase_IWorkshop* theWorkshop);
71
72 private:
73      /// Create preview of planes for sketch plane selection
74    /// \param theOrigin an origin of the plane
75    /// \param theNorm a normal vector of the plane
76    /// \param theRGB a color of plane presentation [r, g, b] array
77   AISObjectPtr createPreviewPlane(std::shared_ptr<GeomAPI_Pnt> theOrigin,
78                                   std::shared_ptr<GeomAPI_Dir> theNorm,
79                                   const int theRGB[3]);
80
81 private:
82   bool myPreviewDisplayed;
83
84   AISObjectPtr myYZPlane;
85   AISObjectPtr myXZPlane;
86   AISObjectPtr myXYPlane;
87 };
88
89 #endif