]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #3040: Include dimensions to FitAll operation.
authorvsv <vsv@opencascade.com>
Fri, 4 Oct 2019 10:33:14 +0000 (13:33 +0300)
committervsv <vsv@opencascade.com>
Fri, 4 Oct 2019 10:33:14 +0000 (13:33 +0300)
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h

index b8c25aa84205110b345f549f0f8132e18688a218..1c88fc4f6bf76b4f5e81138a30fd2c795abdae34 100644 (file)
@@ -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<XGUI_ModuleConnector*>(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<ResultPtr> aResults = aFeature->results();
-    std::list<ResultPtr>::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<SketchPlugin_Feature> aSPFeature =
-            std::dynamic_pointer_cast<SketchPlugin_Feature>(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<Handle(AIS_InteractiveObject)>();
+      if (!aAisObj->IsInfinite()) {
+        Bnd_Box aBox;
+        aAisObj->BoundingBox(aBox);
+        aBndBox.Add(aBox);
+      }
+    }
+    else {
+      std::list<ResultPtr> aResults = aFeature->results();
+      std::list<ResultPtr>::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<SketchPlugin_Feature> aSPFeature =
+              std::dynamic_pointer_cast<SketchPlugin_Feature>(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);
+              }
             }
           }
         }
index bfc8bfac67c08ef9afd5a86cf501755c8e61fe8d..7259514a4eb54083d520cf7e8863bc929d96a348 100644 (file)
@@ -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<GeomAPI_Pln>& thePln);