Salome HOME
Merge remote-tracking branch 'remotes/origin/Dev_ResultNames'
authorazv <azv@opencascade.com>
Sun, 19 Nov 2017 08:51:30 +0000 (11:51 +0300)
committerazv <azv@opencascade.com>
Sun, 19 Nov 2017 08:51:30 +0000 (11:51 +0300)
14 files changed:
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_PreviewSketchPlane.cpp
src/PartSet/PartSet_PreviewSketchPlane.h
src/PartSet/PartSet_WidgetSketchCreator.cpp
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_Projection.cpp
src/SketchPlugin/Test/Test2287.py [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_Angle.cpp
src/SketcherPrs/SketcherPrs_PositionMgr.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_SelectionMgr.cpp
src/XGUI/XGUI_Workshop.cpp

index 3f3c23bd529f361936a65df367ce3d94088b8c1c..57d9fc6b7556b3eb5eacd53e29ab1f6f85d77c06 100755 (executable)
 #include <XGUI_SelectionMgr.h>
 #include <XGUI_ActionsMgr.h>
 
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
 #include <SketchPlugin_ConstraintAngle.h>
 #include <SketchPlugin_ConstraintLength.h>
 #include <SketchPlugin_ConstraintDistance.h>
 #include <SketchPlugin_ConstraintParallel.h>
 #include <SketchPlugin_ConstraintPerpendicular.h>
 #include <SketchPlugin_ConstraintRadius.h>
+#include <SketchPlugin_Feature.h>
+#include <SketchPlugin_Projection.h>
+#include <SketchPlugin_Sketch.h>
 
 #include <SketcherPrs_SymbolPrs.h>
 #include <SketcherPrs_Coincident.h>
@@ -934,15 +935,21 @@ void PartSet_Module::onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS)
 {
   Handle(AIS_InteractiveObject) anAIS = theAIS->impl<Handle(AIS_InteractiveObject)>();
   if (!anAIS.IsNull()) {
+    bool aToUseZLayer = false;
+    FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+    if (aFeature.get() && PartSet_Tools::findRefsToMeFeature(aFeature,
+                                                        SketchPlugin_Projection::ID()))
+      aToUseZLayer = true;
     Handle(AIS_InteractiveContext) aCtx = anAIS->GetContext();
     Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(anAIS);
     if (!aDim.IsNull()) {
-      aCtx->SetZLayer(aDim, myVisualLayerId);
+      aToUseZLayer = true;
     } else {
       Handle(SketcherPrs_SymbolPrs) aCons = Handle(SketcherPrs_SymbolPrs)::DownCast(anAIS);
       if (!aCons.IsNull())
-        aCtx->SetZLayer(aCons, myVisualLayerId);
+      aToUseZLayer = true;
     }
+    aCtx->SetZLayer(anAIS, myVisualLayerId);
   }
 }
 
index 6de85edc74977390ffd94ea3f4230979c65ea3b8..f0f614bb0f4ec9d7dccc2037b878fa7b1f784433 100644 (file)
@@ -41,7 +41,7 @@
 #include <SketchPlugin_SketchEntity.h>
 
 PartSet_PreviewSketchPlane::PartSet_PreviewSketchPlane()
- : myPreviewIsDisplayed(false)
+ : myPreviewIsDisplayed(false), mySizeOfView(0), myIsUseSizeOfView(false)
 {
 }
 
