/*
* Allows to customize reader's behavior for a node. Virtual.
- * The default implementation does nothing. (In debug mode prints
+ * The default impl does nothing. (In debug mode prints
* some info)
*/
void Config_XMLReader::processNode(xmlNodePtr aNode)
/*
* Defines which nodes should be processed recursively. Virtual.
- * The default implementation is to read all nodes.
+ * The default impl is to read all nodes.
*/
bool Config_XMLReader::processChildren(xmlNodePtr aNode)
{
GeomAPI_Interface.h
GeomAPI_Pnt.h
GeomAPI_Dir.h
+ GeomAPI_Pln.h
GeomAPI_Shape.h
)
GeomAPI_Interface.cpp
GeomAPI_Pnt.cpp
GeomAPI_Dir.cpp
+ GeomAPI_Pln.cpp
GeomAPI_Shape.cpp
)
#include "GeomAPI.h"
#include "GeomAPI_Interface.h"
#include "GeomAPI_Pnt.h"
+ #include "GeomAPI_Dir.h"
+ #include "GeomAPI_Pln.h"
#include "GeomAPI_Shape.h"
%}
// %include <boost_shared_ptr.i>
%shared_ptr(GeomAPI_Interface)
%shared_ptr(GeomAPI_Pnt)
+%shared_ptr(GeomAPI_Dir)
+%shared_ptr(GeomAPI_Pln)
%shared_ptr(GeomAPI_Shape)
// all supported interfaces
%include "GeomAPI_Interface.h"
%include "GeomAPI_Pnt.h"
+%include "GeomAPI_Dir.h"
+%include "GeomAPI_Pln.h"
%include "GeomAPI_Shape.h"
delete myImpl;
}
-void* GeomAPI_Interface::implementation()
-{
- return myImpl;
-}
-
-void GeomAPI_Interface::setImplementation(void* theImpl)
+void GeomAPI_Interface::setImpl(void* theImpl)
{
if (myImpl)
delete myImpl;
class GEOMAPI_EXPORT GeomAPI_Interface
{
protected:
- void* myImpl; ///< pointer to the internal implementation object
+ void* myImpl; ///< pointer to the internal impl object
public:
/// None - constructor
GeomAPI_Interface();
- /// Constructor by the implementation pointer (used for internal needs)
+ /// Constructor by the impl pointer (used for internal needs)
GeomAPI_Interface(void* theImpl);
/// Destructor
virtual ~GeomAPI_Interface();
- /// Returns the pointer to the implementation
- void* implementation();
- /// Updates the implementation (deletes the old one)
- void setImplementation(void* theImpl);
+ /// Returns the pointer to the impl
+ template<class T> inline T* implPtr() {return dynamic_cast<T*>(myImpl);}
+ /// Returns the reference object of the impl
+ template<class T> inline const T& impl() {return *(static_cast<T*>(myImpl));}
+ /// Updates the impl (deletes the old one)
+ void setImpl(void* theImpl);
};
#endif
-
--- /dev/null
+// File: GeomAPI_Pln.cpp
+// Created: 23 Apr 2014
+// Author: Mikhail PONIKAROV
+
+#include<GeomAPI_Pln.h>
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Dir.h>
+
+#include<gp_Pln.hxx>
+
+using namespace std;
+
+GeomAPI_Pln::GeomAPI_Pln(const shared_ptr<GeomAPI_Pnt>& thePoint,
+ const shared_ptr<GeomAPI_Dir>& theNormal)
+: GeomAPI_Interface(new gp_Pln(thePoint->impl<gp_Pnt>(),
+ theNormal->impl<gp_Dir>()))
+{
+}
+
+GeomAPI_Pln::GeomAPI_Pln(
+ const double theA, const double theB, const double theC, const double theD)
+: GeomAPI_Interface(new gp_Pln(theA, theB, theC, theD))
+{
+}
+
+shared_ptr<GeomAPI_Pnt> GeomAPI_Pln::location()
+{
+ gp_Pnt aLoc = impl<gp_Pln>().Location();
+ return shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z()));
+}
+
+shared_ptr<GeomAPI_Dir> GeomAPI_Pln::direction()
+{
+ const gp_Dir& aDir = impl<gp_Pln>().Axis().Direction();
+ return shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
+}
--- /dev/null
+// File: GeomAPI_Pln.hxx
+// Created: 23 Apr 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef GeomAPI_Pln_HeaderFile
+#define GeomAPI_Pln_HeaderFile
+
+#include <memory>
+#include <GeomAPI_Interface.h>
+
+class GeomAPI_Pnt;
+class GeomAPI_Dir;
+
+/**\class GeomAPI_Pln
+ * \ingroup DataModel
+ * \brief 3D point defined by three coordinates
+ */
+
+class GEOMAPI_EXPORT GeomAPI_Pln: public GeomAPI_Interface
+{
+public:
+ /// Creation of plane by the point and normal
+ GeomAPI_Pln(const std::shared_ptr<GeomAPI_Pnt>& thePoint,
+ const std::shared_ptr<GeomAPI_Dir>& theNormal);
+
+ /// Creation of plane by coefficients A * X + B * Y + C * Z + D = 0.0
+ GeomAPI_Pln(const double theA, const double theB, const double theC, const double theD);
+
+ /// Returns a point of this plane
+ std::shared_ptr<GeomAPI_Pnt> location();
+
+ /// Returns a plane normal
+ std::shared_ptr<GeomAPI_Dir> direction();
+};
+
+#endif
+
boost::shared_ptr<GeomAPI_Pnt> theCenter, boost::shared_ptr<GeomAPI_Dir> theNormal,
const double theSize)
{
- gp_Pnt* aCenter = static_cast<gp_Pnt*>(theCenter->implementation());
- gp_Dir* aDir = static_cast<gp_Dir*>(theNormal->implementation());
- gp_Pln aPlane(*aCenter, *aDir);
+ const gp_Pnt& aCenter = theCenter->impl<gp_Pnt>();
+ const gp_Dir& aDir = theNormal->impl<gp_Dir>();
+ gp_Pln aPlane(aCenter, aDir);
// half of the size in each direction from the center
BRepBuilderAPI_MakeFace aFaceBuilder(aPlane,
-theSize / 2., theSize / 2., -theSize / 2., theSize / 2.);
boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
- aRes->setImplementation(new TopoDS_Shape(aFaceBuilder.Face()));
+ aRes->setImpl(new TopoDS_Shape(aFaceBuilder.Face()));
return aRes;
}
* \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 implementation returns FALSE,
+ * 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.
*/
* \brief Verifies whether operator is ready to start.
* \return TRUE if operation is ready to start
*
- * Default implementation returns TRUE. Redefine this method to add own verifications
+ * Default impl returns TRUE. Redefine this method to add own verifications
*/
bool ModuleBase_Operation::isReadyToStart() const
{
* \brief Virtual method called when operation is started
*
* Virtual method called when operation started (see start() method for more description)
- * Default implementation calls corresponding slot and commits immediately.
+ * Default impl calls corresponding slot and commits immediately.
*/
void ModuleBase_Operation::startOperation()
{
myWorkshop = theWshop;
XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
- connect(anOperationMgr, SIGNAL(beforeOperationStart()), this, SLOT(onBeforeOperationStart()));
+ connect(anOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
+ connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
+ this, SLOT(onOperationStopped(ModuleBase_Operation*)));
}
PartSet_Module::~PartSet_Module()
Events_Loop::loop()->send(aMessage);
}
-/**
- * Slot that is called by the operation requiring of preview display or erase
- * \param isDisplay the display or erase state
-*/
-void PartSet_Module::onVisualizePreview(bool isDisplay)
-{
- ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
- if (!anOperation)
- return;
-
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
- if (!aPreviewOp)
- return;
-
- if (isDisplay)
- myWorkshop->displayer()->Display(anOperation->feature(), aPreviewOp->preview());
- else
- myWorkshop->displayer()->Erase(anOperation->feature(), aPreviewOp->preview());
-}
-
-void PartSet_Module::onBeforeOperationStart()
+void PartSet_Module::onOperationStarted()
{
ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (aPreviewOp) {
- connect(anOperation, SIGNAL(stopped()), this, SLOT(onOperationStopped()));
- connect(aPreviewOp, SIGNAL(visualizePreview(bool)), this, SLOT(onVisualizePreview(bool)));
connect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()),
aPreviewOp, SLOT(onViewSelectionChanged()));
+ visualizePreview(true);
}
}
-void PartSet_Module::onOperationStopped()
+void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
{
- ModuleBase_PropPanelOperation* anOperation = dynamic_cast<ModuleBase_PropPanelOperation*>(sender());
+ ModuleBase_PropPanelOperation* anOperation = dynamic_cast<ModuleBase_PropPanelOperation*>(theOperation);
if (!anOperation)
return;
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (aPreviewOp) {
- disconnect(aPreviewOp, SIGNAL(visualizePreview(bool)), this, SLOT(onVisualizePreview(bool)));
disconnect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()),
aPreviewOp, SLOT(onViewSelectionChanged()));
+ visualizePreview(false);
}
}
+
+void PartSet_Module::visualizePreview(bool isDisplay)
+{
+ ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
+ if (!anOperation)
+ return;
+
+ PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
+ if (!aPreviewOp)
+ return;
+
+ if (isDisplay)
+ myWorkshop->displayer()->Display(anOperation->feature(), aPreviewOp->preview());
+ else
+ myWorkshop->displayer()->Erase(anOperation->feature(), aPreviewOp->preview());
+}
public slots:
void onFeatureTriggered();
- void onBeforeOperationStart();
- void onOperationStopped();
- void onVisualizePreview(bool isDisplay);
+ /// SLOT, that is called after the operation is started. Perform some specific for module
+ /// actions, e.g. connect the sketch feature to the viewer selection and show the sketch preview.
+ void onOperationStarted();
+ /// SLOT, that is called after the operation is stopped. Disconnect the sketch feature
+ /// from the viewer selection and show the sketch preview.
+ void onOperationStopped(ModuleBase_Operation* theOperation);
+
+private:
+ /// Displays or erase the current operation preview, if it has it.
+ /// \param isDisplay the state whether the presentation should be displayed or erased
+ void visualizePreview(bool isDisplay);
private:
XGUI_Workshop* myWorkshop;
+// File: PartSet_OperationSketch.h
+// Created: 20 Apr 2014
+// Author: Natalia ERMOLAEVA
+
#include <PartSet_OperationSketch.h>
#include <SketchPlugin_Feature.h>
{
}
-/*!
- * \brief Destructor
- */
PartSet_OperationSketch::~PartSet_OperationSketch()
{
}
-/**
- * The sketch can not be created immediately, firstly a plane should be set
- * \return false value
- */
bool PartSet_OperationSketch::isPerformedImmediately() const
{
return false;
+// File: PartSet_OperationSketch.h
+// Created: 20 Apr 2014
+// Author: Natalia ERMOLAEVA
+
#ifndef PartSet_OperationSketch_H
#define PartSet_OperationSketch_H
/*!
\class PartSet_OperationSketch
- * \brief The operation for the sketch creation
- *
- * Base class for all operations. If you perform an action it is reasonable to create
+ * \brief The operation for the sketch feature creation
*/
class PARTSET_EXPORT PartSet_OperationSketch : public PartSet_OperationSketchBase
{
-Q_OBJECT
+ Q_OBJECT
public:
+ /// Constructor
+ /// \param theId the feature identifier
+ /// \param theParent the operation parent
PartSet_OperationSketch(const QString& theId, QObject* theParent);
+ /// Destructor
virtual ~PartSet_OperationSketch();
+ /// The sketch can not be created immediately, firstly a plane should be set
virtual bool isPerformedImmediately() const;
};
+// File: PartSet_OperationSketchBase.cpp
+// Created: 20 Apr 2014
+// Author: Natalia ERMOLAEVA
+
#include <PartSet_OperationSketchBase.h>
#include <SketchPlugin_Feature.h>
using namespace std;
-/*!
- \brief Constructor
- \param theId an feature index
- \param theParent the object parent
- */
PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId,
QObject* theParent)
: ModuleBase_PropPanelOperation(theId, theParent)
{
}
-/*!
- * \brief Destructor
- */
PartSet_OperationSketchBase::~PartSet_OperationSketchBase()
{
}
-/**
- * Returns the feature preview shape
- */
const TopoDS_Shape& PartSet_OperationSketchBase::preview() const
{
- boost::shared_ptr<SketchPlugin_Feature> aFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(feature());
- return *(static_cast<TopoDS_Shape*>(aFeature->preview()->implementation()));
-}
-
-/*!
- * Perform the operation start and emit signal about visualization of the operation preview
- */
-void PartSet_OperationSketchBase::startOperation()
-{
- ModuleBase_PropPanelOperation::startOperation();
-
- emit visualizePreview(true);
-}
-
-/*!
- * Perform the operation stop and emit signal about visualization stop of the operation preview
- */
-void PartSet_OperationSketchBase::stopOperation()
-{
- ModuleBase_PropPanelOperation::stopOperation();
-
- emit visualizePreview(false);
+ boost::shared_ptr<SketchPlugin_Feature> aFeature =
+ boost::dynamic_pointer_cast<SketchPlugin_Feature>(feature());
+ return aFeature->preview()->impl<TopoDS_Shape>();
}
+// File: PartSet_OperationSketchBase.h
+// Created: 20 Apr 2014
+// Author: Natalia ERMOLAEVA
+
#ifndef PartSet_OperationSketchBase_H
#define PartSet_OperationSketchBase_H
#include <QObject>
/*!
- \class PartSet_OperationSketchBase
- * \brief The base operation for the sketch features.
- *
- * Base class for all sketch operations. It provides an access to the feature preview
+ \class PartSet_OperationSketchBase
+ * \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
{
-Q_OBJECT
+ Q_OBJECT
public:
+ /// Constructor
+ /// \param theId an feature index
+ /// \param theParent the object parent
PartSet_OperationSketchBase(const QString& theId, QObject* theParent);
+ /// Destructor
virtual ~PartSet_OperationSketchBase();
+ /// Returns the feature preview shape
const TopoDS_Shape& preview() const;
-
-signals:
- /**
- * The signal about preview visualization.
- * \param isDisplay a state whether the preview should be displayed or erased
- */
- void visualizePreview(bool isDisplay);
-
-protected:
- virtual void startOperation();
- virtual void stopOperation();
};
#endif
#include "SketchPlugin_Feature.h"
-/**
- * Returns the sketch preview
- */
-const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Feature::preview()
+void SketchPlugin_Feature::setPreview(const boost::shared_ptr<GeomAPI_Shape>& theShape)
{
- return myPreview;
+ myPreview = theShape;
}
-/**
- * Set the shape to the internal preview field
- * \param theShape a preview shape
- */
-void SketchPlugin_Feature::setPreview(const boost::shared_ptr<GeomAPI_Shape>& theShape)
+const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Feature::getPreview() const
{
- myPreview = theShape;
+ return myPreview;
}
/**\class SketchPlugin_Feature
* \ingroup DataModel
- * \brief Feature for creation of the new part in PartSet.
+ * \brief Feature for creation of the new feature in PartSet. This is an abstract class to give
+ * an interface to create the sketch feature preview.
*/
class SketchPlugin_Feature: public ModelAPI_Feature
{
public:
- SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview() = 0;
+ /// Returns the sketch preview
+ /// \return the built preview
+ SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview() = 0;
protected:
+ /// Set the shape to the internal preview field
+ /// \param theShape a preview shape
void setPreview(const boost::shared_ptr<GeomAPI_Shape>& theShape); ///< the preview shape
+ /// Return the shape from the internal preview field
+ /// \return theShape a preview shape
+ const boost::shared_ptr<GeomAPI_Shape>& getPreview() const;
private:
boost::shared_ptr<GeomAPI_Shape> myPreview; ///< the preview shape
const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Sketch::preview()
{
- if (!SketchPlugin_Feature::preview())
- {
-
- boost::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
- boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(1, 0, 0));
- boost::shared_ptr<GeomAPI_Shape> aFace =
- GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE);
- setPreview(aFace);
- }
- return SketchPlugin_Feature::preview();
+ boost::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
+ boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(1, 0, 0));
+ boost::shared_ptr<GeomAPI_Shape> aFace =
+ GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE);
+ setPreview(aFace);
+
+ return getPreview();
}
+// File: XGUI_Displayer.cpp
+// Created: 20 Apr 2014
+// Author: Natalia ERMOLAEVA
+
#include "XGUI_Displayer.h"
-#include "XGUI_Tools.h"
#include "XGUI_Viewer.h"
#include <ModelAPI_Document.h>
#include <AIS_InteractiveContext.hxx>
#include <AIS_Shape.hxx>
-/*!
- \brief Constructor
- */
XGUI_Displayer::XGUI_Displayer(XGUI_Viewer* theViewer)
: myViewer(theViewer)
{
}
-/*!
- \brief Destructor
- */
XGUI_Displayer::~XGUI_Displayer()
{
}
-/*!
- * Display the feature
- * \param theFeature a feature instance
- */
void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature)
{
}
-/*!
- * Display the feature and a shape. This shape would be associated to the given feature
- * \param theFeature a feature instance
- * \param theFeature a shape
- */
void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature,
const TopoDS_Shape& theShape)
{
aContext->UpdateCurrentViewer();
}
-/*!
- * Erase the feature and a shape.
- * \param theFeature a feature instance
- * \param theFeature a shape
- */
void XGUI_Displayer::Erase(boost::shared_ptr<ModelAPI_Feature> theFeature,
const TopoDS_Shape& theShape)
{
+// File: XGUI_Displayer.h
+// Created: 20 Apr 2014
+// Author: Natalia ERMOLAEVA
+
#ifndef XGUI_Displayer_H
#define XGUI_Displayer_H
/**\class XGUI_Displayer
* \ingroup GUI
- * \brief Displayer. Provides mechanizm of displa/erase of objects in viewer
+ * \brief Displayer. Provides mechanizm of display/erase of objects in the viewer
*/
class XGUI_EXPORT XGUI_Displayer
{
public:
+ /// Constructor
+ /// \param theViewer the viewer
XGUI_Displayer(XGUI_Viewer* theViewer);
+ /// Destructor
virtual ~XGUI_Displayer();
+ /// Display the feature. Obtain the visualized object from the feature.
+ /// \param theFeature a feature instance
void Display(boost::shared_ptr<ModelAPI_Feature> theFeature);
+ /// Display the feature and a shape. This shape would be associated to the given feature
+ /// \param theFeature a feature instance
+ /// \param theFeature a shape
void Display(boost::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape);
+ /// Erase the feature and a shape.
+ /// \param theFeature a feature instance
+ /// \param theFeature a shape
void Erase(boost::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape);
protected:
- XGUI_Viewer* myViewer; ///< the viewer
+ XGUI_Viewer* myViewer; ///< the viewer where the objects should be visualized
};
#endif
+// File: XGUI_OperationMgr.h
+// Created: 20 Apr 2014
+// Author: Natalia ERMOLAEVA
+
#include "XGUI_OperationMgr.h"
#include "ModuleBase_Operation.h"
#include <QMessageBox>
-/*!
- \brief Constructor
- */
XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent)
: QObject(theParent)
{
}
-/*!
- \brief Destructor
- */
XGUI_OperationMgr::~XGUI_OperationMgr()
{
}
-/*!
- \brief Returns the current operation or NULL
- * \return the current operation
- */
ModuleBase_Operation* XGUI_OperationMgr::currentOperation() const
{
return myOperations.count() > 0 ? myOperations.last() : 0;
}
-/*!
- \brief Sets the current operation or NULL
- * \return the current operation
- */
bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation)
{
if (!canStartOperation(theOperation))
return false;
myOperations.append(theOperation);
- emit beforeOperationStart();
connect(theOperation, SIGNAL(stopped()), this, SLOT(onOperationStopped()));
- theOperation->start();
+ connect(theOperation, SIGNAL(started()), this, SIGNAL(operationStarted()));
- emit afterOperationStart();
+ theOperation->start();
return true;
}
return aCanStart;
}
-void XGUI_OperationMgr::commitCurrentOperation()
-{
- ModuleBase_Operation* anOperation = currentOperation();
- if (!anOperation)
- return;
-
- anOperation->commit();
-}
-
void XGUI_OperationMgr::onOperationStopped()
{
ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
if (!aSenderOperation || !anOperation || aSenderOperation != anOperation )
return;
+ emit operationStopped(anOperation);
+
myOperations.removeAll(anOperation);
+ anOperation->deleteLater();
// get last operation which can be resumed
ModuleBase_Operation* aResultOp = 0;
+// File: XGUI_OperationMgr.h
+// Created: 20 Apr 2014
+// Author: Natalia ERMOLAEVA
+
#ifndef XGUI_OperationMgr_H
#define XGUI_OperationMgr_H
/**\class XGUI_OperationMgr
* \ingroup GUI
* \brief Operation manager. Servers to manupulate to the workshop operations. Contains a stack
- * of started operations and uses the upper one as a current.
+ * of started operations. In simple case, if only one operration is started, the stack contains
+ * one operation. It is possible for some kind of operations to start them above already
+ * started one. In that case, the previous active operation becames suspended, a new one - active.
+ * The new operation is added to the top of the stack. Then it is finished, it is removed from
+ * the stack and the previous operation is activated.
*/
class XGUI_EXPORT XGUI_OperationMgr : public QObject
{
Q_OBJECT
public:
+ /// Constructor
+ /// \param theParent the parent
XGUI_OperationMgr(QObject* theParent);
+ /// Destructor
virtual ~XGUI_OperationMgr();
+ /// Returns the current operation or NULL
+ /// \return the current operation
ModuleBase_Operation* currentOperation() const;
+ /// Sets the current operation or NULL
+ /// \return the current operation
bool startOperation(ModuleBase_Operation* theOperation);
- void commitCurrentOperation();
-
signals:
- void beforeOperationStart();
- void afterOperationStart();
+ /// Signal about an operation is started. It is emitted after the start() of operation is done.
+ void operationStarted();
+ /// Signal about an operation is stopped. It is emitted after the stop() of operation is done.
+ /// \param theOperation a stopped operation
+ void operationStopped(ModuleBase_Operation* theOperation);
protected:
+ /// Returns whether the operation can be started. Check if there is already started operation and
+ /// the granted parameter of the launched operation
+ /// \param theOperation an operation to check
bool canStartOperation(ModuleBase_Operation* theOperation);
protected slots:
+ /// Slot that is called by an operation stop. Removes the stopped operation form the stack.
+ /// If there is a suspended operation, restart it.
void onOperationStopped();
private:
- typedef QList<ModuleBase_Operation*> Operations;
- Operations myOperations;
+ typedef QList<ModuleBase_Operation*> Operations; ///< definition for a list of operations
+ Operations myOperations; ///< a stack of started operations. The active operation is on top,
+ // others are suspended and started by the active is finished
};
#endif
XGUI_TopDataModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent);
virtual ~XGUI_TopDataModel();
- // Reimplementation from QAbstractItemModel
+ // Reimpl from QAbstractItemModel
virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
virtual QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
XGUI_PartDataModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent);
virtual ~XGUI_PartDataModel();
- // Reimplementation from QAbstractItemModel
+ // Reimpl from QAbstractItemModel
virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
virtual QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
mySelector = new XGUI_SelectionMgr(this);
myDisplayer = new XGUI_Displayer(myMainWindow->viewer());
myOperationMgr = new XGUI_OperationMgr(this);
- connect(myOperationMgr, SIGNAL(beforeOperationStart()), this, SLOT(onBeforeOperationStart()));
- connect(myOperationMgr, SIGNAL(afterOperationStart()), this, SLOT(onAfterOperationStart()));
+ connect(myOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
+ connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
+ this, SLOT(onOperationStopped(ModuleBase_Operation*)));
}
//******************************************************
ModuleBase_PropPanelOperation* anOperation =
(ModuleBase_PropPanelOperation*)(aPartSetMsg->pointer());
- if (myOperationMgr->startOperation(anOperation))
- {
- if (anOperation->isPerformedImmediately())
- {
- myOperationMgr->commitCurrentOperation();
+ if (myOperationMgr->startOperation(anOperation)) {
+ if (anOperation->isPerformedImmediately()) {
+ anOperation->commit();
updateCommandStatus();
}
- /*if(anOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
- //connectToPropertyPanel(anOperation);
-
- anOperation->start();
-
- if (anOperation->isPerformedImmediately()) {
- anOperation->commit();
- updateCommandStatus();
- }
- } else {
- connectToPropertyPanel(anOperation);
- QWidget* aPropWidget = myMainWindow->findChild<QWidget*>(XGUI::PROP_PANEL_WDG);
- qDeleteAll(aPropWidget->children());
-
- anOperation->start();
-
- XGUI_WidgetFactory aFactory = XGUI_WidgetFactory(anOperation);
- aFactory.createWidget(aPropWidget);
- myMainWindow->setPropertyPannelTitle(anOperation->description());
- }*/
}
return;
}
}
-void XGUI_Workshop::onBeforeOperationStart()
+//******************************************************
+void XGUI_Workshop::onOperationStarted()
{
ModuleBase_PropPanelOperation* aOperation =
(ModuleBase_PropPanelOperation*)(myOperationMgr->currentOperation());
if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
- //myPartSetModule->connectToPropertyPanel(aOperation);
} else {
connectWithOperation(aOperation);
QWidget* aPropWidget = myMainWindow->findChild<QWidget*>(XGUI::PROP_PANEL_WDG);
qDeleteAll(aPropWidget->children());
- }
-}
-void XGUI_Workshop::onAfterOperationStart()
-{
- ModuleBase_PropPanelOperation* aOperation =
- (ModuleBase_PropPanelOperation*)(myOperationMgr->currentOperation());
+ myMainWindow->showPropertyPanel();
- if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
- } else {
XGUI_WidgetFactory aFactory = XGUI_WidgetFactory(aOperation);
- QWidget* aPropWidget = myMainWindow->findChild<QWidget*>(XGUI::PROP_PANEL_WDG);
aFactory.createWidget(aPropWidget);
myMainWindow->setPropertyPannelTitle(aOperation->description());
}
}
+//******************************************************
+void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
+{
+ myMainWindow->hidePropertyPanel();
+ updateCommandStatus();
+
+ XGUI_MainMenu* aMenu = myMainWindow->menuObject();
+ aMenu->restoreCommandState();
+}
+
/*
*
*/
myPartSetModule->featureCreated(aCommand);
}
-/*
- *
- */
-/*void XGUI_Workshop::fillPropertyPanel(ModuleBase_PropPanelOperation* theOperation)
-{
- connectWithOperation(theOperation);
- QWidget* aPropWidget = myMainWindow->findChild<QWidget*>(XGUI::PROP_PANEL_WDG);
- qDeleteAll(aPropWidget->children());
- theOperation->start();
- XGUI_WidgetFactory aFactory = XGUI_WidgetFactory(theOperation);
- aFactory.createWidget(aPropWidget);
- myMainWindow->setPropertyPannelTitle(theOperation->description());
-}*/
-
/*
* Makes a signal/slot connections between Property Panel
* and given operation. The given operation becomes a
QPushButton* aCancelBtn = aPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
connect(aCancelBtn, SIGNAL(clicked()), theOperation, SLOT(abort()));
- connect(theOperation, SIGNAL(started()), myMainWindow, SLOT(showPropertyPanel()));
- connect(theOperation, SIGNAL(stopped()), myMainWindow, SLOT(hidePropertyPanel()));
- connect(theOperation, SIGNAL(stopped()), this, SLOT(updateCommandStatus()));
-
XGUI_MainMenu* aMenu = myMainWindow->menuObject();
- connect(theOperation, SIGNAL(stopped()), aMenu, SLOT(restoreCommandState()));
-
XGUI_Command* aCommand = aMenu->feature(theOperation->operationId());
//Abort operation on uncheck the command
connect(aCommand, SIGNAL(toggled(bool)), theOperation, SLOT(setRunning(bool)));
void connectWithOperation(ModuleBase_Operation* theOperation);
protected slots:
- void onBeforeOperationStart();
- void onAfterOperationStart();
+ /// SLOT, that is called after the operation is started. Update workshop state according to
+ /// the started operation, e.g. visualizes the property panel and connect to it.
+ void onOperationStarted();
+ /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
+ /// hides the property panel and udpate the command status.
+ /// \param theOpertion a stopped operation
+ void onOperationStopped(ModuleBase_Operation* theOperation);
private:
void initMenu();
XGUI_SelectionMgr* mySelector;
XGUI_Displayer* myDisplayer;
- XGUI_OperationMgr* myOperationMgr;
+ XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
};
#endif