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 }
Isis::NomenclatureToolConfigDialog::m_tool
FeatureNomenclatureTool * m_tool
The tool we're configuring.
Definition: NomenclatureToolConfigDialog.h:45
Isis::FeatureNomenclatureTool::fontColor
QColor fontColor() const
What is the font color to use?
Definition: FeatureNomenclatureTool.cpp:161
Isis::FeatureNomenclatureTool::VectorType
VectorType
Enumeration of extent vector typess.
Definition: FeatureNomenclatureTool.h:62
QWidget
Isis::FeatureNomenclatureTool::Arrows4
@ Arrows4
When using this vector (extent) type, 4 arrows will be drawn out from the text of the feature.
Definition: FeatureNomenclatureTool.h:83
Isis::NomenclatureToolConfigDialog::~NomenclatureToolConfigDialog
~NomenclatureToolConfigDialog()
Clean up allocated memory.
Definition: NomenclatureToolConfigDialog.cpp:119
Isis::NomenclatureToolConfigDialog::m_showApprovedCheckBox
QPointer< QCheckBox > m_showApprovedCheckBox
Filter out unapproved features.
Definition: NomenclatureToolConfigDialog.h:52
Isis::FeatureNomenclatureTool::setFontColor
void setFontColor(QColor color)
Set the color to use for drawing on the viewport.
Definition: FeatureNomenclatureTool.cpp:215
Isis::FeatureNomenclatureTool::showApprovedOnly
bool showApprovedOnly() const
Show approved features only?
Definition: FeatureNomenclatureTool.cpp:181
Isis::NomenclatureToolConfigDialog::m_showVectorsCombo
QPointer< QComboBox > m_showVectorsCombo
Show feature extents.
Definition: NomenclatureToolConfigDialog.h:50
Isis::FeatureNomenclatureTool::defaultEnabled
bool defaultEnabled() const
Is this tool enabled by default? (i.e.
Definition: FeatureNomenclatureTool.cpp:151
Isis::NomenclatureToolConfigDialog::NomenclatureToolConfigDialog
NomenclatureToolConfigDialog(FeatureNomenclatureTool *tool, QWidget *parent)
Create a config dialog that configures the given FeatureNomenclatureTool.
Definition: NomenclatureToolConfigDialog.cpp:21
Isis::FeatureNomenclatureTool::None
@ None
When using this vector (extent) type, no extents will be drawn.
Definition: FeatureNomenclatureTool.h:66
Isis::FeatureNomenclatureTool::setDefaultEnabled
void setDefaultEnabled(bool defaultEnabled)
Set whether this tool is enabled by default.
Definition: FeatureNomenclatureTool.cpp:201
Isis::FeatureNomenclatureTool::Arrows8
@ Arrows8
When using this vector (extent) type, 8 arrows will be drawn out from the text of the feature.
Definition: FeatureNomenclatureTool.h:101
QComboBox
Isis::FeatureNomenclatureTool::setFontSize
void setFontSize(int newFontSize)
Set the font point size to use for drawing text on the viewport.
Definition: FeatureNomenclatureTool.cpp:232
Isis::FeatureNomenclatureTool::setShowApprovedOnly
void setShowApprovedOnly(bool approvedOnly)
Set whether to show approved features and exclude unapproved features.
Definition: FeatureNomenclatureTool.cpp:250
Isis::NomenclatureToolConfigDialog::askUserForColor
void askUserForColor()
Prompt the user for a new font color.
Definition: NomenclatureToolConfigDialog.cpp:168
Isis::FeatureNomenclatureTool::Box
@ Box
When using this vector (extent) type, 4 arrows will be drawn out from the text of the feature.
Definition: FeatureNomenclatureTool.h:110
Isis::NomenclatureToolConfigDialog::m_fontColorButton
QPointer< QPushButton > m_fontColorButton
Color to use when rendering the nomenclature.
Definition: NomenclatureToolConfigDialog.h:56
Isis::FeatureNomenclatureTool
Display nomenclature on MDI Cube Viewports.
Definition: FeatureNomenclatureTool.h:56
Isis::NomenclatureToolConfigDialog::applySettings
void applySettings()
Apply the user's current settings to the tool.
Definition: NomenclatureToolConfigDialog.cpp:127
Isis::FeatureNomenclatureTool::fontSize
int fontSize() const
Retrieve the font size of the features in this tool.
Definition: FeatureNomenclatureTool.cpp:171
Isis::FeatureNomenclatureTool::vectorType
VectorType vectorType() const
Draw vectors to the extents of features?
Definition: FeatureNomenclatureTool.cpp:191
Isis::NomenclatureToolConfigDialog::readSettings
void readSettings()
Read the tool's current settings and set the widget states to match.
Definition: NomenclatureToolConfigDialog.cpp:148
Isis::NomenclatureToolConfigDialog::m_fontSizeCombo
QPointer< QComboBox > m_fontSizeCombo
Font size of the labels.
Definition: NomenclatureToolConfigDialog.h:54
Isis::NomenclatureToolConfigDialog::m_defaultOnCheckBox
QPointer< QCheckBox > m_defaultOnCheckBox
Turn on the nomenclature tool when the application starts.
Definition: NomenclatureToolConfigDialog.h:48
QDialog
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::FeatureNomenclatureTool::setVectorType
void setVectorType(VectorType show)
Set whether to draw vectors from the feature center to the feature extents on the viewport.
Definition: FeatureNomenclatureTool.cpp:269