Salome HOME
1. Mirror/Rotation/Translation constraint: using RefList instead of SelectionList
authornds <natalia.donis@opencascade.com>
Thu, 20 Aug 2015 07:24:03 +0000 (10:24 +0300)
committernds <natalia.donis@opencascade.com>
Thu, 20 Aug 2015 09:44:41 +0000 (12:44 +0300)
2. External edge: do not use execute() for external objects, created temporary for validating; union create/remove external objects
3. Compsolid redisplay: erase CompSolid on redisplay signal if it is visualized but number of sub results is positive
4. Deviation coefficient for visualized shapes with Edge shape type.

26 files changed:
src/ModelAPI/ModelAPI_Tools.cpp [changed mode: 0644->0755]
src/ModelAPI/ModelAPI_Tools.h [changed mode: 0644->0755]
src/ModuleBase/ModuleBase_ResultPrs.cpp [changed mode: 0644->0755]
src/ModuleBase/ModuleBase_Tools.cpp [changed mode: 0644->0755]
src/ModuleBase/ModuleBase_Tools.h [changed mode: 0644->0755]
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp [changed mode: 0644->0755]
src/ModuleBase/ModuleBase_WidgetMultiSelector.h [changed mode: 0644->0755]
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/ModuleBase/ModuleBase_WidgetValidated.cpp
src/ModuleBase/ModuleBase_WidgetValidated.h
src/PartSet/PartSet_CustomPrs.cpp
src/PartSet/PartSet_ExternalObjectsMgr.cpp [changed mode: 0644->0755]
src/PartSet/PartSet_ExternalObjectsMgr.h [changed mode: 0644->0755]
src/PartSet/PartSet_Module.cpp [changed mode: 0644->0755]
src/PartSet/PartSet_OperationPrs.cpp
src/PartSet/PartSet_Tools.cpp [changed mode: 0644->0755]
src/PartSet/PartSet_Tools.h [changed mode: 0644->0755]
src/PartSet/PartSet_Validators.cpp [changed mode: 0644->0755]
src/PartSet/PartSet_WidgetMultiSelector.cpp [changed mode: 0644->0755]
src/PartSet/PartSet_WidgetShapeSelector.cpp [changed mode: 0644->0755]
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp [changed mode: 0644->0755]
src/SketchPlugin/SketchPlugin_MultiRotation.cpp [changed mode: 0644->0755]
src/SketchPlugin/SketchPlugin_MultiTranslation.cpp [changed mode: 0644->0755]
src/SketchPlugin/SketchPlugin_Validators.cpp [changed mode: 0644->0755]
src/XGUI/XGUI_WorkshopListener.cpp

old mode 100644 (file)
new mode 100755 (executable)
index 2f4fba7..1da66a8
@@ -203,5 +203,11 @@ ResultCompSolidPtr compSolidOwner(const ResultPtr& theSub)
   return ResultCompSolidPtr(); // not found
 }
 
+bool hasSubResults(const ResultPtr& theResult)
+{
+  ResultCompSolidPtr aCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(theResult);
+  return aCompSolid.get() && aCompSolid->numberOfSubs() > 0;
+}
+
 } // namespace ModelAPI_Tools
 
old mode 100644 (file)
new mode 100755 (executable)
index 97b93c9..e404948
@@ -67,6 +67,13 @@ MODELAPI_EXPORT CompositeFeaturePtr compositeOwner(const FeaturePtr& theFeature)
  */
 MODELAPI_EXPORT ResultCompSolidPtr compSolidOwner(const ResultPtr& theSub);
 
+/*!
+* Returns true if the result contains a not empty list of sub results. It processes result compsolid.
+* \param theResult a result object
+* \returns boolean value
+*/
+MODELAPI_EXPORT bool hasSubResults(const ResultPtr& theResult);
+
 }
 
 #endif
old mode 100644 (file)
new mode 100755 (executable)
index 8ac1129..73a492d
@@ -66,8 +66,7 @@ void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
     Set(myOriginalShape);
 
     // change deviation coefficient to provide more precise circle
-    Handle(Prs3d_Drawer) aDrawer = Attributes();
-    //aDrawer->SetDeviationCoefficient(ModuleBase_Tools::defaultDeviationCoefficient());
+    ModuleBase_Tools::setDefaultDeviationCoefficient(myOriginalShape, Attributes());
     AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
   }
 }
old mode 100644 (file)
new mode 100755 (executable)
index bed9b77..2c91143
@@ -254,10 +254,11 @@ void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFe
   }
 }
 
-double defaultDeviationCoefficient()
+void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape,
+                                    const Handle(Prs3d_Drawer)& theDrawer)
 {
-  // this value is chosen by performance check. Test case is an extrusion on sketch circle.
-  return 1.e-4; // default value is 1.e-3
+  if (!theShape.IsNull() && theShape.ShapeType() == TopAbs_EDGE)
+    theDrawer->SetDeviationCoefficient(1.e-4);
 }
 
 }
old mode 100644 (file)
new mode 100755 (executable)
index e0aa9c6..aa22e46
@@ -12,6 +12,8 @@
 
 #include <ModelAPI_Feature.h>
 #include <TopAbs_ShapeEnum.hxx>
+#include <TopoDS_Shape.hxx>
+#include <Prs3d_Drawer.hxx>
 
 #include <QPixmap>
 
@@ -96,12 +98,16 @@ Check types of objects which are in the given list
 \param hasParameter will be set to true if list contains Parameter objects
 \param hasSubFeature will be set to true if list contains Sub-Feature objects
 */
-MODULEBASE_EXPORT void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature, bool& hasParameter, bool& hasSubFeature);
+MODULEBASE_EXPORT void checkObjects(const QObjectPtrList& theObjects, bool& hasResult,
+                           bool& hasFeature, bool& hasParameter, bool& hasSubFeature);
 
-/*! Returns the default deviation coefficient value
+/*! Sets the default coeffient into the driver calculated accordingly the shape type.
+It provides 1.e-4 for a shape withe Edge shape type
+\param theShape a shape to define the deviation coeffient, 
 \return double value
 */
-MODULEBASE_EXPORT double defaultDeviationCoefficient();
+MODULEBASE_EXPORT void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape,
+                                                      const Handle(Prs3d_Drawer)& theDrawer);
 }
 
 #endif
old mode 100644 (file)
new mode 100755 (executable)
index 242b05c..a702560
@@ -19,6 +19,8 @@
 
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeRefList.h>
 
 #include <Config_WidgetAPI.h>
 
@@ -64,7 +66,7 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen
                                                                const Config_WidgetAPI* theData,
                                                                const std::string& theParentId)
  : ModuleBase_WidgetSelector(theParent, theWorkshop, theData, theParentId),
