#include <qlistbox.h>
#include <qvgroupbox.h>
#include <qthread.h>
+#include <qgrid.h>
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "VISU_CutLines_i.hh"
#include "VISU_Vectors_i.hh"
#include "VISU_StreamLines_i.hh"
+#include "VISU_Actor.h"
static double MAXVALUE = 1.0E+300;
+#define MAXVAL 1e10
+
+
+
+ArrangeDlg::ArrangeDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator)
+ : QDialog(theParent, "ArrangeDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
+ myAnimator(theAnimator)
+{
+ myCurrent = 0;
+ init();
+ QStringList aFieldNames;
+ // Find names of fields
+ for (int i = 0; i < theAnimator->getNbFields(); i++) {
+ aFieldNames.append(VisuGUI::getValue(theAnimator->getFieldData(i).myField, "myName"));
+ Offset aOffs;
+ aOffs.myOffset[0] = myAnimator->getFieldData(i).myOffset[0];
+ aOffs.myOffset[1] = myAnimator->getFieldData(i).myOffset[1];
+ aOffs.myOffset[2] = myAnimator->getFieldData(i).myOffset[2];
+ myOffsets.append(aOffs);
+ }
+ myFieldLst->insertStringList(aFieldNames);
+ myFieldLst->setSelected(0, true);
+}
+
+
+void ArrangeDlg::init()
+{
+ setCaption("Arrange Presentations");
+ setSizeGripEnabled( TRUE );
+
+ QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 6);
+ aMainLayout->setSpacing(5);
+
+ QButtonGroup* aBtnGrp = new QButtonGroup(2, Qt::Horizontal, this);
+ aBtnGrp->setExclusive(true);
+ aMainLayout->addWidget(aBtnGrp);
+
+ QRadioButton* aAutoBtn = new QRadioButton("Auto", aBtnGrp);
+ aBtnGrp->insert(aAutoBtn, AutoMode);
+
+ QRadioButton* aManualBtn = new QRadioButton("Manual", aBtnGrp);
+ aBtnGrp->insert(aManualBtn, ManualMode);
+ aBtnGrp->setButton(AutoMode);
+
+ myStackWgt = new QWidgetStack(this);
+ aMainLayout->addWidget(myStackWgt);
+
+ // AUTO Pane
+ QVBox* aAutoPane = new QVBox(myStackWgt);
+ aAutoPane->setSpacing(5);
+ // Axis Group
+ myAxisGrp = new QButtonGroup(3, Qt::Horizontal,"Axis", aAutoPane);
+
+ QRadioButton* aXBtn = new QRadioButton("X",myAxisGrp );
+ myAxisGrp->insert(aXBtn, XAxis);
+
+ QRadioButton* aYBtn = new QRadioButton("Y",myAxisGrp );
+ myAxisGrp->insert(aYBtn, YAxis);
+
+ QRadioButton* aZBtn = new QRadioButton("Z",myAxisGrp );
+ myAxisGrp->insert(aZBtn, ZAxis);
+
+ myAxisGrp->setButton(XAxis);
+
+ //Distance Input
+ QHBox* aDistPane = new QHBox(aAutoPane);
+ aDistPane->setSpacing(5);
+ new QLabel("Distance", aDistPane);
+ myDistVal = new QAD_SpinBoxDbl(aDistPane, -5, 5, 0.5 );
+ myDistVal->setValue(0.5);
+
+ myStackWgt->addWidget(aAutoPane, AutoMode);
+
+ // Manual Pane
+ QHBox* aManualPane = new QHBox(myStackWgt);
+ aManualPane->setSpacing(10);
+
+ myFieldLst = new QListBox(aManualPane);
+ connect( myFieldLst, SIGNAL( highlighted(int) ),
+ this, SLOT( onFieldChange(int) ) );
+
+ QGrid* aCoordPane = new QGrid(2, aManualPane);
+ aCoordPane->setSpacing(5);
+
+ new QLabel("X", aCoordPane);
+ myCoord[0] = new QAD_SpinBoxDbl(aCoordPane);
+ myCoord[0]->setRange(-MAXVAL, MAXVAL);
+
+ new QLabel("Y", aCoordPane);
+ myCoord[1] = new QAD_SpinBoxDbl(aCoordPane);
+ myCoord[1]->setRange(-MAXVAL, MAXVAL);
+
+ new QLabel("Z", aCoordPane);
+ myCoord[2] = new QAD_SpinBoxDbl(aCoordPane);
+ myCoord[2]->setRange(-MAXVAL, MAXVAL);
+
+ myStackWgt->addWidget(aManualPane, ManualMode);
+
+ myStackWgt->raiseWidget(AutoMode);
+
+ connect(aBtnGrp, SIGNAL(clicked(int)), myStackWgt, SLOT(raiseWidget(int)) );
+
+ // Common buttons ===========================================================
+ QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
+ GroupButtons->setColumnLayout(0, Qt::Vertical );
+ GroupButtons->layout()->setSpacing( 0 );
+ GroupButtons->layout()->setMargin( 0 );
+ QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
+ GroupButtonsLayout->setAlignment( Qt::AlignTop );
+ GroupButtonsLayout->setSpacing( 6 );
+ GroupButtonsLayout->setMargin( 11 );
+
+ QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
+ buttonOk->setAutoDefault( TRUE );
+ buttonOk->setDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
+ GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
+
+ QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
+ buttonCancel->setAutoDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
+
+ aMainLayout->addWidget( GroupButtons );
+
+ connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
+ connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+}
+
+
+void ArrangeDlg::accept()
+{
+ if (getMode() == ManualMode) {
+ // Save from GUI
+ Offset& aOffs = myOffsets[myCurrent];
+ aOffs.myOffset[0] = myCoord[0]->value();
+ aOffs.myOffset[1] = myCoord[1]->value();
+ aOffs.myOffset[2] = myCoord[2]->value();
+
+ for (int i = 0; i < myAnimator->getNbFields(); i++) {
+ Offset aOffs = myOffsets[i];
+ myAnimator->getFieldData(i).myOffset[0] = aOffs.myOffset[0];
+ myAnimator->getFieldData(i).myOffset[1] = aOffs.myOffset[1];
+ myAnimator->getFieldData(i).myOffset[2] = aOffs.myOffset[2];
+ }
+ } else {
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ FieldData& aData = myAnimator->getFieldData(0);
+ if (aData.myPrs.empty())
+ myAnimator->generatePresentations(0);
+ VISU_Actor* aActor = aActor = aData.myPrs[0]->CreateActor();
+ float aBounds[6];
+ aActor->GetBounds(aBounds);
+ aActor->Delete();
+ float aDist = 0;
+ int aAxis = getAxis();
+ switch (aAxis) {
+ case XAxis:
+ aDist = fabs(aBounds[3] - aBounds[0]);
+ break;
+ case YAxis:
+ aDist = fabs(aBounds[4] - aBounds[1]);
+ break;
+ case ZAxis:
+ aDist = fabs(aBounds[5] - aBounds[2]);
+ }
+ aDist += aDist*getDistance();
+ for (int i = 0; i < myAnimator->getNbFields(); i++) {
+ myAnimator->getFieldData(i).myOffset[0] = 0;
+ myAnimator->getFieldData(i).myOffset[1] = 0;
+ myAnimator->getFieldData(i).myOffset[2] = 0;
+ myAnimator->getFieldData(i).myOffset[aAxis] = aDist * i;
+ }
+
+ QApplication::restoreOverrideCursor();
+ }
+ QDialog::accept();
+}
+
+void ArrangeDlg::onFieldChange(int theCurrent)
+{
+ if (myCurrent != theCurrent) {
+ Offset& aOffs = myOffsets[myCurrent];
+ aOffs.myOffset[0] = myCoord[0]->value();
+ aOffs.myOffset[1] = myCoord[1]->value();
+ aOffs.myOffset[2] = myCoord[2]->value();
+ }
+ myCurrent = theCurrent;
+ const Offset& aNewOffs = myOffsets[myCurrent];
+ myCoord[0]->setValue(aNewOffs.myOffset[0]);
+ myCoord[1]->setValue(aNewOffs.myOffset[1]);
+ myCoord[2]->setValue(aNewOffs.myOffset[2]);
+}
+
+
+
+
+//*****************************************************************************************************
+//*****************************************************************************************************
+//*****************************************************************************************************
SetupDlg::SetupDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator)
: QDialog( theParent, "SetupDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
this, SLOT( onFieldChange(int) ) );
- QVGroupBox* aPropBox = new QVGroupBox("Properties", aPropFrame);
+ QVBox* aSetupBox = new QVBox(aPropFrame);
+ aSetupBox->setSpacing(5);
+
+ QVGroupBox* aPropBox = new QVGroupBox("Properties", aSetupBox);
myTypeCombo = new QComboBox(aPropBox);
connect( myTypeCombo, SIGNAL( activated(int) ),
this, SLOT( onTypeChanged(int) ) );
// myPropBtn->setEnabled(theAnimator->getFieldData(0).myPrsType != VISU::TSCALARMAP);
connect( myPropBtn, SIGNAL( clicked() ),
this, SLOT( onPreferencesDlg() ) );
-
+
+ if (myAnimator->getNbFields() > 1) {
+ myArrangeBtn = new QPushButton("Arrange...", aSetupBox);
+ connect( myArrangeBtn, SIGNAL( clicked() ), this, SLOT( onArrangeDlg() ) );
+ }
onFieldChange(0);
aMainLayout->addWidget(aPropFrame);
#undef EDITPRS
}
+
+//************************************************************************
+void SetupDlg::onArrangeDlg()
+{
+ ArrangeDlg aDlg(this, myAnimator);
+ aDlg.exec();
+}
+
//************************************************************************
void SetupDlg::onRangeCheck(bool theCheck) {
for (int i = 0; i < myAnimator->getNbFields(); i++)