Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom.git into Dev_1.1.0
authorsbh <sergey.belash@opencascade.com>
Tue, 24 Feb 2015 15:02:10 +0000 (18:02 +0300)
committersbh <sergey.belash@opencascade.com>
Tue, 24 Feb 2015 15:02:10 +0000 (18:02 +0300)
Defines a re-factored as static methods of corresponding classes
Conflicts:
src/ConstructionPlugin/ConstructionPlugin_Axis.h
src/ConstructionPlugin/ConstructionPlugin_Point.h

1  2 
src/ConstructionPlugin/ConstructionPlugin_Axis.cpp
src/ConstructionPlugin/ConstructionPlugin_Axis.h
src/ConstructionPlugin/ConstructionPlugin_Plane.cpp
src/ConstructionPlugin/ConstructionPlugin_Plane.h
src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp
src/ConstructionPlugin/ConstructionPlugin_Point.cpp
src/ConstructionPlugin/ConstructionPlugin_Point.h

index 570a3a3b8edb2b58a4a19ff02b5c39e0f59dacd7,11fd775dd86f5b05e9e88c25da855f15bd4ed950..4f3fae9dbdd66352d6b8713368fea1c43ee7ef7e
@@@ -6,6 -6,8 +6,8 @@@
  
  #include "ConstructionPlugin_Axis.h"
  
