]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom.git into Dev_1.1.0
authorsbh <sergey.belash@opencascade.com>
Fri, 17 Apr 2015 12:01:19 +0000 (15:01 +0300)
committersbh <sergey.belash@opencascade.com>
Fri, 17 Apr 2015 12:01:19 +0000 (15:01 +0300)
24 files changed:
src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py
src/Model/Model_Application.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.h
src/PartSet/PartSet_ExternalObjectsMgr.cpp
src/PartSet/PartSet_ExternalObjectsMgr.h
src/PartSet/PartSet_WidgetMultiSelector.cpp
src/PartSet/PartSet_WidgetMultiSelector.h
src/PythonAddons/macros/box/widget.xml
src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp
src/SketchPlugin/plugin-Sketch.xml
src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp
src/SketchSolver/SketchSolver_ConstraintCoincidence.h
src/SketchSolver/SketchSolver_ConstraintMirror.cpp
src/SketchSolver/SketchSolver_Group.cpp
src/SketchSolver/SketchSolver_Storage.cpp
src/SketchSolver/SketchSolver_Storage.h
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_PartDataModel.cpp
src/XGUI/XGUI_Tools.cpp
src/XGUI/XGUI_Tools.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_pictures.qrc
src/XGUI/pictures/box_ico.png [new file with mode: 0644]
src/XGUI/pictures/part_ico.png

index 26ab3ca9fd49099ae27ac15dd0198b381852be41..9241308435320ab15b5bc4f3b83fd8f7431371cb 100644 (file)
@@ -84,9 +84,11 @@ class ExportFeature(ModelAPI.ModelAPI_Feature):
         for anIndex in range(0, aFeaturesNum):
             aFeature = self.Part.object("Features", anIndex)
             aSelectionList = aFeature.data().selectionList("group_list")
-            aName = aFeature.data().name()
             # if a group has been found
             if aSelectionList:
+                aFeature = ModelAPI.objectToFeature(aFeature)
+                if aFeature.firstResult() is not None:
+                  aName = aFeature.firstResult().data().name()
                 groupIndex = groupIndex + 1
                 self.createGroupFromList(aSelectionList, aName)
                      
index a825e747104b6482f68a0b14a7bbbbcc4b13d182..212fd4c9cab1ec924a6fe9fd14d2ced24b7a74ec 100644 (file)
@@ -61,6 +61,10 @@ void Model_Application::deleteDocument(string theDocID)
 
 void Model_Application::deleteAllDocuments()
 {
+  std::map<std::string, std::shared_ptr<Model_Document> >::iterator aDoc = myDocs.begin();
+  for(; aDoc != myDocs.end(); aDoc++) {
+    aDoc->second->close();
+  }
   myDocs.clear();
   myLoadedByDemand.clear();
 }
index 5f2bf3498abd470eb50efc4edb46858e94c5b3b6..cc702f6a129f0da3763c4e498e26bb4c6e84eeab 100644 (file)
@@ -81,7 +81,7 @@ class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_Widge
   void onSelectionTypeChanged();
 
   /// Slot is called on selection changed
-  void onSelectionChanged();
+  virtual void onSelectionChanged();
 
 protected slots:
   /// Slot for copy command in a list pop-up menu
@@ -115,7 +115,7 @@ protected slots:
   /// Start shape selection
   void activateShapeSelection();
 
- private:
+ protected:
    /// Update selection list
    void updateSelectionList(AttributeSelectionListPtr);
 
index 2ba5b86688e4d2373476f4977238243678234862..b12f92b5f05e11978614f49697962480d3637b15 100644 (file)
@@ -37,6 +37,24 @@ ObjectPtr PartSet_ExternalObjectsMgr::externalObject(const ObjectPtr& theSelecte
   return aSelectedObject;
 }
 
+//********************************************************************
+ObjectPtr PartSet_ExternalObjectsMgr::externalObjectValidated(const ObjectPtr& theSelectedObject,
+                                                     const GeomShapePtr& theShape,
+                                                     const CompositeFeaturePtr& theSketch)
+{
+  // TODO(nds): unite with externalObject()
+  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())
+      myExternalObjectValidated = aSelectedObject;
+  }
+  return aSelectedObject;
+}
+
 //********************************************************************
 void PartSet_ExternalObjectsMgr::removeExternal(const CompositeFeaturePtr& theSketch,
                                                 const FeaturePtr& theFeature)