-   mySelectionCount(0), myIsInValidate(false)
+   mySelectionCount(0)
 {
   QGridLayout* aMainLay = new QGridLayout(this);
   ModuleBase_Tools::adjustMargins(aMainLay);
@@ -130,16 +132,11 @@ bool ModuleBase_WidgetMultiSelector::storeValueCustom() const
 {
   // the value is stored on the selection changed signal processing 
   // A rare case when plugin was not loaded. 
-  if(!myFeature)
+  if (!myFeature)
     return false;
-  DataPtr aData = myFeature->data();
-  AttributeSelectionListPtr aSelectionListAttr = 
-    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
-
-  if (aSelectionListAttr) {
-    // Store shapes type
-     TopAbs_ShapeEnum aCurrentType =
-           ModuleBase_Tools::shapeType(myTypeCombo->currentText());
+
+  AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
+  if (aSelectionListAttr.get()) {
      aSelectionListAttr->setSelectionType(myTypeCombo->currentText().toStdString());
   }   
    return true;
@@ -149,73 +146,86 @@ bool ModuleBase_WidgetMultiSelector::storeValueCustom() const
 bool ModuleBase_WidgetMultiSelector::restoreValueCustom()
 {
   // A rare case when plugin was not loaded. 
-  if(!myFeature)
+  if (!myFeature)
     return false;
-  DataPtr aData = myFeature->data();
-  AttributeSelectionListPtr aSelectionListAttr = 
-    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
 
-  if (aSelectionListAttr) {
+  AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
+  if (aSelectionListAttr.get()) {
     // Restore shape type
     if (!aSelectionListAttr->selectionType().empty())
       setCurrentShapeType(ModuleBase_Tools::shapeType(aSelectionListAttr->selectionType().c_str()));
-    updateSelectionList(aSelectionListAttr);
-    return true;
   }
-  return false;
+  updateSelectionList();
+  return true;
 }
 
 //********************************************************************
 void ModuleBase_WidgetMultiSelector::storeAttributeValue()
 {
-  myIsInValidate = true;
-  DataPtr aData = myFeature->data();
-  AttributeSelectionListPtr aSelectionListAttr = 
-    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
-  if (aSelectionListAttr.get() == NULL)
-    return;
-
-  mySelectionType = aSelectionListAttr->selectionType();
-  mySelectionCount = aSelectionListAttr->size();
+  ModuleBase_WidgetValidated::storeAttributeValue();
+
+  AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
+  if (aSelectionListAttr.get()) {
+    mySelectionType = aSelectionListAttr->selectionType();
+    mySelectionCount = aSelectionListAttr->size();
+  }
+  else {
+    AttributeRefListPtr aRefListAttr = myFeature->data()->reflist(attributeID());
+    mySelectionCount = aRefListAttr->size();
+  }
 }
 
 //********************************************************************
-void ModuleBase_WidgetMultiSelector::clearAttribute()
+void ModuleBase_WidgetMultiSelector::restoreAttributeValue(bool theValid)
 {
-  DataPtr aData = myFeature->data();
-  AttributeSelectionListPtr aSelectionListAttr =
-    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
-  aSelectionListAttr->clear();
+  ModuleBase_WidgetValidated::restoreAttributeValue(theValid);
+
+  // Store shape type
+  AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
+  if (aSelectionListAttr.get()) {
+    aSelectionListAttr->setSelectionType(mySelectionType);
+
+    // restore selection in the attribute. Indeed there is only one stored object
+    int aCountAppened = aSelectionListAttr->size() - mySelectionCount;
+    for (int i = 0; i < aCountAppened; i++)
+      aSelectionListAttr->removeLast();
+  }
+  else {
+    AttributeRefListPtr aRefListAttr = myFeature->data()->reflist(attributeID());
+    // restore objects in the attribute. Indeed there is only one stored object
+#ifdef DEBUG_REFLIST
+    int aCountAppened = aRefListAttr->size() - mySelectionCount;
+    for (int i = 0; i < aCountAppened; i++)
+      aRefListAttr->removeLast();
+#endif
+  }
 }
 
 //********************************************************************
-void ModuleBase_WidgetMultiSelector::setObject(ObjectPtr theSelectedObject,
-                                               GeomShapePtr theShape)
+void ModuleBase_WidgetMultiSelector::clearAttribute()
 {
-  DataPtr aData = myFeature->data();
-  AttributeSelectionListPtr aSelectionListAttr = 
-    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
-
-  int aSelCount = aSelectionListAttr->size();
-  ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theSelectedObject);
-  aSelectionListAttr->append(aResult, theShape, myIsInValidate);
+  AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
+  if (aSelectionListAttr.get())
+    aSelectionListAttr->clear();
+  else {
+    AttributeRefListPtr aRefListAttr = myFeature->data()->reflist(attributeID());
+    aRefListAttr->clear();
+  }
 }
 
 //********************************************************************
-void ModuleBase_WidgetMultiSelector::restoreAttributeValue(bool/* theValid*/)
+void ModuleBase_WidgetMultiSelector::setObject(ObjectPtr theSelectedObject,
+                                               GeomShapePtr theShape)
 {
-  myIsInValidate = false;
-
-  // Store shape type
-  DataPtr aData = myFeature->data();
-  AttributeSelectionListPtr aSelectionListAttr = 
-    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
-  aSelectionListAttr->setSelectionType(mySelectionType);
-
-  // restore selection in the attribute
-  int aCountAppened = aSelectionListAttr->size() - mySelectionCount;
-  for ( int i = 0; i < aCountAppened; i++)
-    aSelectionListAttr->removeLast();
+  AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
+  if (aSelectionListAttr.get()) {
+    ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theSelectedObject);
+    aSelectionListAttr->append(aResult, theShape, myIsInValidate);
+  }
+  else {
+    AttributeRefListPtr aRefListAttr = myFeature->data()->reflist(attributeID());
+    aRefListAttr->append(theSelectedObject);
+  }
 }
 
 //********************************************************************
@@ -355,12 +365,10 @@ QList<ModuleBase_ViewerPrs> ModuleBase_WidgetMultiSelector::getAttributeSelectio
   QList<ModuleBase_ViewerPrs> aSelected;
   // Restore selection in the viewer by the attribute selection list
   if(myFeature) {
-    DataPtr aData = myFeature->data();
-    AttributeSelectionListPtr aListAttr = 
-      std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
-    if (aListAttr) {
-      for (int i = 0; i < aListAttr->size(); i++) {
-        AttributeSelectionPtr anAttr = aListAttr->value(i);
+    AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
+    if (aSelectionListAttr.get()) {
+      for (int i = 0; i < aSelectionListAttr->size(); i++) {
+        AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
         ResultPtr anObject = anAttr->context();
         if (anObject.get()) {
           TopoDS_Shape aShape;
@@ -372,17 +380,40 @@ QList<ModuleBase_ViewerPrs> ModuleBase_WidgetMultiSelector::getAttributeSelectio
         }
       }
     }
+    else {
+      AttributeRefListPtr aRefListAttr = myFeature->data()->reflist(attributeID());
+      if (aRefListAttr.get()) {
+        for (int i = 0; i < aRefListAttr->size(); i++) {
+          ObjectPtr anObject = aRefListAttr->object(i);
+          if (anObject.get()) {
+            aSelected.append(ModuleBase_ViewerPrs(anObject, TopoDS_Shape(), NULL));
+          }
+        }
+      }
+    }
   }
   return aSelected;
 }
 
 //********************************************************************
-void ModuleBase_WidgetMultiSelector::updateSelectionList(AttributeSelectionListPtr theList)
+void ModuleBase_WidgetMultiSelector::updateSelectionList()
 {
   myListControl->clear();
-  for (int i = 0; i < theList->size(); i++) {
-    AttributeSelectionPtr aAttr = theList->value(i);
-    myListControl->addItem(aAttr->namingName().c_str());
+
+  AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
+  if (aSelectionListAttr.get()) {
+    for (int i = 0; i < aSelectionListAttr->size(); i++) {
+      AttributeSelectionPtr aAttr = aSelectionListAttr->value(i);
+      myListControl->addItem(aAttr->namingName().c_str());
+    }
+  }
+  else {
+    AttributeRefListPtr aRefListAttr = myFeature->data()->reflist(attributeID());
+    for (int i = 0; i < aRefListAttr->size(); i++) {
+      ObjectPtr anObject = aRefListAttr->object(i);
+      if (anObject.get())
+        myListControl->addItem(anObject->data()->name().c_str());
+    }
   }
   // We have to call repaint because sometimes the List control is not updated
   myListControl->repaint();
old mode 100644 (file)
new mode 100755 (executable)
index 5a86bdf..403847d
@@ -15,7 +15,6 @@
 
 #include <GeomAPI_Shape.h>
 #include <ModelAPI_Result.h>
-#include <ModelAPI_AttributeSelectionList.h>
 
 #include <NCollection_List.hxx>
 #include <TopoDS_Shape.hxx>
@@ -135,8 +134,8 @@ protected:
   /// a shape. If the attribute do not uses the shape, it is empty
   virtual QList<ModuleBase_ViewerPrs> getAttributeSelection() const;
 
-  /// Update selection list
-  void updateSelectionList(AttributeSelectionListPtr);
+  /// Fills the list control by the attribute values
+  void updateSelectionList();
 
   /// Converts the XML defined type choice to the validator type
   /// For example, the "Edges" is converted to "edge"
@@ -163,7 +162,6 @@ protected:
 
   /// Variable of GeomSelection
   int mySelectionCount; // number of elements in the attribute selection list when store
-  bool myIsInValidate; // the widget is in validation mode: store is performed, restore is not
 
   bool myIsUseChoice;
 };
index 6d47be32c6aa52f2ded96d5afad18bacc366fd93..16e0d2a620a7981077f4a70da738d17d14958055 100644 (file)
@@ -249,6 +249,8 @@ void ModuleBase_WidgetShapeSelector::updateSelectionName()
 //********************************************************************
 void ModuleBase_WidgetShapeSelector::storeAttributeValue()
 {
+  ModuleBase_WidgetValidated::storeAttributeValue();
+
   DataPtr aData = myFeature->data();
   AttributePtr anAttribute = myFeature->attribute(attributeID());
 
@@ -266,6 +268,8 @@ void ModuleBase_WidgetShapeSelector::storeAttributeValue()
 //********************************************************************
 void ModuleBase_WidgetShapeSelector::restoreAttributeValue(bool theValid)
 {
+  ModuleBase_WidgetValidated::restoreAttributeValue(theValid);
+
   DataPtr aData = myFeature->data();
   AttributePtr anAttribute = myFeature->attribute(attributeID());
 
index 20b33095f153e38255c8eb0db83eb4a6b8d85716..d549ac306130b108f731650513e1012abb392f57 100644 (file)
@@ -25,7 +25,7 @@ ModuleBase_WidgetValidated::ModuleBase_WidgetValidated(QWidget* theParent,
                                                        const Config_WidgetAPI* theData,
                                                        const std::string& theParentId)
 : ModuleBase_ModelWidget(theParent, theData, theParentId),
-  myWorkshop(theWorkshop)
+  myWorkshop(theWorkshop), myIsInValidate(false)
 {
 }
 
@@ -60,6 +60,18 @@ ObjectPtr ModuleBase_WidgetValidated::findPresentedObject(const AISObjectPtr& th
   return myPresentedObject;
 }
 
+//********************************************************************
+void ModuleBase_WidgetValidated::storeAttributeValue()
+{
+  myIsInValidate = true;
+}
+
+//********************************************************************
+void ModuleBase_WidgetValidated::restoreAttributeValue(const bool theValid)
+{
+  myIsInValidate = false;
+}
+
 //********************************************************************
 bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrs& thePrs)
 {
index d53bbb705beee95affa492329f44bbea9b49cb8c..a9b77d939980e4267c1e858690815233b8afda4b 100644 (file)
@@ -70,13 +70,13 @@ 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
-  virtual void storeAttributeValue() = 0;
+  virtual void storeAttributeValue();
 
   /// 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 theValid a boolean flag, if restore happens for valid parameters
-  virtual void restoreAttributeValue(const bool theValid) = 0;
+  virtual void restoreAttributeValue(const bool theValid);
 
   /// Checks the widget validity. By default, it returns true.
   /// \param theValue a selected presentation in the view
@@ -125,6 +125,7 @@ protected:
 
 protected:
   ModuleBase_IWorkshop* myWorkshop;  /// Reference to workshop
+  bool myIsInValidate; // the widget is in validation mode: store is performed, restore is not
 
 private:
   ObjectPtr myPresentedObject; /// back up of the filtered object
index aedc188b58d111159f80101a8a559d8b2c30fa82..008640c20275c9e0de40b651ea83e36aaa0f4af3 100755 (executable)
@@ -17,9 +17,6 @@
 
 #include <GeomValidators_Tools.h>
 
-#include <ModelAPI_Attribute.h>
-#include <ModelAPI_AttributeSelectionList.h>
-
 #include <Config_PropManager.h>
 
 #include <AIS_InteractiveContext.hxx>
old mode 100644 (file)
new mode 100755 (executable)
index 2cdcd24..df63169
@@ -42,22 +42,27 @@ bool PartSet_ExternalObjectsMgr::isValidObject(const ObjectPtr& theObject)
 
 ObjectPtr PartSet_ExternalObjectsMgr::externalObject(const ObjectPtr& theSelectedObject,
                                                      const GeomShapePtr& theShape,
-                                                     const CompositeFeaturePtr& theSketch)
+                                                     const CompositeFeaturePtr& theSketch,
+                                                     const bool theTemporary)
 {
-  ObjectPtr aSelectedObject = PartSet_Tools::findFixedObjectByExternal(theShape->impl<TopoDS_Shape>(),
-                                                             theSelectedObject, theSketch);
+  ObjectPtr aSelectedObject = PartSet_Tools::findFixedObjectByExternal(
+                                  theShape->impl<TopoDS_Shape>(), theSelectedObject, theSketch);
   if (!aSelectedObject.get()) {
     // Processing of external (non-sketch) object
     aSelectedObject = PartSet_Tools::createFixedObjectByExternal(theShape->impl<TopoDS_Shape>(),
-                                                                 theSelectedObject, theSketch);
-    if (aSelectedObject.get())
-      myExternalObjects.append(aSelectedObject);
+                                                    theSelectedObject, theSketch, theTemporary);
+    if (aSelectedObject.get()) {
+      if (theTemporary)
+        myExternalObjectValidated = aSelectedObject;
+      else
+        myExternalObjects.append(aSelectedObject);
+    }
   }
   return aSelectedObject;
 }
 
 //********************************************************************
-ObjectPtr PartSet_ExternalObjectsMgr::externalObjectValidated(const ObjectPtr& theSelectedObject,
+/*ObjectPtr PartSet_ExternalObjectsMgr::externalObjectValidated(const ObjectPtr& theSelectedObject,
                                                      const GeomShapePtr& theShape,
                                                      const CompositeFeaturePtr& theSketch)
 {
@@ -72,35 +77,24 @@ ObjectPtr PartSet_ExternalObjectsMgr::externalObjectValidated(const ObjectPtr& t
       myExternalObjectValidated = aSelectedObject;
   }
   return aSelectedObject;
-}
+}*/
 
 //********************************************************************
 void PartSet_ExternalObjectsMgr::removeExternal(const CompositeFeaturePtr& theSketch,
                                                 const FeaturePtr& theFeature,
-                                                ModuleBase_IWorkshop* theWorkshop)
+                                                ModuleBase_IWorkshop* theWorkshop,
+                                                const bool theTemporary)
 {
-  QObjectPtrList::const_iterator anIt = myExternalObjects.begin(), aLast = myExternalObjects.end();
-  for (; anIt != aLast; anIt++) {
-    ObjectPtr anObject = *anIt;
-    if (anObject.get()) {
-      DocumentPtr aDoc = anObject->document();
-      FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
-      if (aFeature.get() != NULL) {
-        QObjectPtrList anObjects;
-        anObjects.append(aFeature);
-        // the external feature should be removed with all references, sketch feature should be ignored
-        std::set<FeaturePtr> anIgnoredFeatures;
-        // the current feature should be ignored, because it can use the external feature in the
-        // attributes and, therefore have a references to it. So, the delete functionality tries
-        // to delete this feature. Test case is creation of a constraint on external point,
-        // use in this control after an external point, the point of the sketch.
-        anIgnoredFeatures.insert(theFeature);
-        workshop(theWorkshop)->deleteFeatures(anObjects, anIgnoredFeatures);
-      }
+  if (theTemporary)
+    removeExternalObject(myExternalObjectValidated, theSketch, theFeature, theWorkshop);
+  else{
+    QObjectPtrList::const_iterator anIt = myExternalObjects.begin(), aLast = myExternalObjects.end();
+    for (; anIt != aLast; anIt++) {
+      ObjectPtr anObject = *anIt;
+      removeExternalObject(anObject, theSketch, theFeature, theWorkshop);
     }
-    //removeExternalObject(anObject, theSketch, theFeature);
+    myExternalObjects.clear();
   }
-  myExternalObjects.clear();
 }
 
 //********************************************************************
@@ -126,14 +120,14 @@ void PartSet_ExternalObjectsMgr::removeUnusedExternalObjects(const QObjectPtrLis
 }
 
 //********************************************************************
-void PartSet_ExternalObjectsMgr::removeExternalValidated(const CompositeFeaturePtr& theSketch,
+/*void PartSet_ExternalObjectsMgr::removeExternalValidated(const CompositeFeaturePtr& theSketch,
                                                          const FeaturePtr& theFeature,
                                                          ModuleBase_IWorkshop* theWorkshop)
 {
   // TODO(nds): unite with removeExternal(), remove parameters
   removeExternalObject(myExternalObjectValidated, theSketch, theFeature, theWorkshop);
   myExternalObjectValidated = ObjectPtr();
-}
+}*/
 
 void PartSet_ExternalObjectsMgr::removeExternalObject(const ObjectPtr& theObject,
                                                       const CompositeFeaturePtr& theSketch,
old mode 100644 (file)
new mode 100755 (executable)
index 82f9dbf..97dae52
@@ -45,24 +45,27 @@ class PARTSET_EXPORT PartSet_ExternalObjectsMgr
   /// \param theSelectedObject an object
   /// \param theShape a selected shape, which is used in the selection attribute
   /// \param theSketch a current sketch
+  /// \param theTemporary the created external object is temporary, execute is not performed for it
   /// \return the object
   ObjectPtr externalObject(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape,
-                           const CompositeFeaturePtr& theSketch);
+                           const CompositeFeaturePtr& theSketch, const bool theTemporary = false);
 
-  ObjectPtr externalObjectValidated(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape,
-                           const CompositeFeaturePtr& theSketch);
+  //ObjectPtr externalObjectValidated(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape,
+  //                         const CompositeFeaturePtr& theSketch);
 
   // Removes the external presentation from the model
   /// \param theSketch a current sketch
   /// \param theFeature a current feature
   /// \param theFeature a current workshop
+  /// \param theTemporary if true, a temporary external object is removed overwise all ext objects
   void removeExternal(const CompositeFeaturePtr& theSketch,
                       const FeaturePtr& theFeature,
-                      ModuleBase_IWorkshop* theWorkshop);
+                      ModuleBase_IWorkshop* theWorkshop,
+                      const bool theTemporary);
 
-  void removeExternalValidated(const CompositeFeaturePtr& theSketch,
-                               const FeaturePtr& theFeature,
-                               ModuleBase_IWorkshop* theWorkshop);
+  //void removeExternalVali+dated(const CompositeFeaturePtr& theSketch,
+  //                             const FeaturePtr& theFeature,
+  //                             ModuleBase_IWorkshop* theWorkshop);
 
   void removeUnusedExternalObjects(const QObjectPtrList& theIgnoreObjects,
                             const CompositeFeaturePtr& theSketch,
old mode 100644 (file)
new mode 100755 (executable)
index ab86f1b..03b29dd
@@ -48,7 +48,6 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_ShapeValidator.h>
 #include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultCompSolid.h>
 
 #include <GeomDataAPI_Point2D.h>
 #include <GeomDataAPI_Point.h>
 #include <QDebug>
 #endif
 
-#define DEBUG_COMPOSOLID
-
-
 /*!Create and return new instance of XGUI_Module*/
 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* theWshop)
 {
@@ -361,13 +357,6 @@ bool PartSet_Module::canCommitOperation() const
 
 bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
 {
-#ifdef DEBUG_COMPOSOLID
-  ResultCompSolidPtr aCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>
-                                                                         (theObject);
-  if (aCompSolid.get() && aCompSolid->numberOfSubs() > 0)
-    return false;
-#endif
-
   // the sketch manager put the restriction to the objects display
   return mySketchMgr->canDisplayObject(theObject);
 }
index e775102d3f53c85be6eae7e988227ab86d98beab..d20041e43aa7b97aca301a2f3868e09d78a65580 100755 (executable)
@@ -19,6 +19,8 @@
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeRefList.h>
+
 
 #include <GeomValidators_Tools.h>
 
@@ -88,7 +90,7 @@ void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
         continue;
       TopoDS_Shape aShape = aGeomShape->impl<TopoDS_Shape>();
       // change deviation coefficient to provide more precise circle
-      //aDrawer->SetDeviationCoefficient(ModuleBase_Tools::defaultDeviationCoefficient());
+      ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, aDrawer);
       StdPrs_WFDeflectionShape::Add(thePresentation, aShape, aDrawer);
     }
   }
@@ -178,6 +180,14 @@ void PartSet_OperationPrs::getFeatureShapes(QMap<ObjectPtr, QList<GeomShapePtr>
         addValue(aResult, aShape, myFeature, theObjectShapes);
       }
     }
+    if (anAttrType == ModelAPI_AttributeRefList::typeId()) {
+      std::shared_ptr<ModelAPI_AttributeRefList> aCurSelList =
+        std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttribute);
+      for (int i = 0; i < aCurSelList->size(); i++) {
+        GeomShapePtr aShape;
+        addValue(aCurSelList->object(i), aShape, myFeature, theObjectShapes);
+      }
+    }
     else {
       ObjectPtr anObject;
       GeomShapePtr aShape;
@@ -214,6 +224,7 @@ bool PartSet_OperationPrs::isSelectionAttribute(const AttributePtr& theAttribute
   std::string anAttrType = theAttribute->attributeType();
 
   return anAttrType == ModelAPI_AttributeSelectionList::typeId() ||
+         anAttrType == ModelAPI_AttributeRefList::typeId() ||
          anAttrType == ModelAPI_AttributeRefAttr::typeId() ||
          anAttrType == ModelAPI_AttributeSelection::typeId() ||
          anAttrType == ModelAPI_AttributeReference::typeId();
old mode 100644 (file)
new mode 100755 (executable)
index f9c42ef..7644c72
@@ -480,8 +480,9 @@ ResultPtr PartSet_Tools::findFixedObjectByExternal(const TopoDS_Shape& theShape,
 }
 
 ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShape, 
-                                                 const ObjectPtr& theObject, 
-                                                 CompositeFeaturePtr theSketch)
+                                                     const ObjectPtr& theObject, 
+                                                     CompositeFeaturePtr theSketch,
+                                                     const bool theTemporary)
 {
   if (theShape.ShapeType() == TopAbs_EDGE) {
     Standard_Real aStart, aEnd;
@@ -517,14 +518,14 @@ ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShap
         anEdge->setImpl(new TopoDS_Shape(theShape));
 
         anAttr->setValue(aRes, anEdge);
+        if (!theTemporary) {
+          aMyFeature->execute();
 
-        aMyFeature->execute();
-
-        // fix this edge
-        FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID());
-        aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())->
-          setObject(aMyFeature->lastResult());
-
+          // fix this edge
+          FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID());
+          aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())->
+            setObject(aMyFeature->lastResult());
+        }
         return aMyFeature->lastResult();
       }
     }
