]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_0.6.1' of newgeom:newgeom into Dev_0.6.1
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 30 Dec 2014 09:51:28 +0000 (12:51 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 30 Dec 2014 09:51:28 +0000 (12:51 +0300)
src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp
src/Model/Model_AttributeSelection.cpp
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/NewGeom/NewGeom_SalomeViewer.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_Tools.cpp
src/SketchPlugin/SketchPlugin_Plugin.cpp

index 2dc527d9d5462e97016396853b31144b6e9f754a..6f262f536531617248435a95f8b60710a3072650 100644 (file)
@@ -69,4 +69,4 @@ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::
   std::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
   aRes->setImpl(new TopoDS_Shape(aFaceBuilder.Face()));
   return aRes;
-}
\ No newline at end of file
+}
index cb6db8e7478f9efdb9b905ef42751a12bb28aecf..bcf8a57b3d18bcb63917524d87b95d5b727ee5de 100644 (file)
@@ -80,16 +80,19 @@ void Model_AttributeSelection::setValue(const ResultPtr& theContext,
 
   // do noth use naming if selected shape is result shape itself, but not sub-shape
   TDF_Label aSelLab = selectionLabel();
-  if (theContext->shape().get() && theContext->shape()->isEqual(theSubShape)) {
-    aSelLab.ForgetAllAttributes(true);
-    TDataStd_UAttribute::Set(aSelLab, kSIMPLE_REF_ID);
-  } else {
-    aSelLab.ForgetAttribute(kSIMPLE_REF_ID);
-    if (theContext->groupName() == ModelAPI_ResultBody::group())
+  aSelLab.ForgetAttribute(kSIMPLE_REF_ID);
+  if (theContext->groupName() == ModelAPI_ResultBody::group()) {
+    // do not select the whole shape for body:it is already must be in the data framework
+    if (theContext->shape().get() && theContext->shape()->isEqual(theSubShape)) {
+      aSelLab.ForgetAllAttributes(true);
+      TDataStd_UAttribute::Set(aSelLab, kSIMPLE_REF_ID);
+    } else {
       selectBody(theContext, theSubShape);
-    else if (theContext->groupName() == ModelAPI_ResultConstruction::group())
-      selectConstruction(theContext, theSubShape);
+    }
+  } else if (theContext->groupName() == ModelAPI_ResultConstruction::group()) {
+    selectConstruction(theContext, theSubShape);
   }
+  myIsInitialized = true;
 
   std::string aSelName = namingName();
   if(!aSelName.empty())
@@ -101,7 +104,6 @@ void Model_AttributeSelection::setValue(const ResultPtr& theContext,
   //selectSubShape("EDGE", "Extrusion_1/TopFace|Extrusion_1/LateralFace_1");
   //selectSubShape("EDGE", "Sketch_1/Edge_6");
 #endif
-  myIsInitialized = true;
   owner()->data()->sendAttributeUpdated(this);
 }
 
@@ -348,6 +350,7 @@ bool Model_AttributeSelection::update()
         }
       }
     } else { // simple construction element: the selected is that needed
+      selectConstruction(aContext, aContext->shape());
       owner()->data()->sendAttributeUpdated(this);
       return true;
     }
