return !aFOperation || !aFOperation->hasObject(theObject);
}
-void ModuleBase_IModule::onOperationResumed(ModuleBase_Operation* theOperation)
+void ModuleBase_IModule::operationResumed(ModuleBase_Operation* theOperation)
{
- emit operationResumed(theOperation);
+ emit resumed(theOperation);
}
\r
/// Realizes some functionality by an operation start\r
/// \param theOperation a started operation\r
- virtual void onOperationStarted(ModuleBase_Operation* theOperation) {}\r
+ virtual void operationStarted(ModuleBase_Operation* theOperation) {}\r
\r
/// Realizes some functionality by an operation resume\r
/// By default it emits operationResumed signal\r
/// \param theOperation a resumed operation\r
- virtual void onOperationResumed(ModuleBase_Operation* theOperation);\r
+ virtual void operationResumed(ModuleBase_Operation* theOperation);\r
\r
/// Realizes some functionality by an operation stop\r
- virtual void onOperationStopped(ModuleBase_Operation* theOperation) {}\r
+ virtual void operationStopped(ModuleBase_Operation* theOperation) {}\r
\r
/// Realizes some functionality by an operation commit\r
- virtual void onOperationCommitted(ModuleBase_Operation* theOperation) {}\r
+ virtual void operationCommitted(ModuleBase_Operation* theOperation) {}\r
\r
/// Realizes some functionality by an operation abort\r
- virtual void onOperationAborted(ModuleBase_Operation* theOperation) {}\r
+ virtual void operationAborted(ModuleBase_Operation* theOperation) {}\r
\r
/// Realizes some functionality by an operation start\r
virtual ModuleBase_Operation* currentOperation() const = 0;\r
\r
/// Segnal emitted when an operation is resumed\r
/// \param theOp a resumed operation\r
- void operationResumed(ModuleBase_Operation* theOp);\r
+ void resumed(ModuleBase_Operation* theOp);\r
\r
public slots:\r
/// Called on call of command corresponded to a feature\r
const std::string& theParentId)
: QWidget(theParent),
myParentId(theParentId),
- myIsEditing(false)
+ myIsEditing(false),
+ myState(Stored)
{
myDefaultValue = theData->getProperty(ATTR_DEFAULT);
myUseReset = theData->getBooleanAttribute(ATTR_USE_RESET, true);
myIsObligatory = theData->getBooleanAttribute(ATTR_OBLIGATORY, true);
connect(this, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
+ connect(this, SIGNAL(valuesModified()), this, SLOT(onWidgetValuesModified()));
}
bool ModuleBase_ModelWidget::isInitialized(ObjectPtr theObject) const
bool ModuleBase_ModelWidget::storeValue()
{
+ setValueState(Stored);
+
emit beforeValuesChanged();
bool isDone = storeValueCustom();
emit afterValuesChanged();
return isDone;
}
+void ModuleBase_ModelWidget::setValueState(const ValueState& theState)
+{
+ if (myState == theState)
+ return;
+
+ myState = theState;
+ emit valueStateChanged();
+}
+
bool ModuleBase_ModelWidget::restoreValue()
{
emit beforeValuesRestored();
storeValue();
}
+//**************************************************************
+void ModuleBase_ModelWidget::onWidgetValuesModified()
+{
+ setValueState(Modified);
+}
+
//**************************************************************
void ModuleBase_ModelWidget::blockUpdateViewer(const bool theValue)
{
{
Q_OBJECT
public:
- /// Constructor
+ /// 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
+ };
+
+ /// Constructor
/// \param theParent the parent object
/// \param theData the widget configuration. The attribute of the model widget is obtained from
/// \param theParentId is Id of a parent of the current attribute
/// \return the boolean result
bool isUseReset() const { return myUseReset; }
+ /// Returns this widget value state
+ /// \return the enumeration result
+ ValueState getValueState() const { return myState; }
+
/// Defines if it is supposed that the widget should interact with the viewer.
virtual bool isViewerSelector() { return false; }
/// \param theWidget the model base widget
void focusOutWidget(ModuleBase_ModelWidget* theWidget);
+ /// The signal about value state modification
+ void valueStateChanged();
+
protected:
/// Sets default value of widget. Normally, widget should fetch this value
/// from the xml. However, some widgets derived widgets could define it
myAttributeID = theAttribute;
}
+ /// Sets the current value state. If the value is changed, the signal is emitted
+ /// \param theState a new state
+ void setValueState(const ValueState& theState);
+
/// Saves the internal parameters to the given feature. Emits signals before and after store
/// \return True in success
bool storeValue();
/// Processing of values changed in model widget by store the current value to the feature
void onWidgetValuesChanged();
+ /// Changes widget state.
+ void onWidgetValuesModified();
+
protected:
/// The attribute name of the model feature
/// The non-obligatory widgets should not accept the focus in the property panel
bool myIsObligatory;
+ /// The widget value state
+ ValueState myState;
+
private:
/// Value should be computed on execute, like radius for circle's constraint (can not be zero)
bool myIsComputedDefault;
Config_Prop::Integer, SKETCH_WIDTH);
}
-void PartSet_Module::onOperationCommitted(ModuleBase_Operation* theOperation)
+void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation)
{
if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
mySketchMgr->commitNestedSketch(theOperation);
myRestartingMode = RM_None;
}
-void PartSet_Module::onOperationAborted(ModuleBase_Operation* theOperation)
+void PartSet_Module::operationAborted(ModuleBase_Operation* theOperation)
{
breakOperationSequence();
}
-void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
+void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
{
if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
mySketchMgr->startSketch(theOperation);
myCustomPrs->activate(aFOperation->feature(), true);
}
-void PartSet_Module::onOperationResumed(ModuleBase_Operation* theOperation)
+void PartSet_Module::operationResumed(ModuleBase_Operation* theOperation)
{
- ModuleBase_IModule::onOperationResumed(theOperation);
+ ModuleBase_IModule::operationResumed(theOperation);
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
if (aFOperation)
myCustomPrs->activate(aFOperation->feature(), true);
}
-void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
+void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
{
bool isModified = myCustomPrs->deactivate(false);
/// Displays all sketcher sub-Objects, hides sketcher result, appends selection filters
/// Activate the operation presentation
/// \param theOperation a started operation
- virtual void onOperationStarted(ModuleBase_Operation* theOperation);
+ virtual void operationStarted(ModuleBase_Operation* theOperation);
/// Realizes some functionality by an operation resume
/// Activate the operation presentation
/// \param theOperation a resumed operation
- virtual void onOperationResumed(ModuleBase_Operation* theOperation);
+ virtual void operationResumed(ModuleBase_Operation* theOperation);
/// Realizes some functionality by an operation commit
/// Restarts sketcher operation automatically of it is necessary
/// \param theOperation a committed operation
- virtual void onOperationCommitted(ModuleBase_Operation* theOperation);
+ virtual void operationCommitted(ModuleBase_Operation* theOperation);
/// Realizes some functionality by an operation abort
/// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
/// \param theOperation an aborted operation
- virtual void onOperationAborted(ModuleBase_Operation* theOperation);
+ virtual void operationAborted(ModuleBase_Operation* theOperation);
/// Realizes some functionality by an operation stop
/// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
/// \param theOperation a stopped operation
- virtual void onOperationStopped(ModuleBase_Operation* theOperation);
+ virtual void operationStopped(ModuleBase_Operation* theOperation);
/// Returns current operation
virtual ModuleBase_Operation* currentOperation() const;
PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule)
: QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false),
- myIsResetCurrentValue(false), myIsCurrentValueUnderModification(false), myIsMouseOverWindow(false),
+ myIsResetCurrentValue(false), myIsMouseOverWindow(false),
myIsMouseOverViewProcessed(true), myPreviousUpdateViewerEnabled(true),
myIsPopupMenuActive(false), myIsConstraintsShown(true)
{
// redisplayed before this update, the feature presentation jumps from reset value to current.
myIsMouseOverWindow = true;
myIsResetCurrentValue = false;
- myIsCurrentValueUnderModification = false;
+ //myIsCurrentValueUnderModification = false;
// it is important to validate operation here only if sketch entity create operation is active
// because at this operation we reacts to the mouse leave/enter view port
//operationMgr()->onValidateOperation();
// disable the viewer update in order to avoid visualization of redisplayed feature in viewer
// obtained after reset value
bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
- ModuleBase_Operation* aOperation = getCurrentOperation();
- ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
- ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget();
- if (aActiveWgt && aActiveWgt->reset()) {
+ ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
+ if (anActiveWidget && anActiveWidget->reset()) {
myIsResetCurrentValue = true;
}
aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
}
}
-void PartSet_SketcherMgr::onValuesModied()
+void PartSet_SketcherMgr::onValueStateChanged()
{
- myIsCurrentValueUnderModification = true;
+ ///myIsCurrentValueUnderModification = true;
// update Apply enable state
//myIsResetCurrentValue = false;
//if (!isNestedCreateOperation(getCurrentOperation()))
// return;
- operationMgr()->onValidateOperation();
+
+ ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
+ if (anActiveWidget && anActiveWidget->getValueState() != ModuleBase_ModelWidget::Stored)
+ operationMgr()->onValidateOperation();
}
void PartSet_SketcherMgr::onBeforeValuesChangedInPropertyPanel()
{
myIsResetCurrentValue = false;
- myIsCurrentValueUnderModification = false;
+ //myIsCurrentValueUnderModification = false;
if (isNestedCreateOperation(getCurrentOperation()))
return;
return;
if (aFOperation->isEditOperation()) {
- ModuleBase_IPropertyPanel* aPanel = aFOperation->propertyPanel();
- ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget();
// If the current widget is a selector, do nothing, it processes the mouse press
- if(aActiveWgt && aActiveWgt->isViewerSelector()) {
+ ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
+ if(anActiveWidget && anActiveWidget->isViewerSelector()) {
return;
}
}
if (isNestedCreateOperation(getCurrentOperation()) && !myIsMouseOverViewProcessed) {
myIsMouseOverViewProcessed = true;
// 1. perform the widget mouse move functionality and display the presentation
- ModuleBase_Operation* aOperation = getCurrentOperation();
- ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
- ModuleBase_ModelWidget* anActiveWdg = aPanel->activeWidget();
// the mouse move should be processed in the widget, if it can in order to visualize correct
// presentation. These widgets correct the feature attribute according to the mouse position
- PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(anActiveWdg);
+ ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
+ PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(anActiveWidget);
if (aPoint2DWdg) {
aPoint2DWdg->onMouseMove(theWnd, theEvent);
}
PartSet_WidgetPoint2dDistance* aDistanceWdg = dynamic_cast<PartSet_WidgetPoint2dDistance*>
- (anActiveWdg);
+ (anActiveWidget);
if (aDistanceWdg) {
aDistanceWdg->onMouseMove(theWnd, theEvent);
}
AttributeStringPtr aAttributeString = aSketch->string(SketchPlugin_Sketch::SOLVER_ERROR());
anError = aAttributeString->value().c_str();
}
- else if (myIsResetCurrentValue || myIsCurrentValueUnderModification) {
+ else if (myIsResetCurrentValue /*|| myIsCurrentValueUnderModification*/) {
// this flags do not allow commit of the current operation
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
(getCurrentOperation());
FeaturePtr aFeature = aFOperation->feature();
if (aFeature.get() && aFeature == theFeature && isNestedCreateOperation(aFOperation)) {
QString anAttributeName = "";
- ModuleBase_IPropertyPanel* aPanel = aFOperation->propertyPanel();
- ModuleBase_ModelWidget* anActiveWgt = aPanel->activeWidget();
- if (anActiveWgt) {
- AttributePtr anAttr = aFeature->attribute(anActiveWgt->attributeID());
+ ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
+ if (anActiveWidget) {
+ AttributePtr anAttr = aFeature->attribute(anActiveWidget->attributeID());
if (anAttr.get())
anAttributeName = anAttr->id().c_str();
}
if (myIsResetCurrentValue)
anError = "Attribute \"" + anAttributeName + "\" is not initialized.";
- else if (myIsCurrentValueUnderModification) {
- anError = "Attribute \"" + anAttributeName + "\" modification is not applyed. Please click \"Enter\" or \"Tab\".";
- }
+ //else if (myIsCurrentValueUnderModification) {
+ // anError = "Attribute \"" + anAttributeName + "\" modification is not applyed. Please click \"Enter\" or \"Tab\".";
+ //}
+ }
+ }
+ }
+ else {
+ ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
+ if (anActiveWidget && anActiveWidget->getValueState() != ModuleBase_ModelWidget::Stored) {
+ AttributePtr anAttr = anActiveWidget->feature()->attribute(anActiveWidget->attributeID());
+ if (anAttr.get()) {
+ QString anAttributeName = anAttr->id().c_str();
+ anError = "Attribute \"" + anAttributeName + "\" modification is not applyed. Please click \"Enter\" or \"Tab\".";
}
}
}
{
connectToPropertyPanel(false);
myIsResetCurrentValue = false;
- myIsCurrentValueUnderModification = false;
+ //myIsCurrentValueUnderModification = false;
myIsMouseOverViewProcessed = true;
operationMgr()->onValidateOperation();
if (isNestedCreateOperation(theOp))
// c. widget editor control
#ifndef DEBUG_DO_NOT_BY_ENTER
if (aCanDisplay && isNestedCreateOperation(getCurrentOperation())) {
- ModuleBase_Operation* aOperation = getCurrentOperation();
- ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
- ModuleBase_ModelWidget* anActiveWdg = aPanel ? aPanel->activeWidget() : 0;
- ModuleBase_WidgetEditor* anEditorWdg = anActiveWdg ? dynamic_cast<ModuleBase_WidgetEditor*>(anActiveWdg) : 0;
+ ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
+ ModuleBase_WidgetEditor* anEditorWdg = anActiveWidget ? dynamic_cast<ModuleBase_WidgetEditor*>(anActiveWidget) : 0;
// the active widget editor should not influence here. The presentation should be visible always
// when this widget is active.
if (!anEditorWdg && !myIsPopupMenuActive) {
bool PartSet_SketcherMgr::canDisplayCurrentCreatedFeature() const
{
- return myIsMouseOverWindow || (!myIsResetCurrentValue && !myIsCurrentValueUnderModification);
+ bool aCanDisplay = myIsMouseOverWindow;
+ if (!aCanDisplay) {
+ ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
+ bool isValueStored = anActiveWidget && anActiveWidget->getValueState() == ModuleBase_ModelWidget::Stored;
+ aCanDisplay = !myIsResetCurrentValue && isValueStored;
+ }
+ return aCanDisplay;
+ //return myIsMouseOverWindow || (!myIsResetCurrentValue && !myIsCurrentValueUnderModification);
#ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS
qDebug(QString("canDisplayCurrentCreatedFeature: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str());
#endif
if (isToConnect) {
connect(aWidget, SIGNAL(beforeValuesChanged()),
this, SLOT(onBeforeValuesChangedInPropertyPanel()));
- connect(aWidget, SIGNAL(valuesModified()),
- this, SLOT(onValuesModied()));
+ connect(aWidget, SIGNAL(valueStateChanged()),
+ this, SLOT(onValueStateChanged()));
connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
connect(aWidget, SIGNAL(afterValuesChanged()),
this, SLOT(onAfterValuesChangedInPropertyPanel()));
return myModule->workshop()->currentOperation();
}
+//**************************************************************
+ModuleBase_ModelWidget* PartSet_SketcherMgr::getActiveWidget() const
+{
+ ModuleBase_ModelWidget* aWidget = 0;
+ ModuleBase_Operation* anOperation = getCurrentOperation();
+ if (anOperation) {
+ ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
+ if (aPanel)
+ aWidget = aPanel->activeWidget();
+ }
+ return aWidget;
+}
+
void PartSet_SketcherMgr::visualizeFeature(const FeaturePtr& theFeature,
const bool isEditOperation,
const bool isToDisplay,
/// a nested sketch feature, it hides the feature in the viewer
void onLeaveViewPort();
- /// Updates the flag of reset state
- void onValuesModied();
+ /// Validates the operation. Apply button is disabled if the widget value is in Modified state
+ void onValueStateChanged();
/// Listens to the value changed signal and display the current operation feature
void onBeforeValuesChangedInPropertyPanel();
/// Listens to the signal about values are to be changed in the property panel
/// \return an operation
ModuleBase_Operation* getCurrentOperation() const;
+ /// Get the active widget in the property panel
+ ModuleBase_ModelWidget* getActiveWidget() const;
+
/// Erase or display the feature of the current operation. If the mouse over the active view or
/// a current value is changed by property panel, the feature is displayed otherwise it is hidden
/// \param theOperation an operation which feature is to be displayed, it is nested create operation
bool myIsDragging;
bool myDragDone;
bool myIsResetCurrentValue; /// the state that value in the property panel is reset
- bool myIsCurrentValueUnderModification; /// the value is modified in PP but it is not applyed in the model
+ //bool myIsCurrentValueUnderModification; /// the value is modified in PP but it is not applyed in the model
bool myIsMouseOverWindow; /// the state that the mouse over the view
bool myIsMouseOverViewProcessed; /// the state whether the over view state is processed by mouseMove method
bool myIsPopupMenuActive; /// the state of the popup menu is shown
if (aCompFeature->numberOfSubs() == 0)
return ModuleBase_ModelWidget::focusTo();
- connect(myModule, SIGNAL(operationResumed(ModuleBase_Operation*)), SLOT(onResumed(ModuleBase_Operation*)));
+ connect(myModule, SIGNAL(resumed(ModuleBase_Operation*)), SLOT(onResumed(ModuleBase_Operation*)));
SessionPtr aMgr = ModelAPI_Session::get();
// Open transaction that is general for the previous nested one: it will be closed on nested commit
bool aIsOp = aMgr->isOperation();
}
updateCommandStatus();
- myModule->onOperationStarted(aFOperation);
+ myModule->operationStarted(aFOperation);
// the objects of the current operation should be deactivated
QObjectPtrList anObjects;
}
updateCommandStatus();
- myModule->onOperationResumed(theOperation);
+ myModule->operationResumed(theOperation);
}
hidePropertyPanel();
myPropertyPanel->cleanContent();
- myModule->onOperationStopped(aFOperation);
+ myModule->operationStopped(aFOperation);
// the deactivated objects of the current operation should be activated back.
// They were deactivated on operation start or an object redisplay
void XGUI_Workshop::onOperationCommitted(ModuleBase_Operation* theOperation)
{
- myModule->onOperationCommitted(theOperation);
+ myModule->operationCommitted(theOperation);
}
void XGUI_Workshop::onOperationAborted(ModuleBase_Operation* theOperation)
{
- myModule->onOperationAborted(theOperation);
+ myModule->operationAborted(theOperation);
}
void XGUI_Workshop::setGrantedFeatures(ModuleBase_Operation* theOperation)