#undef TO_STRING
}
-QString ModuleBase_IModule::getFeatureError(const FeaturePtr& theFeature)
+QString ModuleBase_IModule::getFeatureError(const FeaturePtr& theFeature, const bool isCheckGUI)
{
QString anError;
if (!theFeature.get() || !theFeature->data()->isValid() || theFeature->isAction())
//! Returns the feature error if the current state of the feature in the module is not correct\r
//! If the feature is correct, it returns an empty value\r
//! \return string value\r
- virtual QString getFeatureError(const FeaturePtr& theFeature);\r
+ virtual QString getFeatureError(const FeaturePtr& theFeature, const bool isCheckGUI = true);\r
\r
/// Returns list of granted operation indices\r
virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const;\r
/// \param thePreviousState the previous state of the widget\r
virtual void widgetStateChanged(int thePreviousState) {};\r
\r
+ /// Returns true if the event is processed.\r
+ /// \param thePreviousAttributeID an index of the previous active attribute\r
+ virtual bool processEnter(const std::string& thePreviousAttributeID) { return false; };\r
+\r
signals:\r
/// Signal which is emitted when operation is launched\r
void operationLaunched();\r
myMenuMgr->updateViewerMenu(theStdActions);
}
-QString PartSet_Module::getFeatureError(const FeaturePtr& theFeature)
+QString PartSet_Module::getFeatureError(const FeaturePtr& theFeature, const bool isCheckGUI)
{
- QString anError = ModuleBase_IModule::getFeatureError(theFeature);
+ QString anError = ModuleBase_IModule::getFeatureError(theFeature, isCheckGUI);
if (anError.isEmpty())
- anError = sketchMgr()->getFeatureError(theFeature);
+ anError = sketchMgr()->getFeatureError(theFeature, isCheckGUI);
return anError;
}
{
mySketchMgr->widgetStateChanged(thePreviousState);
}
+
+bool PartSet_Module::processEnter(const std::string& thePreviousAttributeID)
+{
+ return mySketchReentrantMgr->processEnter(thePreviousAttributeID);
+}
//! Returns the feature error if the current state of the feature in the module is not correct
//! If the feature is correct, it returns an empty value
//! \return string value
- virtual QString getFeatureError(const FeaturePtr& theFeature);
+ virtual QString getFeatureError(const FeaturePtr& theFeature, const bool isCheckGUI = true);
/// Returns list of granted operation indices
virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const;
/// \thePrevState the previous widget value state
virtual void widgetStateChanged(int thePreviousState);
+ /// Returns true if the event is processed. It gives the reentrance manager to process the enter.
+ /// \param thePreviousAttributeID an index of the previous active attribute
+ virtual bool processEnter(const std::string& thePreviousAttributeID);
+
public slots:
/// Redefines the parent method in order to customize the next case:
/// If the sketch nested operation is active and the presentation is not visualized in the viewer,
aReentranceMgr, SLOT(onWidgetActivated()));
}
- XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
- connect(anOpMgr, SIGNAL(keyEnterReleased()), aReentranceMgr, SLOT(onEnterReleased()));
-
XGUI_ViewerProxy* aViewerProxy = aWorkshop->viewer();
connect(aViewerProxy, SIGNAL(enterViewPort()), this, SLOT(onEnterViewPort()));
connect(aViewerProxy, SIGNAL(leaveViewPort()), this, SLOT(onLeaveViewPort()));
return anError;
}
-QString PartSet_SketcherMgr::getFeatureError(const FeaturePtr& theFeature)
+QString PartSet_SketcherMgr::getFeatureError(const FeaturePtr& theFeature, const bool isCheckGUI)
{
QString anError = "";
if (!theFeature.get() || !theFeature->data()->isValid())
}
else {
ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
- if (anActiveWidget) {
+ if (isCheckGUI && anActiveWidget) {
ModuleBase_ModelWidget::ValueState aState = anActiveWidget->getValueState();
if (aState != ModuleBase_ModelWidget::Stored) {
AttributePtr anAttr = anActiveWidget->feature()->attribute(anActiveWidget->attributeID());
//! Incorrect states: the feature is sketch, the solver error value
//! The feature value is reset, this is the flag of sketch mgr
//! \return string value
- QString getFeatureError(const FeaturePtr& theFeature);
+ QString getFeatureError(const FeaturePtr& theFeature, const bool isCheckGUI = true);
/// Returns list of strings which contains id's of sketch operations
static const QStringList& sketchOperationIdList();
{
if (!isActiveMgr())
return;
- XGUI_OperationMgr* anOpMgr = workshop()->operationMgr();
- if (!anOpMgr->isApplyEnabled())
- return;
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
(myWorkshop->currentOperation());
+ if (!myWorkshop->module()->getFeatureError(aFOperation->feature(), false).isEmpty())
+ return;
+
if (aFOperation) {
if (PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) {
- XGUI_OperationMgr* anOpMgr = workshop()->operationMgr();
if (myRestartingMode != RM_Forbided) {
myRestartingMode = RM_LastFeatureUsed;
startInternalEdit(thePreviousAttributeID);
}
- else
+ else {
aFOperation->commit();
+ }
}
}
}
+bool PartSet_SketcherReetntrantMgr::processEnter(const std::string& thePreviousAttributeID)
+{
+ bool isDone = false;
+
+ if (!isActiveMgr())
+ return isDone;
+
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+ (myWorkshop->currentOperation());
+ if (!myWorkshop->module()->getFeatureError(aFOperation->feature(), false).isEmpty())
+ return isDone;
+
+ myRestartingMode = RM_EmptyFeatureUsed;
+ startInternalEdit(thePreviousAttributeID);
+ isDone = true;
+
+ return isDone;
+}
+
void PartSet_SketcherReetntrantMgr::onVertexSelected()
{
if (!isActiveMgr())
}
}
-void PartSet_SketcherReetntrantMgr::onEnterReleased()
-{
- if (!isActiveMgr())
- return;
-
- ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
- (myWorkshop->currentOperation());
- if (myIsInternalEditOperation)
- myRestartingMode = RM_EmptyFeatureUsed;
-}
-
void PartSet_SketcherReetntrantMgr::onBeforeStopped()
{
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
/// or return null. If the current widget of the operation is a viewer selector, it returns null.
ModuleBase_ModelWidget* internalActiveWidget() const;
+ /// if the internal flags allow it and the manager is active, it starts an internal edit operation
+ /// for the created operation.
+ /// \param thePreviousAttributeID an index of the previous active attribute
+ //bool restartOperation(const std::string& thePreviousAttributeID);
+ bool processEnter(const std::string& thePreviousAttributeID);
+
/// Resets the internal flags
/// \param theOperation a started operation
void operationStarted(ModuleBase_Operation* theOperation);
/// the current feature is a line and there are not obligate widgets anymore
void onVertexSelected();
- /// SLOT, that is called by enter key released
- /// Set a specific type of restarting the current operation to do not use the feature
- /// for initialization of a new started operation.
- void onEnterReleased();
-
/// Deactivates selection and filters of the first operation widget if it is an internal
/// 'edit' operation
void onBeforeStopped();
ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget();
if (!aActiveWgt || !aActiveWgt->processEnter()) {
- ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(currentOperation());
- if (!aFOperation || myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty()) {
- emit keyEnterReleased();
- commitOperation();
+ if (!myWorkshop->module()->processEnter(aActiveWgt->attributeID())) {
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(currentOperation());
+ if (!aFOperation || myWorkshop->module()->getFeatureError(aFOperation->feature(), false).isEmpty()) {
+ emit keyEnterReleased();
+ commitOperation();
+ }
+ else
+ isAccepted = false;
}
- else
- isAccepted = false;
}
}
break;