From: azv Date: Sun, 19 Nov 2017 08:51:30 +0000 (+0300) Subject: Merge remote-tracking branch 'remotes/origin/Dev_ResultNames' X-Git-Tag: V_2.10.0RC~155 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=75e77d680594278a2da06c25fb6dbbad178e9fcd;hp=189c09cdd3b47bfb5a93440f0021bc522c331d56;p=modules%2Fshaper.git Merge remote-tracking branch 'remotes/origin/Dev_ResultNames' --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 3f3c23bd5..57d9fc6b7 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -90,14 +90,15 @@ #include #include -#include -#include #include #include #include #include #include #include +#include +#include +#include #include #include @@ -934,15 +935,21 @@ void PartSet_Module::onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS) { Handle(AIS_InteractiveObject) anAIS = theAIS->impl(); 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); } } diff --git a/src/PartSet/PartSet_PreviewSketchPlane.cpp b/src/PartSet/PartSet_PreviewSketchPlane.cpp index 6de85edc7..f0f614bb0 100644 --- a/src/PartSet/PartSet_PreviewSketchPlane.cpp +++ b/src/PartSet/PartSet_PreviewSketchPlane.cpp @@ -41,7 +41,7 @@ #include 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 (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 anOrigin = std::dynamic_pointer_cast( theSketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); std::shared_ptr aNormal = std::dynamic_pointer_cast( 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()) { diff --git a/src/PartSet/PartSet_PreviewSketchPlane.h b/src/PartSet/PartSet_PreviewSketchPlane.h index 11eabebd6..b797b2dd4 100644 --- a/src/PartSet/PartSet_PreviewSketchPlane.h +++ b/src/PartSet/PartSet_PreviewSketchPlane.h @@ -53,6 +53,15 @@ public: void createSketchPlane(const std::shared_ptr& 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 createPreviewPlane(); @@ -61,6 +70,9 @@ private: bool myPreviewIsDisplayed; std::shared_ptr myPlane; //! visualized presentation std::shared_ptr 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 diff --git a/src/PartSet/PartSet_WidgetSketchCreator.cpp b/src/PartSet/PartSet_WidgetSketchCreator.cpp index a1bd76150..f31198234 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.cpp +++ b/src/PartSet/PartSet_WidgetSketchCreator.cpp @@ -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(); diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index d3908d81e..63cd3927e 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -278,7 +278,20 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs PartSet_Module* aModule = dynamic_cast(myWorkshop->module()); if (aModule) { CompositeFeaturePtr aSketch = std::dynamic_pointer_cast(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(myWorkshop->module()); if (aModule) aModule->onViewTransformed(); diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index e7ec8b7c7..30bf99ae1 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -225,6 +225,7 @@ ADD_UNIT_TESTS(TestSketchPointLine.py TestSignedDistancePointLine.py Test2273.py Test2280.py + Test2287.py ) if(${SKETCHER_CHANGE_RADIUS_WHEN_MOVE}) diff --git a/src/SketchPlugin/SketchPlugin_Projection.cpp b/src/SketchPlugin/SketchPlugin_Projection.cpp index fb6815a16..3d783a408 100644 --- a/src/SketchPlugin/SketchPlugin_Projection.cpp +++ b/src/SketchPlugin/SketchPlugin_Projection.cpp @@ -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 index 000000000..1049f7d1c --- /dev/null +++ b/src/SketchPlugin/Test/Test2287.py @@ -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 +## + +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()) diff --git a/src/SketcherPrs/SketcherPrs_Angle.cpp b/src/SketcherPrs/SketcherPrs_Angle.cpp index 9521f1db1..d1735600b 100644 --- a/src/SketcherPrs/SketcherPrs_Angle.cpp +++ b/src/SketcherPrs/SketcherPrs_Angle.cpp @@ -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); diff --git a/src/SketcherPrs/SketcherPrs_PositionMgr.cpp b/src/SketcherPrs/SketcherPrs_PositionMgr.cpp index 31921298b..21b6dacb1 100644 --- a/src/SketcherPrs/SketcherPrs_PositionMgr.cpp +++ b/src/SketcherPrs/SketcherPrs_PositionMgr.cpp @@ -37,9 +37,9 @@ #include #include -#include #include #include +#include #include #include @@ -202,22 +202,11 @@ gp_Vec getVector(ObjectPtr theShape, GeomDirPtr theDir, gp_Pnt theP) std::shared_ptr(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(), - aEdgePtr->impl()); - 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(); - gp_Pnt aP; - aCurv->D1(aParam, aP, aVec); - break; - } - } - } + Handle(Geom_Curve) aCurv = aCurve->impl(); + 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()); diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index eb2b6bbc7..961245200 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -74,7 +74,7 @@ #include #ifdef TINSPECTOR -#include +#include #endif #include diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index ad655723d..cfdf13912 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -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); } diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index f91a1b391..eebb23d22 100755 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -46,7 +46,7 @@ #include #ifdef TINSPECTOR -#include +#include #endif XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 56f264361..1e7e18aba 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -132,8 +132,8 @@ #ifdef TINSPECTOR #include #include -#include -#include +#include +#include static TInspector_Communicator* MyTCommunicator; static Handle(VInspector_CallBack) MyVCallBack;