]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Provide selection synchronisation
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 18 Jul 2014 14:48:17 +0000 (18:48 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 18 Jul 2014 14:48:17 +0000 (18:48 +0400)
20 files changed:
src/ModuleBase/ModuleBase_ViewerPrs.h
src/ModuleBase/ModuleBase_WidgetFeature.cpp
src/ModuleBase/ModuleBase_WidgetFeature.h
src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp
src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/PartSet/PartSet_OperationFeatureCreate.h
src/PartSet/PartSet_OperationFeatureEdit.cpp
src/PartSet/PartSet_OperationFeatureEdit.h
src/PartSet/PartSet_OperationFeatureEditMulti.cpp
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketchBase.cpp
src/PartSet/PartSet_OperationSketchBase.h
src/PartSet/PartSet_TestOCC.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_DocumentDataModel.cpp
src/XGUI/XGUI_SelectionMgr.cpp

index a365c753ab92f961b6699392020bd21df6e1cb34..40ec6661358cb598b55783415fc589de7e72211e 100644 (file)
@@ -69,7 +69,7 @@ public:
     bool aResult = (myResult.get() == thePrs.object().get());
     bool aOwner = (myOwner.Access() == thePrs.owner().Access());
     bool aShape = myShape.IsEqual(thePrs.shape());
-    bool aIO = myInteractive == thePrs.interactive();
+    bool aIO = (myInteractive == thePrs.interactive());
     return aResult && aOwner && aShape && aIO;
   }
 
index 2a65062b0828686a48437c0765064244f4b60165..7bf014ed3302378e7c81ac5104d52795d8c21639 100644 (file)
@@ -28,7 +28,7 @@ ModuleBase_WidgetFeature::ModuleBase_WidgetFeature(QWidget* theParent,
 : ModuleBase_ModelWidget(theParent, theData)
 {
   QString aKinds = QString::fromStdString(theData->getProperty(FEATURE_KEYSEQUENCE));
-  myFeatureKinds = aKinds.split(" ");
+  myObjectKinds = aKinds.split(" ");
 
   myContainer = new QWidget(theParent);
   QHBoxLayout* aControlLay = new QHBoxLayout(myContainer);
@@ -62,20 +62,20 @@ bool ModuleBase_WidgetFeature::setValue(ModuleBase_WidgetValue* theValue)
   if (theValue) {
     ModuleBase_WidgetValueFeature* aFeatureValue = 
                          dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
-    // TODO
-//    if (aFeatureValue)
-//      isDone = setFeature(aFeatureValue->feature());
+    if (aFeatureValue)
+      isDone = setObject(aFeatureValue->object());
   }
   return isDone;
 }
 
-bool ModuleBase_WidgetFeature::setFeature(const FeaturePtr& theFeature)
+bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject)
 {
-  if (!myFeatureKinds.contains(theFeature->getKind().c_str()))
-    return false;
+  // TODO
+  //if (!myObjectKinds.contains(theObject->getKind().c_str()))
+  //  return false;
 
-  myFeature = theFeature;
-  myEditor->setText(theFeature ? theFeature->data()->name().c_str() : "");
+  myObject = theObject;
+  myEditor->setText(theObject ? theObject->data()->name().c_str() : "");
   emit valuesChanged();
   return true;
 }
@@ -90,7 +90,7 @@ bool ModuleBase_WidgetFeature::storeValue(ObjectPtr theObject) const
           boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
 
   ModuleBase_WidgetFeature* that = (ModuleBase_WidgetFeature*) this;
-  aRef->setObject(myFeature);
+  aRef->setObject(myObject);
   aFeature->execute();
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
 
@@ -105,8 +105,8 @@ bool ModuleBase_WidgetFeature::restoreValue(ObjectPtr theObject)
 
   FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
   if (aFeature) {
-    myFeature = aFeature;
-    myEditor->setText(myFeature ? myFeature->data()->name().c_str() : "");
+    myObject = aFeature;
+    myEditor->setText(myObject ? myObject->data()->name().c_str() : "");
     return true;
   }
   return false;
index c57bd531e6c41bcabfb5a96e7c26f8f86b47996b..8cfd499a62a3bbf2ebd5ddf721c1873e04f3c9c7 100644 (file)
@@ -56,11 +56,11 @@ protected:
   /// Fill the widget values by given point
   /// \param thePoint the point
   /// \return the boolean result of the feature set
