]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Main fix of this integration is in ConstraintRigid. The AIS should be created uncondi...
authornds <natalia.donis@opencascade.com>
Thu, 25 Jun 2015 06:09:32 +0000 (09:09 +0300)
committernds <natalia.donis@opencascade.com>
Thu, 25 Jun 2015 06:09:32 +0000 (09:09 +0300)
Also the customizePresentation is realized for lenght and dimension, the color should be set there similar to other presentations.

src/SketchPlugin/SketchPlugin_ConstraintBase.h
src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.h
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_ConstraintLength.h
src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp
src/SketchPlugin/SketchPlugin_Plugin.cpp

index cd7155409b14f2de533dcbefd9c2549878287858..f6f6b07822cee2254a24221a45c956f4a87b401a 100644 (file)
@@ -30,7 +30,6 @@
  *    Also the list of possible attributes is provided to simplify assignment.
  */
 
-#define SKETCH_CONSTRAINT_COLOR "225,225,0"
 #define SKETCH_DIMENSION_COLOR "64,128,225"
 
 /** \class SketchPlugin_ConstraintBase
index 4f5110400708e8c5b4bdd8636a44208c1fd4ca19..85a255bfb8fa924fa459ec9bbb82439fb9e35009 100644 (file)
@@ -36,9 +36,6 @@ AISObjectPtr SketchPlugin_ConstraintCoincidence::getAISObject(AISObjectPtr thePr
   AISObjectPtr anAIS = thePrevious;
   if (!anAIS) {
     anAIS = SketcherPrs_Factory::coincidentConstraint(this, sketch()->coordinatePlane());
-  //std::vector<int> aRGB = Config_PropManager::color("Visualization", "sketch_constraint_color",
-  //                                                  SKETCH_DIMENSION_COLOR);
-  //anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
   }
   return anAIS;
 }
index 3891a2c6cc5eed9a0a013533322e3f5280036d11..11672f77a14bd074d4cf09d1a91ffdc1124a6bde 100644 (file)
@@ -133,11 +133,6 @@ AISObjectPtr SketchPlugin_ConstraintDistance::getAISObject(AISObjectPtr thePrevi
   if (!anAIS) {
     anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this, sketch()->coordinatePlane());
   }
-
-  // Set color from preferences
-  std::vector<int> aRGB = Config_PropManager::color("Visualization", "sketch_dimension_color",
-                                                    SKETCH_DIMENSION_COLOR);
-  anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
   return anAIS;
 }
 
@@ -285,3 +280,15 @@ void SketchPlugin_ConstraintDistance::attributeChanged(const std::string& theID)
   }
 }
 
+bool SketchPlugin_ConstraintDistance::customisePresentation(ResultPtr theResult,
+                                    AISObjectPtr thePrs,
+                                    std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
+{
+  bool isCustomized = false;
+  std::vector<int> aRGB = Config_PropManager::color("Visualization", "sketch_dimension_color",
+                                                    SKETCH_DIMENSION_COLOR);
+  isCustomized = thePrs->setColor(aRGB[0], aRGB[1], aRGB[2]);
+
+  return isCustomized;
+}
+
index c8c7cb78129f01627acced76b0ebef54a77cb702..370519bdaec0aa043ebcc832fbff05f2c45e905d 100644 (file)
@@ -12,6 +12,8 @@
 #include "SketchPlugin_Sketch.h"
 #include "ModelAPI_Data.h"
 
+#include <GeomAPI_ICustomPrs.h>
+
 #include <list>
 
 class SketchPlugin_Line;
@@ -25,7 +27,7 @@ class GeomDataAPI_Point2D;
  *  This constraint has three attributes:
  *  SketchPlugin_Constraint::VALUE(), SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B()
  */
-class SketchPlugin_ConstraintDistance : public SketchPlugin_ConstraintBase
+class SketchPlugin_ConstraintDistance : public SketchPlugin_ConstraintBase, public GeomAPI_ICustomPrs
 {
  public:
   /// Distance constraint kind
@@ -68,6 +70,10 @@ class SketchPlugin_ConstraintDistance : public SketchPlugin_ConstraintBase
   /// Returns the current distance between the feature attributes
   double calculateCurrentDistance() const;
 
+    /// Customize presentation of the feature
+  virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
+                                     std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
+
   /// \brief Use plugin manager for features creation
   SketchPlugin_ConstraintDistance();
 
index 9d996ab24028ccde370554cefbe64b3497148b90..dfdca6488f6131804db15880136a774af34cc3e8 100644 (file)
@@ -128,11 +128,6 @@ AISObjectPtr SketchPlugin_ConstraintLength::getAISObject(AISObjectPtr thePreviou
   if (!anAIS) {
     anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this, sketch()->coordinatePlane());
   }
-
-  // Set color from preferences
-  std::vector<int> aRGB = Config_PropManager::color("Visualization", "sketch_dimension_color",
-                                                    SKETCH_DIMENSION_COLOR);
-  anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
   return anAIS;
 }
 