@@ -544,13 +545,14 @@ ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShap
         aVert->setImpl(new TopoDS_Shape(theShape));
 
         anAttr->setValue(aRes, aVert);
-        aMyFeature->execute();
-
-        // fix this edge
-        FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID());
-        aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())->
-          setObject(aMyFeature->lastResult());
+        if (theTemporary) {
+          aMyFeature->execute();
 
+          // fix this edge
+          FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID());
+          aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())->
+            setObject(aMyFeature->lastResult());
+        }
         return aMyFeature->lastResult();
       }
     }
old mode 100644 (file)
new mode 100755 (executable)
index c113b83..9578493
@@ -166,10 +166,12 @@ class PARTSET_EXPORT PartSet_Tools
   /// \param theShape an edge
   /// \param theObject a selected result object
   /// \param theSketch a sketch feature
+  /// \param theTemporary the created external object is temporary, execute is not performed for it
   /// \return result of created feature
   static ResultPtr createFixedObjectByExternal(const TopoDS_Shape& theShape, 
                                                const ObjectPtr& theObject, 
-                                               CompositeFeaturePtr theSketch);
+                                               CompositeFeaturePtr theSketch,
+                                               const bool theTemporary = false);
 
   /// Checks whether the list of selected presentations contains the given one
   /// \param theSelected a list of presentations
