const static char* ATTR_MODIFIED_IN_EDIT = "modified_in_edit";
const static char* ATTR_MAIN_ARG = "main_argument";
const static char* ATTR_GEOMETRICAL_SELECTION = "geometrical_selection";
+const static char* ATTR_VISUAL_CHANGED = "change_visual_attributes";
// WDG_INFO properties
}
void Model_AttributeIntArray::setValue(const int theIndex,
- const int theValue)
+ const int theValue,
+ bool sendUpdated)
{
if (myArray->Value(theIndex) != theValue) {
myArray->SetValue(theIndex, theValue);
- owner()->data()->sendAttributeUpdated(this);
+ if (sendUpdated)
+ owner()->data()->sendAttributeUpdated(this);
}
}
/// Defines the value of the array by index [0; size-1]
MODEL_EXPORT virtual void setValue(const int theIndex,
- const int theValue);
+ const int theValue,
+ bool sendUpdated = true);
/// Returns the value by the index
MODEL_EXPORT virtual int value(const int theIndex);
/// Defines the value of the array by index [0; size-1]
MODELAPI_EXPORT virtual void setValue(const int theIndex,
- const int theValue) = 0;
+ const int theValue,
+ bool sendUpdated = true) = 0;
/// Returns the value by the index
MODELAPI_EXPORT virtual int value(const int theIndex) = 0;
/// Event ID that provides a request for list of non-fixed objects necessary for DoF = 0
static const char * EVENT_DOF_OBJECTS = "DoFObjects";
+/// Event ID that requests updates visual attributes for presentations
+static const char * EVENT_VISUAL_ATTRIBUTES = "UpdateVisualAttributes";
+
/// Message that feature was changed (used for Object Browser update): moved, updated and deleted
class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
{
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_AttributeDocRef.h>
#include <ModelAPI_Validator.h>
+#include <ModelAPI_AttributeIntArray.h>
#include <list>
#include <map>
#include <iostream>
}
}
+double getDeflection(const std::shared_ptr<ModelAPI_Result>& theResult)
+{
+ double aDeflection = -1;
+ // get deflection from the attribute of the result
+ if (theResult.get() != NULL &&
+ theResult->data()->attribute(ModelAPI_Result::DEFLECTION_ID()).get() != NULL) {
+ AttributeDoublePtr aDoubleAttr = theResult->data()->real(ModelAPI_Result::DEFLECTION_ID());
+ if (aDoubleAttr.get() && aDoubleAttr->isInitialized()) {
+ double aValue = aDoubleAttr->value();
+ if (aValue > 0) /// zero value should not be used as a deflection(previous studies)
+ aDeflection = aDoubleAttr->value();
+ }
+ }
+ return aDeflection;
+}
+
+
+void getColor(const std::shared_ptr<ModelAPI_Result>& theResult, std::vector<int>& theColor)
+{
+ theColor.clear();
+ // get color from the attribute of the result
+ if (theResult.get() != NULL &&
+ theResult->data()->attribute(ModelAPI_Result::COLOR_ID()).get() != NULL) {
+ AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID());
+ if (aColorAttr.get() && aColorAttr->size()) {
+ theColor.push_back(aColorAttr->value(0));
+ theColor.push_back(aColorAttr->value(1));
+ theColor.push_back(aColorAttr->value(2));
+ }
+ }
+}
+
+double getTransparency(const std::shared_ptr<ModelAPI_Result>& theResult)
+{
+ double aTransparency = -1;
+ // get transparency from the attribute of the result
+ if (theResult.get() != NULL &&
+ theResult->data()->attribute(ModelAPI_Result::TRANSPARENCY_ID()).get() != NULL) {
+ AttributeDoublePtr aDoubleAttr = theResult->data()->real(ModelAPI_Result::TRANSPARENCY_ID());
+ if (aDoubleAttr.get() && aDoubleAttr->isInitialized()) {
+ aTransparency = aDoubleAttr->value();
+ }
+ }
+ return aTransparency;
+}
+
} // namespace ModelAPI_Tools
/*! Creates a remove result features with the given results
*/
MODELAPI_EXPORT void removeResults(const std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
+
+/*! Returns current deflection in the given result
+* \param theResult a result object
+* \return a deflection value or -1 if it was not defined
+*/
+MODELAPI_EXPORT double getDeflection(const std::shared_ptr<ModelAPI_Result>& theResult);
+
+/*! Returns current color of the current result
+* \param[in] theResult a result object
+* \param[out] theColor a color values if it is defined
+*/
+MODELAPI_EXPORT void getColor(const std::shared_ptr<ModelAPI_Result>& theResult,
+ std::vector<int>& theColor);
+
+/*! Returns current transparency in the given result
+* \param theResult a result object
+* \return a transparency value or -1 if it was not defined
+*/
+MODELAPI_EXPORT double getTransparency(const std::shared_ptr<ModelAPI_Result>& theResult);
+
}
#endif
}
}
-Handle(AIS_InteractiveObject) ModuleBase_IModule::createPresentation(const ObjectPtr& theResult)
+AISObjectPtr ModuleBase_IModule::createPresentation(const ObjectPtr& theResult)
{
- return Handle(AIS_InteractiveObject)();
+ return AISObjectPtr();
}
bool ModuleBase_IModule::canBeShaded(Handle(AIS_InteractiveObject) theAIS) const
return new ModuleBase_OperationFeature(theFeatureId.c_str(), this);
}
-bool ModuleBase_IModule::customizeObject(ObjectPtr theObject,
- const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
- const bool theUpdateViewer)
-{
- return false;
-}
-
ModuleBase_Operation* ModuleBase_IModule::createOperation(const std::string& theFeatureId)
{
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
const bool theUpdateViewer) {}
/// Modifies the given presentation in the custom way.
- virtual bool customisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
- AISObjectPtr thePrs,
- GeomCustomPrsPtr theCustomPrs) { return false; };
+ //virtual bool customisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
+ // AISObjectPtr thePrs,
+ // GeomCustomPrsPtr theCustomPrs) { return false; };
- /// Modifies the given presentation in the custom way after usual customize is performed.
- virtual bool afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
- AISObjectPtr thePrs,
- GeomCustomPrsPtr theCustomPrs) { return false; };
+ ///// Modifies the given presentation in the custom way after usual customize is performed.
+ //virtual bool afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
+ // AISObjectPtr thePrs,
+ // GeomCustomPrsPtr theCustomPrs) { return false; };
/// Update the object presentable properties such as color, lines width and other
/// If the object is result with the color attribute value set, it is used,
/// should be updated(e.g. only highlighted elements)
/// \param theUpdateViewer the parameter whether the viewer should be update immediately
/// \returns true if the object is modified
- virtual bool customizeObject(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
- const bool theUpdateViewer);
+ virtual bool customizeFeature(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
+ const bool theUpdateViewer) {
+ return false;
+ }
/// Disable displaying of custom mode
/// \param theMode a mode to disable
/// \param theCmdId the operation name
virtual ModuleBase_Operation* createOperation(const std::string& theCmdId);
- /// Create specific for the module presentation
+ /// Create specific for the module presentation. The presentation has to be
+ /// customized accordingly to the object.
/// \param theResult an object for presentation
/// \return created presentation or NULL(default value)
- virtual Handle(AIS_InteractiveObject) createPresentation(const ObjectPtr& theResult);
+ virtual AISObjectPtr createPresentation(const ObjectPtr& theResult);
+
+ /// Customize presentation according to objects attributes
+ /// \param theObject an object for presentation
+ /// \param thePrs a presentation object
+ virtual void customizePresentation(const ObjectPtr& theObject, const AISObjectPtr& thePrs) const {}
//! Returns data object by AIS
virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const = 0;
//**************************************************************
ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent,
- const Config_WidgetAPI* theData)
- : QWidget(theParent),
- myIsEditing(false),
- myState(Stored),
- myIsValueStateBlocked(false),
- myFlushUpdateBlocked(false),
- myWidgetValidator(0)
+ const Config_WidgetAPI* theData)
+ : QWidget(theParent),
+ myIsEditing(false),
+ myState(Stored),
+ myIsValueStateBlocked(false),
+ myFlushUpdateBlocked(false),
+ myWidgetValidator(0)
{
#ifdef DEBUG_WIDGET_INSTANCE
qDebug("ModuleBase_ModelWidget::ModuleBase_ModelWidget");
myIsModifiedInEdit = theData->getProperty(ATTR_MODIFIED_IN_EDIT);
+ myUpdateVisualAttributes = theData->getBooleanAttribute(ATTR_VISUAL_CHANGED, false);
+
myDefaultValue = theData->getProperty(ATTR_DEFAULT);
myUseReset = theData->getBooleanAttribute(ATTR_USE_RESET, true);
myIsComputedDefault = theData->getProperty(ATTR_DEFAULT) == DOUBLE_WDG_DEFAULT_COMPUTED;
#ifdef DEBUG_WIDGET_INSTANCE
qDebug("ModuleBase_ModelWidget::updateObject");
#endif
+ if (myFeature.get() && myUpdateVisualAttributes) {
+ static const Events_ID anEvent = Events_Loop::eventByName(EVENT_VISUAL_ATTRIBUTES);
+ ModelAPI_EventCreator::get()->sendUpdated(myFeature, anEvent);
+ }
ModuleBase_Tools::flushUpdated(theObject);
emit objectUpdated();
}
bool myIsValueStateBlocked;
/// do not flush updated signal
bool myFlushUpdateBlocked;
+
+ bool myUpdateVisualAttributes;
};
#endif
// (for the sketch result) to start processing of the sketch in the solver.
// TODO: these flushes should be moved in a separate method provided by Model
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_VISUAL_ATTRIBUTES));
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
theValues.append(anInvalidValues);
if (isDone) // may be the feature's result is not displayed, but attributes should be
- myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeArguments,
+ myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeArguments,
true);/// hope that something is redisplayed by object updated
return isDone;
myWorkshop->setSelected(getAttributeSelection());
// may be the feature's result is not displayed, but attributes should be
- myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeArguments,
+ myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeArguments,
true); /// hope that something is redisplayed by object updated
}
restoreValue();
myWorkshop->setSelected(getAttributeSelection());
// may be the feature's result is not displayed, but attributes should be
- myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeArguments,
+ myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeArguments,
true); /// hope that something is redisplayed by object updated
// clear history should follow after set selected to do not increase history by setSelected
clearSelectedHistory();
//********************************************************************
void ModuleBase_WidgetMultiSelector::onListSelection()
{
- myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeHighlightedObjects,
- true);
+ myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeHighlightedObjects,
+ true);
}
//********************************************************************
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include <PartSet_CustomPrs.h>
-#include <PartSet_Module.h>
+#include "PartSet_CustomPrs.h"
+#include "PartSet_Module.h"
#include "PartSet_OperationPrs.h"
#include "PartSet_OverconstraintListener.h"
+#include "PartSet_SketcherMgr.h"
#include <XGUI_ModuleConnector.h>
#include <XGUI_Workshop.h>
#include <ModuleBase_IViewer.h>
#include <ModuleBase_Tools.h>
+#include <ModelAPI_Tools.h>
+#include <SketchPlugin_Sketch.h>
+
#include <Config_PropManager.h>
#include <Events_Loop.h>
#include <ModelAPI_Events.h>
#ifdef DO_NOT_VISUALIZE_CUSTOM_PRESENTATION
return false;
#endif
+ bool isModified = false;
- myIsActive[theFlag] = true;
- myFeature = theFeature;
+ // Do not call customisation for sketcher and all its sub-objects
+ if (theFeature->getKind() == SketchPlugin_Sketch::ID())
+ return isModified;
+
+ FeaturePtr aParent = ModelAPI_Tools::compositeOwner(theFeature);
+ if (aParent.get()) {
+ std::string aType = aParent->getKind();
+ if (aType == SketchPlugin_Sketch::ID())
+ return isModified;
+ }
- bool isModified = false;
if (theFeature.get()) {
+ myIsActive[theFlag] = true;
+ myFeature = theFeature;
displayPresentation(theFlag, theUpdateViewer);
isModified = true;
}
#include <ModuleBase_WidgetFactory.h>
#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_ViewerPrs.h>
-#include <ModelAPI_ResultField.h>
+#include <ModuleBase_ResultPrs.h>
+#include <ModelAPI_ResultField.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_Events.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_AttributeIntArray.h>
+#include <ModelAPI_ResultGroup.h>
#include <GeomDataAPI_Point2D.h>
#include <GeomDataAPI_Point.h>
#include <XGUI_ActiveControlSelector.h>
#include <XGUI_ActionsMgr.h>
#include <XGUI_ContextMenuMgr.h>
-#include <XGUI_CustomPrs.h>
#include <XGUI_DataModel.h>
#include <XGUI_Displayer.h>
#include <XGUI_ErrorMgr.h>
setDefaultConstraintShown();
+ //Config_PropManager::registerProp("Visualization", "object_default_color", "Object color",
+ // Config_Prop::Color, "225,225,225");
+
+ Config_PropManager::registerProp("Visualization", "result_body_color", "Result color",
+ Config_Prop::Color, ModelAPI_ResultBody::DEFAULT_COLOR());
+
+ Config_PropManager::registerProp("Visualization", "result_group_color", "Group color",
+ Config_Prop::Color, ModelAPI_ResultGroup::DEFAULT_COLOR());
+
+ Config_PropManager::registerProp("Visualization", "result_construction_color",
+ "Construction color",
+ Config_Prop::Color,
+ ModelAPI_ResultConstruction::DEFAULT_COLOR());
+
+ Config_PropManager::registerProp("Visualization", "result_part_color", "Part color",
+ Config_Prop::Color, ModelAPI_ResultPart::DEFAULT_COLOR());
+
+ Config_PropManager::registerProp("Visualization", "result_field_color", "Field color",
+ Config_Prop::Color, ModelAPI_ResultField::DEFAULT_COLOR());
+
Config_PropManager::registerProp("Visualization", "operation_parameter_color",
"Reference shape wireframe color in operation", Config_Prop::Color,
PartSet_CustomPrs::OPERATION_PARAMETER_COLOR());
}
//******************************************************
-bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
- std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs)
-{
- bool aCustomized = false;
-
- XGUI_Workshop* aWorkshop = getWorkshop();
- XGUI_Displayer* aDisplayer = aWorkshop->displayer();
- ObjectPtr anObject = aDisplayer->getObject(thePrs);
- if (!anObject)
- return aCustomized;
-
- if (!theResult.get()) {
- std::vector<int> aColor;
- XGUI_CustomPrs::getDefaultColor(anObject, true, aColor);
- if (!aColor.empty()) {
- aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
- }
- }
- // customize dimentional constrains
- sketchMgr()->customizePresentation(anObject);
-
- return aCustomized;
-}
-
-//******************************************************
-bool PartSet_Module::afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
- AISObjectPtr thePrs,
- GeomCustomPrsPtr theCustomPrs)
-{
- bool aCustomized = false;
-
- XGUI_Workshop* aWorkshop = getWorkshop();
- XGUI_Displayer* aDisplayer = aWorkshop->displayer();
- ObjectPtr anObject = aDisplayer->getObject(thePrs);
- if (!anObject)
- return aCustomized;
-
- std::vector<int> aColor;
- bool aUseCustomColor = true;
- if (aUseCustomColor)
- myOverconstraintListener->getCustomColor(anObject, aColor);
- // customize sketch symbol presentation
- Handle(AIS_InteractiveObject) anAISIO = thePrs->impl<Handle(AIS_InteractiveObject)>();
- if (!anAISIO.IsNull()) {
- if (!Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO).IsNull()) {
- Handle(SketcherPrs_SymbolPrs) aPrs = Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO);
- if (!aPrs.IsNull()) {
- aPrs->SetCustomColor(aColor);
- aCustomized = true;
- }
- } else if (!Handle(SketcherPrs_Coincident)::DownCast(anAISIO).IsNull()) {
- Handle(SketcherPrs_Coincident) aPrs = Handle(SketcherPrs_Coincident)::DownCast(anAISIO);
- if (!aPrs.IsNull()) {
- aPrs->SetCustomColor(aColor);
- aCustomized = true;
- }
- }
- }
- // customize sketch dimension constraint presentation
- if (!aCustomized) {
- if (!aColor.empty()) { // otherwise presentation has the default color
- aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
- }
- }
- return aCustomized;
-}
-
-//******************************************************
-bool PartSet_Module::customizeObject(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
+//bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
+// std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs)
+//{
+// bool aCustomized = false;
+//
+// XGUI_Workshop* aWorkshop = getWorkshop();
+// XGUI_Displayer* aDisplayer = aWorkshop->displayer();
+// ObjectPtr anObject = aDisplayer->getObject(thePrs);
+// if (!anObject)
+// return aCustomized;
+//
+// if (!theResult.get()) {
+// std::vector<int> aColor;
+// XGUI_CustomPrs::getDefaultColor(anObject, true, aColor);
+// if (!aColor.empty()) {
+// aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+// }
+// }
+// // customize dimentional constrains
+// sketchMgr()->customisePresentation(anObject);
+//
+// return aCustomized;
+//}
+//
+////******************************************************
+//bool PartSet_Module::afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
+// AISObjectPtr thePrs,
+// GeomCustomPrsPtr theCustomPrs)
+//{
+// bool aCustomized = false;
+//
+// XGUI_Workshop* aWorkshop = getWorkshop();
+// XGUI_Displayer* aDisplayer = aWorkshop->displayer();
+// ObjectPtr anObject = aDisplayer->getObject(thePrs);
+// if (!anObject)
+// return aCustomized;
+//
+// std::vector<int> aColor;
+// bool aUseCustomColor = true;
+// if (aUseCustomColor)
+// myOverconstraintListener->getCustomColor(anObject, aColor);
+// // customize sketch symbol presentation
+// Handle(AIS_InteractiveObject) anAISIO = thePrs->impl<Handle(AIS_InteractiveObject)>();
+// if (!anAISIO.IsNull()) {
+// if (!Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO).IsNull()) {
+// Handle(SketcherPrs_SymbolPrs) aPrs = Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO);
+// if (!aPrs.IsNull()) {
+// aPrs->SetCustomColor(aColor);
+// aCustomized = true;
+// }
+// } else if (!Handle(SketcherPrs_Coincident)::DownCast(anAISIO).IsNull()) {
+// Handle(SketcherPrs_Coincident) aPrs = Handle(SketcherPrs_Coincident)::DownCast(anAISIO);
+// if (!aPrs.IsNull()) {
+// aPrs->SetCustomColor(aColor);
+// aCustomized = true;
+// }
+// }
+// }
+// // customize sketch dimension constraint presentation
+// if (!aCustomized) {
+// if (!aColor.empty()) { // otherwise presentation has the default color
+// aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+// }
+// }
+// return aCustomized;
+//}
+
+//******************************************************
+bool PartSet_Module::customizeFeature(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
const bool theUpdateViewer)
{
bool isRedisplayed = false;
}
//******************************************************
-Handle(AIS_InteractiveObject) PartSet_Module::createPresentation(const ObjectPtr& theObject)
+AISObjectPtr PartSet_Module::createPresentation(const ObjectPtr& theObject)
+{
+ Handle(AIS_InteractiveObject) anAISPrs = mySketchMgr->createPresentation(theObject);
+ if (anAISPrs.IsNull()) {
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (aResult.get()) {
+ std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
+ if (aShapePtr.get() != NULL)
+ anAISPrs = new ModuleBase_ResultPrs(aResult);
+ }
+ else {
+ FieldStepPtr aStep =
+ std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(theObject);
+ if (aStep.get()) {
+ anAISPrs = new PartSet_FieldStepPrs(aStep);
+ }
+ }
+ }
+ AISObjectPtr anAIS;
+ if (!anAISPrs.IsNull()) {
+ Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(anAISPrs);
+ if (!aShapePrs.IsNull())
+ ModuleBase_Tools::setPointBallHighlighting((AIS_Shape*)aShapePrs.get());
+
+ anAIS = AISObjectPtr(new GeomAPI_AISObject());
+ anAIS->setImpl(new Handle(AIS_InteractiveObject)(anAISPrs));
+ customizePresentation(theObject, anAIS);
+ }
+ return anAIS;
+}
+
+//******************************************************
+void getResultColor(const ResultPtr& theResult, std::vector<int>& theColor)
{
- ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
- if (aResult.get())
- return mySketchMgr->createPresentation(aResult);
+ ModelAPI_Tools::getColor(theResult, theColor);
+ if (theColor.empty())
+ PartSet_Tools::getDefaultColor(theResult, false, theColor);
+}
+
+//******************************************************
+double getResultDeflection(const ResultPtr& theResult)
+{
+ double aDeflection = ModelAPI_Tools::getDeflection(theResult);
+ if (aDeflection < 0)
+ aDeflection = PartSet_Tools::getDefaultDeflection(theResult);
+ return aDeflection;
+}
+
+//******************************************************
+double getResultTransparency(const ResultPtr& theResult)
+{
+ double aTransparency = ModelAPI_Tools::getTransparency(theResult);
+ if (aTransparency < 0)
+ aTransparency = PartSet_Tools::getDefaultTransparency();
+ return aTransparency;
+}
+
+
+//******************************************************
+void PartSet_Module::customizePresentation(const ObjectPtr& theObject, const AISObjectPtr& thePrs) const
+{
+ if (mySketchMgr->isSketchStarted()) {
+ mySketchMgr->customizeSketchPresentation(theObject, thePrs);
+ }
else {
- FieldStepPtr aStep =
- std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(theObject);
- if (aStep.get()) {
- return new PartSet_FieldStepPrs(aStep);
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (aResult.get()) {
+ std::vector<int> aColor;
+ getResultColor(aResult, aColor);
+
+ SessionPtr aMgr = ModelAPI_Session::get();
+ if (aMgr->activeDocument() != aResult->document()) {
+ QColor aQColor(aColor[0], aColor[1], aColor[2]);
+ QColor aNewColor =
+ QColor::fromHsvF(aQColor.hueF(), aQColor.saturationF() / 3., aQColor.valueF());
+ aColor[0] = aNewColor.red();
+ aColor[1] = aNewColor.green();
+ aColor[2] = aNewColor.blue();
+ }
+ thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+
+ thePrs->setDeflection(getResultDeflection(aResult));
+
+ thePrs->setTransparency(getResultTransparency(aResult));
+ }
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+ if (aFeature.get()) {
+ if (aFeature->getKind() == SketchPlugin_Sketch::ID())
+ thePrs->setWidth(2);
}
}
- return Handle(AIS_InteractiveObject)();
}
+
//******************************************************
ObjectPtr PartSet_Module::findPresentedObject(const AISObjectPtr& theAIS) const
{
const bool theUpdateViewer);
/// Modifies the given presentation in the custom way.
- virtual bool customisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
- AISObjectPtr thePrs,
- std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs);
+ //virtual bool customisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
+ // AISObjectPtr thePrs,
+ // std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs);
- /// Modifies the given presentation in the custom way after usual customize is performed.
- virtual bool afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
- AISObjectPtr thePrs,
- GeomCustomPrsPtr theCustomPrs);
+ ///// Modifies the given presentation in the custom way after usual customize is performed.
+ //virtual bool afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
+ // AISObjectPtr thePrs,
+ // GeomCustomPrsPtr theCustomPrs);
/// Update the object presentable properties such as color, lines width and other
/// If the object is result with the color attribute value set, it is used,
/// should be updated(e.g. only highlighted elements)
/// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
/// \returns true if the object is modified
- virtual bool customizeObject(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
- const bool theUpdateViewer);
+ virtual bool customizeFeature(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
+ const bool theUpdateViewer);
/// Disable displaying of custom mode
/// \param theMode a mode to disable
/// Create specific for the module presentation
/// \param theResult an object for presentation
/// \return created presentation or NULL(default value)
- virtual Handle(AIS_InteractiveObject) createPresentation(const ObjectPtr& theResult);
+ virtual AISObjectPtr createPresentation(const ObjectPtr& theResult);
+
+ /// Customize presentation according to objects attributes
+ /// \param theObject an object for presentation
+ /// \param thePrs a presentation object
+ virtual void customizePresentation(const ObjectPtr& theObject, const AISObjectPtr& thePrs) const;
//! Returns data object by AIS
virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;
#include <PartSet_SketcherMgr.h>
#include <PartSet_SketcherReentrantMgr.h>
-#include "XGUI_CustomPrs.h"
#include "XGUI_Displayer.h"
#include "XGUI_ModuleConnector.h"
#include "XGUI_OperationMgr.h"
{
static Events_Loop* aLoop = Events_Loop::loop();
- static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_VISUAL_ATTRIBUTES);
static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
std::set<ObjectPtr>::const_iterator anIt = theObjects.begin(), aLast = theObjects.end();
/// Redefinition of Events_Listener method
virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
+
+ bool isConflictingObject(const ObjectPtr& theObject) const
+ {
+ return (myConflictingObjects.find(theObject) != myConflictingObjects.end());
+ }
+
+ bool isFullyConstrained() const { return myIsFullyConstrained; }
+
protected:
/// Append objects to the internal container of conflicting object, redisplay necessary objects
/// \param theObjects a list of new conflicting objects
: QObject(theModule), myModule(theModule), myIsEditLaunching(false), myIsDragging(false),
myDragDone(false), myIsMouseOverWindow(false),
myIsMouseOverViewProcessed(true), myPreviousUpdateViewerEnabled(true),
- myIsPopupMenuActive(false), myExternalPointsMgr(0), myNoDragMoving(false)
+ myIsPopupMenuActive(false), myExternalPointsMgr(0), myNoDragMoving(false),
+ myIsSketchStarted(false)
{
ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
ModuleBase_IViewer* aViewer = anIWorkshop->viewer();
void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
{
ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+ ModuleBase_IViewer* aViewer = aWorkshop->viewer();
if (myIsDragging)
- aWorkshop->viewer()->enableDrawMode(myPreviousDrawModeEnabled);
+ aViewer->enableDrawMode(myPreviousDrawModeEnabled);
bool aWasDragging = myIsDragging;
myIsDragging = false;
if (!myIsMouseOverViewProcessed) {
return;
}
- ModuleBase_IViewer* aViewer = aWorkshop->viewer();
//if (!aViewer->canDragByMouse())
// return;
ModuleBase_OperationFeature* aOp =
- dynamic_cast<ModuleBase_OperationFeature*>(getCurrentOperation());
+ dynamic_cast<ModuleBase_OperationFeature*>(getCurrentOperation());
if (aOp) {
bool aStartNoDragOperation = !aViewer->canDragByMouse() && aOp->isEditOperation();
if (aStartNoDragOperation || myNoDragMoving) {
theModes.append(TopAbs_EDGE);
}
-Handle(AIS_InteractiveObject) PartSet_SketcherMgr::createPresentation(const ResultPtr& theResult)
+Handle(AIS_InteractiveObject) PartSet_SketcherMgr::createPresentation(const ObjectPtr& theObj)
{
Handle(AIS_InteractiveObject) aPrs;
- FeaturePtr aFeature = ModelAPI_Feature::feature(theResult);
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theObj);
if (aFeature.get() && aFeature->getKind() == SketchPlugin_Sketch::ID()) {
- aPrs = new PartSet_ResultSketchPrs(theResult);
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObj);
+ if (aResult.get())
+ aPrs = new PartSet_ResultSketchPrs(aResult);
}
return aPrs;
}
void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
{
+ static Events_ID EVENT_ATTR = Events_Loop::loop()->eventByName(EVENT_VISUAL_ATTRIBUTES);
+ static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
(getCurrentOperation());
if (!aFOperation)
return;
+ myIsSketchStarted = true;
SketcherPrs_Tools::setPixelRatio(ModuleBase_Tools::currentPixelRatio());
myModule->onViewTransformed();
myModule->overconstraintListener()->setActive(true);
// Display sketcher objects
QStringList anInfo;
- Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
aNumberOfSubs = myCurrentSketch->numberOfSubs();
for (int i = 0; i < aNumberOfSubs; i++) {
aECreator->sendUpdated(aFeature, EVENT_DISP);
else
aFeature->setDisplayed(true);
+ aECreator->sendUpdated(aFeature, EVENT_ATTR);
}
#ifdef DEBUG_SKETCHER_ENTITIES
QString anInfoStr = anInfo.join(";\t");
workshop()->selectionActivate()->updateSelectionFilters();
workshop()->selectionActivate()->updateSelectionModes();
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ Events_Loop::loop()->flush(EVENT_DISP);
+ Events_Loop::loop()->flush(EVENT_ATTR);
myExternalPointsMgr = new PartSet_ExternalPointsMgr(myModule->workshop(), myCurrentSketch);
myModule->workshop()->viewer()->setFitter(0);
delete aFitter;
+ myIsSketchStarted = false;
+
myIsMouseOverWindow = false;
myIsConstraintsShown[PartSet_Tools::Geometrical] = true;
myIsConstraintsShown[PartSet_Tools::Dimensional] = true;
}
}
-void PartSet_SketcherMgr::customizePresentation(const ObjectPtr& theObject)
-{
- ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
- (getCurrentOperation());
- if (aFOperation && (PartSet_SketcherMgr::isSketchOperation(aFOperation) ||
- isNestedSketchOperation(aFOperation)))
- SketcherPrs_Tools::sendExpressionShownEvent(myIsConstraintsShown[PartSet_Tools::Expressions]);
-
- // update entities selection priorities
- FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
- if (aFeature.get() && PartSet_SketcherMgr::isEntity(aFeature->getKind())) {
- // update priority for feature
- updateSelectionPriority(aFeature, aFeature);
- // update priority for results of the feature
- std::list<ResultPtr> aResults = aFeature->results();
- std::list<ResultPtr>::const_iterator anIt = aResults.begin(), aLastIt = aResults.end();
- for (; anIt != aLastIt; anIt++)
- updateSelectionPriority(*anIt, aFeature);
- }
-}
+//void PartSet_SketcherMgr::customisePresentation(const ObjectPtr& theObject)
+//{
+// ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+// (getCurrentOperation());
+// if (aFOperation && (PartSet_SketcherMgr::isSketchOperation(aFOperation) ||
+// isNestedSketchOperation(aFOperation)))
+// SketcherPrs_Tools::sendExpressionShownEvent(myIsConstraintsShown[PartSet_Tools::Expressions]);
+//
+// // update entities selection priorities
+// FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+// if (aFeature.get() && PartSet_SketcherMgr::isEntity(aFeature->getKind())) {
+// // update priority for feature
+// updateSelectionPriority(aFeature, aFeature);
+// // update priority for results of the feature
+// std::list<ResultPtr> aResults = aFeature->results();
+// std::list<ResultPtr>::const_iterator anIt = aResults.begin(), aLastIt = aResults.end();
+// for (; anIt != aLastIt; anIt++)
+// updateSelectionPriority(*anIt, aFeature);
+// }
+//}
ModuleBase_Operation* PartSet_SketcherMgr::getCurrentOperation() const
{
}
}
+bool isExternal(const ObjectPtr& theObject)
+{
+ AttributeSelectionPtr aAttr =
+ theObject->data()->selection(SketchPlugin_SketchEntity::EXTERNAL_ID());
+ if (aAttr)
+ return aAttr->context().get() != NULL && !aAttr->isInvalid();
+ return false;
+}
+
+bool isCopy(const ObjectPtr& theObject)
+{
+ AttributeBooleanPtr anAttr = theObject->data()->boolean(SketchPlugin_SketchEntity::COPY_ID());
+ if (anAttr.get())
+ return anAttr->value();
+ return false;
+}
+
+bool isIncludeToResult(const ObjectPtr& theObject)
+{
+ AttributeBooleanPtr anAttr;
+ std::set<AttributePtr> aRefsToMe = theObject->data()->refsToMe();
+ std::set<AttributePtr>::const_iterator aIt;
+ for (aIt = aRefsToMe.cbegin(); aIt != aRefsToMe.cend(); ++aIt) {
+ if ((*aIt)->id() == SketchPlugin_Projection::PROJECTED_FEATURE_ID()) {
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>((*aIt)->owner());
+ if (aFeature.get()) {
+ anAttr = aFeature->data()->boolean(SketchPlugin_Projection::INCLUDE_INTO_RESULT());
+ if (anAttr.get())
+ return anAttr->value();
+ }
+ }
+ }
+ return true;
+}
+
+
+void PartSet_SketcherMgr::customizeSketchPresentation(const ObjectPtr& theObject,
+ const AISObjectPtr& thePrs) const
+{
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+ PartSet_OverconstraintListener* aOCListener = myModule->overconstraintListener();
+
+ // Check constraints objects
+ const QStringList& aConstrIds = constraintsIdList();
+ std::string aKind = aFeature->getKind();
+ if (aConstrIds.contains(QString(aKind.c_str()))) {
+ std::vector<int> aColor;
+ if (aOCListener->isConflictingObject(theObject))
+ aColor = Config_PropManager::color("Visualization", "sketch_overconstraint_color");
+ else if (isDistanceKind(aKind))
+ aColor = Config_PropManager::color("Visualization", "sketch_dimension_color");
+
+ if (!aColor.empty())
+ thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+ return;
+ }
+ int aShapeType = thePrs->getShapeType();
+ // a compound is processed like the edge because the
+ // arc feature uses the compound for presentable AIS
+ if (aShapeType != 6/*an edge*/ && aShapeType != 7/*a vertex*/ && aShapeType != 0/*compound*/)
+ return;
+
+ // set color from preferences
+ std::shared_ptr<ModelAPI_AttributeBoolean> anAuxiliaryAttr =
+ aFeature->data()->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID());
+ bool isConstruction = anAuxiliaryAttr.get() != NULL && anAuxiliaryAttr->value();
+
+ std::vector<int> aColor;
+ if (aOCListener->isFullyConstrained())
+ aColor = Config_PropManager::color("Visualization", "sketch_fully_constrained_color");
+ else if (aOCListener->isConflictingObject(theObject))
+ aColor = Config_PropManager::color("Visualization", "sketch_overconstraint_color");
+ else {
+ if (isConstruction)
+ aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color");
+ else if (isExternal(aFeature))
+ aColor = Config_PropManager::color("Visualization", "sketch_external_color");
+ else
+ aColor = Config_PropManager::color("Visualization", "sketch_entity_color");
+ }
+ if (!aColor.empty()) {
+ // The code below causes redisplay again
+ if (ModelAPI_Session::get()->isOperation()) {
+ AttributeIntArrayPtr aColorAttr = theObject->data()->intArray(ModelAPI_Result::COLOR_ID());
+ if (aColorAttr.get()) {
+ aColorAttr->setSize(3);
+ // Set the color attribute in order do not use default colors in the presentation object
+ for (int i = 0; i < 3; i++)
+ aColorAttr->setValue(i, aColor[i], false);
+ }
+ }
+ thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+ }
+
+ if (aShapeType == 6 || aShapeType == 0) { // if this is an edge or a compound
+ if (isConstruction) {
+ // Set axilliary line
+ thePrs->setWidth(SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH_AUXILIARY());
+ thePrs->setLineStyle(SketchPlugin_SketchEntity::SKETCH_LINE_STYLE_AUXILIARY());
+ }
+ else {
+ int aWidth = Config_PropManager::integer("Visualization", "sketch_line_width");
+ thePrs->setWidth(aWidth);
+ thePrs->setLineStyle(SketchPlugin_SketchEntity::SKETCH_LINE_STYLE());
+ }
+ }
+ else if (aShapeType == 7) { // otherwise this is a vertex
+ // The width value do not have effect on the point presentation.
+ // It is defined in order to extend selection area of the object.
+ thePrs->setWidth(17);
+ // thePrs->setPointMarker(1, 1.); // Set point as a '+' symbol
+ }
+ if (isCopy(aFeature) && !isIncludeToResult(aFeature)) {
+ double aWidth = thePrs->width();
+ thePrs->setWidth(aWidth / 2.5);
+ }
+
+ double aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
+ thePrs->setDeflection(aDeflection);
+}
+
+//*************************************************************************************
void PartSet_Fitter::fitAll(Handle(V3d_View) theView)
{
CompositeFeaturePtr aSketch = mySketchMgr->activeSketch();
#include <ModuleBase_ModelWidget.h>
#include <GeomAPI_Pln.h>
+#include <GeomAPI_AISObject.h>
#ifdef HAVE_SALOME
#include <OCCViewer_ViewModel.h>
/// Create specific for the module presentation
/// \param theResult an object for presentation
/// \return created presentation or NULL(default value)
- virtual Handle(AIS_InteractiveObject) createPresentation(const ResultPtr& theResult);
+ Handle(AIS_InteractiveObject) createPresentation(const ObjectPtr& theResult);
/// Connects or disconnects to the value changed signal of the property panel widgets
/// \param theWidget a property contol widget
/// If the current operation is a dimention one, the style of dimension visualization is send for
/// the current object
/// \param theObject an object to be customized
- void customizePresentation(const ObjectPtr& theObject);
+ //void customisePresentation(const ObjectPtr& theObject);
+
+ void customizeSketchPresentation(const ObjectPtr& theObject, const AISObjectPtr& thePrs) const;
/// Update sketch presentations according to the the state
/// \param theType a type of sketch visualization style
*/
virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
+ bool isSketchStarted() const { return myIsSketchStarted; }
+
+
public slots:
/// Process sketch plane selected event
void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
QMap<ResultPtr, Handle(AIS_Shape)> myPointsHighlight;
bool myNoDragMoving;
+
+ bool myIsSketchStarted;
};
#include <ModelGeomAlgo_Point2D.h>
#include <Events_Loop.h>
+#include <Events_InfoMessage.h>
#include <SketcherPrs_Tools.h>
#include <GeomAPI_Pnt.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Vertex.h>
+#include <GeomAPI_ShapeExplorer.h>
#include <GeomAPI_Dir.h>
#include <GeomAPI_XYZ.h>
theFirst = aDoc->index(aFirstFeatureInFolder);
theLast = aDoc->index(aLastFeatureInFolder);
}
+
+
+void PartSet_Tools::getDefaultColor(ObjectPtr theObject, const bool isEmptyColorValid,
+ std::vector<int>& theColor)
+{
+ theColor.clear();
+ // get default color from the preferences manager for the given result
+ if (theColor.empty()) {
+ std::string aSection, aName, aDefault;
+ theObject->colorConfigInfo(aSection, aName, aDefault);
+ if (!aSection.empty() && !aName.empty()) {
+ theColor = Config_PropManager::color(aSection, aName);
+ }
+ }
+ if (!isEmptyColorValid && theColor.empty()) {
+ // all AIS objects, where the color is not set, are in black.
+ // The color should be defined in XML or set in the attribute
+ theColor = Config_PropManager::color("Visualization", "object_default_color");
+ Events_InfoMessage("PartSet_Tools",
+ "A default color is not defined in the preferences for this result type").send();
+ }
+}
+
+double PartSet_Tools::getDefaultDeflection(const ObjectPtr& theObject)
+{
+ double aDeflection = -1;
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (aResult.get()) {
+ bool isConstruction = false;
+
+ std::string aResultGroup = aResult->groupName();
+ if (aResultGroup == ModelAPI_ResultConstruction::group())
+ isConstruction = true;
+ else if (aResultGroup == ModelAPI_ResultBody::group()) {
+ GeomShapePtr aGeomShape = aResult->shape();
+ if (aGeomShape.get()) {
+ // if the shape could not be exploded on faces, it contains only wires, edges, and vertices
+ // correction of deviation for them should not influence to the application performance
+ GeomAPI_ShapeExplorer anExp(aGeomShape, GeomAPI_Shape::FACE);
+ isConstruction = !anExp.more();
+ }
+ }
+ if (isConstruction)
+ aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
+ else
+ aDeflection = Config_PropManager::real("Visualization", "body_deflection");
+ }
+ return aDeflection;
+}
+
+
+double PartSet_Tools::getDefaultTransparency()
+{
+ return Config_PropManager::integer("Visualization", "shaper_default_transparency") / 100.;
+}
FeaturePtr& theCreatedFeature);
- static void getFirstAndLastIndexInFolder(const ObjectPtr& theFolder, int& theFirst, int& theLast);
+ static void getFirstAndLastIndexInFolder(const ObjectPtr& theFolder,
+ int& theFirst, int& theLast);
+
+
+ /**
+ * Returns default color value for the given object
+ */
+ static void getDefaultColor(ObjectPtr theObject, const bool isEmptyColorValid,
+ std::vector<int>& theColor);
+
+ /**
+ * Returns default deflection value for the given object
+ */
+ static double getDefaultDeflection(const ObjectPtr& theObject);
+
+
+ /**
+ * Returns default transparency value
+ */
+ static double getDefaultTransparency();
};
#endif
#include "SketchPlugin_ConstraintAngle.h"
#include <SketchPlugin_Line.h>
+#include <SketchPlugin_Tools.h>
#include <SketcherPrs_Tools.h>
#include <ModelAPI_AttributeDouble.h>
AISObjectPtr anAIS = SketcherPrs_Factory::angleConstraint(this, sketch(),
thePrevious);
+ if (anAIS.get() && !thePrevious.get())
+ SketchPlugin_Tools::setDimensionColor(anAIS);
return anAIS;
}
#include <SketchPlugin_Point.h>
#include <SketchPlugin_Circle.h>
#include <SketchPlugin_Line.h>
+#include <SketchPlugin_Tools.h>
#include <SketcherPrs_Tools.h>
#include <SketcherPrs_Factory.h>
AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this,
sketch(),
thePrevious);
+ if (anAIS.get() && !thePrevious.get())
+ SketchPlugin_Tools::setDimensionColor(anAIS);
return anAIS;
}
// Author: Artem ZHIDKOV
#include <SketchPlugin_ConstraintDistanceAlongDir.h>
+#include <SketchPlugin_Tools.h>
#include <SketcherPrs_Tools.h>
#include <SketcherPrs_Factory.h>
AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this,
sketch(),
thePrevious);
+ if (anAIS.get() && !thePrevious.get())
+ SketchPlugin_Tools::setDimensionColor(anAIS);
return anAIS;
}
#include "SketchPlugin_ConstraintLength.h"
#include <SketchPlugin_Line.h>
+#include <SketchPlugin_Tools.h>
#include <GeomDataAPI_Point2D.h>
AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this,
sketch(), thePrevious);
+ if (anAIS.get() && !thePrevious.get())
+ SketchPlugin_Tools::setDimensionColor(anAIS);
return anAIS;
}
#include <SketchPlugin_Arc.h>
#include <SketchPlugin_Circle.h>
#include <SketchPlugin_Point.h>
+#include <SketchPlugin_Tools.h>
#include <SketcherPrs_Factory.h>
#include <SketcherPrs_Tools.h>
AISObjectPtr anAIS = SketcherPrs_Factory::radiusConstraint(this, sketch(),
thePrevious);
+ if (anAIS.get() && !thePrevious.get())
+ SketchPlugin_Tools::setDimensionColor(anAIS);
return anAIS;
}
anAISObject = AISObjectPtr(new GeomAPI_AISObject);
}
anAISObject->createShape(anArcShape);
+ bool isAxiliary = false;
+ AttributeBooleanPtr aAttr = boolean(AUXILIARY_ID());
+ if (aAttr.get())
+ isAxiliary = aAttr->value();
+ SketchPlugin_Tools::customizeFeaturePrs(anAISObject, isAxiliary);
return anAISObject;
}
anAIS.reset(new GeomAPI_AISObject());
}
anAIS->createShape(aCompound);
+ SketchPlugin_Tools::customizeFeaturePrs(anAIS, boolean(AUXILIARY_ID())->value());
return anAIS;
}
anAIS.reset(new GeomAPI_AISObject());
}
anAIS->createShape(aCompound);
+
+ // Modify attributes
+ SketchPlugin_Tools::customizeFeaturePrs(anAIS, boolean(AUXILIARY_ID())->value());
+
return anAIS;
}
if (!anAIS)
anAIS.reset(new GeomAPI_AISObject());
anAIS->createShape(aCompound);
+
+ // Modify attributes
+ SketchPlugin_Tools::customizeFeaturePrs(anAIS, boolean(AUXILIARY_ID())->value());
+
return anAIS;
}
if (!anAIS)
anAIS.reset(new GeomAPI_AISObject());
anAIS->createShape(aCompound);
+ SketchPlugin_Tools::customizeFeaturePrs(anAIS, boolean(AUXILIARY_ID())->value());
return anAIS;
}
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_Tools.h>
+#include <ModelAPI_Events.h>
+
+#include <Events_Loop.h>
#include <GeomAPI_Circ.h>
#include <GeomAPI_Edge.h>
static const double tolerance = 1.e-7;
+
SketchPlugin_Projection::SketchPlugin_Projection()
: SketchPlugin_SketchEntity(),
myIsComputing(false)
setResult(aResult);
GeomShapePtr anEmptyVal;
aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), anEmptyVal);
+
+ static const Events_ID anEvent = Events_Loop::eventByName(EVENT_VISUAL_ATTRIBUTES);
+ ModelAPI_EventCreator::get()->sendUpdated(aProjection, anEvent, false);
}
}
}
* \ingroup Plugins
* \brief Feature for creation of the new part in PartSet.
*/
-class SketchPlugin_Sketch : public ModelAPI_CompositeFeature, public GeomAPI_ICustomPrs
+class SketchPlugin_Sketch : public ModelAPI_CompositeFeature//, public GeomAPI_ICustomPrs
{
public:
/// Sketch feature kind
static std::shared_ptr<GeomAPI_Ax3> plane(SketchPlugin_Sketch* theSketch);
/// Customize presentation of the feature
- virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
- std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
- {
- bool isCustomized = false;
- // apply the color of the result to the presentation
- if (theDefaultPrs.get())
- isCustomized = theDefaultPrs->customisePresentation(theResult, thePrs, theDefaultPrs);
- // set the sketch presentation bold
- isCustomized = thePrs->setWidth(2) || isCustomized;
-
- return isCustomized;
- }
+ //virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
+ // std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
+ //{
+ // bool isCustomized = false;
+ // // apply the color of the result to the presentation
+ // if (theDefaultPrs.get())
+ // isCustomized = theDefaultPrs->customisePresentation(theResult, thePrs, theDefaultPrs);
+ // // set the sketch presentation bold
+ // isCustomized = thePrs->setWidth(2) || isCustomized;
+
+ // return isCustomized;
+ //}
private:
/// Substitute all links to external objects by newly created features.
* This is an abstract class to give
* an interface to create the entity features such as line, circle, arc and point.
*/
-class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_ICustomPrs
+class SketchPlugin_SketchEntity : public SketchPlugin_Feature //, public GeomAPI_ICustomPrs
{
public:
/// Reference to the construction type of the feature
}
/// Width of the auxiliary line
- inline static const double SKETCH_LINE_WIDTH_AUXILIARY()
+ inline static const int SKETCH_LINE_WIDTH_AUXILIARY()
{
return 2;
}
/// Width of the line
- inline static const double SKETCH_LINE_WIDTH()
+ inline static const int SKETCH_LINE_WIDTH()
{
return Config_PropManager::integer("Visualization", "sketch_line_width");
}
return false;
}
- virtual bool isIncludeToResult() const
- {
- AttributeBooleanPtr anAttr;
- std::set<AttributePtr> aRefsToMe = data()->refsToMe();
- std::set<AttributePtr>::const_iterator aIt;
- for (aIt = aRefsToMe.cbegin(); aIt != aRefsToMe.cend(); ++aIt) {
- if ((*aIt)->id() == "ProjectedFeature") {
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>((*aIt)->owner());
- if (aFeature.get()) {
- anAttr = aFeature->data()->boolean("IncludeToResult");
- if (anAttr.get())
- return anAttr->value();
- }
- }
- }
- return true;
- }
+ //virtual bool isIncludeToResult() const
+ //{
+ // AttributeBooleanPtr anAttr;
+ // std::set<AttributePtr> aRefsToMe = data()->refsToMe();
+ // std::set<AttributePtr>::const_iterator aIt;
+ // for (aIt = aRefsToMe.cbegin(); aIt != aRefsToMe.cend(); ++aIt) {
+ // if ((*aIt)->id() == "ProjectedFeature") {
+ // FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>((*aIt)->owner());
+ // if (aFeature.get()) {
+ // anAttr = aFeature->data()->boolean("IncludeToResult");
+ // if (anAttr.get())
+ // return anAttr->value();
+ // }
+ // }
+ // }
+ // return true;
+ //}
// LCOV_EXCL_START
/// Customize presentation of the feature
- virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
- std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
- {
- /// Store previous color values of the presentation to check it after setting specific entity
- /// color. Default color is set into presentation to have not modified isCustomized state
- /// after default customize prs is completed.
- std::vector<int> aPrevColor;
- aPrevColor.resize(3);
- thePrs->getColor(aPrevColor[0], aPrevColor[1], aPrevColor[2]);
- if (theResult.get()) {
- std::string aSection, aName, aDefault;
- theResult->colorConfigInfo(aSection, aName, aDefault);
- std::vector<int> aColor;
- aColor = Config_PropManager::color(aSection, aName);
- thePrs->setColor(aColor[0], aColor[1], aColor[2]);
- }
-
- bool isCustomized = theDefaultPrs.get() != NULL &&
- theDefaultPrs->customisePresentation(theResult, thePrs, theDefaultPrs);
- int aShapeType = thePrs->getShapeType();
- // a compound is processed like the edge because the
- // arc feature uses the compound for presentable AIS
- if (aShapeType != 6/*an edge*/ && aShapeType != 7/*a vertex*/ && aShapeType != 0/*compound*/)
- return false;
-
- // set color from preferences
- std::vector<int> aColor;
- std::shared_ptr<ModelAPI_AttributeBoolean> anAuxiliaryAttr =
- data()->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID());
- bool isConstruction = anAuxiliaryAttr.get() != NULL && anAuxiliaryAttr->value();
- if (isConstruction) {
- aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color");
- }
- else if (isExternal()) {
- aColor = Config_PropManager::color("Visualization", "sketch_external_color");
- }
- else {
- aColor = Config_PropManager::color("Visualization", "sketch_entity_color");
- }
- if (!aColor.empty()) {
- if (theResult.get() && ModelAPI_Session::get()->isOperation()) {
- AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID());
- aColorAttr->setSize(3);
- // Set the color attribute in order do not use default colors in the presentation object
- for (int i = 0; i < 3; i++)
- aColorAttr->setValue(i, aColor[i]);
- }
- thePrs->setColor(aColor[0], aColor[1], aColor[2]);
- for (int i = 0; i < 3 && !isCustomized; i++)
- isCustomized = aColor[i] != aPrevColor[i];
- }
-
- if (aShapeType == 6 || aShapeType == 0) { // if this is an edge or a compound
- if (isConstruction) {
- isCustomized = thePrs->setWidth(SKETCH_LINE_WIDTH_AUXILIARY()) || isCustomized;
- isCustomized = thePrs->setLineStyle(SKETCH_LINE_STYLE_AUXILIARY()) || isCustomized;
- }
- else {
- isCustomized = thePrs->setWidth(SKETCH_LINE_WIDTH()) || isCustomized;
- isCustomized = thePrs->setLineStyle(SKETCH_LINE_STYLE()) || isCustomized;
- }
- }
- else if (aShapeType == 7) { // otherwise this is a vertex
- // The width value do not have effect on the point presentation.
- // It is defined in order to extend selection area of the object.
- thePrs->setWidth(17);
- // thePrs->setPointMarker(1, 1.); // Set point as a '+' symbol
- }
- if(isCopy() && !isIncludeToResult()) {
- double aWidth = thePrs->width();
- isCustomized = thePrs->setWidth(aWidth / 2.5) || isCustomized;
- }
-
- if (!theResult.get()) {
- double aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
- thePrs->setDeflection(aDeflection);
- }
- return isCustomized;
- }
+ //virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
+ // std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
+ //{
+ // /// Store previous color values of the presentation to check it after setting specific entity
+ // /// color. Default color is set into presentation to have not modified isCustomized state
+ // /// after default customize prs is completed.
+ // std::vector<int> aPrevColor;
+ // aPrevColor.resize(3);
+ // thePrs->getColor(aPrevColor[0], aPrevColor[1], aPrevColor[2]);
+ // if (theResult.get()) {
+ // std::string aSection, aName, aDefault;
+ // theResult->colorConfigInfo(aSection, aName, aDefault);
+ // std::vector<int> aColor;
+ // aColor = Config_PropManager::color(aSection, aName);
+ // thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+ // }
+
+ // bool isCustomized = theDefaultPrs.get() != NULL &&
+ // theDefaultPrs->customisePresentation(theResult, thePrs, theDefaultPrs);
+ // int aShapeType = thePrs->getShapeType();
+ // // a compound is processed like the edge because the
+ // // arc feature uses the compound for presentable AIS
+ // if (aShapeType != 6/*an edge*/ && aShapeType != 7/*a vertex*/ && aShapeType != 0/*compound*/)
+ // return false;
+
+ // // set color from preferences
+ // std::vector<int> aColor;
+ // std::shared_ptr<ModelAPI_AttributeBoolean> anAuxiliaryAttr =
+ // data()->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID());
+ // bool isConstruction = anAuxiliaryAttr.get() != NULL && anAuxiliaryAttr->value();
+ // if (isConstruction) {
+ // aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color");
+ // }
+ // else if (isExternal()) {
+ // aColor = Config_PropManager::color("Visualization", "sketch_external_color");
+ // }
+ // else {
+ // aColor = Config_PropManager::color("Visualization", "sketch_entity_color");
+ // }
+ // if (!aColor.empty()) {
+ // if (theResult.get() && ModelAPI_Session::get()->isOperation()) {
+ // AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID());
+ // aColorAttr->setSize(3);
+ // // Set the color attribute in order do not use default colors in the presentation object
+ // for (int i = 0; i < 3; i++)
+ // aColorAttr->setValue(i, aColor[i]);
+ // }
+ // thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+ // for (int i = 0; i < 3 && !isCustomized; i++)
+ // isCustomized = aColor[i] != aPrevColor[i];
+ // }
+
+ // if (aShapeType == 6 || aShapeType == 0) { // if this is an edge or a compound
+ // if (isConstruction) {
+ // isCustomized = thePrs->setWidth(SKETCH_LINE_WIDTH_AUXILIARY()) || isCustomized;
+ // isCustomized = thePrs->setLineStyle(SKETCH_LINE_STYLE_AUXILIARY()) || isCustomized;
+ // }
+ // else {
+ // isCustomized = thePrs->setWidth(SKETCH_LINE_WIDTH()) || isCustomized;
+ // isCustomized = thePrs->setLineStyle(SKETCH_LINE_STYLE()) || isCustomized;
+ // }
+ // }
+ // else if (aShapeType == 7) { // otherwise this is a vertex
+ // // The width value do not have effect on the point presentation.
+ // // It is defined in order to extend selection area of the object.
+ // thePrs->setWidth(17);
+ // // thePrs->setPointMarker(1, 1.); // Set point as a '+' symbol
+ // }
+ // if(isCopy() && !isIncludeToResult()) {
+ // double aWidth = thePrs->width();
+ // isCustomized = thePrs->setWidth(aWidth / 2.5) || isCustomized;
+ // }
+
+ // if (!theResult.get()) {
+ // double aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
+ // thePrs->setDeflection(aDeflection);
+ // }
+ // return isCustomized;
+ //}
// LCOV_EXCL_STOP
protected:
return GeomPnt2dPtr(new GeomAPI_Pnt2d(X, Y));
}
+
+void customizeFeaturePrs(const AISObjectPtr& thePrs, bool isAxiliary)
+{
+ std::vector<int> aColor;
+ int aWidth = 1;
+ if (isAxiliary) {
+ thePrs->setLineStyle(SketchPlugin_SketchEntity::SKETCH_LINE_STYLE_AUXILIARY());
+ aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color");
+ aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH_AUXILIARY();
+ }
+ else {
+ thePrs->setLineStyle(SketchPlugin_SketchEntity::SKETCH_LINE_STYLE());
+ aColor = Config_PropManager::color("Visualization", "sketch_entity_color");
+ aWidth = Config_PropManager::integer("Visualization", "sketch_line_width");
+ }
+ thePrs->setWidth(aWidth);
+ thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+}
+
+void setDimensionColor(const AISObjectPtr& theDimPrs)
+{
+ std::vector<int> aColor = Config_PropManager::color("Visualization", "sketch_dimension_color");
+ if (aColor.size() == 3)
+ theDimPrs->setColor(aColor[0], aColor[1], aColor[2]);
+}
+
} // namespace SketchPlugin_Tools
#include <ModelAPI_Attribute.h>
#include <ModelAPI_AttributeRefAttr.h>
#include <GeomAPI_Shape.h>
+#include <GeomAPI_AISObject.h>
#include <GeomDataAPI_Point2D.h>
#include <GeomAlgoAPI_ShapeTools.h>
std::shared_ptr<GeomAPI_Shape>& theTangentCurve,
std::shared_ptr<GeomAPI_Pnt2d>& thePassingPoint);
-
/// Calculate global coordinates for flyout point of Length constraint
GeomPnt2dPtr flyoutPointCoordinates(const std::shared_ptr<SketchPlugin_Constraint>& theConstraint);
+
+/// Sets attributes of feature presentation
+/// \param[in] thePrs a presentation
+/// \param[in] isAxiliary is axiliary flag
+void customizeFeaturePrs(const AISObjectPtr& thePrs, bool isAxiliary);
+
+void setDimensionColor(const AISObjectPtr& theDimPrs);
+
}; // namespace SketchPlugin_Tools
namespace SketchPlugin_SegmentationTools
helpfile="pointFeature.html">
<sketch-2dpoint_selector id="PointCoordinates" accept_expressions="0" title="Point" tooltip="Point coordinates"
enable_value="enable_by_preferences"/>
- <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
+ <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0" change_visual_attributes="true"/>
</feature>
<!-- SketchLine -->
enable_value="enable_by_preferences"/>
<labelvalue id="LineLength" accept_expressions="0" label="Length" default="computed" icon="icons/Sketch/distance_value.png"
tooltip="Line length" obligatory="0" enable_value="false"/>
- <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
+ <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0" change_visual_attributes="true"/>
<validator id="GeomValidators_Different" parameters="StartPoint,EndPoint"/>
</feature>
</group>
accept_expressions="0"
enable_value="enable_by_preferences">
</labelvalue>
- <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
+ <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0" change_visual_attributes="true"/>
</feature>
<!-- SketchMacroCircle -->
<feature id="SketchMacroCircle"
tooltip="Construction element"
label="Auxiliary"
default="false"
- obligatory="0"/>
+ obligatory="0"
+ change_visual_attributes="true"/>
</feature>
<!-- SketchArc -->
label="Auxiliary"
tooltip="Construction element"
default="false"
- obligatory="0"/>
+ obligatory="0"
+ change_visual_attributes="true"/>
</feature>
<!-- SketchMacroArc -->
label="Auxiliary"
tooltip="Construction element"
default="false"
- obligatory="0"/>
+ obligatory="0"
+ change_visual_attributes="true"/>
</feature>
<!-- SketchFillet -->
accept_expressions="0"
enable_value="enable_by_preferences">
</labelvalue>
- <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
+ <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0" change_visual_attributes="true"/>
</feature>
<!-- SketchMacroEllipse -->
<feature id="SketchMacroEllipse"
tooltip="Construction element"
label="Auxiliary"
default="false"
- obligatory="0"/>
+ obligatory="0"
+ change_visual_attributes="true"/>
</feature>
<!-- SketchEllipticArc is a hidden feature. It is created inside SketchMacroEllipse. -->
accept_expressions="0"
enable_value="enable_by_preferences">
</labelvalue>
- <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
+ <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0" change_visual_attributes="true"/>
</feature>
<!-- SketchMacroEllipticArc -->
<feature id="SketchMacroEllipticArc"
tooltip="Construction element"
label="Auxiliary"
default="false"
- obligatory="0"/>
+ obligatory="0"
+ change_visual_attributes="true"/>
</feature>
</group>
use_sketch_plane="false">
<validator id="SketchPlugin_ProjectionValidator"/>
</sketch_shape_selector>
- <boolvalue id="IncludeToResult" label="Include into the sketch result" default="true" tooltip="Include projected feature into the sketch result"/>
+ <boolvalue id="IncludeToResult" label="Include into the sketch result" default="true" tooltip="Include projected feature into the sketch result"
+ change_visual_attributes="true"/>
<validator id="PartSet_ProjectionSelection"/>
</feature>
use_sketch_plane="false">
<validator id="SketchPlugin_IntersectionValidator"/>
</sketch_shape_selector>
- <boolvalue id="IncludeToResult" label="Include into the sketch result" default="true" tooltip="Include projected feature into the sketch result"/>
+ <boolvalue id="IncludeToResult" label="Include into the sketch result" default="true" tooltip="Include projected feature into the sketch result"
+ change_visual_attributes="true"/>
<validator id="PartSet_IntersectionSelection"/>
</feature>
</group>
XGUI_ActiveControlSelector.h
XGUI_ColorDialog.h
XGUI_ContextMenuMgr.h
- XGUI_CustomPrs.h
XGUI_DataModel.h
XGUI_DeflectionDialog.h
XGUI_Displayer.h
XGUI_ActiveControlMgr.cpp
XGUI_ColorDialog.cpp
XGUI_ContextMenuMgr.cpp
- XGUI_CustomPrs.cpp
XGUI_DataModel.cpp
XGUI_DeflectionDialog.cpp
XGUI_Displayer.cpp
+++ /dev/null
-// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include <XGUI_CustomPrs.h>
-#include <XGUI_Workshop.h>
-#include <XGUI_Displayer.h>
-
-#include <ModuleBase_IModule.h>
-
-#include <ModelAPI_AttributeIntArray.h>
-#include <ModelAPI_AttributeDouble.h>
-#include <ModelAPI_Session.h>
-#include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultConstruction.h>
-
-#include <GeomAPI_ShapeExplorer.h>
-
-#include <Config_PropManager.h>
-
-#include <Events_InfoMessage.h>
-
-#include <vector>
-#include <QColor>
-
-double getDeflection(const ResultPtr& theResult)
-{
- double aDeflection = -1;
- // get deflection from the attribute of the result
- if (theResult.get() != NULL &&
- theResult->data()->attribute(ModelAPI_Result::DEFLECTION_ID()).get() != NULL) {
- AttributeDoublePtr aDoubleAttr = theResult->data()->real(ModelAPI_Result::DEFLECTION_ID());
- if (aDoubleAttr.get() && aDoubleAttr->isInitialized()) {
- double aValue = aDoubleAttr->value();
- if (aValue > 0) /// zero value should not be used as a deflection(previous studies)
- aDeflection = aDoubleAttr->value();
- }
- }
- return aDeflection;
-}
-
-void getColor(const ResultPtr& theResult, std::vector<int>& theColor)
-{
- theColor.clear();
- // get color from the attribute of the result
- if (theResult.get() != NULL &&
- theResult->data()->attribute(ModelAPI_Result::COLOR_ID()).get() != NULL) {
- AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID());
- if (aColorAttr.get() && aColorAttr->size()) {
- theColor.push_back(aColorAttr->value(0));
- theColor.push_back(aColorAttr->value(1));
- theColor.push_back(aColorAttr->value(2));
- }
- }
-}
-
-void XGUI_CustomPrs::getDefaultColor(ObjectPtr theObject, const bool isEmptyColorValid,
- std::vector<int>& theColor)
-{
- theColor.clear();
- // get default color from the preferences manager for the given result
- if (theColor.empty()) {
- std::string aSection, aName, aDefault;
- theObject->colorConfigInfo(aSection, aName, aDefault);
- if (!aSection.empty() && !aName.empty()) {
- theColor = Config_PropManager::color(aSection, aName);
- }
- }
- if (!isEmptyColorValid && theColor.empty()) {
- // all AIS objects, where the color is not set, are in black.
- // The color should be defined in XML or set in the attribute
- theColor = Config_PropManager::color("Visualization", "object_default_color");
- Events_InfoMessage("XGUI_CustomPrs",
- "A default color is not defined in the preferences for this kind of result").send();
- }
-}
-
-double XGUI_CustomPrs::getDefaultDeflection(const ObjectPtr& theObject)
-{
- double aDeflection = -1;
- ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
- if (aResult.get()) {
- bool isConstruction = false;
-
- std::string aResultGroup = aResult->groupName();
- if (aResultGroup == ModelAPI_ResultConstruction::group())
- isConstruction = true;
- else if (aResultGroup == ModelAPI_ResultBody::group()) {
- GeomShapePtr aGeomShape = aResult->shape();
- if (aGeomShape.get()) {
- // if the shape could not be exploded on faces, it contains only wires, edges, and vertices
- // correction of deviation for them should not influence to the application performance
- GeomAPI_ShapeExplorer anExp(aGeomShape, GeomAPI_Shape::FACE);
- isConstruction = !anExp.more();
- }
- }
- if (isConstruction)
- aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
- else
- aDeflection = Config_PropManager::real("Visualization", "body_deflection");
- }
- return aDeflection;
-}
-
-double getTransparency(const ResultPtr& theResult)
-{
- double aTransparency = -1;
- // get transparency from the attribute of the result
- if (theResult.get() != NULL &&
- theResult->data()->attribute(ModelAPI_Result::TRANSPARENCY_ID()).get() != NULL) {
- AttributeDoublePtr aDoubleAttr = theResult->data()->real(ModelAPI_Result::TRANSPARENCY_ID());
- if (aDoubleAttr.get() && aDoubleAttr->isInitialized()) {
- aTransparency = aDoubleAttr->value();
- }
- }
- return aTransparency;
-}
-
-double getDefaultTransparency(const ResultPtr& theResult)
-{
- return Config_PropManager::integer("Visualization", "shaper_default_transparency") / 100.;
-}
-
-XGUI_CustomPrs::XGUI_CustomPrs(XGUI_Workshop* theWorkshop)
-: myWorkshop(theWorkshop)
-{
-}
-
-void XGUI_CustomPrs::getResultColor(const ResultPtr& theResult, std::vector<int>& theColor)
-{
- getColor(theResult, theColor);
- if (theColor.empty())
- getDefaultColor(theResult, false, theColor);
-}
-
-double XGUI_CustomPrs::getResultDeflection(const ResultPtr& theResult)
-{
- double aDeflection = getDeflection(theResult);
- if (aDeflection < 0)
- aDeflection = getDefaultDeflection(theResult);
- return aDeflection;
-}
-
-double XGUI_CustomPrs::getResultTransparency(const ResultPtr& theResult)
-{
- double aTransparency = getTransparency(theResult);
- if (aTransparency < 0)
- aTransparency = getDefaultTransparency(theResult);
- return aTransparency;
-}
-
-bool XGUI_CustomPrs::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
- std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs)
-{
- bool aCustomized = false;
- if (theResult.get()) {
- std::vector<int> aColor;
- getResultColor(theResult, aColor);
-
- SessionPtr aMgr = ModelAPI_Session::get();
- if (aMgr->activeDocument() != theResult->document()) {
- QColor aQColor(aColor[0], aColor[1], aColor[2]);
- QColor aNewColor =
- QColor::fromHsvF(aQColor.hueF(), aQColor.saturationF()/3., aQColor.valueF());
- aColor[0] = aNewColor.red();
- aColor[1] = aNewColor.green();
- aColor[2] = aNewColor.blue();
- }
- aCustomized = !aColor.empty() && thePrs->setColor(aColor[0], aColor[1], aColor[2]);
-
- aCustomized = thePrs->setDeflection(getResultDeflection(theResult)) | aCustomized;
-
- aCustomized = thePrs->setTransparency(getResultTransparency(theResult)) | aCustomized;
- }
- ModuleBase_IModule* aModule = myWorkshop->module();
- aCustomized = aModule->customisePresentation(theResult, thePrs, theCustomPrs) || aCustomized;
- return aCustomized;
-}
+++ /dev/null
-// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef XGUI_CustomPrs_H
-#define XGUI_CustomPrs_H
-
-#include "XGUI.h"
-#include <GeomAPI_ICustomPrs.h>
-#include <GeomAPI_AISObject.h>
-#include <ModelAPI_Result.h>
-
-class XGUI_Workshop;
-
-/**
-* Interface of a class which can provide specific customization of
-* object presentation
-*/
-class XGUI_CustomPrs : public GeomAPI_ICustomPrs
-{
-public:
- /// Constructor
- /// \param theWorkshop the current workshop instance
- XGUI_EXPORT XGUI_CustomPrs(XGUI_Workshop* theWorkshop);
-
- XGUI_EXPORT virtual ~XGUI_CustomPrs() {};
-
- /// Modifies the given presentation in the custom way.
- virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
- std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs);
-
- /// Returns color of a result object
- /// \param theResult a result object
- /// \param theColor a color in form of RGB vector
- static void getResultColor(const ResultPtr& theResult, std::vector<int>& theColor);
-
- /// Returns deflection of a result object
- /// \param theResult a result object
- /// \return theDeflection a real value
- static double getResultDeflection(const ResultPtr& theResult);
-
- /// Returns transparency of a result object
- /// \param theResult a result object
- /// \return theTransparency a real value
- static double getResultTransparency(const ResultPtr& theResult);
-
- /// Returns the default object color. It obtains colorConfigInfo of the object
- /// and find it in preferences. If there are no this color in preference and an empty
- /// color is interpreted as invalid, it shows error message
- /// \param theObject an investigated object
- /// \param isEmptyColorValid boolean state about interpretation of empty color
- /// \param theColor the result color
- static void XGUI_EXPORT getDefaultColor(ObjectPtr theObject, const bool isEmptyColorValid,
- std::vector<int>& theColor);
-
- /// Returns the default deflection value. The value is obtained from the application preferences
- /// \param theObject an investigated object
- /// \return deflection value
- static double XGUI_EXPORT getDefaultDeflection(const ObjectPtr& theObject);
-
-protected:
- XGUI_Workshop* myWorkshop; ///< the current workshop
-};
-
-#endif
#include "XGUI_Displayer.h"
-#include "XGUI_CustomPrs.h"
#include "XGUI_FacesPanel.h"
#include "XGUI_Selection.h"
#include "XGUI_SelectionActivate.h"
#include <ModuleBase_BRepOwner.h>
#include <ModuleBase_IModule.h>
#include <ModuleBase_Preferences.h>
-#include <ModuleBase_ResultPrs.h>
#include <ModuleBase_Tools.h>
#include <ModuleBase_ViewerPrs.h>
#include <ModuleBase_IViewer.h>
: myWorkshop(theWorkshop), myNeedUpdate(false),
myViewerBlockedRecursiveCount(0), myIsFirstAISContextUse(true)
{
- myCustomPrs = std::shared_ptr<GeomAPI_ICustomPrs>(new XGUI_CustomPrs(theWorkshop));
}
//**************************************************************
}
anAIS = aPrs->getAISObject(anAIS);
} else {
- Handle(AIS_InteractiveObject) anAISPrs =
- myWorkshop->module()->createPresentation(theObject);
- if (anAISPrs.IsNull()) {
- ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
- if (aResult.get() != NULL) {
- std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
- if (aShapePtr.get() != NULL) {
- anAISPrs = new ModuleBase_ResultPrs(aResult);
- }
- }
- }
- Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(anAISPrs);
- if (!aShapePrs.IsNull())
- ModuleBase_Tools::setPointBallHighlighting((AIS_Shape*)aShapePrs.get());
- anAIS = AISObjectPtr(new GeomAPI_AISObject());
- anAIS->setImpl(new Handle(AIS_InteractiveObject)(anAISPrs));
+ anAIS = myWorkshop->module()->createPresentation(theObject);
isShading = true;
}
- if (anAIS)
+ if (anAIS.get())
aDisplayed = display(theObject, anAIS, isShading, theUpdateViewer);
}
return aDisplayed;
if (!anAISIO.IsNull()) {
appendResultObject(theObject, theAIS);
- bool isCustomized = customizeObject(theObject);
+ //bool isCustomized = customizeObject(theObject);
int aDispMode = isShading? Shading : Wireframe;
if (isShading)
bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer)
{
bool aRedisplayed = false;
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return aRedisplayed;
+
if (!isVisible(theObject))
return aRedisplayed;
AISObjectPtr aAISObj = getAISObject(theObject);
- Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ Handle(AIS_InteractiveObject) aAISIO;
GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
if (aPrs) {
}
aAISIO = aAIS_Obj->impl<Handle(AIS_InteractiveObject)>();
}
+ else {
+ aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ }
- Handle(AIS_InteractiveContext) aContext = AISContext();
- if (!aContext.IsNull() && !aAISIO.IsNull()) {
+ if (!aAISIO.IsNull()) {
// Check that the visualized shape is the same and the redisplay is not necessary
// Redisplay of AIS object leads to this object selection compute and the selection
// in the browser is lost
// before and after the values modification.
// Moreother, this check avoids customize and redisplay presentation if the presentable
// parameter is changed.
- bool isEqualShapes = false;
- ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
- if (aResult.get() != NULL) {
- Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aAISIO);
- if (!aShapePrs.IsNull()) {
- std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
- if (aShapePtr.get()) {
- const TopoDS_Shape& aOldShape = aShapePrs->Shape();
- if (!aOldShape.IsNull())
- isEqualShapes = aOldShape.IsEqual(aShapePtr->impl<TopoDS_Shape>());
- }
- }
- }
+ //bool isEqualShapes = false;
+ //ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ //if (aResult.get() != NULL) {
+ // Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aAISIO);
+ // if (!aShapePrs.IsNull()) {
+ // std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
+ // if (aShapePtr.get()) {
+ // const TopoDS_Shape& aOldShape = aShapePrs->Shape();
+ // if (!aOldShape.IsNull())
+ // isEqualShapes = aOldShape.IsEqual(aShapePtr->impl<TopoDS_Shape>());
+ // }
+ // }
+ //}
// Customization of presentation
- bool isCustomized = customizeObject(theObject);
+ //bool isCustomized = customizeObject(theObject);
#ifdef DEBUG_FEATURE_REDISPLAY
- qDebug(QString("Redisplay: %1, isEqualShapes=%2, isCustomized=%3").
- arg(!isEqualShapes || isCustomized).arg(isEqualShapes)
- .arg(isCustomized).toStdString().c_str());
+ qDebug(QString("Redisplay: %1, isEqualShapes=%2").
+ arg(!isEqualShapes/* || isCustomized*/).arg(isEqualShapes)
+ .toStdString().c_str());
#endif
- if (!isEqualShapes || isCustomized) {
- /// if shapes are equal and presentation are customized, selection should be restored
- bool aNeedToRestoreSelection = isEqualShapes && isCustomized;
- if (aNeedToRestoreSelection)
- myWorkshop->module()->storeSelection();
+ //if (!isEqualShapes/* || isCustomized*/) {
+ // /// if shapes are equal and presentation are customized, selection should be restored
+ // bool aNeedToRestoreSelection = isEqualShapes/* && isCustomized*/;
+ // if (aNeedToRestoreSelection)
+ if (aAISObj.get() && myWorkshop->facesPanel())
+ myWorkshop->facesPanel()->customizeObject(theObject, aAISObj);
+
+ myWorkshop->module()->storeSelection();
#ifdef CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
- myWorkshop->selector()->deselectPresentation(aAISIO);
+ myWorkshop->selector()->deselectPresentation(aAISIO);
#endif
- if (aContext->IsDisplayed(aAISIO))
- aContext->Redisplay(aAISIO, false);
- else
- aContext->Display(aAISIO, false);
-
+ if (aContext->IsDisplayed(aAISIO))
+ aContext->Redisplay(aAISIO, false);
+ else {
+ aContext->Display(aAISIO, false);
+ }
#ifdef TINSPECTOR
if (getCallBack()) getCallBack()->Redisplay(aAISIO);
#endif
- if (aNeedToRestoreSelection)
- myWorkshop->module()->restoreSelection();
+ //if (aNeedToRestoreSelection)
+ myWorkshop->module()->restoreSelection();
- aRedisplayed = true;
- #ifdef DEBUG_FEATURE_REDISPLAY
- qDebug(" Redisplay happens");
- #endif
- if (theUpdateViewer)
- updateViewer();
- }
+ aRedisplayed = true;
+ #ifdef DEBUG_FEATURE_REDISPLAY
+ qDebug(" Redisplay happens");
+ #endif
+ if (theUpdateViewer)
+ updateViewer();
}
return aRedisplayed;
}
}
//**************************************************************
-bool XGUI_Displayer::customizeObject(ObjectPtr theObject)
-{
- AISObjectPtr anAISObj = getAISObject(theObject);
- // correct the result's color it it has the attribute
- ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-
- // Customization of presentation
- GeomCustomPrsPtr aCustomPrs;
- FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
- if (aFeature.get() != NULL) {
- GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast<GeomAPI_ICustomPrs>(aFeature);
- if (aCustPrs.get() != NULL)
- aCustomPrs = aCustPrs;
- }
- if (aCustomPrs.get() == NULL) {
- GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
- // we ignore presentable not customized objects
- if (aPrs.get() == NULL)
- aCustomPrs = myCustomPrs;
- }
- bool isCustomized = aCustomPrs.get() &&
- aCustomPrs->customisePresentation(aResult, anAISObj, myCustomPrs);
- isCustomized = myWorkshop->module()->afterCustomisePresentation(aResult, anAISObj, myCustomPrs)
- || isCustomized;
-
- // update presentation state if faces panel is active
- if (anAISObj.get() && myWorkshop->facesPanel())
- isCustomized = myWorkshop->facesPanel()->customizeObject(theObject, anAISObj) || isCustomized;
-
- return isCustomized;
-}
+//bool XGUI_Displayer::customizeObject(ObjectPtr theObject)
+//{
+// AISObjectPtr anAISObj = getAISObject(theObject);
+// // correct the result's color it it has the attribute
+// ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+//
+// // Customization of presentation
+// GeomCustomPrsPtr aCustomPrs;
+// FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+// if (aFeature.get() != NULL) {
+// GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast<GeomAPI_ICustomPrs>(aFeature);
+// if (aCustPrs.get() != NULL)
+// aCustomPrs = aCustPrs;
+// }
+// if (aCustomPrs.get() == NULL) {
+// GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
+// // we ignore presentable not customized objects
+// if (aPrs.get() == NULL)
+// aCustomPrs = myCustomPrs;
+// }
+// bool isCustomized = aCustomPrs.get() &&
+// aCustomPrs->customisePresentation(aResult, anAISObj, myCustomPrs);
+// isCustomized = myWorkshop->module()->afterCustomisePresentation(aResult, anAISObj, myCustomPrs)
+// || isCustomized;
+//
+// // update presentation state if faces panel is active
+// if (anAISObj.get() && myWorkshop->facesPanel())
+// isCustomized = myWorkshop->facesPanel()->customizeObject(theObject, anAISObj) || isCustomized;
+//
+// return isCustomized;
+//}
//**************************************************************
QColor XGUI_Displayer::setObjectColor(ObjectPtr theObject,
#include "XGUI.h"
#include <GeomAPI_AISObject.h>
-#include <GeomAPI_ICustomPrs.h>
#include <GeomAPI_Pln.h>
#include <ModelAPI_Result.h>
#endif
Handle(SelectMgr_AndFilter) myAndFilter; ///< A container for selection filters
- /// A default custom presentation, which is used if the displayed feature is not
- /// a custom presentation
- GeomCustomPrsPtr myCustomPrs;
-
/// Definition of a type of map which defines correspondance between objects and presentations
#ifdef OPTIMIZE_PRS
XGUI_TwoSidePresentationMap myResult2AISObjectMap; ///< A map of displayed objects
#include <ModuleBase_ITreeNode.h>
#include <XGUI_Workshop.h>
+#include <XGUI_Displayer.h>
#include <QLayout>
#include <QLineEdit>
update(aModel->index(i, 1, aParent));
update(aModel->index(i, 2, aParent));
}
+ XGUI_ObjectsBrowser* aObjBrowser = qobject_cast<XGUI_ObjectsBrowser*>(parent());
+ aObjBrowser->workshop()->displayer()->updateViewer();
}
void XGUI_DataTree::processEyeClick(const QModelIndex& theIndex)
#include "XGUI_Tools.h"
#include "XGUI_ViewerProxy.h"
#include "XGUI_WorkshopListener.h"
-#include <XGUI_CustomPrs.h>
#include <XGUI_HistoryMenu.h>
#include <XGUI_QtEvents.h>
#include <XGUI_DataModel.h>
connect(myEventsListener, SIGNAL(errorOccurred(std::shared_ptr<Events_InfoMessage>)),
myErrorDlg, SLOT(addError(std::shared_ptr<Events_InfoMessage>)));
- //Config_PropManager::registerProp("Visualization", "object_default_color", "Object color",
- // Config_Prop::Color, "225,225,225");
-
- Config_PropManager::registerProp("Visualization", "result_body_color", "Result color",
- Config_Prop::Color, ModelAPI_ResultBody::DEFAULT_COLOR());
- Config_PropManager::registerProp("Visualization", "result_group_color", "Group color",
- Config_Prop::Color, ModelAPI_ResultGroup::DEFAULT_COLOR());
- Config_PropManager::registerProp("Visualization", "result_construction_color",
- "Construction color",
- Config_Prop::Color,
- ModelAPI_ResultConstruction::DEFAULT_COLOR());
- Config_PropManager::registerProp("Visualization", "result_part_color", "Part color",
- Config_Prop::Color, ModelAPI_ResultPart::DEFAULT_COLOR());
- Config_PropManager::registerProp("Visualization", "result_field_color", "Field color",
- Config_Prop::Color, ModelAPI_ResultField::DEFAULT_COLOR());
-
if (ModuleBase_Preferences::resourceMgr()->booleanValue("Viewer", "face-selection", true))
myViewerSelMode.append(TopAbs_FACE);
if (ModuleBase_Preferences::resourceMgr()->booleanValue("Viewer", "edge-selection", true))
foreach(ObjectPtr anObject, theObjects) {
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
if (aResult.get()) {
- XGUI_CustomPrs::getResultColor(aResult, aColor);
+ ModelAPI_Tools::getColor(aResult, aColor);
}
else {
// TODO: remove the obtaining a color from the AIS object
foreach(ObjectPtr anObject, theObjects) {
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
if (aResult.get()) {
- aDeflection = XGUI_CustomPrs::getResultDeflection(aResult);
+ aDeflection = ModelAPI_Tools::getDeflection(aResult);
}
else {
// TODO: remove the obtaining a property from the AIS object
foreach(ObjectPtr anObject, theObjects) {
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
if (aResult.get()) {
- aCurrentValue = XGUI_CustomPrs::getResultTransparency(aResult);
+ aCurrentValue = ModelAPI_Tools::getTransparency(aResult);
}
if (aCurrentValue > 0)
break;
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ aLoop->registerListener(this, Events_Loop::eventByName(EVENT_VISUAL_ATTRIBUTES));
aLoop->registerListener(this, Events_LongOp::eventID());
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_PLUGIN_LOADED));
// Redisplay feature
else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
- std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
+ std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
onFeatureRedisplayMsg(aUpdMsg);
+ }
+ else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_VISUAL_ATTRIBUTES)) {
+ std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
+ std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
+ std::set<ObjectPtr> aObjList = aUpdMsg->objects();
+ std::set<ObjectPtr>::const_iterator aIt;
+ std::list<ResultPtr>::const_iterator aResIt;
+ XGUI_Displayer* aDisplayer = workshop()->displayer();
+ AISObjectPtr aAIS;
+ for (aIt = aObjList.begin(); aIt != aObjList.end(); ++aIt) {
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*aIt);
+ if (aFeature) {
+ aAIS = aDisplayer->getAISObject(aFeature);
+ if (aAIS.get())
+ workshop()->module()->customizePresentation(aFeature, aAIS);
+
+ std::list<ResultPtr> aResults = aFeature->results();
+ for (aResIt = aResults.begin(); aResIt != aResults.end(); ++aResIt) {
+ aAIS = aDisplayer->getAISObject(*aResIt);
+ if (aAIS.get())
+ workshop()->module()->customizePresentation(*aResIt, aAIS);
+ }
+ }
+ }
} else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION)) {
std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
//if (aHiddenObjects.size() > 0)
// myWorkshop->module()->processHiddenObject(aHiddenObjects);
- bool isCustomized = customizeCurrentObject(anObjects, aRedisplayed);
+ bool isCustomized = customizeFeature(anObjects, aRedisplayed);
if (aRedisplayed || isCustomized) {
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION));
}
}
- bool isCustomized = customizeCurrentObject(anObjects, aDisplayed);
+ bool isCustomized = customizeFeature(anObjects, aDisplayed);
//if (myObjectBrowser)
// myObjectBrowser->processEvent(theMsg);
return aDisplayer->display(theObj, false);
}
-bool XGUI_WorkshopListener::customizeCurrentObject(const std::set<ObjectPtr>& theObjects,
+bool XGUI_WorkshopListener::customizeFeature(const std::set<ObjectPtr>& theObjects,
bool theForceRedisplay)
{
XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
// the feature is hidden, but arguments of the feature are modified
// e.g. extrusion is hidden(h=0) but sketch is chosen
if (theForceRedisplay || theObjects.find(aCurrentFeature) != theObjects.end()) {
- aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
+ aCustomized = myWorkshop->module()->customizeFeature(aCurrentFeature,
ModuleBase_IModule::CustomizeArguments, false) || aCustomized;
- aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
+ aCustomized = myWorkshop->module()->customizeFeature(aCurrentFeature,
ModuleBase_IModule::CustomizeResults, false) || aCustomized;
- aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
+ aCustomized = myWorkshop->module()->customizeFeature(aCurrentFeature,
ModuleBase_IModule::CustomizeHighlightedObjects, false) || aCustomized;
}
}
/// if forced redisplay is false
/// \param theForceRedisplay a flag to customize object even always
/// \return true if the object is modified
- bool customizeCurrentObject(const std::set<ObjectPtr>& theObjects, bool theForceRedisplay);
+ bool customizeFeature(const std::set<ObjectPtr>& theObjects, bool theForceRedisplay);
/// Returns the workshop
XGUI_Workshop* workshop() const;