-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpointeritem.h
More file actions
executable file
·127 lines (101 loc) · 3.49 KB
/
pointeritem.h
File metadata and controls
executable file
·127 lines (101 loc) · 3.49 KB
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
/****************************************************************************
*
* This class implements the graphical pointers that extend from callouts to
* assembly images as visual indicators to the builder as to where to
* add the completed submodel into partially assembeled final model.
*
* Please see lpub.h for an overall description of how the files in LPub
* make up the LPub program.
*
***************************************************************************/
#ifndef POINTERITEMH
#define POINTERITEMH
#include "pointer.h"
#include "metaitem.h"
#include "resize.h"
class QGraphicsPolygonItem;
class QGraphicsLineItem;
class QGraphicsItemGroup;
class Callout;
class CalloutPointerItem : public QGraphicsItemGroup, public MetaItem, public AbstractResize
{
public:
CalloutPointerItem(
Callout *co,
Meta *meta,
Pointer *pointer,
QGraphicsItem *parent,
QGraphicsView *view);
public:
enum SelectedPoint { Tip, Base, NumGrabbers };
private:
QGraphicsView *view;
Callout *callout;
QString borderColor;
float borderThickness;
Pointer pointer;
PlacementEnc placement;
bool positionChanged;
QGraphicsLineItem *shaft;
QGraphicsPolygonItem *head;
QPointF points[NumGrabbers]; // the points on the inside polygon
Grabber *grabbers[NumGrabbers];
virtual void placeGrabbers();
virtual void resize(QPointF);
virtual void change();
virtual QGraphicsItem *myParentItem()
{
return parentItem();
}
/*
* +--------------------------------------------++
* | |
* | . +-------------------------------------+ |
* | | | . |
* | | | |
*
*
* callout size defines the outside edge of the callout.
* When there is a border, the inside rectangle starts
* at +thickness,+thickness, and ends at size-thickness,
* size-tickness.
*
* Using round end cap caps the ends of the lines that
* intersect the callout are at +- tickness/2. I'm not
* sure the affect of thickness is even vs. odd.
*
* Loc should be calculated on the inside rectangle?
* The triangles have to go to the edge of the inner
* rectangle to obscure the border.
*
*/
public:
void drawTip(QPoint delta);
/* When we drag the pointer tip, we move the tip relative
* to the CSI rect, so we must recalculate the offset
* into the CSI */
void updatePointer(QPoint &delta);
/* When the user "Add Pointer", we need to give a default/
reasonable pointer */
void defaultPointer();
private:
/* Drag the tip of the pointer, and calculate a good
* location for the pointer to connect to the callout. */
bool autoLocFromTip();
/* When we drag the CSI or the pointer's callout, we
* need recalculate the Location portion of the pointer
* meta, but the offset remains unchanged */
void calculatePointerMetaLoc();
void calculatePointerMeta();
/* When using menu to add a new pointer, we need to add
* a new line to the LDraw file. */
void addPointerMeta();
/* When we drag the callout or CSI, we need to recalculate
* the pointer . */
void drawPointerPoly();
bool autoLocFromLoc(QPoint loc);
protected:
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
};
#endif