-  bool setFeature(const FeaturePtr& theObject);
+  bool setObject(const ObjectPtr& theObject);
 
   /// Returns current widget feature
   /// \return the feature
-  const FeaturePtr feature() const { return myFeature; }
+  const ObjectPtr object() const { return myObject; }
 
   /// Returns the widget editor
   /// \return the editor
@@ -68,11 +68,11 @@ protected:
 
   /// Returns the possible feature kinds
   /// \return the list of kinds
-  const QStringList& featureKinds() const { return myFeatureKinds; }
+  const QStringList& featureKinds() const { return myObjectKinds; }
 
 private:
-  FeaturePtr myFeature; ///< the current widget feature
-  QStringList myFeatureKinds; ///< the kinds of possible features
+  ObjectPtr myObject; ///< the current widget feature
+  QStringList myObjectKinds; ///< the kinds of possible features
 
   QWidget*   myContainer; /// the parent top control
   QLabel*    myLabel; /// the editor information label
index 87a1a88c2bd226cc68e3e9a820c7736b8ce1ac12..70c0fe959a14e570ae8f2dfbaf0487f1f861fd5e 100644 (file)
@@ -47,10 +47,9 @@ bool ModuleBase_WidgetFeatureOrAttribute::setValue(ModuleBase_WidgetValue* theVa
                          dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
     if (aFeatureValue) {
       boost::shared_ptr<GeomAPI_Pnt2d> aValuePoint = aFeatureValue->point();
-      //TODO
-/*      FeaturePtr aValueFeature = aFeatureValue->feature();
+      ObjectPtr aValueFeature = aFeatureValue->object();
       if (aValueFeature) {
-        isDone = setFeature(aValueFeature);
+        isDone = setObject(aValueFeature);
       }
       if (!isDone && aValuePoint) {
         // find the given point in the feature attributes
@@ -67,7 +66,7 @@ bool ModuleBase_WidgetFeatureOrAttribute::setValue(ModuleBase_WidgetValue* theVa
         }
         if (aFPoint)
           isDone = setAttribute(aFPoint);
-      }*/
+      }
     }
   }
   return isDone;
@@ -80,8 +79,8 @@ bool ModuleBase_WidgetFeatureOrAttribute::storeValue(FeaturePtr theFeature) cons
           boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
 
   ModuleBase_WidgetFeatureOrAttribute* that = (ModuleBase_WidgetFeatureOrAttribute*) this;
-  if (feature())
-    aRef->setObject(feature());
+  if (object())
+    aRef->setObject(object());
   else if (myAttribute)
     aRef->setAttr(myAttribute);
 
@@ -99,7 +98,7 @@ bool ModuleBase_WidgetFeatureOrAttribute::restoreValue(FeaturePtr theFeature)
 
   FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
   if (aFeature) {
-    setFeature(aFeature);
+    setObject(aFeature);
     myAttribute = aRef->attr();
 
     std::string aText = "";
index e43f341e5797432d8542ee3d4f7d9eb5eb7c478e..871654bd21c99da06bc005768d8b300c1be95419 100644 (file)
@@ -33,12 +33,12 @@ bool ModuleBase_WidgetPoint2dDistance::setValue(ModuleBase_WidgetValue* theValue
                          dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
     if (aFeatureValue) {
       boost::shared_ptr<GeomAPI_Pnt2d> aPnt = aFeatureValue->point();
-      // TODO
-      /*FeaturePtr aFeature = aFeatureValue->feature();
+      ObjectPtr aObject = aFeatureValue->object();
+      FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
       if (aFeature && aPnt) {
         setPoint(aFeature, aPnt);
         isDone = true;
-      }*/
+      }
     }
   }
   return isDone;
index 8e05584b9cb6e9bdf84d4e31990b6c9216e803f4..a5c40e7e80dffc669766d3de0bc923b31ed31def 100644 (file)
@@ -240,7 +240,8 @@ void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
           Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAIS);
           aSketchOp->setSketchPlane(aAISShape->Shape());
         }
-      }
+      } else 
+        aSketchOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
     } else
       aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
   }
@@ -318,25 +319,24 @@ void PartSet_Module::onMultiSelectionEnabled(bool theEnabled)
   aViewer->enableMultiselection(theEnabled);
 }
 
