]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
authornds <natalia.donis@opencascade.com>
Thu, 19 Mar 2015 09:29:08 +0000 (12:29 +0300)
committernds <natalia.donis@opencascade.com>
Thu, 19 Mar 2015 09:29:08 +0000 (12:29 +0300)
17 files changed:
src/ModuleBase/ModuleBase_FilterValidated.cpp
src/ModuleBase/ModuleBase_IModule.h
src/ModuleBase/ModuleBase_ISelection.h
src/ModuleBase/ModuleBase_IWorkshop.cpp
src/ModuleBase/ModuleBase_IWorkshop.h
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.h
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/ModuleBase/ModuleBase_WidgetShapeSelector.h
src/ModuleBase/ModuleBase_WidgetValidated.cpp
src/ModuleBase/ModuleBase_WidgetValidated.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/SketchPlugin/SketchPlugin_ShapeValidator.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_Selection.cpp
src/XGUI/XGUI_Selection.h

index 20c1692625886efa1696088f5e4213082d28bc30..a6336d3533360bdf3c7c3f7e345ca44a297a4dfe 100644 (file)
@@ -4,61 +4,25 @@
 // Created:     17 Mar 2015
 // Author:      Natalia ERMOLAEVA
 
-
 #include "ModuleBase_FilterValidated.h"
 #include "ModuleBase_IWorkshop.h"
 
-#include <ModelAPI_Session.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_ResultConstruction.h>
-
-#include <AIS_InteractiveObject.hxx>
-#include <AIS_Shape.hxx>
-
-#include <StdSelect_BRepOwner.hxx>
-
-#include <BRep_Tool.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
-#include <Geom_Curve.hxx>
-
-#include <ModelAPI_CompositeFeature.h>
-#include <GeomAPI_ICustomPrs.h>
-
+#include <ModuleBase_IModule.h>
+#include <ModuleBase_IPropertyPanel.h>
+#include <ModuleBase_Operation.h>
+#include <ModuleBase_WidgetValidated.h>
 
 IMPLEMENT_STANDARD_HANDLE(ModuleBase_FilterValidated, SelectMgr_Filter);
 IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_FilterValidated, SelectMgr_Filter);
 
 Standard_Boolean ModuleBase_FilterValidated::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
 {
-/*  // global selection should be ignored, the filter processes only selected sub-shapes
-  Handle(StdSelect_BRepOwner) aShapeOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
-  if (!aShapeOwner.IsNull()) {
-    if (!aShapeOwner->ComesFromDecomposition())
-      return Standard_True;
-  }
-
-  if (theOwner->HasSelectable()) {
-    Handle(AIS_InteractiveObject) aAisObj = 
-      Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
-    if (!aAisObj.IsNull()) {
-      std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
-      aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj));
-      ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj);
+  ModuleBase_Operation* anOperation = myWorkshop->module()->currentOperation();
+  ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
 
-      ResultConstructionPtr aConstr = 
-        std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObj);
-      if (aConstr != NULL) {
-        // it provides selection only on compositie features, construction without composite
-        // feature is not selectable
-        FeaturePtr aFeature = ModelAPI_Feature::feature(aConstr);
-        CompositeFeaturePtr aComposite = 
-          std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
-        return aComposite && aComposite->numberOfSubs() > 0;
-      }
-    }
-  }
-  */
-  return Standard_False;
+  ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
+  ModuleBase_WidgetValidated* aWidgetValidated = dynamic_cast<ModuleBase_WidgetValidated*>
+                                                                          (anActiveWidget);
+  return !aWidgetValidated || aWidgetValidated->isValid(theOwner);
 }
 
index 1e467d859cdf7fb1bc34dd87e96229bff441b3c4..ffe5139479fdc09fdcc09043798e4b6fcd413786 100644 (file)
@@ -69,6 +69,10 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   /// Realizes some functionality by an operation abort\r
   virtual void operationAborted(ModuleBase_Operation* theOperation) {}\r
 \r
