X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_WidgetSketchLabel.cpp;h=5464d078f641c9910a53557cee5a8a589a629c20;hb=6fb5a58743556b877d64129002572de4116abd96;hp=a45de9121931cd880672d529b3d5531343add30a;hpb=674e60d84265e00a9da2d59c9ce293c7339b6087;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index a45de9121..5464d078f 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -1,8 +1,22 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: PartSet_WidgetSketchLabel.cpp -// Created: 07 July 2014 -// Author: Vitaly SMETANNIKOV +// 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 +// #include "PartSet_WidgetSketchLabel.h" #include "PartSet_Tools.h" @@ -34,6 +48,8 @@ #include #include #include +#include +#include #include #include @@ -211,10 +227,12 @@ void PartSet_WidgetSketchLabel::onShowConstraint(bool theOn) void PartSet_WidgetSketchLabel::blockAttribute(const AttributePtr& theAttribute, const bool& theToBlock, bool& isFlushesActived, - bool& isAttributeSetInitializedBlocked) + bool& isAttributeSetInitializedBlocked, + bool& isAttributeSendUpdatedBlocked) { ModuleBase_WidgetValidated::blockAttribute(theAttribute, theToBlock, isFlushesActived, - isAttributeSetInitializedBlocked); + isAttributeSetInitializedBlocked, + isAttributeSendUpdatedBlocked); // We do not restore the previous state of isAttributeSetInitializedBlocked for each of // attributes. It it is necessary, these states should be append to the method attributes // or stored in the widget @@ -305,12 +323,9 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs // Rotate view if the sketcher plane is selected only from preview planes // Preview planes are created only if there is no any shape - bool aRotate = Config_PropManager::boolean(SKETCH_TAB_NAME, "rotate_to_plane", "false"); + bool aRotate = Config_PropManager::boolean(SKETCH_TAB_NAME, "rotate_to_plane"); if (aRotate) { myWorkshop->viewer()->setViewProjection(aXYZ.X(), aXYZ.Y(), aXYZ.Z(), aTwist); - PartSet_Module* aModule = dynamic_cast(myWorkshop->module()); - if (aModule) - aModule->onViewTransformed(); } QString aSizeOfViewStr = mySizeOfView->text(); if (!aSizeOfViewStr.isEmpty()) { @@ -326,6 +341,9 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs } } } + PartSet_Module* aModule = dynamic_cast(myWorkshop->module()); + if (aModule) + aModule->onViewTransformed(); } // 3. Clear text in the label myStackWidget->setCurrentIndex(1); @@ -346,7 +364,9 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs // 6. Update sketcher actions XGUI_ActionsMgr* anActMgr = aWorkshop->actionsMgr(); + myWorkshop->updateCommandStatus(); + aWorkshop->selector()->clearSelection(); myWorkshop->viewer()->update(); } @@ -522,6 +542,9 @@ void PartSet_WidgetSketchLabel::activateSelection(bool toActivate) QIntList aModes; std::shared_ptr aPlane = plane(); if (aPlane.get()) { + //QList> aEdges = findCircularEdgesInPlane(); + //foreach(std::shared_ptr aPrs, aEdges) { + //} myWorkshop->module()->activeSelectionModes(aModes); } else { @@ -568,7 +591,7 @@ std::shared_ptr std::shared_ptr anOrigPnt(new GeomAPI_Pnt(aCoords)); // X axis is preferable to be dirX on the sketch const double tol = Precision::Confusion(); - bool isX = fabs(anA - 1.0) < tol && fabs(aB) < tol && fabs(aC) < tol; + bool isX = fabs(fabs(anA) - 1.0) < tol && fabs(aB) < tol && fabs(aC) < tol; std::shared_ptr aTempDir( isX ? new GeomAPI_Dir(0, 1, 0) : new GeomAPI_Dir(1, 0, 0)); std::shared_ptr aYDir(new GeomAPI_Dir(aNormDir->cross(aTempDir))); @@ -601,3 +624,47 @@ void PartSet_WidgetSketchLabel::onSetPlaneView() aModule->onViewTransformed(); } } + + +//****************************************************** +QList> PartSet_WidgetSketchLabel::findCircularEdgesInPlane() +{ + QList> aResult; + XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop); + XGUI_Displayer* aDisplayer = aWorkshop->displayer(); + QObjectPtrList aDispObjects = aDisplayer->displayedObjects(); + + std::shared_ptr aPlane = plane(); + foreach(ObjectPtr aObj, aDispObjects) { + ResultPtr aResObj = std::dynamic_pointer_cast(aObj); + if (aResObj.get()) { + GeomShapePtr aShape = aResObj->shape(); + if (aShape.get()) { + GeomAPI_ShapeExplorer aExplorer(aShape, GeomAPI_Shape::EDGE); + for(; aExplorer.more(); aExplorer.next()) { + GeomShapePtr aEdgeShape = aExplorer.current(); + GeomAPI_Edge anEdge(aEdgeShape); + if ((anEdge.isCircle() || anEdge.isArc() || anEdge.isEllipse()) && + anEdge.isInPlane(aPlane)) { + bool isContains = false; + // Check that edge is not used. + // It is possible that the same edge will be taken from different faces + foreach(std::shared_ptr aPrs, aResult) { + GeomAPI_Edge aUsedEdge(aPrs->shape()); + if (aUsedEdge.isEqual(aEdgeShape)) { + isContains = true; + break; + } + } + if (!isContains) { + std::shared_ptr + aPrs(new ModuleBase_ViewerPrs(aResObj, aEdgeShape)); + aResult.append(aPrs); + } + } + } + } + } + } + return aResult; +}