-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLine.h
151 lines (139 loc) · 5.55 KB
/
Line.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#ifndef LINE_H
#define LINE_H
/*! \file */
#include "Shapes.h"
#include <QLine>
class Line: public Shape
{
public:
/*!*****************************************************************
* @brief Constructor Line: Class Line
*___________________________________________________________________
* Constructs a fully instantiated object of the Line class.
*___________________________________________________________________
* PRE-CONDITIONS
* int id - id of the shape
* ShapeType type - type of shape
*
* POST-CONDITIONS
* This function creates a Line object of type LINE.
* @param id - id of the shape
* @param type - type of shape
*******************************************************************/
Line(int id = -1, ShapeType type = NONE);
/*!*****************************************************************
* @brief Constructor Line: Class Line
*___________________________________________________________________
* Creates the default instance of the line class.
*___________________________________________________________________
* PRE-CONDITIONS
* <none>
*
* POST-CONDITIONS
* This function creates a Line object of type LINE.
*******************************************************************/
Line();
/*!*****************************************************************
* @brief Destructor ~Line: Class Line
*___________________________________________________________________
* Destructs the line object.
*___________________________________________________________________
* PRE-CONDITIONS
* <none>
*
* POST-CONDITIONS
* This function destructs the outstanding pointers in line.
*******************************************************************/
~Line() {}
//Accessors
/*!*****************************************************************
* @brief Method GetLine: Class Line
*___________________________________________________________________
* This method will return the address of a QLine line.
*___________________________________________________________________
* PRE-CONDITIONS
* <none>
*
* POST-CONDITIONS
* Returns QLine& of a line.
@return Returns QLine& of a line.
*******************************************************************/
QLine& GetLine();
//Mutators
/*!*****************************************************************
* @brief Method setLine: Class Line
*___________________________________________________________________
* This method will set the line using the points saved privately
* in Line.
*___________________________________________________________________
* PRE-CONDITIONS
* <none>
*
* POST-CONDITIONS
* Returns nothing.
*******************************************************************/
void setLine();
/*!*****************************************************************
* @brief Method draw: Class Line
*___________________________________________________________________
* This method will draw a line using the QLine line
* stored in Line.
*___________________________________________________________________
* PRE-CONDITIONS
* <none>
*
* POST-CONDITIONS
* Returns nothing. Draws shape on canvas.
*******************************************************************/
void draw(QPainter* shape) override;
/*!*****************************************************************
* @brief Method move: Class Line
*___________________________________________________________________
* This method will move a line using the integer array passed
* as a parameter to update the existing dimensions of the line.
*___________________________________________________________________
* PRE-CONDITIONS
* int[] - array of ints with new coordinates for points
*
* POST-CONDITIONS
* Returns nothing. Moves shape on canvas.
@param int[] array of ints with new coordinates for points
*******************************************************************/
void move(int[]) override;
/*!*****************************************************************
* @brief Method area: Class Line
*___________________________________________________________________
* This virtual method will calculate the area of a line,
* which is always zero.
*___________________________________________________________________
* PRE-CONDITIONS
* <none>
*
* POST-CONDITIONS
* Returns integer area(always 0 for Line)
@return Returns integer area(always 0 for Line)
*******************************************************************/
int area() override { return 0;}
/*!*****************************************************************
* @brief Method perimeter: Class Line
*___________________________________________________________________
* This virtual method will calculate the perimeter of a line,
* which is always zero.
*___________________________________________________________________
* PRE-CONDITIONS
* <none>
*
* POST-CONDITIONS
* Returns integer perimeter(always 0 for Line)
@return Returns integer perimeter(always 0 for Line)
*******************************************************************/
int perimeter() override { return 0; }
private:
/*! the line object */
QLine line;
/* the beginning point of the line */
QPoint beginPoint;
/* the end point of the line */
QPoint endPoint;
};
#endif // LINE_H