]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
The references to the external edge attribute is added
authormpv <mikhail.ponikarov@opencascade.com>
Fri, 24 Oct 2014 07:48:03 +0000 (11:48 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Fri, 24 Oct 2014 07:48:03 +0000 (11:48 +0400)
src/Model/Model_AttributeSelection.cpp
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_Arc.h
src/SketchPlugin/SketchPlugin_Circle.cpp
src/SketchPlugin/SketchPlugin_Circle.h
src/SketchPlugin/SketchPlugin_Feature.h
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/SketchPlugin_Line.h
src/SketchPlugin/SketchPlugin_Point.cpp
src/SketchPlugin/SketchPlugin_Point.h

index f919cecd6e0d3ef9f75d6ecda22548d997f9a18b..9c71730a021a647bef420f490b566f0c6cdb8c29 100644 (file)
@@ -85,6 +85,7 @@ void Model_AttributeSelection::setObject(const boost::shared_ptr<ModelAPI_Object
 bool Model_AttributeSelection::update()
 {
   ResultPtr aContext = context();
+  if (!aContext) return false;
   if (aContext->groupName() == ModelAPI_ResultBody::group()) {
     // body: just a named shape, use selection mechanism from OCCT
     TNaming_Selector aSelector(myRef.myRef->Label());
index 21e616aef9b61b0e7fc846ede607cab03787eac6..ec9d227deec81d97d63e91b2eec985cee2d73a7b 100644 (file)
@@ -6,6 +6,8 @@
 #include "SketchPlugin_Sketch.h"
 #include <ModelAPI_Data.h>
 #include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_Validator.h>
 
 #include <GeomAPI_Circ2d.h>
 #include <GeomAPI_Pnt2d.h>
@@ -24,9 +26,11 @@ SketchPlugin_Arc::SketchPlugin_Arc()
 
 void SketchPlugin_Arc::initAttributes()
 {
-  data()->addAttribute(SketchPlugin_Arc::CENTER_ID(), GeomDataAPI_Point2D::type());
-  data()->addAttribute(SketchPlugin_Arc::START_ID(), GeomDataAPI_Point2D::type());
-  data()->addAttribute(SketchPlugin_Arc::END_ID(), GeomDataAPI_Point2D::type());
+  data()->addAttribute(CENTER_ID(), GeomDataAPI_Point2D::type());
+  data()->addAttribute(START_ID(), GeomDataAPI_Point2D::type());
+  data()->addAttribute(END_ID(), GeomDataAPI_Point2D::type());
+  data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
 }
 
 void SketchPlugin_Arc::execute()
@@ -138,3 +142,7 @@ double SketchPlugin_Arc::distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>&
 
   return aDelta;
 }
+
+bool SketchPlugin_Arc::isFixed() {
+  return data()->selection(EXTERNAL_ID())->context();
+}
index 00ada99b0c1f797dd497c6834a99521af2bf460d..3ee2ba8e714c0bfa2a271d89fea9ae1eb104d114 100644 (file)
@@ -50,6 +50,9 @@ class SketchPlugin_Arc : public SketchPlugin_Feature  //, public GeomAPI_IPresen
     return MY_KIND;
   }
 
+  /// Returns true is sketch element is under the rigid constraint
+  SKETCHPLUGIN_EXPORT virtual bool isFixed();
+
   /// Creates an arc-shape
   SKETCHPLUGIN_EXPORT virtual void execute();
 
index 635214f42fa39c3b70a7b92fcc0ce11aee90397e..4828a0f7b91a7b247e6e833caa30d6abaf493664 100644 (file)
@@ -6,6 +6,8 @@
 #include "SketchPlugin_Sketch.h"
 #include <ModelAPI_Data.h>
 #include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_Validator.h>
 
 #include <GeomAPI_Pnt2d.h>
 #include <GeomDataAPI_Point2D.h>
@@ -24,6 +26,8 @@ void SketchPlugin_Circle::initAttributes()
 {
   data()->addAttribute(SketchPlugin_Circle::CENTER_ID(), GeomDataAPI_Point2D::type());
   data()->addAttribute(SketchPlugin_Circle::RADIUS_ID(), ModelAPI_AttributeDouble::type());
+  data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
 }
 
 void SketchPlugin_Circle::execute()
@@ -98,3 +102,7 @@ double SketchPlugin_Circle::distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2
 
   return aPoint->pnt()->distance(thePoint);
 }
+
+bool SketchPlugin_Circle::isFixed() {
+  return data()->selection(EXTERNAL_ID())->context();
+}
index c489f1014c45c8c6c5ad7320881a717240c6ba51..11311dcb0da8c230e74ce32ee5623e8797ea2841 100644 (file)
@@ -45,6 +45,9 @@ class SketchPlugin_Circle : public SketchPlugin_Feature  //, public GeomAPI_IPre
     return MY_KIND;
   }
 