-void PartSet_Module::onStopSelection(const QFeatureList& theFeatures, const bool isStop)
+void PartSet_Module::onStopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop)
 {
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
   if (!isStop) {
-    QFeatureList::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
-    for (; anIt != aLast; anIt++) {
-      activateFeature((*anIt), false);
+    foreach(ObjectPtr aObject, theFeatures) {
+      activateFeature(aObject, false);
     }
   }
-  QResultList aResults;
-  foreach(FeaturePtr aFeature, theFeatures) {
-    if (aFeature->results().size() > 0) {
+  //ObjectPtr aResults;
+  //foreach(ObjectPtr aFeature, theFeatures) {
+/* TODO    if (aFeature->results().size() > 0) {
       const std::list<ResultPtr>& aResList = aFeature->results();
       std::list<ResultPtr>::const_iterator aIt;
       for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt)
         aResults.append(*aIt);
     }
-  }
-  aDisplayer->stopSelection(aResults, isStop, false);
+  }*/
+  aDisplayer->stopSelection(theFeatures, isStop, false);
 
   XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
   aViewer->enableSelection(!isStop);
@@ -344,7 +344,7 @@ void PartSet_Module::onStopSelection(const QFeatureList& theFeatures, const bool
   aDisplayer->updateViewer();
 }
 
-void PartSet_Module::onSetSelection(const QResultList& theFeatures)
+void PartSet_Module::onSetSelection(const QList<ObjectPtr>& theFeatures)
 {
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
   aDisplayer->setSelected(theFeatures, false);
@@ -440,10 +440,10 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI
     connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)),
             this, SLOT(onMultiSelectionEnabled(bool)));
 
-    connect(aPreviewOp, SIGNAL(stopSelection(const QFeatureList&, const bool)),
-            this, SLOT(onStopSelection(const QFeatureList&, const bool)));
-    connect(aPreviewOp, SIGNAL(setSelection(const QFeatureList&)),
-            this, SLOT(onSetSelection(const QFeatureList&)));
+    connect(aPreviewOp, SIGNAL(stopSelection(const QList<ObjectPtr>&, const bool)),
+            this, SLOT(onStopSelection(const QList<ObjectPtr>&, const bool)));
+    connect(aPreviewOp, SIGNAL(setSelection(const QList<ObjectPtr>&)),
+            this, SLOT(onSetSelection(const QList<ObjectPtr>&)));
 
      connect(aPreviewOp, SIGNAL(closeLocalContext()),
              this, SLOT(onCloseLocalContext()));
@@ -532,10 +532,9 @@ void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
     boost::shared_ptr<SketchPlugin_Feature> aSPFeature = 
       boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
     if (aSPFeature) {
-      showPlanes();
-      //boost::shared_ptr<GeomAPI_AISObject> anAIS = 
-      //  aSPFeature->getAISObject(aDisplayer->getAISObject(aResult));
-      //aDisplayer->redisplay(aResult, anAIS, false);
+      PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
+      if (aSketchOp && !aSketchOp->hasSketchPlane())
+        showPlanes();
     }
   }
   else
@@ -545,15 +544,18 @@ void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
     aDisplayer->updateViewer();
 }
 
-void PartSet_Module::activateFeature(FeaturePtr theFeature, const bool isUpdateViewer)
+void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateViewer)
 {
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
-/* TODO  if (aPreviewOp) {
-    XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-    aDisplayer->activateInLocalContext(theFeature->firstResult(), aPreviewOp->getSelectionModes(theFeature),
-                                       isUpdateViewer);
-  }*/
+  if (aPreviewOp) {
+    PartSet_OperationSketch* aOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
+    if (!aOp) {
+      XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+      aDisplayer->activateInLocalContext(theFeature, aPreviewOp->getSelectionModes(theFeature),
+                                         isUpdateViewer);
+    }
+  }
 }
 
 void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
index 83bb0b2d08c89c3c34563c33711c01fea57709b4..d95a75ebed77a62be1fea5b7629fd646df5827bc 100644 (file)
@@ -62,7 +62,7 @@ public:
   /// Activates the feature in the displayer
   /// \param theFeature the feature instance to be displayed
   /// \param isUpdateViewer the flag whether the viewer should be updated