@@ -61,6 +79,61 @@ void PartSet_ExternalObjectsMgr::removeExternal(const CompositeFeaturePtr& theSk
         XGUI_Workshop::deleteFeatures(anObjects, anIgnoredFeatures);
       }
     }
+    //removeExternalObject(anObject, theSketch, theFeature);
   }
   myExternalObjects.clear();
 }
+
+//********************************************************************
+void PartSet_ExternalObjectsMgr::removeUnusedExternalObjects(const QObjectPtrList& theIgnoreObjects,
+                                                             const CompositeFeaturePtr& theSketch,
+                                                             const FeaturePtr& theFeature)
+{
+  /*
+  // TODO(nds): unite with removeExternal(), remove parameters
+  QObjectPtrList aUsedExternalObjects;
+
+  QObjectPtrList::const_iterator anIt = myExternalObjects.begin(), aLast = myExternalObjects.end();
+  for (; anIt != aLast; anIt++) {
+    ObjectPtr anObject = *anIt;
+    if (theIgnoreObjects.contains(anObject))
+      aUsedExternalObjects.append(anObject);
+    else
+      removeExternalObject(anObject, theSketch, theFeature);
+  }*/
+  myExternalObjects.clear();
+  //if (!aUsedExternalObjects.empty())
+  //  myExternalObjects = aUsedExternalObjects;
+}
+
+//********************************************************************
+void PartSet_ExternalObjectsMgr::removeExternalValidated(const CompositeFeaturePtr& theSketch,
+                                                         const FeaturePtr& theFeature)
+{
+  // TODO(nds): unite with removeExternal(), remove parameters
+  removeExternalObject(myExternalObjectValidated, theSketch, theFeature);
+  myExternalObjectValidated = NULL;
+}
+
+void PartSet_ExternalObjectsMgr::removeExternalObject(const ObjectPtr& theObject,
+                                                      const CompositeFeaturePtr& theSketch,
+                                                      const FeaturePtr& theFeature)
+{
+  if (theObject.get()) {
+    DocumentPtr aDoc = theObject->document();
+    FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+    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;
+      anIgnoredFeatures.insert(theSketch);
+      // 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);
+      XGUI_Workshop::deleteFeatures(anObjects, anIgnoredFeatures);
+    }
+  }
+}
index 6451751dee3dda3e01d0e659f079de9f3583d918..45f89a84c90eaab6b444b03a124948ab44c498a5 100644 (file)
@@ -44,16 +44,35 @@ class PARTSET_EXPORT PartSet_ExternalObjectsMgr
   ObjectPtr externalObject(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
   void removeExternal(const CompositeFeaturePtr& theSketch,
                       const FeaturePtr& theFeature);
 
+  void removeExternalValidated(const CompositeFeaturePtr& theSketch,
+                               const FeaturePtr& theFeature);
+
+  void removeUnusedExternalObjects(const QObjectPtrList& theIgnoreObjects,
+                            const CompositeFeaturePtr& theSketch,
+                            const FeaturePtr& theFeature);
+
+protected:
+  void removeExternalObject(const ObjectPtr& theObject,
+                            const CompositeFeaturePtr& theSketch,
+                            const FeaturePtr& theFeature);
+
 protected:
   /// An external object
   QObjectPtrList myExternalObjects;
 
+  /// An external object
+  ObjectPtr myExternalObjectValidated;
+
   /// Boolean value about the neccessity of the external object use
   bool myUseExternal;
 };
index c59c6919e7de0754a3d78e5a2d77e8d7e1320ba4..43f066ea2337b8e935f502013489d968d4328e9f 100644 (file)
 #include <ModelAPI_Validator.h>
 
 #include <ModuleBase_Definitions.h>
+#include <ModuleBase_Tools.h>
+#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_ISelection.h>
+
 #include <Config_WidgetAPI.h>
 
 #include <PartSet_Tools.h>
 
 #include <XGUI_Workshop.h>
 
+#include <QComboBox>
+
 PartSet_WidgetMultiSelector::PartSet_WidgetMultiSelector(QWidget* theParent,
                                                          ModuleBase_IWorkshop* theWorkshop,
                                                          const Config_WidgetAPI* theData,
                                                          const std::string& theParentId)
-: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId)
+: ModuleBase_WidgetMultiSelector(theParent, theWorkshop, theData, theParentId)
 {
   myExternalObjectMgr = new PartSet_ExternalObjectsMgr(theData->getProperty("use_external"), false);
 }
