aAction = new QAction(QIcon(":pictures/eye_pencil_closed.png"), tr("Hide"), this);
addAction("HIDE_CMD", aAction);
+
+ aAction = new QAction(QIcon(":pictures/shading.png"), tr("Shading"), this);
+ addAction("SHADING_CMD", aAction);
+
+ aAction = new QAction(QIcon(":pictures/wireframe.png"), tr("Wireframe"), this);
+ addAction("WIREFRAME_CMD", aAction);
}
void XGUI_ContextMenuMgr::addAction(const QString& theId, QAction* theAction)
} else if (hasFeature) {
aMenu->addAction(action("EDIT_CMD"));
} else {
- if (aDisplayer->isVisible(aObject))
+ if (aDisplayer->isVisible(aObject)) {
aMenu->addAction(action("HIDE_CMD"));
- else {
+ if (aDisplayer->displayMode(aObject) == XGUI_Displayer::Shading)
+ aMenu->addAction(action("WIREFRAME_CMD"));
+ else
+ aMenu->addAction(action("SHADING_CMD"));
+ } else {
aMenu->addAction(action("SHOW_CMD"));
}
aMenu->addAction(action("SHOW_ONLY_CMD"));
aMenu->addAction(action("SHOW_CMD"));
aMenu->addAction(action("HIDE_CMD"));
aMenu->addAction(action("SHOW_ONLY_CMD"));
+ aMenu->addSeparator();
+ aMenu->addAction(action("SHADING_CMD"));
+ aMenu->addAction(action("WIREFRAME_CMD"));
}
}
if (hasFeature)
//if (aObjects.size() == 1)
// theMenu->addAction(action("EDIT_CMD"));
bool isVisible = false;
+ bool isShading = false;
foreach(ObjectPtr aObject, aObjects)
{
ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(aObject);
if (aRes && myWorkshop->displayer()->isVisible(aRes)) {
isVisible = true;
+ isShading = (myWorkshop->displayer()->displayMode(aObject) == XGUI_Displayer::Shading);
break;
}
}
- if (isVisible)
+ if (isVisible) {
theMenu->addAction(action("HIDE_CMD"));
- else
+ if (isShading)
+ theMenu->addAction(action("WIREFRAME_CMD"));
+ else
+ theMenu->addAction(action("SHADING_CMD"));
+ } else
theMenu->addAction(action("SHOW_CMD"));
//theMenu->addAction(action("DELETE_CMD"));
}
{
}
-bool XGUI_Displayer::isVisible(ObjectPtr theObject)
+bool XGUI_Displayer::isVisible(ObjectPtr theObject) const
{
return myResult2AISObjectMap.find(theObject) != myResult2AISObjectMap.end();
}
aContext->RemoveFilters();
aContext->NotUseDisplayedObjects();
-}
\ No newline at end of file
+}
+
+
+void XGUI_Displayer::setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bool toUpdate)
+{
+ if (theMode == NoMode)
+ return;
+
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
+
+ boost::shared_ptr<GeomAPI_AISObject> aAISObj = getAISObject(theObject);
+ if (!aAISObj)
+ return;
+
+ Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ aContext->SetDisplayMode(aAISIO, theMode, toUpdate);
+}
+
+
+XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) const
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return NoMode;
+
+ boost::shared_ptr<GeomAPI_AISObject> aAISObj = getAISObject(theObject);
+ if (!aAISObj)
+ return NoMode;
+
+ Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ return (XGUI_Displayer::DisplayMode) aAISIO->DisplayMode();
+}
+
class XGUI_EXPORT XGUI_Displayer
{
public:
+ enum DisplayMode { NoMode = -1, Wireframe, Shading };
+
/// Constructor
/// \param theViewer the viewer
XGUI_Displayer(XGUI_Workshop* theWorkshop);
/// Returns the feature visibility state.
/// \param theFeature a feature instance
- bool isVisible(ObjectPtr theObject);
+ bool isVisible(ObjectPtr theObject) const;
/// Display the feature. Obtain the visualized object from the feature.
/// \param theFeature a feature instance
void deactivateObjectsOutOfContext();
+ /// Sets display mode for the given object if this object is displayed
+ void setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bool toUpdate = true);
+
+ /// Returns current display mode for the given object.
+ /// If object is not displayed then returns NoMode.
+ DisplayMode displayMode(ObjectPtr theObject) const;
+
+
protected:
/// Deactivate local selection
/// \param isUpdateViewer the state wether the viewer should be updated immediatelly
showObjects(aObjects, false);
else if (theId == "SHOW_ONLY_CMD")
showOnlyObjects(aObjects);
+ else if (theId == "SHADING_CMD")
+ setDisplayMode(aObjects, XGUI_Displayer::Shading);
+ else if (theId == "WIREFRAME_CMD")
+ setDisplayMode(aObjects, XGUI_Displayer::Wireframe);
}
//**************************************************************
for (int i = 0; i < theDoc->size(theGroup); i++)
myDisplayer->display(theDoc->object(theGroup, i), false);
}
+
+//**************************************************************
+void XGUI_Workshop::setDisplayMode(const QList<ObjectPtr>& theList, int theMode)
+{
+ foreach(ObjectPtr aObj, theList) {
+ myDisplayer->setDisplayMode(aObj, (XGUI_Displayer::DisplayMode)theMode, false);
+ }
+ if (theList.size() > 0)
+ myDisplayer->updateViewer();
+}
//! Show the given features in 3d Viewer
void showOnlyObjects(const QList<ObjectPtr>& theList);
+ void setDisplayMode(const QList<ObjectPtr>& theList, int theMode);
+
ModuleBase_IModule* module() const
{
return myModule;
<file>pictures/view_prefs.png</file>
<file>pictures/module.png</file>
+ <file>pictures/shading.png</file>
+ <file>pictures/wireframe.png</file>
</qresource>
</RCC>