1 // Copyright (C) 2014-2019 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 email : webmaster.salome@opencascade.com
20 #ifndef PartSet_PreviewSketchPlane_H
21 #define PartSet_PreviewSketchPlane_H
23 #include <GeomAPI_Pnt.h>
25 class GeomAPI_AISObject;
28 class ModuleBase_IWorkshop;
29 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 /// Erase preview planes
47 /// \param theWorkshop the application workshop
48 /// \param isClearPlane flag whether the plane, origin and normal should be nullified
49 void eraseSketchPlane(ModuleBase_IWorkshop* theWorkshop, const bool isClearPlane = true);
51 /// Show preview planes
52 /// \param theSketch source sketch to initialize plane
53 /// \param theWorkshop the application workshop
54 void createSketchPlane(const std::shared_ptr<ModelAPI_CompositeFeature>& theSketch,
55 ModuleBase_IWorkshop* theWorkshop);
57 /// Returns bounding box size covered the sketch sub-elements.
58 /// If the sketch uses extenal face, it will not have default size and returns false.
59 /// \param theSketch sources sketch
60 /// \param [out] theSizeOfView maximum value in X, Y or Z direction
61 /// \param theCentralPoint central point of the sketch sub features
62 /// \return boolean value
63 bool getDefaultSizeOfView(const std::shared_ptr<ModelAPI_CompositeFeature>& theSketch,
64 double& theSizeOfView,
65 std::shared_ptr<GeomAPI_Pnt>& theCentralPnt);
67 /// Returns whether custom size of view is set
68 /// \return boolean value
69 bool isUseSizeOfView() const { return myIsUseSizeOfView; }
71 /// Sets the size of default created face
72 /// \param theSizeOfView value
73 /// \param isUseSizeOfView state whether the size should be used
74 void setSizeOfView(double theSizeOfView, bool isUseSizeOfView,
75 const std::shared_ptr<GeomAPI_Pnt>& theCentralPoint = std::shared_ptr<GeomAPI_Pnt>());
78 /// Create a square face by parameters
79 std::shared_ptr<GeomAPI_AISObject> createPreviewPlane();
82 bool myPreviewIsDisplayed;
83 std::shared_ptr<GeomAPI_AISObject> myPlane; //! visualized presentation
84 std::shared_ptr<GeomAPI_Shape> myShape; //! current shape to be displayed
85 std::shared_ptr<GeomAPI_Pnt> myViewCentralPoint; //! central point of the default view
87 double mySizeOfView; //! size that should be used by creating a default face
88 bool myIsUseSizeOfView; //! state if the size is custom or from preferences
89 std::shared_ptr<GeomAPI_Pnt> myViewOrigin; //! origin point of sketch if default view is used