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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/G4OpenGLQtExportDialog.cc (Version 11.3.0) and /visualization/OpenGL/src/G4OpenGLQtExportDialog.cc (Version 1.0)


  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 "G4OpenGLQtExportDialog.hh"              
 31                                                   
 32 #include <qvariant.h>                             
 33 #include <qpushbutton.h>                          
 34 #include <qcheckbox.h>                            
 35 #include <qlabel.h>                               
 36 #include <qcombobox.h>                            
 37 #include <qslider.h>                              
 38 #include <qlayout.h>                              
 39 #include <qgroupbox.h>                            
 40 #include <qradiobutton.h>                         
 41 #include <qimage.h>                               
 42 #include <qlineedit.h>                            
 43 #include <qbuttongroup.h>                         
 44                                                   
 45 #ifndef G4GMAKE                                   
 46 #include "moc_G4OpenGLQtExportDialog.cpp"         
 47 #endif                                            
 48                                                   
 49 G4OpenGLQtExportDialog::G4OpenGLQtExportDialog    
 50  QWidget* parentw                                 
 51 ,QString format                                   
 52  ,int aHeight                                     
 53  ,int aWidth                                      
 54 )                                                 
 55   : QDialog( parentw ),                           
 56     isChangingSize(false)                         
 57 {                                                 
 58   setWindowTitle( tr( " Export options" ));       
 59   originalWidth = aWidth;                         
 60   originalHeight = aHeight;                       
 61                                                   
 62   // Initializations                              
 63   vectorEPSCheckBox = NULL;                       
 64   qualitySlider = NULL;                           
 65   width = NULL;                                   
 66   height = NULL;                                  
 67   colorButton = NULL;                             
 68   BWButton = NULL;                                
 69                                                   
 70   // global layout                                
 71   QVBoxLayout* globalVLayout = new QVBoxLayout    
 72   globalVLayout->setContentsMargins(10,10,10,1    
 73   globalVLayout->setSpacing(10);                  
 74                                                   
 75                                                   
 76                                                   
 77                                                   
 78   // size box                                     
 79                                                   
 80   QWidget * sizeWidget = new QWidget(this); //    
 81   QVBoxLayout * sizeWidgetLayout = new QVBoxLa    
 82   sizeWidgetLayout->setContentsMargins(10,10,1    
 83                                                   
 84   // original and modify radiobuttons             
 85                                                   
 86   sizeGroupBox = new QGroupBox(tr("Size"));       
 87   QVBoxLayout *sizeGroupBoxLayout = new QVBoxL    
 88   QButtonGroup * sizeButtonGroupBox = new QBut    
 89   sizeGroupBoxLayout->setContentsMargins(15,15    
 90                                                   
 91   original = new QRadioButton("Original");        
 92   modify = new QRadioButton("Modify");            
 93                                                   
 94   sizeButtonGroupBox->addButton(original);        
 95   sizeButtonGroupBox->addButton(modify);          
 96   sizeButtonGroupBox->setExclusive(true);         
 97                                                   
 98   sizeGroupBoxLayout->addWidget(original);        
 99   sizeGroupBoxLayout->addWidget(modify);          
100                                                   
101   sizeGroupBox->setLayout(sizeGroupBoxLayout);    
102   sizeWidgetLayout->addWidget(sizeGroupBox);      
103                                                   
104   connect( sizeButtonGroupBox, SIGNAL( buttonC    
105   original->setChecked( true );                   
106                                                   
107                                                   
108   // height                                       
109   heightWidget = new QWidget(sizeWidget);         
110                                                   
111   QHBoxLayout *heightLineLayout = new QHBoxLay    
112                                                   
113   QString tmp;                                    
114                                                   
115   heightLineLayout->addWidget(new QLabel("Heig    
116   height = new QLineEdit(tmp.setNum(originalHe    
117   height->setMaxLength(5);                        
118   heightLineLayout->addWidget(height);            
119                                                   
120   heightWidget->setLayout(heightLineLayout);      
121                                                   
122   sizeWidgetLayout->addWidget(heightWidget);      
123   connect( height, SIGNAL( textChanged ( const    
124                                                   
125                                                   
126   // width                                        
127   widthWidget = new QWidget(sizeWidget);          
128                                                   
129   QHBoxLayout *widthLineLayout = new QHBoxLayo    
130                                                   
131   widthLineLayout->addWidget(new QLabel("Width    
132   width = new QLineEdit(tmp.setNum(originalWid    
133   width->setMaxLength(5);                         
134   widthLineLayout->addWidget(width);              
135   widthWidget->setLayout(widthLineLayout);        
136   sizeWidgetLayout->addWidget(widthWidget);       
137   connect( width, SIGNAL( textChanged ( const     
138                                                   
139                                                   
140                                                   
141   // ratio check box                              
142                                                   
143   ratioCheckBox = new QCheckBox( "Keep ratio",    
144   ratioCheckBox->setChecked( true );              
145                                                   
146   sizeWidgetLayout->addWidget(ratioCheckBox);     
147                                                   
148   ratioCheckBox->hide();                          
149   heightWidget->hide();                           
150   widthWidget->hide();                            
151                                                   
152   sizeWidget->setLayout(sizeWidgetLayout);        
153   globalVLayout->addWidget(sizeWidget);           
154                                                   
155  if (format == "eps") {                           
156                                                   
157    QGroupBox *EPSWidgetGroupBox = new QGroupBo    
158                                                   
159                                                   
160     QVBoxLayout * EPSGroupBoxLayout = new QVBo    
161      EPSGroupBoxLayout->setContentsMargins(15,    
162                                                   
163 //     colorButton = new QRadioButton("Color",    
164 //     BWButton = new QRadioButton("Grayscale"    
165                                                   
166 //     QButtonGroup * EPSColorButtonGroupBox =    
167 //     EPSColorButtonGroupBox->addButton(color    
168 //     EPSColorButtonGroupBox->addButton(BWBut    
169 //     EPSColorButtonGroupBox->setExclusive(tr    
170                                                   
171 //     EPSGroupBoxLayout->addWidget(colorButto    
172 //     EPSGroupBoxLayout->addWidget(BWButton);    
173                                                   
174     vectorEPSCheckBox = new QCheckBox( "Vector    
175     EPSGroupBoxLayout->addWidget(vectorEPSChec    
176                                                   
177     EPSWidgetGroupBox->setLayout(EPSGroupBoxLa    
178     //    colorButton->setChecked( true );        
179     vectorEPSCheckBox->setChecked( true );        
180                                                   
181     globalVLayout->addWidget(EPSWidgetGroupBox    
182     connect( vectorEPSCheckBox, SIGNAL( clicke    
183                                                   
184   }                                               
185                                                   
186   if ((format == "jpg") ||                        
187       (format == "jpeg")) {                       
188                                                   
189     QGroupBox *imageGroupBox = new QGroupBox(t    
190     QHBoxLayout *hSliderLayout = new QHBoxLayo    
191     hSliderLayout->setContentsMargins(15,15,15    
192                                                   
193     qualitySlider= new QSlider(Qt::Horizontal,    
194     qualitySlider->setMinimum(0);                 
195     qualitySlider->setMaximum(100);               
196     qualitySlider->setTickPosition(QSlider::Ti    
197     qualitySlider->setValue(60);                  
198     hSliderLayout->addWidget(new QLabel("Low "    
199     hSliderLayout->addWidget(qualitySlider);      
200     hSliderLayout->addWidget(new QLabel(" Maxi    
201                                                   
202     imageGroupBox->setLayout(hSliderLayout);      
203                                                   
204     globalVLayout->addWidget(imageGroupBox);      
205   }                                               
206                                                   
207                                                   
208   // button ok/cancel box                         
209                                                   
210   QWidget *buttonBox = new QWidget(this);         
211                                                   
212   QHBoxLayout *buttonBoxLayout = new QHBoxLayo    
213                                                   
214   buttonOk = new QPushButton( tr( "&OK" ),butt    
215   buttonOk->setAutoDefault( true );               
216   buttonOk->setDefault( true );                   
217   buttonBoxLayout->addWidget(buttonOk);           
218                                                   
219   buttonCancel = new QPushButton( tr( "&Cancel    
220   buttonCancel->setAutoDefault( true );           
221   buttonBoxLayout->addWidget(buttonCancel);       
222                                                   
223   buttonBox->setLayout(buttonBoxLayout);          
224   globalVLayout->addWidget(buttonBox);            
225                                                   
226                                                   
227                                                   
228   setLayout(globalVLayout);                       
229                                                   
230   // signals and slots connections                
231   connect( buttonOk, SIGNAL( clicked() ), this    
232   connect( buttonCancel, SIGNAL( clicked() ),     
233 }                                                 
234                                                   
235                                                   
236                                                   
237 int G4OpenGLQtExportDialog::getSliderValue()      
238 {                                                 
239   if (!qualitySlider) return -1;                  
240   return qualitySlider->value();                  
241 }                                                 
242                                                   
243 int G4OpenGLQtExportDialog::getHeight()           
244 {                                                 
245   if (!height) return originalHeight;             
246   return height->text().toInt();                  
247 }                                                 
248                                                   
249 int G4OpenGLQtExportDialog::getWidth()            
250 {                                                 
251   if (!width) return originalWidth;               
252   return width->text().toInt();                   
253 }                                                 
254                                                   
255 bool G4OpenGLQtExportDialog::getVectorEPS()       
256 {                                                 
257   if (!vectorEPSCheckBox) return 0;               
258   return vectorEPSCheckBox->isChecked();          
259 }                                                 
260                                                   
261                                                   
262 void G4OpenGLQtExportDialog::changeVectorEPS()    
263 {                                                 
264   if (!vectorEPSCheckBox) return;                 
265   if (vectorEPSCheckBox->isChecked()) {           
266     sizeGroupBox->show();                         
267     original->show();                             
268     modify->show();                               
269     changeSizeBox();                              
270   } else {                                        
271     sizeGroupBox->hide();                         
272     original->hide();                             
273     modify->hide();                               
274     ratioCheckBox->hide();                        
275     heightWidget->hide();                         
276     widthWidget->hide();                          
277   }                                               
278 }                                                 
279                                                   
280                                                   
281 void G4OpenGLQtExportDialog::changeSizeBox()      
282 {                                                 
283   if (!original) return;                          
284   if (!heightWidget) return;                      
285   if (!widthWidget) return;                       
286   if (!ratioCheckBox) return;                     
287                                                   
288   if ( original->isChecked()) {                   
289     ratioCheckBox->hide();                        
290     heightWidget->hide();                         
291     widthWidget->hide();                          
292   } else {                                        
293     heightWidget->show();                         
294     widthWidget->show();                          
295     ratioCheckBox->show();                        
296   }                                               
297 }                                                 
298                                                   
299                                                   
300 void G4OpenGLQtExportDialog::textWidthChanged(    
301  const QString & s                                
302  )                                                
303 {                                                 
304   if (!ratioCheckBox) return;                     
305   if (!width) return;                             
306   if (isChangingSize == true) return; // exclu    
307                                                   
308   if (ratioCheckBox->isChecked()){                
309     isChangingSize = true;                        
310     QString tmp;                                  
311   height->setText(tmp.setNum((int)(s.toInt()*(    
312   isChangingSize = false;                         
313   }                                               
314 }                                                 
315                                                   
316 void G4OpenGLQtExportDialog::  textHeightChang    
317  const QString & s                                
318 )                                                 
319 {                                                 
320   if (!ratioCheckBox) return;                     
321   if (!width) return;                             
322   if (isChangingSize == true) return; // exclu    
323                                                   
324   if (ratioCheckBox->isChecked()){                
325   isChangingSize = true;                          
326     QString tmp;                                  
327     width->setText(tmp.setNum(s.toInt()*origin    
328   isChangingSize = false;                         
329   }                                               
330 }                                                 
331                                                   
332 G4OpenGLQtExportDialog::~G4OpenGLQtExportDialo    
333 {                                                 
334 }                                                 
335