1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "SVTK_RecorderDlg.h"
21 #include "SVTK_Recorder.h"
23 #include <SUIT_FileDlg.h>
24 #include <SUIT_MessageBox.h>
25 #include <SUIT_ResourceMgr.h>
26 #include <SUIT_Session.h>
28 #include <QtxDoubleSpinBox.h>
29 #include <QtxIntSpinBox.h>
38 #include <QPushButton>
43 SVTK_RecorderDlg::SVTK_RecorderDlg( QWidget* theParent, SVTK_Recorder* theRecorder ):
45 myRecorder( theRecorder )
47 setWindowTitle( tr( "DLG_RECORDER_TITLE" ) );
49 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
51 QVBoxLayout* aTopLayout = new QVBoxLayout( this );
52 aTopLayout->setSpacing( 6 );
53 aTopLayout->setMargin( 6 );
56 QGroupBox* mySettingsBox = new QGroupBox( tr( "SETTINGS" ), this );
58 QGridLayout* aSettingsLayout = new QGridLayout( mySettingsBox );
59 aSettingsLayout->setSpacing( 6 );
60 aSettingsLayout->setMargin( 11 );
62 QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), mySettingsBox );
63 myFileNameLineEdit = new QLineEdit( mySettingsBox );
64 myFileNameLineEdit->setMinimumWidth( 250 );
65 myFileNameLineEdit->setReadOnly( true );
67 QLabel* aRecordingModeLabel = new QLabel( tr( "RECORDING_MODE" ), mySettingsBox );
68 myRecordingModeComboBox = new QComboBox( mySettingsBox );
69 myRecordingModeComboBox->addItem( tr( "SKIPPED_FRAMES" ) );
70 myRecordingModeComboBox->addItem( tr( "ALL_DISLPAYED_FRAMES" ) );
71 myRecordingModeComboBox->setCurrentIndex( aResourceMgr->integerValue( "VTKViewer", "recorder_mode", 1 ) );
73 QLabel* aFPSLabel = new QLabel( tr( "FPS" ), mySettingsBox );
74 myFPSSpinBox = new QtxDoubleSpinBox( 0.1, 100.0, 1.0, mySettingsBox );
75 myFPSSpinBox->setValue( aResourceMgr->doubleValue( "VTKViewer", "recorder_fps", 10.0 ) );
77 QLabel* aQualityLabel = new QLabel( tr( "QUALITY" ), mySettingsBox );
78 myQualitySpinBox = new QtxIntSpinBox( 1, 100, 1, mySettingsBox );
79 myQualitySpinBox->setValue( aResourceMgr->integerValue( "VTKViewer", "recorder_quality", 80 ) );
81 myProgressiveCheckBox = new QCheckBox( tr( "PROGRESSIVE" ), mySettingsBox );
82 myProgressiveCheckBox->setChecked( aResourceMgr->booleanValue( "VTKViewer", "recorder_progressive", false ) );
84 aSettingsLayout->addWidget( aFileNameLabel, 0, 0 );
85 aSettingsLayout->addWidget( myFileNameLineEdit, 1, 0, 1, 2 );
86 aSettingsLayout->addWidget( aRecordingModeLabel, 2, 0 );
87 aSettingsLayout->addWidget( myRecordingModeComboBox, 2, 1 );
88 aSettingsLayout->addWidget( aFPSLabel, 3, 0 );
89 aSettingsLayout->addWidget( myFPSSpinBox, 3, 1 );
90 aSettingsLayout->addWidget( aQualityLabel, 4, 0 );
91 aSettingsLayout->addWidget( myQualitySpinBox, 4, 1 );
92 aSettingsLayout->addWidget( myProgressiveCheckBox, 5, 0 );
94 aTopLayout->addWidget( mySettingsBox );
97 QGroupBox* CommonGroup = new QGroupBox( this );
98 QGridLayout* CommonGroupLayout = new QGridLayout( CommonGroup );
99 CommonGroupLayout->setAlignment( Qt::AlignTop );
100 CommonGroupLayout->setSpacing( 6 );
101 CommonGroupLayout->setMargin( 11 );
103 QPushButton* aStartButton = new QPushButton( tr( "START" ), CommonGroup );
104 aStartButton->setAutoDefault( true );
105 aStartButton->setDefault( true );
106 CommonGroupLayout->addWidget( aStartButton, 0, 0 );
107 CommonGroupLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
109 QPushButton* aCloseButton = new QPushButton( tr( "CLOSE" ), CommonGroup );
110 aCloseButton->setAutoDefault( true );
111 CommonGroupLayout->addWidget( aCloseButton, 0, 2 );
113 //QPushButton* aHelpButton = new QPushButton( tr( "HELP" ), CommonGroup );
114 //aHelpButton->setAutoDefault( true );
115 //CommonGroupLayout->addWidget( aHelpButton, 0, 3 );
117 aTopLayout->addWidget( CommonGroup );
119 connect( aStartButton, SIGNAL( clicked() ), this, SLOT( onStart() ) );
120 connect( aCloseButton, SIGNAL( clicked() ), this, SLOT( onClose() ) );
121 //connect( aHelpButton, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
124 SVTK_RecorderDlg::~SVTK_RecorderDlg()
128 void SVTK_RecorderDlg::onStart()
130 if( myFileName.isNull() )
133 myRecorder->SetName( (const char*)myFileName.toLatin1() );
135 myRecorder->SetUseSkippedFrames( myRecordingModeComboBox->currentIndex() == 0 );
136 myRecorder->SetNbFPS( myFPSSpinBox->value() );
137 myRecorder->SetQuality( myQualitySpinBox->value() );
138 myRecorder->SetProgressiveMode( myProgressiveCheckBox->isChecked() );
144 void SVTK_RecorderDlg::onClose()
149 void SVTK_RecorderDlg::onHelp()
152 QString aHelpFileName = "animation_in_gauss_viewer.htm";
153 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
155 app->onHelpContextModule(app->activeModule() ? app->moduleName(app->activeModule()->moduleName()) : QString(""), aHelpFileName);
159 platform = "winapplication";
161 platform = "application";
163 SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
164 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
165 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName) );
170 bool SVTK_RecorderDlg::onBrowseFile()
173 aFilter.append( tr( "FLT_AVI_FILES" ) );
174 aFilter.append( tr( "FLT_ALL_FILES" ) );
176 QString aFileName = SUIT_FileDlg::getFileName( this, getenv( "HOME" ), aFilter,
177 tr( "FILE_NAME" ), false );
179 if( aFileName.isNull() )
182 myFileName = aFileName;
183 myFileNameLineEdit->setText( aFileName.section( '/', -1 ) );
188 int SVTK_RecorderDlg::exec()
190 if( !onBrowseFile() )
195 return QDialog::exec();
198 void SVTK_RecorderDlg::keyPressEvent( QKeyEvent* e )
200 QDialog::keyPressEvent( e );
201 if ( e->isAccepted() )
204 if ( e->key() == Qt::Key_F1 )