@@ -35,9 +41,135 @@ PartSet_WidgetMultiSelector::~PartSet_WidgetMultiSelector()
   delete myExternalObjectMgr;
 }
 
+//********************************************************************
+void PartSet_WidgetMultiSelector::onSelectionChanged()
+{
+  ModuleBase_WidgetMultiSelector::onSelectionChanged();
+  // 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());
+  }
+
+  myExternalObjectMgr->removeUnusedExternalObjects(aListOfAttributeObjects, sketch(), myFeature);
+}
+
+//********************************************************************
+void PartSet_WidgetMultiSelector::storeAttributeValue()
+{
+  myIsInVaildate = true;
+  ModuleBase_WidgetMultiSelector::storeAttributeValue();
+
+}
+
 //********************************************************************
 void PartSet_WidgetMultiSelector::restoreAttributeValue(const bool theValid)
 {
-  ModuleBase_WidgetShapeSelector::restoreAttributeValue(theValid);
-  myExternalObjectMgr->removeExternal(sketch(), myFeature);
+  myIsInVaildate = false;
+  ModuleBase_WidgetMultiSelector::restoreAttributeValue(theValid);
+
+  myExternalObjectMgr->removeExternalValidated(sketch(), myFeature);
+}
+
+//********************************************************************
+bool PartSet_WidgetMultiSelector::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
+{
+  TopoDS_Shape aShape = thePrs.shape();
+  if ((myTypeCombo->count() > 1) && (!aShape.IsNull())) {
+    TopAbs_ShapeEnum aType = ModuleBase_Tools::shapeType(myTypeCombo->currentText());
+    if (aShape.ShapeType() != aType)
+      return false;
+  }
+  ResultPtr aResult;
+  if (!thePrs.owner().IsNull()) {
+    ObjectPtr anObject = myWorkshop->selection()->getSelectableObject(thePrs.owner());
+    aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
+  }
+  else {
+    aResult = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs.object());
+  }
+
+
+  if (myFeature) {
+    // We can not select a result of our feature
+    const std::list<ResultPtr>& aResList = myFeature->results();
+    std::list<ResultPtr>::const_iterator aIt;
+    bool isSkipSelf = false;
+    for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) {
+      if ((*aIt) == aResult) {
+        isSkipSelf = true;
+        break;
+      }
+    }
+    if(isSkipSelf)
+      return false;
+  }
+
+  GeomShapePtr aGShape = GeomShapePtr();
+  const TopoDS_Shape& aTDSShape = thePrs.shape();
+  // if only result is selected, an empty shape is set to the model
+  if (aTDSShape.IsNull()) {
+    //aSelectionListAttr->append(aResult, GeomShapePtr());
+  }
+  else {
+    aGShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
+    //GeomShapePtr aShape(new GeomAPI_Shape());
+    aGShape->setImpl(new TopoDS_Shape(aTDSShape));
+    // We can not select a result of our feature
+    if (aGShape->isEqual(aResult->shape())) {
+      //aSelectionListAttr->append(aResult, GeomShapePtr());
+      aGShape = GeomShapePtr();
+    }
+    else {
+      //aSelectionListAttr->append(aResult, aShape);
+    }
+  }
+
+  setObject(aResult, aGShape);
+  return true;
+}
+
+//********************************************************************
+bool PartSet_WidgetMultiSelector::setObject(const ObjectPtr& theSelectedObject,
+                                            const GeomShapePtr& theShape)
+{
+  ObjectPtr aSelectedObject = theSelectedObject;
+  GeomShapePtr aShape = theShape;
+
+  FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(aSelectedObject);
+  //if (aSelectedFeature == myFeature)  // In order to avoid selection of the same object
+  //  return false;
+
+  // Do check using of external feature
+  std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
+          std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
+
+  // Do check that we can use external feature
+  if ((aSPFeature.get() != NULL) && aSPFeature->isExternal() && (!myExternalObjectMgr->useExternal()))
+    return false;
+
+  if (aSPFeature.get() == NULL && aShape.get() != NULL && !aShape->isNull() && myExternalObjectMgr->useExternal()) {
+    if (myIsInVaildate)
+      aSelectedObject = myExternalObjectMgr->externalObjectValidated(theSelectedObject, theShape, sketch());
+    else
+      aSelectedObject = myExternalObjectMgr->externalObject(theSelectedObject, theShape, sketch());
+  }
+
+
+  ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aSelectedObject);
+
+  DataPtr aData = myFeature->data();
+  AttributeSelectionListPtr aSelectionListAttr = 
+    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
+
+  aSelectionListAttr->append(aResult, aShape);
+
+  return true;
 }