-  void activateFeature(FeaturePtr theFeature,
+  void activateFeature(ObjectPtr theFeature,
                        const bool isUpdateViewer);
 
   /// Updates current operation preview, if it has it.
@@ -122,11 +122,11 @@ public slots:
   /// SLOT, to stop or start selection mode for the features
   /// \param theFeatures a list of features to be disabled
   /// \param theToStop the boolean state whether it it stopped or non stopped
-  void onStopSelection(const QFeatureList& theFeatures, const bool isStop);
+  void onStopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop);
 
   /// SLOT, to set selection
   /// \param theFeatures a list of features to be selected
-  void onSetSelection(const QResultList& theFeatures);
+  void onSetSelection(const QList<ObjectPtr>& theFeatures);
 
   /// SLOT, to close the viewer local context
   void onCloseLocalContext();
index 2e96339ff2fdeb63b218cee443259e817be9a3c3..44cf5e5a3d2f954c159cbf90a11a818313437784 100644 (file)
@@ -75,7 +75,7 @@ bool PartSet_OperationFeatureCreate::isGranted(ModuleBase_IOperation* theOperati
   return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type();
 }
 
-std::list<int> PartSet_OperationFeatureCreate::getSelectionModes(FeaturePtr theFeature) const
+std::list<int> PartSet_OperationFeatureCreate::getSelectionModes(ObjectPtr theFeature) const
 {
   std::list<int> aModes;
   if (theFeature != feature())
@@ -149,17 +149,14 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle
   if (!theSelected.empty()) {
     ModuleBase_ViewerPrs aPrs = theSelected.front();
     aFeature = aPrs.object();
-  }
-  // TODO
-  //else
-  //  aFeature = feature(); // for the widget distance only
+  } else
+    aFeature = feature(); // for the widget distance only
 
-  // TODO
-  /*bool isApplyed = setWidgetValue(aFeature, aX, anY);
+  bool isApplyed = setWidgetValue(aFeature, aX, anY);
   if (isApplyed) {
     flushUpdated();
     emit activateNextWidget(myActiveWidget);
-  }*/
+  }
 }
 
 void PartSet_OperationFeatureCreate::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
@@ -280,7 +277,7 @@ FeaturePtr PartSet_OperationFeatureCreate::createFeature(const bool theFlushMess
   return aNewFeature;
 }
 
-bool PartSet_OperationFeatureCreate::setWidgetValue(FeaturePtr theFeature, double theX, double theY)
+bool PartSet_OperationFeatureCreate::setWidgetValue(ObjectPtr theFeature, double theX, double theY)
 {
   ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature();
   aValue->setObject(theFeature);
index f5823d6c1de244d119f8b23a423cd7f192509719..b0d9918875df89341a0c951229e6f666fa0d6fd9 100644 (file)
@@ -52,7 +52,7 @@ public:
   /// 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(FeaturePtr theFeature) const;
+  virtual std::list<int> getSelectionModes(ObjectPtr theFeature) const;
 
   /// Initializes the operation with previously created feature. It is used in sequental operations
   virtual void initFeature(FeaturePtr theFeature);
@@ -120,7 +120,7 @@ protected:
   /// \param theX the horizontal coordinate
   /// \param theY the vertical coordinate
   /// \return true if the point is set
-  bool setWidgetValue(FeaturePtr theFeature, double theX, double theY);
+  bool setWidgetValue(ObjectPtr theFeature, double theX, double theY);
 
 private:
   FeaturePtr myInitFeature; ///< the initial feature
index 5b107d34dcba5b93336278c02222f8f04c450558..7975baa652d223a39a1765023498965bc8b29277 100644 (file)
@@ -53,7 +53,7 @@ bool PartSet_OperationFeatureEdit::isGranted(ModuleBase_IOperation* theOperation
   return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type();
 }
 
-std::list<int> PartSet_OperationFeatureEdit::getSelectionModes(FeaturePtr theFeature) const
+std::list<int> PartSet_OperationFeatureEdit::getSelectionModes(ObjectPtr theFeature) const
 {
   return PartSet_OperationSketchBase::getSelectionModes(theFeature);
 }
@@ -78,25 +78,21 @@ void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3
     aFeature = theHighlighted.front().object();
   if (!aFeature && !theSelected.empty()) // changed for a constrain
     aFeature = theSelected.front().object();
-  // TODO
-  /*if (!aFeature || aFeature != feature())
-  {
+  if (!aFeature || aFeature != feature()) {
     commit();
     emit featureConstructed(feature(), FM_Deactivation);
 
     bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
     if(aHasShift && !theHighlighted.empty()) {
-      QResultList aSelected;
-      // TODO
+      QList<ObjectPtr> aSelected;
       aSelected.push_back(feature());
-      aSelected.push_back(theHighlighted.front().result());
+      aSelected.push_back(theHighlighted.front().object());
       emit setSelection(aSelected);
     }
-    // TODO
     else if (aFeature) {
       restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
     }
-  }*/
+  }
 }
 
 void PartSet_OperationFeatureEdit::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
