static Events_Loop* aLoop = Events_Loop::loop();
static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
- if (field()) {
- aECreator->sendUpdated(field()->step(id()), EVENT_DISP); // updated pointer to this
+ ModelAPI_ResultField* aField = field();
+ if (aField) {
+ aECreator->sendUpdated(aField->step(id()), EVENT_DISP); // updated pointer to this
+ if (myIsDisplayed) {
+ for (int i = 0; i < aField->stepsSize(); i++)
+ if (i != id())
+ aField->step(i)->setDisplayed(false);
+ aField->setDisplayed(false);
+ }
}
}
}
+
+
+void ModelAPI_ResultField::setDisplayed(const bool theDisplay)
+{
+ ModelAPI_Result::setDisplayed(theDisplay);
+ if (isDisplayed()) {
+ for (int i = 0; i < stepsSize(); i++)
+ step(i)->setDisplayed(false);
+ }
+}
/// \param theId an id of the object
virtual std::shared_ptr<ModelAPI_ResultField::ModelAPI_FieldStep> step(int theId) const = 0;
+ /// Sets the displayed/hidden state of the object. If it is changed, sends the "redisplay"
+ /// signal.
+ MODELAPI_EXPORT virtual void setDisplayed(const bool theDisplay);
+
/// To refresh the steps of a field
MODELAPI_EXPORT virtual void updateSteps() = 0;
};
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_AttributeString.h>
#include <ModelAPI_Expression.h>
+#include <ModelAPI_ResultField.h>
#include <Events_Loop.h>
#include <ModelAPI_Data.h>
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(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);
- hasResult |= (aResult.get() != NULL);
+ hasResult |= ((aResult.get() != NULL) || (aStep.get() != NULL));
hasFeature |= (aFeature.get() != NULL);
hasFolder |= (aFolder.get() != NULL);
hasParameter |= (aConstruction.get() != NULL);
#include <ModelAPI_ResultField.h>
#include <ModelAPI_Folder.h>
#include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_ResultField.h>
#include <Config_DataModelReader.h>
foreach(ModuleBase_ViewerPrsPtr aPrs, aPrsList) {
aObject = aPrs->object();
GeomShapePtr aShape = aPrs->shape();
- ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
- if (aRes && aRes->isDisplayed()) {
+ if (aObject->isDisplayed()) {
isVisible = true;
canBeShaded = myWorkshop->displayer()->canBeShaded(aObject);
isShading =
aList.append(action("DELETE_CMD"));
myObjBrowserMenus[ModelAPI_Folder::group()] = aList;
+ //---------------------------------------
+ // Step objects menu
+ aList.clear();
+ aList.append(action("SHOW_CMD"));
+ aList.append(action("HIDE_CMD"));
+ aList.append(action("SHOW_ONLY_CMD"));
+ myObjBrowserMenus[ModelAPI_ResultField::ModelAPI_FieldStep::group()] = aList;
}
void XGUI_ContextMenuMgr::buildViewerMenu()
myViewerMenu[ModelAPI_ResultGroup::group()] = aList;
myViewerMenu[ModelAPI_ResultField::group()] = aList;
//-------------------------------------
+ // Step objects menu
+ aList.clear();
+ aList.append(action("HIDE_CMD"));
+ myViewerMenu[ModelAPI_ResultField::ModelAPI_FieldStep::group()] = aList;
}
void XGUI_DataTree::processEyeClick(const QModelIndex& theIndex)
{
- static Events_Loop* aLoop = Events_Loop::loop();
- static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
- static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
-
+ XGUI_ObjectsBrowser* aObjBrowser = qobject_cast<XGUI_ObjectsBrowser*>(parent());
XGUI_DataModel* aModel = dataModel();
ObjectPtr aObj = aModel->object(theIndex);
if (aObj.get()) {
- XGUI_ObjectsBrowser* aObjBrowser = qobject_cast<XGUI_ObjectsBrowser*>(parent());
- ResultFieldPtr aField = std::dynamic_pointer_cast<ModelAPI_ResultField>(aObj);
- if (aField.get()) {
- bool toDisplay = !aField->isDisplayed();
- aField->setDisplayed(toDisplay);
- if (toDisplay) {
- for (int i = 0; i < aField->stepsSize(); i++) {
- aField->step(i)->setDisplayed(false);
- }
- }
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
- }
- else {
- FieldStepPtr aStep =
- std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(aObj);
- if (aStep.get()) {
- // Only one step from a field can be visible at once
- bool toDisplay = !aStep->isDisplayed();
- if (toDisplay) {
- int aId = aStep->id();
- ModelAPI_ResultField* aField = aStep->field();
- aField->setDisplayed(false);
- for (int i = 0; i < aField->stepsSize(); i++) {
- aField->step(i)->setDisplayed(i == aId);
- }
- }
- else {
- aStep->setDisplayed(false);
- aECreator->sendUpdated(aStep, EVENT_DISP);
- }
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
- }
- else {
- ResultPtr aResObj = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
- if (aResObj.get()) {
- std::set<ObjectPtr> anObjects;
- anObjects.insert(aResObj);
-
- bool hasHiddenState = aModel->hasHiddenState(theIndex);
- if (aObjBrowser && hasHiddenState && !aObjBrowser->workshop()->prepareForDisplay(anObjects))
- return;
- if (hasHiddenState) { // #issue 2335(hide all faces then show solid problem)
- if (aResObj->isDisplayed())
- aResObj->setDisplayed(false);
- aResObj->setDisplayed(true);
- }
- else
- aResObj->setDisplayed(!aResObj->isDisplayed());
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
- }
- }
+ std::set<ObjectPtr> anObjects;
+ anObjects.insert(aObj);
+
+ bool hasHiddenState = aModel->hasHiddenState(theIndex);
+ if (aObjBrowser && hasHiddenState && !aObjBrowser->workshop()->prepareForDisplay(anObjects))
+ return;
+ if (hasHiddenState) { // #issue 2335(hide all faces then show solid problem)
+ if (aObj->isDisplayed())
+ aObj->setDisplayed(false);
+ aObj->setDisplayed(true);
}
+ else
+ aObj->setDisplayed(!aObj->isDisplayed());
+
// Update list of selected objects because this event happens after
// selection event in object browser
if (aObjBrowser) {
aObjBrowser->onSelectionChanged();
}
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
update(theIndex);
}
}
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
}
-//**************************************************************
-#define SET_DISPLAY_GROUP(aGroupName, aDisplay) \
-for (int i = 0; i < aDoc->size(aGroupName); i++) { \
- aDoc->object(aGroupName, i)->setDisplayed(aDisplay); \
-}
//******************************************************
void XGUI_Workshop::showObjects(const QObjectPtrList& theList, bool isVisible)