Engauge Digitizer 2
Loading...
Searching...
No Matches
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
16 DlgSettingsAbstractBase (tr ("Import Advanced"),
17 "DlgImportAdvanced",
18 mainWindow)
19{
20 LOG4CPP_INFO_S ((*mainCat)) << "DlgImportAdvanced::DlgImportAdvanced";
21
22 QWidget *subPanel = createSubPanel ();
23 finishPanel (subPanel);
24
25 // Accept even the default value without any additional actions, rather than delay the Ok button to after a change
26 enableOk (true);
28}
29
30void DlgImportAdvanced::createOptionalSaveDefault (QHBoxLayout * /* layout */)
31{
32 LOG4CPP_INFO_S ((*mainCat)) << "DlgImportAdvanced::createOptionalSaveDefault";
33}
34
36{
37 LOG4CPP_INFO_S ((*mainCat)) << "DlgImportAdvanced::createSubPanel";
38
39 QWidget *subPanel = new QWidget ();
40 QGridLayout *layout = new QGridLayout (subPanel);
41 subPanel->setLayout (layout);
42
43 int row = 0;
44
45 // Coordinate system count
46 QLabel *labelCoordCount = new QLabel (tr ("Coordinate System Count:"));
47 layout->addWidget (labelCoordCount, row, 1);
48
49 m_spinCoordSystemCount = new QSpinBox;
50 m_spinCoordSystemCount->setMinimum (1);
51 m_spinCoordSystemCount->setValue (1);
52 m_spinCoordSystemCount->setWhatsThis (tr ("Coordinate System Count\n\n"
53 "Specifies the total number of coordinate systems that will be used in the imported image. "
54 "There can be one or more graphs in the image, and each graph can have one or more "
55 "coordinate systems. Each coordinate system is defined by a pair of coordinate axes."));
56 connect (m_spinCoordSystemCount, SIGNAL (valueChanged (const QString &)), this, SLOT (slotImportAdvanced (const QString &)));
57 layout->addWidget (m_spinCoordSystemCount, row++, 2);
58
59 // Axes point count
60 QLabel *labelPointCount = new QLabel (tr ("Axes Points Count:"));
61 layout->addWidget (labelPointCount, row, 1);
62
63 m_btnAxesPointCount3 = new QRadioButton (tr ("3 points"));
64 m_btnAxesPointCount3->setChecked (true); // This is the traditional setting, and so is used as the default
65 m_btnAxesPointCount3->setWhatsThis (tr ("Three axes points will define the coordinate system. Each will have both "
66 "x and y coordinates.\n\n"
67 "This setting is always used when importing images in non-advanced mode.\n\n"
68 "In total, there will be three points as (x1,y1), (x2,y2) "
69 "and (x3,y3)."));
70 connect (m_btnAxesPointCount3, SIGNAL (toggled (bool)), this, SLOT (slotAxesPointCount (bool)));
71 layout->addWidget (m_btnAxesPointCount3, row++, 2);
72
73 m_btnAxesPointCount4 = new QRadioButton (tr ("4 points"));
74 m_btnAxesPointCount4->setWhatsThis (tr ("Four axes points will define the coordinate system. Each will have a single "
75 "x or y coordinate.\n\n"
76 "This setting is required when the x coordinate of the y axis is unknown, and/or "
77 "the y coordinate of the x axis is unknown.\n\n"
78 "In total, there will be two points on the x axis as (x1) and "
79 "(x2), and two points on the y axis as (y1) and (y2)."));
80 connect (m_btnAxesPointCount4, SIGNAL (toggled (bool)), this, SLOT (slotAxesPointCount (bool)));
81 layout->addWidget (m_btnAxesPointCount4, row++, 2);
82
83 return subPanel;
84}
85
86DocumentAxesPointsRequired DlgImportAdvanced::documentAxesPointsRequired () const
87{
88 if (m_btnAxesPointCount3->isChecked ()) {
89 return DOCUMENT_AXES_POINTS_REQUIRED_3;
90 } else {
91 return DOCUMENT_AXES_POINTS_REQUIRED_4;
92 }
93}
94
96{
97 LOG4CPP_INFO_S ((*mainCat)) << "DlgImportAdvanced::handleOk";
98
99 setResult (QDialog::Accepted); // Set return value so Ok button is not handled like the Cancel button
100
101 hide ();
102}
103
104void DlgImportAdvanced::load(CmdMediator & /* cmdMediator */)
105{
106 LOG4CPP_INFO_S ((*mainCat)) << "DlgImportAdvanced::load";
107}
108
110{
111 return m_spinCoordSystemCount->value ();
112}
113
114void DlgImportAdvanced::slotAxesPointCount (bool)
115{
116 LOG4CPP_INFO_S ((*mainCat)) << "DlgCoordSystem::slotAxesPointCount";
117}
118
119void DlgImportAdvanced::slotCoordSystemCount (const QString &)
120{
121 LOG4CPP_INFO_S ((*mainCat)) << "DlgCoordSystem::slotImportAdvanced";
122}
123
Command queue stack.
Definition CmdMediator.h:24
virtual void handleOk()
Process slotOk.
DlgImportAdvanced(MainWindow &mainWindow)
Single constructor.
virtual void createOptionalSaveDefault(QHBoxLayout *layout)
Let subclass define an optional Save As Default button.
virtual QWidget * createSubPanel()
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
unsigned int numberCoordSystem() const
Number of coordinate systems selected by user.
DocumentAxesPointsRequired documentAxesPointsRequired() const
Number of axes points selected by user.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
Abstract base class for all Settings dialogs.
void enableOk(bool enable)
Let leaf subclass control the Ok button.
void setDisableOkAtStartup(bool disableOkAtStartup)
Override the default Ok button behavior applied in showEvent.
void finishPanel(QWidget *subPanel)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition MainWindow.h:78