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] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/OpenGL/src/G4OpenGLQtMovieDialog.cc (Version 11.3.0) and /visualization/OpenGL/src/G4OpenGLQtMovieDialog.cc (Version 4.1)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 //                                                
 27 //                                                
 28 //                                                
 29                                                   
 30 #include "G4OpenGLQtViewer.hh" // should be fi    
 31                                // some boost S    
 32 #include "G4OpenGLQtMovieDialog.hh"               
 33                                                   
 34 #include <qpushbutton.h>                          
 35 #include <qpalette.h>                             
 36 #include <qlabel.h>                               
 37 #include <qgroupbox.h>                            
 38 #include <qlayout.h>                              
 39 #include <qlineedit.h>                            
 40 #include <qfiledialog.h>                          
 41 #include <qprocess.h>                             
 42                                                   
 43 #ifndef G4GMAKE                                   
 44 #include "moc_G4OpenGLQtMovieDialog.cpp"          
 45 #endif                                            
 46                                                   
 47 // +---------------------------------------+      
 48 // +        Path for encoder               +      
 49 // +  _______                              +      
 50 // + | select| ____________________        +      
 51 // +  -------                              +      
 52 // +        Temp path                      +      
 53 // +  _______                              +      
 54 // + | select| ____________________        +      
 55 // +  -------                              +      
 56 // +                                       +      
 57 // + max number of frames  ________        +      
 58 // + ....                                  +      
 59 // +                                       +      
 60 // +     Label : X frames Saves/Encoding   +      
 61 // +         Cancel        Encode          +      
 62 // +---------------------------------------+      
 63                                                   
 64 G4OpenGLQtMovieDialog::G4OpenGLQtMovieDialog(     
 65  G4OpenGLQtViewer* parentViewer,                  
 66  QWidget* parentw                                 
 67 )                                                 
 68   : QDialog( parentw ),                           
 69     fParentViewer(parentViewer)                   
 70 {                                                 
 71   setModal(false);                                
 72   setWindowTitle( tr( " Save as movie" ));        
 73                                                   
 74                                                   
 75   // global layout                                
 76   QVBoxLayout* globalVLayout = new QVBoxLayout    
 77   globalVLayout->setContentsMargins(10,10,10,1    
 78   globalVLayout->setSpacing(10);                  
 79                                                   
 80   // Encoder group box                            
 81   QGroupBox *encoderGroupBox = new QGroupBox(t    
 82   QVBoxLayout *encoderVGroupBoxLayout = new QV    
 83                                                   
 84   // Encoder Path                                 
 85   QWidget *encoderHBox = new QWidget(encoderGr    
 86   QHBoxLayout *encoderHBoxLayout = new QHBoxLa    
 87   fEncoderPath = new QLineEdit("",encoderHBox)    
 88                                                   
 89   QPushButton *encoderButton = new QPushButton    
 90   encoderButton->setMaximumWidth (30);            
 91                                                   
 92   fEncoderStatus = new QLabel(encoderGroupBox)    
 93                                                   
 94   fEncoderStatus->setWordWrap(true);              
 95   encoderVGroupBoxLayout->setContentsMargins(1    
 96                                                   
 97   fEncoderStatus->setText("");                    
 98                                                   
 99   encoderHBoxLayout->addWidget(fEncoderPath);     
100   encoderHBoxLayout->addWidget(encoderButton);    
101   encoderVGroupBoxLayout->addWidget(encoderHBo    
102   encoderVGroupBoxLayout->addWidget(fEncoderSt    
103                                                   
104   encoderGroupBox->setLayout(encoderVGroupBoxL    
105   globalVLayout->addWidget(encoderGroupBox);      
106                                                   
107   connect( encoderButton, SIGNAL( clicked( ) )    
108                                                   
109                                                   
110   // temp folder group box                        
111   QGroupBox *tempFolderGroupBox = new QGroupBo    
112   QVBoxLayout *tempFolderVGroupBoxLayout = new    
113                                                   
114   // temp folder Path                             
115   QWidget *tempFolderHBox = new QWidget(tempFo    
116   QHBoxLayout *tempFolderHBoxLayout = new QHBo    
117                                                   
118   fTempFolderPath = new QLineEdit("",tempFolde    
119                                                   
120   QPushButton *tempButton = new QPushButton(tr    
121   tempButton->setMaximumWidth (30);               
122                                                   
123   fTempFolderStatus = new QLabel(tempFolderGro    
124   fTempFolderStatus->setWordWrap(true);           
125   tempFolderVGroupBoxLayout->setContentsMargin    
126   fTempFolderStatus->setText("");                 
127                                                   
128   tempFolderHBoxLayout->addWidget(fTempFolderP    
129   tempFolderHBoxLayout->addWidget(tempButton);    
130   tempFolderVGroupBoxLayout->addWidget(tempFol    
131   tempFolderVGroupBoxLayout->addWidget(fTempFo    
132                                                   
133   tempFolderGroupBox->setLayout(tempFolderVGro    
134   globalVLayout->addWidget(tempFolderGroupBox)    
135                                                   
136   connect( tempButton, SIGNAL( clicked( ) ), t    
137                                                   
138                                                   
139                                                   
140                                                   
141   // save file group box                          
142   QGroupBox *saveFileGroupBox = new QGroupBox(    
143   QVBoxLayout *saveFileVGroupBoxLayout = new Q    
144                                                   
145   // save file                                    
146   QWidget *saveFileHBox = new QWidget(saveFile    
147   QHBoxLayout *saveFileHBoxLayout = new QHBoxL    
148                                                   
149   fSaveFileName = new QLineEdit("G4Movie.mpeg"    
150                                                   
151   QPushButton *saveButton = new QPushButton(tr    
152   saveButton->setMaximumWidth (30);               
153                                                   
154   fSaveFileStatus = new QLabel(saveFileGroupBo    
155   fSaveFileStatus->setWordWrap(true);             
156   saveFileVGroupBoxLayout->setContentsMargins(    
157   fSaveFileStatus->setText("");                   
158                                                   
159   saveFileHBoxLayout->addWidget(fSaveFileName)    
160   saveFileHBoxLayout->addWidget(saveButton);      
161   saveFileVGroupBoxLayout->addWidget(saveFileH    
162   saveFileVGroupBoxLayout->addWidget(fSaveFile    
163                                                   
164   saveFileGroupBox->setLayout(saveFileVGroupBo    
165   globalVLayout->addWidget(saveFileGroupBox);     
166                                                   
167   connect( saveButton, SIGNAL( clicked( ) ), t    
168                                                   
169                                                   
170                                                   
171   // label                                        
172                                                   
173   QLabel *infoLabel = new QLabel("  Press SPAC    
174                                                   
175   // global status                                
176   QGroupBox *statusGroupBox = new QGroupBox(tr    
177   QVBoxLayout *statusVGroupBoxLayout = new QVB    
178                                                   
179   fRecordingStatus = new QLabel(statusGroupBox    
180   statusVGroupBoxLayout->setContentsMargins(15    
181   fRecordingStatus->setWordWrap(true);            
182   QPalette mypalette( fRecordingStatus->palett    
183   mypalette.setColor( QPalette::Text, Qt::gree    
184   fRecordingStatus->setPalette(mypalette);        
185                                                   
186   fRecordingInfos = new QLabel(statusGroupBox)    
187   fRecordingInfos->setWordWrap(true);             
188   setRecordingInfos("");                          
189                                                   
190   statusVGroupBoxLayout->addWidget(fRecordingS    
191   statusVGroupBoxLayout->addWidget(fRecordingI    
192                                                   
193   statusGroupBox->setLayout(statusVGroupBoxLay    
194   globalVLayout->addWidget(infoLabel);            
195   globalVLayout->addWidget(statusGroupBox);       
196                                                   
197   // buttons                                      
198   QWidget *buttonBox = new QWidget(this);         
199                                                   
200   QHBoxLayout *buttonBoxLayout = new QHBoxLayo    
201                                                   
202   QPushButton *buttonReset = new QPushButton(     
203   buttonReset->setAutoDefault( TRUE );            
204   buttonBoxLayout->addWidget(buttonReset);        
205                                                   
206   fButtonStartPause = new QPushButton( tr( "      
207   fButtonStartPause->setEnabled(true);            
208   fButtonStartPause->setAutoDefault( TRUE );      
209   buttonBoxLayout->addWidget(fButtonStartPause    
210                                                   
211   fButtonStopFinishClose = new QPushButton( tr    
212   fButtonStopFinishClose->setEnabled(false);      
213   fButtonStopFinishClose->setAutoDefault( TRUE    
214   buttonBoxLayout->addWidget(fButtonStopFinish    
215                                                   
216   fButtonSave = new QPushButton( tr( "&Save" )    
217   fButtonSave->setEnabled(false);                 
218   fButtonSave->setAutoDefault( TRUE );            
219   buttonBoxLayout->addWidget(fButtonSave);        
220                                                   
221   QPushButton *buttonCancel = new QPushButton(    
222   buttonCancel->setAutoDefault( TRUE );           
223   buttonBoxLayout->addWidget(buttonCancel);       
224                                                   
225   buttonBox->setLayout(buttonBoxLayout);          
226   globalVLayout->addWidget(buttonBox);            
227                                                   
228                                                   
229                                                   
230   setLayout(globalVLayout);                       
231                                                   
232   // signals and slots connections                
233   connect( fButtonStartPause, SIGNAL( clicked(    
234   connect( buttonReset, SIGNAL( clicked() ), t    
235   connect( buttonCancel, SIGNAL( clicked() ),     
236   connect( fButtonStopFinishClose, SIGNAL( cli    
237   connect( fButtonSave, SIGNAL( clicked() ), t    
238                                                   
239   // fill                                         
240   setRecordingStatus("");                         
241   fEncoderPath->setText(fParentViewer->getEnco    
242   fTempFolderPath->setText(fParentViewer->getT    
243                                                   
244   // connect line edit signals                    
245   connect (fEncoderPath,SIGNAL(textChanged ( c    
246   connect (fTempFolderPath,SIGNAL(textChanged     
247   connect (fSaveFileName,SIGNAL(textChanged (     
248                                                   
249   connect (fEncoderPath,SIGNAL(editingFinished    
250   connect (fTempFolderPath,SIGNAL(editingFinis    
251   connect (fSaveFileName,SIGNAL(editingFinishe    
252                                                   
253 }                                                 
254                                                   
255                                                   
256                                                   
257 G4OpenGLQtMovieDialog::~G4OpenGLQtMovieDialog(    
258 {                                                 
259 }                                                 
260                                                   
261 void G4OpenGLQtMovieDialog::selectEncoderPathA    
262 {                                                 
263   QString nomFich =  QFileDialog::getOpenFileN    
264                                                   
265                                                   
266                                                   
267                                                   
268   if (nomFich == "") {                            
269     return;                                       
270   }                                               
271   fEncoderPath->setText(nomFich);                 
272   checkEncoderSwParameters();                     
273  }                                                
274                                                   
275                                                   
276 void G4OpenGLQtMovieDialog::selectTempPathActi    
277 {                                                 
278   QString nomFich =  QFileDialog::getExistingD    
279                                                   
280                                                   
281                                                   
282   if (nomFich == "") {                            
283     return;                                       
284   }                                               
285   fTempFolderPath->setText(nomFich);              
286   checkTempFolderParameters();                    
287  }                                                
288                                                   
289                                                   
290 void G4OpenGLQtMovieDialog::selectSaveFileName    
291 {                                                 
292   QString nomFich =  QFileDialog::getSaveFileN    
293                                                   
294                                                   
295                                                   
296   if (nomFich == "") {                            
297     return;                                       
298   }                                               
299   fSaveFileName->setText(nomFich);                
300   checkSaveFileNameParameters();                  
301  }                                                
302                                                   
303                                                   
304 void G4OpenGLQtMovieDialog::stopFinishClose()     
305   fParentViewer->stopVideo();                     
306 }                                                 
307                                                   
308 void G4OpenGLQtMovieDialog::save() {              
309   if (((fParentViewer->isPaused()) || fParentV    
310     fParentViewer->saveVideo();                   
311   }                                               
312 }                                                 
313                                                   
314   /**                                             
315  * If one of parameter is incorrect, put it in    
316  * If valid, save it                              
317  */                                               
318 bool G4OpenGLQtMovieDialog::checkEncoderSwPara    
319                                                   
320   bool status = true;                             
321   QPalette mypalette( fEncoderPath->palette()     
322                                                   
323   QString temp = fParentViewer->setEncoderPath    
324   setRecordingInfos("");                          
325   fEncoderStatus->setText(temp);                  
326   if (temp != "") {                               
327     mypalette.setColor( QPalette::Base, Qt::re    
328     if (fParentViewer->isReadyToEncode()) {       
329       setRecordingInfos("No valid encode defin    
330   }                                               
331     status = false;                               
332   } else {                                        
333     mypalette.setColor( QPalette::Base, Qt::wh    
334     fEncoderPath->setText(fParentViewer->getEn    
335   }                                               
336   fEncoderPath->setPalette(mypalette);            
337   return status;                                  
338 }                                                 
339                                                   
340                                                   
341 /**                                               
342  * If one of parameter is incorrect, put it in    
343  * If valid, save it                              
344  */                                               
345 bool G4OpenGLQtMovieDialog::checkTempFolderPar    
346                                                   
347   bool status = true;                             
348   QPalette mypalette( fTempFolderPath->palette    
349                                                   
350   QString temp = fParentViewer->setTempFolderP    
351   fTempFolderStatus->setText(temp);               
352   if (temp != "") {                               
353     mypalette.setColor( QPalette::Base, Qt::re    
354     status = false;                               
355   } else {                                        
356     mypalette.setColor( QPalette::Base, Qt::wh    
357     fTempFolderPath->setText(fParentViewer->ge    
358   }                                               
359   fTempFolderPath->setPalette(mypalette);         
360   return status;                                  
361 }                                                 
362                                                   
363                                                   
364 /**                                               
365  * If one of parameter is incorrect, put it in    
366  * If valid, save it                              
367  */                                               
368 bool G4OpenGLQtMovieDialog::checkSaveFileNameP    
369                                                   
370   bool status = true;                             
371   QPalette mypalette( fSaveFileName->palette()    
372                                                   
373   QString temp = fParentViewer->setSaveFileNam    
374   fSaveFileStatus->setText(temp);                 
375   if (temp != "") {                               
376     mypalette.setColor( QPalette::Base, Qt::re    
377     status = false;                               
378   } else {                                        
379     mypalette.setColor( QPalette::Base, Qt::wh    
380     fSaveFileName->setText(fParentViewer->getS    
381   }                                               
382   fSaveFileName->setPalette(mypalette);           
383   return status;                                  
384 }                                                 
385                                                   
386                                                   
387 void G4OpenGLQtMovieDialog::resetRecording() {    
388   fParentViewer->resetRecording();                
389 }                                                 
390                                                   
391                                                   
392 void G4OpenGLQtMovieDialog::setRecordingStatus    
393   fRecordingStatus->setText(txt);                 
394   if (fParentViewer->isWaiting()) {               
395     fButtonStartPause->setText("  &Start ");      
396     fButtonStartPause->setEnabled(true);          
397     fButtonStopFinishClose->setEnabled(false);    
398     fButtonSave->setEnabled(false);               
399                                                   
400   } else if (fParentViewer->isPaused()) {         
401                                                   
402     fButtonStartPause->setText("  &Continue ")    
403     fButtonStartPause->setEnabled(true);          
404     fButtonStopFinishClose->setEnabled(true);     
405     fButtonSave->setEnabled(false);               
406                                                   
407   } else if (fParentViewer->isRecording()) {      
408                                                   
409     fButtonStartPause->setText("  &Pause ");      
410     fButtonStartPause->setEnabled(true);          
411     fButtonStopFinishClose->setEnabled(true);     
412     fButtonSave->setEnabled(false);               
413                                                   
414   } else if (fParentViewer->isBadOutput()) {      
415                                                   
416     fButtonStartPause->setText("  &Start ");      
417     fButtonStartPause->setEnabled(true);          
418     fButtonStopFinishClose->setEnabled(false);    
419     fButtonSave->setEnabled(false);               
420                                                   
421   } else if (fParentViewer->isBadTmp()) {         
422                                                   
423     fButtonStartPause->setText("  &Start ");      
424     fButtonStartPause->setEnabled(false);         
425     fButtonStopFinishClose->setEnabled(false);    
426     fButtonSave->setEnabled(false);               
427                                                   
428   } else if (fParentViewer->isBadEncoder()) {     
429                                                   
430     fButtonStartPause->setText("  &Start ");      
431     fButtonStartPause->setEnabled(true);          
432     fButtonStopFinishClose->setEnabled(false);    
433     fButtonSave->setEnabled(false);               
434                                                   
435   } else if (fParentViewer->isSuccess()) {        
436                                                   
437     fButtonStartPause->setText("  &Start ");      
438     fButtonStartPause->setEnabled(false);         
439     fButtonStopFinishClose->setEnabled(false);    
440     fButtonSave->setEnabled(false);               
441                                                   
442   } else if (fParentViewer->isFailed()) {         
443                                                   
444     fButtonStartPause->setText("  &Start ");      
445     fButtonStartPause->setEnabled(false);         
446     fButtonStopFinishClose->setEnabled(false);    
447     fButtonSave->setEnabled(false);               
448                                                   
449   } else if (fParentViewer->isStopped()) {        
450                                                   
451     fButtonStartPause->setText("  &Start ");      
452     fButtonStartPause->setEnabled(false);         
453     fButtonStopFinishClose->setEnabled(false);    
454     fButtonSave->setEnabled(true);                
455   }                                               
456 }                                                 
457                                                   
458                                                   
459 void G4OpenGLQtMovieDialog::setRecordingInfos(    
460   fRecordingInfos->setText(txt);                  
461 }                                                 
462                                                   
463                                                   
464 void G4OpenGLQtMovieDialog::enabledApplyButton    
465   fButtonStartPause->setEnabled(true);            
466 }                                                 
467