From: jfa Date: Wed, 11 Jan 2006 13:13:14 +0000 (+0000) Subject: PAL11083: Can't change the animation speed when saving pictures; PAL11086: Poor quali... X-Git-Tag: T_Before_Join_BR-D5-38-2003~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=10400cea6abf83ad14b2c24b694ff94d1cfa823c;p=modules%2Fvisu.git PAL11083: Can't change the animation speed when saving pictures; PAL11086: Poor quality of the saved pictures. --- diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index 12ce55ee..0918a05e 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -49,6 +49,7 @@ #include #include +#include #include #include #include @@ -1000,6 +1001,7 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule, _PTR(Stu 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()); @@ -1008,21 +1010,39 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule, _PTR(Stu 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); @@ -1031,12 +1051,13 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule, _PTR(Stu 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); @@ -1126,10 +1147,13 @@ void VisuGUI_TimeAnimationDlg::onPlayPressed() { 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(); diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index e9a04037..c16e1f87 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -42,6 +42,8 @@ #include "SALOMEDSClient_AttributeName.hxx" #include +#include +#include using namespace std; @@ -515,12 +517,32 @@ void VISU_TimeAnimation::run() } 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]); @@ -528,29 +550,9 @@ void VISU_TimeAnimation::run() 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; @@ -619,6 +621,19 @@ void VISU_TimeAnimation::setSpeed(CORBA::Long theSpeed) 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() @@ -1040,6 +1055,12 @@ void VISU_TimeAnimation_i::dumpTo (const char* thePath) 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();