Salome HOME
Issue #371: show external edges in different color. Also hide rigid constraint for...
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 5 Feb 2015 09:32:27 +0000 (12:32 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 5 Feb 2015 09:32:27 +0000 (12:32 +0300)
src/GeomAPI/GeomAPI_AISObject.cpp
src/ModuleBase/ModuleBase_IModule.cpp
src/ModuleBase/ModuleBase_IModule.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/PartSet/PartSet_WidgetSketchLabel.h
src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp
src/SketchPlugin/SketchPlugin_Feature.h
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/SketchPlugin/SketchPlugin_Sketch.h

index aea1179d62076fc4aaddd0a1c44f53950acf8787..5e0c21b44ae344824eff4008ce15cf299a561dab 100644 (file)
@@ -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
index fd2686df308b3bc672761701127e048f974182b7..f7637f9d77128f8c720878d0d6a274720e97ea64 100644 (file)
@@ -97,6 +97,7 @@ void ModuleBase_IModule::createFeatures()
 {
   registerValidators();
   registerFilters();
+  registerProperties();
 
   Config_ModuleReader aXMLReader = Config_ModuleReader();
   aXMLReader.readAll();
index 88fa049d45e5549396bffe806882ffa4b77b1530..01896bb8fa3610406fe3e357df9130c9eeff5704 100644 (file)
@@ -128,6 +128,9 @@ protected slots:
   /// Register selection filters for this module\r
   virtual void registerFilters() {}\r
 \r
+  /// Register properties of this module\r
+  virtual void registerProperties() {}\r
+\r
   /// Returns new instance of operation object (used in createOperation for customization)\r
   virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);\r
 \r
index 7fe2956f1a9d516ff55781c83c23dde2b344fd96..cd0f44109e5537405f39ef6e23bef37f2e84b40a 100644 (file)
@@ -51,6 +51,7 @@
 //#include <SketchPlugin_ConstraintRigid.h>
 
 #include <Events_Loop.h>
+#include <Config_PropManager.h>
 
 #include <StdSelect_TypeOfFace.hxx>
 #include <TopoDS_Vertex.hxx>
@@ -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())
index 5bd2296297b61616e3f711c588359fa6e0d7bceb..13cfba1d9ac4cdf3a8fd61ffea08028e68911db8 100644 (file)
@@ -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();
index afe12cd2d39ce60e64dc1994fcb02387218cf796..159624efa7cd8309d092f426e3a7558f9427fc1b 100644 (file)
@@ -38,8 +38,6 @@
 #include <QTimer>
 #include <QApplication>
 
-#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<GeomA
                                                            std::shared_ptr<GeomAPI_Dir> 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<GeomAPI_Shape> aFace = GeomAlgoAPI_FaceBuilder::square(theOrigin, theNorm, aSize);
   AISObjectPtr aAIS = AISObjectPtr(new GeomAPI_AISObject());
   aAIS->createShape(aFace);
index 9c9ffad2cc8a4007c626792c5d06b205821b9e44..d7b412f16b0024dffdfa9951693193d55c2595ca 100644 (file)
@@ -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 
index 5a7b9d5f9781283302182a23c2e8ad6a6013be56..00e973d1a0a04923945d885946fec94b6c1f5951 100644 (file)
@@ -44,6 +44,13 @@ AISObjectPtr SketchPlugin_ConstraintRigid::getAISObject(AISObjectPtr thePrevious
 
     if (!aConst) 
       return thePrevious;
+
+    std::shared_ptr<SketchPlugin_Feature> aSketchFea = 
+      std::dynamic_pointer_cast<SketchPlugin_Feature>(ModelAPI_Feature::feature(aConst));
+    if (aSketchFea.get() != NULL) {
+      if (aSketchFea->isExternal())
+        return thePrevious;
+    }
     aShape = aConst->shape();
   }
   else {
index acf95e2a67554a19c01394ce5a55f7ceec15c8ad..66d59467b5682dfb6fc6ebcf95a0aeb1083edb73 100644 (file)
@@ -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.);
index 452e07401f313c26d1d867ccaf2f0182f2b86f06..030f786f18b1d78d2e5d0f218b0dd3e0d98ebb85 100644 (file)
@@ -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);
index 84cda7dfba7a5604b83de15b59adb4ac64eb887c..cb3efbea6864f5cdc90751c99b056ed842421587 100644 (file)
 #include <GeomAPI_IPresentable.h>
 #include <list>
 
-/// 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.