Salome HOME
refs #80 - Sketch base GUI: create/draw point, circle and arc
authornds <natalia.donis@opencascade.com>
Thu, 19 Jun 2014 08:56:56 +0000 (12:56 +0400)
committernds <natalia.donis@opencascade.com>
Thu, 19 Jun 2014 08:56:56 +0000 (12:56 +0400)
1. Split init(feature, feature) on init(feature), setFeature(feature, selection mode). The cause is lenght constraint.
2. Mouse double click signal listen by operation.
3. Correct displayer to use the selection mode only in activateInLocalContext method. It was temporary realized in the redisplay().
4. Increase selection tolerance for dimension text.

21 files changed:
src/PartSet/PartSet_FeatureLengthPrs.cpp
src/PartSet/PartSet_FeatureLengthPrs.h
src/PartSet/PartSet_FeatureLinePrs.cpp
src/PartSet/PartSet_FeatureLinePrs.h
src/PartSet/PartSet_FeaturePrs.cpp
src/PartSet/PartSet_FeaturePrs.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationConstraint.cpp
src/PartSet/PartSet_OperationConstraint.h
src/PartSet/PartSet_OperationCreateConstraint.cpp
src/PartSet/PartSet_OperationCreateFeature.cpp
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h
src/PartSet/PartSet_OperationSketchBase.cpp
src/PartSet/PartSet_OperationSketchBase.h
src/PartSet/PartSet_Presentation.cpp
src/PartSet/PartSet_TestOCC.cpp
src/PartSet/PartSet_Tools.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h

index 24c798fb693407974901da8bca772cbaa46039be..36bc766ea57237d699add8c1605a6780030131fb 100644 (file)
@@ -174,18 +174,19 @@ boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureLengthPrs::featurePoint
   return boost::shared_ptr<GeomDataAPI_Point2D>();
 }
 
-void PartSet_FeatureLengthPrs::initFeature(FeaturePtr theSourceFeature)
+bool PartSet_FeatureLengthPrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
 {
-  if (feature() && theSourceFeature && theSourceFeature->getKind() == SKETCH_LINE_KIND)
+  bool aResult = false;
+  if (feature() && theFeature && theFeature->getKind() == SKETCH_LINE_KIND && theMode == SM_FirstPoint)
   {
     // set length feature
     boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
     boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
           boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
-    aRef->setFeature(theSourceFeature);
+    aRef->setFeature(theFeature);
 
     // set length value
-    aData = theSourceFeature->data();
+    aData = theFeature->data();
     boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
           boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
     boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
@@ -193,5 +194,7 @@ void PartSet_FeatureLengthPrs::initFeature(FeaturePtr theSourceFeature)
 
     double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
     PartSet_Tools::setFeatureValue(feature(), aLenght, CONSTRAINT_ATTR_VALUE);
+    aResult = true;
   }
+  return aResult;
 }
index 2c39f38bc1deaf76a2e61f7fb296fd246a897f81..1bd7f8c1f4dace6db0a8b36ca1cf3155894ec8c9 100644 (file)
@@ -39,6 +39,12 @@ public:
   virtual PartSet_SelectionMode setPoint(double theX, double theY,
                                          const PartSet_SelectionMode& theMode);
 
+  /// Sets the feature to to a feature attribute depending on the selection mode
+  /// \param theFeature a feature instance
+  /// \param theMode the selection mode
+  /// \return whether the feature is set
+  virtual bool setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
+
   /// Returns the feature attribute name for the selection mode
   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
   virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const;
@@ -69,10 +75,6 @@ protected:
   /// Returns the feature point in the selection mode position.
   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
   virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode);
-
-  /// Initializes current feature by the given
-  /// \param theSourceFeature the feature, which attributes are used to initialize the current feature
-  virtual void initFeature(FeaturePtr theSourceFeature);
 };
 
 #endif
