Engauge Digitizer 2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
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 14 of file GridLine.cpp.

15{
16}

◆ ~GridLine()

GridLine::~GridLine ( )
virtual

Definition at line 23 of file GridLine.cpp.

24{
25 // Crash here means QGraphicsScene::clear was called, which is entirely unnecessary
26
27 for (int i = 0; i < m_segments.count(); i++) {
28 QGraphicsItem *item = m_segments [i];
29 delete item;
30 }
31
32 m_segments.clear ();
33}
const int INNER_RADIUS_MIN

◆ 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 18 of file GridLine.cpp.

19{
20 ENGAUGE_ASSERT (false);
21}
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...

Member Function Documentation

◆ add()

void GridLine::add ( QGraphicsItem * item)

Add graphics item which represents one segment of the line.

Definition at line 42 of file GridLine.cpp.

43{
44 m_segments.push_back (item);
45}

◆ operator=()

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

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

Definition at line 35 of file GridLine.cpp.

36{
37 ENGAUGE_ASSERT (false);
38
39 return *this;
40}

◆ setPen()

void GridLine::setPen ( const QPen & pen)

Set the pen style.

Definition at line 47 of file GridLine.cpp.

48{
49 for (int i = 0; i < m_segments.count(); i++) {
50 QGraphicsItem *item = m_segments [i];
51 if (item != nullptr) {
52
53 // Downcast since QGraphicsItem does not have a pen
54 QGraphicsLineItem *itemLine = dynamic_cast<QGraphicsLineItem*> (item);
55 QGraphicsEllipseItem *itemArc = dynamic_cast<QGraphicsEllipseItem*> (item);
56 if (itemLine != nullptr) {
57 itemLine->setPen (pen);
58 } else if (itemArc != nullptr) {
59 itemArc->setPen (pen);
60 }
61 }
62 }
63}

◆ setVisible()

void GridLine::setVisible ( bool visible)

Set each grid line as visible or hidden.

Definition at line 65 of file GridLine.cpp.

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

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