Also the customizePresentation is realized for lenght and dimension, the color should be set there similar to other presentations.
* 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
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;
}
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;
}
}
}
+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;
+}
+
#include "SketchPlugin_Sketch.h"
#include "ModelAPI_Data.h"
+#include <GeomAPI_ICustomPrs.h>
+
#include <list>
class SketchPlugin_Line;
* 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
/// 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();
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;
}
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;
+}
#include "SketchPlugin.h"
#include "SketchPlugin_ConstraintBase.h"
-#include <SketchPlugin_Sketch.h>
+#include "SketchPlugin_Sketch.h"
+
+#include <GeomAPI_ICustomPrs.h>
+
#include <list>
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
/// \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();
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;
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);