index bc7e2d14433cc953f5594d6a0f3dfe1563527da6..ef6e7c0059c4a3bfdbc974aafc197a62016b18a7 100644 (file)
@@ -35,24 +35,6 @@ std::string PartSet_FeatureLinePrs::getKind()
   return SKETCH_LINE_KIND;
 }
 
-void PartSet_FeatureLinePrs::initFeature(FeaturePtr theFeature)
-{
-  if (feature() && theFeature)
-  {
-    // use the last point of the previous feature as the first of the new one
-    boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-    boost::shared_ptr<GeomDataAPI_Point2D> anInitPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
-                                                                  (aData->attribute(LINE_ATTR_END));
-    PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_START);
-    PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_END);
-
-    aData = feature()->data();
-    boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
-                                                                 (aData->attribute(LINE_ATTR_START));
-    PartSet_Tools::createConstraint(sketch(), anInitPoint, aPoint);
-  }
-}
-
 PartSet_SelectionMode PartSet_FeatureLinePrs::setPoint(double theX, double theY,
                                                        const PartSet_SelectionMode& theMode)
 {
@@ -76,6 +58,27 @@ PartSet_SelectionMode PartSet_FeatureLinePrs::setPoint(double theX, double theY,
   return aMode;
 }
 
+bool PartSet_FeatureLinePrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
+{
+  bool aResult = false;
+  if (feature() && theFeature && theMode == SM_FirstPoint)
+  {
+    // use the last point of the previous feature as the first of the new one
+    boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+    boost::shared_ptr<GeomDataAPI_Point2D> anInitPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
+                                                                  (aData->attribute(LINE_ATTR_END));
+    PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_START);
+    PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_END);
+
+    aData = feature()->data();
+    boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
+                                                                 (aData->attribute(LINE_ATTR_START));
+    PartSet_Tools::createConstraint(sketch(), anInitPoint, aPoint);
+    aResult = true;
+  }
+  return aResult;
+}
+
 std::string PartSet_FeatureLinePrs::getAttribute(const PartSet_SelectionMode& theMode) const
 {
   std::string aAttribute;
index 0f6fb051fd323e99a009e42f01543b06e0038619..3ba4367974a95957c06546148b5e570a1fa7b6c3 100644 (file)
@@ -43,6 +43,12 @@ public:
   virtual PartSet_SelectionMode setPoint(double theX, double theY,
                                          const PartSet_SelectionMode& theMode);
 
+  /// Sets the feature to to a feature attribute depending on the selection mode
+  /// \param theFeature a feature instance
+  /// \param theMode the selection mode
+  /// \return whether the feature is set
+  virtual bool setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
+
   /// Returns the feature attribute name for the selection mode
   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
   virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const;
@@ -93,10 +99,6 @@ public:
                            double& theX, double& theY);
 
 protected:
-  /// Initializes current feature by the given
-  /// \param theSourceFeature the feature, which attributes are used to initialize the current feature
-  virtual void initFeature(FeaturePtr theSourceFeature);
-
   /// Returns the feature point in the selection mode position.
   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
   virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode);
index 4712baf3a09821f0e6e7afe9db177d098fb6469d..9f2184d862da2f7998434b32eff26a6a9e3c6e06 100644 (file)
@@ -28,12 +28,9 @@ PartSet_FeaturePrs::~PartSet_FeaturePrs()
 {
 }
 
-void PartSet_FeaturePrs::init(FeaturePtr theFeature, FeaturePtr theSourceFeature)
+void PartSet_FeaturePrs::init(FeaturePtr theFeature)
 {
   myFeature = theFeature;
-  if (theSourceFeature) {
-    initFeature(theSourceFeature);
-  }
 }
 
 FeaturePtr PartSet_FeaturePrs::sketch() const
index 6ba12c6d8630a711424c1286f55f501f056da41b..0acc2125d2b3c3929071f1445ff48c084b6c6d42 100644 (file)
@@ -29,8 +29,7 @@ public:
   /// Initializes some fields of feature accorging to the source feature
   /// Saves the fiature as the presentation internal feature
   /// \param theFeature the presentation feature
