Separation an abstract IOperation from the operation filled by a feature and operation description.
SET(PROJECT_HEADERS
ModuleBase.h
+ ModuleBase_IOperation.h
ModuleBase_Operation.h
+ ModuleBase_OperationDescription.h
ModuleBase_PropPanelOperation.h
ModuleBase_WidgetCustom.h
ModuleBase_WidgetFactory.h
)
SET(PROJECT_SOURCES
+ ModuleBase_IOperation.cpp
ModuleBase_Operation.cpp
+ ModuleBase_OperationDescription.cpp
ModuleBase_PropPanelOperation.cpp
ModuleBase_WidgetFactory.cpp
ModuleBase_WidgetPoint2D.cpp
--- /dev/null
+/*
+ * ModuleBase_IOperation.cpp
+ *
+ * Created on: May 5, 2014
+ * Author: nds
+ */
+
+#include "ModuleBase_IOperation.h"
+#include "ModuleBase_OperationDescription.h"
+
+#include <ModelAPI_Document.h>
+#include <ModelAPI_PluginManager.h>
+
+#ifdef _DEBUG
+#include <QDebug>
+#endif
+
+ModuleBase_IOperation::ModuleBase_IOperation(const QString& theId, QObject* theParent)
+ : QObject(theParent)
+{
+ myDescription = new ModuleBase_OperationDescription(theId);
+}
+
+ModuleBase_IOperation::~ModuleBase_IOperation()
+{
+ delete myDescription;
+}
+
+ModuleBase_OperationDescription* ModuleBase_IOperation::getDescription() const
+{
+ return myDescription;
+}
+
+bool ModuleBase_IOperation::isGranted() const
+{
+ return false;
+}
+
+boost::shared_ptr<ModelAPI_Document> ModuleBase_IOperation::document() const
+{
+ return ModelAPI_PluginManager::get()->rootDocument();
+}
+
+void ModuleBase_IOperation::start()
+{
+ document()->startOperation();
+
+ startOperation();
+ emit started();
+}
+
+void ModuleBase_IOperation::resume()
+{
+}
+
+void ModuleBase_IOperation::abort()
+{
+ abortOperation();
+ emit aborted();
+
+ stopOperation();
+
+ document()->abortOperation();
+ emit stopped();
+}
+
+void ModuleBase_IOperation::commit()
+{
+ commitOperation();
+ emit committed();
+
+ stopOperation();
+
+ document()->finishOperation();
+ emit stopped();
+}
+
+void ModuleBase_IOperation::setRunning(bool theState)
+{
+ if (!theState) {
+ abort();
+ }
+}
--- /dev/null
+/*
+ * ModuleBase_IOperation.h
+ *
+ * Created on: May 5, 2014
+ * Author: nds
+ */
+
+
+#ifndef ModuleBase_IOperation_H
+#define ModuleBase_IOperation_H
+
+#include <ModuleBase.h>
+
+#include <QObject>
+#include <QString>
+
+#include <boost/shared_ptr.hpp>
+
+class ModelAPI_Document;
+class ModuleBase_OperationDescription;
+
+/*!
+ \class ModuleBase_IOperation
+ * \brief Base class for all operations
+ *
+ * Base class for all operations. If you perform an action it is reasonable to create
+ * operation intended for this. This is a base class for all operations which provides
+ * mechanism for correct starting operations, starting operations above already started
+ * ones, committing operations and so on. To create own operation it is reasonable to
+ * inherit it from this class and redefines virtual methods to provide own behavior
+ * Main virtual methods are
+ * - virtual bool isReadyToStart();
+ * - virtual void startOperation();
+ * - virtual void abortOperation();
+ * - virtual void commitOperation();
+ */
+
+class MODULEBASE_EXPORT ModuleBase_IOperation: public QObject
+{
+Q_OBJECT
+
+public:
+ /// Constructor
+ /// Constructs an empty operation. Constructor should work very fast because many
+ /// operators may be created after starting workshop but only several from them
+ /// may be used. As result this constructor stores given workshop in myApp field
+ /// and set Waiting status.
+ /// \param theId the operation identifier
+ /// \param theParent the QObject parent
+ ModuleBase_IOperation(const QString& theId = "", QObject* theParent = 0);
+ /// Destructor
+ virtual ~ModuleBase_IOperation();
+
+ /// Returns the operation description
+ /// /returns the instance of the description class
+ ModuleBase_OperationDescription* getDescription() const;
+
+ /// Verifies whether this operator can be always started above any already running one
+ /// \return Returns TRUE if current operation must not be checked for ActiveOperation->IsValid( this )
+ /// This method must be redefined in derived operation if operation of derived class
+ /// must be always can start above any launched one. Default impl returns FALSE,
+ /// so it is being checked for IsValid, but some operations may overload IsGranted()
+ /// In this case they will always start, no matter what operation is running.
+ virtual bool isGranted() const;
+
+signals:
+ void started(); /// the operation is started
+ void aborted(); /// the operation is aborted
+ void committed(); /// the operation is committed
+ void stopped(); /// the operation is aborted or committed
+
+public slots:
+ /// Starts operation
+ /// Public slot. Verifies whether operation can be started and starts operation.
+ /// This slot is not virtual and cannot be redefined. Redefine startOperation method
+ /// to change behavior of operation. There is no point in using this method. It would
+ /// be better to inherit own operator from base one and redefine startOperation method
+ /// instead.
+ void start();
+ /// Resumes operation
+ /// Public slot. Verifies whether operation can be started and starts operation.
+ /// This slot is not virtual and cannot be redefined. Redefine startOperation method
+ /// to change behavior of operation. There is no point in using this method. It would
+ /// be better to inherit own operator from base one and redefine startOperation method
+ /// instead.
+ void resume();
+ /// Aborts operation
+ /// Public slot. Aborts operation. This slot is not virtual and cannot be redefined.
+ /// Redefine abortOperation method to change behavior of operation instead
+ void abort();
+ /// Commits operation
+ /// Public slot. Commits operation. This slot is not virtual and cannot be redefined.
+ /// Redefine commitOperation method to change behavior of operation instead
+ void commit();
+
+ /// Alias for start/abort slots
+ /// Public slot. Aborts operation if false, else does nothing.
+ /// Provided for S/S compatibility with QAction's toggle(bool)
+ /// \param theState th flag to abort, if it is true, do nothing, overwise abort
+ void setRunning(bool theState);
+
+ // Data model methods.
+ /// Stores a real value in model.
+ /// \param theValue - to store
+ virtual void storeReal(double theValue) = 0;
+ /// Stores a custom value in model.
+ virtual void storeCustomValue() = 0;
+
+protected:
+ /// Virtual method called when operation started (see start() method for more description)
+ /// Default impl calls corresponding slot and commits immediately.
+ virtual void startOperation() = 0;
+ /// Virtual method called when operation stopped - committed or aborted.
+ virtual void stopOperation() = 0;
+ /// Virtual method called when operation aborted (see abort() method for more description)
+ virtual void abortOperation() = 0;
+ /// Virtual method called when operation committed (see commit() method for more description)
+ virtual void commitOperation() = 0;
+
+ /// Returns pointer to the root document.
+ boost::shared_ptr<ModelAPI_Document> document() const;
+
+private:
+ ModuleBase_OperationDescription* myDescription; /// the container to have the operation description
+};
+
+#endif
/*
* ModuleBase_Operation.cpp
*
- * Created on: Apr 2, 2014
- * Author: sbh
+ * Created on: May 5, 2014
+ * Author: nds
*/
#include "ModuleBase_Operation.h"
+#include "ModuleBase_OperationDescription.h"
#include "ModuleBase_WidgetCustom.h"
#include <ModelAPI_AttributeDouble.h>
#include <QDebug>
#endif
-/*!
- \brief Constructor
- \param XGUI_Workshop - workshop for this operation
-
- Constructs an empty operation. Constructor should work very fast because many
- operators may be created after starting workshop but only several from them
- may be used. As result this constructor stores given workshop in myApp field
- and set Waiting status.
- */
-ModuleBase_Operation::ModuleBase_Operation(const QString& theId, QObject* parent)
- : QObject(parent),
- myFlags(Transaction),
- myState(Waiting),
- myExecStatus(Rejected),
- myOperationId(theId)
+ModuleBase_Operation::ModuleBase_Operation(const QString& theId, QObject* theParent)
+: ModuleBase_IOperation(theId, theParent)
{
}
-/*!
- * \brief Destructor
- */
ModuleBase_Operation::~ModuleBase_Operation()
{
-
-}
-
-/*!
- * \brief Unique name of the operation
- *
- * Returns string name of the operation.
- */
-QString ModuleBase_Operation::operationId() const
-{
- return myOperationId;
}
boost::shared_ptr<ModelAPI_Feature> ModuleBase_Operation::feature() const
return myFeature;
}
-/*!
- * \brief Gets state of operation
- * \return Value from OperationState enumeration
- *
- * Gets state of operation (see OperationState enumeration)
- */
-ModuleBase_Operation::OperationState ModuleBase_Operation::state() const
-{
- return myState;
-}
-
-/*!
- * \brief Verifies whether operation is an ran one (state()==Running)
- * \return TRUE if operation is active, FALSE otherwise
- *
- * Verifies whether operation is an running. Returns TRUE if state of operator
- * is Running
- */
-bool ModuleBase_Operation::isRunning() const
-{
- return state() == Running;
-}
-
-/*!
- * \brief Verifies whether given operator is valid for this one
- * \param theOtherOp - other operation
- * \return Returns TRUE if the given operator is valid for this one
- *
- * Verifies whether given operator is valid for this one (i.e. can be started "above"
- * this operator)
- */
-bool ModuleBase_Operation::isValid(ModuleBase_Operation*) const
-{
- return false;
-}
-
-/*!
- * \brief Verifies whether this operator can be always started above any already running one
- * \return Returns TRUE if current operation must not be checked for ActiveOperation->IsValid( this )
- *
- * This method must be redefined in derived operation if operation of derived class
- * must be always can start above any launched one. Default impl returns FALSE,
- * so it is being checked for IsValid, but some operations may overload IsGranted()
- * In this case they will always start, no matter what operation is running.
- */
-bool ModuleBase_Operation::isGranted() const
-{
- return false;
-}
-
-/*
- * Returns pointer to the root document.
- */
-boost::shared_ptr<ModelAPI_Document> ModuleBase_Operation::document() const
-{
- return ModelAPI_PluginManager::get()->rootDocument();
-}
-
-/*!
- * \brief Sets slot which is called when operation is started
- * \param theReceiver - object containing slot
- * \param theSlot - slot of theReceiver object
- * \return TR if slot was connected successfully, FALSE otherwise
- *
- * Sets slot which is called when operation is started. There is no point in
- * using this method. It would be better to inherit own operator from base
- * one and redefine startOperation method
- */
-bool ModuleBase_Operation::setSlot(const QObject* theReceiver, const char* theSlot)
-{
- return connect(this, SIGNAL(callSlot()), theReceiver, theSlot);
-}
-
-/*!
- * \brief Sets the flags of operation
- * \param f - flags of operation to be set
- *
- * Sets flags of operation (see Flags enumeration)
- */
-void ModuleBase_Operation::setFlags(const int f)
-{
- myFlags = myFlags | f;
-}
-
-/*!
- * \brief Clears the flags of operation
- * \param f - flags of operation to be cleared
- *
- * Clears flags of operation (see Flags enumeration)
- */
-void ModuleBase_Operation::clearFlags(const int f)
-{
- myFlags = myFlags & ~f;
-}
-
-/*!
- * \brief Test the flags of operation
- * \param f - flags of operation to be tested
- *
- * Returns TRUE if the specified flags set in the operation (see Flags enumeration)
- */
-bool ModuleBase_Operation::testFlags(const int f) const
-{
- return (myFlags & f) == f;
-}
-
-/*!
- * \brief Gets execution status
- * \return Execution status
- *
- * Gets execution status
- */
-int ModuleBase_Operation::execStatus() const
-{
- return myExecStatus;
-}
-
-/*!
- * \brief Starts operation
- *
- * Public slot. Verifies whether operation can be started and starts operation.
- * This slot is not virtual and cannot be redefined. Redefine startOperation method
- * to change behavior of operation. There is no point in using this method. It would
- * be better to inherit own operator from base one and redefine startOperation method
- * instead.
- */
-void ModuleBase_Operation::start()
-{
- //document()->start(this);
- document()->startOperation();
-
- startOperation();
- emit started();
-}
-
-/*!
- * \brief Resumes operation
- *
- * Public slot. Verifies whether operation can be started and starts operation.
- * This slot is not virtual and cannot be redefined. Redefine startOperation method
- * to change behavior of operation. There is no point in using this method. It would
- * be better to inherit own operator from base one and redefine startOperation method
- * instead.
- */
-void ModuleBase_Operation::resume()
-{
-}
-
-/*!
- * \brief Aborts operation
- *
- * Public slot. Aborts operation. This slot is not virtual and cannot be redefined.
- * Redefine abortOperation method to change behavior of operation instead
- */
-void ModuleBase_Operation::abort()
-{
- abortOperation();
- myState = Waiting;
- emit aborted();
-
- stopOperation();
-
- document()->abortOperation();
- emit stopped();
-}
-
-/*!
- * \brief Commits operation
- *
- * Public slot. Commits operation. This slot is not virtual and cannot be redefined.
- * Redefine commitOperation method to change behavior of operation instead
- */
-void ModuleBase_Operation::commit()
-{
- commitOperation();
- myState = Waiting;
- emit committed();
-
- stopOperation();
-
- document()->finishOperation();
- emit stopped();
-}
-
-/*
- * \brief Alias for start/abort slots
- *
- * Public slot. Aborts operation if false, else does nothing.
- * Provided for S/S compatibility with QAction's toggle(bool)
- */
-void ModuleBase_Operation::setRunning(bool on)
-{
- if (!on) {
- abort();
- }
-}
-
-/*!
- * \brief Stores a real value in model.
- * \param theValue - to store
- *
- * Public slot. Passes theValue into the model.
- */
void ModuleBase_Operation::storeReal(double theValue)
{
if(!myFeature){
aReal->setValue(theValue);
}
-/*!
- * \brief Stores a real value in model.
- * \param theValue - to store
- *
- * Public slot. Passes theValue into the model.
- */
void ModuleBase_Operation::storeCustomValue()
{
if(!myFeature){
aCustom->store(myFeature);
}
-/*!
- * \brief Verifies whether operator is ready to start.
- * \return TRUE if operation is ready to start
- *
- * Default impl returns TRUE. Redefine this method to add own verifications
- */
-bool ModuleBase_Operation::isReadyToStart() const
-{
- return true;
-}
-
-/*!
- * \brief Virtual method called when operation is started
- *
- * Virtual method called when operation started (see start() method for more description)
- * Default impl calls corresponding slot and commits immediately.
- */
void ModuleBase_Operation::startOperation()
{
boost::shared_ptr<ModelAPI_Document> aDoc = ModelAPI_PluginManager::get()->rootDocument();
- myFeature = aDoc->addFeature(myOperationId.toStdString());
+ myFeature = aDoc->addFeature(getDescription()->operationId().toStdString());
if (myFeature) // TODO: generate an error if feature was not created
myFeature->execute();
//emit callSlot();
//commit();
}
-/*!
- * \brief Virtual method called when operation is started
- *
- * Virtual method called when operation stopped - committed or aborted.
- */
void ModuleBase_Operation::stopOperation()
{
}
-/*!
- * \brief Virtual method called when operation aborted
- *
- * Virtual method called when operation aborted (see abort() method for more description)
- */
void ModuleBase_Operation::abortOperation()
{
}
-/*!
- * \brief Virtual method called when operation committed
- *
- * Virtual method called when operation committed (see commit() method for more description)
- */
void ModuleBase_Operation::commitOperation()
{
if (myFeature) myFeature->execute();
}
-
-/*!
- * \brief Sets execution status
- * \param theStatus - execution status
- *
- * Sets myExecStatus to the given value
- */
-void ModuleBase_Operation::setExecStatus(const int theVal)
-{
- myExecStatus = (ExecStatus) theVal;
-}
-
-/*!
- * \brief Sets state of operation
- * \param theState - state of operation to be set
- *
- * Sets state of operation (see OperationState enumeration)
- */
-void ModuleBase_Operation::setState(const ModuleBase_Operation::OperationState theState)
-{
- myState = theState;
-}
/*
* ModuleBase_Operation.h
*
- * Created on: Apr 2, 2014
- * Author: sbh
+ * Created on: May 5, 2014
+ * Author: nds
*/
-#ifndef MODULEBASE_OPERATION_H
-#define MODULEBASE_OPERATION_H
+#ifndef ModuleBase_Operation_H
+#define ModuleBase_Operation_H
#include <ModuleBase.h>
+#include <ModuleBase_IOperation.h>
#include <QObject>
#include <QString>
#include <boost/shared_ptr.hpp>
-class SUIT_Study;
-class XGUI_Workshop;
class ModelAPI_Feature;
class ModelAPI_Document;
* - virtual void commitOperation();
*/
-class MODULEBASE_EXPORT ModuleBase_Operation: public QObject
+class MODULEBASE_EXPORT ModuleBase_Operation: public ModuleBase_IOperation
{
Q_OBJECT
public:
- /*! Enum describes state of operation */
- enum OperationState
- {
- Waiting, //!< Operation is not used (it is not run or suspended)
- Running //!< Operation is started
- };
-
- /*!
- * Enum describes execution status of operation. Execution status often used after
- * ending work of operation which was started from this one. In this case this
- * operation can ask previously started operation whether it finished successfully.
- */
- enum ExecStatus
- {
- Rejected, //!< Operation has not performed any action (modification of data model for example)
- Accepted //!< Operation has performed an actions and must be stopped
- };
-
- /*!
- * Enum describes setting of the operation.
- */
- enum Flags
- {
- None = 0x00, //!< None options
- Transaction = 0x01 //!< Automatically open (commit/abort) transaction during start (commit/abort).
- };
-
-public:
- ModuleBase_Operation(const QString& theId = "", QObject* parent = 0);
+ /// Constructor
+ /// \param theId the operation identifier
+ /// \param theParent the QObject parent
+ ModuleBase_Operation(const QString& theId = "", QObject* theParent = 0);
+ /// Destructor
virtual ~ModuleBase_Operation();
- // Operation processing.
- virtual QString operationId() const;
-
+ /// Returns the operation feature
+ /// \return the feature
boost::shared_ptr<ModelAPI_Feature> feature() const;
- OperationState state() const;
- bool isRunning() const;
- virtual bool isValid(ModuleBase_Operation* theOtherOp) const;
- virtual bool isGranted() const;
-
- bool setSlot(const QObject* theReceiver, const char* theSlot);
-
- void setFlags(const int);
- void clearFlags(const int);
- bool testFlags(const int) const;
-
- int execStatus() const;
-
-signals:
- void started();
- void aborted();
- void committed();
- void stopped(); //!< operation aborted or committed
-
- void callSlot();
-
-public slots:
- void start();
- void resume();
- void abort();
- void commit();
-
- //true = do nothing, false = abort()
- //Provided for S/S compatibility with QAction's toggle(bool)
- void setRunning(bool);
-
- // Data model operations.
- void storeReal(double);
-
- // Data model operations.
+ // Data model methods.
+ /// Stores a real value in model.
+ /// \param theValue - to store
+ void storeReal(double theValue);
+ /// Stores a custom value in model.
void storeCustomValue();
protected:
- virtual bool isReadyToStart() const;
-
+ /// Virtual method called when operation started (see start() method for more description)
+ /// Default impl calls corresponding slot and commits immediately.
virtual void startOperation();
+ /// Virtual method called when operation stopped - committed or aborted.
virtual void stopOperation();
+ /// Virtual method called when operation aborted (see abort() method for more description)
virtual void abortOperation();
+ /// Virtual method called when operation committed (see commit() method for more description)
virtual void commitOperation();
- void setExecStatus(const int);
- void setState(const OperationState);
-
- boost::shared_ptr<ModelAPI_Document> document() const;
-
private:
- int myFlags; //!< Operation flags
- OperationState myState; //!< Operation state
- ExecStatus myExecStatus; //!< Execution status
-
- //!< Next fields could be extracted into a subclass;
- QString myOperationId;
- boost::shared_ptr<ModelAPI_Feature> myFeature;
+ boost::shared_ptr<ModelAPI_Feature> myFeature; /// the operation feature to be handled
};
#endif
--- /dev/null
+/*
+ * ModuleBase_OperationDescription.cpp
+ *
+ * Created on: May 5, 2014
+ * Author: nds
+ */
+
+#include <ModuleBase_OperationDescription.h>
+#include <QString>
+
+ModuleBase_OperationDescription::ModuleBase_OperationDescription(const QString& theId)
+: myOperationId(theId)
+{
+}
+
+ModuleBase_OperationDescription::~ModuleBase_OperationDescription()
+{
+}
+
+const QString& ModuleBase_OperationDescription::operationId() const
+{
+ return myOperationId;
+}
+
+const QString& ModuleBase_OperationDescription::xmlRepresentation() const
+{
+ return myXmlRepr;
+}
+
+void ModuleBase_OperationDescription::setXmlRepresentation(const QString& xmlRepr)
+{
+ myXmlRepr = xmlRepr;
+}
+
+const QString& ModuleBase_OperationDescription::description() const
+{
+ return myDescription;
+}
+
+void ModuleBase_OperationDescription::setDescription(const QString& theDescription)
+{
+ myDescription = theDescription;
+}
+
--- /dev/null
+/*
+ * ModuleBase_OperationDescription.h
+ *
+ * Created on: May 5, 2014
+ * Author: nds
+ */
+
+#ifndef MODULEBASE_OPERATIONDESCRIPTION_H
+#define MODULEBASE_OPERATIONDESCRIPTION_H
+
+#include <ModuleBase.h>
+#include <ModuleBase_Operation.h>
+
+#include <QObject>
+#include <QString>
+
+#include <memory>
+
+/*!
+ * \class ModuleBase_OperationDescription
+ *
+ */
+class MODULEBASE_EXPORT ModuleBase_OperationDescription
+{
+public:
+ /// Constructor
+ /// \param theId - the operation identifier
+ ModuleBase_OperationDescription(const QString& theId = "");
+ /// Destructor
+ virtual ~ModuleBase_OperationDescription();
+
+ /// Unique name of the operation
+ /// \return string name of the operation.
+ const QString& operationId() const;
+
+ /// Returns XML representation of the operation's widget.
+ /// \return XML QString
+ const QString& xmlRepresentation() const;
+
+ /// Sets XML representation of the operation's widget.
+ /// \param xmlRepr - XML QString
+ void setXmlRepresentation(const QString& xmlRepr);
+
+ /// Returns a short description of operation (will be
+ /// inserted in title of property panel)
+ const QString& description() const;
+
+ /// Sets a short description of operation (will be
+ /// inserted in title of property panel)
+ void setDescription(const QString& theDescription);
+
+private:
+ //!< Next fields could be extracted into a subclass;
+ QString myOperationId; /// the operation identifier
+ QString myXmlRepr; /// the XML representation of the operation's widget
+ QString myDescription; /// the short description of the opertaion
+};
+
+#endif //ModuleBase_OperationDescription_H
#include <ModuleBase_WidgetFactory.h>
#include <ModuleBase_WidgetSwitch.h>
+#include <ModuleBase_OperationDescription.h>
-#include <ModuleBase_PropPanelOperation.h>
+#include <ModuleBase_Operation.h>
#include <ModuleBase_WidgetPoint2D.h>
#include <Config_Keywords.h>
#include <Config_WidgetAPI.h>
#include <cfloat>
#include <climits>
-ModuleBase_WidgetFactory::ModuleBase_WidgetFactory(ModuleBase_PropPanelOperation* theOperation)
- : myOperation(theOperation)
+ModuleBase_WidgetFactory::ModuleBase_WidgetFactory(ModuleBase_Operation* theOperation)
+ : myOperation(theOperation)
{
- QString aXml = myOperation->xmlRepresentation();
+ QString aXml = myOperation->getDescription()->xmlRepresentation();
myWidgetApi = new Config_WidgetAPI(aXml.toStdString());
}
class QObject;
class QWidget;
class Config_WidgetAPI;
-class ModuleBase_PropPanelOperation;
+class ModuleBase_Operation;
class MODULEBASE_EXPORT ModuleBase_WidgetFactory
{
public:
- ModuleBase_WidgetFactory(ModuleBase_PropPanelOperation*);
+ ModuleBase_WidgetFactory(ModuleBase_Operation*);
virtual ~ModuleBase_WidgetFactory();
void createWidget(QWidget* theParent);
private:
Config_WidgetAPI* myWidgetApi;
- ModuleBase_PropPanelOperation* myOperation;
+ ModuleBase_Operation* myOperation;
};
#include <PartSet_Module.h>
#include <PartSet_OperationSketch.h>
#include <PartSet_OperationSketchLine.h>
+#include <ModuleBase_Operation.h>
+#include <ModuleBase_OperationDescription.h>
#include <PartSet_Listener.h>
#include <PartSet_Tools.h>
aWdgReader.readAll();
std::string aXmlCfg = aWdgReader.featureWidgetCfg(aStdCmdId);
std::string aDescription = aWdgReader.featureDescription(aStdCmdId);
- ModuleBase_PropPanelOperation* aPartSetOp;
+ ModuleBase_Operation* aPartSetOp;
if (theCmdId == "Sketch" ) {
aPartSetOp = new PartSet_OperationSketch(theCmdId, this);
}
aPartSetOp = new PartSet_OperationSketchLine(theCmdId, this, aSketchFeature);
}
else {
- aPartSetOp = new ModuleBase_PropPanelOperation(theCmdId, this);
+ aPartSetOp = new ModuleBase_Operation(theCmdId, this);
}
- aPartSetOp->setXmlRepresentation(QString::fromStdString(aXmlCfg));
- aPartSetOp->setDescription(QString::fromStdString(aDescription));
+ aPartSetOp->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg));
+ aPartSetOp->getDescription()->setDescription(QString::fromStdString(aDescription));
//TODO(sbh): Implement static method to extract event id [SEID]
static Events_ID aModuleEvent = Events_Loop::eventByName("PartSetModuleEvent");
void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
{
- ModuleBase_PropPanelOperation* anOperation = dynamic_cast<ModuleBase_PropPanelOperation*>(theOperation);
- if (!anOperation)
+ if (!theOperation)
return;
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
+ PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
//if (aPreviewOp)
// visualizePreview(false);
}
PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId,
QObject* theParent)
-: ModuleBase_PropPanelOperation(theId, theParent)
+: ModuleBase_Operation(theId, theParent)
{
setEditMode(false);
}
#include <gp_Pnt.hxx>
#include <NCollection_List.hxx>
-#include <ModuleBase_PropPanelOperation.h>
+#include <ModuleBase_Operation.h>
+#include <ModuleBase_Operation.h>
#include <QObject>
class GeomAPI_Shape;
* \brief The base operation for the sketch features.
* Base class for all sketch operations. It provides an access to the feature preview
*/
-class PARTSET_EXPORT PartSet_OperationSketchBase : public ModuleBase_PropPanelOperation
+class PARTSET_EXPORT PartSet_OperationSketchBase : public ModuleBase_Operation
{
Q_OBJECT
public:
#include <Events_Loop.h>
#include <Events_Error.h>
-#include <ModuleBase_PropPanelOperation.h>
#include <ModuleBase_Operation.h>
+#include <ModuleBase_Operation.h>
+#include <ModuleBase_OperationDescription.h>
#include <Config_FeatureMessage.h>
#include <Config_PointerMessage.h>
}
const Config_PointerMessage* aPartSetMsg = dynamic_cast<const Config_PointerMessage*>(theMessage);
if (aPartSetMsg) {
- ModuleBase_PropPanelOperation* anOperation =
- (ModuleBase_PropPanelOperation*)(aPartSetMsg->pointer());
+ ModuleBase_Operation* anOperation =
+ (ModuleBase_Operation*)(aPartSetMsg->pointer());
if (myOperationMgr->startOperation(anOperation)) {
- if (anOperation->xmlRepresentation().isEmpty()) {
+ if (anOperation->getDescription()->xmlRepresentation().isEmpty()) {
anOperation->commit();
updateCommandStatus();
}
//******************************************************
void XGUI_Workshop::onOperationStarted()
{
- ModuleBase_PropPanelOperation* aOperation =
- (ModuleBase_PropPanelOperation*)(myOperationMgr->currentOperation());
+ ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
- if(!aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
+ if(!aOperation->getDescription()->xmlRepresentation().isEmpty()) { //!< No need for property panel
connectWithOperation(aOperation);
QWidget* aPropWidget = myPropertyPanelDock->findChild<QWidget*>(XGUI::PROP_PANEL_WDG);
qDeleteAll(aPropWidget->children());
ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aOperation);
aFactory.createWidget(aPropWidget);
- setPropertyPannelTitle(aOperation->description());
+ setPropertyPannelTitle(aOperation->getDescription()->description());
}
}
//******************************************************
void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
{
- ModuleBase_PropPanelOperation* aOperation =
- (ModuleBase_PropPanelOperation*)(myOperationMgr->currentOperation());
+ ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
- if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
+ if(aOperation->getDescription()->xmlRepresentation().isEmpty()) { //!< No need for property panel
updateCommandStatus();
} else {
hidePropertyPanel();
QAction* aCommand = 0;
if (isSalomeMode()) {
- aCommand = salomeConnector()->command(theOperation->operationId());
+ aCommand = salomeConnector()->command(theOperation->getDescription()->operationId());
} else {
XGUI_MainMenu* aMenu = myMainWindow->menuObject();
- aCommand = aMenu->feature(theOperation->operationId());
+ aCommand = aMenu->feature(theOperation->getDescription()->operationId());
}
//Abort operation on uncheck the command
connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
class XGUI_ViewerProxy;
class ModuleBase_Operation;
-class ModuleBase_PropPanelOperation;
class Config_FeatureMessage;
class Config_PointerMessage;