File failed to load: https://isis.astrogeology.usgs.gov/6.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
CubePlotCurveConfigureDialog.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include "CubePlotCurveConfigureDialog.h"
10 
11 #include <iostream>
12 
13 #include <QCheckBox>
14 #include <QColorDialog>
15 #include <QComboBox>
16 #include <QGridLayout>
17 #include <QLabel>
18 #include <QLineEdit>
19 #include <QPushButton>
20 
21 #include "CubePlotCurve.h"
22 #include "IException.h"
23 #include "PlotWindow.h"
24 
25 namespace Isis {
34  CubePlotCurve *curve, QWidget *parent) : QDialog(parent) {
35  m_plotCurve = curve;
36  m_parent = parent;
37  // initially set selected curve index to 0 (first curve)
38  m_selectedCurve = 0;
39 
40  // we can grab the CubePlotCurve QList from the parent widget (PlotWindow)
41  if (parent) {
42  connect( parent, SIGNAL( plotChanged() ),
43  this, SLOT( updateCurvesList() ) );
44  m_plotCurvesList = qobject_cast<PlotWindow *>(parent)->plotCurves();
45  }
46  else {
47  m_plotCurvesList.append(curve);
48  }
49 
50  QGridLayout *optionsLayout = new QGridLayout;
51  int row = 0;
52 
53  // only create a combo box if instantiating this dialog with the configure tool button
54  if (parent) {
55  QLabel *curvesLabel = new QLabel("Curves: ");
56  m_curvesCombo = new QComboBox();
57  connect( m_curvesCombo, SIGNAL( currentIndexChanged(int) ),
58  this, SLOT( updateComboIndex(int) ) );
59  optionsLayout->addWidget(curvesLabel, row, 0);
60  optionsLayout->addWidget(m_curvesCombo, row, 1);
61  row++;
62  }
63 
64  QLabel *nameLabel = new QLabel("Curve Name: ");
65  m_nameEdit = new QLineEdit( m_plotCurve->title().text() );
66  optionsLayout->addWidget(nameLabel, row, 0);
67  optionsLayout->addWidget(m_nameEdit, row, 1);
68  row++;
69 
70  QLabel *colorLabel = new QLabel("Color: ");
71  m_colorButton = new QPushButton;
72  m_colorButton->setFixedWidth(25);
73  connect( m_colorButton, SIGNAL( clicked() ),
74  this, SLOT( askUserForColor() ) );
75  optionsLayout->addWidget(colorLabel, row, 0);
76  optionsLayout->addWidget(m_colorButton, row, 1);
77  row++;
78 
79  QLabel *styleLabel = new QLabel("Style:");
80  m_styleCombo = new QComboBox;
81  m_styleCombo->addItem("No Line", static_cast<int>(Qt::NoPen));
82  m_styleCombo->addItem("Solid Line", static_cast<int>(Qt::SolidLine));
83  m_styleCombo->addItem("Dash Line", static_cast<int>(Qt::DashLine));
84  m_styleCombo->addItem("Dot Line", static_cast<int>(Qt::DotLine));
85  m_styleCombo->addItem("Dash Dot Line", static_cast<int>(Qt::DashDotLine));
86  m_styleCombo->addItem("Dash Dot Dot Line", static_cast<int>(Qt::DashDotDotLine));
87  optionsLayout->addWidget(styleLabel, row, 0);
88  optionsLayout->addWidget(m_styleCombo, row, 1);
89  row++;
90 
91  QLabel *sizeLabel = new QLabel("Size:");
92  m_sizeCombo = new QComboBox;
93  m_sizeCombo->addItem("1", 1);
94  m_sizeCombo->addItem("2", 2);
95  m_sizeCombo->addItem("3", 3);
96  m_sizeCombo->addItem("4", 4);
97  optionsLayout->addWidget(sizeLabel, row, 0);
98  optionsLayout->addWidget(m_sizeCombo, row, 1);
99  row++;
100 
101  QLabel *symbolLabel = new QLabel("Symbol:");
102  m_symbolCombo = new QComboBox;
103  m_symbolCombo->addItem("None", QwtSymbol::NoSymbol);
104 
105  m_symbolCombo->addItem("Diamond", QwtSymbol::Diamond);
106  m_symbolCombo->addItem("Rectangle", QwtSymbol::Rect);
107  m_symbolCombo->addItem("Triangle", QwtSymbol::Triangle);
108  m_symbolCombo->insertSeparator( m_symbolCombo->count() );
109 
110  m_symbolCombo->addItem("Down Facing Triangle", QwtSymbol::UTriangle);
111  m_symbolCombo->addItem("Up Facing Triangle", QwtSymbol::DTriangle);
112  m_symbolCombo->addItem("Left Facing Triangle", QwtSymbol::RTriangle);
113  m_symbolCombo->addItem("Right Facing Triangle", QwtSymbol::LTriangle);
114  m_symbolCombo->insertSeparator( m_symbolCombo->count() );
115 
116  m_symbolCombo->addItem("Diagonal Cross (X)", QwtSymbol::XCross);
117  m_symbolCombo->addItem("Eight-Pointed Star", QwtSymbol::Star1);
118  m_symbolCombo->addItem("Ellipse", QwtSymbol::Ellipse);
119  m_symbolCombo->addItem("Hexagon", QwtSymbol::Hexagon);
120  m_symbolCombo->addItem("Horizontal Line", QwtSymbol::HLine);
121  m_symbolCombo->addItem("Plus Sign (+)", QwtSymbol::Cross);
122  m_symbolCombo->addItem("Six-Pointed Star", QwtSymbol::Star2);
123  m_symbolCombo->addItem("Vertical Line", QwtSymbol::VLine);
124  optionsLayout->addWidget(symbolLabel, row, 0);
125  optionsLayout->addWidget(m_symbolCombo, row, 1);
126  row++;
127 
128  QHBoxLayout *applyButtonsLayout = new QHBoxLayout;
129  applyButtonsLayout->addStretch();
130 
131  QPushButton *okay = new QPushButton("&Ok");
132  okay->setIcon( QIcon::fromTheme("dialog-ok") );
133  connect( okay, SIGNAL( clicked() ),
134  this, SLOT( applySettingsToCurve() ) );
135  connect( okay, SIGNAL( clicked() ),
136  this, SLOT( close() ) );
137  applyButtonsLayout->addWidget(okay);
138 
139  QPushButton *apply = new QPushButton("&Apply");
140  apply->setIcon( QIcon::fromTheme("dialog-ok-apply") );
141  connect( apply, SIGNAL( clicked() ),
142  this, SLOT( applySettingsToCurve() ) );
143  applyButtonsLayout->addWidget(apply);
144 
145  QPushButton *cancel = new QPushButton("&Cancel");
146  cancel->setIcon( QIcon::fromTheme("dialog-cancel") );
147  connect( cancel, SIGNAL( clicked() ),
148  this, SLOT( close() ) );
149  applyButtonsLayout->addWidget(cancel);
150 
151  QWidget *optionsHolder = new QWidget;
152  optionsHolder->setLayout(optionsLayout);
153 
154  QWidget *applyButtonsHolder = new QWidget;
155  applyButtonsHolder->setLayout(applyButtonsLayout);
156 
157  QVBoxLayout *mainLayout = new QVBoxLayout;
158  mainLayout->addWidget(optionsHolder);
159  mainLayout->addWidget(applyButtonsHolder);
160 
161  setLayout(mainLayout);
162 
164  }
165 
166 
172  m_colorButton = NULL;
173  m_plotCurve = NULL;
174  }
175 
176 
183  if ( m_plotCurve->title() != m_nameEdit->text() ) {
184  m_plotCurve->enableAutoRenaming(false);
185  m_plotCurve->setTitle( m_nameEdit->text() );
186  }
187 
188  QPalette colorPalette( m_colorButton->palette() );
189 
190  QPen curvePen;
191  curvePen.setColor( colorPalette.color(QPalette::Button) );
192 
193  int penWidth = m_sizeCombo->itemData( m_sizeCombo->currentIndex() ).toInt();
194  curvePen.setWidth(penWidth);
195 
196  Qt::PenStyle penStyle = (Qt::PenStyle)m_styleCombo->itemData(
197  m_styleCombo->currentIndex() ).toInt();
198  curvePen.setStyle(penStyle);
199 
200  m_plotCurve->setPen(curvePen);
201  m_plotCurve->setColor( colorPalette.color(QPalette::Button) );
202 
203 
204  QwtSymbol::Style symbolStyle = (QwtSymbol::Style)m_symbolCombo->itemData(
205  m_symbolCombo->currentIndex() ).toInt();
206  m_plotCurve->setMarkerSymbol(symbolStyle);
207 
208  m_plotCurve->show();
209  m_plotCurve->plot()->replot();
210 
211  // When user hits Apply, the current curve will still be selected
212  // can't use m_curvesCombo->currentIndex() - CubePlotCurve instantiates this config dialog
213  // without a combo box
215  }
216 
217 
223  // ensure that the m_selectedCurve index is in bounds
224  if (m_selectedCurve > m_plotCurvesList.size() - 1 || m_selectedCurve < 0) {
225  throw IException(IException::Programmer, "Curves combobox index out of bounds", _FILEINFO_);
226  }
227 
229 
230  setWindowTitle( "Configure " + m_plotCurve->title().text() );
231 
232  // see if the curves combo box exists in the dialog (right-clicking a curve will not create
233  // a combo box in the dialog)
234  if (m_curvesCombo) {
235  m_curvesCombo->blockSignals(true);
236  m_curvesCombo->clear();
237  // add items to combo box
238  foreach(CubePlotCurve *curve, m_plotCurvesList) {
239  m_curvesCombo->addItem( curve->title().text() );
240  }
241  m_curvesCombo->setCurrentIndex(m_selectedCurve);
242 // m_curvesCombo->setItemText( m_curvesCombo->currentIndex(), m_plotCurve->title().text() );
243  m_curvesCombo->blockSignals(false);
244  }
245 
246  m_nameEdit->setText( m_plotCurve->title().text() );
247 
248  QPalette colorPalette;
249  colorPalette.setColor( QPalette::Button, m_plotCurve->pen().color() );
250  m_colorButton->setPalette(colorPalette);
251 
252  if ( m_sizeCombo->count() ) {
253  m_sizeCombo->setCurrentIndex(0);
254  for (int i = 0; i < m_sizeCombo->count(); i++) {
255  if ( m_sizeCombo->itemData(i) == m_plotCurve->pen().width() )
256  m_sizeCombo->setCurrentIndex(i);
257  }
258  }
259 
260  if ( m_styleCombo->count() ) {
261  m_styleCombo->setCurrentIndex(0);
262  for (int i = 0; i < m_styleCombo->count(); i++) {
263  if ( m_styleCombo->itemData(i) == static_cast<int>(m_plotCurve->pen().style()) )
264  m_styleCombo->setCurrentIndex(i);
265  }
266  }
267 
268  if ( m_symbolCombo->count() ) {
269  m_symbolCombo->setCurrentIndex(0);
270  for (int i = 0; i < m_symbolCombo->count(); i++) {
271  if ( m_symbolCombo->itemData(i).toInt() == m_plotCurve->markerSymbol()->style() ) {
272  m_symbolCombo->setCurrentIndex(i);
273  }
274  }
275  }
276  }
277 
278 
279  void CubePlotCurveConfigureDialog::updateComboIndex(int selected) {
280  m_selectedCurve = selected;
282  }
283 
284 
285  void CubePlotCurveConfigureDialog::updateCurvesList() {
286  QList<CubePlotCurve*> newPlotCurveList = qobject_cast<PlotWindow*>(m_parent)->plotCurves();
287  // if we deleted a plot curve, the new list will be smaller in size, reset m_selectedCurve
288  if ( newPlotCurveList.size() < m_plotCurvesList.size() ) {
289  m_selectedCurve = 0;
290  }
291  m_plotCurvesList.clear();
292  m_plotCurvesList = newPlotCurveList;
293  // don't read settings if there are 0 curves in the plot window
294  if (m_plotCurvesList.size() != 0) {
296  }
297  // close the configure dialog if the last curve was deleted
298  else {
299  close();
300  }
301  }
302 
307  QPalette colorPalette( m_colorButton->palette() );
308 
309  QColor newColor = QColorDialog::getColor(
310  colorPalette.color(QPalette::Button), this);
311 
312  if( newColor.isValid() ) {
313  colorPalette.setColor(QPalette::Button, newColor);
314  m_colorButton->setPalette(colorPalette);
315  }
316  }
317 }
Isis::CubePlotCurveConfigureDialog::m_curvesCombo
QPointer< QComboBox > m_curvesCombo
The selection/combo box for the cube plot curve.
Definition: CubePlotCurveConfigureDialog.h:78
QWidget
Isis::CubePlotCurveConfigureDialog::~CubePlotCurveConfigureDialog
virtual ~CubePlotCurveConfigureDialog()
This destroys the configuration dialog, which happens when the user closes it or clicks ok or cancel.
Definition: CubePlotCurveConfigureDialog.cpp:171
Isis::CubePlotCurveConfigureDialog::m_symbolCombo
QPointer< QComboBox > m_symbolCombo
The selection/combo box for the cube plot curve's marker style.
Definition: CubePlotCurveConfigureDialog.h:96
QList
This is free and unencumbered software released into the public domain.
Definition: BoxcarCachingAlgorithm.h:13
Isis::CubePlotCurveConfigureDialog::askUserForColor
void askUserForColor()
This prompts the user to select a new color for the curve/curve markers.
Definition: CubePlotCurveConfigureDialog.cpp:306
Isis::CubePlotCurve
This is a plot curve with information relating it to a particular cube or region of a cube.
Definition: CubePlotCurve.h:53
Isis::CubePlotCurveConfigureDialog::m_plotCurve
QPointer< CubePlotCurve > m_plotCurve
The current plot curve to configure.
Definition: CubePlotCurveConfigureDialog.h:86
Isis::CubePlotCurveConfigureDialog::m_plotCurvesList
QList< CubePlotCurve * > m_plotCurvesList
The list of plot curves to configure.
Definition: CubePlotCurveConfigureDialog.h:88
PlotWindow.h
Isis::CubePlotCurveConfigureDialog::m_selectedCurve
int m_selectedCurve
The index of the selected curve in m_curvesCombo.
Definition: CubePlotCurveConfigureDialog.h:90
Isis::CubePlotCurveConfigureDialog::m_nameEdit
QPointer< QLineEdit > m_nameEdit
The line edit containing the cube plot curve's name.
Definition: CubePlotCurveConfigureDialog.h:80
QComboBox
Isis::CubePlotCurveConfigureDialog::CubePlotCurveConfigureDialog
CubePlotCurveConfigureDialog(CubePlotCurve *curve, QWidget *parent=NULL)
This instantiates a configuration dialog associated with the given cube plot curve.
Definition: CubePlotCurveConfigureDialog.cpp:33
Isis::CubePlotCurveConfigureDialog::m_colorButton
QPointer< QPushButton > m_colorButton
The button for changing the cube plot curve's color.
Definition: CubePlotCurveConfigureDialog.h:82
Isis::toInt
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition: IString.cpp:93
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
Isis::CubePlotCurveConfigureDialog::m_styleCombo
QPointer< QComboBox > m_styleCombo
The selection/combo box for the cube plot curve's line style.
Definition: CubePlotCurveConfigureDialog.h:94
Isis::CubePlotCurveConfigureDialog::m_parent
QPointer< QWidget > m_parent
The parent widget of the configuration dialog.
Definition: CubePlotCurveConfigureDialog.h:84
Isis::CubePlotCurveConfigureDialog::applySettingsToCurve
void applySettingsToCurve()
This takes the configuration settings and applies them to the plot curve.
Definition: CubePlotCurveConfigureDialog.cpp:182
QDialog
Isis::CubePlotCurveConfigureDialog::m_sizeCombo
QPointer< QComboBox > m_sizeCombo
The selection/combo box for the cube plot curve's size/thickness.
Definition: CubePlotCurveConfigureDialog.h:92
Isis::CubePlotCurveConfigureDialog::readSettingsFromCurve
void readSettingsFromCurve()
This takes the current data inside of the plot curve and populates this configuration dialog's widget...
Definition: CubePlotCurveConfigureDialog.cpp:222
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 07/13/2023 15:16:22