-  /// \param theSourceFeature the feature, which attributes are used to initialize the feature
-  void init(FeaturePtr theFeature, FeaturePtr theSourceFeature);
+  void init(FeaturePtr theFeature);
 
   /// Returns the operation sketch feature
   /// \returns the sketch instance
@@ -44,6 +43,12 @@ public:
   virtual PartSet_SelectionMode setPoint(double theX, double theY,
                                          const PartSet_SelectionMode& theMode) = 0;
 
+  /// Sets the feature to to a feature attribute depending on the selection mode
+  /// \param theFeature a feature instance
+  /// \param theMode the selection mode
+  /// \return whether the feature is set
+  virtual bool setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode) { return false; };
+
   /// Returns the feature attribute name for the selection mode
   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
   virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const = 0;
@@ -82,10 +87,6 @@ protected:
   /// \return the feature
   FeaturePtr feature() const;
 
-  /// Initializes current feature by the given
-  /// \param theSourceFeature the feature, which attributes are used to initialize the current feature
-  virtual void initFeature(FeaturePtr theSourceFeature) {};
-
   /// Returns the feature point in the selection mode position.
   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
   virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode) = 0;
index 8b683a16905500449d12ac6c067d8844d33caeeb..7590e3b8020a80c81af673c17545b2937f45c6b6 100644 (file)
@@ -40,7 +40,7 @@
 #include <GeomAPI_Shape.h>
 
 #include <AIS_ListOfInteractive.hxx>
-#include <AIS_DimensionSelectionMode.hxx>
+//#include <AIS_DimensionSelectionMode.hxx>
 
 #include <QObject>
 #include <QMouseEvent>
@@ -81,6 +81,9 @@ PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop)
           this, SLOT(onMouseMoved(QMouseEvent*)));
   connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)),
           this, SLOT(onKeyRelease(QKeyEvent*)));
+  connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)),
+          this, SLOT(onMouseDoubleClick(QMouseEvent*)));
+
 }
 
 PartSet_Module::~PartSet_Module()
@@ -213,6 +216,20 @@ void PartSet_Module::onKeyRelease(QKeyEvent* theEvent)
   }
 }
 
+void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
+{
+  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
+                                       myWorkshop->operationMgr()->currentOperation());
+  if (aPreviewOp)
+  {
+    XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+    std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
+    std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
+    aPreviewOp->mouseDoubleClick(theEvent, myWorkshop->viewer()->activeView(), aSelected,
+                                 aHighlighted);
+  }
+}
+
 void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
 {
   myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
@@ -418,11 +435,7 @@ void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
                            aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(),
                            aDisplayer->getAISObject(theFeature));
 
-    int aSelectionMode = -1;
-    if (theFeature->getKind() == SKETCH_CONSTRAINT_LENGTH_KIND) {
-      aSelectionMode = AIS_DSM_Text;
-    }
-    aDisplayer->redisplay(theFeature, anAIS, aSelectionMode, false);
+    aDisplayer->redisplay(theFeature, anAIS, false);
   }
   else
     aDisplayer->erase(theFeature, false);
@@ -470,7 +483,7 @@ void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
                            aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(),
                            aDisplayer->getAISObject(aFeature));
     if (!anAIS.IsNull())
-      aDisplayer->redisplay(aFeature, anAIS, -1, false);
+      aDisplayer->redisplay(aFeature, anAIS, false);
     aDisplayer->activateInLocalContext(aFeature, aModes, false);
   }
   aDisplayer->updateViewer();
index 31e41081696c6543dc4f0899dfed61395495562b..49fb587da76e1767f5a4384bbb2e8641983ea819 100644 (file)
@@ -83,6 +83,10 @@ public slots:
   /// \param theEvent the mouse event
   void onKeyRelease(QKeyEvent* theEvent);
 
+  /// SLOT, that is called by the mouse double click in the viewer.
+  /// \param theEvent the mouse event
+  void onMouseDoubleClick(QMouseEvent* theEvent);
+
   /// SLOT, to apply to the current viewer the operation
   /// \param theX the X projection value
   /// \param theY the Y projection value
