Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
View
ViewProfile.cpp
Go to the documentation of this file.
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 <QGraphicsRectItem>
8
#include "
ViewProfile.h
"
9
#include "
ViewProfileParameters.h
"
10
11
const
int
FRAME_WIDTH
= 2;
12
13
// Insert a little space on the left and right so first and last points are visible. Although the
14
// ViewProfile will no longer be exactly aligned with the ViewScale underneath, the difference is insignificant
15
const
double
SLOP_ON_SIDES
= 0.5;
16
17
ViewProfile::ViewProfile
(QGraphicsScene *scene,
18
int
minimumWidth,
19
QWidget *parent) :
20
QGraphicsView (scene, parent)
21
{
22
setRenderHint (QPainter::Antialiasing);
23
setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
24
setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
25
26
setMinimumHeight (160);
27
setMaximumHeight (160);
28
setMinimumWidth (minimumWidth);
29
30
createFrame ();
31
refit ();
32
}
33
34
void
ViewProfile::createFrame ()
35
{
36
m_frame =
new
QGraphicsRectItem (0, 0, 100, 100);
37
m_frame->setPen (QPen (QBrush (qRgb (0.0, 0.0, 0.0)),
FRAME_WIDTH
));
38
39
scene()->addItem (m_frame);
40
}
41
42
void
ViewProfile::refit ()
43
{
44
// Force the scene boundaries to be the same, even after resizing
45
QRectF bounds = QRectF (
VIEW_PROFILE_X_MIN
-
SLOP_ON_SIDES
,
46
VIEW_PROFILE_Y_MIN
,
47
VIEW_PROFILE_X_MAX
+ 2 *
SLOP_ON_SIDES
,
48
VIEW_PROFILE_Y_MAX
);
49
fitInView (bounds);
50
setSceneRect (bounds);
51
}
52
53
void
ViewProfile::resizeEvent
(QResizeEvent *event)
54
{
55
refit ();
56
57
QGraphicsView::resizeEvent (event);
58
}
VIEW_PROFILE_X_MIN
const double VIEW_PROFILE_X_MIN
Definition
ViewProfileParameters.cpp:9
VIEW_PROFILE_Y_MAX
const double VIEW_PROFILE_Y_MAX
Definition
ViewProfileParameters.cpp:12
VIEW_PROFILE_X_MAX
const double VIEW_PROFILE_X_MAX
Definition
ViewProfileParameters.cpp:11
VIEW_PROFILE_Y_MIN
const double VIEW_PROFILE_Y_MIN
Definition
ViewProfileParameters.cpp:10
ViewProfileParameters.h
SLOP_ON_SIDES
const double SLOP_ON_SIDES
Definition
ViewProfile.cpp:15
FRAME_WIDTH
const int FRAME_WIDTH
Definition
ViewProfile.cpp:11
ViewProfile.h
ViewProfile::ViewProfile
ViewProfile(QGraphicsScene *scene, int minimumWidth, QWidget *parent=0)
Single constructor.
Definition
ViewProfile.cpp:17
ViewProfile::resizeEvent
virtual void resizeEvent(QResizeEvent *event)
Intercept resize events so the geometry can be scaled to perfectly fit into the window.
Definition
ViewProfile.cpp:53
Generated on
for Engauge Digitizer by
1.17.0