: QWidget(theParent),
myParentId(theParentId),
myIsEditing(false),
- myState(Stored)
+ myState(Stored),
+ myIsValueStateBlocked(false)
{
myDefaultValue = theData->getProperty(ATTR_DEFAULT);
myUseReset = theData->getBooleanAttribute(ATTR_USE_RESET, true);
activateCustom();
}
+void ModuleBase_ModelWidget::deactivate()
+{
+ myIsValueStateBlocked = false;
+ myState = Stored;
+}
+
void ModuleBase_ModelWidget::initializeValueByActivate()
{
if (isComputedDefault()) {
return isDone;
}
-void ModuleBase_ModelWidget::setValueState(const ValueState& theState)
+ModuleBase_ModelWidget::ValueState ModuleBase_ModelWidget::setValueState(const ValueState& theState)
{
- if (myState == theState)
- return;
+ ValueState aState = myState;
+ if (myState != theState && !myIsValueStateBlocked) {
+ myState = theState;
+ emit valueStateChanged();
+ }
+ return aState;
+}
- myState = theState;
- emit valueStateChanged();
+bool ModuleBase_ModelWidget::blockValueState(const bool theBlocked)
+{
+ bool isBlocked = myIsValueStateBlocked;
+ myIsValueStateBlocked = theBlocked;
+ return isBlocked;
}
bool ModuleBase_ModelWidget::restoreValue()
//**************************************************************
void ModuleBase_ModelWidget::onWidgetValuesModified()
{
- setValueState(Modified);
+ setValueState(ModifiedInPP);
}
//**************************************************************
public:
/// State of the widget
enum ValueState { Stored, /// modification is finished and applyed to the model
- Modified, /// modification has not been finished and set to the model yet
- Reset };
+ ModifiedInPP, /// modification has not been finished and set to the model yet
+ ModifiedInViewer, /// modification performed by viewer events
+ Reset }; /// the value is reset
/// Constructor
/// \param theParent the parent object
void activate();
/// The method called when widget is deactivated
- virtual void deactivate() {}
+ virtual void deactivate();
/// Returns list of widget controls
/// \return a control list
}
/// Sets the current value state. If the value is changed, the signal is emitted
+ /// If the current value state is Blocked, this method do nothing
/// \param theState a new state
- void setValueState(const ValueState& theState);
+ /// \return the previous value state
+ ValueState setValueState(const ValueState& theState);
+
+ /// Blocks the value state change.
+ /// \param theBlocked a block state
+ /// \return the previous value
+ bool blockValueState(const bool theBlocked);
/// Compute the feature default value and fill the controls with it
/// or store the control value to the feature
/// the reset state. If it is false, the reset method of the widget is not performed
bool myUseReset;
+ /// blocked flag of modification of the value state
+ bool myIsValueStateBlocked;
};
#endif
//********************************************************************
void ModuleBase_WidgetSelector::deactivate()
{
+ ModuleBase_ModelWidget::deactivate();
disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
activateSelection(false);
activateFilters(false);
PartSet_WidgetShapeSelector.h
PartSet_WidgetFileSelector.h
PartSet_Filters.h
- PartSet_LockApplyMgr.h
PartSet_FilterInfinite.h
PartSet_SketcherMgr.h
PartSet_MenuMgr.h
PartSet_WidgetShapeSelector.cpp
PartSet_WidgetFileSelector.cpp
PartSet_Filters.cpp
- PartSet_LockApplyMgr.cpp
PartSet_FilterInfinite.cpp
PartSet_SketcherMgr.cpp
PartSet_MenuMgr.cpp
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File: PartSet_LockApplyMgr.cpp
-// Created: 25 Jun 2015
-// Author: Natalia Ermolaeva
-
-#include "PartSet_LockApplyMgr.h"
-#include "PartSet_Module.h"
-
-#include <ModuleBase_IWorkshop.h>
-#include <ModuleBase_IViewer.h>
-
-#include <XGUI_Workshop.h>
-#include <XGUI_ViewerProxy.h>
-#include <XGUI_ModuleConnector.h>
-#include <XGUI_OperationMgr.h>
-
-PartSet_LockApplyMgr::PartSet_LockApplyMgr(QObject* theParent,
- ModuleBase_IWorkshop* theWorkshop)
-: QObject(theParent), myWorkshop(theWorkshop)
-{
-}
-
-void PartSet_LockApplyMgr::activate()
-{
- XGUI_ViewerProxy* aViewer = dynamic_cast<XGUI_ViewerProxy*>(myWorkshop->viewer());
- connect(aViewer, SIGNAL(enterViewPort()), this, SLOT(onLockValidating()));
- connect(aViewer, SIGNAL(leaveViewPort()), this, SLOT(onUnlockValidating()));
-
- PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
- if (aModule->isMouseOverWindow())
- onLockValidating();
-}
-
-void PartSet_LockApplyMgr::deactivate()
-{
- XGUI_ViewerProxy* aViewer = dynamic_cast<XGUI_ViewerProxy*>(myWorkshop->viewer());
- disconnect(aViewer, SIGNAL(enterViewPort()), this, SLOT(onLockValidating()));
- disconnect(aViewer, SIGNAL(leaveViewPort()), this, SLOT(onUnlockValidating()));
-
- onUnlockValidating();
-}
-
-void PartSet_LockApplyMgr::valuesChanged()
-{
- operationMgr()->setLockValidating(false);
-}
-
-void PartSet_LockApplyMgr::onLockValidating()
-{
- XGUI_OperationMgr* anOperationMgr = operationMgr();
-
- anOperationMgr->setLockValidating(true);
- // the Ok button should be disabled in the property panel by moving the mouse point in the viewer
- // this leads that the user does not try to click Ok and it avoids an incorrect situation that the
- // line is moved to the cursor to the Ok button
- //anOperationMgr->setApplyEnabled(false);
-}
-
-void PartSet_LockApplyMgr::onUnlockValidating()
-{
- XGUI_OperationMgr* anOperationMgr = operationMgr();
-
- // it is important to restore the validity state in the property panel after leaving the
- // view port. Unlock the validating.
- if (anOperationMgr->isValidationLocked()) {
- anOperationMgr->setLockValidating(false);
- //anOperationMgr->onValidateOperation();
- }
-}
-
-XGUI_OperationMgr* PartSet_LockApplyMgr::operationMgr() const
-{
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
- XGUI_Workshop* aWorkshop = aConnector->workshop();
-
- return aWorkshop->operationMgr();
-}
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File: PartSet_LockApplyMgr.h
-// Created: 25 Jun 2015
-// Author: Natalia Ermolaeva
-
-#ifndef PartSet_LockApplyMgr_H
-#define PartSet_LockApplyMgr_H
-
-#include "PartSet.h"
-
-#include <QObject>
-
-class ModuleBase_IWorkshop;
-class XGUI_OperationMgr;
-
-/**
-* \ingroup Modules
-* Customosation of ModuleBase_WidgetShapeSelector in order to provide
-* working with sketch specific objects.
-*/
-class PARTSET_EXPORT PartSet_LockApplyMgr : public QObject
-{
- Q_OBJECT
-
-public:
- /// Constructor
- /// \param theParent a parent object
- /// \param theWorkshop a reference to workshop
- PartSet_LockApplyMgr(QObject* theParent,
- ModuleBase_IWorkshop* theWorkshop);
-
- virtual ~PartSet_LockApplyMgr() {}
-
- /// Activates the object
- void activate();
-
- /// Deactivates the object
- void deactivate();
-
- /// Unlocks validation in operations manager
- void valuesChanged();
-
-protected slots:
- /// Set lock validating in the operation manager. Set apply is disabled
- void onLockValidating();
-
- /// Set unlock validating in the operation manager. Call method to update the apply state.
- void onUnlockValidating();
-
-private:
- XGUI_OperationMgr* operationMgr() const;
-
-private:
- ModuleBase_IWorkshop* myWorkshop; // the current application workshop
-};
-
-#endif
\ No newline at end of file
QString PartSet_Module::getFeatureError(const FeaturePtr& theFeature)
{
QString anError = ModuleBase_IModule::getFeatureError(theFeature);
-
if (anError.isEmpty())
anError = sketchMgr()->getFeatureError(theFeature);
- if (anError.isEmpty()) {
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
- XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
-
- if (anOpMgr->isValidationLocked()) {
- ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
- (anOpMgr->currentOperation());
- if (!aFOperation || theFeature == aFOperation->feature())
- anError = "Validation is locked by the current operation";
- }
- }
return anError;
}
if (anAttr.get()) {
QString anAttributeName = anAttr->id().c_str();
switch (aState) {
- case ModuleBase_ModelWidget::Modified:
+ case ModuleBase_ModelWidget::ModifiedInPP:
anError = "Attribute \"" + anAttributeName +
"\" modification is not applyed. Please click \"Enter\" or \"Tab\".";
break;
+ case ModuleBase_ModelWidget::ModifiedInViewer:
+ anError = "Attribute \"" + anAttributeName +
+ "\" is locked by modification value in the viewer.";
+ break;
case ModuleBase_ModelWidget::Reset:
anError = "Attribute \"" + anAttributeName + "\" is not initialized.";
break;
#include "PartSet_WidgetPoint2d.h"
#include <PartSet_Tools.h>
#include <PartSet_Module.h>
-#include <PartSet_LockApplyMgr.h>
#include <ModuleBase_ParamSpinBox.h>
#include <ModuleBase_Tools.h>
<< SketchPlugin_Point::ID().c_str()
<< SketchPlugin_Circle::ID().c_str();
}
- myLockApplyMgr = new PartSet_LockApplyMgr(theParent, myWorkshop);
// the control should accept the focus, so the boolen flag is corrected to be true
myIsObligatory = true;
aModes << TopAbs_VERTEX;
aModes << TopAbs_EDGE;
myWorkshop->activateSubShapesSelection(aModes);
-
- myLockApplyMgr->activate();
}
void PartSet_WidgetPoint2D::deactivate()
{
+ ModuleBase_ModelWidget::deactivate();
ModuleBase_IViewer* aViewer = myWorkshop->viewer();
disconnect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
myWorkshop->deactivateSubShapesSelection();
-
- myLockApplyMgr->deactivate();
}
bool PartSet_WidgetPoint2D::getPoint2d(const Handle(V3d_View)& theView,
double aX, anY;
PartSet_Tools::convertTo2D(aPoint, mySketch, theWnd->v3dView(), aX, anY);
+ // we need to block the value state change
+ bool isBlocked = blockValueState(true);
setPoint(aX, anY);
+ blockValueState(isBlocked);
+ setValueState(ModifiedInViewer);
}
double PartSet_WidgetPoint2D::x() const
void PartSet_WidgetPoint2D::onValuesChanged()
{
- myLockApplyMgr->valuesChanged();
emit valuesChanged();
}
class ModuleBase_IViewWindow;
class GeomAPI_Pnt2d;
class ModuleBase_IWorkshop;
-class PartSet_LockApplyMgr;
class QGroupBox;
class QMouseEvent;
void setConstraintWith(const ObjectPtr& theObject);
ModuleBase_IWorkshop* myWorkshop;
- PartSet_LockApplyMgr* myLockApplyMgr; ///< a manager to lock/unlock Apply button in PP
QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets
ModuleBase_ParamSpinBox* myXSpin; ///< the spin box for the X coordinate
#include "PartSet_WidgetPoint2dDistance.h"
#include "PartSet_Tools.h"
-#include "PartSet_LockApplyMgr.h"
#include <ModuleBase_ParamSpinBox.h>
#include <ModuleBase_IWorkshop.h>
const std::string& theParentId)
: ModuleBase_WidgetDoubleValue(theParent, theData, theParentId), myWorkshop(theWorkshop)
{
- myLockApplyMgr = new PartSet_LockApplyMgr(theParent, myWorkshop);
-
myFirstPntName = theData->getProperty("first_point");
// Reconnect to local slot
this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)),
this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
-
- myLockApplyMgr->activate();
}
void PartSet_WidgetPoint2dDistance::deactivate()
{
+ ModuleBase_ModelWidget::deactivate();
ModuleBase_IViewer* aViewer = myWorkshop->viewer();
disconnect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
disconnect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)),
this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
-
- myLockApplyMgr->deactivate();
}
void PartSet_WidgetPoint2dDistance::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
PartSet_Tools::convertTo2D(aPoint, mySketch, theWnd->v3dView(), aX, aY);
std::shared_ptr<GeomAPI_Pnt2d> aPnt = std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, aY));
+ bool isBlocked = blockValueState(true);
setPoint(feature(), aPnt);
+ blockValueState(isBlocked);
+ setValueState(ModifiedInViewer);
}
void PartSet_WidgetPoint2dDistance::onValuesChanged()
{
- myLockApplyMgr->valuesChanged();
emit valuesChanged();
}
#include <ModelAPI_CompositeFeature.h>
-class PartSet_LockApplyMgr;
class GeomAPI_Pnt2d;
class ModuleBase_IWorkshop;
class ModuleBase_IViewWindow;
/// A reference to workshop
ModuleBase_IWorkshop* myWorkshop;
- /// A manager to lock/unlock Apply button in PP
- PartSet_LockApplyMgr* myLockApplyMgr;
-
/// A name of the first point
std::string myFirstPntName;
void PartSet_WidgetSketchLabel::deactivate()
{
+ ModuleBase_ModelWidget::deactivate();
erasePreviewPlanes();
activateSelection(false);
XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent,
ModuleBase_IWorkshop* theWorkshop)
-: QObject(theParent), myIsValidationLock(false), myIsApplyEnabled(false),
- myWorkshop(theWorkshop)
+: QObject(theParent), myIsApplyEnabled(false), myWorkshop(theWorkshop)
{
}
setApplyEnabled(myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty());
}
-void XGUI_OperationMgr::setLockValidating(bool toLock)
-{
- myIsValidationLock = toLock;
- onValidateOperation();
-}
-
void XGUI_OperationMgr::setApplyEnabled(const bool theEnabled)
{
myIsApplyEnabled = theEnabled;
/// \param theOperation an aborted operation
void abortOperation(ModuleBase_Operation* theOperation);
- /// Blocking/unblocking enabling of Ok button in property panel.
- /// It is used when operation can not be validated even all attributes are valid
- void setLockValidating(bool toLock);
-
- /// Returns state of validation locking
- bool isValidationLocked() const { return myIsValidationLock; }
-
/// Returns enable apply state
/// \return theEnabled a boolean value
bool isApplyEnabled() const;
/// Current workshop
ModuleBase_IWorkshop* myWorkshop;
-
- /// Lock/Unlock access to Ok button in property panel
- bool myIsValidationLock;
/// Lock/Unlock access to Ok button in property panel
bool myIsApplyEnabled;
};
if (aPanel)
anActiveWidget = aPanel->activeWidget();
}
- if (anActiveWidget && anActiveWidget->getValueState() != ModuleBase_ModelWidget::Stored)
+ if (anActiveWidget)
operationMgr()->onValidateOperation();
}