From: nds Date: Mon, 5 May 2014 06:24:31 +0000 (+0400) Subject: refs #30 - Sketch base GUI: create, draw lines X-Git-Tag: V_0.2~96 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6df60c642d0427e2cb42bd29e2c64d4e5dbdaee4;p=modules%2Fshaper.git refs #30 - Sketch base GUI: create, draw lines Separation an abstract IOperation from the operation filled by a feature and operation description. --- diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index 116353000..2c4489db8 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -3,7 +3,9 @@ SET(CMAKE_AUTOMOC ON) SET(PROJECT_HEADERS ModuleBase.h + ModuleBase_IOperation.h ModuleBase_Operation.h + ModuleBase_OperationDescription.h ModuleBase_PropPanelOperation.h ModuleBase_WidgetCustom.h ModuleBase_WidgetFactory.h @@ -12,7 +14,9 @@ SET(PROJECT_HEADERS ) SET(PROJECT_SOURCES + ModuleBase_IOperation.cpp ModuleBase_Operation.cpp + ModuleBase_OperationDescription.cpp ModuleBase_PropPanelOperation.cpp ModuleBase_WidgetFactory.cpp ModuleBase_WidgetPoint2D.cpp diff --git a/src/ModuleBase/ModuleBase_IOperation.cpp b/src/ModuleBase/ModuleBase_IOperation.cpp new file mode 100644 index 000000000..9a14779c6 --- /dev/null +++ b/src/ModuleBase/ModuleBase_IOperation.cpp @@ -0,0 +1,83 @@ +/* + * ModuleBase_IOperation.cpp + * + * Created on: May 5, 2014 + * Author: nds + */ + +#include "ModuleBase_IOperation.h" +#include "ModuleBase_OperationDescription.h" + +#include +#include + +#ifdef _DEBUG +#include +#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 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(); + } +} diff --git a/src/ModuleBase/ModuleBase_IOperation.h b/src/ModuleBase/ModuleBase_IOperation.h new file mode 100644 index 000000000..6b75e7eca --- /dev/null +++ b/src/ModuleBase/ModuleBase_IOperation.h @@ -0,0 +1,127 @@ +/* + * ModuleBase_IOperation.h + * + * Created on: May 5, 2014 + * Author: nds + */ + + +#ifndef ModuleBase_IOperation_H +#define ModuleBase_IOperation_H + +#include + +#include +#include + +#include + +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 document() const; + +private: + ModuleBase_OperationDescription* myDescription; /// the container to have the operation description +}; + +#endif diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index d5a0ce993..8c2f4a274 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -1,12 +1,13 @@ /* * 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 @@ -20,40 +21,13 @@ #include #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 ModuleBase_Operation::feature() const @@ -61,209 +35,6 @@ boost::shared_ptr 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 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){ @@ -279,12 +50,6 @@ void ModuleBase_Operation::storeReal(double theValue) 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){ @@ -300,79 +65,25 @@ void ModuleBase_Operation::storeCustomValue() 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 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; -} diff --git a/src/ModuleBase/ModuleBase_Operation.h b/src/ModuleBase/ModuleBase_Operation.h index 14978bee3..c9d7588d5 100644 --- a/src/ModuleBase/ModuleBase_Operation.h +++ b/src/ModuleBase/ModuleBase_Operation.h @@ -1,23 +1,22 @@ /* * 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 +#include #include #include #include -class SUIT_Study; -class XGUI_Workshop; class ModelAPI_Feature; class ModelAPI_Document; @@ -37,105 +36,42 @@ 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 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 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 myFeature; + boost::shared_ptr myFeature; /// the operation feature to be handled }; #endif diff --git a/src/ModuleBase/ModuleBase_OperationDescription.cpp b/src/ModuleBase/ModuleBase_OperationDescription.cpp new file mode 100644 index 000000000..a9bd201ac --- /dev/null +++ b/src/ModuleBase/ModuleBase_OperationDescription.cpp @@ -0,0 +1,44 @@ +/* + * ModuleBase_OperationDescription.cpp + * + * Created on: May 5, 2014 + * Author: nds + */ + +#include +#include + +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; +} + diff --git a/src/ModuleBase/ModuleBase_OperationDescription.h b/src/ModuleBase/ModuleBase_OperationDescription.h new file mode 100644 index 000000000..aedb625b2 --- /dev/null +++ b/src/ModuleBase/ModuleBase_OperationDescription.h @@ -0,0 +1,59 @@ +/* + * ModuleBase_OperationDescription.h + * + * Created on: May 5, 2014 + * Author: nds + */ + +#ifndef MODULEBASE_OPERATIONDESCRIPTION_H +#define MODULEBASE_OPERATIONDESCRIPTION_H + +#include +#include + +#include +#include + +#include + +/*! + * \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 diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index d902d0eef..9437d5de6 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -8,8 +8,9 @@ #include #include +#include -#include +#include #include #include #include @@ -31,10 +32,10 @@ #include #include -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()); } diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.h b/src/ModuleBase/ModuleBase_WidgetFactory.h index 404bcc057..3241bfb2f 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.h +++ b/src/ModuleBase/ModuleBase_WidgetFactory.h @@ -14,12 +14,12 @@ 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); @@ -37,7 +37,7 @@ protected: private: Config_WidgetAPI* myWidgetApi; - ModuleBase_PropPanelOperation* myOperation; + ModuleBase_Operation* myOperation; }; diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 13f3c8635..d38cc9f0a 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -1,6 +1,8 @@ #include #include #include +#include +#include #include #include @@ -109,7 +111,7 @@ void PartSet_Module::launchOperation(const QString& theCmdId) 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); } @@ -121,10 +123,10 @@ void PartSet_Module::launchOperation(const QString& theCmdId) 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"); @@ -154,10 +156,9 @@ void PartSet_Module::onOperationStarted() void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation) { - ModuleBase_PropPanelOperation* anOperation = dynamic_cast(theOperation); - if (!anOperation) + if (!theOperation) return; - PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); + PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(theOperation); //if (aPreviewOp) // visualizePreview(false); } diff --git a/src/PartSet/PartSet_OperationSketchBase.cpp b/src/PartSet/PartSet_OperationSketchBase.cpp index c372bc72f..d1f4533a0 100644 --- a/src/PartSet/PartSet_OperationSketchBase.cpp +++ b/src/PartSet/PartSet_OperationSketchBase.cpp @@ -14,7 +14,7 @@ using namespace std; PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId, QObject* theParent) -: ModuleBase_PropPanelOperation(theId, theParent) +: ModuleBase_Operation(theId, theParent) { setEditMode(false); } diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h index 48aa06c84..6b419b080 100644 --- a/src/PartSet/PartSet_OperationSketchBase.h +++ b/src/PartSet/PartSet_OperationSketchBase.h @@ -11,7 +11,8 @@ #include #include -#include +#include +#include #include class GeomAPI_Shape; @@ -21,7 +22,7 @@ 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: diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 7f8b861d9..e07178ec3 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -26,8 +26,9 @@ #include #include -#include #include +#include +#include #include #include @@ -191,11 +192,11 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) } const Config_PointerMessage* aPartSetMsg = dynamic_cast(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(); } @@ -220,10 +221,9 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) //****************************************************** 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(XGUI::PROP_PANEL_WDG); qDeleteAll(aPropWidget->children()); @@ -232,17 +232,16 @@ void XGUI_Workshop::onOperationStarted() 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(); @@ -317,10 +316,10 @@ void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation) 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))); diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 03e21ed31..de7dc670b 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -24,7 +24,6 @@ class XGUI_SalomeViewer; class XGUI_ViewerProxy; class ModuleBase_Operation; -class ModuleBase_PropPanelOperation; class Config_FeatureMessage; class Config_PointerMessage;