1 // Copyright (C) 2007-2024 CEA, EDF, 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, or (at your option) any later version.
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>
30 #include <QtxDoubleSpinBox.h>
31 #include <QtxIntSpinBox.h>
40 #include <QPushButton>
46 SVTK_RecorderDlg::SVTK_RecorderDlg( QWidget* theParent, SVTK_Recorder* theRecorder ):
48 myRecorder( theRecorder )
50 setWindowTitle( tr( "DLG_RECORDER_TITLE" ) );
52 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
54 QVBoxLayout* aTopLayout = new QVBoxLayout( this );
55 aTopLayout->setSpacing( 6 );
56 aTopLayout->setMargin( 6 );
59 QGroupBox* mySettingsBox = new QGroupBox( tr( "SETTINGS" ), this );
61 QGridLayout* aSettingsLayout = new QGridLayout( mySettingsBox );
62 aSettingsLayout->setSpacing( 6 );
63 aSettingsLayout->setMargin( 11 );
65 QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), mySettingsBox );
66 myFileNameLineEdit = new QLineEdit( mySettingsBox );
67 myFileNameLineEdit->setMinimumWidth( 250 );
68 myFileNameLineEdit->setReadOnly( true );
70 QLabel* aRecordingModeLabel = new QLabel( tr( "RECORDING_MODE" ), mySettingsBox );
71 myRecordingModeComboBox = new QComboBox( mySettingsBox );
72 myRecordingModeComboBox->addItem( tr( "SKIPPED_FRAMES" ) );
73 myRecordingModeComboBox->addItem( tr( "ALL_DISLPAYED_FRAMES" ) );
74 myRecordingModeComboBox->setCurrentIndex( aResourceMgr->integerValue( "VTKViewer", "recorder_mode", 1 ) );
76 QLabel* aFPSLabel = new QLabel( tr( "FPS" ), mySettingsBox );
77 myFPSSpinBox = new QtxDoubleSpinBox( 0.1, 100.0, 1.0, mySettingsBox );
78 myFPSSpinBox->setValue( aResourceMgr->doubleValue( "VTKViewer", "recorder_fps", 10.0 ) );
80 QLabel* aQualityLabel = new QLabel( tr( "QUALITY" ), mySettingsBox );
81 myQualitySpinBox = new QtxIntSpinBox( 1, 100, 1, mySettingsBox );
82 myQualitySpinBox->setValue( aResourceMgr->integerValue( "VTKViewer", "recorder_quality", 80 ) );
84 myProgressiveCheckBox = new QCheckBox( tr( "PROGRESSIVE" ), mySettingsBox );
85 myProgressiveCheckBox->setChecked( aResourceMgr->booleanValue( "VTKViewer", "recorder_progressive", false ) );
87 aSettingsLayout->addWidget( aFileNameLabel, 0, 0 );
88 aSettingsLayout->addWidget( myFileNameLineEdit, 1, 0, 1, 2 );
89 aSettingsLayout->addWidget( aRecordingModeLabel, 2, 0 );
90 aSettingsLayout->addWidget( myRecordingModeComboBox, 2, 1 );
91 aSettingsLayout->addWidget( aFPSLabel, 3, 0 );
92 aSettingsLayout->addWidget( myFPSSpinBox, 3, 1 );
93 aSettingsLayout->addWidget( aQualityLabel, 4, 0 );
94 aSettingsLayout->addWidget( myQualitySpinBox, 4, 1 );
95 aSettingsLayout->addWidget( myProgressiveCheckBox, 5, 0 );
97 aTopLayout->addWidget( mySettingsBox );
100 QGroupBox* CommonGroup = new QGroupBox( this );
101 QGridLayout* CommonGroupLayout = new QGridLayout( CommonGroup );
102 CommonGroupLayout->setAlignment( Qt::AlignTop );
103 CommonGroupLayout->setSpacing( 6 );
104 CommonGroupLayout->setMargin( 11 );
106 QPushButton* aStartButton = new QPushButton( tr( "START" ), CommonGroup );
107 aStartButton->setAutoDefault( true );
108 aStartButton->setDefault( true );
109 CommonGroupLayout->addWidget( aStartButton, 0, 0 );
110 CommonGroupLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
112 QPushButton* aCloseButton = new QPushButton( tr( "CLOSE" ), CommonGroup );
113 aCloseButton->setAutoDefault( true );
114 CommonGroupLayout->addWidget( aCloseButton, 0, 2 );
116 //QPushButton* aHelpButton = new QPushButton( tr( "HELP" ), CommonGroup );
117 //aHelpButton->setAutoDefault( true );
118 //CommonGroupLayout->addWidget( aHelpButton, 0, 3 );
120 aTopLayout->addWidget( CommonGroup );
122 connect( aStartButton, SIGNAL( clicked() ), this, SLOT( onStart() ) );
123 connect( aCloseButton, SIGNAL( clicked() ), this, SLOT( onClose() ) );
124 //connect( aHelpButton, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
127 SVTK_RecorderDlg::~SVTK_RecorderDlg()
131 void SVTK_RecorderDlg::onStart()
133 if( myFileName.isNull() )
136 myRecorder->SetName( (const char*)myFileName.toUtf8() );
138 myRecorder->SetUseSkippedFrames( myRecordingModeComboBox->currentIndex() == 0 );
139 myRecorder->SetNbFPS( myFPSSpinBox->value() );
140 myRecorder->SetQuality( myQualitySpinBox->value() );
141 myRecorder->SetProgressiveMode( myProgressiveCheckBox->isChecked() );
147 void SVTK_RecorderDlg::onClose()
152 void SVTK_RecorderDlg::onHelp()
155 QString aHelpFileName = "animation_in_gauss_viewer.htm";
156 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
158 app->onHelpContextModule(app->activeModule() ? app->moduleName(app->activeModule()->moduleName()) : QString(""), aHelpFileName);
162 platform = "winapplication";
164 platform = "application";
166 SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
167 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
168 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName) );
173 bool SVTK_RecorderDlg::onBrowseFile()
176 aFilter.append( tr( "FLT_AVI_FILES" ) );
177 aFilter.append( tr( "FLT_ALL_FILES" ) );
179 QString aFileName = SUIT_FileDlg::getFileName( this, QDir::homePath(), aFilter,
180 tr( "FILE_NAME" ), false );
182 if( aFileName.isNull() )
185 myFileName = aFileName;
186 myFileNameLineEdit->setText( aFileName.section( '/', -1 ) );
191 int SVTK_RecorderDlg::exec()
193 if( !onBrowseFile() )
198 return QDialog::exec();
201 void SVTK_RecorderDlg::keyPressEvent( QKeyEvent* e )
203 QDialog::keyPressEvent( e );
204 if ( e->isAccepted() )
207 if ( e->key() == Qt::Key_F1 )