@@ -398,11 +401,11 @@ static void registerSubShape(TDF_Label& theMainLabel, TopoDS_Shape theShape,
   else if (theShape.ShapeType() == TopAbs_VERTEX) aName<<"Vertex";
 
   if (theRefs.IsNull()) {
-    aName<<"_"<<theID;
+    aName<<theID;
   } else { // make a compisite name from all sub-elements indexes: "1_2_3_4"
     TColStd_MapIteratorOfPackedMapOfInteger aRef(theRefs->GetMap());
     for(; aRef.More(); aRef.Next()) {
-      aName<<"_"<<aRef.Key();
+      aName<<"-"<<aRef.Key();
     }
   }
 
@@ -418,13 +421,18 @@ void Model_AttributeSelection::selectConstruction(
   FeaturePtr aContextFeature = theContext->document()->feature(theContext);
   CompositeFeaturePtr aComposite = 
     std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aContextFeature);
+  const TopoDS_Shape& aSubShape = theSubShape->impl<TopoDS_Shape>();
   if (!aComposite || aComposite->numberOfSubs() == 0) {
-    return; // saving of context is enough: result construction contains exactly the needed shape
+    // saving of context is enough: result construction contains exactly the needed shape
+    TNaming_Builder aBuilder(selectionLabel());
+    aBuilder.Generated(aSubShape);
+    aMyDoc->addNamingName(selectionLabel(), theContext->data()->name());
+    TDataStd_Name::Set(selectionLabel(), theContext->data()->name().c_str());
+    return;
   }
   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(owner()->data());
   TDF_Label aLab = myRef.myRef->Label();
   // identify the reuslts of sub-object of the composite by edges
-  const TopoDS_Shape& aSubShape = theSubShape->impl<TopoDS_Shape>();
   // save type of the selected shape in integer attribute
   TopAbs_ShapeEnum aShapeType = aSubShape.ShapeType();
   TDataStd_Integer::Set(aLab, (int)aShapeType);
index 1f5eedfe9a7a11639486087bc77cb32616532026..7b1b6db85abeb5aa0264f346a08b01d52d282bd1 100644 (file)
@@ -1130,3 +1130,23 @@ TDF_Label Model_Document::findNamingName(std::string theName)
     return TDF_Label(); // not found
   return aFind->second;
 }
+
+ResultPtr Model_Document::findByName(const std::string theName)
+{
+  NCollection_DataMap<TDF_Label, FeaturePtr>::Iterator anObjIter(myObjs);
+  for(; anObjIter.More(); anObjIter.Next()) {
+    FeaturePtr& aFeature = anObjIter.ChangeValue();
+    if (!aFeature) // may be on close
+      continue;
+    const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
+    std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
+    for (; aRIter != aResults.cend(); aRIter++) {
+      if (aRIter->get() && (*aRIter)->data() && (*aRIter)->data()->isValid() &&
+          (*aRIter)->data()->name() == theName) {
+        return *aRIter;
+      }
+    }
+  }
+  // not found
+  return ResultPtr();
+}
index 6aa9ef4e83578e0e0793e58107c887da9086960e..ad309ce94ff6a117f647ae7a88d9bbc91ea625b7 100644 (file)
@@ -140,6 +140,9 @@ class Model_Document : public ModelAPI_Document
   void addNamingName(const TDF_Label theLabel, std::string theName);
   //! Returns the label, keeper of the name  for the topological naming needs
   TDF_Label findNamingName(std::string theName);
+  //! Returns the result by name of the result (names of results must be unique, used for naming
+  //! selection by name.
+  ResultPtr findByName(const std::string theName);
 
  protected:
 
index b1810b0e9ca183777d8fc38d5af4602d5d74abfe..d83e344d46255d409815931935d172f88acd1815 100644 (file)
@@ -188,12 +188,11 @@ void NewGeom_SalomeViewer::onActivated(SUIT_ViewWindow*)
 //**********************************************
 void NewGeom_SalomeViewer::enableSelection(bool isEnabled)
 {
-  mySelector->viewer()->enableSelection(isEnabled);
-  // there is a fix for a black-colored window 
-  // the viewer rubber band is valid if the values delta is less than 1
-  // TODO: remove this row after moving to SALOME 7.5
-  //mySelector->viewer()->setInteractionStyle(isEnabled ? SUIT_ViewModel::STANDARD
-  //                                                    : SUIT_ViewModel::KEY_FREE);
+  //mySelector->viewer()->enableSelection(isEnabled);
+  // The enableSelection() in SALOME 7.5 cause of forced Viewer update(we have blinking)
+  // After this is corrected, the first row should be recommented, the last - removed
+  mySelector->viewer()->setInteractionStyle(isEnabled ? SUIT_ViewModel::STANDARD
+                                                      : SUIT_ViewModel::KEY_FREE);
 }
 
 //**********************************************
