]> 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 08:27:28 +0000 (11:27 +0300)
committermpv <mpv@opencascade.com>
Mon, 13 Apr 2015 08:27:28 +0000 (11:27 +0300)
src/GeomValidators/GeomValidators_Face.cpp
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/XGUI/XGUI_Workshop.cpp

index 821b45cb0755d58d8e11b839b9167a4817beb3d1..0fe74f8082fc6cb2981294994b035494232ce2f7 100644 (file)
@@ -46,16 +46,21 @@ bool GeomValidators_Face::isValid(const AttributePtr& theAttribute,
     AttributeSelectionPtr aSelectionAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
                                                                  (theAttribute);
     std::shared_ptr<GeomAPI_Shape> aGeomShape = aSelectionAttr->value();
-    std::shared_ptr<GeomAPI_Face> aGeomFace(new GeomAPI_Face(aGeomShape));
-    if (aGeomFace.get() != NULL) {
-      switch(aFaceType) {
-          case GeomAbs_Plane:
-            aValid = aGeomFace->isPlanar();
-            break;
-          case GeomAbs_Cylinder:
-            break;
-          default:
-            break;
+    // it is necessary to check whether the shape is face in order to set in selection a value
+    // with any type and check the type in this validator
+    // It is realized to select any object in OB and filter it in this validator (sketch plane)
+    if (aGeomShape->isFace()) {
+      std::shared_ptr<GeomAPI_Face> aGeomFace(new GeomAPI_Face(aGeomShape));
+      if (aGeomFace.get() != NULL) {
+        switch(aFaceType) {
+            case GeomAbs_Plane:
+              aValid = aGeomFace->isPlanar();
+              break;
+            case GeomAbs_Cylinder:
+              break;
+            default:
+              break;
+        }
       }
     }
   }
index 42d4cd3edecc0d737ba7f675269b026f89cea5c1..6760949400bf9c47906b827752426f307d9bd62b 100644 (file)
@@ -113,50 +113,54 @@ void PartSet_WidgetSketchLabel::onSelectionChanged()
   if (aPrs.isEmpty())
     return;
 
-  if (isValidSelection(aPrs)) {
-    // 2. set the selection to sketch
-    setSelectionCustom(aPrs);
-    // 3. hide main planes if they have been displayed
-    erasePreviewPlanes();
-    // 4. if the planes were displayed, change the view projection
-    TopoDS_Shape aShape = aPrs.shape();
-    if (!aShape.IsNull()) {
-      DataPtr aData = feature()->data();
-      AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
-                                (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
-      if (aSelAttr) {
-        GeomShapePtr aShapePtr = aSelAttr->value();
-        if (aShapePtr.get() == NULL || aShapePtr->isNull()) {
-          //TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
-          std::shared_ptr<GeomAPI_Shape> aGShape(new GeomAPI_Shape);
-          aGShape->setImpl(new TopoDS_Shape(aShape));
-          // get plane parameters
-          std::shared_ptr<GeomAPI_Pln> aPlane = GeomAlgoAPI_FaceBuilder::plane(aGShape);
-          std::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
-
-          myWorkshop->viewer()->setViewProjection(aDir->x(), aDir->y(), aDir->z());
-        }
-      }
+  if (!isValidSelection(aPrs))
+    return;
+
+  // 2. set the selection to sketch
+  setSelectionCustom(aPrs);
+  // 3. hide main planes if they have been displayed
+  erasePreviewPlanes();
+  // 4. if the planes were displayed, change the view projection
+  TopoDS_Shape aShape = aPrs.shape();
+  std::shared_ptr<GeomAPI_Shape> aGShape;
+  // selection happens in OCC viewer
+  if (!aShape.IsNull()) {
+    aGShape =  std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape);
+    aGShape->setImpl(new TopoDS_Shape(aShape));
+  }
+  else { // selection happens in OCC viewer(on body) of in the OB browser
+    DataPtr aData = feature()->data();
+    AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
+                              (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
+    if (aSelAttr) {
+      aGShape = aSelAttr->value();
     }
-    // 5. Clear text in the label
-    myLabel->setText("");
-    myLabel->setToolTip("");
-    disconnect(myWorkshop->selector(), SIGNAL(selectionChanged()), 
-               this, SLOT(onSelectionChanged()));
-    // 6. deactivate face selection filter
-    activateFilters(myWorkshop->module()->workshop(), false);
-
-    // 7. Clear selection mode and define sketching mode
-    //XGUI_Displayer* aDisp = myWorkshop->displayer();
-    //aDisp->closeLocalContexts();
-    emit planeSelected(plane());
-    //setSketchingMode();
+  }
+  if (aGShape.get() != NULL) {
+    // get plane parameters
+    std::shared_ptr<GeomAPI_Pln> aPlane = GeomAlgoAPI_FaceBuilder::plane(aGShape);
+    std::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
 
-    // 8. Update sketcher actions
-    XGUI_ActionsMgr* anActMgr = myWorkshop->actionsMgr();
-    anActMgr->update();
-    myWorkshop->viewer()->update();
+    myWorkshop->viewer()->setViewProjection(aDir->x(), aDir->y(), aDir->z());
   }
+  // 5. Clear text in the label
+  myLabel->setText("");
+  myLabel->setToolTip("");
+  disconnect(myWorkshop->selector(), SIGNAL(selectionChanged()), 
+              this, SLOT(onSelectionChanged()));
+  // 6. deactivate face selection filter
+  activateFilters(myWorkshop->module()->workshop(), false);
+
+  // 7. Clear selection mode and define sketching mode
+  //XGUI_Displayer* aDisp = myWorkshop->displayer();
+  //aDisp->closeLocalContexts();
+  emit planeSelected(plane());
+  //setSketchingMode();
+
+  // 8. Update sketcher actions
+  XGUI_ActionsMgr* anActMgr = myWorkshop->actionsMgr();
+  anActMgr->update();
+  myWorkshop->viewer()->update();
 }
 
 std::shared_ptr<GeomAPI_Pln> PartSet_WidgetSketchLabel::plane() const
@@ -210,14 +214,16 @@ bool PartSet_WidgetSketchLabel::setSelectionCustom(const ModuleBase_ViewerPrs& t
       ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs.object());
       if (aRes) {
         GeomShapePtr aShapePtr(new GeomAPI_Shape());
-        if (aShape.IsNull()) {
+        if (aShape.IsNull()) {  // selection happens in the OCC viewer
           aShapePtr = ModelAPI_Tools::shape(aRes);
         }
-        else {
+        else { // selection happens in OB browser
           aShapePtr->setImpl(new TopoDS_Shape(aShape));
         }
-        aSelAttr->setValue(aRes, aShapePtr);
-        isOwnerSet = true;
+        if (aShapePtr.get() != NULL) {
+          aSelAttr->setValue(aRes, aShapePtr);
+          isOwnerSet = true;
+        }
       }
     }
   }
index 08d66b704b7a38d7572d071074ce7897b7511dc2..985f1f307e6b9ac67f19547c9f8fa9b35720b053 100644 (file)
@@ -93,8 +93,8 @@
 #include <dlfcn.h>
 #endif
 
-#define DEBUG_FEATURE_CREATED
-#define DEBUG_FEATURE_REDISPLAY
+//#define DEBUG_FEATURE_CREATED
+//#define DEBUG_FEATURE_REDISPLAY
 
 QMap<QString, QString> XGUI_Workshop::myIcons;