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

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

r610@mac-90108: laurentgarnier | 2007-09-25 16:54:15 +0200
boite de dialogue presque ok, reste plus qu a connecter

  • Property svn:mime-type set to text/cpp
File size: 8.4 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     nomFich.endsWith(".jpg")) {
91    QGroupBox *EPSGroupBox = new QGroupBox(tr("EPS options"));
92    QVBoxLayout *EPSGroupBoxLayout = new QVBoxLayout;
93
94    boxEPS = new QCheckBox( "boxEPS" );
95    boxEPS->setText( "save background" );
96    boxEPS->setChecked( true );
97
98    color = new QRadioButton("Color");
99    BW = new QRadioButton("Grayscale");
100    color->setChecked( true );
101    BW->setChecked( false );
102   
103    connect( color, SIGNAL( toggled(bool) ), BW, SLOT( setChecked(bool) ) );
104    connect( BW, SIGNAL( toggled(bool) ), color, SLOT( setChecked(bool) ) );
105
106
107    EPSGroupBoxLayout->addWidget(boxEPS);   
108    EPSGroupBoxLayout->addWidget(color);   
109    EPSGroupBoxLayout->addWidget(BW);   
110    EPSGroupBox->setLayout(EPSGroupBoxLayout);
111    globalVLayout->addWidget(EPSGroupBox);
112
113  }
114
115  if(nomFich.endsWith(".tif") ||
116     nomFich.endsWith(".tiff") ||
117     nomFich.endsWith(".jpg") ||
118     nomFich.endsWith(".png") ||
119     nomFich.endsWith(".xpm")) {
120
121    QGroupBox *transparencyGroupBox = new QGroupBox(tr("Transparency"));
122    QVBoxLayout *transparencyGroupBoxLayout = new QVBoxLayout;
123
124    boxTransparency = new QCheckBox("Save transparency");
125    boxTransparency->setChecked( false );
126    //    boxTransparency->setEnabled(false);
127
128    transparencyGroupBoxLayout->addWidget(boxTransparency);   
129    transparencyGroupBox->setLayout(transparencyGroupBoxLayout);
130    globalVLayout->addWidget(transparencyGroupBox);
131
132  }
133
134  // size box
135  QGroupBox *sizeGroupBox = new QGroupBox(tr("Size"));
136  QVBoxLayout *sizeGroupBoxLayout = new QVBoxLayout;
137 
138  QHBoxLayout *modifyAndRatioLayout = new QHBoxLayout;
139  QWidget* modifyAndRatioWidget = new QWidget;
140
141  // original button
142  original = new QRadioButton("Original");
143  original->setChecked( true );
144  sizeGroupBoxLayout->addWidget(original);
145
146  // modify and ratio
147  modify = new QRadioButton("Modify");
148  modify->setChecked( false );
149
150  ratioCheckBox = new QCheckBox( "Keep ratio" );
151  ratioCheckBox->setChecked( true );
152
153  modifyAndRatioLayout->addWidget(modify);
154  modifyAndRatioLayout->addWidget(ratioCheckBox);
155  modifyAndRatioWidget->setLayout(modifyAndRatioLayout);
156  sizeGroupBoxLayout->addWidget(modifyAndRatioWidget);
157  ratioCheckBox->setVisible(modify->isChecked());
158
159  connect( original, SIGNAL( toggled(bool) ), modify, SLOT( setChecked(bool) ) );
160  connect( modify, SIGNAL( toggled(bool) ), original, SLOT( setChecked(bool) ) );
161  connect( modify, SIGNAL( toggled(bool) ), this, SLOT( changeSizeBox(bool) ) );
162
163  // height
164  QHBoxLayout *heightLineLayout = new QHBoxLayout;
165  heightWidget = new QWidget;
166  QString tmp;
167 
168  heightLineLayout->addWidget(new QLabel("Height"));
169  height = new QLineEdit(tmp.setNum(originalHeight));
170  height->setMaxLength(5);
171  heightLineLayout->addWidget(height);
172  heightWidget->setLayout(heightLineLayout);
173  sizeGroupBoxLayout->addWidget(heightWidget);
174  connect( height, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textHeightChanged(const QString &) ) );
175
176
177  // width
178  QHBoxLayout *widthLineLayout = new QHBoxLayout;
179  widthWidget = new QWidget;
180
181  widthLineLayout->addWidget(new QLabel("Width "));
182  width = new QLineEdit(tmp.setNum(originalWidth));
183  width->setMaxLength(5);
184  widthLineLayout->addWidget(width);
185  widthWidget->setLayout(widthLineLayout);
186  sizeGroupBoxLayout->addWidget(widthWidget);
187  connect( width, SIGNAL( textChanged ( const QString& ) ), this, SLOT( textWidthChanged(const QString &) ) );
188
189  sizeGroupBox->setLayout(sizeGroupBoxLayout);
190  globalVLayout->addWidget(sizeGroupBox);
191
192  heightWidget->setVisible(false);
193  widthWidget->setVisible(false);
194
195  // button ok/cancel box
196
197  QGroupBox *buttonGroupBox = new QGroupBox();
198  QHBoxLayout *buttonGroupBoxLayout = new QHBoxLayout;
199
200  buttonOk = new QPushButton( tr( "&OK" ) );
201  buttonOk->setAutoDefault( TRUE );
202  buttonOk->setDefault( TRUE );
203  buttonGroupBoxLayout->addWidget(buttonOk);
204
205  buttonCancel = new QPushButton( tr( "&Cancel" ) );
206  buttonCancel->setAutoDefault( TRUE );
207  buttonGroupBoxLayout->addWidget(buttonCancel);
208
209  buttonGroupBox->setLayout(buttonGroupBoxLayout);
210  globalVLayout->addWidget(buttonGroupBox);
211
212
213  setLayout(globalVLayout);
214
215  // signals and slots connections
216  connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
217  connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
218}
219
220
221
222int G4OpenGLQtExportDialog::getSliderValue()
223{
224  return qualitySlider->value();
225}
226
227int G4OpenGLQtExportDialog::getHeight()
228{
229  return height->text().toInt();
230}
231
232int G4OpenGLQtExportDialog::getWidth()
233{
234  return width->text().toInt();
235}
236
237
238void G4OpenGLQtExportDialog::changeSizeBox(bool aChange)
239{
240  heightWidget->setVisible(modify->isChecked());
241  widthWidget->setVisible(modify->isChecked());
242  ratioCheckBox->setVisible(modify->isChecked());
243}
244
245void G4OpenGLQtExportDialog::textWidthChanged(
246 const QString & s
247 )
248{
249  if (ratioCheckBox->isChecked()){
250    QString tmp;
251    width->setText(tmp.setNum(s.toInt()*originalHeight/originalHeight));
252  }
253}
254
255void G4OpenGLQtExportDialog::  textHeightChanged(
256 const QString & s
257)
258{
259  if (ratioCheckBox->isChecked()){
260    QString tmp;
261    width->setText(tmp.setNum(s.toInt()*originalWidth/originalWidth));
262  }
263}
264
265G4OpenGLQtExportDialog::~G4OpenGLQtExportDialog()
266{
267}
268
269
270#endif
Note: See TracBrowser for help on using the repository browser.