1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "SVTK_RecorderDlg.h"
23 #include "SVTK_Recorder.h"
25 #include <SUIT_FileDlg.h>
26 #include <SUIT_MessageBox.h>
27 #include <SUIT_ResourceMgr.h>
28 #include <SUIT_Session.h>
30 #include <QtxDoubleSpinBox.h>
31 #include <QtxIntSpinBox.h>
40 #include <QPushButton>
45 SVTK_RecorderDlg::SVTK_RecorderDlg( QWidget* theParent, SVTK_Recorder* theRecorder ):
47 myRecorder( theRecorder )
49 setWindowTitle( tr( "DLG_RECORDER_TITLE" ) );
51 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
53 QVBoxLayout* aTopLayout = new QVBoxLayout( this );
54 aTopLayout->setSpacing( 6 );
55 aTopLayout->setMargin( 6 );
58 QGroupBox* mySettingsBox = new QGroupBox( tr( "SETTINGS" ), this );
60 QGridLayout* aSettingsLayout = new QGridLayout( mySettingsBox );
61 aSettingsLayout->setSpacing( 6 );
62 aSettingsLayout->setMargin( 11 );
64 QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), mySettingsBox );
65 myFileNameLineEdit = new QLineEdit( mySettingsBox );
66 myFileNameLineEdit->setMinimumWidth( 250 );
67 myFileNameLineEdit->setReadOnly( true );
69 QLabel* aRecordingModeLabel = new QLabel( tr( "RECORDING_MODE" ), mySettingsBox );
70 myRecordingModeComboBox = new QComboBox( mySettingsBox );
71 myRecordingModeComboBox->addItem( tr( "SKIPPED_FRAMES" ) );
72 myRecordingModeComboBox->addItem( tr( "ALL_DISLPAYED_FRAMES" ) );
73 myRecordingModeComboBox->setCurrentIndex( aResourceMgr->integerValue( "VTKViewer", "recorder_mode", 1 ) );
75 QLabel* aFPSLabel = new QLabel( tr( "FPS" ), mySettingsBox );
76 myFPSSpinBox = new QtxDoubleSpinBox( 0.1, 100.0, 1.0, mySettingsBox );
77 myFPSSpinBox->setValue( aResourceMgr->doubleValue( "VTKViewer", "recorder_fps", 10.0 ) );
79 QLabel* aQualityLabel = new QLabel( tr( "QUALITY" ), mySettingsBox );
80 myQualitySpinBox = new QtxIntSpinBox( 1, 100, 1, mySettingsBox );
81 myQualitySpinBox->setValue( aResourceMgr->integerValue( "VTKViewer", "recorder_quality", 80 ) );
83 myProgressiveCheckBox = new QCheckBox( tr( "PROGRESSIVE" ), mySettingsBox );
84 myProgressiveCheckBox->setChecked( aResourceMgr->booleanValue( "VTKViewer", "recorder_progressive", false ) );
86 aSettingsLayout->addWidget( aFileNameLabel, 0, 0 );
87 aSettingsLayout->addWidget( myFileNameLineEdit, 1, 0, 1, 2 );
88 aSettingsLayout->addWidget( aRecordingModeLabel, 2, 0 );
89 aSettingsLayout->addWidget( myRecordingModeComboBox, 2, 1 );
90 aSettingsLayout->addWidget( aFPSLabel, 3, 0 );
91 aSettingsLayout->addWidget( myFPSSpinBox, 3, 1 );
92 aSettingsLayout->addWidget( aQualityLabel, 4, 0 );
93 aSettingsLayout->addWidget( myQualitySpinBox, 4, 1 );
94 aSettingsLayout->addWidget( myProgressiveCheckBox, 5, 0 );
96 aTopLayout->addWidget( mySettingsBox );
99 QGroupBox* CommonGroup = new QGroupBox( this );
100 QGridLayout* CommonGroupLayout = new QGridLayout( CommonGroup );
101 CommonGroupLayout->setAlignment( Qt::AlignTop );
102 CommonGroupLayout->setSpacing( 6 );
103 CommonGroupLayout->setMargin( 11 );
105 QPushButton* aStartButton = new QPushButton( tr( "START" ), CommonGroup );
106 aStartButton->setAutoDefault( true );
107 aStartButton->setDefault( true );
108 CommonGroupLayout->addWidget( aStartButton, 0, 0 );
109 CommonGroupLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
111 QPushButton* aCloseButton = new QPushButton( tr( "CLOSE" ), CommonGroup );
112 aCloseButton->setAutoDefault( true );
113 CommonGroupLayout->addWidget( aCloseButton, 0, 2 );
115 //QPushButton* aHelpButton = new QPushButton( tr( "HELP" ), CommonGroup );
116 //aHelpButton->setAutoDefault( true );
117 //CommonGroupLayout->addWidget( aHelpButton, 0, 3 );
119 aTopLayout->addWidget( CommonGroup );
121 connect( aStartButton, SIGNAL( clicked() ), this, SLOT( onStart() ) );
122 connect( aCloseButton, SIGNAL( clicked() ), this, SLOT( onClose() ) );
123 //connect( aHelpButton, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
126 SVTK_RecorderDlg::~SVTK_RecorderDlg()
130 void SVTK_RecorderDlg::onStart()
132 if( myFileName.isNull() )
135 myRecorder->SetName( (const char*)myFileName.toLatin1() );
137 myRecorder->SetUseSkippedFrames( myRecordingModeComboBox->currentIndex() == 0 );
138 myRecorder->SetNbFPS( myFPSSpinBox->value() );
139 myRecorder->SetQuality( myQualitySpinBox->value() );
140 myRecorder->SetProgressiveMode( myProgressiveCheckBox->isChecked() );
146 void SVTK_RecorderDlg::onClose()
151 void SVTK_RecorderDlg::onHelp()
154 QString aHelpFileName = "animation_in_gauss_viewer.htm";
155 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
157 app->onHelpContextModule(app->activeModule() ? app->moduleName(app->activeModule()->moduleName()) : QString(""), aHelpFileName);
161 platform = "winapplication";
163 platform = "application";
165 SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
166 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
167 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName) );
172 bool SVTK_RecorderDlg::onBrowseFile()
175 aFilter.append( tr( "FLT_AVI_FILES" ) );
176 aFilter.append( tr( "FLT_ALL_FILES" ) );
178 QString aFileName = SUIT_FileDlg::getFileName( this, getenv( "HOME" ), aFilter,
179 tr( "FILE_NAME" ), false );
181 if( aFileName.isNull() )
184 myFileName = aFileName;
185 myFileNameLineEdit->setText( aFileName.section( '/', -1 ) );
190 int SVTK_RecorderDlg::exec()
192 if( !onBrowseFile() )
197 return QDialog::exec();
200 void SVTK_RecorderDlg::keyPressEvent( QKeyEvent* e )
202 QDialog::keyPressEvent( e );
203 if ( e->isAccepted() )
206 if ( e->key() == Qt::Key_F1 )