+ #include <Config_PropManager.h>
  #include <ModelAPI_AttributeSelection.h>
  #include <ModelAPI_ResultConstruction.h>
  
  
  using namespace std;
  
 -static const double MINIMAL_LENGTH = 1.e-5;
 -
  ConstructionPlugin_Axis::ConstructionPlugin_Axis()
  {
  }
  
  void ConstructionPlugin_Axis::initAttributes()
  {
 -  data()->addAttribute(POINT_ATTR_FIRST,  ModelAPI_AttributeSelection::type());
 -  data()->addAttribute(POINT_ATTR_SECOND, ModelAPI_AttributeSelection::type());
 +  data()->addAttribute(ConstructionPlugin_Axis::POINT_FIRST(),
 +                       ModelAPI_AttributeSelection::type());
 +  data()->addAttribute(ConstructionPlugin_Axis::POINT_SECOND(),
 +                       ModelAPI_AttributeSelection::type());
  }
  
  void ConstructionPlugin_Axis::execute()
  {
 -  AttributeSelectionPtr aRef1 = data()->selection(POINT_ATTR_FIRST);
 -  AttributeSelectionPtr aRef2 = data()->selection(POINT_ATTR_SECOND);
 +  AttributeSelectionPtr aRef1 = data()->selection(ConstructionPlugin_Axis::POINT_FIRST());
 +  AttributeSelectionPtr aRef2 = data()->selection(ConstructionPlugin_Axis::POINT_SECOND());
    if ((aRef1.get() != NULL) && (aRef2.get() != NULL)) {
      GeomShapePtr aShape1 = aRef1->value();
      GeomShapePtr aShape2 = aRef2->value();
      if (aShape1->isVertex() && aShape2->isVertex() && (!aShape1->isEqual(aShape2))) {
        std::shared_ptr<GeomAPI_Pnt> aStart = GeomAlgoAPI_PointBuilder::point(aShape1);
        std::shared_ptr<GeomAPI_Pnt> anEnd = GeomAlgoAPI_PointBuilder::point(aShape2);
 -      if (aStart->distance(anEnd) > MINIMAL_LENGTH) {
 +      if (aStart->distance(anEnd) > ConstructionPlugin_Axis::MINIMAL_LENGTH()) {
          std::shared_ptr<GeomAPI_Edge> anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd);
  
          ResultConstructionPtr aConstr = document()->createConstruction(data());
@@@ -50,7 -52,9 +52,9 @@@
  
  void ConstructionPlugin_Axis::customisePresentation(AISObjectPtr thePrs)
  {
-   thePrs->setColor(0, 0, 0);
+   std::vector<int> aRGB = Config_PropManager::color("Visualization", "construction_axis_color",
 -                                                    CONSTRUCTION_AXIS_COLOR);
++                                                    ConstructionPlugin_Axis::DEFAULT_COLOR());
+   thePrs->setColor(aRGB[0], aRGB[1], aRGB[2]);
    thePrs->setLineStyle(3);
    thePrs->redisplay();
 -}
 +}
index 2b968ba593553a229efbc52ef920111993e57583,81e1b02b3749144fa9cea3a76c977110708efa4a..ef021ba50eb7caad950ef1202ffabed4c5a3aca0
  #include <ModelAPI_Feature.h>
  #include <GeomAPI_ICustomPrs.h>
  
 -
 -/// Point kind
 -const std::string CONSTRUCTION_AXIS_KIND("Axis");
 -
 -/// attribute name for first point
 -const std::string POINT_ATTR_FIRST = "firstPoint";
 -
 -/// attribute name for second point
 -const std::string POINT_ATTR_SECOND = "secondPoint";
 -
 -#define CONSTRUCTION_AXIS_COLOR "#000000"
--
  /**\class ConstructionPlugin_Axis
   * \ingroup Plugins
   * \brief Feature for creation of the new axis in PartSet.
@@@ -22,31 -33,10 +21,37 @@@ class ConstructionPlugin_Axis : public 
    /// Returns the kind of a feature
    CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
    {
 -    static std::string MY_KIND = CONSTRUCTION_AXIS_KIND;
 +    static std::string MY_KIND = ConstructionPlugin_Axis::ID();
      return MY_KIND;
    }
  
 +  /// Axis kind
 +  inline static const std::string& ID()
 +  {
 +    static const std::string CONSTRUCTION_AXIS_KIND("Axis");
 +    return CONSTRUCTION_AXIS_KIND;
 +  }
 +  /// attribute name for first point
 +  inline static const std::string& POINT_FIRST()
 +  {
 +    static const std::string POINT_ATTR_FIRST("firstPoint");
 +    return POINT_ATTR_FIRST;
 +  }
 +  /// attribute name for second point
 +  inline static const std::string& POINT_SECOND()
 +  {
 +    static const std::string POINT_ATTR_SECOND("secondPoint");
 +    return POINT_ATTR_SECOND;
 +  }
++  /// default color for an axis
++  inline static const std::string& DEFAULT_COLOR()
++  {
++    static const std::string CONSTRUCTION_AXIS_COLOR("#000000");
++    return CONSTRUCTION_AXIS_COLOR;
++  }
 +
 +  inline static const double MINIMAL_LENGTH() { return 1.e-5; }
 +
    /// Creates a new part document if needed
    CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
  
@@@ -64,4 -54,4 +69,4 @@@
  };
  
  
 -#endif
 +#endif
index 39fa27ed966998a30a1eef0955e2aff5ee762a1e,5b347354cc1677b513a931cbdcf0dfec0310b590..d0ecc4d7ee88012e5f239c892402f118851862a1
@@@ -6,6 -6,8 +6,8 @@@
  
  #include "ConstructionPlugin_Plane.h"
  
+ #include <Config_PropManager.h>
  #include <ModelAPI_AttributeSelection.h>
  #include <ModelAPI_AttributeDouble.h>
  #include <ModelAPI_ResultConstruction.h>
@@@ -22,14 -24,14 +24,14 @@@ ConstructionPlugin_Plane::ConstructionP
  
  void ConstructionPlugin_Plane::initAttributes()
  {
 -  data()->addAttribute(FACE_ATTR,  ModelAPI_AttributeSelection::type());
 -  data()->addAttribute(DISTANCE_ATTR, ModelAPI_AttributeDouble::type());
 +  data()->addAttribute(ConstructionPlugin_Plane::FACE(),  ModelAPI_AttributeSelection::type());
 +  data()->addAttribute(ConstructionPlugin_Plane::DISTANCE(), ModelAPI_AttributeDouble::type());
  }
  
  void ConstructionPlugin_Plane::execute()
  {
 -  AttributeSelectionPtr aFaceAttr = data()->selection(FACE_ATTR);
 -  AttributeDoublePtr aDistAttr = data()->real(DISTANCE_ATTR);
 +  AttributeSelectionPtr aFaceAttr = data()->selection(ConstructionPlugin_Plane::FACE());
 +  AttributeDoublePtr aDistAttr = data()->real(ConstructionPlugin_Plane::DISTANCE());
    if ((aFaceAttr.get() != NULL) && (aDistAttr.get() != NULL) && 
      aFaceAttr->isInitialized() && aDistAttr->isInitialized()) {
  
@@@ -73,6 -75,8 +75,8 @@@
  
  void ConstructionPlugin_Plane::customisePresentation(AISObjectPtr thePrs)
  {
-   thePrs->setColor(50, 255, 50);
+   std::vector<int> aRGB = Config_PropManager::color("Visualization", "construction_plane_color",
 -                                                    CONSTRUCTION_PLANE_COLOR);
++                                                    ConstructionPlugin_Plane::DEFAULT_COLOR());
+   thePrs->setColor(aRGB[0], aRGB[1], aRGB[2]);
    thePrs->setTransparensy(0.6);
 -}
 +}
index fd73f263e2fdbf2a1f770d15de9f4226aa75aea2,aedaff7f8e037e2c137d4ebbb322a39edf0b0ca8..f57ff1eb10099565f71d87486d4da7465c0ccb85
  #include <ModelAPI_Feature.h>
  #include <GeomAPI_ICustomPrs.h>
  
 -/// Point kind
 -const std::string CONSTRUCTION_PLANE_KIND("Plane");
  
 -/// attribute name for base face
 -const std::string FACE_ATTR = "planeFace";
 -
 -/// attribute name for distance
 -const std::string DISTANCE_ATTR = "distance";
  
  /**\class ConstructionPlugin_Plane
   * \ingroup Plugins
   * \brief Feature for creation of the new planar surface in PartSet.
   */
 -#define CONSTRUCTION_PLANE_COLOR "#32FF32"
 -
 -
  class ConstructionPlugin_Plane : public ModelAPI_Feature, public GeomAPI_ICustomPrs
  {
   public:
    /// Returns the kind of a feature
    CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
    {
 -    static std::string MY_KIND = CONSTRUCTION_PLANE_KIND;
 +    static std::string MY_KIND = ConstructionPlugin_Plane::ID();
      return MY_KIND;
    }
  
++  /// default color for a plane
++  inline static const std::string& DEFAULT_COLOR()
++  {
++    static const std::string CONSTRUCTION_PLANE_COLOR("#32FF32");
++    return CONSTRUCTION_PLANE_COLOR;
++  }
++
 +  /// Plane kind
 +  inline static const std::string& ID()
 +  {
 +    static const std::string CONSTRUCTION_PLANE_KIND("Plane");
 +    return CONSTRUCTION_PLANE_KIND;
 +  }
 +  /// attribute name for base face
 +  inline static const std::string& FACE()
 +  {
 +    static const std::string FACE_ATTR("planeFace");
 +    return FACE_ATTR;
 +  }
 +  /// attribute name for distance
 +  inline static const std::string& DISTANCE()
 +  {
 +    static const std::string DISTANCE_ATTR("distance");
 +    return DISTANCE_ATTR;
 +  }
 +
 +  /// the a parameter for the general equation of a plane (ax+by+cz+d=0)
 +  inline static const std::string& A()
 +  {
 +    static const std::string PARAM_A_ATTR("A");
 +    return PARAM_A_ATTR;
 +  }
 +  /// the b parameter for the general equation of a plane (ax+by+cz+d=0)
 +  inline static const std::string& B()
 +  {
 +    static const std::string PARAM_B_ATTR("B");
 +    return PARAM_B_ATTR;
 +  }
 +  /// the c parameter for the general equation of a plane (ax+by+cz+d=0)
 +  inline static const std::string& C()
 +  {
 +    static const std::string PARAM_C_ATTR("C");
 +    return PARAM_C_ATTR;
 +  }
 +  /// the d parameter for the general equation of a plane (ax+by+cz+d=0)
 +  inline static const std::string& D()
 +  {
 +    static const std::string PARAM_D_ATTR("D");
 +    return PARAM_D_ATTR;
 +  }
 +
    /// Creates a new part document if needed
    CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
  
    /// Request for initialization of data model of the feature: adding all attributes
    CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
  
 -  /// Construction result is allways recomuted on the fly
 +  /// Construction result is always recomputed on the fly
    CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
  
    /// Use plugin manager for features creation
@@@ -87,4 -53,4 +94,4 @@@
    virtual void customisePresentation(AISObjectPtr thePrs);
  };
  
 -#endif
 +#endif
index f06bd7635440f443c99e3bb42532f58711b33bb4,dff14b5b63453d8468fe84c4680144a13f3215f2..4731cc4c8c766fea1a5e00d6398838618711dd49
@@@ -5,6 -5,8 +5,8 @@@
  #include "ConstructionPlugin_Axis.h"
  #include "ConstructionPlugin_Plane.h"
  
+ #include <Config_PropManager.h>
  #include <ModelAPI_Session.h>
  #include <ModelAPI_Document.h>
  
@@@ -17,17 -19,25 +19,25 @@@ ConstructionPlugin_Plugin::Construction
  {
    // register this plugin
    ModelAPI_Session::get()->registerPlugin(this);
 -                                   Config_Prop::Color, CONSTRUCTION_POINT_COLOR);
+   // register construction properties
+   Config_PropManager::registerProp("Visualization", "construction_point_color", "Construction point color",
 -                                   Config_Prop::Color, CONSTRUCTION_AXIS_COLOR);
++                                   Config_Prop::Color, ConstructionPlugin_Point::DEFAULT_COLOR());
+   Config_PropManager::registerProp("Visualization", "construction_axis_color", "Construction axis color",
 -                                   Config_Prop::Color, CONSTRUCTION_PLANE_COLOR);
++                                   Config_Prop::Color, ConstructionPlugin_Axis::DEFAULT_COLOR());
+   Config_PropManager::registerProp("Visualization", "construction_plane_color", "Construction plane color",
++                                   Config_Prop::Color, ConstructionPlugin_Plane::DEFAULT_COLOR());
  }
  
  FeaturePtr ConstructionPlugin_Plugin::createFeature(string theFeatureID)
  {
 -  if (theFeatureID == CONSTRUCTION_POINT_KIND) {
 +  if (theFeatureID == ConstructionPlugin_Point::ID()) {
      return FeaturePtr(new ConstructionPlugin_Point);
    }
 -  else if (theFeatureID == CONSTRUCTION_AXIS_KIND) {
 +  else if (theFeatureID == ConstructionPlugin_Axis::ID()) {
      return FeaturePtr(new ConstructionPlugin_Axis);
    }
 -  else if (theFeatureID == CONSTRUCTION_PLANE_KIND) {
 +  else if (theFeatureID == ConstructionPlugin_Plane::ID()) {
      return FeaturePtr(new ConstructionPlugin_Plane);
    }
    // feature of such kind is not found
index 4c13dba4958abb832558f62db3d307c557470e4e,ab915408cac8c9834bd38101bd4ff8643f682d72..231e54fb2cddaa70bbcfbeb0b7d9f0adfe269791
  #include <GeomAlgoAPI_PointBuilder.h>
  #include <GeomAPI_Pnt.h>
  
+ #include <Config_PropManager.h>
  using namespace std;
  
  ConstructionPlugin_Point::ConstructionPlugin_Point()
  {
  }
  
 +const std::string& ConstructionPlugin_Point::getKind()
 +{
 +  static std::string MY_KIND = ConstructionPlugin_Point::ID();
 +  return MY_KIND;
 +}
 +
  void ConstructionPlugin_Point::initAttributes()
  {
 -  data()->addAttribute(POINT_ATTR_X, ModelAPI_AttributeDouble::type());
 -  data()->addAttribute(POINT_ATTR_Y, ModelAPI_AttributeDouble::type());
 -  data()->addAttribute(POINT_ATTR_Z, ModelAPI_AttributeDouble::type());
 +  data()->addAttribute(ConstructionPlugin_Point::X(), ModelAPI_AttributeDouble::type());
 +  data()->addAttribute(ConstructionPlugin_Point::Y(), ModelAPI_AttributeDouble::type());
 +  data()->addAttribute(ConstructionPlugin_Point::Z(), ModelAPI_AttributeDouble::type());
  }
  
  void ConstructionPlugin_Point::execute()
  {
    std::shared_ptr<GeomAPI_Pnt> aPnt(
 -      new GeomAPI_Pnt(data()->real(POINT_ATTR_X)->value(), data()->real(POINT_ATTR_Y)->value(),
 -                      data()->real(POINT_ATTR_Z)->value()));
 +      new GeomAPI_Pnt(data()->real(ConstructionPlugin_Point::X())->value(),
 +                      data()->real(ConstructionPlugin_Point::Y())->value(),
 +                      data()->real(ConstructionPlugin_Point::Z())->value()));
  
    std::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
    aConstr->setShape(GeomAlgoAPI_PointBuilder::point(aPnt));
    setResult(aConstr);
  }
 -                                                    CONSTRUCTION_POINT_COLOR);
+ void ConstructionPlugin_Point::customisePresentation(AISObjectPtr thePrs)
+ {
+   std::vector<int> aRGB = Config_PropManager::color("Visualization", "construction_point_color",
 -}
++                                                    ConstructionPlugin_Point::DEFAULT_COLOR());
+   thePrs->setColor(aRGB[0], aRGB[1], aRGB[2]);
+   thePrs->redisplay();
++}
index b0504698d93c7f9017edc73ad1ab98b925c45a9f,03f9d3a9f2b5d11bc172aeb99cd34d891c074424..f4bf39a1186fdc61b3ee35e42f3665a8b7a609fa
@@@ -9,40 -9,33 +9,48 @@@
  
  #include "ConstructionPlugin.h"
  #include <ModelAPI_Feature.h>
+ #include <GeomAPI_ICustomPrs.h>
  
 -
 -/// Point kind
 -const std::string CONSTRUCTION_POINT_KIND("Point");
 -
 -/// attribute name for X coordinate
 -const std::string POINT_ATTR_X = "x";
 -/// attribute name for Y coordinate
 -const std::string POINT_ATTR_Y = "y";
 -/// attribute name for Z coordinate
 -const std::string POINT_ATTR_Z = "z";
 -
 -#define CONSTRUCTION_POINT_COLOR "#ffff00"
 -
  /**\class ConstructionPlugin_Point
   * \ingroup Plugins
   * \brief Feature for creation of the new part in PartSet.
   */
- class ConstructionPlugin_Point : public ModelAPI_Feature
+ class ConstructionPlugin_Point : public ModelAPI_Feature, public GeomAPI_ICustomPrs
  {
   public:
    /// Returns the kind of a feature
 -  CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
 +  CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind();
 +
 +  inline static const std::string& ID()
 +  {
 +    static const std::string CONSTRUCTION_POINT_KIND("Point");
 +    return CONSTRUCTION_POINT_KIND;
 +  }
 +
++  /// default color for a point
++  inline static const std::string& DEFAULT_COLOR()
++  {
++    static const std::string CONSTRUCTION_POINT_COLOR("#ffff00");
++    return CONSTRUCTION_POINT_COLOR;
++  }
++
 +  /// attribute name for X coordinate
 +  inline static const std::string& X()
 +  {
 +    static const std::string POINT_ATTR_X("x");
 +    return POINT_ATTR_X;
 +  }
 +  /// attribute name for Y coordinate
 +  inline static const std::string& Y()
 +  {
 +    static const std::string POINT_ATTR_Y("y");
 +    return POINT_ATTR_Y;
 +  }
 +  /// attribute name for Z coordinate
 +  inline static const std::string& Z()
    {
 -    static std::string MY_KIND = CONSTRUCTION_POINT_KIND;
 -    return MY_KIND;
 +    static const std::string POINT_ATTR_Z("z");
 +    return POINT_ATTR_Z;
    }
  
    /// Creates a new part document if needed
  
    /// Use plugin manager for features creation
    ConstructionPlugin_Point();
+   /// Modifies the given presentation in the custom way.
+   virtual void customisePresentation(AISObjectPtr thePrs);
  };
  
  #endif