* This method allows to bound the range of generated frames.
* If this method is not used, the animation will be generated
* on the basis of all time stamps contained in the field.
- * /param theMin The value of the first time stamp which will be used for generation of the animation.
- * /param theMax The value of the last time stamp which will be used for generation of the animation.
+ * \param theMin The value of the first time stamp which will be used for generation of the animation.
+ * \param theMax The value of the last time stamp which will be used for generation of the animation.
*/
void setAnimationRange(in double theMin, in double theMax);
boolean isRangeDefined();
/*! Saves all the frames composing the animation into a definite directory.
- * \param thePath The directory where all the frames will be saved.
+ * Pictures format is set with method <VAR>setDumpFormat()</VAR>.
+ * \param thePath The directory where all the frames will be saved.
*/
void dumpTo(in string thePath);
+ /*! Set format for saving all the frames composing the animation.
+ * \param theFormat The format for saving pictures.
+ * For available formats see QImageIO documentation (Qt).
+ * If specified format is not available, default format will be used.
+ * Default format is JPEG or first of supported, if JPEG is not available.
+ * \return Really set format. Differ from \a theFormat if \a theFormat is not available.
+ */
+ string setDumpFormat(in string theFormat);
+
/*! Returns True, if the playback of the animation is cycling.
*/
boolean isCycling();
#include <qhbox.h>
#include <qgrid.h>
+#include <qimage.h>
#include <qlayout.h>
#include <qslider.h>
#include <qthread.h>
connect(aPropCheck, SIGNAL(toggled(bool)), myAnimator, SLOT(setProportionalSlot(bool)));
TopLayout->addMultiCellWidget(aPropCheck, 6, 6, 0, 3);
+ // Pictures saving on disk
QGroupBox* aSaveBox = new QGroupBox( "Saving", myPlayFrame );
aSaveBox->setColumnLayout(0, Qt::Horizontal );
QGridLayout* aSaveLay = new QGridLayout(aSaveBox->layout());
mySaveCheck = new QCheckBox("Save pictures to directory", aSaveBox);
aSaveLay->addMultiCellWidget(mySaveCheck, 0, 0, 0, 2);
+
+ QLabel* aFormatLbl = new QLabel("Saving format:", aSaveBox);
+ aFormatLbl->setEnabled(false);
+ connect(mySaveCheck, SIGNAL( toggled(bool)),
+ aFormatLbl, SLOT( setEnabled(bool) ));
+ aSaveLay->addMultiCellWidget(aFormatLbl, 1, 1, 0, 1);
+
+ myPicsFormat = new QComboBox(aSaveBox);
+ QStrList aDumpFormats = QImageIO::outputFormats();
+ for (unsigned int i = 0; i < aDumpFormats.count(); i++) {
+ myPicsFormat->insertItem(aDumpFormats.at(i));
+ }
+ if (aDumpFormats.find("JPEG"))
+ myPicsFormat->setCurrentItem(aDumpFormats.find("JPEG"));
+ else
+ myPicsFormat->setCurrentItem(0);
+ myPicsFormat->setEnabled(false);
+ aSaveLay->addWidget(myPicsFormat, 1, 2);
connect(mySaveCheck, SIGNAL( toggled(bool)),
- aWheel, SLOT( setDisabled(bool) ));
+ myPicsFormat, SLOT( setEnabled(bool) ));
QLabel* aPathLbl = new QLabel("Path:", aSaveBox);
aPathLbl->setEnabled(false);
connect(mySaveCheck, SIGNAL( toggled(bool)),
- aPathLbl, SLOT( setEnabled(bool) ));
- aSaveLay->addWidget(aPathLbl, 1, 0);
+ aPathLbl, SLOT( setEnabled(bool) ));
+ aSaveLay->addWidget(aPathLbl, 2, 0);
myPathEdit = new QLineEdit(aSaveBox);
myPathEdit->setReadOnly(true);
myPathEdit->setEnabled(false);
connect(mySaveCheck, SIGNAL( toggled(bool)),
- myPathEdit, SLOT( setEnabled(bool) ));
- aSaveLay->addWidget(myPathEdit, 1, 1);
+ myPathEdit, SLOT( setEnabled(bool) ));
+ aSaveLay->addWidget(myPathEdit, 2, 1);
QPushButton* aBrowseBtn = new QPushButton("Browse...", aSaveBox);
aBrowseBtn->setEnabled(false);
connect(aBrowseBtn, SIGNAL( clicked()),
this, SLOT( onBrowse() ));
mySaveCheck->setChecked(false);
- aSaveLay->addWidget(aBrowseBtn, 1, 2);
+ aSaveLay->addWidget(aBrowseBtn, 2, 2);
TopLayout->addMultiCellWidget(aSaveBox, 7, 7, 0, 3);
aMainLayout->addWidget(myPlayFrame);
+ // Animation publishing in study
QHBox* aPublishBox = new QHBox(this);
aPublishBox->setSpacing(5);
{
if (myPlayBtn->isOn() && (!myAnimator->running())) {
myPlayBtn->setIconSet(MYpausePixmap);
- if (mySaveCheck->isChecked())
+ if (mySaveCheck->isChecked()) {
+ QStrList aDumpFormats = QImageIO::outputFormats();
+ myAnimator->setDumpFormat(aDumpFormats.at(myPicsFormat->currentItem()));
myAnimator->dumpTo(myPathEdit->text());
- else
+ } else {
myAnimator->dumpTo("");
+ }
mySetupBtn->setEnabled(false);
myGenBtn->setEnabled(false);
myAnimator->startAnimation();
#include "SALOMEDSClient_AttributeName.hxx"
#include <qpixmap.h>
+#include <qimage.h>
+#include <qstrlist.h>
using namespace std;
}
myView->Repaint(false);
+ k = 1;
+ if (myProportional) {
+ switch (myFrame) {
+ case 0:
+ break;
+ case 1:
+ if (myFieldsLst[0].myNbFrames > 2)
+ k = (myFieldsLst[0].myTiming[myFrame+1] -
+ myFieldsLst[0].myTiming[myFrame]) / aOneVal;
+ break;
+ default:
+ if (myFrame < (myFieldsLst[0].myNbFrames - 1))
+ k = (myFieldsLst[0].myTiming[myFrame+1] -
+ myFieldsLst[0].myTiming[myFrame]) / aOneVal;
+ }
+ }
+ int delay = (int)(1000. * k / mySpeed);
+ if (delay < 1 && isDumping) {
+ // We must unlock mutex for some time before grabbing to allow view updating
+ delay = 1;
+ }
+ qApp->unlock();
+ msleep(delay);
+ qApp->lock();
+
if (isDumping) {
// We must unlock mutex for some time before grabbing to allow view updating
qApp->unlock();
while ((aPos = aName.find(".")) > -1 )
aName.replace(aPos, 1, "_");
aFile += aName;
- aFile += ".jpeg";
- px.save(aFile, "JPEG");
- } else {
- k = 1;
- if (myProportional) {
- switch (myFrame) {
- case 0:
- break;
- case 1:
- if (myFieldsLst[0].myNbFrames > 2)
- k = (myFieldsLst[0].myTiming[myFrame+1] -
- myFieldsLst[0].myTiming[myFrame]) / aOneVal;
- break;
- default:
- if (myFrame < (myFieldsLst[0].myNbFrames - 1))
- k = (myFieldsLst[0].myTiming[myFrame+1] -
- myFieldsLst[0].myTiming[myFrame]) / aOneVal;
- }
- }
- int delay = (int)(1000. * k / mySpeed);
- qApp->unlock();
- msleep(delay);
- qApp->lock();
+ aFile += ".";
+ aFile += myDumpFormat.lower();
+ px.save(aFile, myDumpFormat);
}
if (!myIsActive) break;
mySpeed = (theSpeed<1)? 1 : theSpeed;
}
-//------------------------------------------------------------------------
+std::string VISU_TimeAnimation::setDumpFormat(const char* theFormat)
+{
+ myDumpFormat = theFormat;
+ QStrList aDumpFormats = QImageIO::outputFormats();
+ if (myDumpFormat.isEmpty() || aDumpFormats.find(theFormat) < 0) {
+ if (aDumpFormats.find("JPEG"))
+ myDumpFormat = "JPEG";
+ else
+ myDumpFormat = aDumpFormats.at(0);
+ }
+ return myDumpFormat.latin1();
+}
+
+//************************************************************************
int VISU_TimeAnimation::myNBAnimations = 0;
QString VISU_TimeAnimation::GenerateName()
{
myAnim->dumpTo(thePath);
}
+char* VISU_TimeAnimation_i::setDumpFormat (const char* theFormat)
+{
+ string aDumpFormat = myAnim->setDumpFormat(theFormat);
+ return CORBA::string_dup(aDumpFormat.c_str());
+}
+
CORBA::Boolean VISU_TimeAnimation_i::isCycling()
{
return myAnim->isCycling();