old mode 100644 (file)
new mode 100755 (executable)
index f62a88b..86f6cb9
@@ -21,6 +21,7 @@
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeRefList.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Session.h>
 
@@ -295,6 +296,28 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute
       }
     }
   }
+  else if (anAttrType == ModelAPI_AttributeRefList::typeId()) {
+    std::shared_ptr<ModelAPI_AttributeRefList> aCurSelList =
+      std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
+    anAttrs = aFeature->data()->attributes(ModelAPI_AttributeRefList::typeId());
+    if (anAttrs.size() > 0) {
+      std::list<std::shared_ptr<ModelAPI_Attribute>>::iterator anAttrItr = anAttrs.begin();
+      for (; anAttrItr != anAttrs.end(); anAttrItr++){
+        if ((*anAttrItr).get() && (*anAttrItr)->id() != theAttribute->id()){
+          std::shared_ptr<ModelAPI_AttributeRefList> aRefSelList =
+            std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*anAttrItr);
+          for (int i = 0; i < aCurSelList->size(); i++) {
+            ObjectPtr aCurSelObject = aCurSelList->object(i);
+            for (int j = 0; j < aRefSelList->size(); j++) {
+              if (aCurSelObject == aRefSelList->object(j)) {
+                return false;
+              }
+            }
+          }
+        }
+      }
+    }
+  }
   return !featureHasReferences(theAttribute);
 }
 
