1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef PartSet_PreviewSketchPlane_H
22 #define PartSet_PreviewSketchPlane_H
24 #include <GeomAPI_AISObject.h>
26 #include <GeomAPI_Pnt.h>
27 #include <GeomAPI_Dir.h>
28 #include <GeomAPI_AISObject.h>
30 class ModuleBase_IWorkshop;
31 class ModelAPI_CompositeFeature;
34 * \class PartSet_PreviewSketchPlane
36 * A class to show/hide sketch preview plane
38 class PartSet_PreviewSketchPlane
42 PartSet_PreviewSketchPlane();
44 ~PartSet_PreviewSketchPlane() {};
46 /// Returns if the sketch plane was displayed
47 /// \return boolean value
48 bool isSketchDisplayed() const { return mySketchDisplayed; }
50 /// Sets parameters of another sketch to be used in createSketchPlane().
51 /// \param theOtherSketchFace a shape of other selected sketch. It is a planar face.
52 void setOtherSketchParameters(const std::shared_ptr<GeomAPI_Shape>& theOtherSketchFace);
54 /// Erase preview planes
55 /// \param theWorkshop the application workshop
56 /// \param isClearPlane flag whether the plane, origin and normal should be nullified
57 void eraseSketchPlane(ModuleBase_IWorkshop* theWorkshop, const bool isClearPlane = true);
59 /// Show preview planes
60 /// \param theSketch source sketch to initialize plane
61 /// \param theWorkshop the application workshop
62 void createSketchPlane(const std::shared_ptr<ModelAPI_CompositeFeature>& theSketch,
63 ModuleBase_IWorkshop* theWorkshop);
65 /// Resize plane size by sketch content
66 /// \param theSketch source sketch to build sketch sub features bounding box
67 /// \param theWorkshop the application workshop
68 void updatePlaneSize(const std::shared_ptr<ModelAPI_CompositeFeature>& theSketch,
69 ModuleBase_IWorkshop* theWorkshop);
72 /// Create a square face by parameters
73 /// \param theSize a size of created square
74 AISObjectPtr createPreviewPlane(double theSize);
76 /// Finds origin and maximum size of the shape
77 /// \param theShape source shape
78 /// \param theOrigin a shape center of mass
79 /// \param theSize maximum of delta X, Y or Z
80 void getShapeParameters(const std::shared_ptr<GeomAPI_Shape>& theShape,
81 std::shared_ptr<GeomAPI_Pnt>& theOrigin,
84 /// Calculate maximum bounding box size of sketch sub features
85 /// \param theSketch source sketch to build sketch sub features bounding box
86 /// \param theCentralPoint central point of the sketch sub features
87 /// \return double value
88 double getSketchBoundingBoxSize(const std::shared_ptr<ModelAPI_CompositeFeature>& theSketch,
89 std::shared_ptr<GeomAPI_Pnt>& theCentralPnt);
92 bool mySketchDisplayed;
94 std::shared_ptr<GeomAPI_Pnt> myOrigin; //! an origin of the plane
95 std::shared_ptr<GeomAPI_Dir> myNormal; //! a normal vector of the plane
97 std::shared_ptr<GeomAPI_Pnt> myOtherSketchOrigin;
98 double myOtherSketchSize;