index e810cf39092bd9b50c45b5409abdf7e603eaa24a..9b1d2129e7fe70fedcbcf0111dc948b5c1cd2535 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <PartSet_Tools.h>
 #include <PartSet_OperationSketch.h>
+#include <SketchPlugin_ConstraintLength.h>
 
 #include <SketchPlugin_Feature.h>
 #include <SketchPlugin_Sketch.h>
@@ -54,6 +55,11 @@ PartSet_OperationConstraint::~PartSet_OperationConstraint()
 {
 }
 
+std::string PartSet_OperationConstraint::Type()
+{
+  return SKETCH_CONSTRAINT_LENGTH_KIND;
+}
+
 bool PartSet_OperationConstraint::isGranted(ModuleBase_IOperation* theOperation) const
 {
   return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type();
index 678964aaf265a7eb145be6274633f97fc3fb524f..56ffe26291b4e7735e739f942cf3c10e5d16cd50 100644 (file)
@@ -9,8 +9,6 @@
 
 #include <PartSet_OperationSketchBase.h>
 
-#include <SketchPlugin_ConstraintLength.h>
-
 #include <QObject>
 
 /*!
@@ -23,7 +21,7 @@ class PARTSET_EXPORT PartSet_OperationConstraint : public PartSet_OperationSketc
 
 public:
   /// Returns the operation type key
-  static std::string Type() { return SKETCH_CONSTRAINT_LENGTH_KIND; }
+  static std::string Type();
 
 public:
   /// Constructor
index ec9ae0662b6c755481ea3e7d2e49857ca0abe7a3..bc4463b94ff000e982dc9d13fffc3e16d87bf678 100644 (file)
@@ -106,9 +106,10 @@ void PartSet_OperationCreateConstraint::mouseReleased(QMouseEvent* theEvent, Han
         XGUI_ViewerPrs aPrs = theSelected.front();
         FeaturePtr aFeature = aPrs.feature();
 
-        myFeaturePrs->init(feature(), aFeature);
-        flushUpdated();
-        setPointSelectionMode(SM_SecondPoint);
+        if (myFeaturePrs->setFeature(aFeature, myPointSelectionMode)) {
+          flushUpdated();
+          setPointSelectionMode(SM_SecondPoint);
+        }
       }
     }
     break;
@@ -189,9 +190,15 @@ void PartSet_OperationCreateConstraint::keyReleased(const int theKey)
         // it start a new line creation at a free point
         restartOperation(feature()->getKind(), FeaturePtr()/*feature()*/);
       }
-      //else
-      //  abort();
-      //restartOperation(feature()->getKind(), FeaturePtr());
+      // changed
+      // the modification is really need until the focus of editor do not accept the focus
+      if (myPointSelectionMode == SM_ThirdPoint) {
+        if (myEditor->isStarted())
+          myEditor->stop();
+        commit();
+        // it start a new line creation at a free point
+        restartOperation(feature()->getKind(), FeaturePtr()/*feature()*/);
+      }
     }
     break;
     case Qt::Key_Escape: {
@@ -246,7 +253,9 @@ FeaturePtr PartSet_OperationCreateConstraint::createFeature(const bool theFlushM
 
     aFeature->addSub(aNewFeature);
   }
-  myFeaturePrs->init(aNewFeature, myInitFeature);
+  myFeaturePrs->init(aNewFeature);
+  if (myInitFeature)
+    myFeaturePrs->setFeature(myInitFeature, SM_FirstPoint);
 
   emit featureConstructed(aNewFeature, FM_Activation);
   if (theFlushMessage)
index 2bfca9f7c0ece4001509d390dce12756fab94b81..23c746219a6e55dde46c4ff17f800575fff0c728 100644 (file)
@@ -270,7 +270,8 @@ FeaturePtr PartSet_OperationCreateFeature::createFeature(const bool theFlushMess
 
     aFeature->addSub(aNewFeature);
   }
-  myFeaturePrs->init(aNewFeature, myInitFeature);
+  myFeaturePrs->init(aNewFeature);
+  myFeaturePrs->setFeature(myInitFeature, SM_FirstPoint);
 
   emit featureConstructed(aNewFeature, FM_Activation);
   if (theFlushMessage)
index bc57e5068e87db6b041060bc5c06ab61f6364614..c028eab6e7a4e7233cd08ceeb7153ce5a44e8db4 100644 (file)
@@ -130,6 +130,38 @@ void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_Vi
   }
 }
 