@@ -343,11 +366,8 @@ bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute,
   if (anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
     AttributeSelectionListPtr aSelectionListAttr = 
                       std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
-    // it filters only selection list attributes
-    std::string aType = aSelectionListAttr->selectionType().c_str();
     // all context objects should be sketch entities
-    int aSize = aSelectionListAttr->size();
-    for (int i = 0; i < aSelectionListAttr->size() && isSketchEntities; i++) {
+    for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize && isSketchEntities; i++) {
       AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i);
       ObjectPtr anObject = aSelectAttr->context();
       // a context of the selection attribute is a feature result. It can be a case when the result
@@ -362,6 +382,24 @@ bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute,
       }
     }
   }
+  if (anAttributeType == ModelAPI_AttributeRefList::typeId()) {
+    AttributeRefListPtr aRefListAttr =
+      std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
+    // all context objects should be sketch entities
+    for (int i = 0, aSize = aRefListAttr->size(); i < aSize && isSketchEntities; i++) {
+      ObjectPtr anObject = aRefListAttr->object(i);
+      // a context of the selection attribute is a feature result. It can be a case when the result
+      // of the feature is null, e.g. the feature is modified and has not been executed yet.
+      // The validator returns an invalid result here. The case is an extrusion built on a sketch
+      // feature. A new sketch element creation leads to an empty result.
+      if (!anObject.get())
+        isSketchEntities = false;
+      else {
+        FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+        isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
+      }
+    }
+  }
   if (anAttributeType == ModelAPI_AttributeRefAttr::typeId()) {
     std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = 
                      std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
old mode 100644 (file)
new mode 100755 (executable)
index 91404aa..9f76f81
@@ -7,6 +7,8 @@
 #include "PartSet_WidgetMultiSelector.h"
 
 #include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeRefList.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 
@@ -49,15 +51,25 @@ bool PartSet_WidgetMultiSelector::setSelection(QList<ModuleBase_ViewerPrs>& theV
     // TODO(nds): unite with externalObject(), remove parameters
     //myFeature->execute();
 
-    DataPtr aData = myFeature->data();
-    AttributeSelectionListPtr aSelectionListAttr = 
-      std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
-
     QObjectPtrList aListOfAttributeObjects;
-    for (int i = 0; i < aSelectionListAttr->size(); i++) {
-      AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
-      aListOfAttributeObjects.append(anAttr->context());
+
+    AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
+    if (anAttribute->attributeType() == ModelAPI_AttributeSelectionList::typeId()) {
+      AttributeSelectionListPtr aSelectionListAttr = 
+                           std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(anAttribute);
+      for (int i = 0; i < aSelectionListAttr->size(); i++) {
+        AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
+        aListOfAttributeObjects.append(anAttr->context());
+      }
     }
+    else if (anAttribute->attributeType() == ModelAPI_AttributeRefList::typeId()) {
+      AttributeRefListPtr aRefListAttr = 
+                                 std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttribute);
+      for (int i = 0; i < aRefListAttr->size(); i++) {
+        aListOfAttributeObjects.append(aRefListAttr->object(i));
+      }
+    }
+
     myExternalObjectMgr->removeUnusedExternalObjects(aListOfAttributeObjects, sketch(), myFeature);
   }
   return aSucceed;
@@ -79,7 +91,7 @@ void PartSet_WidgetMultiSelector::restoreAttributeValue(const bool theValid)
 {
   ModuleBase_WidgetMultiSelector::restoreAttributeValue(theValid);
 
-  myExternalObjectMgr->removeExternalValidated(sketch(), myFeature, myWorkshop);
+  myExternalObjectMgr->removeExternal/*Validated*/(sketch(), myFeature, myWorkshop, true);
 }
 
 void PartSet_WidgetMultiSelector::getGeomSelection(const ModuleBase_ViewerPrs& thePrs,
@@ -101,10 +113,10 @@ void PartSet_WidgetMultiSelector::getGeomSelection(const ModuleBase_ViewerPrs& t
         aShape = aResult->shape();
     }
     if (aShape.get() != NULL && !aShape->isNull()) {
-      if (myIsInValidate)
-        theObject = myExternalObjectMgr->externalObjectValidated(theObject, aShape, sketch());
-      else
-        theObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch());
+      //if (myIsInValidate)
+      //  theObject = myExternalObjectMgr->externalObjectValidated(theObject, aShape, sketch());
+      //else
+      theObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch(), myIsInValidate);
     }
   }
 }