index db5d4085957e64d7632dbefe7da55b039690d247..ba7ffea5497942228d1df1a2d90b3fffd4f4a5c0 100644 (file)
@@ -10,7 +10,8 @@
 
 #include "PartSet.h"
 
-#include <ModuleBase_WidgetShapeSelector.h>
+#include <ModuleBase_WidgetMultiSelector.h>
+#include <ModuleBase_ViewerPrs.h>
 
 #include <ModelAPI_CompositeFeature.h>
 
@@ -18,10 +19,10 @@ class PartSet_ExternalObjectsMgr;
 
 /**
 * \ingroup Modules
-* Customosation of ModuleBase_WidgetShapeSelector in order to provide 
-* working with sketch specific objects.
+* Customosation of ModuleBase_WidgetMultiSelector in order to provide 
+* working with sketch specific objects and creation of external objects.
 */
-class PARTSET_EXPORT PartSet_WidgetMultiSelector: public ModuleBase_WidgetShapeSelector
+class PARTSET_EXPORT PartSet_WidgetMultiSelector: public ModuleBase_WidgetMultiSelector
 {
 Q_OBJECT
  public:
@@ -42,17 +43,39 @@ Q_OBJECT
   /// Retrurns installed sketcher
   CompositeFeaturePtr sketch() const { return mySketch; }
 
+  /// Fills the attribute with the value of the selected owner
+  /// \param theOwner a selected owner
+  virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
+
+public slots:
+  /// Slot is called on selection changed
+  virtual void onSelectionChanged();
+
 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();
+
   /// 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
   void restoreAttributeValue(const bool theValid);
 
+  /// Store the values to the model attribute of the widget. It casts this attribute to
+  /// the specific type and set the given values
+  /// \param theSelectedObject an object
+  /// \param theShape a selected shape, which is used in the selection attribute
+  /// \return true if it is succeed
+  bool setObject(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape);
+
 protected:
   PartSet_ExternalObjectsMgr* myExternalObjectMgr;
   /// Pointer to a sketch 
   CompositeFeaturePtr mySketch;
+
+  bool myIsInVaildate;
 };
 
 #endif
\ No newline at end of file
index 508c85d2e5caaff8bbd57b772a43c2c804339205..9ef95858daf21d1d13d55cd4219011dfc960150b 100644 (file)
@@ -2,7 +2,7 @@
   <workbench id="Macros" document="Part">
     <group id="Samples">
 
-      <feature id="Box" title="Box" tooltip="Create a box parallel to xyz by extruding a rectangular" icon=":pictures/part_ico.png">
+      <feature id="Box" title="Box" tooltip="Create a box parallel to xyz by extruding a rectangular" icon=":pictures/box_ico.png">
         <doublevalue id="width"  label="dx: " min="0" step="1.0" default="50" tooltip="Sets the box width">
           <validator id="GeomValidators_Positive"/>
         </doublevalue>
