From: vsv Date: Thu, 5 Feb 2015 09:32:27 +0000 (+0300) Subject: Issue #371: show external edges in different color. Also hide rigid constraint for... X-Git-Tag: V_1.1.0~212^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7b57d5fd5d0ef1259a3568be884f63d9a906b83d;p=modules%2Fshaper.git Issue #371: show external edges in different color. Also hide rigid constraint for external edges. Fixed bug with setColor and planes preferences management. --- diff --git a/src/GeomAPI/GeomAPI_AISObject.cpp b/src/GeomAPI/GeomAPI_AISObject.cpp index aea1179d6..5e0c21b44 100644 --- a/src/GeomAPI/GeomAPI_AISObject.cpp +++ b/src/GeomAPI/GeomAPI_AISObject.cpp @@ -274,6 +274,8 @@ void GeomAPI_AISObject::setColor(const int& theColor) if (!aDimAIS.IsNull()) { aDimAIS->DimensionAspect()->SetCommonColor(aColor); } + Handle(AIS_InteractiveContext) aContext = anAIS->GetContext(); + aContext->SetColor(anAIS, aColor, false); } void GeomAPI_AISObject::setWidth(const double& theWidth) @@ -296,6 +298,8 @@ void GeomAPI_AISObject::setColor(int theR, int theG, int theB) if (!aDimAIS.IsNull()) { aDimAIS->DimensionAspect()->SetCommonColor(aColor); } + Handle(AIS_InteractiveContext) aContext = anAIS->GetContext(); + aContext->SetColor(anAIS, aColor, false); } bool GeomAPI_AISObject::empty() const diff --git a/src/ModuleBase/ModuleBase_IModule.cpp b/src/ModuleBase/ModuleBase_IModule.cpp index fd2686df3..f7637f9d7 100644 --- a/src/ModuleBase/ModuleBase_IModule.cpp +++ b/src/ModuleBase/ModuleBase_IModule.cpp @@ -97,6 +97,7 @@ void ModuleBase_IModule::createFeatures() { registerValidators(); registerFilters(); + registerProperties(); Config_ModuleReader aXMLReader = Config_ModuleReader(); aXMLReader.readAll(); diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 88fa049d4..01896bb8f 100644 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -128,6 +128,9 @@ protected slots: /// Register selection filters for this module virtual void registerFilters() {} + /// Register properties of this module + virtual void registerProperties() {} + /// Returns new instance of operation object (used in createOperation for customization) virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId); diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 7fe2956f1..cd0f44109 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -51,6 +51,7 @@ //#include #include +#include #include #include @@ -136,6 +137,14 @@ void PartSet_Module::registerFilters() new ModuleBase_FilterCustom(aSelectFilter)); } +void PartSet_Module::registerProperties() +{ + Config_PropManager::registerProp("Sketch planes", "planes_size", "Size", Config_Prop::Double, + PLANE_SIZE); + Config_PropManager::registerProp("Sketch planes", "planes_thickness", "Thickness", + Config_Prop::Integer, SKETCH_WIDTH); +} + void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation) { if (theOperation->isEditOperation()) diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 5bd229629..13cfba1d9 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -123,6 +123,9 @@ protected slots: /// Register selection filters for this module virtual void registerFilters(); + /// Register properties of this module + virtual void registerProperties(); + private slots: /// Processing of vertex selected void onVertexSelected(); diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index afe12cd2d..159624efa 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -38,8 +38,6 @@ #include #include -#define PLANE_SIZE "200" -#define SKETCH_WIDTH "4" PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent, @@ -214,7 +212,7 @@ AISObjectPtr PartSet_WidgetSketchLabel::createPreviewPlane(std::shared_ptr theNorm, const int theRGB[3]) { - double aSize = Config_PropManager::integer("Sketch planes", "Size of planes", PLANE_SIZE); + double aSize = Config_PropManager::integer("Sketch planes", "planes_size", PLANE_SIZE); std::shared_ptr aFace = GeomAlgoAPI_FaceBuilder::square(theOrigin, theNorm, aSize); AISObjectPtr aAIS = AISObjectPtr(new GeomAPI_AISObject()); aAIS->createShape(aFace); diff --git a/src/PartSet/PartSet_WidgetSketchLabel.h b/src/PartSet/PartSet_WidgetSketchLabel.h index 9c9ffad2c..d7b412f16 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.h +++ b/src/PartSet/PartSet_WidgetSketchLabel.h @@ -24,6 +24,12 @@ class QTimer; class XGUI_OperationMgr; class XGUI_Workshop; +/// the plane edge width +#define SKETCH_WIDTH "4" + +/// face of the square-face displayed for selection of general plane +#define PLANE_SIZE "200" + /** * \ingroup Modules * A model widget implementation for a label which provides specific behaviour diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp b/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp index 5a7b9d5f9..00e973d1a 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp @@ -44,6 +44,13 @@ AISObjectPtr SketchPlugin_ConstraintRigid::getAISObject(AISObjectPtr thePrevious if (!aConst) return thePrevious; + + std::shared_ptr aSketchFea = + std::dynamic_pointer_cast(ModelAPI_Feature::feature(aConst)); + if (aSketchFea.get() != NULL) { + if (aSketchFea->isExternal()) + return thePrevious; + } aShape = aConst->shape(); } else { diff --git a/src/SketchPlugin/SketchPlugin_Feature.h b/src/SketchPlugin/SketchPlugin_Feature.h index acf95e2a6..66d59467b 100644 --- a/src/SketchPlugin/SketchPlugin_Feature.h +++ b/src/SketchPlugin/SketchPlugin_Feature.h @@ -60,7 +60,7 @@ class SketchPlugin_Feature : public ModelAPI_Feature, public GeomAPI_ICustomPrs { AttributeSelectionPtr aAttr = data()->selection(EXTERNAL_ID()); if (aAttr) - return aAttr->context().get() == NULL; + return aAttr->context().get() != NULL; return false; } @@ -68,8 +68,11 @@ class SketchPlugin_Feature : public ModelAPI_Feature, public GeomAPI_ICustomPrs virtual void customisePresentation(AISObjectPtr thePrs) { // if this is an edge - if (thePrs->getShapeType() == 6) + if (thePrs->getShapeType() == 6) { thePrs->setWidth(3); + if (isExternal()) + thePrs->setColor(0,255,0); + } // if this is a vertex //else if (thePrs->getShapeType() == 7) // thePrs->setPointMarker(6, 2.); diff --git a/src/SketchPlugin/SketchPlugin_Plugin.cpp b/src/SketchPlugin/SketchPlugin_Plugin.cpp index 452e07401..030f786f1 100644 --- a/src/SketchPlugin/SketchPlugin_Plugin.cpp +++ b/src/SketchPlugin/SketchPlugin_Plugin.cpp @@ -53,12 +53,6 @@ SketchPlugin_Plugin::SketchPlugin_Plugin() ModelAPI_Session::get()->registerPlugin(this); // register sketcher properties - Config_PropManager::registerProp("Sketch planes", "planes_color", "Color", Config_Prop::Color, - SKETCH_PLANE_COLOR); - Config_PropManager::registerProp("Sketch planes", "planes_size", "Size", Config_Prop::Double, - PLANE_SIZE); - Config_PropManager::registerProp("Sketch planes", "planes_thickness", "Thickness", - Config_Prop::Integer, SKETCH_WIDTH); Config_PropManager::registerProp("Visualization", "parallel_color", "Parallel constraint color", Config_Prop::Color, PARALLEL_COLOR); diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index 84cda7dfb..cb3efbea6 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -14,15 +14,6 @@ #include #include -/// the plane edge color -#define SKETCH_PLANE_COLOR "#700000" - -/// the plane edge width -#define SKETCH_WIDTH "4" - -/// face of the square-face displayed for selection of general plane -#define PLANE_SIZE "200" - /**\class SketchPlugin_Sketch * \ingroup Plugins * \brief Feature for creation of the new part in PartSet.