]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Bug IPAL20132 Arrange Actors is not working for table presentations V4_1_0_maintainance_20080724 mergeto_BR_QT4_Dev_08Jul08
authordmv <dmv@opencascade.com>
Wed, 23 Jul 2008 10:07:43 +0000 (10:07 +0000)
committerdmv <dmv@opencascade.com>
Wed, 23 Jul 2008 10:07:43 +0000 (10:07 +0000)
src/VISUGUI/VisuGUI_TimeAnimation.cxx
src/VISUGUI/VisuGUI_TimeAnimation.h

index e4811c5fa2bfd4bfa84c8be510f3aa05543167f0..2ea7c5266c96a7321fb5a101269e000927fe0c06 100644 (file)
@@ -160,7 +160,7 @@ ArrangeDlg::ArrangeDlg(QWidget* theParent,
   vtkActorCollection *aCollection = myViewWindow->getRenderer()->GetActors();
   aCollection->InitTraversal();
   while(vtkActor* anActor = aCollection->GetNextActor()){
-    if (VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
+    if (VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor)) {
       if(anVISUActor->GetVisibility() != 0){
        if (VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d()){
          if(!myPrsMap.contains(aPrs)){
@@ -182,8 +182,33 @@ ArrangeDlg::ArrangeDlg(QWidget* theParent,
              }
            }
          }
-       }
+       } 
       }
+    } else { //if PointMap3d Actor
+      if (VISU_ActorBase* anActorBase = dynamic_cast<VISU_ActorBase*>(anActor))
+       if(anActorBase->GetVisibility() != 0)
+         if (VISU::PointMap3d_i* aPrs = dynamic_cast<VISU::PointMap3d_i*>(anActorBase->GetFactory())) {
+           if(!myPointMapPrsMap.contains(aPrs)){
+             Handle(SALOME_InteractiveObject) anIO = aPrs->GetIO();
+             if(!anIO->hasEntry())
+               continue;
+             SalomeApp_Study* aStudy = VISU::GetAppStudy(theModule);
+             VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, anIO->getEntry());
+             if(_PTR(SObject) aSObject = anObjectInfo.mySObject){
+               _PTR(GenericAttribute) anAttr;
+               if (aSObject->FindAttribute(anAttr, "AttributeName")) {
+                 _PTR(AttributeName) aName(anAttr);
+                 QString strIn(aName->Value().c_str());
+                 aPrsNames.append(strIn);
+                 myPointMapPrsMap[aPrs] = myOffsets.count();
+                 Offset aOffs;
+                 anActorBase->GetPosition(aOffs.myOffset);
+                 myOffsets.append(aOffs);
+               }
+             }
+           }
+         }
+    }
   }
   myFieldLst->insertStringList(aPrsNames);
   myFieldLst->setSelected(0, true);
@@ -411,14 +436,24 @@ void ArrangeDlg::acceptViewWindow()
        if (mySaveChk->isChecked())
          aPrs->SetOffset(aOffs.myOffset[0],aOffs.myOffset[1],aOffs.myOffset[2]);
     }
