From: jfa Date: Wed, 27 Jul 2005 14:16:32 +0000 (+0000) Subject: IPAL8918: incorrect auto-arrange actors X-Git-Tag: V3_0_1~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bad971fe75b298d6cc65f28f074eda0f1d4ba900;p=modules%2Fvisu.git IPAL8918: incorrect auto-arrange actors --- diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index cc639284..d905c731 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -294,7 +294,25 @@ void ArrangeDlg::acceptAnimation() case ZAxis: aDist = fabs(aBounds[5] - aBounds[4]); } - aDist = aDist*getDistance(); + + float dx = fabs(aBounds[1] - aBounds[0]); + float dy = fabs(aBounds[3] - aBounds[2]); + float dz = fabs(aBounds[5] - aBounds[4]); + float max = (dx > dy) ? dx : dy; + max = (dz > max) ? dz : max; + max /= 100.0; + + if (aDist < 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; + + aDist = (dx < dy) ? dx : dy; + aDist = (dz < aDist) ? dz : aDist; + } + aDist = aDist * getDistance(); for (int i = 0; i < myAnimator->getNbFields(); i++) { myAnimator->getFieldData(i).myOffset[0] = 0; myAnimator->getFieldData(i).myOffset[1] = 0; @@ -328,6 +346,7 @@ void ArrangeDlg::acceptViewWindow() float aDist = 0; float aShift = 0; float aPrevDist = 0; + float aPrevShift = 0; // bool aInit = true; int i; QMap::Iterator it; @@ -353,14 +372,51 @@ void ArrangeDlg::acceptViewWindow() float aOffset[3]; aOffset[0] = aOffset[1] = aOffset[2] = 0; - aShift = (i == 0)? 0 : aShift + (aDist + aPrevDist) * getDistance() / 2; + if (i > 0) { + float aCCDist = (aDist + aPrevDist) / 2.0; + + float dx = fabs(aBounds[1] - aBounds[0]); + float dy = fabs(aBounds[3] - aBounds[2]); + float dz = fabs(aBounds[5] - aBounds[4]); + float 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 + // aDist / 2 + // <--> + // .--------------. .------. + //----------->| | | | + // aPrevShift '--------------' '------' + // <------> + // aPrevDist / 2 + // + // <---------------> + // (aDist + aPrevDist) * getDistance() / 2 + + aShift = aPrevShift + aPrevDist/2.0 + aCCDist*getDistance() - aDist/2.0; + } aOffset[aAxis] = aShift; aActor->SetPosition(aOffset); if (mySaveChk) if (mySaveChk->isChecked()) aPrs->SetOffset(aOffset); + aPrevDist = aDist; + aPrevShift = aShift; } } }