1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: SketchPlugin_ConstraintAngle.h
4 // Created: 19 August 2015
5 // Author: Artem ZHIDKOV
7 #ifndef SketchPlugin_ConstraintAngle_H_
8 #define SketchPlugin_ConstraintAngle_H_
10 #include "SketchPlugin.h"
11 #include <SketchPlugin_Sketch.h>
12 #include "SketchPlugin_ConstraintBase.h"
14 /** \class SketchPlugin_ConstraintAngle
16 * \brief Feature for creation of a new constraint fix angle between two lines
18 * This constraint has two attributes:
19 * SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B()
21 class SketchPlugin_ConstraintAngle : public SketchPlugin_ConstraintBase
24 /// Angle constraint kind
25 inline static const std::string& ID()
27 static const std::string MY_CONSTRAINT_ANGLE_ID("SketchConstraintAngle");
28 return MY_CONSTRAINT_ANGLE_ID;
30 /// \brief Returns the kind of a feature
31 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
33 static std::string MY_KIND = SketchPlugin_ConstraintAngle::ID();
37 /// attribute name of operation type
38 inline static const std::string& TYPE_ID()
40 static const std::string MY_TYPE_ID("AngleType");
44 /// attribute name of operation type
45 inline static const std::string& ANGLE_VALUE_ID()
47 static const std::string MY_ANGLE_VALUE_ID("AngleValue");
48 return MY_ANGLE_VALUE_ID;
51 /// attribute name indicating the first line is reversed
52 inline static const std::string& ANGLE_REVERSED_FIRST_LINE_ID()
54 static const std::string MY_ANGLE_REVERSED_ID("AngleReversedLine1");
55 return MY_ANGLE_REVERSED_ID;
57 /// attribute name indicating the second line is reversed
58 inline static const std::string& ANGLE_REVERSED_SECOND_LINE_ID()
60 static const std::string MY_ANGLE_REVERSED_ID("AngleReversedLine2");
61 return MY_ANGLE_REVERSED_ID;
64 /// \brief Creates a new part document if needed
65 SKETCHPLUGIN_EXPORT virtual void execute();
67 /// Computes the attribute value on the base of other attributes if the value can be computed
68 /// \param theAttributeId an attribute index to be computed
69 /// \return a boolean value about it is computed
70 SKETCHPLUGIN_EXPORT virtual bool compute(const std::string& theAttributeId);
72 /// \brief Request for initialization of data model of the feature: adding all attributes
73 SKETCHPLUGIN_EXPORT virtual void initAttributes();
75 /// Retuns the parameters of color definition in the resources config manager
76 SKETCHPLUGIN_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
77 std::string& theDefault);
79 /// Called on change of any argument-attribute of this object
80 /// \param theID identifier of changed attribute
81 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
83 /// Returns the AIS preview
84 SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
87 /// \param theDeltaX the delta for X coordinate is moved
88 /// \param theDeltaY the delta for Y coordinate is moved
89 SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
91 /// Calculate current value of the angle
92 double calculateAngle();
94 /// Converts the angle value according to the current angle type and sketch plane normal.
95 /// The in/out angle is in degree.
96 /// \param theAngle a source for the calculated angle
97 /// \param isPreviousValueObtuse a flag if obtuse should be processed
98 /// \param a double angle value
99 double getAngleForType(double theAngle, bool isPreviousValueObtuse = false);
101 /// Update value of VALUE attribute by the combination of the current angle type and angle value
102 void updateConstraintValueByAngleValue();
104 /// \brief Use plugin manager for features creation
105 SketchPlugin_ConstraintAngle();
108 bool myFlyoutUpdate; ///< to avoid cyclic dependencies on automatic updates of flyout point