#include <qslider.h>
#include <qthread.h>
#include <qlistbox.h>
+#include <qlineedit.h>
#include <qwt_wheel.h>
-#include <qhgroupbox.h>
#include <qlcdnumber.h>
+#include <qhgroupbox.h>
#include <qvgroupbox.h>
#include <qtoolbutton.h>
aMainLayout->setSpacing(5);
// Range of time stamps
- QFrame* aRangeGrp = new QFrame(this);
- QGridLayout* aRangeLayout = new QGridLayout( aRangeGrp );
- aRangeLayout->setSpacing( 6 );
- aRangeLayout->setMargin( 11 );
- aRangeGrp->setFrameStyle(QFrame::Box | QFrame::Raised);
-
- myUseRangeChk = new QCheckBox("Use range of time stamps", aRangeGrp);
- aRangeLayout->addMultiCellWidget(myUseRangeChk, 0, 0, 0, 3);
- myUseRangeChk->setChecked(myAnimator->isRangeDefined());
+ myUseRangeBox = new QHGroupBox("Use range of time stamps", this);
+ myUseRangeBox->setCheckable( true );
+ myUseRangeBox->setChecked(myAnimator->isRangeDefined());
double aMaxTime = myAnimator->getMaxTime();
double aMinTime = myAnimator->getMinTime();
aStep = (aMaxTime - aMinTime) / myAnimator->getAbsoluteFrameNumber(aLastFieldFrame);
}
- QLabel* aMinLbl = new QLabel("From", aRangeGrp);
- aMinLbl->setEnabled(myUseRangeChk->isChecked());
- aRangeLayout->addWidget(aMinLbl, 1, 0);
- myMinVal = new QtxDblSpinBox( aMinTime, aMaxTime, aStep, aRangeGrp );
- myMinVal->setEnabled(myUseRangeChk->isChecked());
- if (myUseRangeChk->isChecked())
+ QLabel* aMinLbl = new QLabel("From", myUseRangeBox);
+ myMinVal = new QtxDblSpinBox( aMinTime, aMaxTime, aStep, myUseRangeBox );
+ if (myUseRangeBox->isChecked())
myMinVal->setValue( myAnimator->getMinRange() );
else
myMinVal->setValue( aMinTime );
connect(myMinVal, SIGNAL( valueChanged(double)),
this, SLOT( onMinValue(double) ));
- aRangeLayout->addWidget(myMinVal, 1, 1);
-
- QLabel* aMaxLbl = new QLabel("To", aRangeGrp);
- aMaxLbl->setEnabled(myUseRangeChk->isChecked());
- aRangeLayout->addWidget(aMaxLbl, 1, 2);
- myMaxVal = new QtxDblSpinBox( aMinTime, aMaxTime, aStep, aRangeGrp );
- myMaxVal->setEnabled(myUseRangeChk->isChecked());
- if (myUseRangeChk->isChecked())
+
+ QLabel* aMaxLbl = new QLabel("To", myUseRangeBox);
+ myMaxVal = new QtxDblSpinBox( aMinTime, aMaxTime, aStep, myUseRangeBox );
+ if (myUseRangeBox->isChecked())
myMaxVal->setValue( myAnimator->getMaxRange() );
else
myMaxVal->setValue( aMaxTime );
connect(myMaxVal, SIGNAL( valueChanged(double)),
this, SLOT( onMaxValue(double) ));
- aRangeLayout->addWidget(myMaxVal, 1, 3);
- connect(myUseRangeChk, SIGNAL( toggled(bool)),
- aMinLbl, SLOT( setEnabled(bool) ));
- connect(myUseRangeChk, SIGNAL( toggled(bool)),
- aMaxLbl, SLOT( setEnabled(bool) ));
- connect(myUseRangeChk, SIGNAL( toggled(bool)),
+ connect(myUseRangeBox, SIGNAL( toggled(bool)),
this, SLOT( onRangeCheck(bool) ));
- aMainLayout->addWidget(aRangeGrp);
+ aMainLayout->addWidget(myUseRangeBox);
+
+
+ // Sequence of time stamps
+ myUseSequenceBox = new QGroupBox("Use sequence of time stamps", this);
+ myUseSequenceBox->setCheckable( true );
+ myUseSequenceBox->setChecked( myAnimator->isSequenceDefined() );
+
+ myUseSequenceBox->setColumnLayout(0, Qt::Vertical);
+ myUseSequenceBox->layout()->setSpacing( 0 );
+ myUseSequenceBox->layout()->setMargin( 0 );
+ QGridLayout* aUseSequenceLayout = new QGridLayout( myUseSequenceBox->layout() );
+ aUseSequenceLayout->setAlignment( Qt::AlignTop );
+ aUseSequenceLayout->setSpacing( 6 );
+ aUseSequenceLayout->setMargin( 11 );
+
+ QLabel* anIndicesLbl = new QLabel("Indices", myUseSequenceBox);
+ myIndices = new QLineEdit( myUseSequenceBox );
+
+ myValues = new QListBox( myUseSequenceBox );
+ myValues->setSelectionMode( QListBox::Extended );
+
+ connect(myIndices, SIGNAL( textChanged(const QString&)),
+ this, SLOT( onIndicesChanged(const QString&) ));
+
+ connect(myValues, SIGNAL( selectionChanged() ),
+ this, SLOT( onValuesChanged() ) );
+
+ connect(myUseSequenceBox, SIGNAL( toggled(bool)),
+ this, SLOT( onSequenceCheck(bool) ));
+
+ aUseSequenceLayout->addWidget( anIndicesLbl, 0, 0 );
+ aUseSequenceLayout->addWidget( myIndices, 0, 1 );
+ aUseSequenceLayout->addMultiCellWidget( myValues, 1, 1, 0, 1 );
+
+ aMainLayout->addWidget(myUseSequenceBox);
// Fields and Properties
aBtnLayout->addStretch();
QPushButton* aCloseBtn = new QPushButton(tr("BUT_OK"), aBtnBox);
- connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(close()));
+ connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(onClose()));
aMainLayout->addWidget(aBtnBox);
}
+//------------------------------------------------------------------------
+void SetupDlg::initialize()
+{
+ myValues->clear();
+
+ _PTR(Study) aStudy = myAnimator->getStudy();
+
+ FieldData& aData = myAnimator->getFieldData( 0 );
+ _PTR(SObject) aField = aData.myField;
+
+ _PTR(ChildIterator) anIter = aStudy->NewChildIterator(aField);
+ anIter->Next(); // First is reference on support
+ for(int index = 1; anIter->More(); anIter->Next(), index++)
+ {
+ QString aPrefix( "[" );
+ aPrefix += QString::number( index );
+ aPrefix += "] - ";
+
+ double aTime = VISU_TimeAnimation::getTimeValue(anIter->Value());
+ myValues->insertItem( aPrefix + QString::number( aTime ) );
+ }
+
+ QString anIndices( myAnimator->getAnimationSequence() );
+ myIndices->setText( anIndices );
+}
+
//------------------------------------------------------------------------
enum PrsComboItem {
TSCALARMAP_ITEM = 0, // VISU::TSCALARMAP
TSCALARMAPONDEFORMEDSHAPE_ITEM = 9 // VISU::TSCALARMAPONDEFORMEDSHAPE
};
+//------------------------------------------------------------------------
+void SetupDlg::onClose()
+{
+ for (int i = 0; i < myAnimator->getNbFields(); i++)
+ myAnimator->clearData(myAnimator->getFieldData(i));
+
+ if( !myUseRangeBox->isChecked() )
+ myAnimator->setAnimationRange( 0, 0 );
+
+ if( !myUseSequenceBox->isChecked() )
+ myAnimator->setAnimationSequence( 0 );
+
+ close();
+}
+
//------------------------------------------------------------------------
void SetupDlg::onFieldChange (int theIndex)
{
//------------------------------------------------------------------------
void SetupDlg::onRangeCheck (bool theCheck)
{
- myMinVal->setEnabled(theCheck);
- myMaxVal->setEnabled(theCheck);
+ if( theCheck )
+ {
+ myUseSequenceBox->blockSignals( true );
+ myUseSequenceBox->setChecked( false );
+ myUseSequenceBox->blockSignals( false );
+ }
if (!theCheck)
myAnimator->setAnimationRange(0, 0);
myMinVal->setFocus();
return;
}
- for (int i = 0; i < myAnimator->getNbFields(); i++)
- myAnimator->clearData(myAnimator->getFieldData(i));
myAnimator->setAnimationRange(theVal, myAnimator->getMaxRange());
}
myMaxVal->setFocus();
return;
}
- for (int i = 0; i < myAnimator->getNbFields(); i++)
- myAnimator->clearData(myAnimator->getFieldData(i));
myAnimator->setAnimationRange(myAnimator->getMinRange(), theVal);
}
+//------------------------------------------------------------------------
+void SetupDlg::onSequenceCheck( bool theCheck )
+{
+ if( theCheck )
+ {
+ myUseRangeBox->blockSignals( true );
+ myUseRangeBox->setChecked( false );
+ myUseRangeBox->blockSignals( false );
+ }
+}
+
+//------------------------------------------------------------------------
+void SetupDlg::onIndicesChanged( const QString& theIndices )
+{
+ bool aCorrect = true;
+ int aLimit = myValues->count();
+
+ QValueList<long> anIndicesList;
+ aCorrect = myAnimator->getIndicesFromSequence( theIndices, anIndicesList );
+
+ myValues->blockSignals( true );
+ myValues->clearSelection();
+
+ QValueList<long>::iterator indIt = anIndicesList.begin();
+ QValueList<long>::iterator indItEnd = anIndicesList.end();
+ for( int i = 0; indIt != indItEnd; ++indIt, i++ )
+ {
+ long anIndex = *indIt;
+ if( anIndex < 1 || anIndex > aLimit )
+ {
+ aCorrect = false;
+ myValues->clearSelection();
+ break;
+ }
+ myValues->setSelected( anIndex-1, true );
+ }
+
+ myValues->blockSignals( false );
+
+ if( !aCorrect )
+ {
+ myIndices->setPaletteForegroundColor( Qt::red );
+ return;
+ }
+
+ myIndices->setPaletteForegroundColor( Qt::black );
+
+ myAnimator->setAnimationSequence( theIndices.latin1() );
+}
+
+//------------------------------------------------------------------------
+void SetupDlg::onValuesChanged()
+{
+ int aLimit = myValues->count();
+
+ QString anIndices;
+
+ for( int i = 0; i < aLimit; i++ )
+ {
+ if( !myValues->isSelected( i ) )
+ continue;
+
+ QString aString = QString::number( i+1 );
+
+ bool aPrevSelected = i != 0 && myValues->isSelected( i-1 );
+ bool aNextSelected = i != aLimit - 1 && myValues->isSelected( i+1 );
+ if( aPrevSelected )
+ {
+ if( aNextSelected )
+ aString = "";
+ else
+ aString += ",";
+ }
+ else
+ {
+ if( aNextSelected )
+ aString += "-";
+ else
+ aString += ",";
+ }
+
+ anIndices += aString;
+ }
+
+ if( anIndices.right( 1 ) == "," )
+ anIndices.truncate( anIndices.length() - 1 );
+
+ myIndices->blockSignals( true );
+ myIndices->setText( anIndices );
+ myIndices->blockSignals( false );
+
+ myAnimator->setAnimationSequence( anIndices.latin1() );
+}
+
+//------------------------------------------------------------------------
static const char * firstIco[] = {
"18 10 2 1",
" g None",
void VisuGUI_TimeAnimationDlg::showEvent(QShowEvent* theEvent)
{
mySetupDlg = new SetupDlg(this,myModule, myAnimator);
+ mySetupDlg->initialize();
}
//------------------------------------------------------------------------
VISU::Result_i* theResult,
bool theIsRangeDefined,
CORBA::Double theTimeMin,
- CORBA::Double theTimeMax)
+ CORBA::Double theTimeMax,
+ QValueList<long> theSequence)
{
_PTR(ChildIterator) anIter = theStudy->NewChildIterator(theData.myField);
anIter->Next(); // First is reference on support
+ long aSequenceLength = theSequence.count();
+ bool isSequenceDefined = aSequenceLength > 0;
+ if (isSequenceDefined)
+ theData.myPrs.resize(aSequenceLength,NULL);
+
long aFrameId = 0;
- for(; anIter->More(); anIter->Next()){
+ long aSequenceIndex = 1;
+ for(; anIter->More(); anIter->Next(), aSequenceIndex++){
if (aFrameId == theData.myNbTimes) {
MESSAGE("There are extra timestamps in field");
return;
if(!aTimeStamp)
continue;
+ long aSequenceId = -1;
+
theData.myTiming[aFrameId] = VISU_TimeAnimation::getTimeValue(aTimeStamp);
if (theIsRangeDefined) {
if (theData.myTiming[aFrameId] < theTimeMin)
if (theData.myTiming[aFrameId] > theTimeMax)
break;
}
+ else if (isSequenceDefined) {
+ aSequenceId = theSequence.findIndex( aSequenceIndex );
+ if( aSequenceId == -1 )
+ continue;
+ }
VISU::Storable::TRestoringMap aTimeMap = VISU::Storable::GetStorableMap(aTimeStamp);
QString aMeshName = VISU::Storable::FindValue(aTimeMap,"myMeshName");
try{
#endif
if(aPresent->Apply(false)){
- theData.myPrs[aFrameId++] = aPresent;
+ /*
+ if(isSequenceDefined)
+ {
+ theData.myPrs[aSequenceId] = aPresent;
+ aFrameId++;
+ }
+ else
+ */
+ theData.myPrs[aFrameId++] = aPresent;
anIsCreated = true;
}
#ifdef NO_CAS_CATCH
aData.myPrs.resize(aData.myNbTimes,NULL);
aData.myTiming.resize(aData.myNbTimes);
+ QValueList<long> aSequence;
+ if( isSequenceDefined() )
+ {
+ bool ok = getIndicesFromSequence( mySequence, aSequence );
+ if( !ok )
+ return;
+ }
+
using namespace VISU;
switch (aData.myPrsType) {
case VISU::TSCALARMAP:
aResult,
isRangeDefined(),
myTimeMinVal,
- myTimeMaxVal);
+ myTimeMaxVal,
+ aSequence);
break;
case VISU::TISOSURFACES: // Iso Surfaces
GeneratePresentations<IsoSurfaces_i>(myStudy,
aResult,
isRangeDefined(),
myTimeMinVal,
- myTimeMaxVal);
+ myTimeMaxVal,
+ aSequence);
break;
case VISU::TCUTPLANES: // Cut Planes
GeneratePresentations<CutPlanes_i>(myStudy,
aResult,
isRangeDefined(),
myTimeMinVal,
- myTimeMaxVal);
+ myTimeMaxVal,
+ aSequence);
break;
case VISU::TCUTLINES: // Cut Lines
GeneratePresentations<CutLines_i>(myStudy,
aResult,
isRangeDefined(),
myTimeMinVal,
- myTimeMaxVal);
+ myTimeMaxVal,
+ aSequence);
break;
case VISU::TPLOT3D: // Plot3d
GeneratePresentations<Plot3D_i>(myStudy,
aResult,
isRangeDefined(),
myTimeMinVal,
- myTimeMaxVal);
+ myTimeMaxVal,
+ aSequence);
break;
case VISU::TDEFORMEDSHAPE: // Deformed Shape
GeneratePresentations<DeformedShape_i>(myStudy,
aResult,
isRangeDefined(),
myTimeMinVal,
- myTimeMaxVal);
+ myTimeMaxVal,
+ aSequence);
break;
case VISU::TVECTORS: // Vectors
GeneratePresentations<Vectors_i>(myStudy,
aResult,
isRangeDefined(),
myTimeMinVal,
- myTimeMaxVal);
+ myTimeMaxVal,
+ aSequence);
break;
case VISU::TSTREAMLINES: // Stream Lines
GeneratePresentations<StreamLines_i>(myStudy,
aResult,
isRangeDefined(),
myTimeMinVal,
- myTimeMaxVal);
+ myTimeMaxVal,
+ aSequence);
break;
case VISU::TGAUSSPOINTS: // Gauss Points
GeneratePresentations<GaussPoints_i>(myStudy,
aResult,
isRangeDefined(),
myTimeMinVal,
- myTimeMaxVal);
+ myTimeMaxVal,
+ aSequence);
break;
case VISU::TSCALARMAPONDEFORMEDSHAPE: // Scalar map on deformed shape
GeneratePresentations<ScalarMapOnDeformedShape_i>(myStudy,
aResult,
isRangeDefined(),
myTimeMinVal,
- myTimeMaxVal);
+ myTimeMaxVal,
+ aSequence);
break;
default:
MESSAGE("Not implemented for this presentation type: " << aData.myPrsType);
}
if ( myAnimationMode == VISU::Animation::SUCCESSIVE ) { // successive animation mode
- if ( isRangeDefined() ) {
+ if ( isRangeDefined() || isSequenceDefined() ) {
if ( myFieldsAbsFrames.size() == getNbFields() )
myFieldsAbsFrames.clear();
if ( theFieldNum > 0 )
mySpeed = (theSpeed<1)? 1 : theSpeed;
}
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::setAnimationSequence(const char* theSequence)
+{
+ mySequence = QString( theSequence );
+}
+
+//------------------------------------------------------------------------
+char* VISU_TimeAnimation::getAnimationSequence()
+{
+ return (char*)mySequence.latin1();
+}
+
+//------------------------------------------------------------------------
+CORBA::Boolean VISU_TimeAnimation::isSequenceDefined()
+{
+ return !mySequence.isEmpty();
+}
+
+//------------------------------------------------------------------------
+bool VISU_TimeAnimation::getIndicesFromSequence( QString theSequence, QValueList<long>& theIndices )
+{
+ bool isCorrect = true;
+
+ theIndices.clear();
+
+ QStringList aList = QStringList::split( ",", theSequence );
+ QStringList::iterator it = aList.begin();
+ QStringList::iterator itEnd = aList.end();
+ for( ; it != itEnd; ++it )
+ {
+ if( !isCorrect )
+ break;
+
+ isCorrect = false;
+
+ QString aString = *it;
+ if( aString.isEmpty() )
+ continue;
+
+ bool ok = false;
+ int aSingleIndex = aString.toLong( &ok );
+ if( ok )
+ {
+ theIndices.append( aSingleIndex );
+ isCorrect = true;
+ }
+ else if( aString.contains( '-' ) == 1 )
+ {
+ QString aLeftIndexStr = aString.section( '-', 0, 0 );
+ QString aRightIndexStr = aString.section( '-', -1 );
+
+ ok = false;
+ int aLeftIndex = aLeftIndexStr.toLong( &ok );
+ if( !ok )
+ continue;
+
+ ok = false;
+ int aRightIndex = aRightIndexStr.toLong( &ok );
+ if( !ok )
+ continue;
+
+ if( aLeftIndex >= aRightIndex )
+ continue;
+
+ for( int i = aLeftIndex; i <= aRightIndex; i++ )
+ theIndices.append( i );
+
+ isCorrect = true;
+ }
+ }
+
+ return isCorrect;
+}
+
+//------------------------------------------------------------------------
std::string VISU_TimeAnimation::setDumpFormat(const char* theFormat)
{
myDumpFormat = theFormat;
std::string aSComponentEntry = aSComponent->GetID();
QString aComment;
- aComment.sprintf("myComment=ANIMATION;myTimeMinVal=%g;myTimeMaxVal=%g;myMode=%d",
+ aComment.sprintf("myComment=ANIMATION;myTimeMinVal=%g;myTimeMaxVal=%g;mySequence=%s;myMode=%d",
myTimeMinVal,
myTimeMaxVal,
+ mySequence.latin1(),
myAnimationMode);
string anEntry = VISU::CreateAttributes(myStudy,
aComment.sprintf("myComment=ANIMATION;myTimeMinVal=%g;myTimeMaxVal=%g;myMode=%d",
myTimeMinVal,
myTimeMaxVal,
+ mySequence.latin1(),
myAnimationMode);
_PTR(GenericAttribute) anAttr;
bool isExist;
myTimeMinVal = VISU::Storable::FindValue(aMap,"myTimeMinVal",&isExist).toDouble();
myTimeMaxVal = VISU::Storable::FindValue(aMap,"myTimeMaxVal",&isExist).toDouble();
+ mySequence = VISU::Storable::FindValue(aMap,"mySequence",&isExist);
myAnimationMode = VISU::Animation::AnimationMode(VISU::Storable::FindValue(aMap,"myMode",&isExist).toInt());
_PTR(ChildIterator) anIter = myStudy->NewChildIterator(aAnimSObject);
continue;
addField(aFieldObj);
- if ( isRangeDefined() )
+ if ( isRangeDefined() || isSequenceDefined() )
myFieldsAbsFrames.pop_back();
FieldData& aData = getFieldData(getNbFields()-1);
return myAnim->isRangeDefined();
}
+void VISU_TimeAnimation_i::setAnimationSequence (const char* theSequence)
+{
+ myAnim->setAnimationSequence(theSequence);
+}
+
+char* VISU_TimeAnimation_i::getAnimationSequence()
+{
+ return myAnim->getAnimationSequence();
+}
+
+CORBA::Boolean VISU_TimeAnimation_i::isSequenceDefined()
+{
+ return myAnim->isRangeDefined();
+}
+
void VISU_TimeAnimation_i::dumpTo (const char* thePath)
{
myAnim->dumpTo(thePath);