#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);
- if (isDumping) {
+ 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
- qApp->unlock();
- msleep(100);
- qApp->lock();
+ delay = 1;
+ }
+ qApp->unlock();
+ msleep(delay);
+ qApp->lock();
+ if (isDumping) {
QPixmap px = QPixmap::grabWindow(myView->winId());
QString aFile(myDumpPath);
QString aName = QString("%1").arg(myFieldsLst[0].myTiming[myFrame]);
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();