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
Line 
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>
41#include <qslider.h>
42#include <qlayout.h>
43#include <qgroupbox.h>
44#include <qradiobutton.h>
45#include <qimage.h>
46#include <qlineedit.h>
47
48G4OpenGLQtExportDialog::G4OpenGLQtExportDialog(
49 QWidget* parent
50,QString nomFich
51 ,int aHeight
52 ,int aWidth
53)
54  : QDialog( parent )
55{
56  setWindowTitle( tr( " Export options" ));
57  originalWidth = aWidth;
58  originalHeight = aHeight;
59
60  // global layout
61  QVBoxLayout* globalVLayout = new QVBoxLayout();
62
63 
64  if (nomFich.endsWith(".jpg") ||
65      nomFich.endsWith(".jepg")) {
66   
67    QGroupBox *imageGroupBox = new QGroupBox(tr("Image quality"));
68    QVBoxLayout *imageGroupBoxLayout = new QVBoxLayout;
69
70    QWidget *sliderBox = new QWidget;
71    QHBoxLayout *hSlider = new QHBoxLayout;
72    //    qualityLabel =  new QLabel( tr( "Image quality" ) );
73    //    imageGroupBoxLayout->addWidget(qualityLabel);
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);
83    imageGroupBoxLayout->addWidget(sliderBox);
84
85    imageGroupBox->setLayout(imageGroupBoxLayout);
86    globalVLayout->addWidget(imageGroupBox);
87  }
88 
89  if(nomFich.endsWith(".eps")) {
90    QGroupBox *EPSGroupBox = new QGroupBox(tr("EPS options"));
91    QVBoxLayout *EPSGroupBoxLayout = new QVBoxLayout;
92
93    //    transparencyEPS = new QCheckBox( "transparencyEPS" );
94    //    transparencyEPS->setText( "save background" );
95    //    transparencyEPS->setChecked( true );
96
97    color = new QRadioButton("Color");
98    BW = new QRadioButton("Grayscale");
99    color->setChecked( true );
100    BW->setChecked( false );
101
102
103    //    EPSGroupBoxLayout->addWidget(transparencyEPS);   
104    EPSGroupBoxLayout->addWidget(color);   
105    EPSGroupBoxLayout->addWidget(BW);   
106    EPSGroupBox->setLayout(EPSGroupBoxLayout);
107    globalVLayout->addWidget(EPSGroupBox);
108
109  }
110
111  if(nomFich.endsWith(".tif") ||
112     nomFich.endsWith(".tiff") ||
113     nomFich.endsWith(".jpg") ||
114     nomFich.endsWith(".png") ||
115     nomFich.endsWith(".xpm")) {
116
117    QGroupBox *transparencyGroupBox = new QGroupBox(tr("Transparency"));
118    QVBoxLayout *transparencyGroupBoxLayout = new QVBoxLayout;
119
120    boxTransparency = new QCheckBox("Save transparency");
121    boxTransparency->setChecked( false );
122    //    boxTransparency->setEnabled(false);
123
124    transparencyGroupBoxLayout->addWidget(boxTransparency);   
125    transparencyGroupBox->setLayout(transparencyGroupBoxLayout);
126    globalVLayout->addWidget(transparencyGroupBox);
127
128  }
129
130  // size box
131  QGroupBox *sizeGroupBox = new QGroupBox(tr("Size"));
132  QVBoxLayout *sizeGroupBoxLayout = new QVBoxLayout;
133 
134  QHBoxLayout *modifyAndRatioLayout = new QHBoxLayout;
135  QWidget* modifyAndRatioWidget = new QWidget;
136
137  // original button
138  original = new QRadioButton("Original");
139  original->setChecked( true );
140  sizeGroupBoxLayout->addWidget(original);
141
142  // modify and ratio
143  modify = new QRadioButton("Modify");
144  modify->setChecked( false );
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
155  connect( original, SIGNAL( clicked(bool) ), this, SLOT( changeSizeBox(true)) );
156  connect( modify, SIGNAL( clicked(bool) ), this, SLOT( changeSizeBox(false) ) );
157
158  // height
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);
169  connect( height, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textHeightChanged(const QString &) ) );
170
171
172  // width
173  QHBoxLayout *widthLineLayout = new QHBoxLayout;
174  widthWidget = new QWidget;
175
176  widthLineLayout->addWidget(new QLabel("Width "));
177  width = new QLineEdit(tmp.setNum(originalWidth));
178  width->setMaxLength(5);
179  widthLineLayout->addWidget(width);
180  widthWidget->setLayout(widthLineLayout);
181  sizeGroupBoxLayout->addWidget(widthWidget);
182  connect( width, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textWidthChanged(const QString &) ) );
183
184  sizeGroupBox->setLayout(sizeGroupBoxLayout);
185  globalVLayout->addWidget(sizeGroupBox);
186
187  heightWidget->setVisible(false);
188  widthWidget->setVisible(false);
189
190  // button ok/cancel box
191
192  QGroupBox *buttonGroupBox = new QGroupBox();
193  QHBoxLayout *buttonGroupBoxLayout = new QHBoxLayout;
194
195  buttonOk = new QPushButton( tr( "&OK" ) );
196  buttonOk->setAutoDefault( TRUE );
197  buttonOk->setDefault( TRUE );
198  buttonGroupBoxLayout->addWidget(buttonOk);
199
200  buttonCancel = new QPushButton( tr( "&Cancel" ) );
201  buttonCancel->setAutoDefault( TRUE );
202  buttonGroupBoxLayout->addWidget(buttonCancel);
203
204  buttonGroupBox->setLayout(buttonGroupBoxLayout);
205  globalVLayout->addWidget(buttonGroupBox);
206
207
208  setLayout(globalVLayout);
209
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
217int G4OpenGLQtExportDialog::getSliderValue()
218{
219  return qualitySlider->value();
220}
221
222int G4OpenGLQtExportDialog::getHeight()
223{
224  return height->text().toInt();
225}
226
227int G4OpenGLQtExportDialog::getWidth()
228{
229  return width->text().toInt();
230}
231
232int G4OpenGLQtExportDialog::getTransparency()
233{
234  return boxTransparency->isChecked();
235}
236
237int G4OpenGLQtExportDialog::getNbColor()
238{
239  // Black and white
240  if (!color->isChecked())
241    return 1;
242  // rgb color
243  return 3;
244}
245
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
265void G4OpenGLQtExportDialog::textWidthChanged(
266 const QString & s
267 )
268{
269  if (ratioCheckBox->isChecked()){
270    QString tmp;
271    width->setText(tmp.setNum(s.toInt()*originalHeight/originalHeight));
272  }
273}
274
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}
284
285G4OpenGLQtExportDialog::~G4OpenGLQtExportDialog()
286{
287}
288
289
290#endif
Note: See TracBrowser for help on using the repository browser.