@@ -175,11 +171,11 @@ void PartSet_OperationFeatureEdit::blockSelection(bool isBlocked, const bool isR
     return;
 
   myIsBlockedSelection = isBlocked;
-  QFeatureList aFeatureList;
+  QList<ObjectPtr> aFeatureList;
   aFeatureList.append(feature());
 
   if (isBlocked) {
-    emit setSelection(QFeatureList());
+    emit setSelection(QList<ObjectPtr>());
     emit stopSelection(aFeatureList, true);
   }
   else {
index f64e25ab11c1b213b0e8431e8e3ed334d378b009..f893a964e7b99d917ab11087f3dd8f8d73276ae9 100644 (file)
@@ -68,7 +68,7 @@ public:
   /// 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(FeaturePtr theFeature) const;
+  virtual std::list<int> getSelectionModes(ObjectPtr theFeature) const;
 
   /// Initializes the operation with previously created feature. It is used in sequental operations
   virtual void initFeature(FeaturePtr theFeature);
index d66acf804a2ba1cbe435c259ec1bce70da234afe..b08818ec7442a41cb8a9c8694fa42ea7ec1f230e 100644 (file)
@@ -165,13 +165,13 @@ void PartSet_OperationFeatureEditMulti::blockSelection(bool isBlocked, const boo
     return;
 
   myIsBlockedSelection = isBlocked;
-  QFeatureList aFeatureList;
+  QList<ObjectPtr> aFeatureList;
   std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(),
                                             aLast = myFeatures.end();
   /*for(; anIt != aLast; anIt++)
     aFeatureList.append((*anIt).feature());*/
   if (isBlocked) {
-    emit setSelection(QFeatureList());
+    emit setSelection(QList<ObjectPtr>());
     emit stopSelection(aFeatureList, true);
   }
   else {
index c209af34b548f27dbd995f8143850206d5d77cc3..88a0e156e94139b6cad956ec126a5493510195bd 100644 (file)
@@ -86,10 +86,10 @@ void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_Vie
     if (theHighlighted.size() == 1) {
       ObjectPtr aFeature = theHighlighted.front().object();
       if (aFeature) {
-        std::string anOperationType = PartSet_OperationFeatureEdit::Type();
-        if (theSelected.size() > 1)
-          anOperationType = PartSet_OperationFeatureEditMulti::Type();
-        // TODO restartOperation(anOperationType, aFeature);
+        std::string anOperationType = (theSelected.size() > 1)?
+          PartSet_OperationFeatureEditMulti::Type() :
+          PartSet_OperationFeatureEdit::Type();
+        restartOperation(anOperationType, aFeature);
       }
     }
     else
@@ -109,9 +109,8 @@ void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_Vi
     /// for these objects
     if (theSelected.size() == 1) {
       ObjectPtr aFeature = theSelected.front().object();
-      // TODO
-      //if (aFeature)
-      //  restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
+      if (aFeature)
+        restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
     }
   }
 }
index 7c6864f7cc7d4ffc9c6941bbd44056cc5e9f1b53..d82aae96b4d9ed8dcda9ba56ce72644cfe1c9bde 100644 (file)
@@ -50,18 +50,20 @@ std::list<FeaturePtr> PartSet_OperationSketchBase::subFeatures() const
   return std::list<FeaturePtr>();
 }
 
-std::list<int> PartSet_OperationSketchBase::getSelectionModes(FeaturePtr theFeature) const
+std::list<int> PartSet_OperationSketchBase::getSelectionModes(ObjectPtr theFeature) const
 {
   std::list<int> aModes;
-  if (PartSet_Tools::isConstraintFeature(theFeature->getKind())) {
-      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));
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
+  if (aFeature) {
+    if (PartSet_Tools::isConstraintFeature(aFeature->getKind())) {
+        aModes.clear();
+        aModes.push_back(AIS_DSM_Text);
+        aModes.push_back(AIS_DSM_Line);
+        return aModes;
+    }
   }
+  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)
@@ -118,7 +120,7 @@ void PartSet_OperationSketchBase::keyReleased(std::string theName, QKeyEvent* th
 }
 
 void PartSet_OperationSketchBase::restartOperation(const std::string& theType,
-                                                   FeaturePtr theFeature)
+                                                   ObjectPtr theFeature)
 {
   emit launchOperation(theType, theFeature);
 }
