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 // $Id: G4OpenGLQtExportDialog.cc,v 1.9 2008-10-24 14:17:10 lgarnier Exp $ >> 28 // GEANT4 tag $Name: not supported by cvs2svn $ 27 // 29 // 28 // << 30 // >> 31 >> 32 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER 29 33 30 #include "G4OpenGLQtExportDialog.hh" 34 #include "G4OpenGLQtExportDialog.hh" 31 35 32 #include <qvariant.h> 36 #include <qvariant.h> 33 #include <qpushbutton.h> 37 #include <qpushbutton.h> 34 #include <qcheckbox.h> 38 #include <qcheckbox.h> 35 #include <qlabel.h> 39 #include <qlabel.h> 36 #include <qcombobox.h> 40 #include <qcombobox.h> 37 #include <qslider.h> 41 #include <qslider.h> 38 #include <qlayout.h> 42 #include <qlayout.h> 39 #include <qgroupbox.h> 43 #include <qgroupbox.h> 40 #include <qradiobutton.h> 44 #include <qradiobutton.h> 41 #include <qimage.h> 45 #include <qimage.h> 42 #include <qlineedit.h> 46 #include <qlineedit.h> 43 #include <qbuttongroup.h> 47 #include <qbuttongroup.h> 44 48 45 #ifndef G4GMAKE << 46 #include "moc_G4OpenGLQtExportDialog.cpp" << 47 #endif << 48 << 49 G4OpenGLQtExportDialog::G4OpenGLQtExportDialog 49 G4OpenGLQtExportDialog::G4OpenGLQtExportDialog( 50 QWidget* parentw << 50 QWidget* parent 51 ,QString format 51 ,QString format 52 ,int aHeight 52 ,int aHeight 53 ,int aWidth 53 ,int aWidth 54 ) 54 ) 55 : QDialog( parentw ), << 55 : QDialog( parent ), 56 isChangingSize(false) 56 isChangingSize(false) 57 { 57 { 58 setWindowTitle( tr( " Export options" )); 58 setWindowTitle( tr( " Export options" )); 59 originalWidth = aWidth; 59 originalWidth = aWidth; 60 originalHeight = aHeight; 60 originalHeight = aHeight; 61 61 62 // Initializations 62 // Initializations 63 vectorEPSCheckBox = NULL; << 64 qualitySlider = NULL; 63 qualitySlider = NULL; 65 width = NULL; 64 width = NULL; 66 height = NULL; 65 height = NULL; 67 colorButton = NULL; 66 colorButton = NULL; 68 BWButton = NULL; 67 BWButton = NULL; 69 68 70 // global layout 69 // global layout 71 QVBoxLayout* globalVLayout = new QVBoxLayout 70 QVBoxLayout* globalVLayout = new QVBoxLayout(this); 72 globalVLayout->setContentsMargins(10,10,10,1 << 71 globalVLayout->setMargin(10); 73 globalVLayout->setSpacing(10); 72 globalVLayout->setSpacing(10); >> 73 >> 74 >> 75 >> 76 // FIXME : L. Garnier 4/12/07 >> 77 // Not implented. Should deal with alpha channel >> 78 >> 79 // if((format == "tif") || >> 80 // (format == "tiff") || >> 81 // (format == "jpg") || >> 82 // (format == "jpeg") || >> 83 // (format == "png") || >> 84 // (format == "xpm")) { 74 85 >> 86 // QGroupBox *transparencyGroupBox = new QGroupBox(tr("Transparency"),this); >> 87 // QVBoxLayout *transparencyGroupBoxLayout = new QVBoxLayout(transparencyGroupBox); 75 88 >> 89 // boxTransparency = new QCheckBox("Save transparency",transparencyGroupBox); >> 90 // boxTransparency->setChecked( false ); >> 91 >> 92 // transparencyGroupBoxLayout->addWidget(boxTransparency); >> 93 // globalVLayout->addWidget(transparencyGroupBox); >> 94 >> 95 // } >> 96 >> 97 // FIXME : L. Garnier 4/12/07 >> 98 // This is not working for PS and PDF images, it does nothing. >> 99 // Image is staying in color mode >> 100 // if ((format == "ps") || (format == "pdf") || (format == "eps")) { 76 101 77 102 78 // size box 103 // size box 79 104 80 QWidget * sizeWidget = new QWidget(this); // 105 QWidget * sizeWidget = new QWidget(this); // widget containing group button 81 QVBoxLayout * sizeWidgetLayout = new QVBoxLa 106 QVBoxLayout * sizeWidgetLayout = new QVBoxLayout(sizeWidget); 82 sizeWidgetLayout->setContentsMargins(10,10,1 << 107 sizeWidgetLayout->setMargin (10); 83 108 84 // original and modify radiobuttons 109 // original and modify radiobuttons 85 << 110 86 sizeGroupBox = new QGroupBox(tr("Size")); 111 sizeGroupBox = new QGroupBox(tr("Size")); 87 QVBoxLayout *sizeGroupBoxLayout = new QVBoxL 112 QVBoxLayout *sizeGroupBoxLayout = new QVBoxLayout(sizeGroupBox); 88 QButtonGroup * sizeButtonGroupBox = new QBut 113 QButtonGroup * sizeButtonGroupBox = new QButtonGroup(); 89 sizeGroupBoxLayout->setContentsMargins(15,15 << 114 sizeGroupBoxLayout->setMargin (15); 90 115 91 original = new QRadioButton("Original"); 116 original = new QRadioButton("Original"); 92 modify = new QRadioButton("Modify"); 117 modify = new QRadioButton("Modify"); 93 118 94 sizeButtonGroupBox->addButton(original); 119 sizeButtonGroupBox->addButton(original); 95 sizeButtonGroupBox->addButton(modify); 120 sizeButtonGroupBox->addButton(modify); 96 sizeButtonGroupBox->setExclusive(true); 121 sizeButtonGroupBox->setExclusive(true); 97 122 98 sizeGroupBoxLayout->addWidget(original); << 123 sizeGroupBoxLayout->addWidget(original); 99 sizeGroupBoxLayout->addWidget(modify); << 124 sizeGroupBoxLayout->addWidget(modify); 100 125 101 sizeGroupBox->setLayout(sizeGroupBoxLayout); 126 sizeGroupBox->setLayout(sizeGroupBoxLayout); 102 sizeWidgetLayout->addWidget(sizeGroupBox); 127 sizeWidgetLayout->addWidget(sizeGroupBox); 103 << 128 104 connect( sizeButtonGroupBox, SIGNAL( buttonC 129 connect( sizeButtonGroupBox, SIGNAL( buttonClicked(QAbstractButton*) ), this, SLOT( changeSizeBox()) ); 105 original->setChecked( true ); 130 original->setChecked( true ); 106 131 107 132 108 // height 133 // height 109 heightWidget = new QWidget(sizeWidget); 134 heightWidget = new QWidget(sizeWidget); 110 135 111 QHBoxLayout *heightLineLayout = new QHBoxLay 136 QHBoxLayout *heightLineLayout = new QHBoxLayout(heightWidget); 112 137 113 QString tmp; 138 QString tmp; 114 << 139 115 heightLineLayout->addWidget(new QLabel("Heig 140 heightLineLayout->addWidget(new QLabel("Height",heightWidget)); 116 height = new QLineEdit(tmp.setNum(originalHe 141 height = new QLineEdit(tmp.setNum(originalHeight),heightWidget); 117 height->setMaxLength(5); 142 height->setMaxLength(5); 118 heightLineLayout->addWidget(height); 143 heightLineLayout->addWidget(height); 119 144 120 heightWidget->setLayout(heightLineLayout); 145 heightWidget->setLayout(heightLineLayout); 121 146 122 sizeWidgetLayout->addWidget(heightWidget); 147 sizeWidgetLayout->addWidget(heightWidget); 123 connect( height, SIGNAL( textChanged ( const 148 connect( height, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textHeightChanged(const QString &) ) ); 124 149 125 150 126 // width 151 // width 127 widthWidget = new QWidget(sizeWidget); 152 widthWidget = new QWidget(sizeWidget); 128 153 129 QHBoxLayout *widthLineLayout = new QHBoxLayo 154 QHBoxLayout *widthLineLayout = new QHBoxLayout(widthWidget); 130 155 131 widthLineLayout->addWidget(new QLabel("Width 156 widthLineLayout->addWidget(new QLabel("Width ",widthWidget)); 132 width = new QLineEdit(tmp.setNum(originalWid 157 width = new QLineEdit(tmp.setNum(originalWidth),widthWidget); 133 width->setMaxLength(5); 158 width->setMaxLength(5); 134 widthLineLayout->addWidget(width); 159 widthLineLayout->addWidget(width); 135 widthWidget->setLayout(widthLineLayout); 160 widthWidget->setLayout(widthLineLayout); 136 sizeWidgetLayout->addWidget(widthWidget); 161 sizeWidgetLayout->addWidget(widthWidget); 137 connect( width, SIGNAL( textChanged ( const 162 connect( width, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textWidthChanged(const QString &) ) ); 138 163 139 164 140 165 141 // ratio check box 166 // ratio check box 142 167 143 ratioCheckBox = new QCheckBox( "Keep ratio", 168 ratioCheckBox = new QCheckBox( "Keep ratio",sizeWidget); 144 ratioCheckBox->setChecked( true ); 169 ratioCheckBox->setChecked( true ); 145 170 146 sizeWidgetLayout->addWidget(ratioCheckBox); 171 sizeWidgetLayout->addWidget(ratioCheckBox); 147 172 148 ratioCheckBox->hide(); 173 ratioCheckBox->hide(); 149 heightWidget->hide(); 174 heightWidget->hide(); 150 widthWidget->hide(); 175 widthWidget->hide(); 151 176 152 sizeWidget->setLayout(sizeWidgetLayout); 177 sizeWidget->setLayout(sizeWidgetLayout); 153 globalVLayout->addWidget(sizeWidget); 178 globalVLayout->addWidget(sizeWidget); 154 179 155 if (format == "eps") { 180 if (format == "eps") { 156 181 157 QGroupBox *EPSWidgetGroupBox = new QGroupBo 182 QGroupBox *EPSWidgetGroupBox = new QGroupBox(tr("EPS options"),this); // widget containing group button 158 183 159 184 160 QVBoxLayout * EPSGroupBoxLayout = new QVBo 185 QVBoxLayout * EPSGroupBoxLayout = new QVBoxLayout(EPSWidgetGroupBox); 161 EPSGroupBoxLayout->setContentsMargins(15, << 186 EPSGroupBoxLayout->setMargin (15); 162 187 163 // colorButton = new QRadioButton("Color", 188 // colorButton = new QRadioButton("Color",EPSWidgetGroupBox); 164 // BWButton = new QRadioButton("Grayscale" 189 // BWButton = new QRadioButton("Grayscale",EPSWidgetGroupBox); 165 190 166 // QButtonGroup * EPSColorButtonGroupBox = 191 // QButtonGroup * EPSColorButtonGroupBox = new QButtonGroup(); 167 // EPSColorButtonGroupBox->addButton(color 192 // EPSColorButtonGroupBox->addButton(colorButton); 168 // EPSColorButtonGroupBox->addButton(BWBut 193 // EPSColorButtonGroupBox->addButton(BWButton); 169 // EPSColorButtonGroupBox->setExclusive(tr 194 // EPSColorButtonGroupBox->setExclusive(true); 170 195 171 // EPSGroupBoxLayout->addWidget(colorButto << 196 // EPSGroupBoxLayout->addWidget(colorButton); 172 // EPSGroupBoxLayout->addWidget(BWButton); << 197 // EPSGroupBoxLayout->addWidget(BWButton); 173 198 174 vectorEPSCheckBox = new QCheckBox( "Vector 199 vectorEPSCheckBox = new QCheckBox( "Vector EPS File",EPSWidgetGroupBox); 175 EPSGroupBoxLayout->addWidget(vectorEPSChec 200 EPSGroupBoxLayout->addWidget(vectorEPSCheckBox); 176 201 177 EPSWidgetGroupBox->setLayout(EPSGroupBoxLa 202 EPSWidgetGroupBox->setLayout(EPSGroupBoxLayout); 178 // colorButton->setChecked( true ); 203 // colorButton->setChecked( true ); 179 vectorEPSCheckBox->setChecked( true ); 204 vectorEPSCheckBox->setChecked( true ); 180 << 205 181 globalVLayout->addWidget(EPSWidgetGroupBox 206 globalVLayout->addWidget(EPSWidgetGroupBox); 182 connect( vectorEPSCheckBox, SIGNAL( clicke 207 connect( vectorEPSCheckBox, SIGNAL( clicked() ), this, SLOT( changeVectorEPS()) ); 183 208 184 } 209 } 185 210 186 if ((format == "jpg") || << 211 if ((format == "jpg") || 187 (format == "jpeg")) { 212 (format == "jpeg")) { 188 << 213 189 QGroupBox *imageGroupBox = new QGroupBox(t 214 QGroupBox *imageGroupBox = new QGroupBox(tr("Image quality"),this); 190 QHBoxLayout *hSliderLayout = new QHBoxLayo 215 QHBoxLayout *hSliderLayout = new QHBoxLayout(imageGroupBox); 191 hSliderLayout->setContentsMargins(15,15,15 << 216 hSliderLayout->setMargin (15); 192 217 193 qualitySlider= new QSlider(Qt::Horizontal, 218 qualitySlider= new QSlider(Qt::Horizontal,imageGroupBox); 194 qualitySlider->setMinimum(0); 219 qualitySlider->setMinimum(0); 195 qualitySlider->setMaximum(100); 220 qualitySlider->setMaximum(100); 196 qualitySlider->setTickPosition(QSlider::Ti 221 qualitySlider->setTickPosition(QSlider::TicksBelow); 197 qualitySlider->setValue(60); 222 qualitySlider->setValue(60); 198 hSliderLayout->addWidget(new QLabel("Low " 223 hSliderLayout->addWidget(new QLabel("Low ",imageGroupBox)); 199 hSliderLayout->addWidget(qualitySlider); 224 hSliderLayout->addWidget(qualitySlider); 200 hSliderLayout->addWidget(new QLabel(" Maxi 225 hSliderLayout->addWidget(new QLabel(" Maximum",imageGroupBox)); 201 << 226 202 imageGroupBox->setLayout(hSliderLayout); 227 imageGroupBox->setLayout(hSliderLayout); 203 228 204 globalVLayout->addWidget(imageGroupBox); 229 globalVLayout->addWidget(imageGroupBox); 205 } 230 } 206 231 207 232 208 // button ok/cancel box 233 // button ok/cancel box 209 234 210 QWidget *buttonBox = new QWidget(this); 235 QWidget *buttonBox = new QWidget(this); 211 236 212 QHBoxLayout *buttonBoxLayout = new QHBoxLayo 237 QHBoxLayout *buttonBoxLayout = new QHBoxLayout(buttonBox); 213 238 214 buttonOk = new QPushButton( tr( "&OK" ),butt 239 buttonOk = new QPushButton( tr( "&OK" ),buttonBox ); 215 buttonOk->setAutoDefault( true ); << 240 buttonOk->setAutoDefault( TRUE ); 216 buttonOk->setDefault( true ); << 241 buttonOk->setDefault( TRUE ); 217 buttonBoxLayout->addWidget(buttonOk); 242 buttonBoxLayout->addWidget(buttonOk); 218 243 219 buttonCancel = new QPushButton( tr( "&Cancel 244 buttonCancel = new QPushButton( tr( "&Cancel" ),buttonBox ); 220 buttonCancel->setAutoDefault( true ); << 245 buttonCancel->setAutoDefault( TRUE ); 221 buttonBoxLayout->addWidget(buttonCancel); 246 buttonBoxLayout->addWidget(buttonCancel); 222 247 223 buttonBox->setLayout(buttonBoxLayout); 248 buttonBox->setLayout(buttonBoxLayout); 224 globalVLayout->addWidget(buttonBox); 249 globalVLayout->addWidget(buttonBox); 225 250 226 251 227 252 228 setLayout(globalVLayout); 253 setLayout(globalVLayout); 229 254 230 // signals and slots connections 255 // signals and slots connections 231 connect( buttonOk, SIGNAL( clicked() ), this 256 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); 232 connect( buttonCancel, SIGNAL( clicked() ), 257 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); 233 } 258 } 234 259 235 260 236 261 237 int G4OpenGLQtExportDialog::getSliderValue() 262 int G4OpenGLQtExportDialog::getSliderValue() 238 { 263 { 239 if (!qualitySlider) return -1; 264 if (!qualitySlider) return -1; 240 return qualitySlider->value(); 265 return qualitySlider->value(); 241 } 266 } 242 267 243 int G4OpenGLQtExportDialog::getHeight() 268 int G4OpenGLQtExportDialog::getHeight() 244 { 269 { 245 if (!height) return originalHeight; 270 if (!height) return originalHeight; 246 return height->text().toInt(); 271 return height->text().toInt(); 247 } 272 } 248 273 249 int G4OpenGLQtExportDialog::getWidth() 274 int G4OpenGLQtExportDialog::getWidth() 250 { 275 { 251 if (!width) return originalWidth; 276 if (!width) return originalWidth; 252 return width->text().toInt(); 277 return width->text().toInt(); 253 } 278 } 254 279 >> 280 int G4OpenGLQtExportDialog::getTransparency() >> 281 { >> 282 if (!boxTransparency) return -1; >> 283 return boxTransparency->isChecked(); >> 284 } >> 285 >> 286 int G4OpenGLQtExportDialog::getNbColor() >> 287 { >> 288 if (!colorButton) return -1; >> 289 // Black and white >> 290 if (!colorButton->isChecked()) >> 291 return 1; >> 292 // rgb color >> 293 return 3; >> 294 } >> 295 255 bool G4OpenGLQtExportDialog::getVectorEPS() 296 bool G4OpenGLQtExportDialog::getVectorEPS() 256 { 297 { 257 if (!vectorEPSCheckBox) return 0; 298 if (!vectorEPSCheckBox) return 0; 258 return vectorEPSCheckBox->isChecked(); 299 return vectorEPSCheckBox->isChecked(); 259 } 300 } 260 301 261 302 262 void G4OpenGLQtExportDialog::changeVectorEPS() 303 void G4OpenGLQtExportDialog::changeVectorEPS() 263 { 304 { 264 if (!vectorEPSCheckBox) return; 305 if (!vectorEPSCheckBox) return; 265 if (vectorEPSCheckBox->isChecked()) { 306 if (vectorEPSCheckBox->isChecked()) { 266 sizeGroupBox->show(); 307 sizeGroupBox->show(); 267 original->show(); 308 original->show(); 268 modify->show(); 309 modify->show(); 269 changeSizeBox(); 310 changeSizeBox(); 270 } else { 311 } else { 271 sizeGroupBox->hide(); 312 sizeGroupBox->hide(); 272 original->hide(); 313 original->hide(); 273 modify->hide(); 314 modify->hide(); 274 ratioCheckBox->hide(); 315 ratioCheckBox->hide(); 275 heightWidget->hide(); 316 heightWidget->hide(); 276 widthWidget->hide(); 317 widthWidget->hide(); 277 } 318 } 278 } 319 } 279 320 280 321 281 void G4OpenGLQtExportDialog::changeSizeBox() 322 void G4OpenGLQtExportDialog::changeSizeBox() 282 { 323 { 283 if (!original) return; 324 if (!original) return; 284 if (!heightWidget) return; 325 if (!heightWidget) return; 285 if (!widthWidget) return; 326 if (!widthWidget) return; 286 if (!ratioCheckBox) return; 327 if (!ratioCheckBox) return; 287 328 288 if ( original->isChecked()) { 329 if ( original->isChecked()) { 289 ratioCheckBox->hide(); 330 ratioCheckBox->hide(); 290 heightWidget->hide(); 331 heightWidget->hide(); 291 widthWidget->hide(); 332 widthWidget->hide(); 292 } else { 333 } else { 293 heightWidget->show(); 334 heightWidget->show(); 294 widthWidget->show(); 335 widthWidget->show(); 295 ratioCheckBox->show(); 336 ratioCheckBox->show(); 296 } 337 } 297 } 338 } 298 339 299 340 300 void G4OpenGLQtExportDialog::textWidthChanged( 341 void G4OpenGLQtExportDialog::textWidthChanged( 301 const QString & s 342 const QString & s 302 ) 343 ) 303 { 344 { 304 if (!ratioCheckBox) return; 345 if (!ratioCheckBox) return; 305 if (!width) return; 346 if (!width) return; 306 if (isChangingSize == true) return; // exclu 347 if (isChangingSize == true) return; // exclusive slot 307 348 308 if (ratioCheckBox->isChecked()){ 349 if (ratioCheckBox->isChecked()){ 309 isChangingSize = true; 350 isChangingSize = true; 310 QString tmp; 351 QString tmp; 311 height->setText(tmp.setNum((int)(s.toInt()*( 352 height->setText(tmp.setNum((int)(s.toInt()*(double)((double)originalHeight/(double)originalWidth)))); 312 isChangingSize = false; 353 isChangingSize = false; 313 } 354 } 314 } 355 } 315 356 316 void G4OpenGLQtExportDialog:: textHeightChang 357 void G4OpenGLQtExportDialog:: textHeightChanged( 317 const QString & s 358 const QString & s 318 ) 359 ) 319 { 360 { 320 if (!ratioCheckBox) return; 361 if (!ratioCheckBox) return; 321 if (!width) return; 362 if (!width) return; 322 if (isChangingSize == true) return; // exclu 363 if (isChangingSize == true) return; // exclusive slot 323 364 324 if (ratioCheckBox->isChecked()){ 365 if (ratioCheckBox->isChecked()){ 325 isChangingSize = true; 366 isChangingSize = true; 326 QString tmp; 367 QString tmp; 327 width->setText(tmp.setNum(s.toInt()*origin 368 width->setText(tmp.setNum(s.toInt()*originalWidth/originalHeight)); 328 isChangingSize = false; 369 isChangingSize = false; 329 } 370 } 330 } << 371 } 331 372 332 G4OpenGLQtExportDialog::~G4OpenGLQtExportDialo 373 G4OpenGLQtExportDialog::~G4OpenGLQtExportDialog() 333 { 374 { 334 } 375 } >> 376 >> 377 >> 378 #endif 335 379