]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 16 Apr 2015 14:45:37 +0000 (17:45 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 16 Apr 2015 14:45:37 +0000 (17:45 +0300)
src/Model/Model_AttributeSelection.cpp
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_Tools.h
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/ModuleBase/ModuleBase_WidgetShapeSelector.h

index fb7c6925daa15c508242fc971bcea89eb97950dc..3b82ea108368786a4972bb1198d89670e01101be 100644 (file)
@@ -402,28 +402,29 @@ void Model_AttributeSelection::selectBody(
 {
   // perform the selection
   TNaming_Selector aSel(selectionLabel());
-  TopoDS_Shape aNewShape = theSubShape ? theSubShape->impl<TopoDS_Shape>() : TopoDS_Shape();
   TopoDS_Shape aContext;
 
   ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(myRef.value());
   if (aBody) {
     aContext = aBody->shape()->impl<TopoDS_Shape>();
   } else {
-    ResultConstructionPtr aConstr = 
-      std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(myRef.value());
-    if (aConstr) {
-      aContext = aConstr->shape()->impl<TopoDS_Shape>();
+    ResultPtr aResult = 
+      std::dynamic_pointer_cast<ModelAPI_Result>(myRef.value());
+    if (aResult) {
+      aContext = aResult->shape()->impl<TopoDS_Shape>();
     } else {
       Events_Error::send("A result with shape is expected");
       return;
     }
   }
+  TopoDS_Shape aNewShape = theSubShape ? theSubShape->impl<TopoDS_Shape>() : aContext;
   /// fix for issue 411: result modified shapes must not participate in this selection mechanism
   FeaturePtr aFeatureOwner = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
   if (aFeatureOwner.get())
     aFeatureOwner->eraseResults();
-
-  aSel.Select(aNewShape, aContext); 
+  if (!aContext.IsNull()) {
+    aSel.Select(aNewShape, aContext); 
+  }
 }
 
 /// registers the name of the shape in the label (theID == 0) of sub label (theID is a tag)
index 03569839c1ad20b8b7af4eaf437791ac6acebd1c..1d87b4ae22475427772f15b6eefe99eb075f9f67 100644 (file)
@@ -12,6 +12,7 @@
 #include <ModelAPI_AttributeRefAttr.h>
 
 #include <GeomDataAPI_Point2D.h>
+#include <Events_Error.h>
 
 #include <QWidget>
 #include <QLayout>
@@ -154,6 +155,31 @@ QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo)
   return aFeatureStr;
 }
 
+typedef QMap<QString, TopAbs_ShapeEnum> ShapeTypes;
+static ShapeTypes MyShapeTypes;
+
+TopAbs_ShapeEnum shapeType(const QString& theType)
+{
+  if (MyShapeTypes.count() == 0) {
+    MyShapeTypes["face"] = TopAbs_FACE;
+    MyShapeTypes["faces"] = TopAbs_FACE;
+    MyShapeTypes["vertex"] = TopAbs_VERTEX;
+    MyShapeTypes["vertices"] = TopAbs_VERTEX;
+    MyShapeTypes["wire"] = TopAbs_WIRE;
+    MyShapeTypes["edge"] = TopAbs_EDGE;
+    MyShapeTypes["edges"] = TopAbs_EDGE;
+    MyShapeTypes["shell"] = TopAbs_SHELL;
+    MyShapeTypes["solid"] = TopAbs_SOLID;
+    MyShapeTypes["solids"] = TopAbs_SOLID;
+  }
+  QString aType = theType.toLower();
+  if (MyShapeTypes.contains(aType))
+    return MyShapeTypes[aType];
+  Events_Error::send("Shape type defined in XML is not implemented!");
+  return TopAbs_SHAPE;
+}
+
+
 }
 
 
index 3c9006d9a65a1f376da3de9e824be1a9538e164f..75c6b95fead59ea4ca584d3f93051389952b1304 100644 (file)
@@ -10,6 +10,7 @@
 #include "ModuleBase.h"
 
 #include <ModelAPI_Feature.h>
+#include <TopAbs_ShapeEnum.hxx>
 
 #include <QPixmap>
 
@@ -65,6 +66,11 @@ MODULEBASE_EXPORT void setSpinValue(QDoubleSpinBox* theSpin, double theValue);
 /// \return a string
 MODULEBASE_EXPORT QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo = false);
 
+/// Converts string value (name of shape type) to shape enum value
+/// \param theType - string with shape type name
+/// \return TopAbs_ShapeEnum value
+MODULEBASE_EXPORT TopAbs_ShapeEnum shapeType(const QString& theType);
+
 }
 
 #endif
index c74b323b83b6f038769f71032f5418ff79a0c24e..57e2ce9492683be78fd14faa38f6fece0beee4ba 100644 (file)
@@ -131,7 +131,7 @@ bool ModuleBase_WidgetMultiSelector::storeValueCustom() const
   if (aSelectionListAttr) {
     // Store shapes type
      TopAbs_ShapeEnum aCurrentType =
-           ModuleBase_WidgetShapeSelector::shapeType(myTypeCombo->currentText());
+           ModuleBase_Tools::shapeType(myTypeCombo->currentText());
      aSelectionListAttr->setSelectionType(myTypeCombo->currentText().toStdString());
   }   
    return true;
