]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
authornds <natalia.donis@opencascade.com>
Mon, 5 May 2014 15:44:56 +0000 (19:44 +0400)
committernds <natalia.donis@opencascade.com>
Mon, 5 May 2014 15:44:56 +0000 (19:44 +0400)
Edit line.

13 files changed:
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationEditLine.cpp [new file with mode: 0644]
src/PartSet/PartSet_OperationEditLine.h [new file with mode: 0644]
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h
src/PartSet/PartSet_OperationSketchBase.h
src/PartSet/PartSet_OperationSketchLine.cpp
src/PartSet/PartSet_OperationSketchLine.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_Workshop.cpp

index 3744b2d4c831579b16370f16a1d6ed53b0ddb8e0..2f4c40ba7c8601e70570c429ae7f63d996a3745c 100644 (file)
@@ -7,6 +7,7 @@ SET(PROJECT_HEADERS
        PartSet.h
        PartSet_Listener.h
        PartSet_Module.h
+       PartSet_OperationEditLine.h
        PartSet_OperationSketchBase.h
        PartSet_OperationSketch.h
        PartSet_OperationSketchLine.h
@@ -16,6 +17,7 @@ SET(PROJECT_HEADERS
 SET(PROJECT_SOURCES
        PartSet_Listener.cpp
        PartSet_Module.cpp
+       PartSet_OperationEditLine.cpp
        PartSet_OperationSketchBase.cpp
        PartSet_OperationSketch.cpp
        PartSet_OperationSketchLine.cpp
index 4a0c54e5b08f7bdd36ac9d80ede08c07c5558806..bb9556b44a11bf06920cf114d1130e3d5b782d22 100644 (file)
@@ -1,6 +1,7 @@
 #include <PartSet_Module.h>
 #include <PartSet_OperationSketch.h>
 #include <PartSet_OperationSketchLine.h>
+#include <PartSet_OperationEditLine.h>
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_OperationDescription.h>
 #include <PartSet_Listener.h>
@@ -105,34 +106,8 @@ void PartSet_Module::onFeatureTriggered()
   
 void PartSet_Module::launchOperation(const QString& theCmdId)
 {
-  std::string aStdCmdId = theCmdId.toStdString();
-  std::string aPluginFileName = featureFile(aStdCmdId);
-  Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName);
-  aWdgReader.readAll();
-  std::string aXmlCfg = aWdgReader.featureWidgetCfg(aStdCmdId);
-  std::string aDescription = aWdgReader.featureDescription(aStdCmdId);
-  ModuleBase_Operation* aPartSetOp;
-  if (theCmdId == "Sketch" ) {
-    aPartSetOp = new PartSet_OperationSketch(theCmdId, this);
-  }
-  else if(theCmdId == "SketchLine") {
-    ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
-    boost::shared_ptr<ModelAPI_Feature> aSketchFeature;
-    if (anOperation)
-      aSketchFeature = anOperation->feature();
-    aPartSetOp = new PartSet_OperationSketchLine(theCmdId, this, aSketchFeature);
-  }
-  else {
-    aPartSetOp = new ModuleBase_Operation(theCmdId, this);
-  }
-  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");
-  Config_PointerMessage aMessage(aModuleEvent, this);
-  aMessage.setPointer(aPartSetOp);
-  Events_Loop::loop()->send(aMessage);
+  ModuleBase_Operation* anOperation = createOperation(theCmdId);
+  sendOperation(anOperation);
 }
 
 void PartSet_Module::onOperationStarted()
@@ -150,6 +125,9 @@ void PartSet_Module::onOperationStarted()
     if (aSketchOp) {
       connect(aSketchOp, SIGNAL(planeSelected(double, double, double)),
               this, SLOT(onPlaneSelected(double, double, double)));
+      connect(aSketchOp, SIGNAL(launchOperation(std::string, boost::shared_ptr<ModelAPI_Feature>)),
+              this, SLOT(onLaunchOperation(std::string, boost::shared_ptr<ModelAPI_Feature>)));
+
     }
   }
 }
