1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : VVTK_RecorderDlg.cxx
25 // Author : Oleg UVAROV
28 #include "VVTK_RecorderDlg.h"
29 #include "VVTK_Recorder.h"
31 #include "SUIT_FileDlg.h"
32 #include "SUIT_MessageBox.h"
33 #include "SUIT_ResourceMgr.h"
34 #include "SUIT_Session.h"
36 #include "QtxDblSpinBox.h"
37 #include "QtxIntSpinBox.h"
39 #include "LightApp_Application.h"
41 #include <qcheckbox.h>
42 #include <qcombobox.h>
43 #include <qgroupbox.h>
46 #include <qlineedit.h>
47 #include <qpushbutton.h>
52 VVTK_RecorderDlg::VVTK_RecorderDlg( QWidget* theParent, VVTK_Recorder* theRecorder ):
53 QDialog( theParent, "VVTK_RecorderDlg", false ),
54 myRecorder( theRecorder )
56 setCaption( tr( "DLG_RECORDER_TITLE" ) );
58 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
60 QVBoxLayout* aTopLayout = new QVBoxLayout( this );
61 aTopLayout->setSpacing( 6 );
62 aTopLayout->setMargin( 6 );
63 aTopLayout->setAutoAdd( true );
66 QGroupBox* mySettingsBox = new QGroupBox( tr( "SETTINGS" ), this );
67 mySettingsBox->setColumnLayout( 0, Qt::Vertical );
68 mySettingsBox->layout()->setSpacing( 0 );
69 mySettingsBox->layout()->setMargin( 0 );
71 QGridLayout* aSettingsLayout = new QGridLayout( mySettingsBox->layout() );
72 aSettingsLayout->setSpacing( 6 );
73 aSettingsLayout->setMargin( 11 );
75 QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), mySettingsBox );
76 myFileNameLineEdit = new QLineEdit( mySettingsBox );
77 myFileNameLineEdit->setMinimumWidth( 250 );
78 myFileNameLineEdit->setReadOnly( true );
80 QPushButton* aFileNameButton = new QPushButton( mySettingsBox );
81 aFileNameButton->setAutoDefault( false );
82 aFileNameButton->setPixmap( aResourceMgr->loadPixmap( "VISU", tr( "ICON_LOAD_TEXTURE" ) ) );
83 connect( aFileNameButton, SIGNAL( clicked() ), this, SLOT( onBrowseFile() ) );
85 QLabel* aRecordingModeLabel = new QLabel( tr( "RECORDING_MODE" ), mySettingsBox );
86 myRecordingModeComboBox = new QComboBox( mySettingsBox );
87 myRecordingModeComboBox->insertItem( tr( "SKIPPED_FRAMES" ) );
88 myRecordingModeComboBox->insertItem( tr( "ALL_DISLPAYED_FRAMES" ) );
89 myRecordingModeComboBox->setCurrentItem( aResourceMgr->integerValue( "VISU", "recorder_mode", 1 ) );
91 QLabel* aFPSLabel = new QLabel( tr( "FPS" ), mySettingsBox );
92 myFPSSpinBox = new QtxDblSpinBox( 0.1, 100.0, 1.0, mySettingsBox );
93 myFPSSpinBox->setValue( aResourceMgr->doubleValue( "VISU", "recorder_fps", 10.0 ) );
95 QLabel* aQualityLabel = new QLabel( tr( "QUALITY" ), mySettingsBox );
96 myQualitySpinBox = new QtxIntSpinBox( 1, 100, 1, mySettingsBox );
97 myQualitySpinBox->setValue( aResourceMgr->integerValue( "VISU", "recorder_quality", 80 ) );
99 myProgressiveCheckBox = new QCheckBox( tr( "PROGRESSIVE" ), mySettingsBox );
100 myProgressiveCheckBox->setChecked( aResourceMgr->booleanValue( "VISU", "recorder_progressive", false ) );
102 aSettingsLayout->addWidget( aFileNameLabel, 0, 0 );
103 aSettingsLayout->addMultiCellWidget( myFileNameLineEdit, 1, 1, 0, 1 );
104 //aSettingsLayout->addWidget( aFileNameButton, 1, 2 );
105 aSettingsLayout->addWidget( aRecordingModeLabel, 2, 0 );
106 aSettingsLayout->addWidget( myRecordingModeComboBox, 2, 1 );
107 aSettingsLayout->addWidget( aFPSLabel, 3, 0 );
108 aSettingsLayout->addWidget( myFPSSpinBox, 3, 1 );
109 aSettingsLayout->addWidget( aQualityLabel, 4, 0 );
110 aSettingsLayout->addWidget( myQualitySpinBox, 4, 1 );
111 aSettingsLayout->addWidget( myProgressiveCheckBox, 5, 0 );
114 QGroupBox* CommonGroup = new QGroupBox( this );
115 CommonGroup->setColumnLayout(0, Qt::Vertical );
116 CommonGroup->layout()->setSpacing( 0 );
117 CommonGroup->layout()->setMargin( 0 );
118 QGridLayout* CommonGroupLayout = new QGridLayout( CommonGroup->layout() );
119 CommonGroupLayout->setAlignment( Qt::AlignTop );
120 CommonGroupLayout->setSpacing( 6 );
121 CommonGroupLayout->setMargin( 11 );
123 QPushButton* aStartButton = new QPushButton( tr( "START" ), CommonGroup );
124 aStartButton->setAutoDefault( true );
125 aStartButton->setDefault( true );
126 CommonGroupLayout->addWidget( aStartButton, 0, 0 );
127 CommonGroupLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
129 QPushButton* aCloseButton = new QPushButton( tr( "CLOSE" ), CommonGroup );
130 aCloseButton->setAutoDefault( true );
131 CommonGroupLayout->addWidget( aCloseButton, 0, 2 );
133 QPushButton* aHelpButton = new QPushButton( tr( "HELP" ), CommonGroup );
134 aHelpButton->setAutoDefault( true );
135 CommonGroupLayout->addWidget( aHelpButton, 0, 3 );
137 connect( aStartButton, SIGNAL( clicked() ), this, SLOT( onStart() ) );
138 connect( aCloseButton, SIGNAL( clicked() ), this, SLOT( onClose() ) );
139 connect( aHelpButton, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
142 VVTK_RecorderDlg::~VVTK_RecorderDlg()
146 void VVTK_RecorderDlg::show()
152 void VVTK_RecorderDlg::onStart()
154 if( myFileName.isNull() )
157 myRecorder->SetName( myFileName.latin1() );
159 myRecorder->SetUseSkippedFrames( myRecordingModeComboBox->currentItem() == 0 );
160 myRecorder->SetNbFPS( myFPSSpinBox->value() );
161 myRecorder->SetQuality( myQualitySpinBox->value() );
162 myRecorder->SetProgressiveMode( myProgressiveCheckBox->isChecked() );
168 void VVTK_RecorderDlg::onClose()
173 void VVTK_RecorderDlg::onHelp()
175 QString aHelpFileName = "animation_in_gauss_viewer.htm";
176 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
178 app->onHelpContextModule(app->activeModule() ? app->moduleName(app->activeModule()->moduleName()) : QString(""), aHelpFileName);
180 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
181 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
182 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName),
183 QObject::tr("BUT_OK"));
187 bool VVTK_RecorderDlg::onBrowseFile()
189 QString aRootDir = QString( getenv( "VISU_ROOT_DIR") );
192 aFilter.append( tr( "FLT_AVI_FILES" ) );
193 aFilter.append( tr( "FLT_ALL_FILES" ) );
195 QString aFileName = SUIT_FileDlg::getFileName( this, getenv( "HOME" ), aFilter,
196 tr( "FILE_NAME" ), false );
198 if( aFileName.isNull() )
201 myFileName = aFileName;
202 myFileNameLineEdit->setText( aFileName.section( '/', -1 ) );