index f28a09516757ff59a05cbe8966e34693cfeb4fd4..d3ba226f6205b57c555ca4f8d7c084c484d100fe 100644 (file)
@@ -43,8 +43,6 @@ void SketchPlugin_ConstraintMirror::execute()
 {
   AttributeSelectionListPtr aMirrorObjectRefs =
       selectionList(SketchPlugin_ConstraintMirror::MIRROR_LIST_ID());
-  if (!aMirrorObjectRefs->isInitialized())
-    return;
 
   std::shared_ptr<ModelAPI_Data> aData = data();
   AttributeRefListPtr aRefListOfShapes = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
index 0e828bbeef99be4c91be56bad3c1da37a10f2768..87f4cf32482a9f7df50a48bb90fe7c743f5aa536 100644 (file)
             label="Mirror line" tooltip="Select mirror line" shape_types="edge">
             <validator id="GeomValidators_Edge" parameters="line"/>
         </sketch_shape_selector>
-        <multi_selector id="ConstraintMirrorList"
+        <sketch_multi_selector id="ConstraintMirrorList"
             label="List of objects"
             tooltip="Select list of mirroring objects"
-            type_choice="Edges">
+            type_choice="Edges"
+            use_external="true">
             <validator id="SketchPlugin_MirrorAttr" />
-        </multi_selector>
+        </sketch_multi_selector>
       </feature>
     </group>
   </workbench>
index bfa65c19ec3f50ccf8afdd0621f378d76f86df67..721913b19af45323648de8f7d0c9246a2ac000d2 100644 (file)
@@ -68,10 +68,16 @@ void SketchSolver_ConstraintCoincidence::attach(
 Slvs_hConstraint SketchSolver_ConstraintCoincidence::addConstraint(
     Slvs_hEntity thePoint1, Slvs_hEntity thePoint2)
 {
+  bool hasDuplicated = myStorage->hasDuplicatedConstraint();
   Slvs_Constraint aNewConstraint = Slvs_MakeConstraint(SLVS_E_UNKNOWN, myGroup->getId(),
       SLVS_C_POINTS_COINCIDENT, myGroup->getWorkplaneId(), 0.0, thePoint1, thePoint2, 
       SLVS_E_UNKNOWN, SLVS_E_UNKNOWN);
   Slvs_hConstraint aNewID = myStorage->addConstraint(aNewConstraint);
+  if (!hasDuplicated && myStorage->hasDuplicatedConstraint()) {
+    // the duplicated constraint appears
+    myStorage->removeConstraint(aNewID);
+    return SLVS_E_UNKNOWN;
+  }
   mySlvsConstraints.push_back(aNewID);
   return aNewID;
 }
@@ -103,6 +109,22 @@ void SketchSolver_ConstraintCoincidence::addConstraint(ConstraintPtr theConstrai
   myExtraCoincidence[aNewConstr] = theConstraint;
 }
 
+void SketchSolver_ConstraintCoincidence::process()
+{
+  SketchSolver_Constraint::process();
+
+  // Fill the list of coincident points
+  std::list<AttributePtr> anAttrList =
+      myBaseConstraint->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
+  std::list<AttributePtr>::iterator anIt = anAttrList.begin();
+  for (; anIt != anAttrList.end(); anIt++) {
+    AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anIt);
+    if (!aRefAttr || aRefAttr->isObject())
+      continue;
+    myCoincidentPoints.insert(aRefAttr->attr());
+  }
+}
+
 bool SketchSolver_ConstraintCoincidence::remove(ConstraintPtr theConstraint)
 {
   cleanErrorMsg();
index e8cbb8e402759896ac983a6bc8221e20ceef874c..a5c885ade5863fccdce77842f18904c6acb5ff5a 100644 (file)
@@ -41,6 +41,10 @@ public:
   /// \brief Append all data of coincidence constaint to the current
   void attach(std::shared_ptr<SketchSolver_ConstraintCoincidence> theConstraint);
 
+protected:
+  /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
+  virtual void process();
+
 private:
   /// \brief Creates new coincidence constraint
   Slvs_hConstraint addConstraint(Slvs_hEntity thePoint1, Slvs_hEntity thePoint2);
index c27000bd14eb292ddee8239d80eaa601f68cd092..6bb2a9088823a1e1a46cd23f5fa3301dcf5ad140 100644 (file)
@@ -189,6 +189,8 @@ void SketchSolver_ConstraintMirror::process()
 
   // Set the mirror line unchanged during constraint recalculation
   for (int i = 0; i < 2; i++) {
+    if (myStorage->isPointFixed(aMirrorLine.point[i], aConstraint.h, true))
+      continue;
     aConstraint = Slvs_MakeConstraint(
         SLVS_E_UNKNOWN, myGroup->getId(), SLVS_C_WHERE_DRAGGED, myGroup->getWorkplaneId(), 0.0,
         aMirrorLine.point[i], SLVS_E_UNKNOWN, SLVS_E_UNKNOWN, SLVS_E_UNKNOWN);
index e630978ecc48952bde87291222a7b16f1104b44a..8a5267be2c6fb42a56f027737ec2fe34e580f743 100644 (file)
@@ -419,7 +419,7 @@ bool SketchSolver_Group::resolveConstraints()
           aResult = myConstrSolver.solve();
           if (aResult == SLVS_RESULT_OKAY || aNbTemp <= 0)
             break;
-          aNbTemp = myStorage->removeFirstTemporaryConstraint();
+          aNbTemp = myStorage->deleteTemporaryConstraint();
           myStorage->initializeSolver(myConstrSolver);
         }
       }
index 250ce7e564e1fb49ae4c8f463727631a0da19c27..63b22bf4cb4bf2360ae85b0afb4a213d0436c164 100644 (file)
@@ -546,12 +546,37 @@ void SketchSolver_Storage::removeTemporaryConstraints()
   myTemporaryConstraints.clear();
 }
 
