00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER
00032
00033 #include "G4OpenGLQtExportDialog.hh"
00034
00035 #include <qvariant.h>
00036 #include <qpushbutton.h>
00037 #include <qcheckbox.h>
00038 #include <qlabel.h>
00039 #include <qcombobox.h>
00040 #include <qslider.h>
00041 #include <qlayout.h>
00042 #include <qgroupbox.h>
00043 #include <qradiobutton.h>
00044 #include <qimage.h>
00045 #include <qlineedit.h>
00046 #include <qbuttongroup.h>
00047
00048 G4OpenGLQtExportDialog::G4OpenGLQtExportDialog(
00049 QWidget* parentw
00050 ,QString format
00051 ,int aHeight
00052 ,int aWidth
00053 )
00054 : QDialog( parentw ),
00055 isChangingSize(false)
00056 {
00057 setWindowTitle( tr( " Export options" ));
00058 originalWidth = aWidth;
00059 originalHeight = aHeight;
00060
00061
00062 qualitySlider = NULL;
00063 width = NULL;
00064 height = NULL;
00065 colorButton = NULL;
00066 BWButton = NULL;
00067
00068
00069 QVBoxLayout* globalVLayout = new QVBoxLayout(this);
00070 globalVLayout->setMargin(10);
00071 globalVLayout->setSpacing(10);
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 QWidget * sizeWidget = new QWidget(this);
00105 QVBoxLayout * sizeWidgetLayout = new QVBoxLayout(sizeWidget);
00106 sizeWidgetLayout->setMargin (10);
00107
00108
00109
00110 sizeGroupBox = new QGroupBox(tr("Size"));
00111 QVBoxLayout *sizeGroupBoxLayout = new QVBoxLayout(sizeGroupBox);
00112 QButtonGroup * sizeButtonGroupBox = new QButtonGroup();
00113 sizeGroupBoxLayout->setMargin (15);
00114
00115 original = new QRadioButton("Original");
00116 modify = new QRadioButton("Modify");
00117
00118 sizeButtonGroupBox->addButton(original);
00119 sizeButtonGroupBox->addButton(modify);
00120 sizeButtonGroupBox->setExclusive(true);
00121
00122 sizeGroupBoxLayout->addWidget(original);
00123 sizeGroupBoxLayout->addWidget(modify);
00124
00125 sizeGroupBox->setLayout(sizeGroupBoxLayout);
00126 sizeWidgetLayout->addWidget(sizeGroupBox);
00127
00128 connect( sizeButtonGroupBox, SIGNAL( buttonClicked(QAbstractButton*) ), this, SLOT( changeSizeBox()) );
00129 original->setChecked( true );
00130
00131
00132
00133 heightWidget = new QWidget(sizeWidget);
00134
00135 QHBoxLayout *heightLineLayout = new QHBoxLayout(heightWidget);
00136
00137 QString tmp;
00138
00139 heightLineLayout->addWidget(new QLabel("Height",heightWidget));
00140 height = new QLineEdit(tmp.setNum(originalHeight),heightWidget);
00141 height->setMaxLength(5);
00142 heightLineLayout->addWidget(height);
00143
00144 heightWidget->setLayout(heightLineLayout);
00145
00146 sizeWidgetLayout->addWidget(heightWidget);
00147 connect( height, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textHeightChanged(const QString &) ) );
00148
00149
00150
00151 widthWidget = new QWidget(sizeWidget);
00152
00153 QHBoxLayout *widthLineLayout = new QHBoxLayout(widthWidget);
00154
00155 widthLineLayout->addWidget(new QLabel("Width ",widthWidget));
00156 width = new QLineEdit(tmp.setNum(originalWidth),widthWidget);
00157 width->setMaxLength(5);
00158 widthLineLayout->addWidget(width);
00159 widthWidget->setLayout(widthLineLayout);
00160 sizeWidgetLayout->addWidget(widthWidget);
00161 connect( width, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textWidthChanged(const QString &) ) );
00162
00163
00164
00165
00166
00167 ratioCheckBox = new QCheckBox( "Keep ratio",sizeWidget);
00168 ratioCheckBox->setChecked( true );
00169
00170 sizeWidgetLayout->addWidget(ratioCheckBox);
00171
00172 ratioCheckBox->hide();
00173 heightWidget->hide();
00174 widthWidget->hide();
00175
00176 sizeWidget->setLayout(sizeWidgetLayout);
00177 globalVLayout->addWidget(sizeWidget);
00178
00179 if (format == "eps") {
00180
00181 QGroupBox *EPSWidgetGroupBox = new QGroupBox(tr("EPS options"),this);
00182
00183
00184 QVBoxLayout * EPSGroupBoxLayout = new QVBoxLayout(EPSWidgetGroupBox);
00185 EPSGroupBoxLayout->setMargin (15);
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 vectorEPSCheckBox = new QCheckBox( "Vector EPS File",EPSWidgetGroupBox);
00199 EPSGroupBoxLayout->addWidget(vectorEPSCheckBox);
00200
00201 EPSWidgetGroupBox->setLayout(EPSGroupBoxLayout);
00202
00203 vectorEPSCheckBox->setChecked( true );
00204
00205 globalVLayout->addWidget(EPSWidgetGroupBox);
00206 connect( vectorEPSCheckBox, SIGNAL( clicked() ), this, SLOT( changeVectorEPS()) );
00207
00208 }
00209
00210 if ((format == "jpg") ||
00211 (format == "jpeg")) {
00212
00213 QGroupBox *imageGroupBox = new QGroupBox(tr("Image quality"),this);
00214 QHBoxLayout *hSliderLayout = new QHBoxLayout(imageGroupBox);
00215 hSliderLayout->setMargin (15);
00216
00217 qualitySlider= new QSlider(Qt::Horizontal,imageGroupBox);
00218 qualitySlider->setMinimum(0);
00219 qualitySlider->setMaximum(100);
00220 qualitySlider->setTickPosition(QSlider::TicksBelow);
00221 qualitySlider->setValue(60);
00222 hSliderLayout->addWidget(new QLabel("Low ",imageGroupBox));
00223 hSliderLayout->addWidget(qualitySlider);
00224 hSliderLayout->addWidget(new QLabel(" Maximum",imageGroupBox));
00225
00226 imageGroupBox->setLayout(hSliderLayout);
00227
00228 globalVLayout->addWidget(imageGroupBox);
00229 }
00230
00231
00232
00233
00234 QWidget *buttonBox = new QWidget(this);
00235
00236 QHBoxLayout *buttonBoxLayout = new QHBoxLayout(buttonBox);
00237
00238 buttonOk = new QPushButton( tr( "&OK" ),buttonBox );
00239 buttonOk->setAutoDefault( TRUE );
00240 buttonOk->setDefault( TRUE );
00241 buttonBoxLayout->addWidget(buttonOk);
00242
00243 buttonCancel = new QPushButton( tr( "&Cancel" ),buttonBox );
00244 buttonCancel->setAutoDefault( TRUE );
00245 buttonBoxLayout->addWidget(buttonCancel);
00246
00247 buttonBox->setLayout(buttonBoxLayout);
00248 globalVLayout->addWidget(buttonBox);
00249
00250
00251
00252 setLayout(globalVLayout);
00253
00254
00255 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
00256 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
00257 }
00258
00259
00260
00261 int G4OpenGLQtExportDialog::getSliderValue()
00262 {
00263 if (!qualitySlider) return -1;
00264 return qualitySlider->value();
00265 }
00266
00267 int G4OpenGLQtExportDialog::getHeight()
00268 {
00269 if (!height) return originalHeight;
00270 return height->text().toInt();
00271 }
00272
00273 int G4OpenGLQtExportDialog::getWidth()
00274 {
00275 if (!width) return originalWidth;
00276 return width->text().toInt();
00277 }
00278
00279 int G4OpenGLQtExportDialog::getTransparency()
00280 {
00281 if (!boxTransparency) return -1;
00282 return boxTransparency->isChecked();
00283 }
00284
00285 int G4OpenGLQtExportDialog::getNbColor()
00286 {
00287 if (!colorButton) return -1;
00288
00289 if (!colorButton->isChecked())
00290 return 1;
00291
00292 return 3;
00293 }
00294
00295 bool G4OpenGLQtExportDialog::getVectorEPS()
00296 {
00297 if (!vectorEPSCheckBox) return 0;
00298 return vectorEPSCheckBox->isChecked();
00299 }
00300
00301
00302 void G4OpenGLQtExportDialog::changeVectorEPS()
00303 {
00304 if (!vectorEPSCheckBox) return;
00305 if (vectorEPSCheckBox->isChecked()) {
00306 sizeGroupBox->show();
00307 original->show();
00308 modify->show();
00309 changeSizeBox();
00310 } else {
00311 sizeGroupBox->hide();
00312 original->hide();
00313 modify->hide();
00314 ratioCheckBox->hide();
00315 heightWidget->hide();
00316 widthWidget->hide();
00317 }
00318 }
00319
00320
00321 void G4OpenGLQtExportDialog::changeSizeBox()
00322 {
00323 if (!original) return;
00324 if (!heightWidget) return;
00325 if (!widthWidget) return;
00326 if (!ratioCheckBox) return;
00327
00328 if ( original->isChecked()) {
00329 ratioCheckBox->hide();
00330 heightWidget->hide();
00331 widthWidget->hide();
00332 } else {
00333 heightWidget->show();
00334 widthWidget->show();
00335 ratioCheckBox->show();
00336 }
00337 }
00338
00339
00340 void G4OpenGLQtExportDialog::textWidthChanged(
00341 const QString & s
00342 )
00343 {
00344 if (!ratioCheckBox) return;
00345 if (!width) return;
00346 if (isChangingSize == true) return;
00347
00348 if (ratioCheckBox->isChecked()){
00349 isChangingSize = true;
00350 QString tmp;
00351 height->setText(tmp.setNum((int)(s.toInt()*(double)((double)originalHeight/(double)originalWidth))));
00352 isChangingSize = false;
00353 }
00354 }
00355
00356 void G4OpenGLQtExportDialog:: textHeightChanged(
00357 const QString & s
00358 )
00359 {
00360 if (!ratioCheckBox) return;
00361 if (!width) return;
00362 if (isChangingSize == true) return;
00363
00364 if (ratioCheckBox->isChecked()){
00365 isChangingSize = true;
00366 QString tmp;
00367 width->setText(tmp.setNum(s.toInt()*originalWidth/originalHeight));
00368 isChangingSize = false;
00369 }
00370 }
00371
00372 G4OpenGLQtExportDialog::~G4OpenGLQtExportDialog()
00373 {
00374 }
00375
00376
00377 #endif