From: nds Date: Fri, 20 Feb 2015 10:23:53 +0000 (+0300) Subject: Color preferences for the sketch entities. X-Git-Tag: V_1.1.0~177 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f069f05f6800a491c1ea61a2490fbfdb9583193c;p=modules%2Fshaper.git Color preferences for the sketch entities. --- diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp b/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp index 8c025dd54..dff14b5b6 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp @@ -21,13 +21,12 @@ ConstructionPlugin_Plugin::ConstructionPlugin_Plugin() ModelAPI_Session::get()->registerPlugin(this); // register construction properties - Config_PropManager::registerProp("Visualization", "construction_plane_color", "Construction plane color", - Config_Prop::Color, CONSTRUCTION_PLANE_COLOR); - Config_PropManager::registerProp("Visualization", "construction_point_color", "Construction point color", Config_Prop::Color, CONSTRUCTION_POINT_COLOR); Config_PropManager::registerProp("Visualization", "construction_axis_color", "Construction axis color", Config_Prop::Color, CONSTRUCTION_AXIS_COLOR); + Config_PropManager::registerProp("Visualization", "construction_plane_color", "Construction plane color", + Config_Prop::Color, CONSTRUCTION_PLANE_COLOR); } FeaturePtr ConstructionPlugin_Plugin::createFeature(string theFeatureID) diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 1e9d79070..f3001c881 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -191,9 +191,16 @@ void PartSet_WidgetSketchLabel::showPreviewPlanes() std::shared_ptr aXZDir(new GeomAPI_Dir(0, 1, 0)); std::shared_ptr aXYDir(new GeomAPI_Dir(0, 0, 1)); - int aR[] = {255, 0, 0}; - int aG[] = {0, 255, 0}; - int aB[] = {0, 0, 255}; + std::vector aYZRGB, aXZRGB, aXYRGB; + aYZRGB = Config_PropManager::color("Visualization", "yz_plane_color", + YZ_PLANE_COLOR); + aXZRGB = Config_PropManager::color("Visualization", "xz_plane_color", + XZ_PLANE_COLOR); + aXYRGB = Config_PropManager::color("Visualization", "xy_plane_color", + XY_PLANE_COLOR); + int aR[] = {aYZRGB[0], aYZRGB[1], aYZRGB[2]}; + int aG[] = {aXZRGB[0], aXZRGB[1], aXZRGB[2]}; + int aB[] = {aXYRGB[0], aXYRGB[1], aXYRGB[2]}; myYZPlane = createPreviewPlane(anOrigin, aYZDir, aR); myXZPlane = createPreviewPlane(anOrigin, aXZDir, aG); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintBase.h b/src/SketchPlugin/SketchPlugin_ConstraintBase.h index 8636d3948..ddf0cbf7f 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintBase.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintBase.h @@ -30,6 +30,9 @@ * Also the list of possible attributes is provided to simplify assignment. */ +#define SKETCH_CONSTRAINT_COLOR "#ffff00" +#define SKETCH_DIMENSION_COLOR "#ff00ff" + /** \class SketchPlugin_ConstraintBase * \ingroup Plugins * \brief Feature for creation of a new constraint between other features. diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp index db309bae3..190665560 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp @@ -169,8 +169,8 @@ AISObjectPtr SketchPlugin_ConstraintDistance::getAISObject(AISObjectPtr thePrevi anAIS->createDistance(aPoint1, aPoint2, aFlyoutPnt, aPlane, aValue); // Set color from preferences - std::vector aRGB = Config_PropManager::color("Visualization", "distance_color", - DISTANCE_COLOR); + std::vector aRGB = Config_PropManager::color("Visualization", "sketch_dimension_color", + SKETCH_DIMENSION_COLOR); anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]); return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h index 99281efdb..9bc3d5d06 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h @@ -17,8 +17,6 @@ class SketchPlugin_Line; class GeomDataAPI_Point2D; -#define DISTANCE_COLOR "#ff00ff" - /** \class SketchPlugin_ConstraintDistance * \ingroup Plugins * \brief Feature for creation of a new constraint which defines a distance diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp index f0ac2e41d..da91dc583 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp @@ -141,8 +141,8 @@ AISObjectPtr SketchPlugin_ConstraintLength::getAISObject(AISObjectPtr thePreviou anAIS->createDistance(aPoint1, aPoint2, aFlyoutPnt, aPlane, aValue); // Set color from preferences - std::vector aRGB = - Config_PropManager::color("Visualization", "length_color", LENGTH_COLOR); + std::vector aRGB = Config_PropManager::color("Visualization", "sketch_dimension_color", + SKETCH_DIMENSION_COLOR); anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]); return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.h b/src/SketchPlugin/SketchPlugin_ConstraintLength.h index 5d36f051e..b3954b6fa 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.h @@ -14,8 +14,6 @@ class GeomDataAPI_Point2D; -#define LENGTH_COLOR "#ff00ff" - /** \class SketchPlugin_ConstraintLength * \ingroup Plugins * \brief Feature for creation of a new constraint which defines a length of a line segment diff --git a/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp index 6997f4f0a..ae26fc1c2 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp @@ -5,6 +5,7 @@ // Author: Artem ZHIDKOV #include "SketchPlugin_ConstraintParallel.h" +#include "SketchPlugin_ConstraintPerpendicular.h" #include #include @@ -86,8 +87,8 @@ AISObjectPtr SketchPlugin_ConstraintParallel::getAISObject(AISObjectPtr thePrevi anAIS->createParallel(aLine1, aLine2, aFlyoutPnt, aPlane); // Set color from preferences - std::vector aRGB = Config_PropManager::color("Visualization", "parallel_color", - PARALLEL_COLOR); + std::vector aRGB = Config_PropManager::color("Visualization", "sketch_parallel_color", + SKETCH_CONSTRAINT_COLOR); anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]); return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintParallel.h b/src/SketchPlugin/SketchPlugin_ConstraintParallel.h index 4f3969073..87f69fe70 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintParallel.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintParallel.h @@ -11,8 +11,6 @@ #include #include "SketchPlugin_ConstraintBase.h" -#define PARALLEL_COLOR "#ffff00" - /** \class SketchPlugin_ConstraintParallel * \ingroup Plugins * \brief Feature for creation of a new constraint parallelism of two lines diff --git a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp index c63555da5..770eac2ef 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp @@ -5,6 +5,7 @@ // Author: Artem ZHIDKOV #include "SketchPlugin_ConstraintPerpendicular.h" +#include "SketchPlugin_ConstraintParallel.h" #include #include @@ -78,8 +79,8 @@ AISObjectPtr SketchPlugin_ConstraintPerpendicular::getAISObject(AISObjectPtr the anAIS->createPerpendicular(aLine1, aLine2, aPlane); // Set color from preferences - std::vector aRGB = Config_PropManager::color("Visualization", "perpendicular_color", - PERPENDICULAR_COLOR); + std::vector aRGB = Config_PropManager::color("Visualization", "sketch_parallel_color", + SKETCH_CONSTRAINT_COLOR); anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]); return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h index f0998fa14..fa5eaacec 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h @@ -11,8 +11,6 @@ #include #include "SketchPlugin_ConstraintBase.h" -#define PERPENDICULAR_COLOR "#ffff00" - /** \class SketchPlugin_ConstraintPerpendicular * \ingroup Plugins * \brief Feature for creation of a new constraint for perpendicularity of two lines diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp index 17e16655a..528d636ae 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp @@ -173,7 +173,8 @@ AISObjectPtr SketchPlugin_ConstraintRadius::getAISObject(AISObjectPtr thePreviou anAIS->createRadius(aCircle, aFlyoutPnt, aRadius); // Set color from preferences - std::vector aRGB = Config_PropManager::color("Visualization", "radius_color", RADIUS_COLOR); + std::vector aRGB = Config_PropManager::color("Visualization", "sketch_dimension_color", + SKETCH_DIMENSION_COLOR); anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]); return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRadius.h b/src/SketchPlugin/SketchPlugin_ConstraintRadius.h index 4d6b9a3be..5400bc443 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRadius.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintRadius.h @@ -11,8 +11,6 @@ #include #include "SketchPlugin_ConstraintBase.h" -#define RADIUS_COLOR "#ff00ff" - /** \class SketchPlugin_ConstraintRadius * \ingroup Plugins * \brief Feature for creation of a new constraint which defines diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp b/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp index 00e973d1a..cd1aa6e73 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp @@ -5,6 +5,7 @@ // Author: Artem ZHIDKOV #include "SketchPlugin_ConstraintRigid.h" +#include "SketchPlugin_ConstraintParallel.h" #include #include @@ -70,8 +71,9 @@ AISObjectPtr SketchPlugin_ConstraintRigid::getAISObject(AISObjectPtr thePrevious anAIS->createFixed(aShape, aPlane); // Set color from preferences - std::vector aRGB = Config_PropManager::color("Visualization", "fixing_color", - FIXING_COLOR); + std::vector aRGB = Config_PropManager::color("Visualization", "sketch_parallel_color", + SKETCH_CONSTRAINT_COLOR); + anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]); return anAIS; diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRigid.h b/src/SketchPlugin/SketchPlugin_ConstraintRigid.h index 5c94bcba6..619a8bbd9 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRigid.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintRigid.h @@ -12,8 +12,6 @@ #include #include -#define FIXING_COLOR "#ffff00" - /** \class SketchPlugin_ConstraintRigid * \ingroup Plugins * \brief Feature for creation of a new constraint which defines immovable object diff --git a/src/SketchPlugin/SketchPlugin_Feature.h b/src/SketchPlugin/SketchPlugin_Feature.h index 7a50ef4e3..248f19c7b 100644 --- a/src/SketchPlugin/SketchPlugin_Feature.h +++ b/src/SketchPlugin/SketchPlugin_Feature.h @@ -15,6 +15,12 @@ #include #include +#include + +#define SKETCH_EDGE_COLOR "#ff0000" +#define SKETCH_POINT_COLOR "#ff0000" +#define SKETCH_EXTERNAL_EDGE_COLOR "#00ff00" + class SketchPlugin_Sketch; class GeomAPI_Pnt2d; class Handle_AIS_InteractiveObject; @@ -67,15 +73,31 @@ class SketchPlugin_Feature : public ModelAPI_Feature, public GeomAPI_ICustomPrs /// Customize presentation of the feature virtual void customisePresentation(AISObjectPtr thePrs) { + std::vector aRGB; // if this is an edge if (thePrs->getShapeType() == 6) { thePrs->setWidth(3); - if (isExternal()) - thePrs->setColor(0,255,0); + if (isExternal()) { + // Set color from preferences + aRGB = Config_PropManager::color("Visualization", "sketch_external_color", + SKETCH_EXTERNAL_EDGE_COLOR); + } + else { + // Set color from preferences + aRGB = Config_PropManager::color("Visualization", "sketch_edge_color", + SKETCH_EDGE_COLOR); + } + } + else if (thePrs->getShapeType() == 7) { // otherwise this is a vertex + // Set color from preferences + aRGB = Config_PropManager::color("Visualization", "sketch_point_color", + SKETCH_POINT_COLOR); } // if this is a vertex //else if (thePrs->getShapeType() == 7) // thePrs->setPointMarker(6, 2.); + if (!aRGB.empty()) + thePrs->setColor(aRGB[0], aRGB[1], aRGB[2]); } /// removes also all sub-sketch elements diff --git a/src/SketchPlugin/SketchPlugin_Plugin.cpp b/src/SketchPlugin/SketchPlugin_Plugin.cpp index 030f786f1..c486acf65 100644 --- a/src/SketchPlugin/SketchPlugin_Plugin.cpp +++ b/src/SketchPlugin/SketchPlugin_Plugin.cpp @@ -32,6 +32,8 @@ #include #endif +//#define SET_PLANES_COLOR_IN_PREFERENCES + using namespace std; // the only created instance of this plugin @@ -52,21 +54,29 @@ SketchPlugin_Plugin::SketchPlugin_Plugin() // register this plugin ModelAPI_Session::get()->registerPlugin(this); - // register sketcher properties + Config_PropManager::registerProp("Visualization", "sketch_edge_color", "Sketch edge color", + Config_Prop::Color, SKETCH_EDGE_COLOR); + + Config_PropManager::registerProp("Visualization", "sketch_point_color", "Sketch point color", + Config_Prop::Color, SKETCH_POINT_COLOR); + + Config_PropManager::registerProp("Visualization", "sketch_external_color", "Sketch external edge color", + Config_Prop::Color, SKETCH_EXTERNAL_EDGE_COLOR); - Config_PropManager::registerProp("Visualization", "parallel_color", "Parallel constraint color", - Config_Prop::Color, PARALLEL_COLOR); - Config_PropManager::registerProp("Visualization", "perpendicular_color", - "Perpendicular constraint color", Config_Prop::Color, - PERPENDICULAR_COLOR); - Config_PropManager::registerProp("Visualization", "distance_color", "Distance color", - Config_Prop::Color, DISTANCE_COLOR); - Config_PropManager::registerProp("Visualization", "length_color", "Length color", - Config_Prop::Color, LENGTH_COLOR); - Config_PropManager::registerProp("Visualization", "radius_color", "Radius color", - Config_Prop::Color, RADIUS_COLOR); - Config_PropManager::registerProp("Visualization", "fixing_color", "Fixing color", - Config_Prop::Color, FIXING_COLOR); + Config_PropManager::registerProp("Visualization", "sketch_parallel_color", "Sketch constraint color", + Config_Prop::Color, SKETCH_CONSTRAINT_COLOR); + Config_PropManager::registerProp("Visualization", "sketch_dimension_color", "Sketch dimension color", + Config_Prop::Color, SKETCH_DIMENSION_COLOR); + + // register sketcher properties +#ifdef SET_PLANES_COLOR_IN_PREFERENCES + Config_PropManager::registerProp("Visualization", "yz_plane_color", "YZ plane color", + Config_Prop::Color, YZ_PLANE_COLOR); + Config_PropManager::registerProp("Visualization", "xz_plane_color", "XZ plane color", + Config_Prop::Color, XZ_PLANE_COLOR); + Config_PropManager::registerProp("Visualization", "xy_plane_color", "XY plane color", + Config_Prop::Color, XY_PLANE_COLOR); +#endif } FeaturePtr SketchPlugin_Plugin::createFeature(string theFeatureID) diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index cb3efbea6..f6978b6ab 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -14,6 +14,10 @@ #include #include +#define YZ_PLANE_COLOR "#ff0000" +#define XZ_PLANE_COLOR "#00ff00" +#define XY_PLANE_COLOR "#0000ff" + /**\class SketchPlugin_Sketch * \ingroup Plugins * \brief Feature for creation of the new part in PartSet. diff --git a/src/SketchSolver/CMakeLists.txt b/src/SketchSolver/CMakeLists.txt index cd1ca4297..572c8b0c7 100644 --- a/src/SketchSolver/CMakeLists.txt +++ b/src/SketchSolver/CMakeLists.txt @@ -21,12 +21,14 @@ SET(PROJECT_SOURCES SET(PROJECT_LIBRARIES ${SLVS_LIBRARIES} ${CAS_SHAPE} + Config Events ModelAPI GeomAPI ) INCLUDE_DIRECTORIES( + ${PROJECT_SOURCE_DIR}/src/Config ${PROJECT_SOURCE_DIR}/src/SketchPlugin ${PROJECT_SOURCE_DIR}/src/ModelAPI ${PROJECT_SOURCE_DIR}/src/GeomAPI