]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Constraint for distance between two features is added
authorazv <artem.zhidkov@opencascade.com>
Fri, 23 May 2014 12:29:31 +0000 (16:29 +0400)
committerazv <artem.zhidkov@opencascade.com>
Fri, 23 May 2014 12:31:08 +0000 (16:31 +0400)
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_ConstraintDistance.h [new file with mode: 0644]
src/SketchPlugin/plugin-Sketch.xml

index 60fb882c0c186e5f45047274c60be0088e2799d4..ee4d7da0a22919669f46434ea3f48ff3ce8dff78 100644 (file)
@@ -9,6 +9,7 @@ SET(PROJECT_HEADERS
     SketchPlugin_Point.h
     SketchPlugin_Constraint.h
     SketchPlugin_ConstraintCoincidence.h
+    SketchPlugin_ConstraintDistance.h
 )
 
 SET(PROJECT_SOURCES
@@ -18,6 +19,7 @@ SET(PROJECT_SOURCES
     SketchPlugin_Line.cpp
     SketchPlugin_Point.cpp
     SketchPlugin_ConstraintCoincidence.cpp
+    SketchPlugin_ConstraintDistance.cpp
 )
 
 SET(PROJECT_LIBRARIES
index 57e95f5ba0260ea0e4b68fb0ec9368552f40a4dc..1c5f2adf37c7f437c787c343f7826df9b416adbd 100644 (file)
@@ -14,7 +14,8 @@
  *  \ingroup DataModel
  *  \brief Feature for creation of a new constraint which defines equivalence of two points
  *
- *  These constraint has two attributes: CONSTRAINT_ATTR_POINT_A and CONSTRAINT_ATTR_POINT_B
+ *  These constraint has two attributes:
+ *  CONSTRAINT_ATTR_ENTITY_A and CONSTRAINT_ATTR_ENTITY_B
  */
 class SketchPlugin_ConstraintCoincidence: public SketchPlugin_Constraint
 {
diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
new file mode 100644 (file)
index 0000000..57f7b62
--- /dev/null
@@ -0,0 +1,31 @@
+// File:    SketchPlugin_ConstraintDistance.cpp
+// Created: 23 May 2014
+// Author:  Artem ZHIDKOV
+
+#include "SketchPlugin_ConstraintDistance.h"
+
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_Data.h>
+#include <SketchPlugin_Point.h>
+
+SketchPlugin_ConstraintDistance::SketchPlugin_ConstraintDistance()
+{
+}
+
+void SketchPlugin_ConstraintDistance::initAttributes()
+{
+  data()->addAttribute(CONSTRAINT_ATTR_VALUE,    ModelAPI_AttributeDouble::type());
+  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type());
+}
+
+void SketchPlugin_ConstraintDistance::execute()
+{
+}
+
+const boost::shared_ptr<GeomAPI_Shape>&  SketchPlugin_ConstraintDistance::preview()
+{
+  /// \todo Preview for distance constraint
+  return getPreview();
+}
+
diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h
new file mode 100644 (file)
index 0000000..4295e8c
--- /dev/null
@@ -0,0 +1,45 @@
+// File:    SketchPlugin_ConstraintDistance.h
+// Created: 23 May 2014
+// Author:  Artem ZHIDKOV
+
+#ifndef SketchPlugin_ConstraintDistance_HeaderFile
+#define SketchPlugin_ConstraintDistance_HeaderFile
+
+#include "SketchPlugin.h"
+#include "SketchPlugin_Constraint.h"
+#include <list>
+
+
+/** \class SketchPlugin_ConstraintDistance
+ *  \ingroup DataModel
+ *  \brief Feature for creation of a new constraint which defines a distance
+ *         between a point and another feature (point, line, plane or face)
+ *
+ *  These constraint has three attributes:
+ *  CONSTRAINT_ATTR_VALUE, CONSTRAINT_ATTR_ENTITY_A and CONSTRAINT_ATTR_ENTITY_B
+ */
+class SketchPlugin_ConstraintDistance: public SketchPlugin_Constraint
+{
+public:
+  /// \brief Returns the kind of a feature
+  SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
+  {static std::string MY_KIND = "SketchConstraintDistance"; return MY_KIND;}
+
+  /// \brief Returns to which group in the document must be added feature
+  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
+  {static std::string MY_GROUP = "Sketch"; return MY_GROUP;}
+
+  /// \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();
+
+  /// \brief Returns the sketch preview
+  SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
+
+  /// \brief Use plugin manager for features creation
+  SketchPlugin_ConstraintDistance();
+};
+
+#endif
index 706d85f3b1ae8258e016209da1e57b83403f6f9e..443ad5327cbf5ec6298bc6cfe0ddae46eef1c7c5 100644 (file)
@@ -11,6 +11,7 @@
         <point_selector id="EndPoint" title="End point" tooltip="End point of the line"/>
       </feature>
       <feature id="SketchConstraintCoincidence" title="Points coincidence" tooltip="Create constraint for the coincidence of two points" internal="1"/>
+      <feature id="SketchConstraintDistance" title="Distance between objects" tooltip="Create constraint for the distance from a point to an object" internal="1"/>
     </group>
   </workbench>
 </plugin>