]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 24 Apr 2014 08:41:40 +0000 (12:41 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 24 Apr 2014 08:41:40 +0000 (12:41 +0400)
25 files changed:
src/Config/Config_XMLReader.cpp
src/GeomAPI/CMakeLists.txt
src/GeomAPI/GeomAPI.i
src/GeomAPI/GeomAPI_Interface.cpp
src/GeomAPI/GeomAPI_Interface.h
src/GeomAPI/GeomAPI_Pln.cpp [new file with mode: 0644]
src/GeomAPI/GeomAPI_Pln.h [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp
src/ModuleBase/ModuleBase_Operation.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h
src/PartSet/PartSet_OperationSketchBase.cpp
src/PartSet/PartSet_OperationSketchBase.h
src/SketchPlugin/SketchPlugin_Feature.cpp
src/SketchPlugin/SketchPlugin_Feature.h
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_OperationMgr.h
src/XGUI/XGUI_PartDataModel.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index f804cd501bb5a949144625764274b33b623012eb..3f07973dfe0889050628ac957f6485adc400caa6 100644 (file)
@@ -58,7 +58,7 @@ void Config_XMLReader::readAll()
 
 /*
  * 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)
@@ -72,7 +72,7 @@ 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)
 {
index 15162678616da2275f604cd114e5b2c174ecfe3d..c0c67230e5acef38e77d47571e39a9bc30fc9527 100644 (file)
@@ -9,6 +9,7 @@ SET(PROJECT_HEADERS
     GeomAPI_Interface.h
     GeomAPI_Pnt.h
     GeomAPI_Dir.h
+    GeomAPI_Pln.h
     GeomAPI_Shape.h
 )
 
@@ -16,6 +17,7 @@ SET(PROJECT_SOURCES
     GeomAPI_Interface.cpp
     GeomAPI_Pnt.cpp
     GeomAPI_Dir.cpp
+    GeomAPI_Pln.cpp
     GeomAPI_Shape.cpp
 )
 
index 3f65f05f21ba8978b0bdeec124704d11051ce7bd..67d8297f7baa307eb1c14caacba98ca43a264dd8 100644 (file)
@@ -5,6 +5,8 @@
   #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"
index 5e9b257fbb17a6436d864d3ce921126caf2b59e5..a583aa564cb499f9022c84ad94de9169f3d5da48 100644 (file)
@@ -20,12 +20,7 @@ GeomAPI_Interface::~GeomAPI_Interface()
     delete myImpl;
 }
 
-void* GeomAPI_Interface::implementation()
-{
-  return myImpl;
-}
-
-void GeomAPI_Interface::setImplementation(void* theImpl)
+void GeomAPI_Interface::setImpl(void* theImpl)
 {
   if (myImpl)
     delete myImpl;
index 1a605595bf5445069eb36a7c5a25e089337ea1b3..bd9a77ab13078880e6a961b4a9ab86df08e55900 100644 (file)
 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
-
diff --git a/src/GeomAPI/GeomAPI_Pln.cpp b/src/GeomAPI/GeomAPI_Pln.cpp
new file mode 100644 (file)
index 0000000..d6b476c
--- /dev/null
@@ -0,0 +1,36 @@
+// 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()));
+}
diff --git a/src/GeomAPI/GeomAPI_Pln.h b/src/GeomAPI/GeomAPI_Pln.h
new file mode 100644 (file)
index 0000000..49b4a9d
--- /dev/null
@@ -0,0 +1,37 @@
+// 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
+
index 642e90996af905bf1de718affb8156547e6417c4..4b2ebc4d26b6adfd3ca7c27a2e31b08961348584 100644 (file)
@@ -11,13 +11,13 @@ boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::square(
   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;
 }
index 8a1ddc82d8026a2fd0e0da390f0e1ccbe2a02985..76459c132203a50b7d311cc2f89c6a73d67885c3 100644 (file)
@@ -100,7 +100,7 @@ bool ModuleBase_Operation::isValid(ModuleBase_Operation*) const
  * \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.
  */
@@ -268,7 +268,7 @@ void ModuleBase_Operation::storeReal(double theValue)
  * \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
 {
@@ -279,7 +279,7 @@ 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()
 {
index a4e64417be2e86752d8a2af7296b62c42d2cdb2d..2b2a3ddb10be1e020ff46fa80f2b3a08ac3e16d5 100644 (file)
@@ -34,7 +34,9 @@ PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop)
   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()
@@ -90,49 +92,44 @@ void PartSet_Module::onFeatureTriggered()
   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());
+}
index dc22f1f440137b4a13912da4ca494081584acf26..60f78835cc6251f8be2cb3f07c7d6c1d8fbcfcd7 100644 (file)
@@ -22,9 +22,17 @@ public:
 
 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;
index 3b4e5bd8d89b49ab98a2a5e8c4f1175ce350a656..a12c38b0a4cdc8e7264b20a06e4ee9a1259dc038 100644 (file)
@@ -1,3 +1,7 @@
+// File:        PartSet_OperationSketch.h
+// Created:     20 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
 #include <PartSet_OperationSketch.h>
 
 #include <SketchPlugin_Feature.h>
@@ -14,17 +18,10 @@ PartSet_OperationSketch::PartSet_OperationSketch(const QString& theId,
 {
 }
 
-/*!
- * \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;
index 679f74afa739013a653404c2612d27f99c48732c..63375e5e60bae4cbe03c5c384b82e99fca12a185 100644 (file)
@@ -1,3 +1,7 @@
+// 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;
 };
 
index ec0d695d529d49eaf43aa6d4bb347b3663931221..519c97f76d5335d3def922e4158b77de59982c2f 100644 (file)
@@ -1,3 +1,7 @@
+// 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>();
 }
index de7c1ce03e4f647b1a7163f30bc55351c14718e9..1a99babc94de8702687a8af90ff1981150952988 100644 (file)
@@ -1,3 +1,7 @@
+// 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
index 8586525f792f4a46811caef7d1c1bfaaaae2201d..e7d9d292ac90e44937429ac44a5ea2fb23052938 100644 (file)
@@ -1,18 +1,11 @@
 #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;
 }
index 964abe80e4f8b97c299afb162abcfbb95146b044..2bb33c268c36be267526e0b38cfa6aca00640d30 100644 (file)
 
 /**\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
index f450ec74660b28ce3eaa72c5bd68d5a50e6a595b..5a597ebf627d43d248aa333d36149b23610a8ac4 100644 (file)
@@ -26,14 +26,11 @@ void SketchPlugin_Sketch::execute()
 
 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();
 }
index 8fb825b5bd30d03e02fb398fc82a8d14f012de68..489d0248e0bdc4222c8939251a35ab8f38ffc8d0 100644 (file)
@@ -1,5 +1,8 @@
+// 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)
 {
@@ -46,11 +34,6 @@ void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature,
   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)
 {
index dc09d99bd06da1a1cedfb6852e0327aad04a4c52..06ebcba1ef5f9ba567a5324d15e299be37dd7b89 100644 (file)
@@ -1,3 +1,7 @@
+// File:        XGUI_Displayer.h
+// Created:     20 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
 #ifndef XGUI_Displayer_H
 #define XGUI_Displayer_H
 
@@ -13,22 +17,33 @@ class ModelAPI_Feature;
 
 /**\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
index ae5aeb04732b065d042ee57b34a82ad61e128894..aeb0ed3c06533a771a44873994117795ae04193f 100644 (file)
@@ -1,49 +1,38 @@
+// 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;
 }
 
@@ -64,15 +53,6 @@ bool XGUI_OperationMgr::canStartOperation(ModuleBase_Operation* theOperation)
   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());
@@ -80,7 +60,10 @@ void XGUI_OperationMgr::onOperationStopped()
   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;
index 4fabac82118e340dbf2c05d223a7a71716969e06..ef06d7da70ecb43514771aded8985b5825d71edb 100644 (file)
@@ -1,3 +1,7 @@
+// 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
index f81f303f40fe36c4fb5611c328f859cf9e81249f..e1f0246ef732636aa0f825c1c16ab6539a685c40 100644 (file)
@@ -17,7 +17,7 @@ public:
   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;
@@ -66,7 +66,7 @@ public:
   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;
index eb4552d96161ab6d21ae48bc83026b93c19dc00d..f653683a1d478f76a4cdf8f3e438da33ab6dfd71 100644 (file)
@@ -50,8 +50,9 @@ XGUI_Workshop::XGUI_Workshop()
   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*)));
 }
 
 //******************************************************
@@ -156,33 +157,11 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
     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;
   }
@@ -194,34 +173,36 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
 
 }
 
-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();
+}
+
 /*
  *
  */
@@ -259,20 +240,6 @@ void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage)
   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
@@ -286,13 +253,7 @@ void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
   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)));
index f61f6e1b10f9d212aafcdb0b4524f8b6b53fc079..6c9034d49e30d95b990a8cade7b9627bea1f6db5 100644 (file)
@@ -75,8 +75,13 @@ protected:
   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();
@@ -90,7 +95,7 @@ private:
   XGUI_SelectionMgr* mySelector;
   XGUI_Displayer* myDisplayer;
 
-  XGUI_OperationMgr* myOperationMgr;
+  XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
 };
 
 #endif