/// \param theObj is object for moving
static void moveObject(ObjectPtr theObj);
+ /// Sends a message about block/unblock viewer updating
+ /// \param theValue a boolean value
+ static void blockUpdateViewer(const bool theValue);
+
signals:
/// The signal about widget values are to be changed
void beforeValuesChanged();
/// The method called when widget is activated
virtual void activateCustom() {};
- /// Sends a message about block/unblock viewer updating
- /// \param theValue a boolean value
- static void blockUpdateViewer(const bool theValue);
-
protected slots:
/// Processing of values changed in model widget by store the current value to the feature
void onWidgetValuesChanged();
ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
if (!anActiveWidget || !anActiveWidget->isViewerSelector()) {
+
+ // block of viewer update
+ // we need to block update content of the viewer because of Sketch Point feature
+ // in activate() the value of the point is initialized and it can be displayed
+ // but the default value is [0, 0]. So, we block update viewer contentent until
+ // onMouseRelease happens, which correct the point position
+ ModuleBase_ModelWidget::blockUpdateViewer(true);
+
restartOperation();
aProcessed = true;
if (aPoint2DWdg && aPoint2DWdg == aFirstWidget) {
aPoint2DWdg->onMouseRelease(theWnd, theEvent);
}
+ // unblock viewer update
+ ModuleBase_ModelWidget::blockUpdateViewer(false);
}
}
}
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);
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;
}
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;
}
}
void removeFilters();
/// Sets a flag to the displayer whether the internal viewer can be updated by
- /// the updateViewer method call. If it is not enabled, this method do nothing
+ /// the updateViewer method call. If it is not enabled, this method do nothing.
+ /// This state maintain recurse, if the update is blocked twice or three times, the
+ /// viewer will not be updated until it is unblocked necessary times(twice or three in the example).
/// \param isEnabled a boolean value
bool enableUpdateViewer(const bool isEnabled);
- /// Returns myEnableUpdateViewer flag
- bool isUpdateEnabled() const { return myEnableUpdateViewer; }
+ /// Returns true if the viewer update is not blocked
+ bool isUpdateEnabled() const;
/// Updates the viewer
void updateViewer() const;
/// Selection modes installed for external objects in local context
QIntList myActiveSelectionModes;
- /// the enable update viewer flag
- bool myEnableUpdateViewer;
+ /// Number of blocking of the viewer update. The viewer is updated only if it equals zero
+ int myViewerBlockedRecursiveCount;
// Flag: use trihedgon for selection or not
bool myIsTrihedronActive;