@@ -75,17 +75,23 @@ void PartSet_PreviewSketchPlane::createSketchPlane(const CompositeFeaturePtr& th
     // selected linear face parameters
     AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
       (theSketch->data()->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
-    if (aSelAttr)
+    if (aSelAttr) {
       myShape = aSelAttr->value();
-
+      // this case is needed by constructing sketch on a plane, where result shape is equal
+      // to context result, therefore value() returns NULL and we should use shape of context.
+      if (!myShape.get() && aSelAttr->context().get())
+        myShape = aSelAttr->context()->shape();
+    }
     if (!myShape.get()) {
       // Create Preview for default planes
       std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
           theSketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
       std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
           theSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
-      myShape = GeomAlgoAPI_FaceBuilder::squareFace(anOrigin->pnt(), aNormal->dir(),
-        Config_PropManager::integer(SKETCH_TAB_NAME, "planes_size"));
+
+      double aFaceSize = myIsUseSizeOfView ? mySizeOfView
+        : Config_PropManager::integer(SKETCH_TAB_NAME, "planes_size");
+      myShape = GeomAlgoAPI_FaceBuilder::squareFace(anOrigin->pnt(), aNormal->dir(), aFaceSize);
     }
     myPlane = createPreviewPlane();
   }
@@ -95,6 +101,12 @@ void PartSet_PreviewSketchPlane::createSketchPlane(const CompositeFeaturePtr& th
   myPreviewIsDisplayed = true;
 }
 
+void PartSet_PreviewSketchPlane::setSizeOfView(double theSizeOfView, bool isUseSizeOfView)
+{
+  mySizeOfView = theSizeOfView;
+  myIsUseSizeOfView = isUseSizeOfView;
+}
+
 AISObjectPtr PartSet_PreviewSketchPlane::createPreviewPlane()
 {
   if (myPlane.get()) {
index 11eabebd69e25b4f1cc49d5615e386120a56ad4e..b797b2dd4fbc04c13c2460aa40c8e80f31105c71 100644 (file)
@@ -53,6 +53,15 @@ public:
   void createSketchPlane(const std::shared_ptr<ModelAPI_CompositeFeature>& theSketch,
                          ModuleBase_IWorkshop* theWorkshop);
 
+  /// Returns whether custom size of view is set
+  /// \return boolean value
+  bool isUseSizeOfView() const { return myIsUseSizeOfView; }
+
+  /// Sets the size of default created face
+  /// \param theSizeOfView value
+  /// \param isUseSizeOfView state whether the size should be used
+  void setSizeOfView(double theSizeOfView, bool isUseSizeOfView);
+
 private:
   /// Create a square face by parameters
   std::shared_ptr<GeomAPI_AISObject> createPreviewPlane();
@@ -61,6 +70,9 @@ private:
   bool myPreviewIsDisplayed;
   std::shared_ptr<GeomAPI_AISObject> myPlane; //! visualized presentation
   std::shared_ptr<GeomAPI_Shape> myShape; //! current shape to be displayed
+
+  double mySizeOfView; //! size that should be used by creating a default face
+  bool myIsUseSizeOfView; //! state if the size is custom or from preferences
 };
 
 #endif
\ No newline at end of file
index a1bd76150cb8264ed0ab1597a6a0ef2aef8833f0..f31198234f3d9be6d5d423019c3021f3522d811f 100644 (file)
@@ -195,6 +195,10 @@ bool PartSet_WidgetSketchCreator::isValidSelectionCustom(const ModuleBase_Viewer
 
 void PartSet_WidgetSketchCreator::activateSelectionControl()
 {
+  // reset previously set size of view needed on restart extrusion after Sketch
+  if (myModule->sketchMgr()->previewSketchPlane()->isUseSizeOfView())
+    myModule->sketchMgr()->previewSketchPlane()->setSizeOfView(0, false);
+
   // we need to call activate here as the widget has no focus accepted controls
   // if these controls are added here, activate will happens automatically after focusIn()
   XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
@@ -359,20 +363,18 @@ bool PartSet_WidgetSketchCreator::startSketchOperation(
   // Set View size if a plane is selected
   if (myPreviewPlanes->isPreviewDisplayed() &&
       myPreviewPlanes->isPreviewShape(aValue->shape())) {
+    // set default plane size
+    bool isSetSizeOfView = false;
+    double aSizeOfView = 0;
     QString aSizeOfViewStr = mySizeOfView->text();
     if (!aSizeOfViewStr.isEmpty()) {
-      bool isOk;
-      double aSizeOfView = aSizeOfViewStr.toDouble(&isOk);
-      if (isOk && aSizeOfView > 0) {
-        Handle(V3d_View) aView3d = myWorkshop->viewer()->activeView();
-        if (!aView3d.IsNull()) {
-          Bnd_Box aBndBox;
-          double aHalfSize = aSizeOfView/2.0;
-          aBndBox.Update(-aHalfSize, -aHalfSize, -aHalfSize, aHalfSize, aHalfSize, aHalfSize);
-          aView3d->FitAll(aBndBox, 0.01, false);
-        }
+      aSizeOfView = aSizeOfViewStr.toDouble(&isSetSizeOfView);
+      if (isSetSizeOfView && aSizeOfView <= 0) {
+        isSetSizeOfView = false;
       }
     }
+    if (isSetSizeOfView)
+      myModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, true);
   }
   // manually deactivation because the widget was not activated as has no focus acceptin controls
   deactivate();
index d3908d81e0e350937d88b90f512c7156dd2fe35d..63cd3927ee2a66112b1837dd45677cc43786346a 100644 (file)
@@ -278,7 +278,20 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs
   PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
   if (aModule) {
     CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+    bool isSetSizeOfView = false;
+    double aSizeOfView = 0;
+    QString aSizeOfViewStr = mySizeOfView->text();
+    if (!aSizeOfViewStr.isEmpty()) {
+      aSizeOfView = aSizeOfViewStr.toDouble(&isSetSizeOfView);
+      if (isSetSizeOfView && aSizeOfView <= 0) {
+        isSetSizeOfView = false;
+      }
+    }
+    if (isSetSizeOfView)
+      aModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, true);
     aModule->sketchMgr()->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop);
+    if (isSetSizeOfView)
+      aModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, false);
   }
   // 2. if the planes were displayed, change the view projection
   const GeomShapePtr& aShape = thePrs->shape();
@@ -334,20 +347,6 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs
     if (aRotate) {
       myWorkshop->viewer()->setViewProjection(aXYZ.X(), aXYZ.Y(), aXYZ.Z(), aTwist);
     }
-    QString aSizeOfViewStr = mySizeOfView->text();
-    if (!aSizeOfViewStr.isEmpty()) {
-      bool isOk;
-      double aSizeOfView = aSizeOfViewStr.toDouble(&isOk);
-      if (isOk && aSizeOfView > 0) {
-        Handle(V3d_View) aView3d = myWorkshop->viewer()->activeView();
-        if (!aView3d.IsNull()) {
-          Bnd_Box aBndBox;
-          double aHalfSize = aSizeOfView/2.0;
-          aBndBox.Update(-aHalfSize, -aHalfSize, -aHalfSize, aHalfSize, aHalfSize, aHalfSize);
-          aView3d->FitAll(aBndBox, 0.01, false);
-        }
-      }
-    }
     PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
     if (aModule)
       aModule->onViewTransformed();
index e7ec8b7c75dd03891b82e56f0ad4bde4e7c85cba..30bf99ae12333c80636975b6bf4cd366752653e4 100644 (file)
@@ -225,6 +225,7 @@ ADD_UNIT_TESTS(TestSketchPointLine.py
                TestSignedDistancePointLine.py
                Test2273.py
                Test2280.py
+               Test2287.py
 )
 
 if(${SKETCHER_CHANGE_RADIUS_WHEN_MOVE})
index fb6815a16192451324a9171601093ae40ca45898..3d783a40850a9c902b5b2db01cfe41b1d25dfc27 100644 (file)
@@ -259,7 +259,8 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID)
     if (aResult) {
       aResult->setShape(aProjection->lastResult()->shape());
       setResult(aResult);
-      aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape());
+      GeomShapePtr anEmptyVal;
+      aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), anEmptyVal);
     }
   }
 }