+    QMap<VISU::PointMap3d_i*, int>::Iterator itt;
+    for (itt = myPointMapPrsMap.begin(); itt != myPointMapPrsMap.end(); ++itt) {
+      VISU::PointMap3d_i* aPrs = itt.key();
+      Offset& aOffs = myOffsets[itt.data()];
+      if (VISU_ActorBase* anActor = VISU::FindActorBase(myViewWindow, aPrs))
+        anActor->SetPosition(aOffs.myOffset);
+      if (mySaveChk)
+       if (mySaveChk->isChecked())
+         aPrs->SetOffset(aOffs.myOffset[0],aOffs.myOffset[1],aOffs.myOffset[2]);
+    }
   } else {
     vtkFloatingPointType aDist = 0;
     vtkFloatingPointType aShift = 0;
     vtkFloatingPointType aPrevDist = 0;
     vtkFloatingPointType aPrevShift = 0;
-    int i;
+    int i = 0;
     QMap<VISU::Prs3d_i*, int>::Iterator it;
-    for (it = myPrsMap.begin(), i = 0; it != myPrsMap.end(); ++it, i++) {
+    for (it = myPrsMap.begin(); it != myPrsMap.end(); ++it, i++) {
       VISU::Prs3d_i* aPrs = it.key();
       if (VISU_Actor* aActor = VISU::FindActor(myViewWindow, aPrs)) {
        int aAxis = getAxis();
@@ -491,7 +526,70 @@ void ArrangeDlg::acceptViewWindow()
        aPrevDist = aDist;
        aPrevShift = aShift;
       }
-    }
+    } // end of myPrsMap loop
+    // Loop in PointMap3D the same as previous loop
+    QMap<VISU::PointMap3d_i*, int>::Iterator itt;
+    for (itt = myPointMapPrsMap.begin(); itt != myPointMapPrsMap.end(); ++itt, i++) {
+      VISU::PointMap3d_i* aPrs = itt.key();
+      if (VISU_ActorBase* aActor = VISU::FindActorBase(myViewWindow, aPrs)) {
+       int aAxis = getAxis();
+
+       vtkFloatingPointType aZeroOffset[3];
+       aZeroOffset[0] = aZeroOffset[1] = aZeroOffset[2] = 0;
+       aActor->SetPosition(aZeroOffset);
+        aActor->GetMapper()->Update();
+
+       vtkFloatingPointType aBounds[6];
+       aActor->GetBounds(aBounds);
+       switch (aAxis) {
+       case XAxis:
+         aDist = fabs(aBounds[1] - aBounds[0]);
+         break;
+       case YAxis:
+         aDist = fabs(aBounds[3] - aBounds[2]);
+         break;
+       case ZAxis:
+         aDist = fabs(aBounds[5] - aBounds[4]);
+       }
+       vtkFloatingPointType aOffset[3];
+        aOffset[0] = aOffset[1] = aOffset[2] = 0;
+        aOffset[aAxis] =
+          (aBounds[2*aAxis+1] < aBounds[2*aAxis]) ? -aBounds[2*aAxis+1] : -aBounds[2*aAxis];
+
+        if (i > 0) {
+          vtkFloatingPointType aCCDist = (aDist + aPrevDist) / 2.0;
+
+          vtkFloatingPointType dx = fabs(aBounds[1] - aBounds[0]);
+          vtkFloatingPointType dy = fabs(aBounds[3] - aBounds[2]);
+          vtkFloatingPointType dz = fabs(aBounds[5] - aBounds[4]);
+          vtkFloatingPointType max = (dx > dy) ? dx : dy;
+          max = (dz > max) ? dz : max;
+          max /= 100.0;
+
+          if (aCCDist < max) {
+            // set base distance between centers of bounding boxes
+            // to minimal (but big enough) size of current bounding box
+            if (dx < max) dx = FLT_MAX;
+            if (dy < max) dy = FLT_MAX;
+            if (dz < max) dz = FLT_MAX;
+
+            aCCDist = (dx < dy) ? dx : dy;
+            aCCDist = (dz < aCCDist) ? dz : aCCDist;
+          }
+          aShift = aPrevShift + aPrevDist/2.0 + aCCDist*getDistance() - aDist/2.0;
+        }
+
+       aOffset[aAxis] += aShift;
+       aActor->SetPosition(aOffset);
+       if (mySaveChk)
+         if (mySaveChk->isChecked())
+           aPrs->SetOffset(aOffset[0],aOffset[1],aOffset[2]);
+
+       aPrevDist = aDist;
+       aPrevShift = aShift;
+      }
+    } // end of myPointMapPrsMap loop
+
   }
   myViewWindow->getRenderer()->ResetCameraClippingRange();
   myViewWindow->Repaint();
index d41e369c482563739dc7131431d21a7997694185..9a97900ecc7ffd1c972c0741574cad62b03ac876 100644 (file)
@@ -47,6 +47,7 @@ class VISU_TimeAnimation;
 namespace VISU 
 {
   class Prs3d_i;
+  class PointMap3d_i;
 }
 
 class SVTK_ViewWindow;
@@ -113,6 +114,7 @@ class ArrangeDlg: public QDialog
 
   int               myCurrent;
   QMap<VISU::Prs3d_i*, int> myPrsMap;
+  QMap<VISU::PointMap3d_i*, int> myPointMapPrsMap;
 };