@@ -172,7 +150,14 @@ void PartSet_Module::onSelectionChanged()
     if (aSelector) {
       NCollection_List<TopoDS_Shape> aList;
       aSelector->selectedShapes(aList);
-      aPreviewOp->setSelectedShapes(aList);
+
+      XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+      boost::shared_ptr<ModelAPI_Feature> aFeature;
+      if (!aList.IsEmpty()) {
+        const TopoDS_Shape& aShape = aList.First();
+        aFeature = aDisplayer->GetFeature(aShape);
+        aPreviewOp->setSelected(aFeature, aShape);
+      }
     }
   }
 }
@@ -225,7 +210,6 @@ void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
   if (anOperation) {
     PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
     if (aPreviewOp) {
-      aPreviewOp->setEditMode(true);
       visualizePreview(aPreviewOp->feature(), false);
     }
   }
@@ -233,6 +217,17 @@ void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
   myWorkshop->actionsMgr()->setNestedActionsEnabled(true);
 }
 
+void PartSet_Module::onLaunchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature)
+{
+  ModuleBase_Operation* anOperation = createOperation(theName.c_str());
+  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
+  if (aPreviewOp)
+  {
+    aPreviewOp->init(theFeature);
+  }
+  sendOperation(anOperation);
+}
+
 void PartSet_Module::onFeatureConstructed(boost::shared_ptr<ModelAPI_Feature> theFeature,
                                           int theMode)
 {
@@ -240,6 +235,48 @@ void PartSet_Module::onFeatureConstructed(boost::shared_ptr<ModelAPI_Feature> th
   visualizePreview(theFeature, isDisplay);
 }
 
+ModuleBase_Operation* PartSet_Module::createOperation(const QString& theCmdId)
+{
+  std::string aStdCmdId = theCmdId.toStdString();
+  if (aStdCmdId == "EditLine")
+    aStdCmdId = "SketchLine";
+  std::string aPluginFileName = featureFile(aStdCmdId);
+  Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName);
+  aWdgReader.readAll();
+  std::string aXmlCfg = aWdgReader.featureWidgetCfg(aStdCmdId);
+  std::string aDescription = aWdgReader.featureDescription(aStdCmdId);
+  ModuleBase_Operation* anOperation;
+  if (theCmdId == "Sketch" ) {
+    anOperation = new PartSet_OperationSketch(theCmdId, this);
+  }
+  else if(theCmdId == "SketchLine" || theCmdId == "EditLine") {
+    ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
+    boost::shared_ptr<ModelAPI_Feature> aSketchFeature;
+    if (aCurOperation)
+      aSketchFeature = aCurOperation->feature();
+    if (theCmdId == "SketchLine")
+      anOperation = new PartSet_OperationSketchLine(theCmdId, this, aSketchFeature);
+    else
+      anOperation = new PartSet_OperationEditLine(theCmdId, this, aSketchFeature);
+  }
+  else {
+    anOperation = new ModuleBase_Operation(theCmdId, this);
+  }
+  anOperation->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg));
+  anOperation->getDescription()->setDescription(QString::fromStdString(aDescription));
+
+  return anOperation;
+}
+
+void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation)
+{
+  //TODO(sbh): Implement static method to extract event id [SEID]
+  static Events_ID aModuleEvent = Events_Loop::eventByName("PartSetModuleEvent");
+  Config_PointerMessage aMessage(aModuleEvent, this);
+  aMessage.setPointer(theOperation);
+  Events_Loop::loop()->send(aMessage);
+}
+
 void PartSet_Module::visualizePreview(boost::shared_ptr<ModelAPI_Feature> theFeature, bool isDisplay)
 {
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
index 1f3197bd9def09569990acdb8f1b3a39b535dc30..8f0a0b086d86b13e44640dc61f0df152035fafb1 100644 (file)
@@ -31,6 +31,8 @@ public:
   virtual QStringList nestedFeatures(QString theFeature);
   std::string featureFile(const std::string&);
 
+  /// Creates an operation and send it to loop
+  /// \param theCmdId the operation name
   virtual void launchOperation(const QString& theCmdId);
 
   /// Displays or erase the current operation preview, if it has it.
@@ -69,11 +71,21 @@ public slots:
   /// \param theZ the Z projection value
   void onPlaneSelected(double theX, double theY, double theZ);
 
+  void onLaunchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature);
+
   /// SLOT, to visualize the feature in another local context mode
   /// \param theFeature the feature to be put in another local context mode
   /// \param theMode the mode appeared on the feature
   void onFeatureConstructed(boost::shared_ptr<ModelAPI_Feature> theFeature,
                             int theMode);