diff --git a/src/SketchPlugin/Test/Test2287.py b/src/SketchPlugin/Test/Test2287.py
new file mode 100644 (file)
index 0000000..1049f7d
--- /dev/null
@@ -0,0 +1,40 @@
+## Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+## See http:##www.salome-platform.org/ or
+## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
+SketchLine_1 = Sketch_1.addLine(-20, -62, 81, 60)
+model.do()
+Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
+SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), True)
+SketchLine_2 = SketchProjection_1.createdFeature()
+model.do()
+Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchProjection_1")])
+model.end()
+
+# before bug fix it was "Sketch_2"
+assert(Edge_1.baseObjects().value(0).namingName() == "Sketch_2/Edge-SketchProjection_1")
+
+assert(model.checkPythonDump())
index 9521f1db16133c227038ec3b31774bb5de21e722..d1735600bd935f063824ce95a6954cb9cce69d59 100644 (file)
@@ -243,7 +243,13 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP
     (myConstraint->data()->attribute(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID()));
   SketcherPrs_Tools::LocationType aLocationType = aLocAttr->isInitialized() ?
     (SketcherPrs_Tools::LocationType)(aLocAttr->value()) : SketcherPrs_Tools::LOCATION_AUTOMATIC;
-  updateArrows(myAspect, GetValue(), aTextSize, aLocationType);
+
+  double aRadius = myCenterPoint.Translated(
+    gp_Vec(myCenterPoint, myFirstPoint).Normalized()*aDist).Distance(myCenterPoint);
+  double anAngleValue = myValue.myDoubleValue;
+  double anAngleCircleLength = aRadius * anAngleValue * PI / 180.;
+
+  updateArrows(myAspect, anAngleCircleLength, aTextSize, aLocationType);
 
   AIS_AngleDimension::Compute(thePresentationManager, thePresentation, theMode);
 
