From: nds Date: Tue, 10 Mar 2015 13:30:47 +0000 (+0300) Subject: Change color for construction/body/group. X-Git-Tag: V_1.1.0~143^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=51946078419dc8b23701496c09e689c8abdfc897;p=modules%2Fshaper.git Change color for construction/body/group. --- diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index 7b7e3c3be..784eff153 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -37,8 +37,6 @@ //#include //#define DEB_IMPORT 1 -#define RESULT_BODY_COLOR "#E0A01B" - Model_ResultBody::Model_ResultBody() { setIsConcealed(false); @@ -51,7 +49,7 @@ void Model_ResultBody::initAttributes() aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::type()); AttributeIntArrayPtr aColorAttr = aData->intArray(COLOR_ID()); std::vector aRGB; - aRGB = Config_PropManager::color("Visualization", "result_body_color", RESULT_BODY_COLOR); + aRGB = Config_PropManager::color("Visualization", "result_body_color", DEFAULT_COLOR()); aColorAttr->setSize(3); aColorAttr->setValue(0, aRGB[0]); aColorAttr->setValue(1, aRGB[1]); diff --git a/src/Model/Model_ResultBody.h b/src/Model/Model_ResultBody.h index 5b849c620..e7fdcb5ca 100644 --- a/src/Model/Model_ResultBody.h +++ b/src/Model/Model_ResultBody.h @@ -29,6 +29,13 @@ class Model_ResultBody : public ModelAPI_ResultBody /// label; index in vector corresponds to the label tag std::vector myBuilders; public: + /// default color for a result body + inline static const std::string& DEFAULT_COLOR() + { + static const std::string RESULT_BODY_COLOR("#E0A01B"); + return RESULT_BODY_COLOR; + } + /// Request for initialization of data model of the result: adding all attributes virtual void initAttributes(); diff --git a/src/Model/Model_ResultConstruction.cpp b/src/Model/Model_ResultConstruction.cpp index aaade70ff..97f2b4fcd 100644 --- a/src/Model/Model_ResultConstruction.cpp +++ b/src/Model/Model_ResultConstruction.cpp @@ -6,6 +6,23 @@ #include +#include +#include + +void Model_ResultConstruction::initAttributes() +{ + // append the color attribute + DataPtr aData = data(); + aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::type()); + AttributeIntArrayPtr aColorAttr = aData->intArray(COLOR_ID()); + std::vector aRGB; + aRGB = Config_PropManager::color("Visualization", "result_construction_color", DEFAULT_COLOR()); + aColorAttr->setSize(3); + aColorAttr->setValue(0, aRGB[0]); + aColorAttr->setValue(1, aRGB[1]); + aColorAttr->setValue(2, aRGB[2]); +} + void Model_ResultConstruction::setShape(std::shared_ptr theShape) { myShape = theShape; diff --git a/src/Model/Model_ResultConstruction.h b/src/Model/Model_ResultConstruction.h index a66aeeb5a..2fb81219d 100644 --- a/src/Model/Model_ResultConstruction.h +++ b/src/Model/Model_ResultConstruction.h @@ -23,6 +23,16 @@ class Model_ResultConstruction : public ModelAPI_ResultConstruction std::shared_ptr myShape; ///< shape of this result created "on the fly" bool myIsInHistory; public: + /// default color for a result construction + inline static const std::string& DEFAULT_COLOR() + { + static const std::string RESULT_CONSTRUCTION_COLOR("#000000"); + return RESULT_CONSTRUCTION_COLOR; + } + + /// Request for initialization of data model of the result: adding all attributes + virtual void initAttributes(); + /// By default object is displayed in the object browser. MODEL_EXPORT virtual bool isInHistory() { diff --git a/src/Model/Model_ResultGroup.cpp b/src/Model/Model_ResultGroup.cpp index ebcdb9b43..a0a5922cd 100644 --- a/src/Model/Model_ResultGroup.cpp +++ b/src/Model/Model_ResultGroup.cpp @@ -6,14 +6,32 @@ #include #include +#include + #include +#include + Model_ResultGroup::Model_ResultGroup(std::shared_ptr theOwnerData) { setIsConcealed(false); myOwnerData = theOwnerData; } +void Model_ResultGroup::initAttributes() +{ + // append the color attribute + DataPtr aData = data(); + aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::type()); + AttributeIntArrayPtr aColorAttr = aData->intArray(COLOR_ID()); + std::vector aRGB; + aRGB = Config_PropManager::color("Visualization", "result_group_color", DEFAULT_COLOR()); + aColorAttr->setSize(3); + aColorAttr->setValue(0, aRGB[0]); + aColorAttr->setValue(1, aRGB[1]); + aColorAttr->setValue(2, aRGB[2]); +} + std::shared_ptr Model_ResultGroup::shape() { std::shared_ptr aResult; diff --git a/src/Model/Model_ResultGroup.h b/src/Model/Model_ResultGroup.h index 33b4351c9..33c0e17a7 100644 --- a/src/Model/Model_ResultGroup.h +++ b/src/Model/Model_ResultGroup.h @@ -20,6 +20,15 @@ class Model_ResultGroup : public ModelAPI_ResultGroup { std::shared_ptr myOwnerData; ///< data of owner of this result public: + /// default color for a result body + inline static const std::string& DEFAULT_COLOR() + { + static const std::string RESULT_GROUP_COLOR("#E0A01B"); + return RESULT_GROUP_COLOR; + } + /// Request for initialization of data model of the result: adding all attributes + virtual void initAttributes(); + /// Returns the compound of selected entities MODEL_EXPORT virtual std::shared_ptr shape(); diff --git a/src/ModuleBase/ModuleBase_Preferences.cpp b/src/ModuleBase/ModuleBase_Preferences.cpp index 616e659e0..4d4d1c78d 100644 --- a/src/ModuleBase/ModuleBase_Preferences.cpp +++ b/src/ModuleBase/ModuleBase_Preferences.cpp @@ -7,6 +7,10 @@ #include "ModuleBase_Preferences.h" //#include "ModuleBase_Constants.h" +#include +#include +#include + #include #include @@ -256,6 +260,13 @@ void ModuleBase_PreferencesDlg::createViewerPage(int thePageId) myPreferences->setItemProperty("texture_stretch_enabled", true, bgId); myPreferences->setItemProperty("custom_enabled", false, bgId); myPreferences->setItemProperty("image_formats", aImgFiles, bgId); + + Config_PropManager::registerProp("Visualization", "result_body_color", "Body color", + Config_Prop::Color, Model_ResultBody::DEFAULT_COLOR()); + Config_PropManager::registerProp("Visualization", "result_group_color", "Group color", + Config_Prop::Color, Model_ResultGroup::DEFAULT_COLOR()); + Config_PropManager::registerProp("Visualization", "result_construction_color", "Construction color", + Config_Prop::Color, Model_ResultConstruction::DEFAULT_COLOR()); } void ModuleBase_PreferencesDlg::createMenuPage(int thePageId) diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 0db30a145..9d6884b92 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -772,13 +772,11 @@ void XGUI_Displayer::customizeObject(ObjectPtr theObject) anAISObj->setColor(aRed, aGreen, aBlue); } } - else { - // Customization of presentation - FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); - if (aFeature.get() != NULL) { - GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast(aFeature); - if (aCustPrs.get() != NULL) - aCustPrs->customisePresentation(anAISObj); - } + // Customization of presentation + FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); + if (aFeature.get() != NULL) { + GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast(aFeature); + if (aCustPrs.get() != NULL) + aCustPrs->customisePresentation(anAISObj); } } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index dacaa1512..45f12d0d5 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -39,6 +39,7 @@ #include #include #include +#include //#include @@ -75,6 +76,10 @@ #include #include #include +#include +#include +#include +#include #ifdef _DEBUG #include @@ -1404,11 +1409,6 @@ bool XGUI_Workshop::canChangeColor() const } //************************************************************** -#include -#include -#include -#include -#include void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects) { // 1. find the initial value of the color @@ -1456,11 +1456,12 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects) return; // 3. abort the previous operation and start a new one - if(!isActiveOperationAborted()) - return; SessionPtr aMgr = ModelAPI_Session::get(); - QString aDescription = contextMenuMgr()->action("DELETE_CMD")->text(); - aMgr->startOperation(aDescription.toStdString()); + bool aWasOperation = aMgr->isOperation(); // keep this value + if (!aWasOperation) { + QString aDescription = contextMenuMgr()->action("DELETE_CMD")->text(); + aMgr->startOperation(aDescription.toStdString()); + } // 4. set the value to all results static Events_ID EVENT_DISP = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); @@ -1479,7 +1480,8 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects) } } } - aMgr->finishOperation(); + if (!aWasOperation) + aMgr->finishOperation(); updateCommandStatus(); }