index 434d98c9086693dc70031db173af59ceacfbb016..2b0b5e121add5cc6b41947ac186b9c5bd742a334 100644 (file)
@@ -184,7 +184,6 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
 
       get2dPoint(theWnd, theEvent, myCurX, myCurY);
       myDragDone = false;
-      aWorkshop->viewer()->enableMultiselection(false);
       launchEditing();
 
     } else if (isSketchOpe && isEditing) {
@@ -194,7 +193,6 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
       myIsDragging = true;
       get2dPoint(theWnd, theEvent, myCurX, myCurY);
       myDragDone = false;
-      aWorkshop->viewer()->enableMultiselection(false);
 
       // This is necessary in order to finalize previous operation
       QApplication::processEvents();
@@ -218,7 +216,6 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse
     aWorkshop->viewer()->enableSelection(myPreviousSelectionEnabled);
     myIsDragging = false;
     if (myDragDone) {
-      aViewer->enableMultiselection(true);
       //aOp->commit();
       myFeature2AttributeMap.clear();
 
@@ -232,9 +229,6 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse
       return;
     }
   }
-  if (!aViewer->isMultiSelectionEnabled()) {
-    aViewer->enableMultiselection(true);
-  }
 }
 
 void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
@@ -277,24 +271,26 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
     // 4. the features and attributes modification(move)
     for (; anIt != aLast; anIt++) {
       FeaturePtr aFeature = anIt.key();
-      AttributePtr anAttr;
 
       AttributeList anAttributes = anIt.value();
-      if (!anAttributes.empty()) {
-        anAttr = anAttributes.first();
-      }
       // Process selection by attribute: the priority to the attribute
-      if (anAttr.get() != NULL) {
-        std::string aAttrId = anAttr->id();
-        DataPtr aData = aFeature->data();
-        if (aData.get() != NULL) {
-          std::shared_ptr<GeomDataAPI_Point2D> aPoint = 
-            std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(aAttrId));
-          if (aPoint.get() != NULL) {
-            bool isImmutable = aPoint->setImmutable(true);
-            aPoint->move(dX, dY);
-            ModelAPI_EventCreator::get()->sendUpdated(aFeature, aMoveEvent);
-            aPoint->setImmutable(isImmutable);
+      if (!anAttributes.empty()) {
+        AttributeList::const_iterator anAttIt = anAttributes.begin(), anAttLast = anAttributes.end();
+        for (; anAttIt != anAttLast; anAttIt++) {
+          AttributePtr anAttr = *anAttIt;
+          if (anAttr.get() == NULL)
+            continue;
+          std::string aAttrId = anAttr->id();
+          DataPtr aData = aFeature->data();
+          if (aData.get() != NULL) {
+            std::shared_ptr<GeomDataAPI_Point2D> aPoint = 
+              std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(aAttrId));
+            if (aPoint.get() != NULL) {
+              bool isImmutable = aPoint->setImmutable(true);
+              aPoint->move(dX, dY);
+              ModelAPI_EventCreator::get()->sendUpdated(aFeature, aMoveEvent);
+              aPoint->setImmutable(isImmutable);
+            }
           }
         }
       } else {
index dbecad94d3081513bcc2beeff6d4058356627444..0b07da7e75db47c670207a7138059a3b9048c0fe 100644 (file)
@@ -384,23 +384,25 @@ std::shared_ptr<GeomAPI_Pln> PartSet_Tools::sketchPlane(CompositeFeaturePtr theS
   std::shared_ptr<GeomAPI_Pln> aPlane;
 
   std::shared_ptr<ModelAPI_Data> aData = theSketch->data();
-  std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
-      aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
-  std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      aData->attribute(SketchPlugin_Sketch::NORM_ID()));
-  if (aNormal && anOrigin) {
-    double adX = aNormal->x();
-    double adY = aNormal->y();
-    double adZ = aNormal->z();
-
-    if ( (adX != 0) || (adY != 0) || (adZ != 0) ) { // Plane is valid
-      double aX = anOrigin->x();
-      double aY = anOrigin->y();
-      double aZ = anOrigin->z();
-      gp_Pln aPln(gp_Pnt(aX, aY, aZ), gp_Dir(adX, adY, adZ));
-      double aA, aB, aC, aD;
-      aPln.Coefficients(aA, aB, aC, aD);
-      aPlane = std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
+  if (aData) {
+    std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
+        aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+    std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+        aData->attribute(SketchPlugin_Sketch::NORM_ID()));
+    if (aNormal && anOrigin) {
+      double adX = aNormal->x();
+      double adY = aNormal->y();
+      double adZ = aNormal->z();
+
+      if ( (adX != 0) || (adY != 0) || (adZ != 0) ) { // Plane is valid
+        double aX = anOrigin->x();
+        double aY = anOrigin->y();
+        double aZ = anOrigin->z();
+        gp_Pln aPln(gp_Pnt(aX, aY, aZ), gp_Dir(adX, adY, adZ));
+        double aA, aB, aC, aD;
+        aPln.Coefficients(aA, aB, aC, aD);
+        aPlane = std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
+      }
     }
   }
   return aPlane;
index 6680aef33008ad4a073d0ed3e3e6b7eebdc207f5..452e07401f313c26d1d867ccaf2f0182f2b86f06 100644 (file)
@@ -129,21 +129,23 @@ std::shared_ptr<ModelAPI_FeatureStateMessage> SketchPlugin_Plugin
       std::dynamic_pointer_cast<SketchPlugin_Sketch>(theFeature);
   if (aSketchFeature.get()) {
     std::shared_ptr<ModelAPI_Data> aData = aSketchFeature->data();
-    std::shared_ptr<GeomDataAPI_Dir> aNormal =
-      std::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::NORM_ID()));
-    aHasSketchPlane = aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0);
-
-    aMsg->setState(SketchPlugin_Point::ID(), aHasSketchPlane);
-    aMsg->setState(SketchPlugin_Line::ID(), aHasSketchPlane);
-    aMsg->setState(SketchPlugin_Circle::ID(), aHasSketchPlane);
-    aMsg->setState(SketchPlugin_Arc::ID(), aHasSketchPlane);
-    aMsg->setState(SketchPlugin_ConstraintCoincidence::ID(), aHasSketchPlane);
-    aMsg->setState(SketchPlugin_ConstraintDistance::ID(), aHasSketchPlane);
-    aMsg->setState(SketchPlugin_ConstraintLength::ID(), aHasSketchPlane);
-    aMsg->setState(SketchPlugin_ConstraintParallel::ID(), aHasSketchPlane);
-    aMsg->setState(SketchPlugin_ConstraintPerpendicular::ID(), aHasSketchPlane);
-    aMsg->setState(SketchPlugin_ConstraintRadius::ID(), aHasSketchPlane);
-    aMsg->setState(SketchPlugin_ConstraintRigid::ID(), aHasSketchPlane);
+    if (aData) {
+      std::shared_ptr<GeomDataAPI_Dir> aNormal =
+        std::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::NORM_ID()));
+      aHasSketchPlane = aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0);
+
+      aMsg->setState(SketchPlugin_Point::ID(), aHasSketchPlane);
+      aMsg->setState(SketchPlugin_Line::ID(), aHasSketchPlane);
+      aMsg->setState(SketchPlugin_Circle::ID(), aHasSketchPlane);
+      aMsg->setState(SketchPlugin_Arc::ID(), aHasSketchPlane);
+      aMsg->setState(SketchPlugin_ConstraintCoincidence::ID(), aHasSketchPlane);
+      aMsg->setState(SketchPlugin_ConstraintDistance::ID(), aHasSketchPlane);
+      aMsg->setState(SketchPlugin_ConstraintLength::ID(), aHasSketchPlane);
+      aMsg->setState(SketchPlugin_ConstraintParallel::ID(), aHasSketchPlane);
+      aMsg->setState(SketchPlugin_ConstraintPerpendicular::ID(), aHasSketchPlane);
+      aMsg->setState(SketchPlugin_ConstraintRadius::ID(), aHasSketchPlane);
+      aMsg->setState(SketchPlugin_ConstraintRigid::ID(), aHasSketchPlane);
+    }
   }
   return aMsg;
 }