+  /// Realizes some functionality by an operation start\r
+  /// \param theOperation a started operation\r
+  virtual ModuleBase_Operation* currentOperation() const = 0;\r
+\r
   /// Add menu atems for viewer into the given menu\r
   /// \param theMenu a popup menu to be shown in the viewer\r
   virtual void addViewerItems(QMenu* theMenu) const {}\r
index e3190488af69f6268a61a1998570abbd06a73edd..29829a39e51f55031ce5732dd7e58d564633e368 100644 (file)
@@ -28,14 +28,12 @@ class ModuleBase_ISelection
  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
-  virtual QList<ModuleBase_ViewerPrs> getSelected(int theShapeTypeToSkip = -1) const = 0;
+  virtual QList<ModuleBase_ViewerPrs> getSelected() const = 0;
 
   /// 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
-  virtual QList<ModuleBase_ViewerPrs> getHighlighted(int theShapeTypeToSkip = -1) const = 0;
+  virtual QList<ModuleBase_ViewerPrs> getHighlighted() const = 0;
 
   /**
    * Returns list of features currently selected in object browser
index 4531933bc2e4164bf4f3b8f28dfa79b77edee3c5..6105bf263ae0f27247bb1409b92bd05d3d5bacc8 100644 (file)
@@ -7,6 +7,17 @@
 #include "ModuleBase_IWorkshop.h"
 #include "ModuleBase_FilterFactory.h"
 
+ModuleBase_IWorkshop::ModuleBase_IWorkshop(QObject* theParent)
+: QObject(theParent)
+{
+  myValidatorFilter = new ModuleBase_FilterValidated(this);
+}
+
+Handle(ModuleBase_FilterValidated) ModuleBase_IWorkshop::validatorFilter()
+{
+  return myValidatorFilter;
+}
+
 ModuleBase_FilterFactory* ModuleBase_IWorkshop::selectionFilters() const
 {
   static ModuleBase_FilterFactory* aFactory = new ModuleBase_FilterFactory;
index b7f02f4a11740600f0ba31338599ddbac1fdcfd0..3646e630c95b18ae5e879150aef6a28f1c18ab98 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "ModuleBase.h"
 #include "ModuleBase_Definitions.h"
+#include <ModuleBase_FilterValidated.h>
 
 #include <ModelAPI_Object.h>
 #include <GeomAPI_AISObject.h>
@@ -31,9 +32,7 @@ Q_OBJECT
  public:
    /// Constructor
    /// \param theParent parent object
-  ModuleBase_IWorkshop(QObject* theParent)
-      : QObject(theParent)
-  {}
+  ModuleBase_IWorkshop(QObject* theParent);
 
   virtual ~ModuleBase_IWorkshop()
   {}
@@ -54,6 +53,10 @@ Q_OBJECT
   //! Returns current viewer
   virtual ModuleBase_IViewer* viewer() const = 0;
 
+  /// A filter to process an attribute validators
+  /// \return a filter
+  Handle(ModuleBase_FilterValidated) validatorFilter();
+
   //! Returns the factory of selection filters : the only one instance per application
   ModuleBase_FilterFactory* selectionFilters() const;
   
@@ -80,6 +83,9 @@ signals:
   /// Signal which is emited after activation of property panel
   void propertyPanelActivated();
 
+protected:
+  /// A filter to process an attribute validators
+  Handle(ModuleBase_FilterValidated) myValidatorFilter;
 };
 
 #endif
index 22145d36f37be5a36554711d88753fe57919806a..c3bf95327950ba72585b4ba20e8238517d12e462 100644 (file)
@@ -171,6 +171,18 @@ bool ModuleBase_WidgetMultiSelector::restoreValue()
   return false;
 }
 
+//********************************************************************
+void ModuleBase_WidgetMultiSelector::backupAttributeValue(const bool isBackup)
+{
+
+}
+
+//********************************************************************
+void ModuleBase_WidgetMultiSelector::setSelection(const Handle_SelectMgr_EntityOwner& theOwner)
+{
+
+}
+
 //********************************************************************
 QList<QWidget*> ModuleBase_WidgetMultiSelector::getControls() const
 {
index bdb1a46eddf75f4409a19db057d769d27cb9b214..e0b257ca4495790b6d0a872e9730af9b9bc451b4 100644 (file)
@@ -95,6 +95,17 @@ protected slots:
   /// \return True in success
   virtual bool storeValueCustom() const;
 
+  /// Creates a backup of the current values of the attribute
+  /// It should be realized in the specific widget because of different
+  /// parameters of the current attribute
+  /// \param isBackup a boolean flag, if true, store values from the attribute
+  /// to backup, otherwise set the backed up values to the attribute
+  virtual void backupAttributeValue(const bool isBackup);
+
+  /// Fills the attribute with the value of the selected owner
+  /// \param theOwner a selected owner
+  virtual void setSelection(const Handle_SelectMgr_EntityOwner& theOwner);
+
   /// Set current shape type for selection
   void setCurrentShapeType(const TopAbs_ShapeEnum theShapeType);
 
index a2034fce6538f751c7ab8ae5ed29bee67e8d4dbe..ec7defe2285bb1eff1724dc7da1695db04907e54 100644 (file)
@@ -448,6 +448,41 @@ void ModuleBase_WidgetShapeSelector::activateCustom()
   activateSelection(true);
 }
 
+//********************************************************************
+void ModuleBase_WidgetShapeSelector::backupAttributeValue(const bool isBackup)
+{
+  DataPtr aData = myFeature->data();
+  AttributePtr anAttribute = myFeature->attribute(attributeID());
+
+  if (isBackup) {
+    myObject = getObject(anAttribute);
+    myShape = getShape();
+    myRefAttribute = NULL;
+    myIsObject = false;
+    AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
+    if (aRefAttr) {
+      myIsObject = aRefAttr->isObject();
+      myRefAttribute = aRefAttr->attr();
+    }
+  }
+  else {
+    storeAttributeValues(myObject, myShape);
+    AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
+    if (aRefAttr) {
+      if (myIsObject)
+        aRefAttr->setObject(myObject);
+      else
+        aRefAttr->setAttr(myRefAttribute);
+    }
+  }
+}
+
+//********************************************************************
+void ModuleBase_WidgetShapeSelector::setSelection(const Handle_SelectMgr_EntityOwner& theOwner)
+{
+
+}
+
 //********************************************************************
 void ModuleBase_WidgetShapeSelector::deactivate()
 {
@@ -472,19 +507,9 @@ bool ModuleBase_WidgetShapeSelector::isValid(ObjectPtr theObj, std::shared_ptr<G
   AttributePtr anAttribute = myFeature->attribute(attributeID());
 
   // 1. make a backup of the previous attribute values
-  ObjectPtr aPrevObject = getObject(anAttribute);
-  GeomShapePtr aPrevShape = getShape();
-  AttributePtr aPrevAttribute;
-  bool aPrevIsObject = false;
-  AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
-  if (aRefAttr) {
-    aPrevIsObject = aRefAttr->isObject();
-    aPrevAttribute = aRefAttr->attr();
-  }
-
+  backupAttributeValue(true);
   // 2. store the current values, disable the model's update
   aData->blockSendAttributeUpdated(true);
-  storeAttributeValues(theObj, theShape);
 
   // 3. check the acceptability of the current values
   std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
@@ -499,44 +524,9 @@ bool ModuleBase_WidgetShapeSelector::isValid(ObjectPtr theObj, std::shared_ptr<G
   }
 
   // 4. if the values are not valid, restore the previous values to the attribute
-  storeAttributeValues(aPrevObject, aPrevShape);
-  if (aRefAttr) {
-    if (aPrevIsObject)
-      aRefAttr->setObject(aPrevObject);
-    else
-      aRefAttr->setAttr(aPrevAttribute);
-  }
+  backupAttributeValue(false);
 
   // 5. enable the model's update
   aData->blockSendAttributeUpdated(false);
-  //updateObject(myFeature);
-  //return aValid;
-
-  if (!aValid)
-    return false;
-
-/*  // Check the acceptability of the object as attribute
-  std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
-  std::list<std::list<std::string> >::iterator aArgs = anArguments.begin();
-  for (; aValidator != aValidators.end(); aValidator++, aArgs++) {
-    const ModelAPI_RefAttrValidator* aAttrValidator =
-        dynamic_cast<const ModelAPI_RefAttrValidator*>(*aValidator);
-    if (aAttrValidator) {
-      //if (!aAttrValidator->isValid(myFeature, *aArgs, theObj)) {
-      //  return false;
-      //}
-    }
-    else {
-      const ModelAPI_ShapeValidator* aShapeValidator = 
-                               dynamic_cast<const ModelAPI_ShapeValidator*>(*aValidator);
-      if (aShapeValidator) {
-        DataPtr aData = myFeature->data();
-        AttributeSelectionPtr aSelectAttr = aData->selection(attributeID());
-        if (!aShapeValidator->isValid(myFeature, *aArgs, theObj, aSelectAttr, theShape)) {
-          return false;
-        }
-      }
-    }
-  }*/
-  return true;
+  return aValid;
 }
