Isis 3 Programmer Reference
NomenclatureToolConfigDialog.cpp
1 #include "NomenclatureToolConfigDialog.h"
2 
3 #include <QCheckBox>
4 #include <QColorDialog>
5 #include <QComboBox>
6 #include <QGridLayout>
7 #include <QtWidgets>
8 #include <QLabel>
9 #include <QPushButton>
10 #include <QVBoxLayout>
11 
12 #include "FeatureNomenclatureTool.h"
13 
14 namespace Isis {
22  FeatureNomenclatureTool *tool, QWidget *parent) : QDialog(parent) {
23  m_tool = tool;
24 
25  QVBoxLayout *mainLayout = new QVBoxLayout;
26  setLayout(mainLayout);
27 
28  QWidget *settingsAreaWidget = new QWidget;
29  mainLayout->addWidget(settingsAreaWidget);
30 
31  QWidget *buttonsAreaWidget = new QWidget;
32  mainLayout->addWidget(buttonsAreaWidget);
33 
34  QGridLayout *settingsAreaLayout = new QGridLayout;
35  settingsAreaWidget->setLayout(settingsAreaLayout);
36 
37  // Settings area
38  int row = 0;
39  QLabel *fontSizeLabel = new QLabel("Font Size");
40  settingsAreaLayout->addWidget(fontSizeLabel, row, 0);
41 
43  for (int i = 8; i <= 20; i++) {
44  m_fontSizeCombo->addItem(QString::number(i), i);
45  }
46  settingsAreaLayout->addWidget(m_fontSizeCombo, row, 1);
47  row++;
48 
49  QLabel *fontColorLabel = new QLabel("Font Color");
50  settingsAreaLayout->addWidget(fontColorLabel, row, 0);
51 
52  m_fontColorButton = new QPushButton;
53  settingsAreaLayout->addWidget(m_fontColorButton, row, 1);
54  connect(m_fontColorButton, SIGNAL(clicked()),
55  this, SLOT(askUserForColor()));
56  row++;
57 
58  QLabel *showVectorsLabel = new QLabel("Show feature extents");
59  settingsAreaLayout->addWidget(showVectorsLabel, row, 0);
60 
62 
67 
68  settingsAreaLayout->addWidget(m_showVectorsCombo, row, 1);
69  row++;
70 
71  QLabel *showApprovedLabel = new QLabel("Show IAU approved only");
72  settingsAreaLayout->addWidget(showApprovedLabel, row, 0);
73 
74  m_showApprovedCheckBox = new QCheckBox;
75  settingsAreaLayout->addWidget(m_showApprovedCheckBox, row, 1);
76  row++;
77 
78  QLabel *defaultOnLabel = new QLabel(
79  "Enabled when " + QCoreApplication::instance()->applicationName() +
80  " starts");
81  settingsAreaLayout->addWidget(defaultOnLabel, row, 0);
82 
83  m_defaultOnCheckBox = new QCheckBox;
84  settingsAreaLayout->addWidget(m_defaultOnCheckBox, row, 1);
85  row++;
86 
87  // Now the buttons area
88  QHBoxLayout *buttonsAreaLayout = new QHBoxLayout;
89  buttonsAreaWidget->setLayout(buttonsAreaLayout);
90 
91  buttonsAreaLayout->addStretch();
92 
93  QPushButton *okayButton = new QPushButton("&Ok");
94  okayButton->setIcon(QIcon::fromTheme("dialog-ok"));
95  buttonsAreaLayout->addWidget(okayButton);
96  connect(okayButton, SIGNAL(clicked()),
97  this, SLOT(applySettings()));
98  connect(okayButton, SIGNAL(clicked()),
99  this, SLOT(accept()));
100 
101  QPushButton *applyButton = new QPushButton("&Apply");
102  applyButton->setIcon(QIcon::fromTheme("dialog-ok-apply"));
103  buttonsAreaLayout->addWidget(applyButton);
104  connect(applyButton, SIGNAL(clicked()),
105  this, SLOT(applySettings()));
106 
107  QPushButton *cancelButton = new QPushButton("&Cancel");
108  cancelButton->setIcon(QIcon::fromTheme("dialog-cancel"));
109  buttonsAreaLayout->addWidget(cancelButton);
110  connect(cancelButton, SIGNAL(clicked()),
111  this, SLOT(reject()));
112 
113  readSettings();
114  }
115 
120 
121  }
122 
123 
129  m_fontSizeCombo->itemData(m_fontSizeCombo->currentIndex()).toInt());
130 
131  QPalette colorPalette(m_fontColorButton->palette());
132  m_tool->setFontColor(colorPalette.color(QPalette::Button));
133 
135 
137 
139  m_showVectorsCombo->itemData(m_showVectorsCombo->currentIndex()).toInt() );
140 
141  readSettings();
142  }
143 
144 
149  m_fontSizeCombo->setCurrentIndex(
150  m_fontSizeCombo->findText(QString::number(m_tool->fontSize())));
151 
152  QPalette colorPalette;
153  colorPalette.setColor(QPalette::Button, m_tool->fontColor());
154  m_fontColorButton->setPalette(colorPalette);
155 
156  m_defaultOnCheckBox->setChecked(m_tool->defaultEnabled());
157 
159 
160  m_showVectorsCombo->setCurrentIndex(
161  m_showVectorsCombo->findData(m_tool->vectorType()));
162  }
163 
164 
169  QPalette colorPalette(m_fontColorButton->palette());
170 
171  QColor newColor = QColorDialog::getColor(
172  colorPalette.color(QPalette::Button), this);
173 
174  if(newColor.isValid()) {
175  colorPalette.setColor(QPalette::Button, newColor);
176  m_fontColorButton->setPalette(colorPalette);
177  }
178  }
179 }
QPointer< QCheckBox > m_showApprovedCheckBox
Filter out unapproved features.
QPointer< QComboBox > m_showVectorsCombo
Show feature extents.
void setFontColor(QColor color)
Set the color to use for drawing on the viewport.
~NomenclatureToolConfigDialog()
Clean up allocated memory.
When using this vector (extent) type, 8 arrows will be drawn out from the text of the feature...
bool showApprovedOnly() const
Show approved features only?
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition: IString.cpp:108
NomenclatureToolConfigDialog(FeatureNomenclatureTool *tool, QWidget *parent)
Create a config dialog that configures the given FeatureNomenclatureTool.
When using this vector (extent) type, no extents will be drawn.
void setFontSize(int newFontSize)
Set the font point size to use for drawing text on the viewport.
bool defaultEnabled() const
Is this tool enabled by default? (i.e.
void setDefaultEnabled(bool defaultEnabled)
Set whether this tool is enabled by default.
When using this vector (extent) type, 4 arrows will be drawn out from the text of the feature...
void setShowApprovedOnly(bool approvedOnly)
Set whether to show approved features and exclude unapproved features.
QPointer< QPushButton > m_fontColorButton
Color to use when rendering the nomenclature.
void askUserForColor()
Prompt the user for a new font color.
void applySettings()
Apply the user&#39;s current settings to the tool.
void readSettings()
Read the tool&#39;s current settings and set the widget states to match.
VectorType vectorType() const
Draw vectors to the extents of features?
int fontSize() const
Retrieve the font size of the features in this tool.
QPointer< QCheckBox > m_defaultOnCheckBox
Turn on the nomenclature tool when the application starts.
Display nomenclature on MDI Cube Viewports.
QPointer< QComboBox > m_fontSizeCombo
Font size of the labels.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
When using this vector (extent) type, 4 arrows will be drawn out from the text of the feature...
FeatureNomenclatureTool * m_tool
The tool we&#39;re configuring.
QColor fontColor() const
What is the font color to use?
void setVectorType(VectorType show)
Set whether to draw vectors from the feature center to the feature extents on the viewport...
VectorType
Enumeration of extent vector typess.