+protected:
+  /// Creates a new operation
+  /// \param theCmdId the operation name
+  ModuleBase_Operation* createOperation(const QString& theCmdId);
+
+  /// Sends the operation
+  /// \param theOperation the operation
+  void sendOperation(ModuleBase_Operation* theOperation);
 
 private:
   XGUI_Workshop* myWorkshop;
diff --git a/src/PartSet/PartSet_OperationEditLine.cpp b/src/PartSet/PartSet_OperationEditLine.cpp
new file mode 100644 (file)
index 0000000..72020fb
--- /dev/null
@@ -0,0 +1,206 @@
+// File:        PartSet_OperationEditLine.h
+// Created:     05 May 2014
+// Author:      Natalia ERMOLAEVA
+
+#include <PartSet_OperationEditLine.h>
+
+#include <SketchPlugin_Feature.h>
+#include <GeomDataAPI_Point2D.h>
+#include <GeomDataAPI_Point.h>
+#include <GeomDataAPI_Dir.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
+
+#include <SketchPlugin_Sketch.h>
+#include <SketchPlugin_Line.h>
+
+#ifdef _DEBUG
+#include <QDebug>
+#endif
+
+using namespace std;
+
+PartSet_OperationEditLine::PartSet_OperationEditLine(const QString& theId,
+                                                 QObject* theParent,
+                                              boost::shared_ptr<ModelAPI_Feature> theFeature)
+: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature)
+{
+}
+
+PartSet_OperationEditLine::~PartSet_OperationEditLine()
+{
+}
+
+bool PartSet_OperationEditLine::isGranted() const
+{
+  return true;
+}
+
+std::list<int> PartSet_OperationEditLine::getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const
+{
+  std::list<int> aModes;
+  //if (theFeature != feature())
+  //  aModes.push_back(TopAbs_VERTEX);
+  return aModes;
+}
+
+void PartSet_OperationEditLine::init(boost::shared_ptr<ModelAPI_Feature> theFeature)
+{
+  setFeature(theFeature);
+}
+
+void PartSet_OperationEditLine::mouseReleased(const gp_Pnt& thePoint)
+{
+  /*switch (myPointSelectionMode)
+  {
+    case SM_FirstPoint: {
+      setLinePoint(thePoint, LINE_ATTR_START);
+      myPointSelectionMode = SM_SecondPoint;
+    }
+    break;
+    case SM_SecondPoint: {
+      setLinePoint(thePoint, LINE_ATTR_END);
+      myPointSelectionMode = SM_None;
+    }
+    break;
+    case SM_None: {
+
+    }
+    break;
+    default:
+      break;
+  }
+*/
+}
+
+void PartSet_OperationEditLine::mouseMoved(const gp_Pnt& thePoint)
+{
+/*  switch (myPointSelectionMode)
+  {
+    case SM_SecondPoint:
+      setLinePoint(thePoint, LINE_ATTR_END);
+      break;
+    case SM_None: {
+      boost::shared_ptr<ModelAPI_Feature> aPrevFeature = feature();
+      // stop the last operation
+      commitOperation();
+      document()->finishOperation();
+      //emit changeSelectionMode(aPrevFeature, TopAbs_VERTEX);
+      // start a new operation
+      document()->startOperation();
+      startOperation();
+      // use the last point of the previous feature as the first of the new one
+      setLinePoint(aPrevFeature, LINE_ATTR_END, LINE_ATTR_START);
+      myPointSelectionMode = SM_SecondPoint;
+
+      emit featureConstructed(aPrevFeature, FM_Deactivation);
+    }
+    break;
+    default:
+      break;
+  }
+*/
+}
+
+void PartSet_OperationEditLine::keyReleased(const int theKey)
+{
+/*  switch (theKey) {
+    case Qt::Key_Escape: {
+      if (myPointSelectionMode != SM_None)
+        emit featureConstructed(feature(), FM_Abort);
+      abort();
+    }
+    break;
+    case Qt::Key_Return: {
+      if (myPointSelectionMode != SM_None) {
+        emit featureConstructed(feature(), FM_Abort);
+        myPointSelectionMode = SM_FirstPoint;
+        document()->abortOperation();
+      }
+      else
+        myPointSelectionMode = SM_FirstPoint;
+    }
+    break;
+    default:
+    break;
+  }
+  */
+}
+
+void PartSet_OperationEditLine::setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
+                                            const TopoDS_Shape& theShape)
+{
+  if (theFeature == feature())
+    return;
+
+  commit();
+
+  if (theFeature)
+    emit launchOperation("EditLine", theFeature);
+}
+
+void PartSet_OperationEditLine::startOperation()
+{
+  //PartSet_OperationSketchBase::startOperation();
+  //myPointSelectionMode = SM_FirstPoint;
+}
+
+void PartSet_OperationEditLine::stopOperation()
+{
+  PartSet_OperationSketchBase::stopOperation();
+  //myPointSelectionMode = SM_None;
+}
+
+boost::shared_ptr<ModelAPI_Feature> PartSet_OperationEditLine::createFeature()
+{
+  return boost::shared_ptr<ModelAPI_Feature>();
+}
+
+void PartSet_OperationEditLine::setLinePoint(const gp_Pnt& thePoint,
+                                               const std::string& theAttribute)
+{
+  boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
+
+  double aX = 0;
+  double anY = 0;
+  convertTo2D(thePoint, aX, anY);
+  aPoint->setValue(aX, anY);
+}
+
+void PartSet_OperationEditLine::setLinePoint(boost::shared_ptr<ModelAPI_Feature> theSourceFeature,
+                                               const std::string& theSourceAttribute,
+                                               const std::string& theAttribute)
+{
+  boost::shared_ptr<ModelAPI_Data> aData = theSourceFeature->data();
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theSourceAttribute));
+  double aX = aPoint->x();
+  double anY = aPoint->y();
+
+  aData = feature()->data();
+  aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
+  aPoint->setValue(aX, anY);
+}
+
+void PartSet_OperationEditLine::convertTo2D(const gp_Pnt& thePoint, double& theX, double& theY)
+{
+  if (!mySketch)
+    return;
+
+  boost::shared_ptr<ModelAPI_AttributeDouble> anAttr;
+  boost::shared_ptr<ModelAPI_Data> aData = mySketch->data();
+
+  boost::shared_ptr<GeomDataAPI_Point> anOrigin = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SKETCH_ATTR_ORIGIN));
+
+  boost::shared_ptr<GeomDataAPI_Dir> aX = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRX));
+  boost::shared_ptr<GeomDataAPI_Dir> anY = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRY));
+
+  gp_Pnt aVec(thePoint.X() - anOrigin->x(), thePoint.Y() - anOrigin->y(), thePoint.Z() - anOrigin->z());
+  theX = aVec.X() * aX->x() + aVec.Y() * aX->y() + aVec.Z() * aX->z();
+  theY = aVec.X() * anY->x() + aVec.Y() * anY->y() + aVec.Z() * anY->z();
+}
diff --git a/src/PartSet/PartSet_OperationEditLine.h b/src/PartSet/PartSet_OperationEditLine.h
new file mode 100644 (file)
index 0000000..5ce170b
--- /dev/null
@@ -0,0 +1,111 @@
+// File:        PartSet_OperationEditLine.h
+// Created:     05 May 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_OperationEditLine_H
+#define PartSet_OperationEditLine_H
+
+#include "PartSet.h"
+
+#include <PartSet_OperationSketchBase.h>
+#include <QObject>
+
+/*!
+ \class PartSet_OperationEditLine
+ * \brief The operation for the sketch feature creation
+*/
+class PARTSET_EXPORT PartSet_OperationEditLine : public PartSet_OperationSketchBase
+{
+  Q_OBJECT
+public:
+  /// Constructor
+  /// \param theId the feature identifier
+  /// \param theParent the operation parent
+  /// \param theFeature the parent feature
+  PartSet_OperationEditLine(const QString& theId, QObject* theParent,
+                            boost::shared_ptr<ModelAPI_Feature> theFeature);
+  /// Destructor
+  virtual ~PartSet_OperationEditLine();
+
+   /// Returns that this operator can be started above already running one.
+   /// The runned operation should be the sketch feature modified operation
+  virtual bool isGranted() const;
+
+  /// Returns the operation local selection mode
+  /// \param theFeature the feature object to get the selection mode
+  /// \return the selection mode
+  virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
+
+  /// Initializes some fields accorging to the feature
+  /// \param theFeature the feature
+  virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature);
+
+  /// Gives the current selected objects to be processed by the operation
+  /// \param thePoint a point clicked in the viewer
+  virtual void mouseReleased(const gp_Pnt& thePoint);
+  /// Gives the current mouse point in the viewer
+  /// \param thePoint a point clicked in the viewer
+  virtual void mouseMoved(const gp_Pnt& thePoint);
+  /// Processes the key pressed in the view
+  /// \param theKey a key value
+  virtual void keyReleased(const int theKey);
+
+  /// Gives the current selected objects to be processed by the operation
+  /// \param theFeature the selected feature
+  /// \param theShape the selected shape
+  virtual void setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
+                           const TopoDS_Shape& theShape);
+
+signals:
+  /// signal about the sketch plane is selected
+  /// \param theX the value in the X direction of the plane
+  /// \param theX the value in the Y direction value of the plane
+  /// \param theX the value in the Z direction of the plane
+  void localContextChanged(boost::shared_ptr<ModelAPI_Feature> theFeature,
+                           int theMode);
+
+protected:
+  /// \brief Virtual method called when operation is started
+  /// Virtual method called when operation started (see start() method for more description)
+  /// After the parent operation body perform, set sketch feature to the created line feature
+  virtual void startOperation();
+
+  /// \brief Virtual method called when operation is started
+  /// Virtual method called when operation stopped - committed or aborted.
+  /// After the parent operation body perform, reset selection point mode of the operation
+  virtual void stopOperation();
+
+  /// Creates an operation new feature
+  /// Returns NULL feature. This is an operation of edition, not creation.
+  /// \returns the created feature
+  virtual boost::shared_ptr<ModelAPI_Feature> createFeature();
+
+protected:
+  /// \brief Save the point to the line.
+  /// \param thePoint the 3D point in the viewer
+  /// \param theAttribute the start or end attribute of the line
+  void setLinePoint(const gp_Pnt& thePoint, const std::string& theAttribute);
+
+  /// \brief Set the point to the line by the point of the source line.
+  /// \param theSourceFeature the feature, where the point is obtained
+  /// \param theSourceAttribute the start or end attribute of the source line
+  /// \param theAttribute the start or end attribute of the line
+  void setLinePoint(boost::shared_ptr<ModelAPI_Feature> theSourceFeature,
+                                               const std::string& theSourceAttribute,
+                                               const std::string& theAttribute);
+  /// \brief Converts the 3D point to the projected coodinates on the sketch plane.
+  /// \param thePoint the 3D point in the viewer
+  /// \param theX the X coordinate
+  /// \param theY the Y coordinate
+  void convertTo2D(const gp_Pnt& thePoint, double& theX, double& theY);
+
+protected:
+  ///< Structure to lists the possible types of point selection modes
+  enum PointSelectionMode {SM_FirstPoint, SM_SecondPoint, SM_None};
+
+private:
+  boost::shared_ptr<ModelAPI_Feature> mySketch; ///< the sketch feature
+  //PointSelectionMode myPointSelectionMode; ///< point selection mode
+};
+
+#endif
index ee9334b32fef36b549554bf2fb74239981a5be3b..6c274b66ef432c3cfcb74e28b4a63f452656b821 100644 (file)
@@ -38,18 +38,22 @@ std::list<int> PartSet_OperationSketch::getSelectionModes(boost::shared_ptr<Mode
   return aModes;
 }
 
-void PartSet_OperationSketch::setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList)
+void PartSet_OperationSketch::setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
+                                          const TopoDS_Shape& theShape)
 {
-  if (theList.IsEmpty())
-    return;
-
-  if (isEditMode())
-    return;
+  if (!isEditMode()) {
+    setSketchPlane(theShape);
+    setEditMode(true);
+  }
+  else if (theFeature)
+    emit launchOperation("EditLine", theFeature);
+}
 
+void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape)
+{
   // get selected shape
-  const TopoDS_Shape& aShape = theList.First();
   boost::shared_ptr<GeomAPI_Shape> aGShape(new GeomAPI_Shape);
-  aGShape->setImpl(new TopoDS_Shape(aShape));
+  aGShape->setImpl(new TopoDS_Shape(theShape));
 
   // get plane parameters
   boost::shared_ptr<GeomAPI_Pln> aPlane = GeomAlgoAPI_FaceBuilder::plane(aGShape);
@@ -79,10 +83,7 @@ void PartSet_OperationSketch::setSelectedShapes(const NCollection_List<TopoDS_Sh
   boost::shared_ptr<GeomDataAPI_Dir> aDirY = 
     boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRY));
   aDirY->setValue(aC, anA, aB);
-
   boost::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
   emit planeSelected(aDir->x(), aDir->y(), aDir->z());
-
-  //commit();
-  //SketchPlugin_Sketch::setActive(myFeature);
 }
+
index e577962bb957c7cf01bc0f27758db3ed00531540..9250595c47c6b0e9fc62e94e634c819ea5d3a463 100644 (file)
@@ -31,9 +31,10 @@ public:
   virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
 
   /// Gives the current selected objects to be processed by the operation
-  /// \param theList a list of interactive selected shapes
-  /// \param theSelectedPoint a point clidked in the viewer
-  virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList);
+  /// \param theFeature the selected feature
+  /// \param theShape the selected shape
+  virtual void setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
+                           const TopoDS_Shape& theShape);
 
 signals:
   /// signal about the sketch plane is selected
@@ -41,6 +42,11 @@ signals:
   /// \param theX the value in the Y direction value of the plane
   /// \param theX the value in the Z direction of the plane
   void planeSelected(double theX, double theY, double theZ);
+
+protected:
+  /// Set the plane to the current sketch
+  /// \param theShape the shape
+  void setSketchPlane(const TopoDS_Shape& theShape);
 };
 
 #endif
index 173851cbc3fe4e336ce0fe0ec26d4233e6bc051e..7814bc9357ea18b4965e130e49db9bf719cf8a57 100644 (file)
@@ -45,9 +45,15 @@ public:
   /// \return the selection mode
   virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const = 0;
 
+  /// Initializes some fields accorging to the feature
+  /// \param theFeature the feature
+  virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature) {}
+
   /// Gives the current selected objects to be processed by the operation
-  /// \param theList a list of interactive selected shapes
-  virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList) {};
+  /// \param theFeature the selected feature
+  /// \param theShape the selected shape
+  virtual void setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
+                           const TopoDS_Shape& theShape) {};
 
   /// Processes the mouse release in the point
   /// \param thePoint a point clicked in the viewer
@@ -67,6 +73,10 @@ signals:
   /// \param theMode the mode of the feature modification
   void featureConstructed(boost::shared_ptr<ModelAPI_Feature> theFeature,
                           int theMode);
+  /// signal about the request to launch operation
+  /// theName the operation name
+  /// theFeature the operation argument
+  void launchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature);
 
 public:
   /// temporary code to provide edition mode
index 14e0502b55c57256aba4d5d649c4dbf691a7b9b2..21f09e9c1f125e3004b8dbb6a4f78e6fde177541 100644 (file)
@@ -132,16 +132,17 @@ void PartSet_OperationSketchLine::stopOperation()
   myPointSelectionMode = SM_None;
 }
 
-void PartSet_OperationSketchLine::createFeature()
+boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketchLine::createFeature()
 {
-  PartSet_OperationSketchBase::createFeature();
+  boost::shared_ptr<ModelAPI_Feature> aNewFeature = PartSet_OperationSketchBase::createFeature();
   if (mySketch) {
     boost::shared_ptr<SketchPlugin_Feature> aFeature = 
                            boost::dynamic_pointer_cast<SketchPlugin_Feature>(mySketch);
 
-    aFeature->addSub(feature());
+    aFeature->addSub(aNewFeature);
   }
-  //emit featureConstructed(aPrevFeature, FM_Activation);
+  //emit featureConstructed(aNewFeature, FM_Activation);
+  return aNewFeature;
 }
 
 void PartSet_OperationSketchLine::setLinePoint(const gp_Pnt& thePoint,
index 7883143fabccc098298cfa1bfaf8f4743a5db782..604baffa3229daa6fa7f43e0bae0563ce90a2e18 100644 (file)
@@ -65,9 +65,11 @@ protected:
   /// After the parent operation body perform, reset selection point mode of the operation
   virtual void stopOperation();
 
-  /// Creates a new feature and save it in the operation internal field.
-  /// In addition to the default realization it set a sketch feature to the created feature
-  virtual void createFeature();
+  /// Creates an operation new feature
+  /// In addition to the default realization it appends the created line feature to
+  /// the sketch feature
+  /// \returns the created feature
+  virtual boost::shared_ptr<ModelAPI_Feature> createFeature();
 
 protected:
   /// \brief Save the point to the line.
index c0a57d545ccabd3b0a81eb15c4f231667ffd3fe1..8e79d48fb93b9b0c7f64b8f65d1c2b4ec2f40767 100644 (file)
@@ -53,6 +53,30 @@ void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature,
     aContext->UpdateCurrentViewer();
 }
 
+boost::shared_ptr<ModelAPI_Feature> XGUI_Displayer::GetFeature(const TopoDS_Shape& theShape)
+{
+  boost::shared_ptr<ModelAPI_Feature> aFeature;
+
+  FeatureToAISMap::const_iterator aFIt = myFeature2AISObjectMap.begin(),
+                                  aFLast = myFeature2AISObjectMap.end();
+  for (; aFIt != aFLast && !aFeature; aFIt++)
+  {
+    std::vector<Handle(AIS_InteractiveObject)> aDispAIS = (*aFIt).second;
+    std::vector<Handle(AIS_InteractiveObject)>::const_iterator anIt = aDispAIS.begin(),
+                                                                aLast = aDispAIS.end();
+    Handle(AIS_InteractiveContext) aContext = AISContext();
+    for (; anIt != aLast && !aFeature; anIt++) {
+      Handle(AIS_InteractiveObject) anAIS = *anIt;
+      Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(anAIS);
+      if (!anAISShape.IsNull() && anAISShape->Shape() == theShape) {
+        aFeature = (*aFIt).first;
+      }
+    }
+  }
+
+  return aFeature;
+}
+
 void XGUI_Displayer::Erase(boost::shared_ptr<ModelAPI_Feature> theFeature,
                            const bool isUpdateViewer)
 {
index ec9d69649151d811a59b6730610082deec7a2562..a7f043d8e942453888165d1a2a3d6f29bd85298a 100644 (file)
@@ -55,6 +55,10 @@ public:
   void Display(boost::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape,
                const bool isUpdateViewer = true);
   
+  /// Returns the feature, that was displayed with this shape
+  /// \param theShape a shape
+  boost::shared_ptr<ModelAPI_Feature> GetFeature( const TopoDS_Shape& theShape );
+
   /// Display the shape and activate selection of sub-shapes
   /// \param theFeature a feature instance
   /// \param theShape a shape
@@ -83,7 +87,9 @@ protected:
 
 protected:
   XGUI_Workshop* myWorkshop;
-  std::map<boost::shared_ptr<ModelAPI_Feature>, std::vector<Handle(AIS_InteractiveObject)> > myFeature2AISObjectMap;
+
+  typedef std::map<boost::shared_ptr<ModelAPI_Feature>, std::vector<Handle(AIS_InteractiveObject)> > FeatureToAISMap;
+  FeatureToAISMap myFeature2AISObjectMap;
 };
 
 #endif
index a956d04871e44558890fa789101dde8871002dd2..2c39696589e4a1132a275b55cf8949c049490ec3 100644 (file)
@@ -204,6 +204,7 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
         (ModuleBase_Operation*)(aPartSetMsg->pointer());
 
     if (myOperationMgr->startOperation(anOperation)) {
+      myPropertyPanel->updateContentWidget(anOperation->feature());
       if (anOperation->getDescription()->xmlRepresentation().isEmpty()) {
         anOperation->commit();
         updateCommandStatus();