]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
authormpv <mpv@opencascade.com>
Mon, 13 Apr 2015 13:30:15 +0000 (16:30 +0300)
committermpv <mpv@opencascade.com>
Mon, 13 Apr 2015 13:30:15 +0000 (16:30 +0300)
src/ConstructionPlugin/plane_widget.xml
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/ModuleBase/ModuleBase_WidgetSwitch.cpp
src/PartSet/PartSet_MenuMgr.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h
src/SketchPlugin/plugin-Sketch.xml

index 4300f5f6f2538f51c5796168ba46dd8cea26f874..938850f418b74be477fe8970a14e27139a4e8041 100644 (file)
                    tooltip="Distance from selected face to plane" 
                default="0" />
     </case>
-    <case id="PlaneByGeneralEquation" title="By palne equation parameters">
-      <doublevalue id="A" 
-                   label="A:" 
-                   tooltip="The A parameter from general plane equation (Ax+By+Cz+D=0)" 
-                   default="0" />
-      <doublevalue id="B" 
-                   label="B:" 
-                   tooltip="The B parameter from general plane equation (Ax+By+Cz+D=0)" 
-                   default="0" />
-      <doublevalue id="C" 
-                   label="C:" 
-                   tooltip="The C parameter from general plane equation (Ax+By+Cz+D=0)" 
-                   default="0" />
-      <doublevalue id="D" 
-                   label="D:" 
-                   tooltip="The D parameter from general plane equation (Ax+By+Cz+D=0)" 
-                   default="0" />
-    </case>
   </switch>
 </source>
index 20f5224844cb33ea30be3c603640086a5fcd8071..a17ea26c9793ee4a8c3acab86dc7f5df40b0646b 100644 (file)
@@ -104,8 +104,12 @@ void ModuleBase_WidgetDoubleValue::reset()
   else {
     bool isOk;
     double aDefValue = QString::fromStdString(getDefaultValue()).toDouble(&isOk);
-    ModuleBase_Tools::setSpinValue(mySpinBox, isOk ? aDefValue : 0.0);
-    storeValueCustom();
+    // reset the value just if there is a default value definition in the XML definition
+    // if the double value can not be found by the default value, do nothing
+    if (isOk) {
+      ModuleBase_Tools::setSpinValue(mySpinBox, isOk ? aDefValue : 0.0);
+      storeValueCustom();
+    }
   }
 }
 
@@ -114,7 +118,7 @@ bool ModuleBase_WidgetDoubleValue::storeValueCustom() const
   DataPtr aData = myFeature->data();
   AttributeDoublePtr aReal = aData->real(attributeID());
   aReal->setValue(mySpinBox->value());
-  std::string aTextRepr;
+  std::string aTextRepr = aReal->text();
   if (mySpinBox->hasVariable()) {
     aTextRepr = mySpinBox->text().toStdString();
   }
index d1b383dd2459ec13d09d989578a9dfd0a03c5460..4d3d50d2b8b1bbb80f7d18d8e94a189a1d858cd1 100644 (file)
@@ -198,8 +198,15 @@ void ModuleBase_WidgetMultiSelector::restoreAttributeValue(bool/* theValid*/)
 //********************************************************************
 bool ModuleBase_WidgetMultiSelector::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
 {
-  ObjectPtr anObject = myWorkshop->selection()->getSelectableObject(thePrs.owner());
-  ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
+  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
@@ -230,7 +237,11 @@ bool ModuleBase_WidgetMultiSelector::setSelectionCustom(const ModuleBase_ViewerP
   else {
     GeomShapePtr aShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
     aShape->setImpl(new TopoDS_Shape(aTDSShape));
-    aSelectionListAttr->append(aResult, aShape);
+    // We can not select a result of our feature
+    if (aShape->isEqual(aResult->shape()))
+      aSelectionListAttr->append(aResult, GeomShapePtr());
+    else
+      aSelectionListAttr->append(aResult, aShape);
   }
   return true;
 }
index de8e013d4a19080fb16ec6cd12f285550f978020..a88479bc5e845eeb14b88d52b7efc8d7ed8e939f 100644 (file)
@@ -158,9 +158,9 @@ bool ModuleBase_WidgetShapeSelector::setObject(ObjectPtr theSelectedObject,
       }
     } else {
       AttributeSelectionPtr aSelectAttr = aData->selection(attributeID());
-      ResultPtr aBody = std::dynamic_pointer_cast<ModelAPI_Result>(theSelectedObject);
-      if (aSelectAttr && aBody && (theShape.get() != NULL)) {
-        aSelectAttr->setValue(aBody, theShape);
+      ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theSelectedObject);
+      if (aSelectAttr) {
+        aSelectAttr->setValue(aResult, theShape);
         isChanged = true;
       }
     }
