}
XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop)
- : myWorkshop(theWorkshop), myEnableUpdateViewer(true), myNeedUpdate(false),
- myIsTrihedronActive(false)
+ : myWorkshop(theWorkshop), myNeedUpdate(false),
+ myIsTrihedronActive(false), myViewerBlockedRecursiveCount(0)
{
- enableUpdateViewer(true);
myCustomPrs = std::shared_ptr<GeomAPI_ICustomPrs>(new XGUI_CustomPrs(theWorkshop));
}
Handle(AIS_InteractiveObject) anAIS = anObject->impl<Handle(AIS_InteractiveObject)>();
if (!anAIS.IsNull()) {
emit beforeObjectErase(theObject, anObject);
- aContext->Remove(anAIS, theUpdateViewer);
+ aContext->Remove(anAIS, false/*update viewer*/);
aErased = true;
}
}
qDebug(QString("erase object: %1").arg(aPtrStr.str().c_str()).toStdString().c_str());
qDebug(getResult2AISObjectMapInfo().c_str());
#endif
+
+ if (theUpdateViewer)
+ updateViewer();
+
return aErased;
}
arg(!isEqualShapes || isCustomized).arg(isEqualShapes).arg(isCustomized).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();
+
aContext->Redisplay(aAISIO, false);
+
+ if (aNeedToRestoreSelection)
+ myWorkshop->module()->restoreSelection();
+
aRedisplayed = true;
#ifdef DEBUG_FEATURE_REDISPLAY
qDebug(" Redisplay happens");
AIS_Shape::SelectionMode((TopAbs_ShapeEnum)theShapeType);
}
+bool XGUI_Displayer::isVisible(XGUI_Displayer* theDisplayer, const ObjectPtr& theObject)
+{
+ bool aVisible = false;
+ GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (aPrs.get() || aResult.get()) {
+ aVisible = theDisplayer->isVisible(theObject);
+ // compsolid is not visualized in the viewer, but should have presentation when all sub solids are
+ // visible. It is useful for highlight presentation where compsolid shape is selectable
+ if (!aVisible && aResult.get() && aResult->groupName() == ModelAPI_ResultCompSolid::group()) {
+ ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
+ if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
+ bool anAllSubsVisible = aCompsolidResult->numberOfSubs() > 0;
+ for(int i = 0; i < aCompsolidResult->numberOfSubs() && anAllSubsVisible; i++) {
+ anAllSubsVisible = theDisplayer->isVisible(aCompsolidResult->subResult(i));
+ }
+ aVisible = anAllSubsVisible;
+ }
+ }
+ }
+ else {
+ // check if all results of the feature are visible
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+ std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr>::const_iterator aIt;
+ aVisible = !aResults.empty();
+ for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+ aVisible = aVisible && theDisplayer->isVisible(*aIt);
+ }
+ }
+ return aVisible;
+}
+
+
void XGUI_Displayer::activateObjects(const QIntList& theModes, const QObjectPtrList& theObjList,
const bool theUpdateViewer)
{
Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
if (!anIO.IsNull()) {
emit beforeObjectErase(aObj, aAISObj);
- aContext->Remove(anIO, false);
+ aContext->Remove(anIO, false/*update viewer*/);
aErased = true;
}
}
bool XGUI_Displayer::enableUpdateViewer(const bool isEnabled)
{
- bool aWasEnabled = myEnableUpdateViewer;
+ bool aWasEnabled = isUpdateEnabled();
+ if (isEnabled)
+ myViewerBlockedRecursiveCount--;
+ else
+ myViewerBlockedRecursiveCount++;
- myEnableUpdateViewer = isEnabled;
- if (myNeedUpdate && myEnableUpdateViewer) {
+ if (myNeedUpdate && isUpdateEnabled()) {
updateViewer();
myNeedUpdate = false;
}
return aWasEnabled;
}
+bool XGUI_Displayer::isUpdateEnabled() const
+{
+ return myViewerBlockedRecursiveCount == 0;
+}
+
void XGUI_Displayer::updateViewer() const
{
Handle(AIS_InteractiveContext) aContext = AISContext();
- if (!aContext.IsNull() && myEnableUpdateViewer) {
+ if (!aContext.IsNull() && isUpdateEnabled()) {
myWorkshop->viewer()->Zfitall();
aContext->UpdateCurrentViewer();
} else {
{
Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
if (!aContext.IsNull()) {
- aContext->Activate(theIO, theMode, theUpdateViewer);
+ aContext->Activate(theIO, theMode, false);
#ifdef DEBUG_ACTIVATE_AIS
ObjectPtr anObject = getObject(theIO);
anInfo.append(ModuleBase_Tools::objectInfo((*anIt)));
qDebug(QString("activateAIS: theMode = %1, object = %2").arg(theMode).arg(anInfo).toStdString().c_str());
#endif
+ if (theUpdateViewer)
+ updateViewer();
}
}
Handle(AIS_InteractiveContext) aContext = AISContext();
Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
if (!aContext.IsNull() && !anAISIO.IsNull()) {
- aContext->Display(anAISIO, 0/*wireframe*/, 0, theUpdateViewer, true, AIS_DS_Displayed);
+ aContext->Display(anAISIO, 0/*wireframe*/, 0, false/*update viewer*/, true, AIS_DS_Displayed);
aDisplayed = true;
aContext->Deactivate(anAISIO);
aContext->Load(anAISIO);
}
}
}
+ if (theUpdateViewer)
+ updateViewer();
}
return aDisplayed;
}
if (!aContext.IsNull()) {
Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
if (!anAISIO.IsNull() && aContext->IsDisplayed(anAISIO)) {
- aContext->Remove(anAISIO, theUpdateViewer);
+ aContext->Remove(anAISIO, false/*update viewer*/);
aErased = true;
}
}
+ if (aErased && theUpdateViewer)
+ updateViewer();
return aErased;
}