-int SketchSolver_Storage::removeFirstTemporaryConstraint()
+int SketchSolver_Storage::deleteTemporaryConstraint()
 {
   if (myTemporaryConstraints.empty())
     return 0;
-  removeConstraint(*myTemporaryConstraints.begin());
-  myTemporaryConstraints.erase(myTemporaryConstraints.begin());
+  // Search the point-on-line or a non-rigid constraint
+  std::set<Slvs_hConstraint>::iterator aCIt = myTemporaryConstraints.begin();
+  for (; aCIt != myTemporaryConstraints.end(); aCIt++) {
+    int aPos = Search(*aCIt, myConstraints);
+    if (myConstraints[aPos].type != SLVS_C_WHERE_DRAGGED)
+      break;
+    std::vector<Slvs_Constraint>::iterator anIt = myConstraints.begin();
+    for (; anIt != myConstraints.end(); anIt++)
+      if (anIt->type == SLVS_C_PT_ON_LINE && anIt->ptA == myConstraints[aPos].ptA)
+        break;
+    if (anIt != myConstraints.end())
+      break;
+  }
+  if (aCIt == myTemporaryConstraints.end())
+    aCIt = myTemporaryConstraints.begin();
+  bool aNewFixed = (*aCIt == myFixed);
+  removeConstraint(*aCIt);
+  myTemporaryConstraints.erase(aCIt);
+  if (aNewFixed) {
+    for (aCIt = myTemporaryConstraints.begin(); aCIt != myTemporaryConstraints.end(); aCIt++) {
+      int aPos = Search(*aCIt, myConstraints);
+      if (myConstraints[aPos].type == SLVS_C_WHERE_DRAGGED) {
+        myFixed = *aCIt;
+        break;
+      }
+    }
+  }
   return (int)myTemporaryConstraints.size();
 }
 
index fc2e46ceba6963d96d58325fa7d780bcad72a184..669f2c0eacc12fd31ef1491d0ef558ed982b3c33 100644 (file)
@@ -108,15 +108,15 @@ public:
   void addTemporaryConstraint(const Slvs_hConstraint& theConstraintID);
   /// \brief Remove all transient constraints
   void removeTemporaryConstraints();
-  /// \brief Remove first temporary constraint
+  /// \brief Remove one temporary constraint. Preferable to remove the points under Point-on-Line constraint
   /// \return Number of remaining temporary constraints
-  int removeFirstTemporaryConstraint();
+  int deleteTemporaryConstraint();
   /// \brief Checks the constraint is temporary
   bool isTemporary(const Slvs_hConstraint& theConstraintID) const;
 
   /// \brief Shows the sketch should be resolved
   bool isNeedToResolve() const
-  { return myNeedToResolve; }
+  { return myNeedToResolve && !myConstraints.empty(); }
 
   /// \brief Shows the storage has the same constraint twice
   bool hasDuplicatedConstraint() const
index 80fdfad7f07ece1ba1b23243e578fdf41ad8d9e6..494ecf28d011cf8dcf54d04dae64ac496ebd843e 100644 (file)
@@ -8,6 +8,7 @@
 #include "XGUI_ViewerProxy.h"
 #include "XGUI_Selection.h"
 #include "XGUI_SalomeConnector.h"
+#include "XGUI_Tools.h"
 
 #include <AppElements_MainWindow.h>
 
@@ -154,18 +155,8 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const
     bool hasResult = false;
     bool hasFeature = false;
     bool hasParameter = false;
-    foreach(ObjectPtr aObj, aObjects)
-    {
-      FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
-      ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
-      ResultParameterPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aResult);
-
-      hasResult = (aResult.get() != NULL);
-      hasFeature = (aFeature.get() != NULL);
-      hasParameter = (aConstruction.get() != NULL);
-      if (hasFeature && hasResult  && hasParameter)
-        break;
-    }
+    XGUI_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter);
+
     //Process Feature
     if (aSelected == 1) {
       ObjectPtr aObject = aObjects.first();
index 5ab5798468bb0bd2c999ddb1bc255a94e696fcf7..bbf0ef9fcc1afa8f45ece496083184ab2d82692b 100644 (file)
@@ -53,7 +53,7 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const
             AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE());
             QString aVal = QString::number(aValueAttribute->value());
             QString aTitle = QString(aObject->data()->name().c_str());
