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 // VISU VISUGUI : GUI of VISU component
23 // File : VVTK_RecorderDlg.cxx
24 // Author : Oleg UVAROV
27 #include "VVTK_RecorderDlg.h"
28 #include "VVTK_Recorder.h"
30 #include "SUIT_FileDlg.h"
31 #include "SUIT_MessageBox.h"
32 #include "SUIT_ResourceMgr.h"
33 #include "SUIT_Session.h"
35 #include "QtxDoubleSpinBox.h"
36 #include "QtxIntSpinBox.h"
38 #include "LightApp_Application.h"
40 #include "CAM_Module.h"
49 #include <QPushButton>
54 VVTK_RecorderDlg::VVTK_RecorderDlg( QWidget* theParent, VVTK_Recorder* theRecorder ):
56 myRecorder( theRecorder )
58 setWindowTitle( tr( "DLG_RECORDER_TITLE" ) );
60 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
62 QVBoxLayout* aTopLayout = new QVBoxLayout( this );
63 aTopLayout->setSpacing( 6 );
64 aTopLayout->setMargin( 6 );
65 //aTopLayout->setAutoAdd( true );
68 QGroupBox* mySettingsBox = new QGroupBox( tr( "SETTINGS" ), this );
69 //mySettingsBox->setColumnLayout( 0, Qt::Vertical );
70 //mySettingsBox->layout()->setSpacing( 0 );
71 //mySettingsBox->layout()->setMargin( 0 );
73 QGridLayout* aSettingsLayout = new QGridLayout( mySettingsBox );
74 aSettingsLayout->setSpacing( 6 );
75 aSettingsLayout->setMargin( 11 );
77 QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), mySettingsBox );
78 myFileNameLineEdit = new QLineEdit( mySettingsBox );
79 myFileNameLineEdit->setMinimumWidth( 250 );
80 myFileNameLineEdit->setReadOnly( true );
82 QLabel* aRecordingModeLabel = new QLabel( tr( "RECORDING_MODE" ), mySettingsBox );
83 myRecordingModeComboBox = new QComboBox( mySettingsBox );
84 myRecordingModeComboBox->addItem( tr( "SKIPPED_FRAMES" ) );
85 myRecordingModeComboBox->addItem( tr( "ALL_DISLPAYED_FRAMES" ) );
86 myRecordingModeComboBox->setCurrentIndex( aResourceMgr->integerValue( "VISU", "recorder_mode", 1 ) );
88 QLabel* aFPSLabel = new QLabel( tr( "FPS" ), mySettingsBox );
89 myFPSSpinBox = new QtxDoubleSpinBox( 0.1, 100.0, 1.0, mySettingsBox );
90 myFPSSpinBox->setValue( aResourceMgr->doubleValue( "VISU", "recorder_fps", 10.0 ) );
92 QLabel* aQualityLabel = new QLabel( tr( "QUALITY" ), mySettingsBox );
93 myQualitySpinBox = new QtxIntSpinBox( 1, 100, 1, mySettingsBox );
94 myQualitySpinBox->setValue( aResourceMgr->integerValue( "VISU", "recorder_quality", 80 ) );
96 myProgressiveCheckBox = new QCheckBox( tr( "PROGRESSIVE" ), mySettingsBox );
97 myProgressiveCheckBox->setChecked( aResourceMgr->booleanValue( "VISU", "recorder_progressive", false ) );
99 aSettingsLayout->addWidget( aFileNameLabel, 0, 0 );
100 aSettingsLayout->addWidget( myFileNameLineEdit, 1, 0, 1, 2 );
101 //aSettingsLayout->addWidget( aFileNameButton, 1, 2 );
102 aSettingsLayout->addWidget( aRecordingModeLabel, 2, 0 );
103 aSettingsLayout->addWidget( myRecordingModeComboBox, 2, 1 );
104 aSettingsLayout->addWidget( aFPSLabel, 3, 0 );
105 aSettingsLayout->addWidget( myFPSSpinBox, 3, 1 );
106 aSettingsLayout->addWidget( aQualityLabel, 4, 0 );
107 aSettingsLayout->addWidget( myQualitySpinBox, 4, 1 );
108 aSettingsLayout->addWidget( myProgressiveCheckBox, 5, 0 );
110 aTopLayout->addWidget( mySettingsBox );
113 QGroupBox* CommonGroup = new QGroupBox( this );
114 //CommonGroup->setColumnLayout(0, Qt::Vertical );
115 //CommonGroup->layout()->setSpacing( 0 );
116 //CommonGroup->layout()->setMargin( 0 );
117 QGridLayout* CommonGroupLayout = new QGridLayout( CommonGroup );
118 CommonGroupLayout->setAlignment( Qt::AlignTop );
119 CommonGroupLayout->setSpacing( 6 );
120 CommonGroupLayout->setMargin( 11 );
122 QPushButton* aStartButton = new QPushButton( tr( "START" ), CommonGroup );
123 aStartButton->setAutoDefault( true );
124 aStartButton->setDefault( true );
125 CommonGroupLayout->addWidget( aStartButton, 0, 0 );
126 CommonGroupLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
128 QPushButton* aCloseButton = new QPushButton( tr( "CLOSE" ), CommonGroup );
129 aCloseButton->setAutoDefault( true );
130 CommonGroupLayout->addWidget( aCloseButton, 0, 2 );
132 QPushButton* aHelpButton = new QPushButton( tr( "HELP" ), CommonGroup );
133 aHelpButton->setAutoDefault( true );
134 CommonGroupLayout->addWidget( aHelpButton, 0, 3 );
136 aTopLayout->addWidget( CommonGroup );
138 connect( aStartButton, SIGNAL( clicked() ), this, SLOT( onStart() ) );
139 connect( aCloseButton, SIGNAL( clicked() ), this, SLOT( onClose() ) );
140 connect( aHelpButton, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
143 VVTK_RecorderDlg::~VVTK_RecorderDlg()
147 void VVTK_RecorderDlg::onStart()
149 if( myFileName.isNull() )
152 myRecorder->SetName( (const char*)myFileName.toLatin1() );
154 myRecorder->SetUseSkippedFrames( myRecordingModeComboBox->currentIndex() == 0 );
155 myRecorder->SetNbFPS( myFPSSpinBox->value() );
156 myRecorder->SetQuality( myQualitySpinBox->value() );
157 myRecorder->SetProgressiveMode( myProgressiveCheckBox->isChecked() );
163 void VVTK_RecorderDlg::onClose()
168 void VVTK_RecorderDlg::onHelp()
170 QString aHelpFileName = "animation_in_gauss_viewer.htm";
171 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
173 app->onHelpContextModule(app->activeModule() ? app->moduleName(app->activeModule()->moduleName()) : QString(""), aHelpFileName);
177 platform = "winapplication";
179 platform = "application";
181 SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
182 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
183 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName) );
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 ) );
207 int VVTK_RecorderDlg::exec()
209 if( !onBrowseFile() )
214 return QDialog::exec();
217 void VVTK_RecorderDlg::keyPressEvent( QKeyEvent* e )
219 QDialog::keyPressEvent( e );
220 if ( e->isAccepted() )
223 if ( e->key() == Qt::Key_F1 )