old mode 100644 (file)
new mode 100755 (executable)
index 5b2a4e7..0bbeb05
@@ -94,7 +94,7 @@ void PartSet_WidgetShapeSelector::getGeomSelection(const ModuleBase_ViewerPrs& t
         aShape = aResult->shape();
     }
     if (aShape.get() != NULL && !aShape->isNull())
-      theObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch());
+      theObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch(), myIsInValidate);
   }
 }
 
@@ -115,7 +115,7 @@ GeomShapePtr PartSet_WidgetShapeSelector::getShape() const
 void PartSet_WidgetShapeSelector::restoreAttributeValue(const bool theValid)
 {
   ModuleBase_WidgetShapeSelector::restoreAttributeValue(theValid);
-  myExternalObjectMgr->removeExternal(sketch(), myFeature, myWorkshop);
+  myExternalObjectMgr->removeExternal(sketch(), myFeature, myWorkshop, true);
 }
 
 //********************************************************************
index b2883760df632b2c29792fdeac1c0df86d8ca02c..73fd01d6cb8743a0ead06e0601b5538ea222fdf6 100644 (file)
@@ -197,7 +197,6 @@ std::shared_ptr<GeomAPI_Pln> PartSet_WidgetSketchLabel::plane() const
 {
   CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
   return PartSet_Tools::sketchPlane(aSketch);
-
 }
 
 bool PartSet_WidgetSketchLabel::focusTo()
@@ -213,10 +212,13 @@ void PartSet_WidgetSketchLabel::enableFocusProcessing()
 
 void PartSet_WidgetSketchLabel::storeAttributeValue()
 {
+  ModuleBase_WidgetValidated::storeAttributeValue();
 }
 
 void PartSet_WidgetSketchLabel::restoreAttributeValue(const bool theValid)
 {
+  ModuleBase_WidgetValidated::restoreAttributeValue(theValid);
+
   // it is not necessary to save the previous plane value because the plane is chosen once
   DataPtr aData = feature()->data();
   AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
old mode 100644 (file)
new mode 100755 (executable)
index 73649b1..5691e6c
@@ -10,7 +10,6 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_AttributeRefList.h>
-#include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
@@ -31,18 +30,14 @@ void SketchPlugin_ConstraintMirror::initAttributes()
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefList::typeId());
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefList::typeId());
-  AttributeSelectionListPtr aSelection = 
-    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
-    SketchPlugin_ConstraintMirror::MIRROR_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
-  aSelection->setSelectionType("EDGE");
+  data()->addAttribute(SketchPlugin_ConstraintMirror::MIRROR_LIST_ID(), ModelAPI_AttributeRefList::typeId());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_B());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_C());
 }
 
 void SketchPlugin_ConstraintMirror::execute()
 {
-  AttributeSelectionListPtr aMirrorObjectRefs =
-      selectionList(SketchPlugin_ConstraintMirror::MIRROR_LIST_ID());
+  AttributeRefListPtr aMirrorObjectRefs = reflist(SketchPlugin_ConstraintMirror::MIRROR_LIST_ID());
 
   // Wait all objects being created, then send update events
   static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
@@ -60,16 +55,16 @@ void SketchPlugin_ConstraintMirror::execute()
   std::vector<bool> isUsed(anInitialList.size(), false);
   // add new items to the list
   for(int anInd = 0; anInd < aMirrorObjectRefs->size(); anInd++) {
-    std::shared_ptr<ModelAPI_AttributeSelection> aSelect = aMirrorObjectRefs->value(anInd);
+    ObjectPtr anObject = aMirrorObjectRefs->object(anInd);
     std::list<ObjectPtr>::const_iterator anIt = anInitialList.begin();
     std::vector<bool>::iterator aUsedIt = isUsed.begin();
     for (; anIt != anInitialList.end(); anIt++, aUsedIt++)
-      if (*anIt == aSelect->context()) {
+      if (*anIt == anObject) {
         *aUsedIt = true;
         break;
       }
     if (anIt == anInitialList.end())
-      aRefListOfShapes->append(aSelect->context());
+      aRefListOfShapes->append(anObject);
   }
   // remove unused items
   std::list<ObjectPtr>::iterator anInitIter = anInitialList.begin();
@@ -204,7 +199,7 @@ AISObjectPtr SketchPlugin_ConstraintMirror::getAISObject(AISObjectPtr thePreviou
 void SketchPlugin_ConstraintMirror::attributeChanged(const std::string& theID)
 {
   if (theID == MIRROR_LIST_ID()) {
-    AttributeSelectionListPtr aMirrorObjectRefs = selectionList(MIRROR_LIST_ID());
+    AttributeRefListPtr aMirrorObjectRefs = reflist(MIRROR_LIST_ID());
     if (aMirrorObjectRefs->size() == 0) {
       // Clear list of objects
       AttributeRefListPtr aRefListOfMirrored = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
old mode 100644 (file)
new mode 100755 (executable)
index 126c2fe..726ffe4
@@ -12,7 +12,6 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_AttributeRefList.h>
-#include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
@@ -37,10 +36,7 @@ void SketchPlugin_MultiRotation::initAttributes()
   data()->addAttribute(NUMBER_OF_COPIES_ID(), ModelAPI_AttributeInteger::typeId());
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefList::typeId());
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefList::typeId());
-  AttributeSelectionListPtr aSelection = 
-    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
-    ROTATION_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
-  aSelection->setSelectionType("EDGE");
+  data()->addAttribute(ROTATION_LIST_ID(), ModelAPI_AttributeRefList::typeId());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_A());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_B());
 }
@@ -53,7 +49,7 @@ void SketchPlugin_MultiRotation::execute()
     return;
   }
 
