Salome HOME
Selection priority in Sketch, clear selection when sketch goes from entity to neutral...
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_SketchEntity.h
index 3148b0c57705a1d18a89f2ab8d1c168c442dfe30..3174d09ea94c4c964263fcfaf395a72f4c93b371 100644 (file)
@@ -23,6 +23,7 @@
 #define SKETCH_ENTITY_COLOR "225,0,0"
 #define SKETCH_EXTERNAL_COLOR "170,0,225"
 #define SKETCH_AUXILIARY_COLOR "0,85,0"
+#define SKETCH_OVERCONSTRAINT_COLOR "0,0,0"
 
 /**\class SketchPlugin_SketchEntity
  * \ingroup Plugins
@@ -53,6 +54,30 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
     return MY_COPY_ID;
   }
 
+  /// Width of the auxiliary line
+  inline static const double SKETCH_LINE_WIDTH_AUXILIARY()
+  {
+    return 2;
+  }
+
+  /// Width of the line
+  inline static const double SKETCH_LINE_WIDTH()
+  {
+    return 3;
+  }
+
+  /// Style of the auxiliary line
+  inline static const int SKETCH_LINE_STYLE_AUXILIARY()
+  {
+    return  3;
+  }
+
+  /// Style of the line
+  inline static const int SKETCH_LINE_STYLE()
+  {
+    return  0;
+  }
+
   /// Request for initialization of data model of the feature: adding all attributes
   virtual void initAttributes();
 
@@ -61,7 +86,7 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
   {
     AttributeSelectionPtr aAttr = data()->selection(EXTERNAL_ID());
     if (aAttr)
-      return aAttr->context().get() != NULL;
+      return aAttr->context().get() != NULL && !aAttr->isInvalid();
     return false;
   }
 
@@ -79,7 +104,9 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
   virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
                                      std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
   {
-    bool isCustomized = false;
+    //bool isCustomized = false;
+    bool isCustomized = theDefaultPrs.get() != NULL &&
+                        theDefaultPrs->customisePresentation(theResult, thePrs, theDefaultPrs);
     int aShapeType = thePrs->getShapeType();
     // a compound is processed like the edge because the arc feature uses the compound for presentable AIS
     if (aShapeType != 6/*an edge*/ && aShapeType != 7/*a vertex*/ && aShapeType != 0/*compound*/)
@@ -107,12 +134,12 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
 
     if (aShapeType == 6 || aShapeType == 0) { // if this is an edge or a compound
       if (isConstruction) {
-        isCustomized = thePrs->setWidth(1) || isCustomized;
-        isCustomized = thePrs->setLineStyle(3) || isCustomized;
+        isCustomized = thePrs->setWidth(SKETCH_LINE_WIDTH_AUXILIARY()) || isCustomized;
+        isCustomized = thePrs->setLineStyle(SKETCH_LINE_STYLE_AUXILIARY()) || isCustomized;
       }
       else {
-        isCustomized = thePrs->setWidth(3) || isCustomized;
-        isCustomized = thePrs->setLineStyle(0) || isCustomized;
+        isCustomized = thePrs->setWidth(SKETCH_LINE_WIDTH()) || isCustomized;
+        isCustomized = thePrs->setLineStyle(SKETCH_LINE_STYLE()) || isCustomized;
       }
     }
     else if (aShapeType == 7) { // otherwise this is a vertex
@@ -123,7 +150,7 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
     }
     if(isCopy()) {
       double aWidth = thePrs->width();
-      thePrs->setWidth(aWidth / 2.5);
+      isCustomized = thePrs->setWidth(aWidth / 2.5) || isCustomized;
     }
     return isCustomized;
   }
@@ -131,6 +158,10 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
 protected:
   /// initializes mySketch
   SketchPlugin_SketchEntity();
+
+  /// \brief Initializes attributes of derived class.
+  virtual void initDerivedClassAttributes(){};
+
 };
 
 #endif