-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef PartSet_PreviewSketchPlane_H
#define PartSet_PreviewSketchPlane_H
-#include <GeomAPI_AISObject.h>
-
#include <GeomAPI_Pnt.h>
-#include <GeomAPI_Dir.h>
-#include <GeomAPI_AISObject.h>
+
+class GeomAPI_AISObject;
+class GeomAPI_Shape;
class ModuleBase_IWorkshop;
class ModelAPI_CompositeFeature;
+#include <memory>
+
/**
* \class PartSet_PreviewSketchPlane
* \ingroup Modules
~PartSet_PreviewSketchPlane() {};
- /// Returns if the sketch plane was displayed
- /// \return boolean value
- bool isSketchDisplayed() const { return mySketchDisplayed; }
-
- /// Sets parameters of another sketch to be used in createSketchPlane().
- /// \param theOtherSketchFace a shape of other selected sketch. It is a planar face.
- void setOtherSketchParameters(const std::shared_ptr<GeomAPI_Shape>& theOtherSketchFace);
-
/// Erase preview planes
/// \param theWorkshop the application workshop
/// \param isClearPlane flag whether the plane, origin and normal should be nullified
void createSketchPlane(const std::shared_ptr<ModelAPI_CompositeFeature>& theSketch,
ModuleBase_IWorkshop* theWorkshop);
- /// Resize plane size by sketch content
- /// \param theSketch source sketch to build sketch sub features bounding box
- /// \param theWorkshop the application workshop
- void updatePlaneSize(const std::shared_ptr<ModelAPI_CompositeFeature>& theSketch,
- ModuleBase_IWorkshop* theWorkshop);
+ /// Returns bounding box size covered the sketch sub-elements.
+ /// If the sketch uses extenal face, it will not have default size and returns false.
+ /// \param theSketch sources sketch
+ /// \param [out] theSizeOfView maximum value in X, Y or Z direction
+ /// \param theCentralPoint central point of the sketch sub features
+ /// \return boolean value
+ bool getDefaultSizeOfView(const std::shared_ptr<ModelAPI_CompositeFeature>& theSketch,
+ double& theSizeOfView,
+ std::shared_ptr<GeomAPI_Pnt>& theCentralPnt);
+
+ /// Returns whether custom size of view is set
+ /// \return boolean value
+ bool isUseSizeOfView() const { return myIsUseSizeOfView; }
+
+ /// Sets the size of default created face
+ /// \param theSizeOfView value
+ /// \param isUseSizeOfView state whether the size should be used
+ void setSizeOfView(double theSizeOfView, bool isUseSizeOfView,
+ const std::shared_ptr<GeomAPI_Pnt>& theCentralPoint = std::shared_ptr<GeomAPI_Pnt>());
+
+ /// Returns True if the plane preview is already created
+ bool isPlaneCreated() const {
+ return myPlane.get();
+ }
+
+ /// Returns current state of the plane preview visibility
+ bool isDisplayed() const { return myPreviewIsDisplayed; }
+
+ /// Displays preview planes
+ /// \param theWorkshop the application workshop
+ void displaySketchPlane(ModuleBase_IWorkshop* theWorkshop);
+
+ /// Nullyfies current plane preview object.
+ /// Important: Before call of this function the plane has to be erased from viewer
+ void clearPlanePreview();
private:
/// Create a square face by parameters
- /// \param theSize a size of created square
- AISObjectPtr createPreviewPlane(double theSize);
-
- /// Finds origin and maximum size of the shape
- /// \param theShape source shape
- /// \param theOrigin a shape center of mass
- /// \param theSize maximum of delta X, Y or Z
- void getShapeParameters(const std::shared_ptr<GeomAPI_Shape>& theShape,
- std::shared_ptr<GeomAPI_Pnt>& theOrigin,
- double& theSize);
-
- /// Calculate maximum bounding box size of sketch sub features
- /// \param theSketch source sketch to build sketch sub features bounding box
- /// \param theCentralPoint central point of the sketch sub features
- /// \return double value
- double getSketchBoundingBoxSize(const std::shared_ptr<ModelAPI_CompositeFeature>& theSketch,
- std::shared_ptr<GeomAPI_Pnt>& theCentralPnt);
+ std::shared_ptr<GeomAPI_AISObject> createPreviewPlane();
private:
- bool mySketchDisplayed;
- AISObjectPtr myPlane;
- std::shared_ptr<GeomAPI_Pnt> myOrigin; //! an origin of the plane
- std::shared_ptr<GeomAPI_Dir> myNormal; //! a normal vector of the plane
-
- std::shared_ptr<GeomAPI_Pnt> myOtherSketchOrigin;
- double myOtherSketchSize;
+ bool myPreviewIsDisplayed;
+ std::shared_ptr<GeomAPI_AISObject> myPlane; //! visualized presentation
+ std::shared_ptr<GeomAPI_Shape> myShape; //! current shape to be displayed
+ std::shared_ptr<GeomAPI_Pnt> myViewCentralPoint; //! central point of the default view
+
+ double mySizeOfView; //! size that should be used by creating a default face
+ bool myIsUseSizeOfView; //! state if the size is custom or from preferences
+ std::shared_ptr<GeomAPI_Pnt> myViewOrigin; //! origin point of sketch if default view is used
};
#endif
\ No newline at end of file