#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());
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();
-}
+}
#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.
/// 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();
};
-#endif
+#endif
#include "ConstructionPlugin_Plane.h"
+ #include <Config_PropManager.h>
+
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_ResultConstruction.h>
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()) {
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);
-}
+}
#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
virtual void customisePresentation(AISObjectPtr thePrs);
};
-#endif
+#endif
#include "ConstructionPlugin_Axis.h"
#include "ConstructionPlugin_Plane.h"
+ #include <Config_PropManager.h>
+
#include <ModelAPI_Session.h>
#include <ModelAPI_Document.h>
{
// 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
#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();
++}
#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