index 449d65834959d8753fec95e39627694f9d30261f..7916815d049e9b59a0af216966c41927103bc734 100644 (file)
@@ -58,7 +58,7 @@ public:
   /// 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(FeaturePtr theFeature) const;
+  virtual std::list<int> getSelectionModes(ObjectPtr theFeature) const;
 
   /// Initializes the operation with previously created feature. It is used in sequental operations
   virtual void initFeature(FeaturePtr theFeature) {}
@@ -116,13 +116,13 @@ public:
   /// \param theType a type of an operation started
   /// theFeature the operation argument
   void restartOperation(const std::string& theType,
-         FeaturePtr theFeature = FeaturePtr());
+         ObjectPtr theFeature = ObjectPtr());
 
 signals:
   /// signal about the request to launch operation
   /// theName the operation name
   /// theFeature the operation argument
-  void launchOperation(std::string theName, FeaturePtr theFeature);
+  void launchOperation(std::string theName, ObjectPtr theFeature);
   /// Signal about the feature construing is finished
   /// \param theFeature the result feature
   /// \param theMode the mode of the feature modification
@@ -138,10 +138,10 @@ signals:
   /// signal to enable/disable selection in the viewer
   /// \param theFeatures a list of features to be disabled
   /// \param theToStop the boolean state whether it it stopped or non stopped
-  void stopSelection(const QFeatureList& theFeatures, const bool theToStop);
+  void stopSelection(const QList<ObjectPtr>& theFeatures, const bool theToStop);
   /// signal to set selection in the viewer
   /// \param theFeatures a list of features to be disabled
-  void setSelection(const QFeatureList& theFeatures);
+  void setSelection(const QList<ObjectPtr>& theFeatures);
 
   /// signal to close the operation local context if it is opened
   void closeLocalContext();
index 47e3cf87052a94de060529151200c4d155d9cdf0..fbf819b15a1a7f53f32d641a81807a1b611aeb00 100644 (file)
@@ -185,7 +185,7 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop)
     //aDisplayer->activateInLocalContext(aFeature, aModes, true);
     myTestObject = aFeature->firstResult();
 
-    QResultList aFeatureList;
+    QList<ObjectPtr> aFeatureList;
     aFeatureList.append(myTestObject);
     aDisplayer->setSelected(aFeatureList, true);
   }
index 92ae9d2a4b4b5ae98788c909f14474723c03e1ff..f124270b5b59bff430cb926cc1ab5aa602087cdd 100644 (file)
@@ -152,7 +152,7 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer)
   }
 }
 
