Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
Grid
GridLine.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 "
EngaugeAssert.h
"
8
#include "
GridLine.h
"
9
#include "
Logger.h
"
10
#include <qdebug.h>
11
#include <QGraphicsItem>
12
#include <QGraphicsScene>
13
#include <QPen>
14
15
GridLine::GridLine
()
16
{
17
}
18
19
GridLine::GridLine
(
const
GridLine
&
/* other */
)
20
{
21
qCCritical(ENGAUGE_LOG) <<
"GridLine::GridLine"
;
22
ENGAUGE_ASSERT
(
false
);
23
}
24
25
GridLine::~GridLine
()
26
{
27
// Crash here means QGraphicsScene::clear was called, which is entirely unnecessary
28
29
for
(
int
i = 0; i < m_segments.count(); i++) {
30
QGraphicsItem *item = m_segments [i];
31
delete
item;
32
}
33
34
m_segments.clear ();
35
}
36
37
GridLine
&
GridLine::operator=
(
GridLine
&
/* other */
)
38
{
39
qCCritical(ENGAUGE_LOG) <<
"GridLine::operator="
;
40
ENGAUGE_ASSERT
(
false
);
41
42
return
*
this
;
43
}
44
45
void
GridLine::add
(QGraphicsItem *item)
46
{
47
m_segments.push_back (item);
48
}
49
50
void
GridLine::setPen
(
const
QPen &pen)
51
{
52
for
(
int
i = 0; i < m_segments.count(); i++) {
53
QGraphicsItem *item = m_segments [i];
54
if
(item !=
nullptr
) {
55
56
// Downcast since QGraphicsItem does not have a pen
57
QGraphicsLineItem *itemLine =
dynamic_cast<
QGraphicsLineItem*
>
(item);
58
QGraphicsEllipseItem *itemArc =
dynamic_cast<
QGraphicsEllipseItem*
>
(item);
59
if
(itemLine !=
nullptr
) {
60
itemLine->setPen (pen);
61
}
else
if
(itemArc !=
nullptr
) {
62
itemArc->setPen (pen);
63
}
64
}
65
}
66
}
67
68
void
GridLine::setVisible
(
bool
visible)
69
{
70
for
(
int
i = 0; i < m_segments.count(); i++) {
71
QGraphicsItem *item = m_segments [i];
72
item->setVisible (visible);
73
}
74
}
EngaugeAssert.h
ENGAUGE_ASSERT
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
Definition
EngaugeAssert.h:17
GridLine.h
Logger.h
GridLine::setPen
void setPen(const QPen &pen)
Set the pen style.
Definition
GridLine.cpp:50
GridLine::operator=
GridLine & operator=(GridLine &other)
Assignment constructor. This will assert if called since copying of pointer containers is problematic...
Definition
GridLine.cpp:37
GridLine::add
void add(QGraphicsItem *item)
Add graphics item which represents one segment of the line.
Definition
GridLine.cpp:45
GridLine::setVisible
void setVisible(bool visible)
Set each grid line as visible or hidden.
Definition
GridLine.cpp:68
GridLine::~GridLine
virtual ~GridLine()
Definition
GridLine.cpp:25
GridLine::GridLine
GridLine()
Default constructor for storage in containers.
Definition
GridLine.cpp:15
Generated on
for Engauge Digitizer by
1.17.0