]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
ModuleBase adapted to new model structure
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 14 Jul 2014 11:11:53 +0000 (15:11 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 14 Jul 2014 11:11:53 +0000 (15:11 +0400)
24 files changed:
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_ISelection.h
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_WidgetBoolValue.cpp
src/ModuleBase/ModuleBase_WidgetBoolValue.h
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/ModuleBase/ModuleBase_WidgetDoubleValue.h
src/ModuleBase/ModuleBase_WidgetFeature.cpp
src/ModuleBase/ModuleBase_WidgetFeature.h
src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
src/ModuleBase/ModuleBase_WidgetPoint2D.h
src/ModuleBase/ModuleBase_WidgetSelector.cpp
src/ModuleBase/ModuleBase_WidgetSelector.h
src/PartSet/PartSet_TestOCC.cpp
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_DataTreeModel.h
src/XGUI/XGUI_DocumentDataModel.h
src/XGUI/XGUI_ObjectsBrowser.cpp
src/XGUI/XGUI_ObjectsBrowser.h
src/XGUI/XGUI_PartDataModel.h
src/XGUI/XGUI_Selection.h
src/XGUI/XGUI_SelectionMgr.cpp

index b21756a5c39ff3dc9c72c13d5cbfd6696a9308cc..350af8c02bd923f2d018b0ecd1300cc84db03312 100644 (file)
@@ -25,6 +25,7 @@ SET(PROJECT_HEADERS
        ModuleBase_SelectionValidator.h
        ModuleBase_ISelection.h
        ModuleBase_ViewerPrs.h
+       ModuleBase_Tools.h
 )
 
 SET(PROJECT_SOURCES
@@ -44,6 +45,7 @@ SET(PROJECT_SOURCES
        ModuleBase_WidgetPoint2dDistance.cpp
        ModuleBase_WidgetValue.cpp
        ModuleBase_WidgetValueFeature.cpp
+       ModuleBase_Tools.cpp
 )
 
 SET(PROJECT_LIBRARIES
index 0519985025d0496684909227602d4c7f61899a56..9a9e52ed7d94c4c4e290c08160062d22180471e3 100644 (file)
@@ -33,7 +33,12 @@ public:
   /**
   * Returns list of features currently selected in 3d viewer
   */
-  virtual QFeatureList selectedFeatures() const = 0;
+  virtual QList<ObjectPtr> selectedObjects() const = 0;
+
+  /**
+  * Returns list of currently selected results
+  */
+  virtual QResultList selectedResults() const = 0;
   
   //! Returns list of currently selected QModelIndexes
   virtual QModelIndexList selectedIndexes() const = 0;
index 720f089331c08703fe22d3a56f2532e62d63c6d8..178eb5d6316cf0db2bb2cf77c712614f498f7a0c 100644 (file)
@@ -17,9 +17,9 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QObject* theParent, const Config_
   myAttributeID = theData ? theData->widgetId() : "";
 }
 
-bool ModuleBase_ModelWidget::isInitialized(FeaturePtr theFeature) const
+bool ModuleBase_ModelWidget::isInitialized(ObjectPtr theObject) const
 {
-  return theFeature->data()->attribute(attributeID())->isInitialized();
+  return theObject->data()->attribute(attributeID())->isInitialized();
 }
 
 bool ModuleBase_ModelWidget::focusTo()
index 96154b37c4245dc85afd378d12cd29f8b0c19bef..8e4b010f6fce72e933ced50fec39124e07608790 100644 (file)
@@ -43,15 +43,15 @@ public:
   virtual bool setValue(ModuleBase_WidgetValue* theValue) { return false; };
 
   /// Returns the state whether the attribute of the feature is initialized
-  /// \param theFeature a model feature to be checked
+  /// \param theObject a model feature to be checked
   /// \return the boolean result
-  bool isInitialized(FeaturePtr theFeature) const;
+  bool isInitialized(ObjectPtr theObject) const;
 
   /// Saves the internal parameters to the given feature
-  /// \param theFeature a model feature to be changed
-  virtual bool storeValue(FeaturePtr theFeature) const = 0;
+  /// \param theObject a model feature to be changed
+  virtual bool storeValue(ObjectPtr theObject) const = 0;
 
-  virtual bool restoreValue(FeaturePtr theFeature) = 0;
+  virtual bool restoreValue(ObjectPtr theObject) = 0;
 
   /// Set focus to the first control of the current widget. The focus policy of the control is checked.
   /// If the widget has the NonFocus focus policy, it is skipped.
index 58a7f371dccd94e57d8b198c6ca936208fa57de3..81be8438b667393ef320e5b2030f3931002aa6be 100644 (file)
@@ -40,9 +40,9 @@ QWidget* ModuleBase_WidgetBoolValue::getControl() const
   return myCheckBox; 
 }
 
-bool ModuleBase_WidgetBoolValue::storeValue(FeaturePtr theFeature) const
+bool ModuleBase_WidgetBoolValue::storeValue(ObjectPtr theObject) const
 {
-  DataPtr aData = theFeature->data();
+  DataPtr aData = theObject->data();
   boost::shared_ptr<ModelAPI_AttributeBoolean> aBool = aData->boolean(attributeID());
 
   if (aBool->value() != myCheckBox->isChecked()) {
@@ -52,9 +52,9 @@ bool ModuleBase_WidgetBoolValue::storeValue(FeaturePtr theFeature) const
   return true;
 }
 
-bool ModuleBase_WidgetBoolValue::restoreValue(FeaturePtr theFeature)
+bool ModuleBase_WidgetBoolValue::restoreValue(ObjectPtr theObject)
 {
-  DataPtr aData = theFeature->data();
+  DataPtr aData = theObject->data();
   boost::shared_ptr<ModelAPI_AttributeBoolean> aRef = aData->boolean(attributeID());
 
   bool isBlocked = myCheckBox->blockSignals(true);
index 6f32ef3ef87183b2961ead0fb7389d444a4a77c9..3969e643e47a3dde01d7deac7fb1a6d0b40fc3d0 100644 (file)
@@ -24,10 +24,10 @@ public:
   virtual ~ModuleBase_WidgetBoolValue();
 
   /// Saves the internal parameters to the given feature
-  /// \param theFeature a model feature to be changed
-  virtual bool storeValue(FeaturePtr theFeature) const;
+  /// \param theObject a model feature to be changed
+  virtual bool storeValue(ObjectPtr theObject) const;
 
-  virtual bool restoreValue(FeaturePtr theFeature);
+  virtual bool restoreValue(ObjectPtr theObject);
 
   /// Returns list of widget controls
   /// \return a control list
index 19828f008bd3ab8028c93a5ce055d864ee2bc8c1..587e1e04141fd09bb49e167d87b692ca623862c6 100644 (file)
@@ -88,9 +88,9 @@ ModuleBase_WidgetDoubleValue::~ModuleBase_WidgetDoubleValue()
 {
 }
 
-bool ModuleBase_WidgetDoubleValue::storeValue(FeaturePtr theFeature) const
+bool ModuleBase_WidgetDoubleValue::storeValue(ObjectPtr theObject) const
 {
-  DataPtr aData = theFeature->data();
+  DataPtr aData = theObject->data();
   AttributeDoublePtr aReal = aData->real(attributeID());
   if (aReal->value() != mySpinBox->value()) {
     aReal->setValue(mySpinBox->value());
@@ -99,9 +99,9 @@ bool ModuleBase_WidgetDoubleValue::storeValue(FeaturePtr theFeature) const
   return true;
 }
 
-bool ModuleBase_WidgetDoubleValue::restoreValue(FeaturePtr theFeature)
+bool ModuleBase_WidgetDoubleValue::restoreValue(ObjectPtr theObject)
 {
-  DataPtr aData = theFeature->data();
+  DataPtr aData = theObject->data();
   AttributeDoublePtr aRef = aData->real(attributeID());
 
   bool isBlocked = mySpinBox->blockSignals(true);
index 2a5b6c2a1c28b63db3ccc283774c8a347f3b6f7f..909855d18e9712d349fe3794e080839b56e43621 100644 (file)
@@ -25,10 +25,10 @@ public:
   virtual ~ModuleBase_WidgetDoubleValue();
 
   /// Saves the internal parameters to the given feature
-  /// \param theFeature a model feature to be changed
-  virtual bool storeValue(FeaturePtr theFeature) const;
+  /// \param theObject a model feature to be changed
+  virtual bool storeValue(ObjectPtr theObject) const;
 
-  virtual bool restoreValue(FeaturePtr theFeature);
+  virtual bool restoreValue(ObjectPtr theObject);
 
   /// Returns list of widget controls
   /// \return a control list
index bfcc1956edf8d9cae610530582213c8777e21658..160965a1e4de25f7c7048f2e045087d89a2c8fee 100644 (file)
@@ -70,7 +70,7 @@ bool ModuleBase_WidgetFeature::setValue(ModuleBase_WidgetValue* theValue)
 
 bool ModuleBase_WidgetFeature::setFeature(const FeaturePtr& theFeature)
 {
-  if (!theFeature || !myFeatureKinds.contains(theFeature->getKind().c_str()))
+  if (!myFeatureKinds.contains(theFeature->getKind().c_str()))
     return false;
 
   myFeature = theFeature;
@@ -79,29 +79,36 @@ bool ModuleBase_WidgetFeature::setFeature(const FeaturePtr& theFeature)
   return true;
 }
 
-bool ModuleBase_WidgetFeature::storeValue(FeaturePtr theFeature) const
+bool ModuleBase_WidgetFeature::storeValue(ObjectPtr theObject) const
 {
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+  if (!aFeature)
+    return false;
+  boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
   boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
           boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
 
   ModuleBase_WidgetFeature* that = (ModuleBase_WidgetFeature*) this;
-  aRef->setFeature(myFeature);
-  theFeature->execute();
+  aRef->setObject(myFeature);
+  aFeature->execute();
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
 
   return true;
 }
 
-bool ModuleBase_WidgetFeature::restoreValue(FeaturePtr theFeature)
+bool ModuleBase_WidgetFeature::restoreValue(ObjectPtr theObject)
 {
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  boost::shared_ptr<ModelAPI_Data> aData = theObject->data();
   boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
           boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
 
-  myFeature = aRef->feature();
-  myEditor->setText(myFeature ? myFeature->data()->name().c_str() : "");
-  return true;
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
+  if (aFeature) {
+    myFeature = aFeature;
+    myEditor->setText(myFeature ? myFeature->data()->name().c_str() : "");
+    return true;
+  }
+  return false;
 }
 
 QWidget* ModuleBase_WidgetFeature::getControl() const
index 329079118288b5cf9431cb45044a38d7a60891f4..c57bd531e6c41bcabfb5a96e7c26f8f86b47996b 100644 (file)
@@ -40,9 +40,9 @@ public:
 
   /// Saves the internal parameters to the given feature
   /// \param theFeature a model feature to be changed
-  virtual bool storeValue(FeaturePtr theFeature) const;
+  virtual bool storeValue(ObjectPtr theObject) const;
 
-  virtual bool restoreValue(FeaturePtr theFeature);
+  virtual bool restoreValue(ObjectPtr theObject);
 
   /// Returns the internal parent wiget control, that can be shown anywhere
   /// \returns the widget
@@ -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& theFeature);
+  bool setFeature(const FeaturePtr& theObject);
 
   /// Returns current widget feature
   /// \return the feature
-  const FeaturePtr& feature() const { return myFeature; }
+  const FeaturePtr feature() const { return myFeature; }
 
   /// Returns the widget editor
   /// \return the editor
index b3165fbf060f441fd3b9903f06b48371f1148c36..c275f22386259733310c2dc681855dd6be774088 100644 (file)
@@ -80,7 +80,7 @@ bool ModuleBase_WidgetFeatureOrAttribute::storeValue(FeaturePtr theFeature) cons
 
   ModuleBase_WidgetFeatureOrAttribute* that = (ModuleBase_WidgetFeatureOrAttribute*) this;
   if (feature())
-    aRef->setFeature(feature());
+    aRef->setObject(feature());
   else if (myAttribute)
     aRef->setAttr(myAttribute);
 
@@ -96,18 +96,21 @@ bool ModuleBase_WidgetFeatureOrAttribute::restoreValue(FeaturePtr theFeature)
   boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
           boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
 
-  FeaturePtr aFeature = aRef->feature();
-  setFeature(aFeature);
-  myAttribute = aRef->attr();
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
+  if (aFeature) {
+    setFeature(aFeature);
+    myAttribute = aRef->attr();
 
-  std::string aText = "";
-  if (aFeature)
-    aText = aFeature->data()->name().c_str();
-  else if (myAttribute)
-    aText = myAttribute->attributeType().c_str();
+    std::string aText = "";
+    if (aFeature)
+      aText = aFeature->data()->name().c_str();
+    else if (myAttribute)
+      aText = myAttribute->attributeType().c_str();
 
-  editor()->setText(aText.c_str());
-  return true;
+    editor()->setText(aText.c_str());
+    return true;
+  }
+  return false;
 }
 
 bool ModuleBase_WidgetFeatureOrAttribute::setAttribute(const boost::shared_ptr<ModelAPI_Attribute>& theAttribute)
index 8407084edf44b233cac4b5341a19d9c33e8e462b..51db5770b64f28dc04fb1aa6b88423e1fb7bcf1f 100644 (file)
@@ -101,9 +101,9 @@ void ModuleBase_WidgetPoint2D::setPoint(const boost::shared_ptr<GeomAPI_Pnt2d>&
   emit valuesChanged();
 }
 
-bool ModuleBase_WidgetPoint2D::storeValue(FeaturePtr theFeature) const
+bool ModuleBase_WidgetPoint2D::storeValue(ObjectPtr theObject) const
 {
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  boost::shared_ptr<ModelAPI_Data> aData = theObject->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(attributeID()));
 
@@ -116,9 +116,9 @@ bool ModuleBase_WidgetPoint2D::storeValue(FeaturePtr theFeature) const
   return true;
 }
 
-bool ModuleBase_WidgetPoint2D::restoreValue(FeaturePtr theFeature)
+bool ModuleBase_WidgetPoint2D::restoreValue(ObjectPtr theObject)
 {
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  boost::shared_ptr<ModelAPI_Data> aData = theObject->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(attributeID()));
 
@@ -158,11 +158,11 @@ bool ModuleBase_WidgetPoint2D::eventFilter(QObject *theObject, QEvent *theEvent)
   return ModuleBase_ModelWidget::eventFilter(theObject, theEvent);
 }
 
-bool ModuleBase_WidgetPoint2D::initFromPrevious(FeaturePtr theFeature)
+bool ModuleBase_WidgetPoint2D::initFromPrevious(ObjectPtr theObject)
 {
   if (myOptionParam.length() == 0)
     return false;
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  boost::shared_ptr<ModelAPI_Data> aData = theObject->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(myOptionParam));
   if (aPoint) {
@@ -172,7 +172,7 @@ bool ModuleBase_WidgetPoint2D::initFromPrevious(FeaturePtr theFeature)
     this->blockSignals(isBlocked);
 
     emit valuesChanged();
-    emit storedPoint2D(theFeature, myOptionParam);
+    emit storedPoint2D(theObject, myOptionParam);
     return true;
   }
   return false;
index 4a34641a7683888d3f42a109959070dff53e645f..5c72695209625ec94169c2c433678a4e745ae571 100644 (file)
@@ -39,10 +39,10 @@ public:
   virtual bool setValue(ModuleBase_WidgetValue* theValue);
 
   /// Saves the internal parameters to the given feature
-  /// \param theFeature a model feature to be changed
-  virtual bool storeValue(FeaturePtr theFeature) const;
+  /// \param theObject a model feature to be changed
+  virtual bool storeValue(ObjectPtr theObject) const;
 
-  virtual bool restoreValue(FeaturePtr theFeature);
+  virtual bool restoreValue(ObjectPtr theObject);
 
   /// Returns the internal parent wiget control, that can be shown anywhere
   /// \returns the widget
@@ -57,13 +57,13 @@ public:
   /// \param theEvent the processed event
   virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
 
-  bool initFromPrevious(FeaturePtr theFeature);
+  bool initFromPrevious(ObjectPtr theObject);
 
 signals:
   /// Signal about the point 2d set to the feature
   /// \param the feature
   /// \param the attribute of the feature
-  void storedPoint2D(FeaturePtr theFeature, const std::string& theAttribute);
+  void storedPoint2D(ObjectPtr theObject, const std::string& theAttribute);
 
 protected:
   /// Fill the widget values by given point
index 36f6af51fff4cbbfc62fa526fe4b0eb211bf0d9e..88aa9c3816570569346f60c04b4290928558197c 100644 (file)
@@ -99,14 +99,14 @@ ModuleBase_WidgetSelector::~ModuleBase_WidgetSelector()
 }
 
 //********************************************************************