@@ -210,3 +205,15 @@ void SketchPlugin_ConstraintLength::attributeChanged(const std::string& theID) {
     myFlyoutUpdate = false;
   }
 }
+
+bool SketchPlugin_ConstraintLength::customisePresentation(ResultPtr theResult,
+                                    AISObjectPtr thePrs,
+                                    std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
+{
+  bool isCustomized = false;
+  std::vector<int> aRGB = Config_PropManager::color("Visualization", "sketch_dimension_color",
+                                                    SKETCH_DIMENSION_COLOR);
+  isCustomized = thePrs->setColor(aRGB[0], aRGB[1], aRGB[2]);
+
+  return isCustomized;
+}
index a905ad1d697d1ffa5fd0f328bc7603608f468779..d6098af221cf8c12e60b629ff246c56b80c63a45 100644 (file)
@@ -9,7 +9,10 @@
 
 #include "SketchPlugin.h"
 #include "SketchPlugin_ConstraintBase.h"
-#include <SketchPlugin_Sketch.h>
+#include "SketchPlugin_Sketch.h"
+
+#include <GeomAPI_ICustomPrs.h>
+
 #include <list>
 
 class GeomDataAPI_Point2D;
@@ -22,7 +25,7 @@ class GeomDataAPI_Point2D;
  *  SketchPlugin_Constraint::VALUE() (length) and SketchPlugin_Constraint::ENTITY_A() (segment),
  *  SketchPlugin_Constraint::FLYOUT_VALUE_PNT() (distance of a constraints handle)
  */
-class SketchPlugin_ConstraintLength : public SketchPlugin_ConstraintBase
+class SketchPlugin_ConstraintLength : public SketchPlugin_ConstraintBase, public GeomAPI_ICustomPrs
 {
  public:
   /// Length constraint kind
@@ -61,6 +64,10 @@ class SketchPlugin_ConstraintLength : public SketchPlugin_ConstraintBase
   /// \param theID identifier of changed attribute
   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
 
+  /// Customize presentation of the feature
+  virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
+                                     std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
+
   /// \brief Use plugin manager for features creation
   SketchPlugin_ConstraintLength();
 
index 8867e16d55932720530b9e6e0ea9dde72eeb88b6..78574b338eddafe71e0616b5dad1944693808d3e 100644 (file)
@@ -36,17 +36,7 @@ AISObjectPtr SketchPlugin_ConstraintRigid::getAISObject(AISObjectPtr thePrevious
 
   AISObjectPtr anAIS = thePrevious;
   if (anAIS.get() == NULL) {
-    std::shared_ptr<ModelAPI_Data> aData = data();
-    std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
-      std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
-    ObjectPtr aObj = anAttr->object();
-    if (aObj.get() != NULL) {
-      FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
-      std::shared_ptr<SketchPlugin_Feature> aSkFea = 
-        std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
-      if (!aSkFea->isExternal()) 
-        anAIS = SketcherPrs_Factory::rigidConstraint(this, sketch()->coordinatePlane());
-    }
+    anAIS = SketcherPrs_Factory::rigidConstraint(this, sketch()->coordinatePlane());
   }
 
   return anAIS;
index 59d20c38d5fa4a6724eb26f345179a4ccfe12707..7742fa5c10c94fd84a6fbbc853cbf94d2a7b1a22 100644 (file)
@@ -80,9 +80,6 @@ SketchPlugin_Plugin::SketchPlugin_Plugin()
   Config_PropManager::registerProp("Visualization", "sketch_auxiliary_color", "Sketch auxiliary entity color",
                                    Config_Prop::Color, SKETCH_AUXILIARY_COLOR);
 
-  Config_PropManager::registerProp("Visualization", "sketch_constraint_color", "Sketch constraint color",
-                                   Config_Prop::Color, SKETCH_CONSTRAINT_COLOR);
-
   Config_PropManager::registerProp("Visualization", "sketch_dimension_color", "Sketch dimension color",
                                    Config_Prop::Color, SKETCH_DIMENSION_COLOR);