X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_PreviewPlanes.cpp;h=2fca7204f4d839cc9efc51807a3c7b3faa43e907;hb=refs%2Fheads%2FV9_11_BR;hp=424deec9d0356aeeed7f034cc0d266b4f86ae6cf;hpb=3b676e8f67d0b110ecee42985223b99fc181532b;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_PreviewPlanes.cpp b/src/PartSet/PartSet_PreviewPlanes.cpp old mode 100755 new mode 100644 index 424deec9d..2fca7204f --- a/src/PartSet/PartSet_PreviewPlanes.cpp +++ b/src/PartSet/PartSet_PreviewPlanes.cpp @@ -1,14 +1,29 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: PartSet_PreviewPlanes.cpp -// Created: 19 Jun 2015 -// Author: Natalia ERMOLAEVA +// Copyright (C) 2014-2023 CEA, EDF +// +// 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_PreviewPlanes.h" #include #include +#include +#include #include #include @@ -33,10 +48,17 @@ bool PartSet_PreviewPlanes::hasVisualizedBodies(ModuleBase_IWorkshop* theWorksho QObjectPtrList aDisplayed = aDisp->displayedObjects(); foreach (ObjectPtr anObj, aDisplayed) { ResultPtr aResult = std::dynamic_pointer_cast(anObj); - if (aResult.get() != NULL) { - aBodyIsVisualized = aResult->groupName() == ModelAPI_ResultBody::group(); - if (aBodyIsVisualized) - break; + // result constructions should not be taken as a body + if (aResult.get() != NULL && + ((aResult->groupName() == ModelAPI_ResultBody::group()) || + ((aResult->groupName() == ModelAPI_ResultPart::group()))) ) { + GeomShapePtr aShape = aResult->shape(); + if (aShape.get()) { + // vertices, edges should not be taken as a body + aBodyIsVisualized = aShape->shapeType() <= GeomAPI_Shape::FACE; + if (aBodyIsVisualized) + break; + } } } return aBodyIsVisualized; @@ -53,14 +75,27 @@ bool PartSet_PreviewPlanes::hasVisualizedSketch(ModuleBase_IWorkshop* theWorksho ResultPtr aResult = std::dynamic_pointer_cast(anObj); if (aResult.get() != NULL) { FeaturePtr aFeature = ModelAPI_Feature::feature(aResult); - aSketchIsVisualized = aFeature.get() && aFeature->getKind() == SketchPlugin_Sketch::ID(); - if (aSketchIsVisualized) - break; + if (aFeature.get() && aFeature->getKind() == SketchPlugin_Sketch::ID()) { + ResultConstructionPtr aCResult = std::dynamic_pointer_cast + (aResult); + if (aCResult.get() && aCResult->facesNum() > 0) { + aSketchIsVisualized = true; + break; + } + } + break; } } return aSketchIsVisualized; } +bool PartSet_PreviewPlanes::isPreviewShape(std::shared_ptr theShape) +{ + return (myYZPlane->getShape()->isEqual(theShape) || + myXZPlane->getShape()->isEqual(theShape) || + myXYPlane->getShape()->isEqual(theShape)); +} + void PartSet_PreviewPlanes::erasePreviewPlanes(ModuleBase_IWorkshop* theWorkshop) { if (myPreviewDisplayed) { @@ -85,13 +120,16 @@ void PartSet_PreviewPlanes::showPreviewPlanes(ModuleBase_IWorkshop* theWorkshop) std::shared_ptr aXZDir(new GeomAPI_Dir(0, -1, 0)); std::shared_ptr aXYDir(new GeomAPI_Dir(0, 0, 1)); - std::vector aYZRGB, aXZRGB, aXYRGB; - aYZRGB = Config_PropManager::color("Visualization", "yz_plane_color", - YZ_PLANE_COLOR); - aXZRGB = Config_PropManager::color("Visualization", "xz_plane_color", - XZ_PLANE_COLOR); - aXYRGB = Config_PropManager::color("Visualization", "xy_plane_color", - XY_PLANE_COLOR); + std::vector aYZRGB(3, 0), aXZRGB(3, 0), aXYRGB(3, 0); +#ifdef SET_PLANES_COLOR_IN_PREFERENCES + aYZRGB = Config_PropManager::color("Visualization", "yz_plane_color"); + aXZRGB = Config_PropManager::color("Visualization", "xz_plane_color"); + aXYRGB = Config_PropManager::color("Visualization", "xy_plane_color"); +#else + aYZRGB[0] = 225; + aXZRGB[1] = 225; + aXYRGB[2] = 225; +#endif int aR[] = {aYZRGB[0], aYZRGB[1], aYZRGB[2]}; int aG[] = {aXZRGB[0], aXZRGB[1], aXZRGB[2]}; int aB[] = {aXYRGB[0], aXYRGB[1], aXYRGB[2]}; @@ -101,21 +139,25 @@ void PartSet_PreviewPlanes::showPreviewPlanes(ModuleBase_IWorkshop* theWorkshop) myXYPlane = createPreviewPlane(anOrigin, aXYDir, aB); } XGUI_Displayer* aDisp = XGUI_Tools::workshop(theWorkshop)->displayer(); - aDisp->displayAIS(myYZPlane, true, false); - aDisp->displayAIS(myXZPlane, true, false); - aDisp->displayAIS(myXYPlane, true, false); + aDisp->displayAIS(myYZPlane, true, 0, false); + aDisp->displayAIS(myXZPlane, true, 0, false); + aDisp->displayAIS(myXYPlane, true, 0, false); myPreviewDisplayed = true; } -AISObjectPtr PartSet_PreviewPlanes::createPreviewPlane(std::shared_ptr theOrigin, - std::shared_ptr theNorm, +AISObjectPtr PartSet_PreviewPlanes::createPreviewPlane(std::shared_ptr theOrigin, + std::shared_ptr theNorm, const int theRGB[3]) { - double aSize = Config_PropManager::integer("Sketch planes", "planes_size", PLANE_SIZE); - std::shared_ptr aFace = GeomAlgoAPI_FaceBuilder::square(theOrigin, theNorm, aSize); + double aSize = Config_PropManager::real(SKETCH_TAB_NAME, "planes_size"); + if (aSize <= Precision::Confusion()) + aSize = 200; // Set default value + + std::shared_ptr aFace = + GeomAlgoAPI_FaceBuilder::squareFace(theOrigin, theNorm, aSize); AISObjectPtr aAIS = AISObjectPtr(new GeomAPI_AISObject()); aAIS->createShape(aFace); - aAIS->setWidth(Config_PropManager::integer("Sketch planes", "planes_thickness", SKETCH_WIDTH)); + aAIS->setWidth(Config_PropManager::real(SKETCH_TAB_NAME, "planes_thickness")); aAIS->setColor(theRGB[0], theRGB[1], theRGB[2]); return aAIS; }