QCAD Application Framework
CAD Application Development and Automation.
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
RGraphicsView.h
Go to the documentation of this file.
1
#ifndef RGRAPHICSVIEW_H
2
#define RGRAPHICSVIEW_H
3
4
#include <QKeyEvent>
5
#include <QCursor>
6
#include <QSwipeGesture>
7
#include <QPanGesture>
8
#include <QPinchGesture>
9
10
#include "
RExporter.h
"
11
#include "
RGrid.h
"
12
#include "
RNonCopyable.h
"
13
#include "
RTextLabel.h
"
14
#include "
RTerminateEvent.h
"
15
16
class
RAction
;
17
class
RDocumentInterface
;
18
class
RGraphicsScene
;
19
class
RLine
;
20
class
RMouseEvent
;
21
class
RTabletEvent
;
22
class
RWheelEvent
;
23
24
#ifndef RDEFAULT_MIN1
25
#define RDEFAULT_MIN1 -1
26
#endif
27
28
37
class
RGraphicsView
:
RNonCopyable
{
38
public
:
39
enum
ColorMode
{
40
FullColor
,
41
GrayScale
,
42
BlackWhite
43
};
44
45
public
:
46
RGraphicsView
(
RGraphicsScene
*
scene
= NULL);
47
virtual
~RGraphicsView
();
48
49
void
setDisplayOnlyCurrentUcs
(
bool
on);
50
51
virtual
void
setScene
(
RGraphicsScene
*
scene
,
bool
regen=
true
);
52
RGraphicsScene
*
getScene
();
53
RDocument
*
getDocument
()
const
;
54
RDocumentInterface
*
getDocumentInterface
();
55
62
virtual
RVector
mapFromView
(
const
RVector
& v,
double
z=0.0)
const
= 0;
63
67
virtual
RVector
mapToView
(
const
RVector
& v)
const
= 0;
68
virtual
RBox
mapToView
(
const
RBox
& box)
const
;
69
74
virtual
double
mapDistanceFromView
(
double
d)
const
= 0;
75
80
virtual
double
mapDistanceToView
(
double
d)
const
= 0;
81
82
virtual
QList<RVector>
mapCornersFromView
()
const
;
83
84
virtual
RBox
getBox
()
const
;
85
virtual
RVector
getMinimum
()
const
;
86
virtual
RVector
getMaximum
()
const
;
87
88
virtual
void
handleTerminateEvent
(
RTerminateEvent
& event);
89
90
virtual
void
handleKeyPressEvent
(QKeyEvent& event);
91
virtual
void
handleKeyReleaseEvent
(QKeyEvent& event);
92
virtual
void
simulateMouseMoveEvent
();
93
virtual
void
handleMouseMoveEvent
(
RMouseEvent
& event);
94
virtual
void
handleMousePressEvent
(
RMouseEvent
& event);
95
virtual
void
handleMouseReleaseEvent
(
RMouseEvent
& event);
96
virtual
void
handleMouseDoubleClickEvent
(
RMouseEvent
& event);
97
virtual
void
handleWheelEvent
(
RWheelEvent
& event);
98
virtual
void
handleTabletEvent
(
RTabletEvent
& event);
99
virtual
void
handleSwipeGestureEvent
(QSwipeGesture& gesture);
100
virtual
void
handlePanGestureEvent
(QPanGesture& gesture);
101
virtual
void
handlePinchGestureEvent
(QPinchGesture& gesture);
105
virtual
bool
hasFocus
() = 0;
106
virtual
void
removeFocus
() = 0;
107
108
virtual
void
viewportChangeEvent
();
109
110
void
saveViewport
();
111
void
restoreViewport
();
112
void
zoomIn
();
113
void
zoomOut
();
114
void
zoomIn
(
const
RVector
& center);
115
void
zoomOut
(
const
RVector
& center);
116
virtual
void
zoom
(
const
RVector
& center,
double
factor
);
117
virtual
void
zoomTo
(
const
RBox
& window,
int
margin
= 0);
118
void
zoomPrevious
();
119
void
autoZoom
(
int
margin
=
RDEFAULT_MIN1
);
120
bool
zoomToSelection
();
121
122
virtual
void
pan
(
const
RVector
& delta);
123
void
startPan
();
124
125
double
getFactor
(
bool
includeStepFactor=
true
)
const
;
126
void
setFactor
(
double
f,
bool
regen=
true
);
127
128
RVector
getOffset
(
bool
includeStepOffset=
true
)
const
;
129
void
setOffset
(
const
RVector
&
offset
,
bool
regen=
true
);
130
139
virtual
void
regenerate
(
bool
force=
false
) = 0;
140
148
virtual
void
repaintView
() = 0;
149
153
virtual
int
getWidth
()
const
= 0;
154
158
virtual
int
getHeight
()
const
= 0;
159
160
void
setNavigationAction
(
RAction
* action);
161
165
RGrid
*
getGrid
() {
166
return
grid
;
167
}
168
174
void
setGrid
(
RGrid
* g) {
175
if
(
grid
!=NULL) {
176
delete
grid
;
177
grid
= NULL;
178
}
179
grid
= g;
180
}
181
182
void
setGridVisible
(
bool
on) {
183
gridVisible
= on;
184
}
185
186
bool
isGridVisible
()
const
{
187
return
gridVisible
;
188
}
189
190
void
setDraftMode
(
bool
on);
191
bool
getDraftMode
()
const
{
192
return
draftMode
;
193
}
194
195
virtual
void
paintGridPoint
(
const
RVector
&
/*ucsPosition*/
) {}
196
virtual
void
paintMetaGridLine
(
const
RLine
&
/*ucsPosition*/
) {}
197
198
virtual
QCursor
getCursor
() {
return
QCursor(Qt::ArrowCursor); }
199
virtual
void
setCursor
(Qt::CursorShape
/*cursorShape*/
) {}
200
virtual
void
setCursor
(
const
QCursor&
/*cursor*/
) {}
201
202
RVector
getClosestReferencePoint
(
const
RVector
& screenPosition,
int
range);
203
RVector
getClosestReferencePoint
(
REntity::Id
entityId,
const
RVector
& screenPosition);
204
REntity::Id
getClosestEntity
(
const
RVector
& screenPosition,
int
range,
bool
includeLockedLayers=
true
);
205
//REntity::Id getClosestEntityInUcs(const RVector& screenPosition, int range);
206
207
virtual
void
setBackgroundColor
(
const
QColor& col);
208
QColor
getBackgroundColor
();
209
210
int
getMargin
();
211
void
setMargin
(
int
m);
212
213
void
setPrinting
(
bool
on);
214
bool
isPrinting
()
const
;
215
void
setPrintPreview
(
bool
on);
216
bool
isPrintPreview
()
const
;
217
void
setPrintPointSize
(
const
RVector
& s);
218
219
void
setColorMode
(
RGraphicsView::ColorMode
cm);
220
RGraphicsView::ColorMode
getColorMode
();
221
222
QList<RTextLabel>
getTextLabels
();
223
void
clearTextLabels
();
224
void
addTextLabel
(
const
RTextLabel
&textLabel);
225
226
RVector
getLastKnownMousePosition
()
const
{
227
return
lastKnownModelPosition
;
228
}
229
230
double
getCurrentStepScaleFactor
()
const
{
231
return
currentStepScaleFactor
;
232
}
233
234
void
setCurrentStepScaleFactor
(
double
f) {
235
currentStepScaleFactor
= f;
236
}
237
238
RVector
getCurrentStepOffset
()
const
{
239
return
currentStepOffset
;
240
}
241
242
void
setCurrentStepOffset
(
const
RVector
& s) {
243
currentStepOffset
= s;
244
}
245
246
protected
:
247
virtual
void
centerTo
(
const
RBox
& box);
248
249
protected
:
250
bool
printing
;
251
bool
printPreview
;
252
RVector
printPointSize
;
253
254
ColorMode
colorMode
;
255
259
RGraphicsScene
*
scene
;
260
264
RGrid
*
grid
;
265
270
RAction
*
navigationAction
;
271
276
RVector
offset
;
277
281
double
factor
;
282
283
RVector
previousOffset
;
284
double
previousFactor
;
285
290
bool
displayOnlyCurrentUcs
;
291
292
bool
autoScalePatterns
;
293
294
QColor
backgroundColor
;
295
int
margin
;
296
300
double
currentStepScaleFactor
;
301
302
RVector
currentStepOffset
;
303
RVector
lastKnownModelPosition
;
304
RVector
lastKnownViewPosition
;
305
309
QList<RTextLabel>
textLabels
;
310
311
bool
gridVisible
;
312
bool
draftMode
;
313
314
// for simulation: 0.0...1.0:
315
//int maxEntities;
316
//REntity::Id nextEntityId;
317
};
318
319
Q_DECLARE_METATYPE
(
RGraphicsView::ColorMode
)
320
Q_DECLARE_METATYPE
(
RGraphicsView
*)
321
Q_DECLARE_METATYPE
(QList<
RGraphicsView
*>)
322
323
#endif
src
core
RGraphicsView.h
Generated on Tue Jun 26 2012 18:41:07 for QCAD Application Framework by
1.8.1.1