Engauge Digitizer 2
Loading...
Searching...
No Matches
GridLine Class Reference

Single grid line drawn a straight or curved line. More...

#include <GridLine.h>

Collaboration diagram for GridLine:
Collaboration graph

Public Member Functions

 GridLine ()
 Default constructor for storage in containers.
virtual ~GridLine ()
 GridLine (const GridLine &other)
 Copy constructor. This will assert if called since copying of pointer containers is problematic.
GridLineoperator= (GridLine &other)
 Assignment constructor. This will assert if called since copying of pointer containers is problematic.
void add (QGraphicsItem *item)
 Add graphics item which represents one segment of the line.
void setPen (const QPen &pen)
 Set the pen style.
void setVisible (bool visible)
 Set each grid line as visible or hidden.

Detailed Description

Single grid line drawn a straight or curved line.

This is expected to be composed of QGraphicsEllipseItem and QGraphicsLineItem objects

Definition at line 20 of file GridLine.h.

Constructor & Destructor Documentation

◆ GridLine() [1/2]

GridLine::GridLine ( )

Default constructor for storage in containers.

Definition at line 15 of file GridLine.cpp.

16{
17}

◆ ~GridLine()

GridLine::~GridLine ( )
virtual

Definition at line 25 of file GridLine.cpp.

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}

◆ GridLine() [2/2]

GridLine::GridLine ( const GridLine & other)

Copy constructor. This will assert if called since copying of pointer containers is problematic.

Definition at line 19 of file GridLine.cpp.

20{
21 LOG4CPP_ERROR_S ((*mainCat)) << "GridLine::GridLine";
22 ENGAUGE_ASSERT (false);
23}
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
log4cpp::Category * mainCat
Definition Logger.cpp:14
#define LOG4CPP_ERROR_S(logger)
Definition convenience.h:12

Member Function Documentation

◆ add()

void GridLine::add ( QGraphicsItem * item)

Add graphics item which represents one segment of the line.

Definition at line 45 of file GridLine.cpp.

46{
47 m_segments.push_back (item);
48}

◆ operator=()

GridLine & GridLine::operator= ( GridLine & other)

Assignment constructor. This will assert if called since copying of pointer containers is problematic.

Definition at line 37 of file GridLine.cpp.

38{
39 LOG4CPP_ERROR_S ((*mainCat)) << "GridLine::operator=";
40 ENGAUGE_ASSERT (false);
41
42 return *this;
43}

◆ setPen()

void GridLine::setPen ( const QPen & pen)

Set the pen style.

Definition at line 50 of file GridLine.cpp.

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}

◆ setVisible()

void GridLine::setVisible ( bool visible)

Set each grid line as visible or hidden.

Definition at line 68 of file GridLine.cpp.

69{
70 for (int i = 0; i < m_segments.count(); i++) {
71 QGraphicsItem *item = m_segments [i];
72 item->setVisible (visible);
73 }
74}

The documentation for this class was generated from the following files: