FieldData& aData = myAnimator->getFieldData(0);
if (aData.myPrs.empty())
myAnimator->generatePresentations(0);
- VISU_Actor* aActor = aActor = aData.myPrs[0]->CreateActor();
+ VISU_Actor* aActor = aData.myPrs[0]->CreateActor();
float aBounds[6];
aActor->GetBounds(aBounds);
aActor->Delete();
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;
for (it = myPrsMap.begin(); it != myPrsMap.end(); ++it) {
VISU::Prs3d_i* aPrs = it.key();
Offset& aOffs = myOffsets[it.data()];
- if (VISU_Actor* anActor = VISU::GetActor(aPrs, myViewWindow)) anActor->SetPosition(aOffs.myOffset);
+ if (VISU_Actor* anActor = VISU::GetActor(aPrs, myViewWindow))
+ anActor->SetPosition(aOffs.myOffset);
if (mySaveChk)
if (mySaveChk->isChecked())
aPrs->SetOffset(aOffs.myOffset);
float aDist = 0;
float aShift = 0;
float aPrevDist = 0;
- // bool aInit = true;
+ float aPrevShift = 0;
int i;
QMap<VISU::Prs3d_i*, int>::Iterator it;
for (it = myPrsMap.begin(), i = 0; it != myPrsMap.end(); ++it, i++) {
VISU::Prs3d_i* aPrs = it.key();
- if (VISU_Actor* aActor = VISU::GetActor(aPrs, myViewWindow)){
+ if (VISU_Actor* aActor = VISU::GetActor(aPrs, myViewWindow)) {
int aAxis = getAxis();
- // if (aInit) {
+
+ float aZeroOffset[3];
+ aZeroOffset[0] = aZeroOffset[1] = aZeroOffset[2] = 0;
+ aActor->SetPosition(aZeroOffset);
+ aActor->GetMapper()->Update();
+
float aBounds[6];
aActor->GetBounds(aBounds);
switch (aAxis) {
case ZAxis:
aDist = fabs(aBounds[5] - aBounds[4]);
}
- // aInit = false;
- // }
float aOffset[3];
- aOffset[0] = aOffset[1] = aOffset[2] = 0;
-
- aShift = (i == 0)? 0 : aShift + (aDist + aPrevDist) * getDistance() / 2;
-
- aOffset[aAxis] = aShift;
+ aOffset[0] = (aBounds[1] < aBounds[0]) ? -aBounds[1] : -aBounds[0];
+ aOffset[1] = (aBounds[3] < aBounds[2]) ? -aBounds[3] : -aBounds[2];
+ aOffset[2] = (aBounds[5] < aBounds[4]) ? -aBounds[5] : -aBounds[4];
+
+ 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;
}
}
}
//*****************************************************************************************************
//*****************************************************************************************************
//*****************************************************************************************************
-SetupDlg::SetupDlg (QWidget* theParent, VISU_TimeAnimation* theAnimator)
- : QDialog(theParent, "SetupDlg", true, WStyle_Customize |
- WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+SetupDlg::SetupDlg (VisuGUI* theModule, VISU_TimeAnimation* theAnimator)
+ : QDialog(VISU::GetDesktop(theModule), "SetupDlg", true, WStyle_Customize |
+ WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
+ myModule(theModule)
{
setCaption("Setup Animation");
setSizeGripEnabled( TRUE );
//************************************************************************
void SetupDlg::onPreferencesDlg()
{
- MESSAGE("SetupDlg::onPreferencesDlg() is not implemented");
SUIT_OverrideCursor c;
FieldData& aData = myAnimator->getFieldData(myFieldLst->currentItem());
if (aData.myPrs.empty())
#define EDITPRS(TYPE, DLG) {\
- DLG* aDlg = new DLG(this);\
+ DLG* aDlg = new DLG (myModule);\
aDlg->initFromPrsObject(dynamic_cast<TYPE*>(aData.myPrs[0]));\
if (aDlg->exec())\
{ \
EDITPRS(VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg);
break;
case TCUTPLANES_ITEM: //Cut Planes
- // EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg);
- {
- c.suspend();
- VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(false, true);
+ c.suspend();
+ EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg);
+ /*{
+ VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg (myModule);
//_CS_PhB :operator [] .at aDlg->initFromPrsObject(dynamic_cast<VISU::CutPlanes_i*>(aData.myPrs.at(0)));
aDlg->initFromPrsObject(dynamic_cast<VISU::CutPlanes_i*>(aData.myPrs[0]));
aDlg->storeToPrsObject(dynamic_cast<VISU::CutPlanes_i*>(aData.myPrs[i]));
}
delete aDlg;
- }
+ }*/
break;
case TPLOT3D_ITEM: //Plot 3D
c.suspend();
static QPixmap MYpausePixmap(pauseIco);
-//VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (QWidget* parent, _PTR(Study) theStudy)
-// : QDialog(parent, "VisuGUI_TimeAnimationDlg", false, WStyle_Customize |
VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule, _PTR(Study) theStudy)
: QDialog(VISU::GetDesktop(theModule), "VisuGUI_TimeAnimationDlg", false, WStyle_Customize |
- WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose)
+ WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose),
+ myModule(theModule),
+ myStudy(theStudy)
{
setCaption("Animation");
setSizeGripEnabled( TRUE );
- myModule = theModule;
- myStudy = theStudy;
isClosing = false;
- //myAnimator = new VISU_TimeAnimation (VISU::GetDSStudy(theStudy));
myAnimator = new VISU_TimeAnimation (theStudy);
myAnimator->setSpeed(1);
myAnimator->setViewer(VISU::GetViewWindow());
QPushButton* aCloseBtn = new QPushButton(tr("BUT_CLOSE"), aBtnBox);
connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(close()));
+ SUIT_Study* aStudy = VISU::GetAppStudy(myModule);
+ connect(aStudy, SIGNAL(destroyed()), this, SLOT(close()));
+
aMainLayout->addWidget(aBtnBox);
myPlayFrame->setEnabled(false);
void VisuGUI_TimeAnimationDlg::addField (_PTR(SObject) theSObject)
{
myPlayFrame->setEnabled(false);
- myAnimator->addField(VISU::GetSObject(theSObject));
+ myAnimator->addField(theSObject);
}
//************************************************************************
void VisuGUI_TimeAnimationDlg::onSetupDlg()
{
if (myAnimator->getNbFrames() > 0) myAnimator->firstFrame();
- SetupDlg* aDlg = new SetupDlg(this, myAnimator);
+ SetupDlg* aDlg = new SetupDlg (myModule, myAnimator);
aDlg->exec();
myPlayFrame->setEnabled(false);
delete aDlg;
void VisuGUI_TimeAnimationDlg::saveToStudy()
{
myAnimator->saveAnimation();
- myModule->updateObjBrowser( true );
+ VISU::UpdateObjBrowser(myModule, true);
}
//************************************************************************
void VisuGUI_TimeAnimationDlg::publishToStudy()
{
myAnimator->publishInStudy();
- myModule->updateObjBrowser( true );
+ VISU::UpdateObjBrowser(myModule, true);
mySaveBtn->setEnabled(myAnimator->isSavedInStudy());
}