From a21546dd18e5bd8b3b21c9e1e94d7c1e25c7a2bd Mon Sep 17 00:00:00 2001 From: apo Date: Fri, 13 Jan 2006 06:30:54 +0000 Subject: [PATCH] Adjust to OCC_development_generic_2006 --- idl/VISU_Gen.idl | 16 ++++-- src/VISUGUI/VisuGUI_TimeAnimation.cxx | 40 ++++++++++++--- src/VISUGUI/VisuGUI_TimeAnimation.h | 1 + src/VISU_I/VISU_TimeAnimation.cxx | 74 ++++++++++++++++++--------- src/VISU_I/VISU_TimeAnimation.h | 3 ++ 5 files changed, 99 insertions(+), 35 deletions(-) diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index e00e0600..79237353 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -1182,8 +1182,8 @@ module VISU { * 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); @@ -1202,10 +1202,20 @@ module VISU { 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 setDumpFormat(). + * \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(); diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index a3523965..4d46d01d 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -51,6 +51,7 @@ #include #include +#include #include #include #include @@ -1014,6 +1015,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()); @@ -1022,21 +1024,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); @@ -1045,12 +1065,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); @@ -1140,10 +1161,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/VISUGUI/VisuGUI_TimeAnimation.h b/src/VISUGUI/VisuGUI_TimeAnimation.h index cfb3401e..53191604 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.h +++ b/src/VISUGUI/VisuGUI_TimeAnimation.h @@ -172,6 +172,7 @@ class VisuGUI_TimeAnimationDlg: public QDialog VISU_TimeAnimation* myAnimator; QCheckBox* mySaveCheck; + QComboBox* myPicsFormat; QLineEdit* myPathEdit; bool isClosing; QCloseEvent* myEvent; diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index 11c0e3f3..ff511dba 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -43,6 +43,8 @@ #include "SALOMEDSClient_AttributeName.hxx" #include +#include +#include using namespace std; @@ -505,6 +507,31 @@ void VISU_TimeAnimation::run() } 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(); @@ -518,29 +545,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; @@ -609,7 +616,20 @@ 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() { @@ -1035,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(); diff --git a/src/VISU_I/VISU_TimeAnimation.h b/src/VISU_I/VISU_TimeAnimation.h index ab1242ab..315415c8 100644 --- a/src/VISU_I/VISU_TimeAnimation.h +++ b/src/VISU_I/VISU_TimeAnimation.h @@ -100,6 +100,7 @@ class VISU_TimeAnimation: public QObject, public QThread CORBA::Boolean isRangeDefined() { return !((myMaxVal==0) && (myMinVal == myMaxVal)); } void dumpTo(const char* thePath) { myDumpPath = thePath; } + std::string setDumpFormat(const char* theFormat); QString getLastErrorMsg() { return myLastError; } @@ -146,6 +147,7 @@ class VISU_TimeAnimation: public QObject, public QThread double myMaxVal, myMinVal; double myTimeMin, myTimeMax; QString myDumpPath; + QString myDumpFormat; SVTK_ViewWindow* myView; QString myAnimEntry; @@ -203,6 +205,7 @@ public: virtual CORBA::Boolean isRangeDefined(); virtual void dumpTo(const char* thePath); + virtual char* setDumpFormat(const char* theFormat); virtual CORBA::Boolean isCycling(); -- 2.39.2