From: vsv Date: Fri, 4 Oct 2019 10:33:14 +0000 (+0300) Subject: Issue #3040: Include dimensions to FitAll operation. X-Git-Tag: V9_4_0a2~4^2~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4315fa15a7f23f343a97f3fd34e84e97b2268355;p=modules%2Fshaper.git Issue #3040: Include dimensions to FitAll operation. --- diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index b8c25aa84..1c88fc4f6 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -1106,7 +1106,7 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation) workshop()->viewer()->set2dMode(true); - PartSet_Fitter* aFitter = new PartSet_Fitter(myCurrentSketch); + PartSet_Fitter* aFitter = new PartSet_Fitter(this); myModule->workshop()->viewer()->setFitter(aFitter); } @@ -2116,30 +2116,47 @@ void PartSet_SketcherMgr::onShowPoints(bool toShow) void PartSet_Fitter::fitAll(Handle(V3d_View) theView) { + CompositeFeaturePtr aSketch = mySketchMgr->activeSketch(); + + ModuleBase_IWorkshop* aWorkshop = mySketchMgr->module()->workshop(); + XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); + XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); + Bnd_Box aBndBox; - int aNumberOfSubs = mySketch->numberOfSubs(); + int aNumberOfSubs = aSketch->numberOfSubs(); + double aXmin, aYmin, aZmin, aXmax, aYmax, aZmax; for (int i = 0; i < aNumberOfSubs; i++) { - FeaturePtr aFeature = mySketch->subFeature(i); - std::list aResults = aFeature->results(); - std::list::const_iterator aIt; - ResultPtr aRes; - double aXmin, aYmin, aZmin, aXmax, aYmax, aZmax; - for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) { - aRes = (*aIt); - if (aRes->isDisplayed()) { - FeaturePtr aFeature = ModelAPI_Feature::feature(aRes); - if (aFeature.get()) { - std::shared_ptr aSPFeature = - std::dynamic_pointer_cast(aFeature); - if (aSPFeature.get()) { - bool isAxiliary = - aSPFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value(); - if (!(aSPFeature->isExternal() || isAxiliary)) { - GeomShapePtr aShape = aRes->shape(); - aShape->computeSize(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); - Bnd_Box aBox; - aBox.Update(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); - aBndBox.Add(aBox); + FeaturePtr aFeature = aSketch->subFeature(i); + if (aDisplayer->isVisible(aFeature)) { + AISObjectPtr aAisPtr = aDisplayer->getAISObject(aFeature); + Handle(AIS_InteractiveObject) aAisObj = aAisPtr->impl(); + if (!aAisObj->IsInfinite()) { + Bnd_Box aBox; + aAisObj->BoundingBox(aBox); + aBndBox.Add(aBox); + } + } + else { + std::list aResults = aFeature->results(); + std::list::const_iterator aIt; + ResultPtr aRes; + for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) { + aRes = (*aIt); + if (aRes->isDisplayed()) { + FeaturePtr aFeature = ModelAPI_Feature::feature(aRes); + if (aFeature.get()) { + std::shared_ptr aSPFeature = + std::dynamic_pointer_cast(aFeature); + if (aSPFeature.get()) { + bool isAxiliary = + aSPFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value(); + if (!(aSPFeature->isExternal() || isAxiliary)) { + GeomShapePtr aShape = aRes->shape(); + aShape->computeSize(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); + Bnd_Box aBox; + aBox.Update(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); + aBndBox.Add(aBox); + } } } } diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index bfc8bfac6..7259514a4 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -68,7 +68,7 @@ class PartSet_ExternalPointsMgr; class AIS_InteractiveObject; class QMouseEvent; - +class PartSet_SketcherMgr; #ifdef HAVE_SALOME class PartSet_Fitter : public OCCViewer_Fitter @@ -77,15 +77,15 @@ class PartSet_Fitter : public AppElements_Fitter #endif { public: - PartSet_Fitter(CompositeFeaturePtr theCurrentSketch): - mySketch(theCurrentSketch) {} + PartSet_Fitter(PartSet_SketcherMgr* theSketchMgr): + mySketchMgr(theSketchMgr) {} /// A method which has top be reimplemented to provide alterantive implementation FitAll command /// \param theView - a view which has to be fit virtual void fitAll(Handle(V3d_View) theView); private: - CompositeFeaturePtr mySketch; + PartSet_SketcherMgr* mySketchMgr; }; @@ -369,6 +369,8 @@ public: return myPointsHighlight.size() > 0; } + PartSet_Module* module() const { return myModule; } + public slots: /// Process sketch plane selected event void onPlaneSelected(const std::shared_ptr& thePln);