-bool ModuleBase_WidgetSelector::storeValue(FeaturePtr theFeature) const
+bool ModuleBase_WidgetSelector::storeValue(ObjectPtr theObject) const
 {
-  DataPtr aData = theFeature->data();
+  DataPtr aData = theObject->data();
   boost::shared_ptr<ModelAPI_AttributeReference> aRef = 
     boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(aData->attribute(attributeID()));
 
-  FeaturePtr aFeature = aRef->value();
-  if (!(aFeature && aFeature->isSame(mySelectedObject))) {
+  ObjectPtr aObject = aRef->value();
+  if (!(aObject && aObject->isSame(mySelectedObject))) {
     aRef->setValue(mySelectedObject);
     Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
   }
@@ -114,9 +114,9 @@ bool ModuleBase_WidgetSelector::storeValue(FeaturePtr theFeature) const
 }
 
 //********************************************************************
-bool ModuleBase_WidgetSelector::restoreValue(FeaturePtr theFeature)
+bool ModuleBase_WidgetSelector::restoreValue(ObjectPtr theObject)
 {
-  DataPtr aData = theFeature->data();
+  DataPtr aData = theObject->data();
   boost::shared_ptr<ModelAPI_AttributeReference> aRef = aData->reference(attributeID());
 
   bool isBlocked = this->blockSignals(true);
index 61fba00492e7a1ff96af8f7fb0182296bbb57b2e..b1782d072b43765f68cf8588b5ca917f69c03209 100644 (file)
@@ -33,10 +33,10 @@ public:
   virtual ~ModuleBase_WidgetSelector();
 
   /// Saves the internal parameters to the given feature
-  /// \param theFeature a model feature to be changed
-  virtual bool storeValue(FeaturePtr theFeature) const;
+  /// \param theObject a model feature to be changed
+  virtual bool storeValue(ObjectPtr theObject) const;
 
-  virtual bool restoreValue(FeaturePtr theFeature);
+  virtual bool restoreValue(ObjectPtr theObject);
 
   /// Returns the internal parent wiget control, that can be shown anywhere
   /// \returns the widget
@@ -66,7 +66,7 @@ private:
   void enableOthersControls(bool toEnable) const;
   void updateSelectionName();
   void raisePanel() const;
-  bool isAccepted(const ObjectPtr theFeature) const;
+  bool isAccepted(const ObjectPtr theObject) const;
 
   static TopAbs_ShapeEnum shapeType(const QString& theType);
 
index f447f59660f3a1bd4894326893b3271874e5d482..4cc60a5c4e7b059260c2302f69d251bbf622bde8 100644 (file)
@@ -18,7 +18,7 @@
 #include <ModelAPI_Document.h>
 
 static double myTestDelta;
-static FeaturePtr myTestFeature;
+static ResultPtr myTestObject;
 
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_Shape.hxx>
@@ -31,13 +31,13 @@ static FeaturePtr myTestFeature;
 
 void PartSet_TestOCC::testSelection(XGUI_Workshop* theWorkshop)
 {
-  if (!myTestFeature) {
+  if (!myTestObject) {
     PartSet_TestOCC::createTestLine(theWorkshop);
     PartSet_TestOCC::moveMouse(theWorkshop->viewer()->AISContext(),
                                theWorkshop->viewer()->activeView());
     PartSet_TestOCC::changeTestLine(theWorkshop);
   }
-  boost::shared_ptr<GeomAPI_AISObject> anIO = theWorkshop->displayer()->getAISObject(myTestFeature);
+  boost::shared_ptr<GeomAPI_AISObject> anIO = theWorkshop->displayer()->getAISObject(myTestObject);
   if (!anIO->empty()) {
     theWorkshop->viewer()->AISContext()->MoveTo(0, 0, theWorkshop->viewer()->activeView());
     theWorkshop->viewer()->AISContext()->Select(0, 0, 2500, 2500, theWorkshop->viewer()->activeView());
@@ -182,10 +182,10 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop)
     //aModes.push_back(TopAbs_VERTEX);
     //aModes.push_back(TopAbs_EDGE);
     //aDisplayer->activateInLocalContext(aFeature, aModes, true);
-    myTestFeature = aFeature;
+    myTestObject = aFeature;
 
     QFeatureList aFeatureList;
-    aFeatureList.append(myTestFeature);
+    aFeatureList.append(myTestObject);
     aDisplayer->setSelected(aFeatureList, true);
   }
 }
@@ -193,9 +193,9 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop)
 void PartSet_TestOCC::changeTestLine(XGUI_Workshop* theWorkshop)
 {
   // change the line
-  if (!myTestFeature)
+  if (!myTestObject)
     return;
-  FeaturePtr aFeature = myTestFeature;
+  FeaturePtr aFeature = myTestObject;
 
   myTestDelta = myTestDelta - 50;
   double aDelta = myTestDelta;
@@ -216,7 +216,7 @@ void PartSet_TestOCC::changeTestLine(XGUI_Workshop* theWorkshop)
   //aDisplayer->activateInLocalContext(aFeature, aModes, true);
 
   /*QFeatureList aFeatureList;
-  aFeatureList.append(myTestFeature);
+  aFeatureList.append(myTestObject);
   theWorkshop->displayer()->setSelected(aFeatureList, true);*/
 
   theWorkshop->displayer()->updateViewer();
index ee93708255b494dff5e60eb125f0ceabf40ad29a..d7dcfce78ad8b04ea0c56d449391c2cfeaf5e8d2 100644 (file)
@@ -13,6 +13,7 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_AttributeDocRef.h>
 #include <ModelAPI_Object.h>
+#include <ModelAPI_ResultPart.h>
 
 #include <QAction>
 #include <QContextMenuEvent>
@@ -99,27 +100,30 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const
 {
   QMenu* aMenu = new QMenu();
   XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
-  QList<ObjectPtr> aFeatures = aSelMgr->selection()->selectedObjects();
-  if (aFeatures.size() == 1) {
+  QList<ObjectPtr> aObjects = aSelMgr->selection()->selectedObjects();
+  if (aObjects.size() == 1) {
     PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
-    FeaturePtr aFeature = aFeatures.first();
+    ObjectPtr aObject = aObjects.first();
     //Process Feature
-    if (aFeature) {
-      if (aFeature->getKind() == PARTSET_PART_KIND) {
-        ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
-        DocumentPtr aFeaDoc = aObject->featureRef()->data()->docRef("PartDocument")->value();
+    if (aObject) {
+      ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
+      if (aPart) {
+        DocumentPtr aFeaDoc = aPart->document();
         if (aMgr->currentDocument() == aFeaDoc)
           aMenu->addAction(action("DEACTIVATE_PART_CMD"));
         else 
           aMenu->addAction(action("ACTIVATE_PART_CMD"));
       } else {
-        aMenu->addAction(action("EDIT_CMD"));
-
-        XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-        if (aDisplayer->isVisible(aFeature))
-          aMenu->addAction(action("HIDE_CMD"));
-        else
-          aMenu->addAction(action("SHOW_CMD"));
+        ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(aObject);
+        if (aResult) {
+          aMenu->addAction(action("EDIT_CMD"));
+
+          XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+          if (aDisplayer->isVisible(aResult))
+            aMenu->addAction(action("HIDE_CMD"));
+          else
+            aMenu->addAction(action("SHOW_CMD"));
+        }
       }
       aMenu->addAction(action("DELETE_CMD"));
       aMenu->addSeparator();
index ece7040f69617f665973ccc33c1bf428f8f1922e..0b8844e2f494414f3874424e701b3c5ccadd1fe7 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Feature.h>
+#include <ModelAPI_ResultPart.h>
 
 #include <QAbstractItemModel>
 #include <QColor>
index 225a7108febd26062e4f329d6750769ae7b0ea6d..c49c6696535871e683459407e8214527a01de0a4 100644 (file)
@@ -4,10 +4,11 @@
 
 #include "XGUI.h"
 #include <ModuleBase_Definitions.h>
+#include <ModelAPI_ResultPart.h>
 
-#include <QAbstractItemModel>
 #include <Events_Listener.h>
 
+#include <QAbstractItemModel>
 #include <QList>
 
 class ModelAPI_Document;
@@ -52,22 +53,22 @@ public:
 
   Qt::ItemFlags flags(const QModelIndex& theIndex) const;
 
-  //! Returns Feature object by the given Model index.
-  //! Returns 0 if the given index is not index of a feature
+  //! Returns an object by the given Model index.
+  //! Returns 0 if the given index is not index of an object
   ObjectPtr object(const QModelIndex& theIndex) const;
 
-  QModelIndex featureIndex(const ObjectPtr theFeature) const;
+  QModelIndex objectIndex(const ObjectPtr theObject) const;
 
-  //! Returns QModelIndex which corresponds to the given feature if this is a part
-  //! If the feature is not found then index is not valid
-  QModelIndex partIndex(const ObjectPtr& theFeature) const;
+  //! Returns QModelIndex which corresponds to the given part
+  //! If the object is not found then index is not valid
+  QModelIndex partIndex(const ResultPartPtr& thePart) const;
 
   //! Activates a part data model if the index is a Part node index. 
   //! Returns true if active part changed.
   bool activatedIndex(const QModelIndex& theIndex);
 
-  //! Retrurns Feature which corresponds to active part
-  ObjectPtr activePart() const;
+  //! Retrurns active part
+  ResultPartPtr activePart() const;
 
   //! Retrurns QModelIndex of active part
   QModelIndex activePartIndex() const { return myActivePartIndex; }
index 27b92756283b4e6304239e698a03adb627b4ba26..5d9d000e3b2af60d799babb832796672de6e1e49 100644 (file)
@@ -46,7 +46,7 @@ void XGUI_DataTree::onSelectionChanged(const QItemSelection& theSelected,
   XGUI_DocumentDataModel* aModel = dataModel();
   QModelIndexList::const_iterator aIt;
   for (aIt = aIndexes.constBegin(); aIt != aIndexes.constEnd(); ++aIt) {
-    FeaturePtr aFeature = aModel->feature(*aIt);
+    ObjectPtr aFeature = aModel->feature(*aIt);
     if (aFeature)
       mySelectedData.append(aFeature);
   }
@@ -83,7 +83,7 @@ void XGUI_DataTree::commitData(QWidget* theEditor)
   QLineEdit* aEditor = dynamic_cast<QLineEdit*>(theEditor);
   if (aEditor) {
     QString aRes = aEditor->text();
-    FeaturePtr aFeature = mySelectedData.first();
+    ObjectPtr aFeature = mySelectedData.first();
     PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
     aMgr->rootDocument()->startOperation();
     if (!XGUI_Tools::isModelObject(aFeature))
@@ -147,15 +147,15 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent)
   aLabelWgt->setFrameShadow(myTreeView->frameShadow());
 
   connect(myTreeView, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
-  connect(myTreeView, SIGNAL(activePartChanged(FeaturePtr)), this, SLOT(onActivePartChanged(FeaturePtr)));
-  connect(myTreeView, SIGNAL(activePartChanged(FeaturePtr)), this, SIGNAL(activePartChanged(FeaturePtr)));
+  connect(myTreeView, SIGNAL(activePartChanged(ObjectPtr)), this, SLOT(onActivePartChanged(ObjectPtr)));
+  connect(myTreeView, SIGNAL(activePartChanged(ObjectPtr)), this, SIGNAL(activePartChanged(ObjectPtr)));
 
   connect(myActiveDocLbl, SIGNAL(customContextMenuRequested(const QPoint&)), 
           this, SLOT(onLabelContextMenuRequested(const QPoint&)));
   connect(myTreeView, SIGNAL(contextMenuRequested(QContextMenuEvent*)), 
           this, SLOT(onContextMenuRequested(QContextMenuEvent*)));
   
-  onActivePartChanged(FeaturePtr());
+  onActivePartChanged(ObjectPtr());
 
   // Create internal actions
   QAction* aAction = new QAction(QIcon(":pictures/rename_edit.png"), tr("Rename"), this);
@@ -170,7 +170,7 @@ XGUI_ObjectsBrowser::~XGUI_ObjectsBrowser()
 }
 
 //***************************************************
-void XGUI_ObjectsBrowser::onActivePartChanged(FeaturePtr thePart)
+void XGUI_ObjectsBrowser::onActivePartChanged(ObjectPtr thePart)
 {
   QPalette aPalet = myActiveDocLbl->palette();
   if (thePart) {
@@ -191,8 +191,8 @@ bool XGUI_ObjectsBrowser::eventFilter(QObject* obj, QEvent* theEvent)
           myTreeView->setExpanded(myDocModel->activePartIndex(), false);
         }
         myDocModel->deactivatePart();
-        onActivePartChanged(FeaturePtr());
-        emit activePartChanged(FeaturePtr());
+        onActivePartChanged(ObjectPtr());
+        emit activePartChanged(ObjectPtr());
       }
     } else {
       // End of editing by mouse click
@@ -235,7 +235,7 @@ void XGUI_ObjectsBrowser::closeDocNameEditing(bool toSave)
 }
 
 //***************************************************
-void XGUI_ObjectsBrowser::activatePart(const FeaturePtr& thePart)
+void XGUI_ObjectsBrowser::activatePart(const ObjectPtr& thePart)
 {
   if (thePart) {
     QModelIndex aIndex = myDocModel->partIndex(thePart);
@@ -250,7 +250,7 @@ void XGUI_ObjectsBrowser::activatePart(const FeaturePtr& thePart)
         myTreeView->setExpanded(aIndex, true);
         onActivePartChanged(myDocModel->feature(aIndex));
       } else {
-        onActivePartChanged(FeaturePtr());
+        onActivePartChanged(ObjectPtr());
       }
     }
   } else {
@@ -258,7 +258,7 @@ void XGUI_ObjectsBrowser::activatePart(const FeaturePtr& thePart)
     if (aIndex.isValid()) {
       myDocModel->activatedIndex(aIndex);
       myTreeView->setExpanded(aIndex, false);
-      onActivePartChanged(FeaturePtr());
+      onActivePartChanged(ObjectPtr());
     }
   }
 }
@@ -266,8 +266,8 @@ void XGUI_ObjectsBrowser::activatePart(const FeaturePtr& thePart)
 //***************************************************
 void XGUI_ObjectsBrowser::onContextMenuRequested(QContextMenuEvent* theEvent) 
 {
-  myFeaturesList = myTreeView->selectedFeatures();
-  bool toEnable = myFeaturesList.size() > 0;
+  myObjectsList = myTreeView->selectedFeatures();
+  bool toEnable = myObjectsList.size() > 0;
   foreach(QAction* aCmd, actions()) {
     aCmd->setEnabled(toEnable);
   }
@@ -277,9 +277,9 @@ void XGUI_ObjectsBrowser::onContextMenuRequested(QContextMenuEvent* theEvent)
 //***************************************************
 void XGUI_ObjectsBrowser::onLabelContextMenuRequested(const QPoint& thePnt)
 {
-  myFeaturesList.clear();
+  myObjectsList.clear();
   //Empty feature pointer means that selected root document
-  myFeaturesList.append(FeaturePtr()); 
+  myObjectsList.append(ObjectPtr()); 
 
   foreach(QAction* aCmd, actions()) {
     aCmd->setEnabled(true);
@@ -291,14 +291,14 @@ void XGUI_ObjectsBrowser::onLabelContextMenuRequested(const QPoint& thePnt)
 //***************************************************
 void XGUI_ObjectsBrowser::onEditItem()
 {
-  if (myFeaturesList.size() > 0) {
-    FeaturePtr aFeature = myFeaturesList.first();
+  if (myObjectsList.size() > 0) {
+    ObjectPtr aFeature = myObjectsList.first();
     if (aFeature) { // Selection happens in TreeView
       // Find index which corresponds the feature
       QModelIndex aIndex;
       foreach(QModelIndex aIdx, selectedIndexes()) {
-        FeaturePtr aFea = dataModel()->feature(aIdx);
-        if (dataModel()->feature(aIdx)->isSame(aFeature)) {
+        ObjectPtr aFea = dataModel()->object(aIdx);
+        if (dataModel()->object(aIdx)->isSame(aFeature)) {
           aIndex = aIdx;
           break;
         }
@@ -320,7 +320,7 @@ void XGUI_ObjectsBrowser::onEditItem()
 //***************************************************
 void XGUI_ObjectsBrowser::onSelectionChanged()
 {
-  myFeaturesList = myTreeView->selectedFeatures();
+  myObjectsList = myTreeView->selectedObjects();
   emit selectionChanged();
 }
 
@@ -332,14 +332,14 @@ void XGUI_ObjectsBrowser::rebuildDataTree()
 }
 
 //***************************************************
-void XGUI_ObjectsBrowser::setFeaturesSelected(const QFeatureList& theFeatures)
+void XGUI_ObjectsBrowser::setObjectsSelected(const QList<ObjectPtr>& theObjects)
 {
   QList<QModelIndex> theIndexes;
   QItemSelectionModel* aSelectModel = myTreeView->selectionModel();
   aSelectModel->clear();
 
-  foreach(FeaturePtr aFeature, theFeatures) {
-    QModelIndex aIndex = myDocModel->featureIndex(aFeature);
+  foreach(ObjectPtr aFeature, theObjects) {
+    QModelIndex aIndex = myDocModel->objectIndex(aFeature);
     if (aIndex.isValid()) {
       aSelectModel->select(aIndex, QItemSelectionModel::Select);
     }
index 0924af4b59dc8d9033a8b3e55d24a001560abef3..edcddc628d0f7a43d1f482ca806754e2fe041f5e 100644 (file)
@@ -20,15 +20,15 @@ public:
   XGUI_DataTree(QWidget* theParent);
   virtual ~XGUI_DataTree();
 
-  //! Returns list of currently selected features
-  QList<ObjectPtr> selectedFeatures() const { return mySelectedData; }
+  //! Returns list of currently selected objects
+  QList<ObjectPtr> selectedObjects() const { return mySelectedData; }
 
   XGUI_DocumentDataModel* dataModel() const;
 
 signals:
   //! Emited when selection is changed
   void selectionChanged();
-  void activePartChanged(FeaturePtr thePart); 
+  void activePartChanged(ObjectPtr thePart); 
  
   //! Emited on context menu request
   void contextMenuRequested(QContextMenuEvent* theEvent);
@@ -64,10 +64,10 @@ public:
   //! Returns Model which provides access to data objects
   XGUI_DocumentDataModel* dataModel() const { return myDocModel; }
 
-  //! Returns list of currently selected features
+  //! Returns list of currently selected objects
   QList<ObjectPtr> selectedObjects() const { return myObjectsList; }
 
-  void setFeaturesSelected(const QFeatureList& theFeatures);
+  void setObjectsSelected(const QList<ObjectPtr>& theObjects);
 
   //! Returns currently selected indexes
   QModelIndexList selectedIndexes() const { return myTreeView->selectionModel()->selectedIndexes(); }
@@ -76,7 +76,7 @@ public:
   XGUI_DataTree* treeView() const { return myTreeView; }
 
   //! Activates currently selected part. Signal activePartChanged will not be sent
-  void activatePart(const FeaturePtr& thePart);
+  void activatePart(const ObjectPtr& thePart);
 
   void rebuildDataTree();
 
@@ -85,7 +85,7 @@ signals:
   void selectionChanged();
 
   //! Emited when current active document is changed
-  void activePartChanged(FeaturePtr thePart); 
+  void activePartChanged(ObjectPtr thePart); 
  
   //! Emited on context menu request
   void contextMenuRequested(QContextMenuEvent* theEvent);
@@ -94,7 +94,7 @@ protected:
   virtual bool eventFilter(QObject* obj, QEvent* theEvent);
 
 private slots:
-  void onActivePartChanged(FeaturePtr thePart);
+  void onActivePartChanged(ObjectPtr thePart);
   void onContextMenuRequested(QContextMenuEvent* theEvent);
   void onLabelContextMenuRequested(const QPoint& thePnt);
 
index b1f808995a545a200dd94796eb67be3853dca6e1..b170ec1cd701b96f0890a193e0d41ab42874b59d 100644 (file)
@@ -103,7 +103,7 @@ public:
   virtual QModelIndex findGroup(const std::string& theGroup) const;
 
   //! Return a Part object
-  virtual ObjectPtr part() const;
+  virtual ResultPartPtr part() const;
 
 private: 
 
index 84b73f0f769c375f3033319e947e4571483b1b67..9202e97bb748fb8d9a8a8337fc11f96979e1f9d9 100644 (file)
@@ -28,31 +28,31 @@ public:
   /// Returns a list of viewer selected presentations
   /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build
   /// \return list of presentations
-  std::list<ModuleBase_ViewerPrs> getSelected(int theShapeTypeToSkip = -1) const;
+  virtual std::list<ModuleBase_ViewerPrs> getSelected(int theShapeTypeToSkip = -1) const;
 
   /// Returns a list of viewer highlited presentations
   /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build
   /// \return list of presentations
-  std::list<ModuleBase_ViewerPrs> getHighlighted(int theShapeTypeToSkip = -1) const;
+  virtual std::list<ModuleBase_ViewerPrs> getHighlighted(int theShapeTypeToSkip = -1) const;
 
   /**
   * Returns list of currently selected objects
   */
-  QList<ObjectPtr> selectedObjects() const;
+  virtual QList<ObjectPtr> selectedObjects() const;
 
   /**
   * Returns list of currently selected results
   */
-  QResultList selectedResults() const;
+  virtual QResultList selectedResults() const;
   
   //! Returns list of currently selected QModelIndexes
-  QModelIndexList selectedIndexes() const;
+  virtual QModelIndexList selectedIndexes() const;
 
   //! Returns list of currently selected AIS objects
-  void selectedAISObjects(AIS_ListOfInteractive& theList) const;
+  virtual void selectedAISObjects(AIS_ListOfInteractive& theList) const;
 
   //! Returns list of currently selected shapes
-  void selectedShapes(NCollection_List<TopoDS_Shape>& theList) const;
+  virtual void selectedShapes(NCollection_List<TopoDS_Shape>& theList) const;
 
 private:
   XGUI_Workshop* myWorkshop;
index d1d9f83a0a008f3c01f825b84c7dcd43ca1c84c1..dc5db4e2b604334dac71bceb7ca3f5a1a7e7babd 100644 (file)
@@ -12,6 +12,8 @@
 #include <ModelAPI_PluginManager.h>
 #include <ModelAPI_AttributeDocRef.h>
 #include <ModelAPI_Data.h>
+#include <ModelAPI_Result.h>
+#include <ModelAPI_Object.h>
 
 
 
@@ -40,24 +42,30 @@ void XGUI_SelectionMgr::connectViewers()
 //**************************************************************
 void XGUI_SelectionMgr::onObjectBrowserSelection()
 {
-  QFeatureList aFeatures = myWorkshop->objectBrowser()->selectedFeatures();
+  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(aFeatures);
+  aDisplayer->setSelected(aResults);
   emit selectionChanged();
 }
 
 //**************************************************************
 void XGUI_SelectionMgr::onViewerSelection()
 {
-  QFeatureList aFeatures;
+  QList<ObjectPtr> aFeatures;
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
   for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
     Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
-    FeaturePtr aFeature = myWorkshop->displayer()->getFeature(anIO);
-    if (aFeature)
-      aFeatures.append(aFeature);
+    ResultPtr aResult = myWorkshop->displayer()->getResult(anIO);
+    if (aResult)
+      aFeatures.append(aResult);
   }
-  myWorkshop->objectBrowser()->setFeaturesSelected(aFeatures);
+  myWorkshop->objectBrowser()->setObjectsSelected(aFeatures);
   emit selectionChanged();
 }