-  AttributeSelectionListPtr aRotationObjectRefs = selectionList(ROTATION_LIST_ID());
+  AttributeRefListPtr aRotationObjectRefs = reflist(ROTATION_LIST_ID());
   int aNbCopies = integer(NUMBER_OF_COPIES_ID())->value();
 
   // Obtain center and angle of rotation
@@ -84,20 +80,20 @@ void SketchPlugin_MultiRotation::execute()
       aRefListOfRotated->size() / aRefListOfShapes->size() - 1 : 0;
   std::list<ObjectPtr> anInitialList = aRefListOfShapes->list();
   std::list<ObjectPtr> aTargetList = aRefListOfRotated->list();
-  std::list<ResultPtr> anAddition;
+  std::list<ObjectPtr> anAddition;
   std::vector<bool> isUsed(anInitialList.size(), false);
   // collect new items and check the items to remove
   for(int anInd = 0; anInd < aRotationObjectRefs->size(); anInd++) {
-    std::shared_ptr<ModelAPI_AttributeSelection> aSelect = aRotationObjectRefs->value(anInd);
+    ObjectPtr anObject = aRotationObjectRefs->object(anInd);
     std::list<ObjectPtr>::const_iterator anIt = anInitialList.begin();
     std::vector<bool>::iterator aUsedIt = isUsed.begin();
     for (; anIt != anInitialList.end(); anIt++, aUsedIt++)
-      if (*anIt == aSelect->context()) {
+      if (*anIt == anObject) {
         *aUsedIt = true;
         break;
       }
     if (anIt == anInitialList.end())
-      anAddition.push_back(aSelect->context());
+      anAddition.push_back(anObject);
   }
   // remove unused items
   std::list<ObjectPtr>::iterator anInitIter = anInitialList.begin();
@@ -170,7 +166,7 @@ void SketchPlugin_MultiRotation::execute()
       aRefListOfRotated->append(*aTargetIter);
   }
   // add new items
-  std::list<ResultPtr>::iterator anAddIter = anAddition.begin();
+  std::list<ObjectPtr>::iterator anAddIter = anAddition.begin();
   for (; anAddIter != anAddition.end(); anAddIter++) {
     aRefListOfShapes->append(*anAddIter);
     aRefListOfRotated->append(*anAddIter);
@@ -281,7 +277,7 @@ void SketchPlugin_MultiRotation::rotateFeature(
 void SketchPlugin_MultiRotation::attributeChanged(const std::string& theID)
 {
   if (theID == ROTATION_LIST_ID()) {
-    AttributeSelectionListPtr aRotationObjectRefs = selectionList(ROTATION_LIST_ID());
+    AttributeRefListPtr aRotationObjectRefs = reflist(ROTATION_LIST_ID());
     if (aRotationObjectRefs->size() == 0) {
       int aNbCopies = integer(NUMBER_OF_COPIES_ID())->value();
       // Clear list of objects
old mode 100644 (file)
new mode 100755 (executable)
index eadf54a..3e6a702
@@ -13,7 +13,6 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_AttributeRefList.h>
-#include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
@@ -31,10 +30,7 @@ void SketchPlugin_MultiTranslation::initAttributes()
   data()->addAttribute(NUMBER_OF_COPIES_ID(), ModelAPI_AttributeInteger::typeId());
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefList::typeId());
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefList::typeId());
-  AttributeSelectionListPtr aSelection = 
-    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
-    TRANSLATION_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
-  aSelection->setSelectionType("EDGE");
+  data()->addAttribute(TRANSLATION_LIST_ID(), ModelAPI_AttributeRefList::typeId());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_A());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_B());
 }
@@ -47,7 +43,7 @@ void SketchPlugin_MultiTranslation::execute()
     return;
   }
 
-  AttributeSelectionListPtr aTranslationObjectRefs = selectionList(TRANSLATION_LIST_ID());
+  AttributeRefListPtr aTranslationObjectRefs = reflist(TRANSLATION_LIST_ID());
   int aNbCopies = integer(NUMBER_OF_COPIES_ID())->value();
 
   // Calculate shift vector
@@ -79,20 +75,21 @@ void SketchPlugin_MultiTranslation::execute()
       aRefListOfTranslated->size() / aRefListOfShapes->size() - 1 : 0;
   std::list<ObjectPtr> anInitialList = aRefListOfShapes->list();
   std::list<ObjectPtr> aTargetList = aRefListOfTranslated->list();
-  std::list<ResultPtr> anAddition;
+  std::list<ObjectPtr> anAddition;
   std::vector<bool> isUsed(anInitialList.size(), false);
   // collect new items and check the items to remove
   for(int anInd = 0; anInd < aTranslationObjectRefs->size(); anInd++) {
-    std::shared_ptr<ModelAPI_AttributeSelection> aSelect = aTranslationObjectRefs->value(anInd);
+    //std::shared_ptr<ModelAPI_AttributeSelection> aSelect = aTranslationObjectRefs->value(anInd);
+    ObjectPtr anObject = aTranslationObjectRefs->object(anInd);
     std::list<ObjectPtr>::const_iterator anIt = anInitialList.begin();
     std::vector<bool>::iterator aUsedIt = isUsed.begin();
     for (; anIt != anInitialList.end(); anIt++, aUsedIt++)
-      if (*anIt == aSelect->context()) {
+      if (*anIt == anObject) {
         *aUsedIt = true;
         break;
       }
     if (anIt == anInitialList.end())
-      anAddition.push_back(aSelect->context());
+      anAddition.push_back(anObject);
   }
   // remove unused items
   std::list<ObjectPtr>::iterator anInitIter = anInitialList.begin();
@@ -165,7 +162,7 @@ void SketchPlugin_MultiTranslation::execute()
       aRefListOfTranslated->append(*aTargetIter);
   }
   // add new items
