1 // Copyright (C) 2014-2020 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 SketchPlugin_MacroRectangle_H_
21 #define SketchPlugin_MacroRectangle_H_
23 #include "SketchPlugin.h"
24 #include <SketchPlugin_SketchEntity.h>
25 #include <GeomAPI_IPresentable.h>
29 /**\class SketchPlugin_MacroRectangle
31 * \brief Feature for creation of the new Rectangle in Sketch.
33 class SketchPlugin_MacroRectangle: public SketchPlugin_SketchEntity,
34 public GeomAPI_IPresentable
37 /// Rectangle feature kind
38 inline static const std::string& ID()
40 static const std::string ID("SketchMacroRectangle");
44 inline static const std::string& RECTANGLE_TYPE_ID()
46 static const std::string ID("rectangle_type");
50 inline static const std::string& EDIT_RECTANGLE_TYPE_ID()
52 static const std::string ID("edit_rectangle_type");
56 inline static const std::string& START_END_POINT_TYPE_ID()
58 static const std::string ID("rectangle_type_by_start_and_end_points");
62 inline static const std::string& CENTER_END_POINT_TYPE_ID()
64 static const std::string ID("rectangle_type_by_center_and_end_points");
68 /// 2D point - start point of the Rectangle
69 inline static const std::string& START1_ID()
71 static const std::string ID("rectangle_start_point1");
75 inline static const std::string& START1_REF_ID()
77 static const std::string ID("rectangle_start_point1_ref");
81 /// 2D point - end point of the Rectangle
82 inline static const std::string& END1_ID()
84 static const std::string ID("rectangle_end_point1");
88 inline static const std::string& END1_REF_ID()
90 static const std::string ID("rectangle_end_point1_ref");
94 /// 2D point - start point of the second Rectangle type
95 inline static const std::string& END2_ID()
97 static const std::string ID("rectangle_end_point2");
101 inline static const std::string& END2_REF_ID()
103 static const std::string ID("rectangle_end_point2_ref");
107 /// 2D point - center point of the second Rectangle type
108 inline static const std::string& CENTER_ID()
110 static const std::string ID("rectangle_center_point");
113 /// Reference for center point selection.
114 inline static const std::string& CENTER_REF_ID()
116 static const std::string ID("rectangle_center_point_ref");
120 /// Returns the kind of a feature
121 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
123 static std::string MY_KIND = SketchPlugin_MacroRectangle::ID();
127 /// Called on change of any argument-attribute of this object
128 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
130 /// Creates a new part document if needed
131 SKETCHPLUGIN_EXPORT virtual void execute();
133 /// Use plugin manager for features creation
134 SketchPlugin_MacroRectangle();
136 SKETCHPLUGIN_EXPORT virtual bool isMacro() const
139 SKETCHPLUGIN_EXPORT virtual void initAttributes();
141 SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;}
143 /// Returns the AIS preview
144 virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
148 std::shared_ptr<GeomAPI_Pnt2d> myStartPoint;
149 std::shared_ptr<GeomAPI_Pnt2d> myEndPoint;
150 std::shared_ptr<GeomAPI_Pnt2d> myCenterPoint;
151 bool myHasCenterPoint;
154 FeaturePtr createRectangle();