index fe4d0cb49a333cee9956c147d5c63652bc6007af..ca735d5324db165b7db91aeae2ffcf43d04d1d07 100644 (file)
@@ -110,6 +110,17 @@ Q_OBJECT
   /// The methiod called when widget is activated
   virtual void activateCustom();
 
+  /// Creates a backup of the current values of the attribute
+  /// It should be realized in the specific widget because of different
+  /// parameters of the current attribute
+  /// \param isBackup a boolean flag, if true, store values from the attribute
+  /// to backup, otherwise set the backed up values to the attribute
+  virtual void backupAttributeValue(const bool isBackup);
+
+  /// Fills the attribute with the value of the selected owner
+  /// \param theOwner a selected owner
+  virtual void setSelection(const Handle_SelectMgr_EntityOwner& theOwner);
+
   /// Computes and updates name of selected object in the widget
   void updateSelectionName();
 
@@ -159,6 +170,18 @@ Q_OBJECT
 
   /// Active/inactive flag
   bool myIsActive;
+
+  /// backup parameters of the model attribute. The class processes three types of attribute:
+  /// Reference, RefAttr and Selection. Depending on the attribute type, only the attribute parameter
+  /// values are reserved in the backup
+  /// An attribute object
+  ObjectPtr myObject;
+  /// An attribute shape
+  GeomShapePtr myShape;
+  /// A reference of the attribute
+  AttributePtr myRefAttribute;
+  /// A boolean value whether refAttr uses reference of object
+  bool myIsObject;
 };
 
 #endif