+  /// Returns true is sketch element is under the rigid constraint
+  SKETCHPLUGIN_EXPORT virtual bool isFixed();
+
   /// Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
 
index 49bcc1320cc138cf75e76fcc8c81197631f83111..97a2d423bd605102a579461c1774ac305baff60e 100644 (file)
@@ -27,6 +27,13 @@ class SketchPlugin_Feature : public ModelAPI_Feature
   static AISObjectPtr simpleAISObject(boost::shared_ptr<ModelAPI_Result> theRes,
                                       AISObjectPtr thePrevious);
 
+  /// Reference to the external edge or vertex as a AttributeSelection
+  inline static const std::string& EXTERNAL_ID()
+  {
+    static const std::string MY_EXTERNAL_ID("External");
+    return MY_EXTERNAL_ID;
+  }
+
   /// Returns true if this feature must be displayed in the history (top level of Part tree)
   SKETCHPLUGIN_EXPORT virtual bool isInHistory()
   {
@@ -45,6 +52,9 @@ class SketchPlugin_Feature : public ModelAPI_Feature
   /// Construction result is allways recomuted on the fly
   SKETCHPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
 
+  /// Returns true is sketch element is under the rigid constraint
+  SKETCHPLUGIN_EXPORT virtual bool isFixed() {return false;}
+
   /// Returns the sketch of this feature
   inline SketchPlugin_Sketch* sketch() {return mySketch;}
 protected:
index 8ae5384bb42cbf8bf057472fe2e64534a6502ce1..72a20f8618db061541c325f0ca7162a8f8d992ff 100644 (file)
@@ -6,6 +6,8 @@
 #include "SketchPlugin_Sketch.h"
 #include <ModelAPI_Data.h>
 #include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_Validator.h>
 
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_Lin2d.h>
@@ -25,6 +27,8 @@ void SketchPlugin_Line::initAttributes()
 {
   data()->addAttribute(SketchPlugin_Line::START_ID(), GeomDataAPI_Point2D::type());
   data()->addAttribute(SketchPlugin_Line::END_ID(), GeomDataAPI_Point2D::type());
+  data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
 }
 
 void SketchPlugin_Line::execute()
@@ -88,3 +92,7 @@ double SketchPlugin_Line::distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>
 
   return aDelta;
 }
+
+bool SketchPlugin_Line::isFixed() {
+  return data()->selection(EXTERNAL_ID())->context();
+}
index d2656e5d83ec89dfaa0360aa6a2b618947a3b8c7..d24f1af52701f79fe25d0ee6b9f6136fcd033f92 100644 (file)
@@ -43,6 +43,9 @@ class SketchPlugin_Line : public SketchPlugin_Feature
     return MY_KIND;
   }
 
+  /// Returns true is sketch element is under the rigid constraint
+  SKETCHPLUGIN_EXPORT virtual bool isFixed();
+
   /// Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
 
index 5e8f2a65ebd45761393ef070c5b0e8d4ef9c9410..c198e9b90fd22c44e7c066ea30ee88a022aa2df1 100644 (file)
@@ -7,6 +7,8 @@
 
 #include <ModelAPI_Data.h>
 #include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_Validator.h>
 
 #include <GeomAPI_Pnt2d.h>
 
@@ -22,6 +24,8 @@ SketchPlugin_Point::SketchPlugin_Point()
 void SketchPlugin_Point::initAttributes()
 {
   data()->addAttribute(SketchPlugin_Point::COORD_ID(), GeomDataAPI_Point2D::type());
+  data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
 }
 
 void SketchPlugin_Point::execute()
@@ -61,3 +65,7 @@ double SketchPlugin_Point::distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d
 
   return aPoint->pnt()->distance(thePoint);
 }
+
+bool SketchPlugin_Point::isFixed() {
+  return data()->selection(EXTERNAL_ID())->context();
+}
index 14f58740248eed1215cf5c980e688d4fa48483d8..48415b18ccf83a6b3592aa9c226b6b83c6f8dcb9 100644 (file)
@@ -36,6 +36,9 @@ class SketchPlugin_Point : public SketchPlugin_Feature
     return MY_KIND;
   }
 
+  /// Returns true is sketch element is under the rigid constraint
+  SKETCHPLUGIN_EXPORT virtual bool isFixed();
+
   /// Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();