Engauge Digitizer  2
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
DlgImportAdvanced.cpp
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #include "DlgImportAdvanced.h"
8 #include "Logger.h"
9 #include "MainWindow.h"
10 #include <QGridLayout>
11 #include <QLabel>
12 #include <QRadioButton>
13 #include <QSpinBox>
14 
15 const int MINIMUM_DIALOG_WIDTH_COORDS = 800;
16 
18  DlgSettingsAbstractBase (tr ("Import Advanced"),
19  "DlgImportAdvanced",
20  mainWindow)
21 {
22  LOG4CPP_INFO_S ((*mainCat)) << "DlgImportAdvanced::DlgImportAdvanced";
23 
24  QWidget *subPanel = createSubPanel ();
25  finishPanel (subPanel,
26  MINIMUM_DIALOG_WIDTH_COORDS);
27 
28  // Accept even the default value without any additional actions, rather than delay the Ok button to after a change
29  enableOk (true);
30  setDisableOkAtStartup (false);
31 }
32 
33 void DlgImportAdvanced::createOptionalSaveDefault (QHBoxLayout * /* layout */)
34 {
35  LOG4CPP_INFO_S ((*mainCat)) << "DlgImportAdvanced::createOptionalSaveDefault";
36 }
37 
39 {
40  LOG4CPP_INFO_S ((*mainCat)) << "DlgImportAdvanced::createSubPanel";
41 
42  QWidget *subPanel = new QWidget ();
43  QGridLayout *layout = new QGridLayout (subPanel);
44  subPanel->setLayout (layout);
45 
46  int row = 0;
47 
48  // Coordinate system count
49  QLabel *labelCoordCount = new QLabel (tr ("Coordinate System Count:"));
50  layout->addWidget (labelCoordCount, row, 1);
51 
52  m_spinCoordSystemCount = new QSpinBox;
53  m_spinCoordSystemCount->setMinimum (1);
54  m_spinCoordSystemCount->setValue (1);
55  m_spinCoordSystemCount->setWhatsThis (tr ("Coordinate System Count\n\n"
56  "Specifies the total number of coordinate systems that will be used in the imported image. "
57  "There can be one or more graphs in the image, and each graph can have one or more "
58  "coordinate systems. Each coordinate system is defined by a pair of coordinate axes."));
59  connect (m_spinCoordSystemCount, SIGNAL (valueChanged (const QString &)), this, SLOT (slotImportAdvanced (const QString &)));
60  layout->addWidget (m_spinCoordSystemCount, row++, 2);
61 
62  // Axes point count
63  QLabel *labelPointCount = new QLabel (tr ("Axes Points Count:"));
64  layout->addWidget (labelPointCount, row, 1);
65 
66  m_btnAxesPointCount3 = new QRadioButton (tr ("3 points"));
67  m_btnAxesPointCount3->setChecked (true); // This is the traditional setting, and so is used as the default
68  m_btnAxesPointCount3->setWhatsThis (tr ("Three axes points will define the coordinate system. Each will have both "
69  "x and y coordinates.\n\n"
70  "This setting is always used when importing images in non-advanced mode.\n\n"
71  "In total, there will be three points as (x1,y1), (x2,y2) "
72  "and (x3,y3)."));
73  connect (m_btnAxesPointCount3, SIGNAL (toggled (bool)), this, SLOT (slotAxesPointCount (bool)));
74  layout->addWidget (m_btnAxesPointCount3, row++, 2);
75 
76  m_btnAxesPointCount4 = new QRadioButton (tr ("4 points"));
77  m_btnAxesPointCount4->setWhatsThis (tr ("Four axes points will define the coordinate system. Each will have a single "
78  "x or y coordinate.\n\n"
79  "This setting is required when the x coordinate of the y axis is unknown, and/or "
80  "the y coordinate of the x axis is unknown.\n\n"
81  "In total, there will be two points on the x axis as (x1) and "
82  "(x2), and two points on the y axis as (y1) and (y2)."));
83  connect (m_btnAxesPointCount4, SIGNAL (toggled (bool)), this, SLOT (slotAxesPointCount (bool)));
84  layout->addWidget (m_btnAxesPointCount4, row++, 2);
85 
86  return subPanel;
87 }
88 
89 DocumentAxesPointsRequired DlgImportAdvanced::documentAxesPointsRequired () const
90 {
91  if (m_btnAxesPointCount3->isChecked ()) {
92  return DOCUMENT_AXES_POINTS_REQUIRED_3;
93  } else {
94  return DOCUMENT_AXES_POINTS_REQUIRED_4;
95  }
96 }
97 
99 {
100  LOG4CPP_INFO_S ((*mainCat)) << "DlgImportAdvanced::handleOk";
101 
102  setResult (QDialog::Accepted); // Set return value so Ok button is not handled like the Cancel button
103 
104  hide ();
105 }
106 
107 void DlgImportAdvanced::load(CmdMediator & /* cmdMediator */)
108 {
109  LOG4CPP_INFO_S ((*mainCat)) << "DlgImportAdvanced::load";
110 }
111 
113 {
114  return m_spinCoordSystemCount->value ();
115 }
116 
117 void DlgImportAdvanced::setSmallDialogs(bool /* smallDialogs */)
118 {
119 }
120 
121 void DlgImportAdvanced::slotAxesPointCount (bool)
122 {
123  LOG4CPP_INFO_S ((*mainCat)) << "DlgCoordSystem::slotAxesPointCount";
124 }
125 
126 void DlgImportAdvanced::slotCoordSystemCount (const QString &)
127 {
128  LOG4CPP_INFO_S ((*mainCat)) << "DlgCoordSystem::slotImportAdvanced";
129 }
130 
virtual QWidget * createSubPanel()
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
void setDisableOkAtStartup(bool disableOkAtStartup)
Override the default Ok button behavior applied in showEvent.
DocumentAxesPointsRequired documentAxesPointsRequired() const
Number of axes points selected by user.
virtual void createOptionalSaveDefault(QHBoxLayout *layout)
Let subclass define an optional Save As Default button.
void finishPanel(QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
unsigned int numberCoordSystem() const
Number of coordinate systems selected by user.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
virtual void handleOk()
Process slotOk.
void enableOk(bool enable)
Let leaf subclass control the Ok button.
Command queue stack.
Definition: CmdMediator.h:23
DlgImportAdvanced(MainWindow &mainWindow)
Single constructor.
Abstract base class for all Settings dialogs.
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:86