source: trunk/geant4/visualization/OpenGL/src/G4OpenGLQtExportDialog.cc @ 589

Last change on this file since 589 was 589, checked in by garnier, 17 years ago

r618@mac-90108: laurentgarnier | 2007-09-26 18:45:28 +0200
eps ok couleur et BW

  • Property svn:mime-type set to text/cpp
File size: 8.6 KB
RevLine 
[581]1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
27// $Id: G4OpenGLQtExportDialog.cc,v 0.1 2007/09/20 15:18:20 garnier $
28// GEANT4 tag $Name: geant4-08-02-patch-01 $
29//
30//
31
32#ifdef G4VIS_BUILD_OPENGLQT_DRIVER
33
34#include "G4OpenGLQtExportDialog.hh"
35
36#include <qvariant.h>
37#include <qpushbutton.h>
38#include <qcheckbox.h>
39#include <qlabel.h>
40#include <qcombobox.h>
[582]41#include <qslider.h>
[581]42#include <qlayout.h>
43#include <qgroupbox.h>
[583]44#include <qradiobutton.h>
[581]45#include <qimage.h>
[583]46#include <qlineedit.h>
[581]47
48G4OpenGLQtExportDialog::G4OpenGLQtExportDialog(
49 QWidget* parent
[583]50,QString nomFich
51 ,int aHeight
52 ,int aWidth
53)
[581]54  : QDialog( parent )
55{
[582]56  setWindowTitle( tr( " Export options" ));
[583]57  originalWidth = aWidth;
58  originalHeight = aHeight;
59
60  // global layout
61  QVBoxLayout* globalVLayout = new QVBoxLayout();
62
[581]63 
[585]64  if (nomFich.endsWith(".jpg") ||
65      nomFich.endsWith(".jepg")) {
[581]66   
[583]67    QGroupBox *imageGroupBox = new QGroupBox(tr("Image quality"));
68    QVBoxLayout *imageGroupBoxLayout = new QVBoxLayout;
69
[582]70    QWidget *sliderBox = new QWidget;
71    QHBoxLayout *hSlider = new QHBoxLayout;
72    //    qualityLabel =  new QLabel( tr( "Image quality" ) );
[583]73    //    imageGroupBoxLayout->addWidget(qualityLabel);
[582]74    qualitySlider= new QSlider(Qt::Horizontal);
75    qualitySlider->setMinimum(0);
76    qualitySlider->setMaximum(100);
77    qualitySlider->setTickPosition(QSlider::TicksBelow);
78    qualitySlider->setValue(60);
79    hSlider->addWidget(new QLabel("low"));
80    hSlider->addWidget(qualitySlider);
81    hSlider->addWidget(new QLabel("Maximum"));
82    sliderBox->setLayout(hSlider);
[583]83    imageGroupBoxLayout->addWidget(sliderBox);
84
85    imageGroupBox->setLayout(imageGroupBoxLayout);
86    globalVLayout->addWidget(imageGroupBox);
[581]87  }
88 
[589]89  if(nomFich.endsWith(".eps")) {
[583]90    QGroupBox *EPSGroupBox = new QGroupBox(tr("EPS options"));
91    QVBoxLayout *EPSGroupBoxLayout = new QVBoxLayout;
92
[589]93    //    transparencyEPS = new QCheckBox( "transparencyEPS" );
94    //    transparencyEPS->setText( "save background" );
95    //    transparencyEPS->setChecked( true );
[583]96
97    color = new QRadioButton("Color");
98    BW = new QRadioButton("Grayscale");
99    color->setChecked( true );
100    BW->setChecked( false );
101
102
[589]103    //    EPSGroupBoxLayout->addWidget(transparencyEPS);   
[583]104    EPSGroupBoxLayout->addWidget(color);   
105    EPSGroupBoxLayout->addWidget(BW);   
106    EPSGroupBox->setLayout(EPSGroupBoxLayout);
107    globalVLayout->addWidget(EPSGroupBox);
108
[581]109  }
110
111  if(nomFich.endsWith(".tif") ||
112     nomFich.endsWith(".tiff") ||
[582]113     nomFich.endsWith(".jpg") ||
[581]114     nomFich.endsWith(".png") ||
115     nomFich.endsWith(".xpm")) {
[583]116
117    QGroupBox *transparencyGroupBox = new QGroupBox(tr("Transparency"));
118    QVBoxLayout *transparencyGroupBoxLayout = new QVBoxLayout;
119
120    boxTransparency = new QCheckBox("Save transparency");
[581]121    boxTransparency->setChecked( false );
[583]122    //    boxTransparency->setEnabled(false);
123
124    transparencyGroupBoxLayout->addWidget(boxTransparency);   
125    transparencyGroupBox->setLayout(transparencyGroupBoxLayout);
126    globalVLayout->addWidget(transparencyGroupBox);
127
[581]128  }
129
[584]130  // size box
[583]131  QGroupBox *sizeGroupBox = new QGroupBox(tr("Size"));
132  QVBoxLayout *sizeGroupBoxLayout = new QVBoxLayout;
133 
[584]134  QHBoxLayout *modifyAndRatioLayout = new QHBoxLayout;
135  QWidget* modifyAndRatioWidget = new QWidget;
136
137  // original button
[583]138  original = new QRadioButton("Original");
[584]139  original->setChecked( true );
140  sizeGroupBoxLayout->addWidget(original);
141
142  // modify and ratio
[583]143  modify = new QRadioButton("Modify");
144  modify->setChecked( false );
[584]145
146  ratioCheckBox = new QCheckBox( "Keep ratio" );
147  ratioCheckBox->setChecked( true );
148
149  modifyAndRatioLayout->addWidget(modify);
150  modifyAndRatioLayout->addWidget(ratioCheckBox);
151  modifyAndRatioWidget->setLayout(modifyAndRatioLayout);
152  sizeGroupBoxLayout->addWidget(modifyAndRatioWidget);
153  ratioCheckBox->setVisible(modify->isChecked());
154
[586]155  connect( original, SIGNAL( clicked(bool) ), this, SLOT( changeSizeBox(true)) );
156  connect( modify, SIGNAL( clicked(bool) ), this, SLOT( changeSizeBox(false) ) );
[581]157
[584]158  // height
[583]159  QHBoxLayout *heightLineLayout = new QHBoxLayout;
160  heightWidget = new QWidget;
161  QString tmp;
162 
163  heightLineLayout->addWidget(new QLabel("Height"));
164  height = new QLineEdit(tmp.setNum(originalHeight));
165  height->setMaxLength(5);
166  heightLineLayout->addWidget(height);
167  heightWidget->setLayout(heightLineLayout);
168  sizeGroupBoxLayout->addWidget(heightWidget);
[584]169  connect( height, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textHeightChanged(const QString &) ) );
[581]170
[584]171
172  // width
[583]173  QHBoxLayout *widthLineLayout = new QHBoxLayout;
174  widthWidget = new QWidget;
175
[585]176  widthLineLayout->addWidget(new QLabel("Width "));
[583]177  width = new QLineEdit(tmp.setNum(originalWidth));
178  width->setMaxLength(5);
179  widthLineLayout->addWidget(width);
180  widthWidget->setLayout(widthLineLayout);
181  sizeGroupBoxLayout->addWidget(widthWidget);
[584]182  connect( width, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textWidthChanged(const QString &) ) );
[583]183
184  sizeGroupBox->setLayout(sizeGroupBoxLayout);
185  globalVLayout->addWidget(sizeGroupBox);
186
187  heightWidget->setVisible(false);
188  widthWidget->setVisible(false);
189
[584]190  // button ok/cancel box
[583]191
192  QGroupBox *buttonGroupBox = new QGroupBox();
193  QHBoxLayout *buttonGroupBoxLayout = new QHBoxLayout;
194
[581]195  buttonOk = new QPushButton( tr( "&OK" ) );
196  buttonOk->setAutoDefault( TRUE );
197  buttonOk->setDefault( TRUE );
[583]198  buttonGroupBoxLayout->addWidget(buttonOk);
[581]199
200  buttonCancel = new QPushButton( tr( "&Cancel" ) );
201  buttonCancel->setAutoDefault( TRUE );
[583]202  buttonGroupBoxLayout->addWidget(buttonCancel);
[581]203
[583]204  buttonGroupBox->setLayout(buttonGroupBoxLayout);
205  globalVLayout->addWidget(buttonGroupBox);
[581]206
207
[583]208  setLayout(globalVLayout);
209
[581]210  // signals and slots connections
211  connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
212  connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
213}
214
215
216
[582]217int G4OpenGLQtExportDialog::getSliderValue()
218{
219  return qualitySlider->value();
220}
221
[585]222int G4OpenGLQtExportDialog::getHeight()
223{
224  return height->text().toInt();
225}
226
227int G4OpenGLQtExportDialog::getWidth()
228{
229  return width->text().toInt();
230}
231
[586]232int G4OpenGLQtExportDialog::getTransparency()
233{
234  return boxTransparency->isChecked();
235}
[585]236
[587]237int G4OpenGLQtExportDialog::getNbColor()
[581]238{
[587]239  // Black and white
[586]240  if (!color->isChecked())
241    return 1;
[587]242  // rgb color
[586]243  return 3;
[583]244}
[581]245
[586]246
247void G4OpenGLQtExportDialog::changeSizeBox(bool aClick)
248{
249  if (aClick) {
250    modify->toggle();
251  } else {
252    original->toggle();
253  }
254  if ( original->isChecked()) {
255    heightWidget->setVisible(false);
256    widthWidget->setVisible(false);
257    ratioCheckBox->setVisible(false);
258  } else {
259    heightWidget->setVisible(true);
260    widthWidget->setVisible(true);
261    ratioCheckBox->setVisible(true);
262  }
263}
264
[584]265void G4OpenGLQtExportDialog::textWidthChanged(
266 const QString & s
267 )
[583]268{
[584]269  if (ratioCheckBox->isChecked()){
270    QString tmp;
271    width->setText(tmp.setNum(s.toInt()*originalHeight/originalHeight));
272  }
[581]273}
274
[584]275void G4OpenGLQtExportDialog::  textHeightChanged(
276 const QString & s
277)
278{
279  if (ratioCheckBox->isChecked()){
280    QString tmp;
281    width->setText(tmp.setNum(s.toInt()*originalWidth/originalWidth));
282  }
283}
[581]284
285G4OpenGLQtExportDialog::~G4OpenGLQtExportDialog()
286{
287}
288
289
290#endif
Note: See TracBrowser for help on using the repository browser.