-  std::list<ResultPtr>::iterator anAddIter = anAddition.begin();
+  std::list<ObjectPtr>::iterator anAddIter = anAddition.begin();
   for (; anAddIter != anAddition.end(); anAddIter++) {
     aRefListOfShapes->append(*anAddIter);
     aRefListOfTranslated->append(*anAddIter);
@@ -223,7 +220,7 @@ ObjectPtr SketchPlugin_MultiTranslation::copyFeature(ObjectPtr theObject)
 void SketchPlugin_MultiTranslation::attributeChanged(const std::string& theID)
 {
   if (theID == TRANSLATION_LIST_ID()) {
-    AttributeSelectionListPtr aTranslationObjectRefs = selectionList(TRANSLATION_LIST_ID());
+    AttributeRefListPtr aTranslationObjectRefs = reflist(TRANSLATION_LIST_ID());
     if (aTranslationObjectRefs->size() == 0) {
       int aNbCopies = integer(NUMBER_OF_COPIES_ID())->value();
       // Clear list of objects
old mode 100644 (file)
new mode 100755 (executable)
index 6e8b36b..377affa
@@ -199,8 +199,8 @@ bool SketchPlugin_MirrorAttrValidator::isValid(const AttributePtr& theAttribute,
                                                std::string& theError) const
 {
   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
-  AttributeSelectionListPtr aSelAttr = 
-    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+  AttributeRefListPtr aSelAttr = 
+    std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
   if (!aSelAttr)
     return false;
 
@@ -209,10 +209,10 @@ bool SketchPlugin_MirrorAttrValidator::isValid(const AttributePtr& theAttribute,
   std::list<ObjectPtr> aMirroredObjects = aRefListOfMirrored->list();
 
   for(int anInd = 0; anInd < aSelAttr->size(); anInd++) {
-    std::shared_ptr<ModelAPI_AttributeSelection> aSelect = aSelAttr->value(anInd);
+    ObjectPtr aSelObject = aSelAttr->object(anInd);
     std::list<ObjectPtr>::iterator aMirIter = aMirroredObjects.begin();
     for (; aMirIter != aMirroredObjects.end(); aMirIter++)
-      if (aSelect->context() == *aMirIter)
+      if (aSelObject == *aMirIter)
         return false;
   }
   return true;
@@ -268,8 +268,8 @@ bool SketchPlugin_CopyValidator::isValid(const AttributePtr& theAttribute,
                                          std::string& theError) const
 {
   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
-  AttributeSelectionListPtr aSelAttr = 
-    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+  AttributeRefListPtr aSelAttr = 
+    std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
   if (!aSelAttr)
     return false;
 
@@ -282,16 +282,16 @@ bool SketchPlugin_CopyValidator::isValid(const AttributePtr& theAttribute,
 
   std::list<ObjectPtr>::iterator anObjIter;
   for(int anInd = 0; anInd < aSelAttr->size(); anInd++) {
-    std::shared_ptr<ModelAPI_AttributeSelection> aSelect = aSelAttr->value(anInd);
+    ObjectPtr aSelObject = aSelAttr->object(anInd);
     anObjIter = anInitialObjects.begin();
     for (; anObjIter != anInitialObjects.end(); anObjIter++)
-      if (aSelect->context() == *anObjIter)
+      if (aSelObject == *anObjIter)
         break;
     if (anObjIter != anInitialObjects.end())
       continue;
     anObjIter = aCopiedObjects.begin();
     for (; anObjIter != aCopiedObjects.end(); anObjIter++)
-      if (aSelect->context() == *anObjIter)
+      if (aSelObject == *anObjIter)
         return false;
   }
   return true;
index bc201061f9484ad4ba82eb40ac9b131e6f63a106..9827652996ba1c2410245b2baf6ec6ecf5cb2223 100755 (executable)
@@ -27,6 +27,7 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_Tools.h>
 
 #include <Events_Loop.h>
 #include <Events_Error.h>
@@ -54,7 +55,6 @@
 #include <iostream>
 #endif
 
-//#define DEBUG_CANDISPLAY
 //#define DEBUG_FEATURE_CREATED
 //#define DEBUG_FEATURE_REDISPLAY
 
@@ -270,15 +270,14 @@ void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI
         // in order to avoid the check whether the object can be redisplayed, the exact method
         // of redisplay is called. This modification is made in order to have the line is updated
         // by creation of a horizontal constraint on the line by preselection
-        /*ResultCompSolidPtr aCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>
-                                                                                   (aObj);
-        if (aCompSolid.get() && aCompSolid->numberOfSubs() > 0) {
+        if (ModelAPI_Tools::hasSubResults(std::dynamic_pointer_cast<ModelAPI_Result>(aObj))) {
           aDisplayer->erase(aObj, false);
-        }*/
-
-        aDisplayer->redisplay(aObj, false);
-        // Deactivate object of current operation from selection
-        aWorkshop->deactivateActiveObject(aObj, false);
+        }
+        else {
+          aDisplayer->redisplay(aObj, false);
+          // Deactivate object of current operation from selection
+          aWorkshop->deactivateActiveObject(aObj, false);
+        }
       } else { // display object if the current operation has it
         if (displayObject(aObj)) {
           // Deactivate object of current operation from selection
@@ -316,15 +315,8 @@ void XGUI_WorkshopListener::onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_O
     if (!aHide) {
       // setDisplayed has to be called in order to synchronize internal state of the object 
       // with list of displayed objects
-#ifdef DEBUG_CANDISPLAY
-      if (displayObject(anObject)/*myWorkshop->module()->canDisplayObject(anObject)*/) {
-        anObject->setDisplayed(true);
-        //isDisplayed = displayObject(anObject);
-#else
-      if (myWorkshop->module()->canDisplayObject(anObject)) {
+      if (displayObject(anObject)) {
         anObject->setDisplayed(true);
-        isDisplayed = displayObject(anObject);
-#endif
       } else 
         anObject->setDisplayed(false);
     }
@@ -436,8 +428,9 @@ void XGUI_WorkshopListener::addFeature(const std::shared_ptr<Config_FeatureMessa
 //**************************************************************
 bool XGUI_WorkshopListener::displayObject(ObjectPtr theObj)
 {
-   XGUI_Workshop* aWorkshop = workshop();
-  if (!aWorkshop->module()->canDisplayObject(theObj))
+  XGUI_Workshop* aWorkshop = workshop();
+  if (ModelAPI_Tools::hasSubResults(std::dynamic_pointer_cast<ModelAPI_Result>(theObj)) ||
+      !aWorkshop->module()->canDisplayObject(theObj))
     return false;
 
   XGUI_Displayer* aDisplayer = aWorkshop->displayer();