if (myObject && (theAttr->attributeType() == "Point2D" || theAttr->id() == "Color" ||
theAttr->id() == "Transparency" || theAttr->id() == "Deflection" ||
theAttr->id() == "Iso_lines" || theAttr->id() == "Show_Iso_lines" ||
- theAttr->id() == "Show_Edges_direction")) {
+ theAttr->id() == "Show_Edges_direction" || theAttr->id() == "Bring_To_Front")) {
static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
}
aData->addAttribute(DEFLECTION_ID(), ModelAPI_AttributeDouble::typeId())->setIsArgument(false);
aData->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeDouble::typeId())->setIsArgument(false);
aData->addAttribute(ISO_LINES_ID(), ModelAPI_AttributeIntArray::typeId())->setIsArgument(false);
- aData->addAttribute(SHOW_ISO_LINES_ID(), ModelAPI_AttributeBoolean::typeId())->
- setIsArgument(false);
- aData->addAttribute(SHOW_EDGES_DIRECTION_ID(), ModelAPI_AttributeBoolean::typeId())->
- setIsArgument(false);
+ aData->addAttribute(SHOW_ISO_LINES_ID(), ModelAPI_AttributeBoolean::typeId())->setIsArgument(false);
+ aData->addAttribute(SHOW_EDGES_DIRECTION_ID(), ModelAPI_AttributeBoolean::typeId())->setIsArgument(false);
+ // Add the "Bring To Front" attribute to the Result base class, as we may support it in the future
+ // for all type of results. Actually, only ResultGroups are supported.
+ aData->addAttribute(BRING_TO_FRONT_ID(), ModelAPI_AttributeBoolean::typeId())->setIsArgument(false);
}
bool ModelAPI_Result::setDisabled(std::shared_ptr<ModelAPI_Result> theThis, const bool theFlag)
return MY_SHOW_EDGES_DIRECTION_ID;
}
+ /// Reference to the BringToFront flag of the result.
+ /// The bool value is used.
+ inline static const std::string& BRING_TO_FRONT_ID()
+ {
+ static const std::string MY_BRING_TO_FRONT_ID("Bring_To_Front");
+ return MY_BRING_TO_FRONT_ID;
+ }
+
/// Returns true if the result is concealed from the data tree (referenced by other objects)
MODELAPI_EXPORT virtual bool isConcealed();
return false;
}
+//******************************************************
+void bringToFront(std::shared_ptr<ModelAPI_Result> theResult, bool theFlag)
+{
+ if (!theResult.get())
+ return;
+
+ AttributeBooleanPtr aAttr = theResult->data()->boolean(ModelAPI_Result::BRING_TO_FRONT_ID());
+ if (aAttr.get() != NULL) {
+ aAttr->setValue(theFlag);
+ }
+}
+
+//******************************************************
+bool isBringToFront(std::shared_ptr<ModelAPI_Result> theResult)
+{
+ if (!theResult.get())
+ return false;
+
+ AttributeBooleanPtr aAttr = theResult->data()->boolean(ModelAPI_Result::BRING_TO_FRONT_ID());
+ if (aAttr.get() != NULL) {
+ return aAttr->value();
+ }
+ return false;
+}
+
//**************************************************************
void setTransparency(ResultPtr theResult, double theTransparency)
{
MODELAPI_EXPORT bool isShowEdgesDirection(std::shared_ptr<ModelAPI_Result> theResult);
+/*! Set flag to bring result in front of other results
+* \param[in] theResult a result object
+* \param[in] theFlag is a flag
+*/
+MODELAPI_EXPORT void bringToFront(std::shared_ptr<ModelAPI_Result> theResult, bool theFlag);
+
+MODELAPI_EXPORT bool isBringToFront(std::shared_ptr<ModelAPI_Result> theResult);
+
/*! Returns current transparency in the given result
* \param theResult a result object
* \return a transparency value or -1 if it was not defined
void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature,
bool& hasParameter, bool& hasCompositeOwner, bool& hasResultInHistory,
- bool& hasFolder)
+ bool& hasFolder, bool &hasGroupsOnly)
{
hasResult = false;
hasFeature = false;
hasCompositeOwner = false;
hasResultInHistory = false;
hasFolder = false;
+ bool hasNonGroup = false;
foreach(ObjectPtr aObj, theObjects) {
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+ ResultGroupPtr aGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(aObj);
FolderPtr aFolder = std::dynamic_pointer_cast<ModelAPI_Folder>(aObj);
ResultParameterPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aResult);
FieldStepPtr aStep = std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(aObj);
hasFeature |= (aFeature.get() != NULL);
hasFolder |= (aFolder.get() != NULL);
hasParameter |= (aConstruction.get() != NULL);
+ hasNonGroup |= (aGroup.get() == NULL);
if (hasFeature)
hasCompositeOwner |= (ModelAPI_Tools::compositeOwner(aFeature) != NULL);
else if (aResult.get())
hasResultInHistory = aFeature.get() && aFeature->isInHistory();
}
- if (hasFeature && hasResult && hasParameter && hasCompositeOwner)
+ if (hasFeature && hasResult && hasParameter && hasCompositeOwner && hasNonGroup)
break;
}
+ hasGroupsOnly = !hasNonGroup;
}
void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape,
/// \param hasFolder will be set to true if one of folder is in the list
MODULEBASE_EXPORT void checkObjects(const QObjectPtrList& theObjects, bool& hasResult,
bool& hasFeature, bool& hasParameter, bool& hasCompositeOwner,
- bool& hasResultInHistory, bool& hasFolder);
+ bool& hasResultInHistory, bool& hasFolder, bool &hasGroupsOnly);
/// Sets the default coeffient into the driver calculated accordingly the shape type.
/// It provides 1.e-4 for results of construction type
bool hasCompositeOwner = false;
bool hasResultInHistory = false;
bool hasFolder = false;
+ bool hasGroupsOnly = false;
ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter,
- hasCompositeOwner, hasResultInHistory, hasFolder);
+ hasCompositeOwner, hasResultInHistory, hasFolder, hasGroupsOnly);
ModuleBase_Operation* aCurrentOp = myWorkshop->currentOperation();
if (aSelected == 1) {
anAction->setCheckable(true);
addAction("SHOW_ISOLINES_CMD", anAction);
+ anAction = ModuleBase_Tools::createAction(QIcon(), tr("Bring To Front"), aDesktop);
+ anAction->setCheckable(true);
+ addAction("BRING_TO_FRONT_CMD", anAction);
+
mySeparator1 = ModuleBase_Tools::createAction(QIcon(), "", aDesktop);
mySeparator1->setSeparator(true);
mySeparator3 = ModuleBase_Tools::createAction(QIcon(), "", aDesktop);
mySeparator3->setSeparator(true);
+ mySeparator4 = ModuleBase_Tools::createAction(QIcon(), "", aDesktop);
+ mySeparator4->setSeparator(true);
+
anAction = ModuleBase_Tools::createAction(QIcon(":pictures/vertex.png"), tr("Vertices"), aDesktop,
this, SLOT(onShapeSelection(bool)));
anAction->setCheckable(true);
bool hasCompositeOwner = false;
bool hasResultInHistory = false;
bool hasFolder = false;
+ bool hasGroupsOnly = false;
ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter,
- hasCompositeOwner, hasResultInHistory, hasFolder);
+ hasCompositeOwner, hasResultInHistory, hasFolder, hasGroupsOnly);
//Process Feature
if (aSelected == 1) { // single selection
ObjectPtr aObject = aObjects.first();
action("SHOW_EDGES_DIRECTION_CMD")->setEnabled(true);
action("SHOW_EDGES_DIRECTION_CMD")->setChecked(ModelAPI_Tools::isShowEdgesDirection(aResult));
+ action("BRING_TO_FRONT_CMD")->setEnabled(hasGroupsOnly);
+ action("BRING_TO_FRONT_CMD")->setChecked(ModelAPI_Tools::isBringToFront(aResult));
+
action("SHOW_ISOLINES_CMD")->setEnabled(true);
action("SHOW_ISOLINES_CMD")->setChecked(ModelAPI_Tools::isShownIsoLines(aResult));
action("ISOLINES_CMD")->setEnabled(true);
action("SHADING_CMD")->setEnabled(true);
action("WIREFRAME_CMD")->setEnabled(true);
action("SHOW_EDGES_DIRECTION_CMD")->setEnabled(true);
+ action("BRING_TO_FRONT_CMD")->setEnabled(hasGroupsOnly);
action("SHOW_ISOLINES_CMD")->setEnabled(true);
action("ISOLINES_CMD")->setEnabled(true);
}
action("SHOW_EDGES_DIRECTION_CMD")->setEnabled(true);
action("SHOW_EDGES_DIRECTION_CMD")->setChecked(
ModelAPI_Tools::isShowEdgesDirection(aResult));
+
+ // Only enable the "Bring To Front" command for Groups
+ ResultGroupPtr aGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(aResult);
+ action("BRING_TO_FRONT_CMD")->setEnabled(aGroup.get() != NULL);
+ action("BRING_TO_FRONT_CMD")->setChecked(ModelAPI_Tools::isBringToFront(aResult));
}
}
}
QActionsList aList;
+ //-------------------------------------
// Result construction menu
aList.append(action("SHOW_CMD"));
aList.append(action("HIDE_CMD"));
myObjBrowserMenus[ModelAPI_ResultConstruction::group()] = aList;
//-------------------------------------
- // Result body menu
+ // Result body/field/part menu
aList.clear();
aList.append(action("WIREFRAME_CMD"));
aList.append(action("SHADING_CMD"));
aList.append(action("SHOW_FEATURE_CMD"));
aList.append(mySeparator3);
aList.append(action("DELETE_CMD"));
+ // Result body menu
myObjBrowserMenus[ModelAPI_ResultBody::group()] = aList;
- // Group menu
+ // Field menu
myObjBrowserMenus[ModelAPI_ResultField::group()] = aList;
// Result part menu
myObjBrowserMenus[ModelAPI_ResultPart::group()] = aList;
+ //-------------------------------------
+ // Group menu
aList.clear();
aList.append(action("WIREFRAME_CMD"));
aList.append(action("SHADING_CMD"));
aList.append(action("SHOW_EDGES_DIRECTION_CMD"));
- aList.append(mySeparator1); // this separator is not shown as this action is added after show only
- // qt list container contains only one instance of the same action
+ aList.append(mySeparator1);
+ aList.append(action("BRING_TO_FRONT_CMD"));
+ aList.append(mySeparator2);
aList.append(action("SHOW_CMD"));
aList.append(action("HIDE_CMD"));
aList.append(action("SHOW_ONLY_CMD"));
- aList.append(mySeparator2);
+ aList.append(mySeparator3);
aList.append(action("AUTOCOLOR_CMD"));
aList.append(action("RENAME_CMD"));
aList.append(action("COLOR_CMD"));
aList.append(action("SHOW_ISOLINES_CMD"));
aList.append(action("ISOLINES_CMD"));
aList.append(action("SHOW_FEATURE_CMD"));
- aList.append(mySeparator3);
+ aList.append(mySeparator4);
aList.append(action("DELETE_CMD"));
- // Group menu
myObjBrowserMenus[ModelAPI_ResultGroup::group()] = aList;
+
//-------------------------------------
// Feature menu
aList.clear();
aList.append(action("DELETE_CMD"));
myObjBrowserMenus[ModelAPI_Feature::group()] = aList;
+ //-------------------------------------
+ // Parameter menu
aList.clear();
aList.append(action("RENAME_CMD"));
aList.append(mySeparator1);
aList.append(action("CLEAN_HISTORY_CMD"));
aList.append(action("DELETE_CMD"));
myObjBrowserMenus[ModelAPI_ResultParameter::group()] = aList;
- //-------------------------------------
+ //-------------------------------------
+ // Folder menu
aList.clear();
aList.append(action("RENAME_CMD"));
aList.append(action("DELETE_CMD"));
void XGUI_ContextMenuMgr::buildViewerMenu()
{
QActionsList aList;
- // Result construction menu
+ // Result construction/part menu
aList.append(action("COLOR_CMD"));
aList.append(action("DEFLECTION_CMD"));
aList.append(action("TRANSPARENCY_CMD"));
aList.append(action("SHOW_ONLY_CMD"));
aList.append(action("HIDE_CMD"));
myViewerMenu[ModelAPI_ResultConstruction::group()] = aList;
- // Result part menu
myViewerMenu[ModelAPI_ResultPart::group()] = aList;
+
//-------------------------------------
// Result body menu
aList.clear();
aList.append(action("SHOW_ONLY_CMD"));
aList.append(action("HIDE_CMD"));
myViewerMenu[ModelAPI_ResultBody::group()] = aList;
+ myViewerMenu[ModelAPI_ResultField::group()] = aList;
+
+ //-------------------------------------
// Group menu
+ aList.clear();
+ aList.append(action("WIREFRAME_CMD"));
+ aList.append(action("SHADING_CMD"));
+ aList.append(action("SHOW_EDGES_DIRECTION_CMD"));
+ aList.append(mySeparator1);
+ aList.append(action("BRING_TO_FRONT_CMD"));
+ aList.append(mySeparator2);
+ aList.append(action("COLOR_CMD"));
+ aList.append(action("DEFLECTION_CMD"));
+ aList.append(action("TRANSPARENCY_CMD"));
+ aList.append(action("SHOW_ISOLINES_CMD"));
+ aList.append(action("ISOLINES_CMD"));
+ aList.append(mySeparator3);
+ aList.append(action("SET_VIEW_NORMAL_CMD"));
+ aList.append(action("SET_VIEW_INVERTEDNORMAL_CMD"));
+ aList.append(mySeparator4);
+ aList.append(action("SHOW_ONLY_CMD"));
+ aList.append(action("HIDE_CMD"));
myViewerMenu[ModelAPI_ResultGroup::group()] = aList;
- myViewerMenu[ModelAPI_ResultField::group()] = aList;
+
//-------------------------------------
// Step objects menu
aList.clear();
anActions.append(action("SHADING_CMD"));
anActions.append(action("SHOW_EDGES_DIRECTION_CMD"));
anActions.append(mySeparator1);
+ anActions.append(action("BRING_TO_FRONT_CMD"));
+ anActions.append(mySeparator2);
anActions.append(action("SHOW_CMD"));
anActions.append(action("HIDE_CMD"));
anActions.append(action("SHOW_ONLY_CMD"));
- anActions.append(mySeparator2);
+ anActions.append(mySeparator3);
anActions.append(action("ADD_TO_FOLDER_BEFORE_CMD"));
anActions.append(action("ADD_TO_FOLDER_AFTER_CMD"));
anActions.append(action("ADD_OUT_FOLDER_BEFORE_CMD"));
anActions.append(action("ADD_OUT_FOLDER_AFTER_CMD"));
- anActions.append(mySeparator3);
+ anActions.append(mySeparator4);
anActions.append(action("MOVE_CMD"));
anActions.append(action("MOVE_SPLIT_CMD"));
anActions.append(action("COLOR_CMD"));
QAction* mySeparator1;
QAction* mySeparator2;
QAction* mySeparator3;
+ QAction* mySeparator4;
};
#endif
#include <ModelAPI_Tools.h>
#include <ModelAPI_AttributeIntArray.h>
#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultGroup.h>
#include <ModuleBase_BRepOwner.h>
#include <ModuleBase_IModule.h>
/// defines the local context mouse selection sensitivity
const int MOUSE_SENSITIVITY_IN_PIXEL = 10;
+/// defines the display priority for results brought to front
+constexpr int FRONT_DISPLAY_PRIORITY = 8; /* = Graphic3d_DisplayPriority_Highlight-1 */
+
+/// defines the default (normal) display priority for all results
+constexpr int DEFAULT_DISPLAY_PRIORITY = 5; /* = Graphic3d_DisplayPriority_Normal */
+
//#define DEBUG_DISPLAY
//#define DEBUG_FEATURE_REDISPLAY
//#define DEBUG_SELECTION_FILTERS
int aDispMode = isShading? Shading : Wireframe;
anAISIO->SetDisplayMode(aDispMode);
aContext->Display(anAISIO, aDispMode, 0, false, AIS_DS_Displayed);
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (ModelAPI_Tools::isBringToFront(aResult)) {
+ // NOTE: do not use a priority higher than 8 as highlight uses priority 9!
+ // Any higher level prevents the highlight from being visible as it would
+ // appear "behind" the Groups.
+ aContext->SetDisplayPriority(anAISIO, FRONT_DISPLAY_PRIORITY);
+ }
#ifdef TINSPECTOR
if (getCallBack()) getCallBack()->Display(anAISIO);
#endif
Handle(ModuleBase_ResultPrs) aResPrs = Handle(ModuleBase_ResultPrs)::DownCast(aAISIO);
if (!aResPrs.IsNull())
aResPrs->updateIsoLines();
+
+ // Only support the "Bring To Front" command for Groups (for now)
+ ResultGroupPtr aGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(aResult);
+ if (aGroup.get()) {
+ bool isInFront = ModelAPI_Tools::isBringToFront(aResult);
+ aContext->SetDisplayPriority(aAISIO, (isInFront ? FRONT_DISPLAY_PRIORITY : DEFAULT_DISPLAY_PRIORITY));
+ }
}
//myWorkshop->module()->storeSelection();
setDisplayMode(anObjects, XGUI_Displayer::Wireframe);
else if (theId == "SHOW_EDGES_DIRECTION_CMD")
toggleEdgesDirection(anObjects);
+ else if (theId == "BRING_TO_FRONT_CMD")
+ toggleBringToFront(anObjects);
else if (theId == "HIDEALL_CMD") {
QObjectPtrList aList = myDisplayer->displayedObjects();
foreach (ObjectPtr aObj, aList) {
bool hasCompositeOwner = false;
bool hasResultInHistory = false;
bool hasFolder = false;
+ bool hasGroupsOnly = false;
ModuleBase_Tools::checkObjects(anObjects, hasResult, hasFeature, hasParameter, hasCompositeOwner,
- hasResultInHistory, hasFolder);
+ hasResultInHistory, hasFolder, hasGroupsOnly);
if (!(hasResult || hasFeature || hasParameter || hasFolder))
return;
myDisplayer->updateViewer();
}
+//**************************************************************
+void XGUI_Workshop::toggleBringToFront(const QObjectPtrList& theList)
+{
+ // Toggle the "BringToFront" state of all objects in the list
+ foreach(ObjectPtr anObj, theList) {
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
+ if (aResult.get() != NULL)
+ {
+ bool aBringToFront = !ModelAPI_Tools::isBringToFront(aResult);
+ ModelAPI_Tools::bringToFront(aResult, aBringToFront);
+ myDisplayer->redisplay(anObj, false);
+ }
+ }
+ if (theList.size() > 0)
+ myDisplayer->updateViewer();
+}
+
//**************************************************************
void XGUI_Workshop::closeDocument()
{
/// Toggle visualisation of edges direction
void toggleEdgesDirection(const QObjectPtrList& theList);
+ /// Toggle state of display priority (normal/in front)
+ void toggleBringToFront(const QObjectPtrList& theList);
+
/// Set selection mode in viewer. If theMode=-1 then activate default mode
/// \param theMode the selection mode (according to TopAbs_ShapeEnum)
void setViewerSelectionMode(int theMode);
<source>Show edges direction</source>
<translation>Afficher la direction des bords</translation>
</message>
+ <message>
+ <source>Bring To Front</source>
+ <translation>Afficher au premier plan</translation>
+ </message>
</context>
<context>
<name>XGUI_DataTree</name>