+#include <QLineEdit>
+void PartSet_OperationSketch::mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
+                                               const std::list<XGUI_ViewerPrs>& theSelected,
+                                               const std::list<XGUI_ViewerPrs>& theHighlighted)
+{
+  return;
+  if (!hasSketchPlane())
+    return;
+  if (!theSelected.empty()) {
+    XGUI_ViewerPrs aPrs = theSelected.front();
+    if (!aPrs.owner().IsNull()) {
+      Handle(AIS_DimensionOwner) anOwner = Handle(AIS_DimensionOwner)::DownCast(aPrs.owner());
+      if (!anOwner.IsNull() && anOwner->SelectionMode() == AIS_DSM_Text) {
+        Handle(SelectMgr_SelectableObject) anObject = anOwner->Selectable();
+        double aValue = 0;
+        if (!anObject.IsNull()) {
+          Handle(AIS_LengthDimension) aLenDim = Handle(AIS_LengthDimension)::DownCast(anObject);
+          if (!aLenDim.IsNull())
+            aValue = aLenDim->GetValue();
+        }
+
+        QLineEdit* aLine = new QLineEdit();
+        QPoint aViewPos = theEvent->globalPos();
+        QPoint aLinePos(aViewPos.x(), aViewPos.y());
+        aLine->move(aLinePos);
+        aLine->setText(QString::number(aValue));
+        aLine->show();
+      }
+    }
+  }
+}
+
 void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
 {
   if (!hasSketchPlane() || !(theEvent->buttons() &  Qt::LeftButton) || myFeatures.empty())
index 27c0d8641db489ef85cde4dce263e84cc9f3386b..161c76a879aa74761810be090c3450aec7693cc3 100644 (file)
@@ -72,6 +72,15 @@ public:
   /// \param theEvent the mouse event
   virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
 
+  /// Processes the mouse double click in the point
+  /// \param theEvent the mouse event
+  /// \param theView a viewer to have the viewer the eye position
+  /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
+  virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
+                                const std::list<XGUI_ViewerPrs>& theSelected,
+                                const std::list<XGUI_ViewerPrs>& theHighlighted);
+
   /// Returns the map of the operation previews including the nested feature previews
   /// \return the map of feature to the feature preview
   virtual std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> >
index 8bb9e3be213209ebb45a420f67f4304c7aae31be..767d7bf71b353727a94d37dc660b7560e5737330 100644 (file)
@@ -7,6 +7,7 @@
 #include <SketchPlugin_Feature.h>
 
 #include <V3d_View.hxx>
+#include <AIS_Shape.hxx>
 
 #include <QKeyEvent>
 
@@ -42,11 +43,20 @@ std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> >
   return std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> >();
 }
 
+#include <AIS_DimensionSelectionMode.hxx>
+#include <SketchPlugin_ConstraintLength.h>
 std::list<int> PartSet_OperationSketchBase::getSelectionModes(FeaturePtr theFeature) const
 {
   std::list<int> aModes;
-  aModes.push_back(TopAbs_VERTEX);
-  aModes.push_back(TopAbs_EDGE);
+  if (theFeature->getKind() == SKETCH_CONSTRAINT_LENGTH_KIND) {
+      aModes.clear();
+      aModes.push_back(AIS_DSM_Text);
+      aModes.push_back(AIS_DSM_Line);
+  }
+  else {
+    aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)TopAbs_VERTEX));
+    aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)TopAbs_EDGE));
+  }
   return aModes;
 }
 FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage)
@@ -71,6 +81,11 @@ void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3
 void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
 {
 }