index a6f05af6025c5eb23d39d9bc6ad3ca0b4a825a12..d81ec7970855eb8aa3d3d3ff194a371d2f5d63ea 100644 (file)
@@ -3,18 +3,21 @@
 #include <ModuleBase_WidgetValidated.h>
 #include <ModuleBase_FilterFactory.h>
 #include <ModuleBase_IViewer.h>
-#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
 
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_ResultValidator.h>
+#include <ModelAPI_AttributeValidator.h>
+
+#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
+#include <SelectMgr_EntityOwner.hxx>
 
 #include <QWidget>
 
 ModuleBase_WidgetValidated::ModuleBase_WidgetValidated(QWidget* theParent,
                                                        const Config_WidgetAPI* theData,
                                                        const std::string& theParentId)
   : ModuleBase_ModelWidget(theParent, theData, theParentId)
+ : ModuleBase_ModelWidget(theParent, theData, theParentId)
 {
 }
 
@@ -22,6 +25,48 @@ ModuleBase_WidgetValidated::~ModuleBase_WidgetValidated()
 {
 }
 
+bool ModuleBase_WidgetValidated::isValid(const Handle_SelectMgr_EntityOwner& theOwner)
+{
+  backupAttributeValue(true);
+
+  setSelection(theOwner);
+  bool aValid = isValidAttribute();
+
+  backupAttributeValue(false);
+
+  return aValid;
+}
+
+//********************************************************************
+bool ModuleBase_WidgetValidated::isValidAttribute() const
+{
+  SessionPtr aMgr = ModelAPI_Session::get();
+  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+  std::list<ModelAPI_Validator*> aValidators;
+  std::list<std::list<std::string> > anArguments;
+  aFactory->validators(parentID(), attributeID(), aValidators, anArguments);
+
+  DataPtr aData = myFeature->data();
+  AttributePtr anAttribute = myFeature->attribute(attributeID());
+
+  aData->blockSendAttributeUpdated(true);
+
+    // 3. check the acceptability of the current values
+  std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
+  std::list<std::list<std::string> >::iterator aArgs = anArguments.begin();
+  bool aValid = true;
+  for (; aValidator != aValidators.end() && aValid; aValidator++, aArgs++) {
+    const ModelAPI_AttributeValidator* aAttrValidator =
+        dynamic_cast<const ModelAPI_AttributeValidator*>(*aValidator);
+    if (aAttrValidator) {
+      aValid = aAttrValidator->isValid(anAttribute, *aArgs);
+    }
+  }
+  aData->blockSendAttributeUpdated(false);
+
+  return aValid;
+}
+
 //********************************************************************
 bool ModuleBase_WidgetValidated::isValid(ObjectPtr theObj, GeomShapePtr theShape) const
 {
@@ -52,7 +97,13 @@ void ModuleBase_WidgetValidated::activateFilters(ModuleBase_IWorkshop* theWorksh
                                                  const bool toActivate) const
 {
   ModuleBase_IViewer* aViewer = theWorkshop->viewer();
-
+/*
+  Handle(SelectMgr_Filter) aSelFilter = theWorkshop->validatorFilter();
+  if (toActivate)
+    aViewer->addSelectionFilter(aSelFilter);
+  else
+    aViewer->removeSelectionFilter(aSelFilter);
+*/  
   // apply filters loaded from the XML definition of the widget
   ModuleBase_FilterFactory* aFactory = theWorkshop->selectionFilters();
   SelectMgr_ListOfFilter aFactoryFilters;
index 014668e12731848f7c303c29dc570cb143558a27..90a83677ead697466b913709069bcf38e764feb3 100644 (file)
@@ -19,6 +19,7 @@
 class QWidget;
 class ModuleBase_IWorkshop;
 class Config_WidgetAPI;
+class Handle_SelectMgr_EntityOwner;
 
 /**
 * \ingroup GUI
@@ -37,7 +38,27 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidg
                              const std::string& theParentId);
   virtual ~ModuleBase_WidgetValidated();
 
+  /// Checks all widget validator if the owner is valid
+  /// \param theOwner a selected owner in the view
+  /// \return a boolean value
+  bool isValid(const Handle_SelectMgr_EntityOwner& theOwner);
+
 protected:
+  /// Creates a backup of the current values of the attribute
+  /// It should be realized in the specific widget because of different
+  /// parameters of the current attribute
+  /// \param isBackup a boolean flag, if true, store values from the attribute
+  /// to backup, otherwise set the backed up values to the attribute
+  virtual void backupAttributeValue(const bool isBackup) = 0;
+
+  /// Fills the attribute with the value of the selected owner
+  /// \param theOwner a selected owner
+  virtual void setSelection(const Handle_SelectMgr_EntityOwner& theOwner) = 0;
+
+  /// Checks the current attibute in all attribute validators
+  // \return true if all validators return that the attribute is valid
+  bool isValidAttribute() const;
+
   /// Check the selected with validators if installed
   /// \param theObj the object for checking
   /// \param theShape the shape for checking
index cb62b8797e4bb8cf8fc57af15810e506f12fa78e..83f59bfe61bab2cde6132c700e168076a81b57df 100644 (file)
@@ -218,6 +218,13 @@ void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
   myWorkshop->viewer()->removeSelectionFilter(myDocumentShapeFilter);
 }
 
+ModuleBase_Operation* PartSet_Module::currentOperation() const
+{
+  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
+  XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
+  return anOpMgr->currentOperation();
+}
+
 bool PartSet_Module::canUndo() const
 {
   bool aCanUndo = false;
index 138ffb3de55b36efdd68503bc2084213ced3b74e..11214c096ee79f5a970eaa214becfcd71ae4230c 100644 (file)
@@ -79,6 +79,10 @@ public:
   /// \param theOperation a stopped operation
   virtual void operationStopped(ModuleBase_Operation* theOperation);
 
+  /// Realizes some functionality by an operation start
+  /// \param theOperation a started operation
+  virtual ModuleBase_Operation* currentOperation() const;
+
   /// Returns action according to the given ID
   /// \param theId an action identifier, it should be uniqued in the bounds of the module
   QAction* action(const QString& theId) const;
index 2aca20171ee6a3eccf0ecd4e54047cb8c124c0dd..e1dacf811bc9702ef7eb0563741e86130ffce78b 100644 (file)
@@ -20,9 +20,6 @@ bool SketchPlugin_ShapeValidator::isValid(const AttributePtr& theAttribute,
     return true;
 
   // ask whether the feature of the attribute is external
-  //std::shared_ptr<SketchPlugin_Feature> aSketchFeature = 
-  //AttributeRefAttrPtr anAttribute = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
-  //                               std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
   bool isAttributeExternal = isExternalAttribute(theAttribute);
 
   // ask whether the feature of the attribute by parameter identifier is external
index bfdf8a5d58dfc26824948896719e6dc78ec70907..da11c4d8ef6f65ba1ca039fe7f9c208d41c92a43 100644 (file)
@@ -19,7 +19,6 @@
 
 #include <ModuleBase_Definitions.h>
 #include <ModuleBase_ViewerPrs.h>
-#include <ModuleBase_FilterValidated.h>
 
 #include <GeomAPI_ICustomPrs.h>
 
@@ -232,8 +231,6 @@ class XGUI_EXPORT XGUI_Displayer
   /// A container for selection filters
   Handle(SelectMgr_AndFilter) myAndFilter;
 
-  Handle(ModuleBase_FilterValidated) myFilterValidated;
-
   /// A default custom presentation, which is used if the displayed feature is not a custom presentation
   GeomCustomPrsPtr myCustomPrs;
 
index 30c623181b9341d6ce7193fd00a99c554770ecdd..0de6255da0409c105be963a079a74d2ab4e0551c 100644 (file)
 #include <AIS_InteractiveContext.hxx>
 
 #include <SelectMgr_Selection.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+
 #include <SelectBasics_SensitiveEntity.hxx>
 #include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <StdSelect_BRepOwner.hxx>
 
 #include <set>
 
@@ -25,7 +28,7 @@ XGUI_Selection::XGUI_Selection(XGUI_Workshop* theWorkshop)
 {
 }
 
-QList<ModuleBase_ViewerPrs> XGUI_Selection::getSelected(int theShapeTypeToSkip) const
+QList<ModuleBase_ViewerPrs> XGUI_Selection::getSelected() const
 {
   QList<long> aSelectedIds; // Remember of selected address in order to avoid duplicates
 
@@ -39,25 +42,18 @@ QList<ModuleBase_ViewerPrs> XGUI_Selection::getSelected(int theShapeTypeToSkip)
   if (aContext->HasOpenedContext()) {
     for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
       ModuleBase_ViewerPrs aPrs;
-      Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
-      if (aSelectedIds.contains((long)anIO.Access()))
+      Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
+
+      if (aSelectedIds.contains((long)anOwner.Access()))
         continue;
-    
-      aSelectedIds.append((long)anIO.Access());
-      aPrs.setInteractive(anIO);
+      aSelectedIds.append((long)anOwner.Access());
+
+      fillPresentation(aPrs, anOwner);
 
-      ObjectPtr aFeature = aDisplayer->getObject(anIO);
-      // we should not check the appearance of this feature because there can be some selected shapes
-      // for one feature
-      TopoDS_Shape aShape = aContext->SelectedShape();
-      if (!aShape.IsNull() && (aShape.ShapeType() != theShapeTypeToSkip))
-        aPrs.setShape(aShape);
-      Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
-      aPrs.setOwner(anOwner);
-      aPrs.setFeature(aFeature);
       aPresentations.append(aPrs);
     }
-  } else {
+  }
+  /* else {
     for (aContext->InitCurrent(); aContext->MoreCurrent(); aContext->NextCurrent()) {
       ModuleBase_ViewerPrs aPrs;
       Handle(AIS_InteractiveObject) anIO = aContext->Current();
@@ -71,11 +67,36 @@ QList<ModuleBase_ViewerPrs> XGUI_Selection::getSelected(int theShapeTypeToSkip)
       aPrs.setFeature(aFeature);
       aPresentations.append(aPrs);
     }
-  }
+  }*/
   return aPresentations;
 }
 
-QList<ModuleBase_ViewerPrs> XGUI_Selection::getHighlighted(int theShapeTypeToSkip) const
+void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrs& thePrs,
+                                      const Handle(SelectMgr_EntityOwner)& theOwner) const
+{
+  thePrs.setOwner(theOwner);
+
+  Handle(AIS_InteractiveObject) anIO = 
+                           Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
+  thePrs.setInteractive(anIO);
+
+  // we should not check the appearance of this feature because there can be some selected shapes
+  // for one feature
+  Handle(StdSelect_BRepOwner) aBRO = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
+  if( !aBRO.IsNull() ) {
+    // the located method is called in the context to obtain the shape by the SelectedShape() method,
+    // so the shape is located by the same rules
+    TopoDS_Shape aShape = aBRO->Shape().Located (aBRO->Location() * aBRO->Shape().Location());
+    if (!aShape.IsNull())
+      thePrs.setShape(aShape);
+  }      
+     
+  XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+  ObjectPtr aFeature = aDisplayer->getObject(anIO);
+  thePrs.setFeature(aFeature);
+}
+
+QList<ModuleBase_ViewerPrs> XGUI_Selection::getHighlighted() const
 {
   QList<long> aSelectedIds; // Remember of selected address in order to avoid duplicates
   QList<ModuleBase_ViewerPrs> aPresentations;
@@ -97,7 +118,7 @@ QList<ModuleBase_ViewerPrs> XGUI_Selection::getHighlighted(int theShapeTypeToSki
     aPrs.setFeature(aResult);
     if (aContext->HasOpenedContext()) {
       TopoDS_Shape aShape = aContext->DetectedShape();
-      if (!aShape.IsNull() && aShape.ShapeType() != theShapeTypeToSkip)
+      if (!aShape.IsNull())
         aPrs.setShape(aShape);
     }
     aPresentations.push_back(aPrs);
index f766841d6edea79f9134a863816e55bd52b400ad..9d6848ccd659fdcff401fe75b01efc5fd64d4708 100644 (file)
@@ -21,6 +21,7 @@
 #include <SelectMgr_IndexedMapOfOwner.hxx>
 
 class XGUI_Workshop;
+class Handle_SelectMgr_EntityOwner;
 
 /**
 * \ingroup GUI
@@ -34,14 +35,17 @@ class XGUI_EXPORT XGUI_Selection : public ModuleBase_ISelection
   XGUI_Selection(XGUI_Workshop* theWorkshop);
 
   /// 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
-  virtual QList<ModuleBase_ViewerPrs> getSelected(int theShapeTypeToSkip = -1) const;
+  virtual QList<ModuleBase_ViewerPrs> getSelected() const;
+
+  /// Fills the viewer presentation parameters by the parameters from the owner
+  /// \param thePrs a container for selection
+  /// \param theOwner a selection owner
+  void fillPresentation(ModuleBase_ViewerPrs& thePrs, const Handle_SelectMgr_EntityOwner& theOwner) 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
-  virtual QList<ModuleBase_ViewerPrs> getHighlighted(int theShapeTypeToSkip = -1) const;
+  virtual QList<ModuleBase_ViewerPrs> getHighlighted() const;
 
   /**
    * Returns list of currently selected objects in object browser