-void XGUI_Displayer::activateInLocalContext(ResultPtr theResult,
+void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult,
                                          const std::list<int>& theModes, const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -186,14 +186,14 @@ void XGUI_Displayer::activateInLocalContext(ResultPtr theResult,
     updateViewer();
 }
 
-void XGUI_Displayer::stopSelection(const QResultList& theResults, const bool isStop,
+void XGUI_Displayer::stopSelection(const QList<ObjectPtr>& theResults, const bool isStop,
                                    const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
 
   Handle(AIS_Shape) anAIS;
-  QResultList::const_iterator anIt = theResults.begin(), aLast = theResults.end();
-  ResultPtr aFeature;
+  QList<ObjectPtr>::const_iterator anIt = theResults.begin(), aLast = theResults.end();
+  ObjectPtr aFeature;
   for (; anIt != aLast; anIt++) {
     aFeature = *anIt;
     if (isVisible(aFeature))
@@ -216,7 +216,7 @@ void XGUI_Displayer::stopSelection(const QResultList& theResults, const bool isS
     updateViewer();
 }
 
-void XGUI_Displayer::setSelected(const QResultList& theResults, const bool isUpdateViewer)
+void XGUI_Displayer::setSelected(const QList<ObjectPtr>& theResults, const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
   // we need to unhighligth objects manually in the current local context
@@ -226,13 +226,12 @@ void XGUI_Displayer::setSelected(const QResultList& theResults, const bool isUpd
     aLocalContext->UnhilightLastDetected(myWorkshop->viewer()->activeView());
 
   aContext->ClearSelected();
-  foreach(ResultPtr aResult, theResults) {
+  foreach(ObjectPtr aResult, theResults) {
     if (myResult2AISObjectMap.find(aResult) == myResult2AISObjectMap.end()) 
-      return;
+      continue;
 
     boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[aResult];
-    if (anObj)
-    {
+    if (anObj) {
       Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
       if (!anAIS.IsNull())
         aContext->AddOrRemoveSelected(anAIS, false);
index df65443a87164d3493862be1e3cf8ebebb9516ec..226a18c7b6954009afb813b9623eacac013741e4 100644 (file)
@@ -70,14 +70,14 @@ public:
   /// \param theShape a shape
   /// \param theMode a list of local selection modes
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void activateInLocalContext(ResultPtr theFeature,
+  void activateInLocalContext(ObjectPtr theFeature,
                               const std::list<int>& theModes, const bool isUpdateViewer = true);
 
   /// Stop the current selection and color the given features to the selection color
   /// \param theFeatures a list of features to be disabled
   /// \param theToStop the boolean state whether it it stopped or non stopped
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void stopSelection(const QResultList& theFeatures, const bool isStop,
+  void stopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop,
                      const bool isUpdateViewer);
 
   /**
@@ -85,7 +85,7 @@ public:
   * \param theFeatures a list of features to be selected
   * isUpdateViewer the parameter whether the viewer should be update immediatelly
   */
-  void setSelected(const QResultList& theFeatures, bool isUpdateViewer = true);
+  void setSelected(const QList<ObjectPtr>& theFeatures, bool isUpdateViewer = true);
 
   /// Erase the feature and a shape.
   /// \param theFeature a feature instance
index 45788794fd2570b3871679f5008a39dcebe86657..7b4db23661673fcab2ffc55a5631e4f5bdbf3b50 100644 (file)
@@ -531,12 +531,15 @@ QModelIndex XGUI_DocumentDataModel::objectIndex(const ObjectPtr theObject) const
   DocumentPtr aDoc = theObject->document();
   if (aDoc == aRootDoc) {
     // This feature belongs to histrory or top model
-    if (theObject->isInHistory()) {
+    FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+    if (aFeature) {
       int aId;
-      for (aId = 0; aId < aRootDoc->size(ModelAPI_Feature::group()); aId++) {
+      int aNb = aRootDoc->size(ModelAPI_Feature::group());
+      for (aId = 0; aId < aNb; aId++) {
         if (theObject == aRootDoc->object(ModelAPI_Feature::group(), aId))
           break;
       }
+      Q_ASSERT(aId < aNb);
       return index(aId + historyOffset(), 0, QModelIndex());
     } else {
       QModelIndex aIndex = myModel->objectIndex(theObject);
index 481db73366a3a4f06714ef767a03a414fbefd2fa..caf78cededfa473823d177c7ad21591edcd6f852 100644 (file)
@@ -43,14 +43,8 @@ void XGUI_SelectionMgr::connectViewers()
 void XGUI_SelectionMgr::onObjectBrowserSelection()
 {
   QList<ObjectPtr> aObjects = myWorkshop->objectBrowser()->selectedObjects();
-  QResultList aResults;
-  foreach(ObjectPtr aObject, aObjects) {
-    ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(aObject);
-    if (aRes)
-      aResults.append(aRes);
-  }
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-  aDisplayer->setSelected(aResults);
+  aDisplayer->setSelected(aObjects);
   emit selectionChanged();
 }
 
@@ -65,7 +59,10 @@ void XGUI_SelectionMgr::onViewerSelection()
     if (aResult)
       aFeatures.append(aResult);
   }
+  bool aBlocked = myWorkshop->objectBrowser()->blockSignals(true);
   myWorkshop->objectBrowser()->setObjectsSelected(aFeatures);
+  myWorkshop->objectBrowser()->blockSignals(aBlocked);
+
   emit selectionChanged();
 }