+void PartSet_OperationSketchBase::mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
+                                                   const std::list<XGUI_ViewerPrs>& theSelected,
+                                                   const std::list<XGUI_ViewerPrs>& theHighlighted)
+{
+}
 
 void PartSet_OperationSketchBase::keyReleased(const int theKey)
 {
index ff6f06847b568dbada696596b3a86a656b94d2da..5f4d556e07e27f1fc0203221a52f170404f1abdc 100644 (file)
@@ -88,6 +88,15 @@ public:
   /// \param theView a viewer to have the viewer the eye position
   virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
 
+  /// Processes the mouse double click in the point
+  /// \param theEvent the mouse event
+  /// \param theView a viewer to have the viewer the eye position
+  /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
+  virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
+                            const std::list<XGUI_ViewerPrs>& theSelected,
+                            const std::list<XGUI_ViewerPrs>& theHighlighted);
+
   /// Processes the key pressed in the view
   /// \param theKey a key value
   virtual void keyReleased(const int theKey);
index 84dc7e3fe10ea98d613fe083a0757f738c5d122f..a89383a7a02a7d049b52551bfcbe58727c9659c4 100644 (file)
@@ -28,6 +28,9 @@
 const Quantity_NameOfColor SKETCH_PLANE_COLOR = Quantity_NOC_CHOCOLATE; /// the plane edge color
 const int SKETCH_WIDTH = 4; /// the plane edge width
 
+const int CONSTRAINT_TEXT_HEIGHT = 28; /// the text height of the constraint
+const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20; /// the text selection tolerance
+
 Handle(AIS_InteractiveObject) PartSet_Presentation::createPresentation(
                                          FeaturePtr theFeature,
                                          FeaturePtr theSketch,
@@ -131,22 +134,23 @@ Handle(AIS_InteractiveObject) PartSet_Presentation::createSketchConstraintLength
   Handle(AIS_InteractiveObject) anAIS = thePrevPrs;
   if (anAIS.IsNull())
   {
-    Handle(AIS_LengthDimension) aLenDim = new AIS_LengthDimension (aP1, aP2, aPlane);
+    Handle(AIS_LengthDimension) aDimAIS = new AIS_LengthDimension (aP1, aP2, aPlane);
 
     Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
     anAspect->MakeArrows3d (Standard_False);
     anAspect->MakeText3d(false/*is text 3d*/);
-    anAspect->TextAspect()->SetHeight(28);
+    anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT);
     anAspect->MakeTextShaded(false/*is test shaded*/);
-    aLenDim->DimensionAspect()->MakeUnitsDisplayed(false/*is units displayed*/);
+    aDimAIS->DimensionAspect()->MakeUnitsDisplayed(false/*is units displayed*/);
     /*if (isUnitsDisplayed)
     {
-      aLenDim->SetDisplayUnits (aDimDlg->GetUnits ());
+      aDimAIS->SetDisplayUnits (aDimDlg->GetUnits ());
     }*/
-    aLenDim->SetDimensionAspect (anAspect);
-    aLenDim->SetFlyout(aFlyout);
+    aDimAIS->SetDimensionAspect (anAspect);
+    aDimAIS->SetFlyout(aFlyout);
+    aDimAIS->SetSelToleranceForText2d(CONSTRAINT_TEXT_SELECTION_TOLERANCE);
 
-    anAIS = aLenDim;
+    anAIS = aDimAIS;
   }
   else {
     // update presentation
index 9de46957036ce667977f75df99f1c8b66c18f65e..9dd77583a16b30a38a101e53cf1d788d54bf8e00 100644 (file)
@@ -153,7 +153,7 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop)
                            aFeature, aSketch,
                            aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(), NULL);
     if (!anAIS.IsNull())
-      aDisplayer->redisplay(aFeature, anAIS, -1, false);
+      aDisplayer->redisplay(aFeature, anAIS, false);
 
     std::list<int> aModes;
     aModes.push_back(TopAbs_VERTEX);
@@ -172,7 +172,7 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop)
                              aFeature, aSketch,
                              aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(), NULL);
       if (!anAIS.IsNull())
