Isis 3 Programmer Reference
SaveAsDialog.cpp
1 #include "SaveAsDialog.h"
2 
3 #include <iostream>
4 
5 #include <QButtonGroup>
6 #include <QLayout>
7 #include <QFileDialog>
8 #include <QPushButton>
9 
10 using namespace std;
11 
12 namespace Isis {
13 
24  SaveAsDialog::SaveAsDialog(QString pTitle, QStringList &pFilterList, QDir &pDir, QWidget *pParent) :
25  FileDialog(pTitle, pFilterList, pDir, pParent), p_dir(pDir)
26  {
27 
28  this->setFileMode(QFileDialog::AnyFile);
29  // This returns a list of all the buttons in QFileDialog
30  QList<QPushButton *> allPButtons = this->findChildren<QPushButton *>();
31 
32  // Edit the first (Open) button title.
33  this->setLabelText(QFileDialog::Accept, "Save");
35  this->setLabelText(QFileDialog::Reject, "Cancel");
36 
37  p_saveAsType = FullImage;
38  QHBoxLayout *hBoxLayout = new QHBoxLayout;
39  hBoxLayout->setAlignment(Qt::AlignLeft);
40  hBoxLayout->setSpacing(25);
41  hBoxLayout->setContentsMargins (25, 11, 25, 11 );
42 
43  // Button Group
44  QButtonGroup *exportOptionsGrp = new QButtonGroup();
45  exportOptionsGrp->setExclusive(true); // only one option can be clicked
46 
47  p_fullImage = new QRadioButton("Export Entire &Image", this);
48  connect(p_fullImage, SIGNAL(clicked(bool)), this, SLOT(setFullImage(bool)));
49  exportOptionsGrp->addButton(p_fullImage);
50  p_fullImage->setWhatsThis("Make a duplicate of the original image.");
51 
52  p_exportAsIs = new QRadioButton("Export Viewport &As Is", this);
53  connect(p_exportAsIs, SIGNAL(clicked(bool)), this, SLOT(setAsIs(bool)));
54  exportOptionsGrp->addButton(p_exportAsIs);
55  p_exportAsIs->setWhatsThis("Save the viewport as it is currently being viewed.");
56 
57  p_exportFullRes = new QRadioButton("Export Viewport at Full &Res", this);
58  connect(p_exportFullRes, SIGNAL(clicked(bool)), this, SLOT(setFullResolution(bool)));
59  exportOptionsGrp->addButton(p_exportFullRes);
60  p_exportFullRes->setWhatsThis("Save the viewport but at the full resolution of the original image.");
61 
62  hBoxLayout->addWidget(p_exportAsIs);
63  hBoxLayout->addWidget(p_exportFullRes);
64 
65  p_fullImage->setEnabled(true);
66  p_exportAsIs->setEnabled(true);
67  p_exportFullRes->setEnabled(true);
68 
69  p_fullImage->setChecked(true);
70 
71  QLayout *dialogLayout = layout();
72  dialogLayout->addWidget(p_fullImage);
73  dialogLayout->addItem(hBoxLayout);
74  dialogLayout->setAlignment(hBoxLayout, Qt::AlignLeft );
75  setLayout(dialogLayout);
76 
77  }
78 
87  {
88  if (p_exportAsIs->isChecked())
89  return ExportAsIs;
90  if(p_exportFullRes->isChecked())
91  return ExportFullRes;
92  return FullImage;
93  }
94 
103  void SaveAsDialog::setFullImage(bool pbChecked)
104  {
105  if(pbChecked) {
106  p_saveAsType = FullImage;
107  }
108  }
109 
118  void SaveAsDialog::setAsIs(bool pbChecked)
119  {
120  if(pbChecked) {
121  p_saveAsType = ExportAsIs;
122  }
123  }
124 
133  void SaveAsDialog::setFullResolution(bool pbChecked)
134  {
135  if(pbChecked) {
136  p_saveAsType = ExportFullRes;
137  }
138  }
139 }
QRadioButton * p_fullImage
FullImage Button.
Definition: SaveAsDialog.h:65
void setAsIs(bool)
Check ExportAsIs radio button and if checked set the saveAsType to ExportAsIs.
void setFullImage(bool)
Check FullImage radio button and if checked set the saveAsType to FullImage.
Class for browsing cubes.
Definition: FileDialog.h:32
void setFullResolution(bool)
Check ExportFullRes radio button and if checked set the saveAsType to ExportFullRes.
Namespace for the standard library.
QRadioButton * p_exportAsIs
ExportAsIs Button.
Definition: SaveAsDialog.h:66
saveAsType p_saveAsType
Current Save Type.
Definition: SaveAsDialog.h:68
int getSaveAsType()
Get user chosen save type.
QRadioButton * p_exportFullRes
ExportFullRes Button.
Definition: SaveAsDialog.h:67
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31