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_Pnt.h>
26 class GeomAPI_AISObject;
29 class ModuleBase_IWorkshop;
30 class ModelAPI_CompositeFeature;
35 * \class PartSet_PreviewSketchPlane
37 * A class to show/hide sketch preview plane
39 class PartSet_PreviewSketchPlane
43 PartSet_PreviewSketchPlane();
45 ~PartSet_PreviewSketchPlane() {};
47 /// Erase preview planes
48 /// \param theWorkshop the application workshop
49 /// \param isClearPlane flag whether the plane, origin and normal should be nullified
50 void eraseSketchPlane(ModuleBase_IWorkshop* theWorkshop, const bool isClearPlane = true);
52 /// Show preview planes
53 /// \param theSketch source sketch to initialize plane
54 /// \param theWorkshop the application workshop
55 void createSketchPlane(const std::shared_ptr<ModelAPI_CompositeFeature>& theSketch,
56 ModuleBase_IWorkshop* theWorkshop);
58 /// Returns bounding box size covered the sketch sub-elements.
59 /// If the sketch uses extenal face, it will not have default size and returns false.
60 /// \param theSketch sources sketch
61 /// \param [out] theSizeOfView maximum value in X, Y or Z direction
62 /// \param theCentralPoint central point of the sketch sub features
63 /// \return boolean value
64 bool getDefaultSizeOfView(const std::shared_ptr<ModelAPI_CompositeFeature>& theSketch,
65 double& theSizeOfView,
66 std::shared_ptr<GeomAPI_Pnt>& theCentralPnt);
68 /// Returns whether custom size of view is set
69 /// \return boolean value
70 bool isUseSizeOfView() const { return myIsUseSizeOfView; }
72 /// Sets the size of default created face
73 /// \param theSizeOfView value
74 /// \param isUseSizeOfView state whether the size should be used
75 void setSizeOfView(double theSizeOfView, bool isUseSizeOfView,
76 const std::shared_ptr<GeomAPI_Pnt>& theCentralPoint = std::shared_ptr<GeomAPI_Pnt>());
79 /// Create a square face by parameters
80 std::shared_ptr<GeomAPI_AISObject> createPreviewPlane();
83 bool myPreviewIsDisplayed;
84 std::shared_ptr<GeomAPI_AISObject> myPlane; //! visualized presentation
85 std::shared_ptr<GeomAPI_Shape> myShape; //! current shape to be displayed
86 std::shared_ptr<GeomAPI_Pnt> myViewCentralPoint; //! central point of the default view
88 double mySizeOfView; //! size that should be used by creating a default face
89 bool myIsUseSizeOfView; //! state if the size is custom or from preferences
90 std::shared_ptr<GeomAPI_Pnt> myViewOrigin; //! origin point of sketch if default view is used