myIsTitleInToolbar = true;
myIsApplyContinue = false;
myHideFacesPanel = false;
+ myAbortConfirmation = true;
}
Config_FeatureMessage::~Config_FeatureMessage()
{
myHideFacesPanel = theValue;
}
+
+bool Config_FeatureMessage::isAbortConfirmation() const
+{
+ return myAbortConfirmation;
+}
+
+void Config_FeatureMessage::setAbortConfirmation(bool theValue)
+{
+ myAbortConfirmation = theValue;
+}
bool myIsAutoPreview; ///< Preview computation is performed automatically
bool myIsTitleInToolbar; ///< False if title should not be displayed in the toolbar
bool myHideFacesPanel; ///< Show or Hide HideFaces panel. By default is False
+ bool myAbortConfirmation; ///< Ask confirmation of abort of the feature from user
/// True if the feature can have Apply/Continue button in its property panel
bool myIsApplyContinue;
CONFIG_EXPORT bool isTitleInToolbar() const;
/// If true - then HideFaces panel has to be shown
CONFIG_EXPORT bool isHideFacesPanel() const;
+ CONFIG_EXPORT bool isAbortConfirmation() const;
///Set feature's Id
CONFIG_EXPORT void setId(const std::string& id);
CONFIG_EXPORT void setTitleInToolbar(bool theValue);
///Set flag to display title in toolbar
CONFIG_EXPORT void setHideFacesPanel(bool theValue);
+ ///Set flag to display title in toolbar
+ CONFIG_EXPORT void setAbortConfirmation(bool theValue);
///Set Apply/Continue state;
///If true - the feature can have Apply/Continue button in its property panel
CONFIG_EXPORT void setApplyContinue(bool isModal);
bool isHideFaces = getBooleanAttribute(theFeatureNode, HIDEFACES_PANEL, false);
outFeatureMessage->setHideFacesPanel(isHideFaces);
+ bool isConfirmAbort = getBooleanAttribute(theFeatureNode, ABORT_CONFIRMATION, true);
+ outFeatureMessage->setAbortConfirmation(isConfirmAbort);
+
//if (isInternal) {
// //Internal feature has no visual representation.
// return;
const static char* FEATURE_ICON = "icon";
const static char* FEATURE_TEXT = "title";
const static char* HELP_FILE = "helpfile";
+const static char* ABORT_CONFIRMATION = "abort_confirmation";
const static char* HIDEFACES_PANEL = "hidefaces_panel";
const static char* FEATURE_KEYSEQUENCE = "keysequence";
const static char* FEATURE_NESTED = "nested";
*/
CONFIG_EXPORT bool getBooleanAttribute(const char* theAttributeName, bool theDefault) const;
- protected:
/// These fields are accessible for ModuleBase_WidgetFactory only
CONFIG_EXPORT Config_WidgetAPI(std::string theRawXml);
//! Pass to the next (sibling) node of widget's xml definition. If impossible, returns false
<source path="export_widget.xml" />
</feature>
<feature id="Dump" title="Dump" tooltip="Dump Python script" icon="icons/Exchange/dump.png"
- helpfile="dumpFeature.html">
+ helpfile="dumpFeature.html" abort_confirmation="false">
<export_file_selector id="file_path"
type="save"
title="Dump to file"
</group>
<group id="Measurement">
<feature id="Measurement" title="Measurement" tooltip="Calculate properties of objects"
- icon="icons/Features/measurement.png" helpfile="measurementFeature.html">
+ icon="icons/Features/measurement.png" helpfile="measurementFeature.html" abort_confirmation="false">
<source path="measurement_widget.xml"/>
</feature>
</group>
ModuleBase_ListView.h
ModuleBase_ModelWidget.h
ModuleBase_Operation.h
- ModuleBase_OperationAction.h
ModuleBase_OperationDescription.h
ModuleBase_OperationFeature.h
ModuleBase_PageBase.h
ModuleBase_ModelDialogWidget.h
ModuleBase_ModelWidget.h
ModuleBase_Operation.h
- ModuleBase_OperationAction.h
ModuleBase_OperationFeature.h
ModuleBase_PagedContainer.h
ModuleBase_PageGroupBox.h
ModuleBase_ListView.cpp
ModuleBase_ModelWidget.cpp
ModuleBase_Operation.cpp
- ModuleBase_OperationAction.cpp
ModuleBase_OperationDescription.cpp
ModuleBase_OperationFeature.cpp
ModuleBase_PageBase.cpp
}
return aFirstWidget;
}
+
+bool ModuleBase_IPropertyPanel::isModified() const
+{
+ bool isModified = false;
+ QList<ModuleBase_ModelWidget*> aWidgets = modelWidgets();
+ foreach(ModuleBase_ModelWidget* aWgt, aWidgets) {
+ bool aRes = aWgt->isModified();
+ isModified |= aRes;
+ }
+ return isModified;
+}
/// The method is called on accepting of operation
virtual void onAcceptData() = 0;
+ /// Returns True if data of its feature was modified during operation
+ virtual bool isModified() const;
+
/// Returns the first widget, where canAcceptFocus returns true
/// \return a widget or null
static ModuleBase_ModelWidget* findFirstAcceptingValueWidget(
/// for current feature. By default does nothing
virtual void showInformativePage() {}
+ /// Returns True if data of its attribute was modified
+ virtual bool isModified() const { return false; }
+
signals:
/// The signal about widget values are to be changed
void beforeValuesChanged();
#include <GeomAPI_Pnt2d.h>
#include <Events_Loop.h>
+#include <Config_WidgetAPI.h>
+#include <Config_Keywords.h>
#include <QTimer>
{
return myGrantedIds.contains(theId);
}
+
+bool ModuleBase_Operation::isModified() const
+{
+ if (myDescription->hasXmlRepresentation()) {
+ Config_WidgetAPI aWidgetApi(myDescription->xmlRepresentation().toStdString());
+ if (!aWidgetApi.getBooleanAttribute(ABORT_CONFIRMATION, true))
+ return false;
+ }
+ //if (myPropertyPanel)
+ // return myPropertyPanel->isModified();
+ //return false;
+ // Most of operation causes creation of a feature
+ return true;
+}
virtual bool isGranted(QString theId) const;
/// Returns True if data of its feature was modified during operation
- virtual bool isModified() const { return myIsModified; }
-
- /// Change the modified state of the operation
- void setIsModified(const bool theIsModified) { myIsModified = theIsModified; }
+ virtual bool isModified() const;
/// Returns operations Id from it's description
QString id() const;
+++ /dev/null
-// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include "ModuleBase_OperationAction.h"
-
-ModuleBase_OperationAction::ModuleBase_OperationAction(const QString& theId, QObject* theParent)
- : ModuleBase_Operation(theId, theParent)
-{
-}
-
-ModuleBase_OperationAction::~ModuleBase_OperationAction()
-{
-}
-
-bool ModuleBase_OperationAction::commit()
-{
- // the action is supposed to perform a single modification,
- // so the operation returns modified state
- setIsModified(true);
-
- return ModuleBase_Operation::commit();
-}
+++ /dev/null
-// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef ModuleBase_OperationAction_H
-#define ModuleBase_OperationAction_H
-
-#include <ModuleBase.h>
-
-#include <ModuleBase_Operation.h>
-
-/*!
- * \class ModuleBase_OperationAction
- * \ingroup GUI
- * \brief Base class for action operations
- *
- * This is an action-like operation, which modifies the structure of data through
- * starting/comitting transactions in the document. This operations are single stepped,
- * and have no filled property panel, like Delete/Detach.
- */
-
-class MODULEBASE_EXPORT ModuleBase_OperationAction : public ModuleBase_Operation
-{
-Q_OBJECT
-
- public:
- /// Constructor
- /// \param theId the operation identifier
- /// \param theParent the QObject parent
- ModuleBase_OperationAction(const QString& theId = "", QObject* theParent = 0);
- /// Destructor
- virtual ~ModuleBase_OperationAction();
-
- public slots:
- /// Commits the operation. Change is modified state to true value.
- /// \return the result of commit
- virtual bool commit();
-};
-
-#endif
std::shared_ptr<ModelAPI_Document> aDoc = ModelAPI_Session::get()->activeDocument();
myFeature = aDoc->addFeature(getDescription()->operationId().toStdString());
}
- if (myFeature) { // TODO: generate an error if feature was not created
- setIsModified(true);
- // Model update should call "execute" of a feature.
- //myFeature->execute();
- // Init default values
- /*QList<ModuleBase_ModelWidget*> aWidgets = getDescription()->modelWidgets();
- QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
- for (; anIt != aLast; anIt++) {
- (*anIt)->storeValue(aFeature);
- }*/
- }
-
- //if (theFlushMessage) {
- // Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
- // Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
- //}
return myFeature;
}
#ifdef DEBUG_OPERATION_START
qDebug("ModuleBase_OperationFeature::start -- begin");
#endif
- setIsModified(false);
QString anId = getDescription()->operationId();
if (myIsEditing) {
anId = anId.append(EditSuffix());
}
return isModified;
}
+
+bool ModuleBase_WidgetDoubleValue::isModified() const
+{
+ QString aText = mySpinBox->text();
+ if (aText.isEmpty())
+ return false;
+
+ if (myHasDefault) {
+ bool aOk = false;
+ double aVal = aText.toDouble(&aOk);
+ if (!aOk || aVal == myDefaultVal)
+ return false;
+ }
+ return true;
+}
\ No newline at end of file
/// \return a control list
virtual QList<QWidget*> getControls() const;
+ /// Returns True if data of its feature was modified during operation
+ virtual bool isModified() const;
+
public slots:
// Delayed value chnged: when user starts typing something,
// it gives him a 0,5 second to finish typing, when sends valueChnaged() signal
}
return isModified;
}
+
+bool ModuleBase_WidgetIntValue::isModified() const
+{
+ QString aText = mySpinBox->text();
+ if (aText.isEmpty())
+ return false;
+
+ if (myHasDefault) {
+ bool aOk = false;
+ int aVal = aText.toInt(&aOk);
+ if (!aOk || aVal == myDefVal)
+ return false;
+ }
+ return true;
+}
\ No newline at end of file
/// \return a control list
virtual QList<QWidget*> getControls() const;
+ /// Returns True if data of its feature was modified during operation
+ virtual bool isModified() const;
+
protected:
/// Returns true if the event is processed.
virtual bool processEnter();
}
return isModified;
}
+
+bool ModuleBase_WidgetLineEdit::isModified() const
+{
+ return !myLineEdit->text().isEmpty();
+}
\ No newline at end of file
/// Redefinition of virtual method
virtual QList<QWidget*> getControls() const;
+ /// Returns True if data of its feature was modified during operation
+ virtual bool isModified() const;
+
protected:
/// Returns true if the event is processed.
virtual bool processEnter();
} else
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
}
+
+bool ModuleBase_WidgetMultiSelector::isModified() const
+{
+ return myListView->getControl()->count() > 0;
+}
\ No newline at end of file
/// The slot is called when user press Ok or OkPlus buttons in the parent property panel
virtual void onFeatureAccepted();
+ /// Returns True if data of its feature was modified during operation
+ virtual bool isModified() const;
+
public slots:
/// Slot is called on selection type changed
void onSelectionTypeChanged();
}
}
}
+
+//********************************************************************
+bool ModuleBase_WidgetShapeSelector::isModified() const
+{
+ return !myTextLine->text().isEmpty();
+}
\ No newline at end of file
/// \return a control list
virtual QList<QWidget*> getControls() const;
+ /// Returns True if data of its feature was modified during operation
+ virtual bool isModified() const;
+
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
#include <ModuleBase_ISelection.h>
#include <ModuleBase_Operation.h>
-#include <ModuleBase_OperationAction.h>
#include <ModuleBase_OperationFeature.h>
#include <ModuleBase_ViewerPrs.h>
#include <ModuleBase_Tools.h>
XGUI_Workshop* aWorkshop = aConnector->workshop();
ModuleBase_Operation* anOperation = myModule->workshop()->currentOperation();
- ModuleBase_OperationAction* anOpAction = new ModuleBase_OperationAction(
- tr("Detach %1").arg(aLine->data()->name().c_str()), myModule);
+ ModuleBase_Operation* anOpAction =
+ new ModuleBase_Operation(tr("Detach %1").arg(aLine->data()->name().c_str()), myModule);
bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation);
XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
// the active nested sketch operation should be aborted unconditionally
QAction* anAction = action("AUXILIARY_CMD");
//SessionPtr aMgr = ModelAPI_Session::get();
- ModuleBase_OperationAction* anOpAction = 0;
+ ModuleBase_Operation* anOpAction = 0;
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
if (isUseTransaction) {
- anOpAction = new ModuleBase_OperationAction(anAction->text(), myModule);
+ anOpAction = new ModuleBase_Operation(anAction->text(), myModule);
bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation);
bool isCommitted;
#include <SketchPlugin_ConstraintCoincidence.h>
#include <ModuleBase_Operation.h>
-#include <ModuleBase_OperationAction.h>
#include <ModuleBase_IViewer.h>
#include <ModuleBase_IViewWindow.h>
#include <ModuleBase_IPropertyPanel.h>
// 3. start operation
QString aDescription = aWorkshop->contextMenuMgr()->action("DELETE_CMD")->text();
- ModuleBase_OperationAction* anOpAction = new ModuleBase_OperationAction(aDescription, this);
+ ModuleBase_Operation* anOpAction = new ModuleBase_Operation(aDescription, this);
// the active nested sketch operation should be aborted unconditionally
// the Delete action should be additionally granted for the Sketch operation
#include <ModuleBase_IModule.h>
#include <ModuleBase_Tools.h>
-#include <ModuleBase_OperationAction.h>
+#include <ModuleBase_Operation.h>
#include <ModuleBase_ViewerPrs.h>
#include <QAction>
}
}
if (aResultOp) {
- bool isModified = aCurrentOperation->isModified();
- aResultOp->setIsModified(aResultOp->isModified() || isModified);
+ //bool isModified = aCurrentOperation->isModified();
+ //aResultOp->setIsModified(aResultOp->isModified() || isModified);
resumeOperation(aResultOp);
onValidateOperation();
}
#include <ModuleBase_Tools.h>
#include <ModuleBase_WidgetFactory.h>
#include <ModuleBase_OperationFeature.h>
-#include <ModuleBase_OperationAction.h>
#include <ModuleBase_PagedContainer.h>
#include <ModuleBase_WidgetValidated.h>
#include <ModuleBase_ModelWidget.h>
bool aDone = false;
QString aDescription = contextMenuMgr()->action("DELETE_CMD")->text() + " %1";
aDescription = aDescription.arg(XGUI_Tools::unionOfObjectNames(anObjects, ", "));
- ModuleBase_OperationAction* anOpAction = new ModuleBase_OperationAction(aDescription, module());
+ ModuleBase_Operation* anOpAction = new ModuleBase_Operation(aDescription, module());
operationMgr()->startOperation(anOpAction);
// 1. start operation
aDescription += "by deleting of " +
aDescription.arg(XGUI_Tools::unionOfObjectNames(anObjects, ", "));
- ModuleBase_OperationAction* anOpAction = new ModuleBase_OperationAction(aDescription, module());
+ ModuleBase_Operation* anOpAction = new ModuleBase_Operation(aDescription, module());
operationMgr()->startOperation(anOpAction);
// WORKAROUND, should be done before each object remove, if it presents in XGUI_DataModel tree