-        aDisplayer->redisplay(aFeature, anAIS, -1, true);
+        aDisplayer->redisplay(aFeature, anAIS, true);
 
       int aVal = 90;
       for (int j = 0; j < 10000000; j++)
@@ -211,7 +211,7 @@ void PartSet_TestOCC::changeTestLine(XGUI_Workshop* theWorkshop)
                           aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(),
                           aPrevAIS);
   if (!anAIS.IsNull())
-    theWorkshop->displayer()->redisplay(aFeature, anAIS, -1, true);
+    theWorkshop->displayer()->redisplay(aFeature, anAIS, true);
   //std::list<int> aModes;
   //aModes.clear();
   //aModes.push_back(TopAbs_VERTEX);
index 02f216cfcb7deb9520354995fb1e000df8e0952f..2241830377292853dfa92dd01de6976459625152 100644 (file)
@@ -159,7 +159,7 @@ boost::shared_ptr<PartSet_FeaturePrs> PartSet_Tools::createFeaturePrs(const std:
   }
 
   if (theFeature && aFeaturePrs)
-    aFeaturePrs->init(theFeature, FeaturePtr());
+    aFeaturePrs->init(theFeature);
 
   return aFeaturePrs;
 }
index c4d8b001e2977d07018b69b746304f71941da008..f2ee9a1965a1acea4b47f392f098181331b7dcd4 100644 (file)
@@ -144,7 +144,6 @@ void XGUI_Displayer::erase(FeaturePtr theFeature,
 
 bool XGUI_Displayer::redisplay(FeaturePtr theFeature,
                                Handle(AIS_InteractiveObject) theAIS,
-                               const int theSelectionMode,
                                const bool isUpdateViewer)
 {
   bool isCreated = false;
@@ -163,14 +162,7 @@ bool XGUI_Displayer::redisplay(FeaturePtr theFeature,
   }
   else {
     myFeature2AISObjectMap[theFeature] = theAIS;
-    if (theSelectionMode < 0)
-    {
-      aContext->Display(theAIS, false);
-    }
-    else
-    {
-      aContext->Display(theAIS, 0, theSelectionMode, false);
-    }
+    aContext->Display(theAIS, false);
     isCreated = true;
   }
   if (isUpdateViewer)
@@ -205,9 +197,9 @@ void XGUI_Displayer::activateInLocalContext(FeaturePtr theFeature,
     aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/);
   }
   // display or redisplay presentation
-  Handle(AIS_Shape) anAIS;
+  Handle(AIS_InteractiveObject) anAIS;
   if (isVisible(theFeature))
-    anAIS = Handle(AIS_Shape)::DownCast(myFeature2AISObjectMap[theFeature]);
+    anAIS = Handle(AIS_InteractiveObject)::DownCast(myFeature2AISObjectMap[theFeature]);
 
   // Activate selection of objects from prs
   if (!anAIS.IsNull()) {
@@ -217,7 +209,7 @@ void XGUI_Displayer::activateInLocalContext(FeaturePtr theFeature,
     std::list<int>::const_iterator anIt = theModes.begin(), aLast = theModes.end();
     for (; anIt != aLast; anIt++)
     {
-      aContext->Activate(anAIS, AIS_Shape::SelectionMode((TopAbs_ShapeEnum)*anIt));
+      aContext->Activate(anAIS, (*anIt));
        }
   }
 
index 7ca8150aeb27139ed71149b2432163a61a514e27..d16b36279839a685d8a3f6e41df7e992e721ee9e 100644 (file)
@@ -81,8 +81,7 @@ public:
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
   /// \returns true if the presentation is created
   bool redisplay(FeaturePtr theFeature,
-                 Handle(AIS_InteractiveObject) theAIS,
-                 const int theSelectionMode, const bool isUpdateViewer = true);
+                 Handle(AIS_InteractiveObject) theAIS, const bool isUpdateViewer = true);
 
   /** Redisplay the shape if it was displayed
   * \param theFeature a feature instance