//#include <TDF_Tool.hxx>
//#define DEB_IMPORT 1
-#define RESULT_BODY_COLOR "#E0A01B"
-
Model_ResultBody::Model_ResultBody()
{
setIsConcealed(false);
aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::type());
AttributeIntArrayPtr aColorAttr = aData->intArray(COLOR_ID());
std::vector<int> 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]);
/// label; index in vector corresponds to the label tag
std::vector<TNaming_Builder*> 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();
#include <Model_ResultConstruction.h>
+#include <ModelAPI_AttributeIntArray.h>
+#include <Config_PropManager.h>
+
+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<int> 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<GeomAPI_Shape> theShape)
{
myShape = theShape;
std::shared_ptr<GeomAPI_Shape> 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()
{
#include <Model_ResultGroup.h>
#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeIntArray.h>
+
#include <GeomAlgoAPI_CompoundBuilder.h>
+#include <Config_PropManager.h>
+
Model_ResultGroup::Model_ResultGroup(std::shared_ptr<ModelAPI_Data> 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<int> 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<GeomAPI_Shape> Model_ResultGroup::shape()
{
std::shared_ptr<GeomAPI_Shape> aResult;
{
std::shared_ptr<ModelAPI_Data> 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<GeomAPI_Shape> shape();
#include "ModuleBase_Preferences.h"
//#include "ModuleBase_Constants.h"
+#include <Model_ResultBody.h>
+#include <Model_ResultGroup.h>
+#include <Model_ResultConstruction.h>
+
#include <Config_PropManager.h>
#include <SUIT_ResourceMgr.h>
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)
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<GeomAPI_ICustomPrs>(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<GeomAPI_ICustomPrs>(aFeature);
+ if (aCustPrs.get() != NULL)
+ aCustPrs->customisePresentation(anAISObj);
}
}
#include <ModelAPI_ResultGroup.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_AttributeIntArray.h>
//#include <PartSetPlugin_Part.h>
#include <QMenu>
#include <QToolButton>
#include <QAction>
+#include <QDialog>
+#include <QDialogButtonBox>
+#include <QHBoxLayout>
+#include <QtxColorButton.h>
#ifdef _DEBUG
#include <QDebug>
}
//**************************************************************
-#include <QDialog>
-#include <QDialogButtonBox>
-#include <QHBoxLayout>
-#include <QtxColorButton.h>
-#include <ModelAPI_AttributeIntArray.h>
void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects)
{
// 1. find the initial value of the color
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);
}
}
}
- aMgr->finishOperation();
+ if (!aWasOperation)
+ aMgr->finishOperation();
updateCommandStatus();
}