Salome HOME
COPY attribute in SketchEntity now persistent
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_SketchEntity.h
index 8f716c79f1de1427c742db9c61afbc18f7b67255..16101d1866aaac9b4c70b587adf8e23782152e7e 100644 (file)
@@ -20,9 +20,9 @@
 
 #include <Config_PropManager.h>
 
-#define SKETCH_ENTITY_COLOR "#ff0000"
-#define SKETCH_EXTERNAL_COLOR "#00ff00"
-#define SKETCH_AUXILIARY_COLOR "#000000"
+#define SKETCH_ENTITY_COLOR "225,0,0"
+#define SKETCH_EXTERNAL_COLOR "170,0,225"
+#define SKETCH_AUXILIARY_COLOR "0,85,0"
 
 /**\class SketchPlugin_SketchEntity
  * \ingroup Plugins
@@ -46,6 +46,13 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
     return MY_EXTERNAL_ID;
   }
 
+  /// Reference to the copy type of the feature
+  inline static const std::string& COPY_ID()
+  {
+    static const std::string MY_COPY_ID("Copy");
+    return MY_COPY_ID;
+  }
+
   /// Request for initialization of data model of the feature: adding all attributes
   virtual void initAttributes();
 
@@ -58,6 +65,16 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
     return false;
   }
 
+  /// Returns true of the feature is a copy of other feature
+  virtual bool isCopy() const
+  {
+    AttributeBooleanPtr anAttr = data()->boolean(COPY_ID());
+    if(anAttr.get()) {
+      return anAttr->value();
+    }
+    return false;
+  }
+
   /// Customize presentation of the feature
   virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
                                      std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
@@ -99,7 +116,14 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
       }
     }
     else if (aShapeType == 7) { // otherwise this is a vertex
-      //  thePrs->setPointMarker(6, 2.);
+      // The width value do not have effect on the point presentation.
+      // It is defined in order to extend selection area of the object.
+      thePrs->setWidth(17);
+    //  thePrs->setPointMarker(1, 1.); // Set point as a '+' symbol
+    }
+    if(isCopy()) {
+      double aWidth = thePrs->width();
+      isCustomized = thePrs->setWidth(aWidth / 2.5) || isCustomized;
     }
     return isCustomized;
   }
@@ -107,6 +131,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