From: nds Date: Thu, 25 Jun 2015 06:09:32 +0000 (+0300) Subject: Main fix of this integration is in ConstraintRigid. The AIS should be created uncondi... X-Git-Tag: V_1.3.0~192 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=83a77e73bf17bf45b4b1c1e163c02acb841f775b;p=modules%2Fshaper.git Main fix of this integration is in ConstraintRigid. The AIS should be created unconditionally, otherwise fixed constraint is not visualized in the viewer when it is created by preselection. Also the customizePresentation is realized for lenght and dimension, the color should be set there similar to other presentations. --- diff --git a/src/SketchPlugin/SketchPlugin_ConstraintBase.h b/src/SketchPlugin/SketchPlugin_ConstraintBase.h index cd7155409..f6f6b0782 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintBase.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintBase.h @@ -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 diff --git a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp index 4f5110400..85a255bfb 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp @@ -36,9 +36,6 @@ AISObjectPtr SketchPlugin_ConstraintCoincidence::getAISObject(AISObjectPtr thePr AISObjectPtr anAIS = thePrevious; if (!anAIS) { anAIS = SketcherPrs_Factory::coincidentConstraint(this, sketch()->coordinatePlane()); - //std::vector aRGB = Config_PropManager::color("Visualization", "sketch_constraint_color", - // SKETCH_DIMENSION_COLOR); - //anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]); } return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp index 3891a2c6c..11672f77a 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp @@ -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 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 theDefaultPrs) +{ + bool isCustomized = false; + std::vector aRGB = Config_PropManager::color("Visualization", "sketch_dimension_color", + SKETCH_DIMENSION_COLOR); + isCustomized = thePrs->setColor(aRGB[0], aRGB[1], aRGB[2]); + + return isCustomized; +} + diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h index c8c7cb781..370519bda 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h @@ -12,6 +12,8 @@ #include "SketchPlugin_Sketch.h" #include "ModelAPI_Data.h" +#include + #include 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 theDefaultPrs); + /// \brief Use plugin manager for features creation SketchPlugin_ConstraintDistance(); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp index 9d996ab24..dfdca6488 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp @@ -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 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 theDefaultPrs) +{ + bool isCustomized = false; + std::vector aRGB = Config_PropManager::color("Visualization", "sketch_dimension_color", + SKETCH_DIMENSION_COLOR); + isCustomized = thePrs->setColor(aRGB[0], aRGB[1], aRGB[2]); + + return isCustomized; +} diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.h b/src/SketchPlugin/SketchPlugin_ConstraintLength.h index a905ad1d6..d6098af22 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.h @@ -9,7 +9,10 @@ #include "SketchPlugin.h" #include "SketchPlugin_ConstraintBase.h" -#include +#include "SketchPlugin_Sketch.h" + +#include + #include 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 theDefaultPrs); + /// \brief Use plugin manager for features creation SketchPlugin_ConstraintLength(); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp b/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp index 8867e16d5..78574b338 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp @@ -36,17 +36,7 @@ AISObjectPtr SketchPlugin_ConstraintRigid::getAISObject(AISObjectPtr thePrevious AISObjectPtr anAIS = thePrevious; if (anAIS.get() == NULL) { - std::shared_ptr aData = data(); - std::shared_ptr anAttr = - std::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); - ObjectPtr aObj = anAttr->object(); - if (aObj.get() != NULL) { - FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); - std::shared_ptr aSkFea = - std::dynamic_pointer_cast(aFeature); - if (!aSkFea->isExternal()) - anAIS = SketcherPrs_Factory::rigidConstraint(this, sketch()->coordinatePlane()); - } + anAIS = SketcherPrs_Factory::rigidConstraint(this, sketch()->coordinatePlane()); } return anAIS; diff --git a/src/SketchPlugin/SketchPlugin_Plugin.cpp b/src/SketchPlugin/SketchPlugin_Plugin.cpp index 59d20c38d..7742fa5c1 100644 --- a/src/SketchPlugin/SketchPlugin_Plugin.cpp +++ b/src/SketchPlugin/SketchPlugin_Plugin.cpp @@ -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);