SketchPlugin_ConstraintRigid.h
SketchPlugin_ConstraintHorizontal.h
SketchPlugin_ConstraintVertical.h
+ SketchPlugin_ConstraintEqual.h
SketchPlugin_ShapeValidator.h
SketchPlugin_Validators.h
SketchPlugin_ResultValidators.h
SketchPlugin_ConstraintRigid.cpp
SketchPlugin_ConstraintHorizontal.cpp
SketchPlugin_ConstraintVertical.cpp
+ SketchPlugin_ConstraintEqual.cpp
SketchPlugin_ShapeValidator.cpp
SketchPlugin_Validators.cpp
SketchPlugin_ResultValidators.cpp
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: SketchPlugin_ConstraintEqual.cpp
+// Created: 16 Mar 2015
+// Author: Artem ZHIDKOV
+
+#include "SketchPlugin_ConstraintEqual.h"
+
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_ResultConstruction.h>
+
+#include <SketchPlugin_Line.h>
+#include <SketchPlugin_Sketch.h>
+
+#include <SketcherPrs_Factory.h>
+
+#include <Config_PropManager.h>
+
+SketchPlugin_ConstraintEqual::SketchPlugin_ConstraintEqual()
+{
+}
+
+void SketchPlugin_ConstraintEqual::initAttributes()
+{
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+}
+
+void SketchPlugin_ConstraintEqual::execute()
+{
+}
+
+AISObjectPtr SketchPlugin_ConstraintEqual::getAISObject(AISObjectPtr thePrevious)
+{
+ if (!sketch())
+ return thePrevious;
+
+ AISObjectPtr anAIS = thePrevious;
+ /// TODO: Equal constraint presentation should be put here
+ return anAIS;
+}
+
+
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: SketchPlugin_ConstraintEqual.h
+// Created: 16 Mar 2015
+// Author: Artem ZHIDKOV
+
+#ifndef SketchPlugin_ConstraintEqual_H_
+#define SketchPlugin_ConstraintEqual_H_
+
+#include "SketchPlugin.h"
+#include <SketchPlugin_Sketch.h>
+#include "SketchPlugin_ConstraintBase.h"
+
+/** \class SketchPlugin_ConstraintEqual
+ * \ingroup Plugins
+ * \brief Feature for creation of a new constraint specifying equality of lengths of two lines
+ * or equality of radii of two circular arcs (full circles)
+ *
+ * This constraint has two attributes:
+ * SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B()
+ */
+class SketchPlugin_ConstraintEqual : public SketchPlugin_ConstraintBase
+{
+ public:
+ /// Equal constraint kind
+ inline static const std::string& ID()
+ {
+ static const std::string MY_CONSTRAINT_EQUAL_ID("SketchConstraintEqual");
+ return MY_CONSTRAINT_EQUAL_ID;
+ }
+ /// \brief Returns the kind of a feature
+ SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = SketchPlugin_ConstraintEqual::ID();
+ return MY_KIND;
+ }
+
+ /// \brief Creates a new part document if needed
+ SKETCHPLUGIN_EXPORT virtual void execute();
+
+ /// \brief Request for initialization of data model of the feature: adding all attributes
+ SKETCHPLUGIN_EXPORT virtual void initAttributes();
+
+ /// Returns the AIS preview
+ SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
+
+ /// \brief Use plugin manager for features creation
+ SketchPlugin_ConstraintEqual();
+};
+
+#endif
#include <SketchPlugin_Arc.h>
#include <SketchPlugin_ConstraintCoincidence.h>
#include <SketchPlugin_ConstraintDistance.h>
+#include <SketchPlugin_ConstraintEqual.h>
#include <SketchPlugin_ConstraintHorizontal.h>
#include <SketchPlugin_ConstraintLength.h>
#include <SketchPlugin_ConstraintParallel.h>
return FeaturePtr(new SketchPlugin_ConstraintHorizontal);
} else if (theFeatureID == SketchPlugin_ConstraintVertical::ID()) {
return FeaturePtr(new SketchPlugin_ConstraintVertical);
+ } else if (theFeatureID == SketchPlugin_ConstraintEqual::ID()) {
+ return FeaturePtr(new SketchPlugin_ConstraintEqual);
}
// feature of such kind is not found
return FeaturePtr();
aMsg->setState(SketchPlugin_ConstraintRigid::ID(), aHasSketchPlane);
aMsg->setState(SketchPlugin_ConstraintHorizontal::ID(), aHasSketchPlane);
aMsg->setState(SketchPlugin_ConstraintVertical::ID(), aHasSketchPlane);
+ aMsg->setState(SketchPlugin_ConstraintEqual::ID(), aHasSketchPlane);
}
}
return aMsg;
<group id="Basic">
<feature
id="Sketch"
- nested="SketchPoint SketchLine SketchCircle SketchArc SketchConstraintLength SketchConstraintRadius SketchConstraintDistance SketchConstraintParallel SketchConstraintPerpendicular SketchConstraintRigid SketchConstraintHorizontal SketchConstraintVertical"
+ nested="SketchPoint SketchLine SketchCircle SketchArc SketchConstraintLength SketchConstraintRadius SketchConstraintDistance SketchConstraintParallel SketchConstraintPerpendicular SketchConstraintRigid SketchConstraintHorizontal SketchConstraintVertical SketchConstraintEqual"
when_nested="accept abort"
title="Sketch"
tooltip="Create a new sketch"
<selection_filter id="EdgeFilter" parameters="line"/>
</sketch_constraint_shape_selector>
</feature>
+ <!-- SketchConstraintEqual -->
+ <feature id="SketchConstraintEqual" title="Equal" tooltip="Create constraint defining equality of two objects">
+ <sketch_constraint_shape_selector id="ConstraintEntityA"
+ label="First object" tooltip="Select line, circle or arc" shape_types="edge">
+ </sketch_constraint_shape_selector>
+
+ <sketch_constraint_shape_selector id="ConstraintEntityB"
+ label="Last object" tooltip="Select line, circle or arc" shape_types="edge">
+ </sketch_constraint_shape_selector>
+ </feature>
</group>
</workbench>
</plugin>
#include <SketchPlugin_Arc.h>
#include <SketchPlugin_ConstraintCoincidence.h>
#include <SketchPlugin_ConstraintDistance.h>
+#include <SketchPlugin_ConstraintEqual.h>
#include <SketchPlugin_ConstraintHorizontal.h>
#include <SketchPlugin_ConstraintLength.h>
#include <SketchPlugin_ConstraintParallel.h>
return getType();
}
+ if (aConstraintKind.compare(SketchPlugin_ConstraintEqual::ID()) == 0)
+ {
+ static const int aConstrType[3] = {
+ SLVS_C_EQUAL_RADIUS,
+ SLVS_C_EQUAL_LINE_ARC_LEN,
+ SLVS_C_EQUAL_LENGTH_LINES
+ };
+ int aNbLines = 0;
+ int aNbEntities = 2; // lines and circles in SolveSpace constraints should start from SketchPlugin_Constraint::ENTITY_C() attribute
+ for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++) {
+ std::shared_ptr<ModelAPI_Attribute> anAttr =
+ aConstrData->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr));
+ AttrType aType = typeOfAttribute(anAttr);
+ if (aType == LINE)
+ {
+ myAttributesList[aNbEntities++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
+ aNbLines++;
+ }
+ else if (aType == CIRCLE || aType == ARC)
+ myAttributesList[aNbEntities++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
+ }
+ if (aNbEntities == 4)
+ myType = aConstrType[aNbLines];
+ return getType();
+ }
+
/// \todo Implement other kind of constraints
return getType();