14#include <QGraphicsEllipseItem>
15#include <QGraphicsPixmapItem>
16#include <QGraphicsRectItem>
17#include <QGraphicsScene>
31 "DlgSettingsPointMatch",
36 m_modelPointMatchBefore (
nullptr),
37 m_modelPointMatchAfter (
nullptr)
54 double radius = radiusAlongDiagonal();
59 if (pos.x() - radius < 0) {
63 if (pos.y() - radius < 0) {
67 if (pos.x() +
diameter > m_scenePreview->sceneRect().width ()) {
68 pos.setX (m_scenePreview->sceneRect().width() -
diameter);
71 if (pos.y() +
diameter > m_scenePreview->sceneRect().height ()) {
72 pos.setY (m_scenePreview->sceneRect().height() -
diameter);
87 m_spinPointSize->setWhatsThis (
tr (
"Select a maximum point size in pixels.\n\n"
88 "Sample match points must fit within a square box, around the cursor, having width and height "
89 "equal to this maximum.\n\n"
90 "This size is also used to determine if a region of pixels that are on, in the processed image, "
91 "should be ignored since that region is wider or taller than this limit.\n\n"
92 "This value has a lower limit"));
96 layout->addWidget (m_spinPointSize,
row++, 2);
102 m_cmbAcceptedPointColor->setWhatsThis (
tr (
"Select a color for matched points that are accepted"));
105 layout->addWidget (m_cmbAcceptedPointColor,
row++, 2);
111 m_cmbRejectedPointColor->setWhatsThis (
tr (
"Select a color for matched points that are rejected"));
114 layout->addWidget (m_cmbRejectedPointColor,
row++, 2);
119 m_cmbCandidatePointColor =
new QComboBox;
120 m_cmbCandidatePointColor->setWhatsThis (
tr (
"Select a color for the point being decided upon"));
123 layout->addWidget (m_cmbCandidatePointColor,
row++, 2);
138 m_scenePreview =
new QGraphicsScene (
this);
142 m_viewPreview->setWhatsThis (
tr (
"Preview window shows how current settings affect "
143 "point matching, and how the marked and candidate points are displayed.\n\nThe points are separated "
144 "by the point separation value, and the maximum point size is shown as a box in the center"));
145 m_viewPreview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
146 m_viewPreview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
150 layout->addWidget (m_viewPreview,
row++, 0, 1, 4);
161 layout->setColumnStretch(0, 1);
162 layout->setColumnStretch(1, 0);
163 layout->setColumnStretch(2, 0);
164 layout->setColumnStretch(3, 1);
174void DlgSettingsPointMatch::createTemplate ()
180 m_circle =
new QGraphicsEllipseItem;
181 m_circle->setPen (pen);
182 m_circle->setZValue (100);
183 m_scenePreview->addItem (m_circle);
192 *m_modelPointMatchBefore,
193 *m_modelPointMatchAfter);
199void DlgSettingsPointMatch::initializeBox ()
203 m_circle->setPos (
cmdMediator().document().pixmap().width () / 2.0,
214 delete m_modelPointMatchBefore;
215 delete m_modelPointMatchAfter;
243 QGraphicsRectItem *
boundary = m_scenePreview->addRect (
QRect (0,
256double DlgSettingsPointMatch::radiusAlongDiagonal ()
const
258 double maxPointSize = m_modelPointMatchAfter->
maxPointSize();
260 return qSqrt (2.0) * maxPointSize / 2.0;
270void DlgSettingsPointMatch::slotAcceptedPointColor (
const QString &)
280void DlgSettingsPointMatch::slotCandidatePointColor (
const QString &)
289void DlgSettingsPointMatch::slotMaxPointSize (
int maxPointSize)
298void DlgSettingsPointMatch::slotMouseMove (
QPointF pos)
302 pos = boxPositionConstraint (pos);
304 m_circle->setPos (pos);
307void DlgSettingsPointMatch::slotRejectedPointColor (
const QString &)
316void DlgSettingsPointMatch::updateControls()
322void DlgSettingsPointMatch::updatePreview()
325 double maxPointSize = m_modelPointMatchAfter->
maxPointSize();
327 double xLeft = -1.0 * maxPointSize / 2.0;
328 double yTop = -1.0 * maxPointSize / 2.0;
331 m_circle->setRect (
xLeft,
const int INNER_RADIUS_MIN
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
log4cpp::Category * mainCat
Command for DlgSettingsPointMatch.
Abstract base class for all Settings dialogs.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
void finishPanel(QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
void populateColorComboWithTransparent(QComboBox &combo)
Add colors in color palette to combobox, with transparent entry at end.
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.
void enableOk(bool enable)
Let leaf subclass control the Ok button.
static int MINIMUM_PREVIEW_HEIGHT
Dialog layout constant that guarantees preview has sufficent room.
MainWindow & mainWindow()
Get method for MainWindow.
virtual ~DlgSettingsPointMatch()
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.
DlgSettingsPointMatch(MainWindow &mainWindow)
Single constructor.
virtual void handleOk()
Process slotOk.
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.
Model for DlgSettingsPointMatch and CmdSettingsPointMatch.
void setMaxPointSize(double maxPointSize)
Set method for max point size.
void setPaletteColorCandidate(ColorPalette paletteColorCandidate)
Set method for candidate color.
ColorPalette paletteColorRejected() const
Get method for rejected color.
void setPaletteColorAccepted(ColorPalette paletteColorAccepted)
Set method for accepted color.
ColorPalette paletteColorCandidate() const
Get method for candidate color.
double maxPointSize() const
Get method for max point size.
void setPaletteColorRejected(ColorPalette paletteColorRejected)
Set method for rejected color.
ColorPalette paletteColorAccepted() const
Get method for accepted color.
QPixmap pixmap() const
Return the image that is being digitized.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Class that modifies QGraphicsView to automatically expand/shrink the view to fit the window,...
@ VIEW_ASPECT_RATIO_VARIABLE
#define LOG4CPP_INFO_S(logger)