return TopAbs_SHAPE;
}
-bool isSubResult(ObjectPtr theObject)
-{
- bool aSubResult = false;
-
- //ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
- return aSubResult;
-}
-
void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature, bool& hasParameter, bool& hasSubFeature)
{
hasResult = false;
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
ResultParameterPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aResult);
- bool aSubResult = isSubResult(aResult);
-
- /// results of compsolids are not processed in SHOW/HIDE/WIREFRAME operations
- hasResult = (aResult.get() != NULL && !aSubResult);
+ hasResult = (aResult.get() != NULL);
hasFeature = (aFeature.get() != NULL);
hasParameter = (aConstruction.get() != NULL);
if (hasFeature)
if (aSelected == 1) {
ObjectPtr aObject = aObjects.first();
if (aObject) {
+ if (hasResult && myWorkshop->canBeShaded(aObject)) {
+ action("WIREFRAME_CMD")->setEnabled(true);
+ action("SHADING_CMD")->setEnabled(true);
+ }
if (!hasFeature) {
if (aObject->isDisplayed()) {
- if (aDisplayer->canBeShaded(aObject)) {
- action("WIREFRAME_CMD")->setEnabled(true);
- action("SHADING_CMD")->setEnabled(true);
- }
action("HIDE_CMD")->setEnabled(true);
} else if (hasResult && (!hasParameter)) {
action("SHOW_CMD")->setEnabled(true);
}
}
} else {
- if (hasResult && (!hasParameter)) {
+ // parameter is commented because the actions are not in the list of result parameter actions
+ if (hasResult /*&& (!hasParameter)*/) {
action("SHOW_CMD")->setEnabled(true);
action("HIDE_CMD")->setEnabled(true);
action("SHOW_ONLY_CMD")->setEnabled(true);
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_Tools.h>
//#include <PartSetPlugin_Part.h>
return aCanMove;
}
+//**************************************************************
+bool XGUI_Workshop::canBeShaded(const ObjectPtr& theObject) const
+{
+ bool aCanBeShaded = myDisplayer->canBeShaded(theObject);
+ if (!aCanBeShaded) {
+ ResultCompSolidPtr aCompsolidResult =
+ std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(theObject);
+ if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
+ for(int i = 0; i < aCompsolidResult->numberOfSubs() && !aCanBeShaded; i++)
+ aCanBeShaded = myDisplayer->canBeShaded(aCompsolidResult->subResult(i));
+ }
+ }
+ return aCanBeShaded;
+}
+
//**************************************************************
bool XGUI_Workshop::canChangeColor() const
{
if (aResult.get() != NULL) {
ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
- for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) {
- ResultPtr aSubResult = aCompsolidResult->subResult(i);
- if (aSubResult.get())
- setColor(aSubResult, aColorResult);
- }
+ for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++)
+ setColor(aCompsolidResult->subResult(i), aColorResult);
}
setColor(aResult, aColorResult);
}
{
foreach(ObjectPtr aObj, theList) {
myDisplayer->setDisplayMode(aObj, (XGUI_Displayer::DisplayMode)theMode, false);
+
+ ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aObj);
+ if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
+ for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) {
+ myDisplayer->setDisplayMode(aCompsolidResult->subResult(i),
+ (XGUI_Displayer::DisplayMode)theMode, false);
+ }
+ }
}
if (theList.size() > 0)
myDisplayer->updateViewer();
//! Move selected features to be after the current feature
void moveObjects();
+ //! Returns true if the object can be shaded. If the object is a compsolid result, the method
+ //! checks subobjects of the result
+ //! \return boolean value
+ bool canBeShaded(const ObjectPtr& theObject) const;
+
//! Returns true if there is at least one selected body/construction/group result
//! \return boolean value
bool canChangeColor() const;