index 31921298ba0424bf4a61a7eedc4fcded4f967873..21b6dacb1e0996ecf4cf0df9df4a860ebeaca6a5 100644 (file)
@@ -37,9 +37,9 @@
 #include <SketchPlugin_ConstraintTangent.h>
 #include <SketchPlugin_ConstraintPerpendicular.h>
 
-#include <BRepExtrema_ExtPC.hxx>
 #include <TopoDS_Vertex.hxx>
 #include <Geom_Curve.hxx>
+#include <GeomAPI_ProjectPointOnCurve.hxx>
 #include <TColGeom_SequenceOfCurve.hxx>
 #include <gp_Dir.hxx>
 
@@ -202,22 +202,11 @@ gp_Vec getVector(ObjectPtr theShape, GeomDirPtr theDir, gp_Pnt theP)
       std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(aShape));
 
     if (aCurve->isCircle()) {
-      GeomEdgePtr aEdgePtr(new GeomAPI_Edge(aShape));
-      GeomVertexPtr aVertexPtr(new GeomAPI_Vertex(theP.X(), theP.Y(), theP.Z()));
-      BRepExtrema_ExtPC aExtrema(aVertexPtr->impl<TopoDS_Vertex>(),
-                                 aEdgePtr->impl<TopoDS_Edge>());
-      int aNb = aExtrema.NbExt();
-      if (aNb > 0) {
-        for (int i = 1; i <= aNb; i++) {
-          if (aExtrema.IsMin(i)) {
-            double aParam = aExtrema.Parameter(i);
-            Handle(Geom_Curve) aCurv = aCurve->impl<Handle_Geom_Curve>();
-            gp_Pnt aP;
-            aCurv->D1(aParam, aP, aVec);
-            break;
-          }
-        }
-      }
+      Handle(Geom_Curve) aCurv = aCurve->impl<Handle_Geom_Curve>();
+      GeomAPI_ProjectPointOnCurve anExtr(theP, aCurv);
+      double aParam = anExtr.LowerDistanceParameter();
+      gp_Pnt aP;
+      aCurv->D1(aParam, aP, aVec);
     } else {
       GeomPointPtr aPnt1 = aCurve->getPoint(aCurve->endParam());
       GeomPointPtr aPnt2 = aCurve->getPoint(aCurve->startParam());
index eb2b6bbc7dd0c82ed90391fe41cce9ffff6d72da..9612452007b84038bfce8bec51f01a0824c51f4f 100644 (file)
@@ -74,7 +74,7 @@
 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
 
 #ifdef TINSPECTOR
-#include <VInspectorAPI_CallBack.hxx>
+#include <inspector/VInspectorAPI_CallBack.hxx>
 #endif
 
 #include <Events_Loop.h>
index ad655723d54f603c55fcd010b18861dbacce117d..cfdf139121f21e2ab9ed886f06c8b7790819d12a 100644 (file)
@@ -59,7 +59,7 @@ public:
   /// \param theParent the parent to be deleted when the parent is deleted
   /// \param theOperationMgr the class to perform deletion
   XGUI_ShortCutListener(QObject* theParent, XGUI_OperationMgr* theOperationMgr)
-    : QObject(theParent), myOperationMgr(theOperationMgr)
+    : QObject(theParent), myOperationMgr(theOperationMgr), myIsActive(false)
   {
     qApp->installEventFilter(this);
   }
index f91a1b39106e9dcca9fa07f691d04ab18962ce09..eebb23d221e1983816e69be758bfcede126ac176 100755 (executable)
@@ -46,7 +46,7 @@
 #include <SelectMgr_ListIteratorOfListOfFilter.hxx>
 
 #ifdef TINSPECTOR
-#include <VInspectorAPI_CallBack.hxx>
+#include <inspector/VInspectorAPI_CallBack.hxx>
 #endif
 
 XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent)
index 56f264361ea8e8903f10343c8b43333525e27f7f..1e7e18aba3c1fa9a8fd4c90d8bdab0dcf0f968dc 100755 (executable)
 #ifdef TINSPECTOR
 #include <CDF_Session.hxx>
 #include <CDF_Application.hxx>
-#include <TInspector_Communicator.hxx>
-#include <VInspector_CallBack.hxx>
+#include <inspector/TInspector_Communicator.hxx>
+#include <inspector/VInspector_CallBack.hxx>
 static TInspector_Communicator* MyTCommunicator;
 static Handle(VInspector_CallBack) MyVCallBack;