index 8cd931574f11f63c76ce57bfc12a96b68f64d3f2..31deb0e986bdc96d06893fa2c4cca5908456ac79 100644 (file)
@@ -47,7 +47,7 @@ int ModuleBase_WidgetSwitch::addPage(ModuleBase_PageBase* thePage, const QString
   int aSuperCount = ModuleBase_PagedContainer::addPage(thePage, theName, theCaseId);
   myCombo->addItem(theName);
   int aResultCount = myCombo->count();
-  if (aResultCount == 1)
+  if (aResultCount == 2)
     myCombo->show();
   QFrame* aFrame = dynamic_cast<QFrame*>(thePage);
   aFrame->setFrameShape(QFrame::Box);
index da3bd6836d178dcea9b56c3b47c995b7254ff2c8..fa44262816150bdec9a85d277a80f584874b9d3e 100644 (file)
@@ -154,6 +154,28 @@ bool PartSet_MenuMgr::addViewerItems(QMenu* theMenu, const QMap<QString, QAction
   aSelection->selectedShapes(aShapeList, aObjectsList);
   bool aIsDetach = false;
 
+  // Check that selected shape is not attribute
+  // if at least a one shape is attribute then we can not add auxiliary item
+  bool hasAttribute = false;
+  if (aShapeList.Extent() > 0) {
+    NCollection_List<TopoDS_Shape>::Iterator aIt(aShapeList);
+    std::list<ObjectPtr>::const_iterator aItObj;
+    TopoDS_Shape aShape;
+    ObjectPtr aObj;
+    ResultPtr aResult;
+    for (aItObj = aObjectsList.cbegin(); aIt.More(); aIt.Next(), aItObj++) {
+      aShape = aIt.Value(); 
+      aObj = (*aItObj);
+      aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+      if (aResult.get() != NULL) {
+        if (!aShape.IsEqual(aResult->shape()->impl<TopoDS_Shape>())) {
+          hasAttribute = true;
+          break;
+        }
+      }
+    }
+  }
+
   if (aShapeList.Extent() == 1) {
     TopoDS_Shape aShape = aShapeList.First();
     if (aShape.ShapeType() == TopAbs_VERTEX) {
@@ -204,21 +226,21 @@ bool PartSet_MenuMgr::addViewerItems(QMenu* theMenu, const QMap<QString, QAction
       }
     }
   }
-  if ((!aIsDetach) && (aObjectsList.size() > 0)) {
+  QObjectPtrList aObjects = aSelection->selectedPresentations();
+  if ((!aIsDetach) && (aObjects.size() > 0)) {
     bool hasFeature = false;
     FeaturePtr aFeature;
-    std::list<ObjectPtr>::const_iterator aIt;
-    ObjectPtr aObject;
-    for (aIt = aObjectsList.cbegin(); aIt != aObjectsList.cend(); ++aIt) {
-      aObject = (*aIt);
+    foreach (ObjectPtr aObject, aObjects) {
       aFeature = ModelAPI_Feature::feature(aObject);
       if (aFeature.get() != NULL) {
         hasFeature = true;
       }
     }
-    if (hasFeature)
+    if (hasFeature && (!hasAttribute))
         theMenu->addAction(theStdActions["DELETE_CMD"]);
   }
+  if (hasAttribute)
+    return true;
   bool isAuxiliary;
   if (canSetAuxiliary(isAuxiliary)) {
     QAction* anAction = action("AUXILIARY_CMD");
@@ -330,7 +352,7 @@ void PartSet_MenuMgr::setAuxiliary(const bool isChecked)
   bool isUseTransaction = false;
   // 1. change auxiliary type of a created feature
   if (PartSet_SketcherMgr::isNestedCreateOperation(anOperation) &&
-      PartSet_SketcherMgr::isEntityOperation(anOperation) ) {
+    PartSet_SketcherMgr::isEntity(anOperation->id().toStdString()) ) {
     anObjects.append(anOperation->feature());
   }
   else {
@@ -387,7 +409,7 @@ bool PartSet_MenuMgr::canSetAuxiliary(bool& theValue) const
   QObjectPtrList anObjects;
   // 1. change auxiliary type of a created feature
   if (PartSet_SketcherMgr::isNestedCreateOperation(anOperation) &&
-      PartSet_SketcherMgr::isEntityOperation(anOperation) ) {
+    PartSet_SketcherMgr::isEntity(anOperation->id().toStdString()) ) {
     anObjects.append(anOperation->feature());
   }
   else {
@@ -399,14 +421,14 @@ bool PartSet_MenuMgr::canSetAuxiliary(bool& theValue) const
     ModuleBase_ISelection* aSelection = myModule->workshop()->selection();
     anObjects = aSelection->selectedPresentations();
   }
-  anEnabled = anObjects.size() > 0;
 
   bool isNotAuxiliaryFound = false;
   if (anObjects.size() > 0) {
     QObjectPtrList::const_iterator anIt = anObjects.begin(), aLast = anObjects.end();
     for (; anIt != aLast && !isNotAuxiliaryFound; anIt++) {
       FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
-      if (aFeature.get() != NULL) {
+      if ((aFeature.get() != NULL) && PartSet_SketcherMgr::isEntity(aFeature->getKind())) {
+        anEnabled = true;
         std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
                             std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
         if (aSketchFeature.get() != NULL) {
index 207aee541f8eab4098baa9d5352f13d168db45f3..9c1c1be0b67ac861b6cc7f4c8ac02f061ede052e 100644 (file)
@@ -640,14 +640,12 @@ bool PartSet_SketcherMgr::isNestedCreateOperation(ModuleBase_Operation* theOpera
   return theOperation && !theOperation->isEditOperation() && isNestedSketchOperation(theOperation);
 }
 
-bool PartSet_SketcherMgr::isEntityOperation(ModuleBase_Operation* theOperation)
+bool PartSet_SketcherMgr::isEntity(const std::string& theId)
 {
-  std::string aId = theOperation ? theOperation->id().toStdString() : "";
-
-  return (aId == SketchPlugin_Line::ID()) ||
-         (aId == SketchPlugin_Point::ID()) ||
-         (aId == SketchPlugin_Arc::ID()) ||
-         (aId == SketchPlugin_Circle::ID());
+  return (theId == SketchPlugin_Line::ID()) ||
+         (theId == SketchPlugin_Point::ID()) ||
+         (theId == SketchPlugin_Arc::ID()) ||
+         (theId == SketchPlugin_Circle::ID());
 }
 
 bool PartSet_SketcherMgr::isDistanceOperation(ModuleBase_Operation* theOperation)
index 977c666d39d9d9b911985ea84b8d0e514797c767..ef2bf9c485fcf98a204f9d2cf4e6e11ae4715e53 100644 (file)
@@ -95,7 +95,7 @@ public:
   /// Returns whether the current operation is a sketch entity - line, point, arc or circle
   /// \param the operation
   /// \return a boolean value
-  static bool isEntityOperation(ModuleBase_Operation* theOperation);
+  static bool isEntity(const std::string& theId);
 
   /// Returns whether the current operation is a sketch distance - lenght, distance or radius
   /// \param the operation
index b42b4af66a0a9fa6d94983293f98cf3ec24c2c58..b915729f23203e0102a2f35b2c19b90278721e60 100644 (file)
       <feature id="SketchConstraintParallel" title="Parallel" tooltip="Create constraint defining two parallel lines" icon=":icons/parallel.png">
         <sketch_shape_selector id="ConstraintEntityA" 
             label="First line" tooltip="Select a line" shape_types="edge">
-            <validator id="GeomValidators_Edge" parameters="line"/>
-            <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityB"/>
+          <validator id="GeomValidators_Edge" parameters="line"/>
+          <validator id="PartSet_DifferentObjects"/>
+          <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityB"/>
         </sketch_shape_selector>
         
         <sketch_shape_selector id="ConstraintEntityB" label="Second line" tooltip="Select a line" 
             label="Second object" tooltip="Select line or arc" shape_types="edge">
         </sketch_shape_selector>
 
-        <doublevalue_editor label="Value" tooltip="Fillet radius" id="ConstraintValue" min="0">
+        <doublevalue label="Value" tooltip="Fillet radius" id="ConstraintValue" min="0">
           <validator id="GeomValidators_Positive"/>
-        </doublevalue_editor>
+        </doublevalue>
         <validator id="PartSet_FilletSelection"/>
       </feature>