-            return aTitle + "=" + aVal;
+            return aTitle + " = " + aVal;
           }
         }
           break;
@@ -285,7 +285,7 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons
             AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE());
             QString aVal = QString::number(aValueAttribute->value());
             QString aTitle = QString(aObject->data()->name().c_str());
-            return aTitle + "=" + aVal;
+            return aTitle + " = " + aVal;
           }
         }
           break;
index 26672cd89bc4cdf295c2152632fe497bdb6c8048..4ffac6dc7ba28294cd40733b3bcc26344f92004d 100644 (file)
@@ -4,6 +4,9 @@
 
 #include <TopoDS_Shape.hxx>
 #include <ModelAPI_Object.h>
+#include <ModelAPI_Result.h>
+#include <ModelAPI_ResultParameter.h>
+#include <ModelAPI_Feature.h>
 #include <GeomAPI_Shape.h>
 
 #include <QDir>
@@ -71,4 +74,24 @@ std::string featureInfo(FeaturePtr theFeature)
  }
  }*/
 
+
+void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature, bool& hasParameter)
+{
+  hasResult = false;
+  hasFeature = false;
+  hasParameter = false;
+  foreach(ObjectPtr aObj, theObjects) {
+    FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
+    ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+    ResultParameterPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aResult);
+
+    hasResult = (aResult.get() != NULL);
+    hasFeature = (aFeature.get() != NULL);
+    hasParameter = (aConstruction.get() != NULL);
+    if (hasFeature && hasResult  && hasParameter)
+      break;
+  }
+}
+
+
 }
index 7db64558ac26448911c1dd19bbbf343af1116f1f..e541ba2f0418e8fcef741ece0fd46eb62e0433f8 100644 (file)
@@ -8,6 +8,7 @@
 #include <QRect>
 
 #include <ModelAPI_Feature.h>
+#include <ModuleBase_Definitions.h>
 
 #include <memory>
 
@@ -63,6 +64,17 @@ bool XGUI_EXPORT isModelObject(FeaturePtr theFeature);
  \param theFeature a feature
  */
 std::string XGUI_EXPORT featureInfo(FeaturePtr theFeature);
-}
+
+
+/*!
+Check types of objects which are in the given list
+\param theObjects the list of objects
+\param hasResult will be set to true if list contains Result objects
+\param hasFeature will be set to true if list contains Feature objects
+\param hasParameter will be set to true if list contains Parameter objects
+*/
+void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature, bool& hasParameter);
+
+};
 
 #endif
index a824d664c740f1bcba914d2fdfb60a939b215dc8..42aa97e3000859a3b259ef7c55413428a5ca42b6 100644 (file)
@@ -1391,6 +1391,13 @@ void XGUI_Workshop::deleteObjects()
   if (!isActiveOperationAborted())
     return;
   QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
+  bool hasResult = false;
+  bool hasFeature = false;
+  bool hasParameter = false;
+  XGUI_Tools::checkObjects(anObjects, hasResult, hasFeature, hasParameter);
+  if (!(hasFeature || hasParameter))
+    return;
+
   // 1. start operation
   QString aDescription = contextMenuMgr()->action("DELETE_CMD")->text();
   aDescription += tr(" %1");
index 022b1c356d5683aa876bb84a5907b51c09a2452c..085837a9202a09c47140df20fd6b85a2fdc5cc19 100644 (file)
@@ -15,6 +15,7 @@
      <file>pictures/constr_object.png</file>
      <file>pictures/constr_object_modified.png</file>
      <file>pictures/part_ico.png</file>
+     <file>pictures/box_ico.png</file>
      <file>pictures/properties.png</file>
      <file>pictures/features.png</file>
      <file>pictures/point_ico.png</file>
diff --git a/src/XGUI/pictures/box_ico.png b/src/XGUI/pictures/box_ico.png
new file mode 100644 (file)
index 0000000..16b4973
Binary files /dev/null and b/src/XGUI/pictures/box_ico.png differ
index 16b49734bbf98d2ae9252da77c353c450873df16..dbbd30cfbf4230d0db3d402f01fd63d3fb766923 100644 (file)
Binary files a/src/XGUI/pictures/part_ico.png and b/src/XGUI/pictures/part_ico.png differ