Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // 27 // 27 // 28 // << 28 // >> 29 >> 30 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER 29 31 30 #include "G4OpenGLQtExportDialog.hh" 32 #include "G4OpenGLQtExportDialog.hh" 31 33 32 #include <qvariant.h> 34 #include <qvariant.h> 33 #include <qpushbutton.h> 35 #include <qpushbutton.h> 34 #include <qcheckbox.h> 36 #include <qcheckbox.h> 35 #include <qlabel.h> 37 #include <qlabel.h> 36 #include <qcombobox.h> 38 #include <qcombobox.h> 37 #include <qslider.h> 39 #include <qslider.h> 38 #include <qlayout.h> 40 #include <qlayout.h> 39 #include <qgroupbox.h> 41 #include <qgroupbox.h> 40 #include <qradiobutton.h> 42 #include <qradiobutton.h> 41 #include <qimage.h> 43 #include <qimage.h> 42 #include <qlineedit.h> 44 #include <qlineedit.h> 43 #include <qbuttongroup.h> 45 #include <qbuttongroup.h> 44 46 45 #ifndef G4GMAKE << 46 #include "moc_G4OpenGLQtExportDialog.cpp" << 47 #endif << 48 << 49 G4OpenGLQtExportDialog::G4OpenGLQtExportDialog 47 G4OpenGLQtExportDialog::G4OpenGLQtExportDialog( 50 QWidget* parentw 48 QWidget* parentw 51 ,QString format 49 ,QString format 52 ,int aHeight 50 ,int aHeight 53 ,int aWidth 51 ,int aWidth 54 ) 52 ) 55 : QDialog( parentw ), 53 : QDialog( parentw ), 56 isChangingSize(false) 54 isChangingSize(false) 57 { 55 { 58 setWindowTitle( tr( " Export options" )); 56 setWindowTitle( tr( " Export options" )); 59 originalWidth = aWidth; 57 originalWidth = aWidth; 60 originalHeight = aHeight; 58 originalHeight = aHeight; 61 59 62 // Initializations 60 // Initializations 63 vectorEPSCheckBox = NULL; << 64 qualitySlider = NULL; 61 qualitySlider = NULL; 65 width = NULL; 62 width = NULL; 66 height = NULL; 63 height = NULL; 67 colorButton = NULL; 64 colorButton = NULL; 68 BWButton = NULL; 65 BWButton = NULL; 69 66 70 // global layout 67 // global layout 71 QVBoxLayout* globalVLayout = new QVBoxLayout 68 QVBoxLayout* globalVLayout = new QVBoxLayout(this); 72 globalVLayout->setContentsMargins(10,10,10,1 << 69 globalVLayout->setMargin(10); 73 globalVLayout->setSpacing(10); 70 globalVLayout->setSpacing(10); 74 << 71 75 72 76 73 77 74 78 // size box 75 // size box 79 76 80 QWidget * sizeWidget = new QWidget(this); // 77 QWidget * sizeWidget = new QWidget(this); // widget containing group button 81 QVBoxLayout * sizeWidgetLayout = new QVBoxLa 78 QVBoxLayout * sizeWidgetLayout = new QVBoxLayout(sizeWidget); 82 sizeWidgetLayout->setContentsMargins(10,10,1 << 79 sizeWidgetLayout->setMargin (10); 83 80 84 // original and modify radiobuttons 81 // original and modify radiobuttons 85 << 82 86 sizeGroupBox = new QGroupBox(tr("Size")); 83 sizeGroupBox = new QGroupBox(tr("Size")); 87 QVBoxLayout *sizeGroupBoxLayout = new QVBoxL 84 QVBoxLayout *sizeGroupBoxLayout = new QVBoxLayout(sizeGroupBox); 88 QButtonGroup * sizeButtonGroupBox = new QBut 85 QButtonGroup * sizeButtonGroupBox = new QButtonGroup(); 89 sizeGroupBoxLayout->setContentsMargins(15,15 << 86 sizeGroupBoxLayout->setMargin (15); 90 87 91 original = new QRadioButton("Original"); 88 original = new QRadioButton("Original"); 92 modify = new QRadioButton("Modify"); 89 modify = new QRadioButton("Modify"); 93 90 94 sizeButtonGroupBox->addButton(original); 91 sizeButtonGroupBox->addButton(original); 95 sizeButtonGroupBox->addButton(modify); 92 sizeButtonGroupBox->addButton(modify); 96 sizeButtonGroupBox->setExclusive(true); 93 sizeButtonGroupBox->setExclusive(true); 97 94 98 sizeGroupBoxLayout->addWidget(original); << 95 sizeGroupBoxLayout->addWidget(original); 99 sizeGroupBoxLayout->addWidget(modify); << 96 sizeGroupBoxLayout->addWidget(modify); 100 97 101 sizeGroupBox->setLayout(sizeGroupBoxLayout); 98 sizeGroupBox->setLayout(sizeGroupBoxLayout); 102 sizeWidgetLayout->addWidget(sizeGroupBox); 99 sizeWidgetLayout->addWidget(sizeGroupBox); 103 << 100 104 connect( sizeButtonGroupBox, SIGNAL( buttonC 101 connect( sizeButtonGroupBox, SIGNAL( buttonClicked(QAbstractButton*) ), this, SLOT( changeSizeBox()) ); 105 original->setChecked( true ); 102 original->setChecked( true ); 106 103 107 104 108 // height 105 // height 109 heightWidget = new QWidget(sizeWidget); 106 heightWidget = new QWidget(sizeWidget); 110 107 111 QHBoxLayout *heightLineLayout = new QHBoxLay 108 QHBoxLayout *heightLineLayout = new QHBoxLayout(heightWidget); 112 109 113 QString tmp; 110 QString tmp; 114 << 111 115 heightLineLayout->addWidget(new QLabel("Heig 112 heightLineLayout->addWidget(new QLabel("Height",heightWidget)); 116 height = new QLineEdit(tmp.setNum(originalHe 113 height = new QLineEdit(tmp.setNum(originalHeight),heightWidget); 117 height->setMaxLength(5); 114 height->setMaxLength(5); 118 heightLineLayout->addWidget(height); 115 heightLineLayout->addWidget(height); 119 116 120 heightWidget->setLayout(heightLineLayout); 117 heightWidget->setLayout(heightLineLayout); 121 118 122 sizeWidgetLayout->addWidget(heightWidget); 119 sizeWidgetLayout->addWidget(heightWidget); 123 connect( height, SIGNAL( textChanged ( const 120 connect( height, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textHeightChanged(const QString &) ) ); 124 121 125 122 126 // width 123 // width 127 widthWidget = new QWidget(sizeWidget); 124 widthWidget = new QWidget(sizeWidget); 128 125 129 QHBoxLayout *widthLineLayout = new QHBoxLayo 126 QHBoxLayout *widthLineLayout = new QHBoxLayout(widthWidget); 130 127 131 widthLineLayout->addWidget(new QLabel("Width 128 widthLineLayout->addWidget(new QLabel("Width ",widthWidget)); 132 width = new QLineEdit(tmp.setNum(originalWid 129 width = new QLineEdit(tmp.setNum(originalWidth),widthWidget); 133 width->setMaxLength(5); 130 width->setMaxLength(5); 134 widthLineLayout->addWidget(width); 131 widthLineLayout->addWidget(width); 135 widthWidget->setLayout(widthLineLayout); 132 widthWidget->setLayout(widthLineLayout); 136 sizeWidgetLayout->addWidget(widthWidget); 133 sizeWidgetLayout->addWidget(widthWidget); 137 connect( width, SIGNAL( textChanged ( const 134 connect( width, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textWidthChanged(const QString &) ) ); 138 135 139 136 140 137 141 // ratio check box 138 // ratio check box 142 139 143 ratioCheckBox = new QCheckBox( "Keep ratio", 140 ratioCheckBox = new QCheckBox( "Keep ratio",sizeWidget); 144 ratioCheckBox->setChecked( true ); 141 ratioCheckBox->setChecked( true ); 145 142 146 sizeWidgetLayout->addWidget(ratioCheckBox); 143 sizeWidgetLayout->addWidget(ratioCheckBox); 147 144 148 ratioCheckBox->hide(); 145 ratioCheckBox->hide(); 149 heightWidget->hide(); 146 heightWidget->hide(); 150 widthWidget->hide(); 147 widthWidget->hide(); 151 148 152 sizeWidget->setLayout(sizeWidgetLayout); 149 sizeWidget->setLayout(sizeWidgetLayout); 153 globalVLayout->addWidget(sizeWidget); 150 globalVLayout->addWidget(sizeWidget); 154 151 155 if (format == "eps") { 152 if (format == "eps") { 156 153 157 QGroupBox *EPSWidgetGroupBox = new QGroupBo 154 QGroupBox *EPSWidgetGroupBox = new QGroupBox(tr("EPS options"),this); // widget containing group button 158 155 159 156 160 QVBoxLayout * EPSGroupBoxLayout = new QVBo 157 QVBoxLayout * EPSGroupBoxLayout = new QVBoxLayout(EPSWidgetGroupBox); 161 EPSGroupBoxLayout->setContentsMargins(15, << 158 EPSGroupBoxLayout->setMargin (15); 162 159 163 // colorButton = new QRadioButton("Color", 160 // colorButton = new QRadioButton("Color",EPSWidgetGroupBox); 164 // BWButton = new QRadioButton("Grayscale" 161 // BWButton = new QRadioButton("Grayscale",EPSWidgetGroupBox); 165 162 166 // QButtonGroup * EPSColorButtonGroupBox = 163 // QButtonGroup * EPSColorButtonGroupBox = new QButtonGroup(); 167 // EPSColorButtonGroupBox->addButton(color 164 // EPSColorButtonGroupBox->addButton(colorButton); 168 // EPSColorButtonGroupBox->addButton(BWBut 165 // EPSColorButtonGroupBox->addButton(BWButton); 169 // EPSColorButtonGroupBox->setExclusive(tr 166 // EPSColorButtonGroupBox->setExclusive(true); 170 167 171 // EPSGroupBoxLayout->addWidget(colorButto << 168 // EPSGroupBoxLayout->addWidget(colorButton); 172 // EPSGroupBoxLayout->addWidget(BWButton); << 169 // EPSGroupBoxLayout->addWidget(BWButton); 173 170 174 vectorEPSCheckBox = new QCheckBox( "Vector 171 vectorEPSCheckBox = new QCheckBox( "Vector EPS File",EPSWidgetGroupBox); 175 EPSGroupBoxLayout->addWidget(vectorEPSChec 172 EPSGroupBoxLayout->addWidget(vectorEPSCheckBox); 176 173 177 EPSWidgetGroupBox->setLayout(EPSGroupBoxLa 174 EPSWidgetGroupBox->setLayout(EPSGroupBoxLayout); 178 // colorButton->setChecked( true ); 175 // colorButton->setChecked( true ); 179 vectorEPSCheckBox->setChecked( true ); 176 vectorEPSCheckBox->setChecked( true ); 180 << 177 181 globalVLayout->addWidget(EPSWidgetGroupBox 178 globalVLayout->addWidget(EPSWidgetGroupBox); 182 connect( vectorEPSCheckBox, SIGNAL( clicke 179 connect( vectorEPSCheckBox, SIGNAL( clicked() ), this, SLOT( changeVectorEPS()) ); 183 180 184 } 181 } 185 182 186 if ((format == "jpg") || << 183 if ((format == "jpg") || 187 (format == "jpeg")) { 184 (format == "jpeg")) { 188 << 185 189 QGroupBox *imageGroupBox = new QGroupBox(t 186 QGroupBox *imageGroupBox = new QGroupBox(tr("Image quality"),this); 190 QHBoxLayout *hSliderLayout = new QHBoxLayo 187 QHBoxLayout *hSliderLayout = new QHBoxLayout(imageGroupBox); 191 hSliderLayout->setContentsMargins(15,15,15 << 188 hSliderLayout->setMargin (15); 192 189 193 qualitySlider= new QSlider(Qt::Horizontal, 190 qualitySlider= new QSlider(Qt::Horizontal,imageGroupBox); 194 qualitySlider->setMinimum(0); 191 qualitySlider->setMinimum(0); 195 qualitySlider->setMaximum(100); 192 qualitySlider->setMaximum(100); 196 qualitySlider->setTickPosition(QSlider::Ti 193 qualitySlider->setTickPosition(QSlider::TicksBelow); 197 qualitySlider->setValue(60); 194 qualitySlider->setValue(60); 198 hSliderLayout->addWidget(new QLabel("Low " 195 hSliderLayout->addWidget(new QLabel("Low ",imageGroupBox)); 199 hSliderLayout->addWidget(qualitySlider); 196 hSliderLayout->addWidget(qualitySlider); 200 hSliderLayout->addWidget(new QLabel(" Maxi 197 hSliderLayout->addWidget(new QLabel(" Maximum",imageGroupBox)); 201 << 198 202 imageGroupBox->setLayout(hSliderLayout); 199 imageGroupBox->setLayout(hSliderLayout); 203 200 204 globalVLayout->addWidget(imageGroupBox); 201 globalVLayout->addWidget(imageGroupBox); 205 } 202 } 206 203 207 204 208 // button ok/cancel box 205 // button ok/cancel box 209 206 210 QWidget *buttonBox = new QWidget(this); 207 QWidget *buttonBox = new QWidget(this); 211 208 212 QHBoxLayout *buttonBoxLayout = new QHBoxLayo 209 QHBoxLayout *buttonBoxLayout = new QHBoxLayout(buttonBox); 213 210 214 buttonOk = new QPushButton( tr( "&OK" ),butt 211 buttonOk = new QPushButton( tr( "&OK" ),buttonBox ); 215 buttonOk->setAutoDefault( true ); 212 buttonOk->setAutoDefault( true ); 216 buttonOk->setDefault( true ); 213 buttonOk->setDefault( true ); 217 buttonBoxLayout->addWidget(buttonOk); 214 buttonBoxLayout->addWidget(buttonOk); 218 215 219 buttonCancel = new QPushButton( tr( "&Cancel 216 buttonCancel = new QPushButton( tr( "&Cancel" ),buttonBox ); 220 buttonCancel->setAutoDefault( true ); 217 buttonCancel->setAutoDefault( true ); 221 buttonBoxLayout->addWidget(buttonCancel); 218 buttonBoxLayout->addWidget(buttonCancel); 222 219 223 buttonBox->setLayout(buttonBoxLayout); 220 buttonBox->setLayout(buttonBoxLayout); 224 globalVLayout->addWidget(buttonBox); 221 globalVLayout->addWidget(buttonBox); 225 222 226 223 227 224 228 setLayout(globalVLayout); 225 setLayout(globalVLayout); 229 226 230 // signals and slots connections 227 // signals and slots connections 231 connect( buttonOk, SIGNAL( clicked() ), this 228 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); 232 connect( buttonCancel, SIGNAL( clicked() ), 229 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); 233 } 230 } 234 231 235 232 236 233 237 int G4OpenGLQtExportDialog::getSliderValue() 234 int G4OpenGLQtExportDialog::getSliderValue() 238 { 235 { 239 if (!qualitySlider) return -1; 236 if (!qualitySlider) return -1; 240 return qualitySlider->value(); 237 return qualitySlider->value(); 241 } 238 } 242 239 243 int G4OpenGLQtExportDialog::getHeight() 240 int G4OpenGLQtExportDialog::getHeight() 244 { 241 { 245 if (!height) return originalHeight; 242 if (!height) return originalHeight; 246 return height->text().toInt(); 243 return height->text().toInt(); 247 } 244 } 248 245 249 int G4OpenGLQtExportDialog::getWidth() 246 int G4OpenGLQtExportDialog::getWidth() 250 { 247 { 251 if (!width) return originalWidth; 248 if (!width) return originalWidth; 252 return width->text().toInt(); 249 return width->text().toInt(); 253 } 250 } 254 251 255 bool G4OpenGLQtExportDialog::getVectorEPS() 252 bool G4OpenGLQtExportDialog::getVectorEPS() 256 { 253 { 257 if (!vectorEPSCheckBox) return 0; 254 if (!vectorEPSCheckBox) return 0; 258 return vectorEPSCheckBox->isChecked(); 255 return vectorEPSCheckBox->isChecked(); 259 } 256 } 260 257 261 258 262 void G4OpenGLQtExportDialog::changeVectorEPS() 259 void G4OpenGLQtExportDialog::changeVectorEPS() 263 { 260 { 264 if (!vectorEPSCheckBox) return; 261 if (!vectorEPSCheckBox) return; 265 if (vectorEPSCheckBox->isChecked()) { 262 if (vectorEPSCheckBox->isChecked()) { 266 sizeGroupBox->show(); 263 sizeGroupBox->show(); 267 original->show(); 264 original->show(); 268 modify->show(); 265 modify->show(); 269 changeSizeBox(); 266 changeSizeBox(); 270 } else { 267 } else { 271 sizeGroupBox->hide(); 268 sizeGroupBox->hide(); 272 original->hide(); 269 original->hide(); 273 modify->hide(); 270 modify->hide(); 274 ratioCheckBox->hide(); 271 ratioCheckBox->hide(); 275 heightWidget->hide(); 272 heightWidget->hide(); 276 widthWidget->hide(); 273 widthWidget->hide(); 277 } 274 } 278 } 275 } 279 276 280 277 281 void G4OpenGLQtExportDialog::changeSizeBox() 278 void G4OpenGLQtExportDialog::changeSizeBox() 282 { 279 { 283 if (!original) return; 280 if (!original) return; 284 if (!heightWidget) return; 281 if (!heightWidget) return; 285 if (!widthWidget) return; 282 if (!widthWidget) return; 286 if (!ratioCheckBox) return; 283 if (!ratioCheckBox) return; 287 284 288 if ( original->isChecked()) { 285 if ( original->isChecked()) { 289 ratioCheckBox->hide(); 286 ratioCheckBox->hide(); 290 heightWidget->hide(); 287 heightWidget->hide(); 291 widthWidget->hide(); 288 widthWidget->hide(); 292 } else { 289 } else { 293 heightWidget->show(); 290 heightWidget->show(); 294 widthWidget->show(); 291 widthWidget->show(); 295 ratioCheckBox->show(); 292 ratioCheckBox->show(); 296 } 293 } 297 } 294 } 298 295 299 296 300 void G4OpenGLQtExportDialog::textWidthChanged( 297 void G4OpenGLQtExportDialog::textWidthChanged( 301 const QString & s 298 const QString & s 302 ) 299 ) 303 { 300 { 304 if (!ratioCheckBox) return; 301 if (!ratioCheckBox) return; 305 if (!width) return; 302 if (!width) return; 306 if (isChangingSize == true) return; // exclu 303 if (isChangingSize == true) return; // exclusive slot 307 304 308 if (ratioCheckBox->isChecked()){ 305 if (ratioCheckBox->isChecked()){ 309 isChangingSize = true; 306 isChangingSize = true; 310 QString tmp; 307 QString tmp; 311 height->setText(tmp.setNum((int)(s.toInt()*( 308 height->setText(tmp.setNum((int)(s.toInt()*(double)((double)originalHeight/(double)originalWidth)))); 312 isChangingSize = false; 309 isChangingSize = false; 313 } 310 } 314 } 311 } 315 312 316 void G4OpenGLQtExportDialog:: textHeightChang 313 void G4OpenGLQtExportDialog:: textHeightChanged( 317 const QString & s 314 const QString & s 318 ) 315 ) 319 { 316 { 320 if (!ratioCheckBox) return; 317 if (!ratioCheckBox) return; 321 if (!width) return; 318 if (!width) return; 322 if (isChangingSize == true) return; // exclu 319 if (isChangingSize == true) return; // exclusive slot 323 320 324 if (ratioCheckBox->isChecked()){ 321 if (ratioCheckBox->isChecked()){ 325 isChangingSize = true; 322 isChangingSize = true; 326 QString tmp; 323 QString tmp; 327 width->setText(tmp.setNum(s.toInt()*origin 324 width->setText(tmp.setNum(s.toInt()*originalWidth/originalHeight)); 328 isChangingSize = false; 325 isChangingSize = false; 329 } 326 } 330 } << 327 } 331 328 332 G4OpenGLQtExportDialog::~G4OpenGLQtExportDialo 329 G4OpenGLQtExportDialog::~G4OpenGLQtExportDialog() 333 { 330 { 334 } 331 } >> 332 >> 333 >> 334 #endif 335 335