@@ -149,8 +149,7 @@ bool ModuleBase_WidgetMultiSelector::restoreValue()
 
   if (aSelectionListAttr) {
     // Restore shape type
-    setCurrentShapeType(
-         ModuleBase_WidgetShapeSelector::shapeType(aSelectionListAttr->selectionType().c_str()));
+    setCurrentShapeType(ModuleBase_Tools::shapeType(aSelectionListAttr->selectionType().c_str()));
     updateSelectionList(aSelectionListAttr);
     return true;
   }
@@ -198,6 +197,12 @@ void ModuleBase_WidgetMultiSelector::restoreAttributeValue(bool/* theValid*/)
 //********************************************************************
 bool ModuleBase_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());
@@ -235,7 +240,7 @@ bool ModuleBase_WidgetMultiSelector::setSelectionCustom(const ModuleBase_ViewerP
     aSelectionListAttr->append(aResult, GeomShapePtr());
   }
   else {
-    GeomShapePtr aShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
+    GeomShapePtr aShape(new GeomAPI_Shape());
     aShape->setImpl(new TopoDS_Shape(aTDSShape));
     // We can not select a result of our feature
     if (aShape->isEqual(aResult->shape()))
@@ -303,7 +308,7 @@ void ModuleBase_WidgetMultiSelector::setCurrentShapeType(const TopAbs_ShapeEnum
   
   for (int idx = 0; idx < myTypeCombo->count(); ++idx) {
     aShapeTypeName = myTypeCombo->itemText(idx);
-    TopAbs_ShapeEnum aRefType = ModuleBase_WidgetShapeSelector::shapeType(aShapeTypeName);
+    TopAbs_ShapeEnum aRefType = ModuleBase_Tools::shapeType(aShapeTypeName);
     if(aRefType == theShapeType && idx != myTypeCombo->currentIndex()) {
       myIsActive = false;
       activateShapeSelection();
@@ -324,7 +329,7 @@ void ModuleBase_WidgetMultiSelector::activateShapeSelection()
   if (myIsActive) {
     QString aNewType = myTypeCombo->currentText();
     QIntList aList;
-    aList.append(ModuleBase_WidgetShapeSelector::shapeType(aNewType));
+    aList.append(ModuleBase_Tools::shapeType(aNewType));
     myWorkshop->activateSubShapesSelection(aList);
   } else {
     myWorkshop->deactivateSubShapesSelection();
index a88479bc5e845eeb14b88d52b7efc8d7ed8e939f..1f5d011ea30eb0e16e7dbba808ceb87ef0c6e862 100644 (file)
 #include <list>
 #include <string>
 
-typedef QMap<QString, TopAbs_ShapeEnum> ShapeTypes;
-static ShapeTypes MyShapeTypes;
-
-TopAbs_ShapeEnum ModuleBase_WidgetShapeSelector::shapeType(const QString& theType)
-{
-  if (MyShapeTypes.count() == 0) {
-    MyShapeTypes["face"] = TopAbs_FACE;
-    MyShapeTypes["faces"] = TopAbs_FACE;
-    MyShapeTypes["vertex"] = TopAbs_VERTEX;
-    MyShapeTypes["vertices"] = TopAbs_VERTEX;
-    MyShapeTypes["wire"] = TopAbs_WIRE;
-    MyShapeTypes["edge"] = TopAbs_EDGE;
-    MyShapeTypes["edges"] = TopAbs_EDGE;
-    MyShapeTypes["shell"] = TopAbs_SHELL;
-    MyShapeTypes["solid"] = TopAbs_SOLID;
-    MyShapeTypes["solids"] = TopAbs_SOLID;
-  }
-  QString aType = theType.toLower();
-  if (MyShapeTypes.contains(aType))
-    return MyShapeTypes[aType];
-  Events_Error::send("Shape type defined in XML is not implemented!");
-  return TopAbs_SHAPE;
-}
 
 ModuleBase_WidgetShapeSelector::ModuleBase_WidgetShapeSelector(QWidget* theParent,
                                                      ModuleBase_IWorkshop* theWorkshop,
@@ -269,7 +246,7 @@ bool ModuleBase_WidgetShapeSelector::acceptSubShape(std::shared_ptr<GeomAPI_Shap
 {
   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
   foreach (QString aType, myShapeTypes) {
-    if (aShape.ShapeType() == shapeType(aType))
+    if (aShape.ShapeType() == ModuleBase_Tools::shapeType(aType))
       return true;
   }
   return false;
@@ -338,7 +315,7 @@ void ModuleBase_WidgetShapeSelector::activateSelection(bool toActivate)
   if (myIsActive) {
     QIntList aList;
     foreach (QString aType, myShapeTypes) {
-      aList.append(shapeType(aType));
+      aList.append(ModuleBase_Tools::shapeType(aType));
     }
     myWorkshop->activateSubShapesSelection(aList);
   } else {
index 8890912dae42a59db05507b8953b4ded9ab54856..bf0fb6800d39f5d4b5029b6b29d53ee6aba28c6e 100644 (file)
@@ -58,11 +58,6 @@ class MODULEBASE_EXPORT ModuleBase_WidgetShapeSelector : public ModuleBase_Widge
 Q_OBJECT
  public:
 
-   /// Converts string value (name of shape type) to shape enum value
-   /// \param theType - string with shape type name
-   /// \return TopAbs_ShapeEnum value
-  static TopAbs_ShapeEnum shapeType(const QString& theType);
-
   /// Constructor
   /// \param theParent the parent object
   /// \param theWorkshop instance of workshop interface