Laxkit
0.0.7.1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
lax
displayer.h
1
//
2
//
3
// The Laxkit, a windowing toolkit
4
// Please consult http://laxkit.sourceforge.net about where to send any
5
// correspondence about this software.
6
//
7
// This library is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU Library General Public
9
// License as published by the Free Software Foundation; either
10
// version 2 of the License, or (at your option) any later version.
11
//
12
// This library is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
// Library General Public License for more details.
16
//
17
// You should have received a copy of the GNU Library General Public
18
// License along with this library; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
//
21
// Copyright (C) 2004-2013 by Tom Lechner
22
//
23
#ifndef _LAX_DISPLAYER_H
24
#define _LAX_DISPLAYER_H
25
26
#include <lax/anxapp.h>
27
#include <lax/vectors.h>
28
#include <lax/pancontroller.h>
29
#include <lax/panuser.h>
30
#include <lax/doublebbox.h>
31
#include <lax/laximages.h>
32
#include <lax/screencolor.h>
33
#include <lax/drawingdefs.h>
34
35
#define DISPLAYER_NO_SHEAR (1<<0)
36
37
namespace
Laxkit {
38
39
40
//----------------------------------- Displayer -----------------------------
41
class
Displayer
:
public
PanUser
,
virtual
public
anObject
42
{
43
protected
:
44
45
//base displayer:
46
anXWindow
*xw;
47
aDrawable
*dr;
48
49
int
on;
//is displayer valid for drawing
50
char
updatepanner;
51
double
spaceminx
,
spacemaxx
,
spaceminy
,
spacemaxy
;
// workspace bounds
52
53
char
draw_immediately;
54
char
real_coordinates;
55
char
decimal;
56
int
num_bez_div;
57
58
public
:
59
unsigned
long
displayer_style;
60
61
double
upperbound
,
lowerbound
;
62
int
Minx
,
Maxx
,
Miny
,
Maxy
;
// screen coords of viewport bounding box
63
64
Displayer
(
aDrawable
*d);
65
Displayer
(
anXWindow
*w=NULL,
PanController
*pan=NULL);
66
virtual
~Displayer
();
67
virtual
Displayer
*duplicate() = 0;
68
71
virtual
aDrawable
*GetDrawable() {
return
dr; }
73
76
virtual
void
SwapBuffers() = 0;
77
virtual
void
BackBuffer(
int
on) = 0;
78
virtual
void
WrapWindow
(
anXWindow
*nw);
79
virtual
int
StartDrawing
(
aDrawable
*buffer) = 0;
80
virtual
int
MakeCurrent
(
aDrawable
*buffer) = 0;
81
virtual
int
ClearDrawable
(
aDrawable
*drawable) = 0;
82
virtual
int
CreateSurface
(
int
width,
int
height,
int
type=-1) = 0;
83
virtual
LaxImage
*
GetSurface
() = 0;
84
virtual
int
ResizeSurface
(
int
width,
int
height) = 0;
85
virtual
int
EndDrawing
() = 0;
87
90
virtual
unsigned
long
NewFG
(
double
r,
double
g,
double
b,
double
a=1.0) = 0;
91
virtual
unsigned
long
NewFG
(
unsigned
long
ncol) = 0;
92
virtual
unsigned
long
NewFG
(
ScreenColor
*col) = 0;
93
virtual
unsigned
long
NewFG
(
int
r,
int
g,
int
b,
int
a=255) = 0;
94
virtual
unsigned
long
NewBG
(
double
r,
double
g,
double
b) = 0;
95
virtual
unsigned
long
NewBG
(
int
r,
int
g,
int
b) = 0;
96
virtual
unsigned
long
NewBG
(
unsigned
long
nc) = 0;
97
virtual
unsigned
long
FG() = 0;
98
virtual
unsigned
long
BG() = 0;
99
virtual
void
LineAttributes
(
double
width,
int
dash,
int
cap,
int
join) = 0;
100
virtual
void
FillAttributes
(
int
fillstyle,
int
fillrule) = 0;
101
virtual
LaxCompositeOp
BlendMode
(
LaxCompositeOp
mode) = 0;
103
104
107
virtual
void
ClearWindow
() = 0;
108
virtual
flatpoint
realtoscreen
(
flatpoint
p) = 0;
109
virtual
flatpoint
realtoscreen
(
double
x,
double
y) = 0;
110
virtual
flatpoint
screentoreal
(
int
x,
int
y) = 0;
111
virtual
flatpoint
screentoreal
(
flatpoint
p) = 0;
112
113
virtual
int
Clip
(
flatpoint
*p,
int
n,
int
append) = 0;
//install a clip mask from a polyline (line is automatically closed)
114
virtual
void
PushClip
(
int
startfresh) = 0;
//push the current clip mask onto a stack, make a new one maybe
115
virtual
void
PopClip
() = 0;
//restore a previous mask
116
virtual
void
ClearClip
() = 0;
//remove any mask
117
virtual
int
activeMask
() = 0;
//return whether there is an active mask
118
119
//path drawing and filling
120
virtual
int
DrawReal
();
//any subsequent calls are using real coordinates
121
virtual
int
DrawScreen
();
//any subsequent calls are using screen coordinates
122
virtual
void
Radians
();
//interpret all angles as radians
123
virtual
void
Degrees
();
//interpret all angles as degrees
124
virtual
void
DrawOnMask
();
125
virtual
void
DrawOnSrc
();
126
virtual
int
DrawImmediately
(
int
yes);
//do not append path operations, draw them with each call
127
virtual
int
onscreen
(
double
x,
double
y);
128
129
virtual
void
show
() = 0;
//collapse source through mask onto surface
130
virtual
void
fill
(
int
preserve) = 0;
131
virtual
void
stroke
(
int
preserve) = 0;
132
virtual
void
moveto(
double
x,
double
y) { moveto(
flatpoint
(x,y)); }
133
virtual
void
moveto(
flatpoint
p) = 0;
134
virtual
void
lineto(
double
x,
double
y) { lineto(
flatpoint
(x,y)); }
135
virtual
void
lineto(
flatpoint
p) = 0;
136
virtual
void
curveto
(
flatpoint
c1,
flatpoint
c2,
flatpoint
v) = 0;
137
virtual
void
closed
() = 0;
138
virtual
void
closeopen
() = 0;
139
virtual
void
drawpixel
(
flatpoint
p) = 0;
140
virtual
void
drawpoint
(
double
x,
double
y,
double
radius,
int
fill
) = 0;
//draw filled circle radius r
141
virtual
void
drawpoint
(
flatpoint
p,
double
radius,
int
fill
);
//draw filled circle radius r
142
virtual
void
drawlines
(
flatpoint
*points,
int
npoints,
char
closed
,
char
fill
) = 0;
143
virtual
void
drawline
(
flatpoint
p1,
flatpoint
p2) = 0;
144
virtual
void
drawline
(
double
ax,
double
ay,
double
bx,
double
by);
145
virtual
void
drawrectangle
(
double
x,
double
y,
double
w,
double
h,
int
tofill);
146
virtual
void
drawbez
(
flatpoint
*bpoints,
int
n,
int
isclosed=0,
int
tofill=0);
147
virtual
int
drawrealline
(
flatline
&ln,
int
num);
148
virtual
void
drawellipse
(
double
x,
double
y,
double
xradius,
double
yradius,
double
start_angle=0,
double
end_angle=0,
int
fill
=0);
149
virtual
void
drawellipse
(
flatpoint
p,
double
xradius,
double
yradius,
double
start_angle=0,
double
end_angle=0,
int
fill
=0);
150
virtual
void
drawarc
(
flatpoint
p,
double
xr,
double
yr,
double
start_angle=0,
double
end_angle=0);
151
virtual
void
drawfocusellipse
(
flatpoint
focus1,
flatpoint
focus2,
double
c,
152
double
start_angle=0,
double
end_angle=0,
int
fill
=0);
153
154
//draw things
155
virtual
void
drawthing
(
double
x,
double
y,
double
rx,
double
ry,
int
fill
,
DrawThingTypes
thing);
// draws same orientation on screen
156
virtual
void
drawthing
(
double
x,
double
y,
double
rx,
double
ry,
DrawThingTypes
thing,
unsigned
long
fg,
unsigned
long
bg,
int
lwidth=1);
157
virtual
void
drawarrow
(
flatpoint
p,
flatpoint
v,
int
rfromp=0,
double
len=10,
char
reallength=1,
int
portion=3);
158
virtual
void
drawaxes
(
double
len=1);
//draw axes with real length at the origin
159
virtual
void
drawnum
(
double
x,
double
y,
int
num);
//write out the text of a number at the given coordinates.
160
161
//draw text
162
virtual
int
font(LaxFont *nfont,
double
size=-1) = 0;
163
virtual
int
font(
const
char
*fontconfigpattern) = 0;
164
virtual
int
font(
const
char
*family,
const
char
*style,
double
size) = 0;
165
virtual
int
fontsize
(
double
size) = 0;
166
virtual
int
textheight
() = 0;
167
virtual
double
textextent
(LaxFont *thisfont,
const
char
*str,
int
len,
double
*width,
double
*height,
double
*ascent,
double
*descent,
char
real) = 0;
168
virtual
double
textextent
(
const
char
*str,
int
len,
double
*width,
double
*height);
169
virtual
double
textout
(
double
x,
double
y,
const
char
*str,
int
len=0,
unsigned
long
align=LAX_CENTER) = 0;
170
virtual
double
textout
(
double
*matrix,
double
x,
double
y,
const
char
*str,
int
len=0,
unsigned
long
align=LAX_CENTER) = 0;
171
virtual
double
textout
(
double
angle
,
double
x,
double
y,
const
char
*str,
int
len=0,
unsigned
long
align=LAX_CENTER) = 0;
172
173
//draw images
174
virtual
int
imageout
(LaxImage *image,
double
x,
double
y,
double
w,
double
h) = 0;
175
virtual
void
imageout
(LaxImage *img,
double
x,
double
y) = 0;
176
virtual
void
imageout
(LaxImage *img,
double
*matrix) = 0;
177
virtual
void
imageout
(LaxImage *img,
double
angle
,
double
x,
double
y) = 0;
178
virtual
void
imageout_rotated(LaxImage *img,
double
x,
double
y,
double
ulx,
double
uly) = 0;
179
virtual
void
imageout_skewed(LaxImage *img,
double
x,
double
y,
double
ulx,
double
uly,
double
urx,
double
ury) = 0;
181
182
185
virtual
const
double
*
Getctm
() = 0;
186
virtual
const
double
*
Getictm
() = 0;
187
virtual
int
righthanded
();
188
189
virtual
char
Updates
(
char
toupdatepanner);
190
virtual
void
syncPanner
(
int
all=0);
191
virtual
void
syncFromPanner
(
int
all=0);
192
virtual
void
UseThisPanner
(PanController *npanner);
193
194
virtual
void
PushAxes
() = 0;
195
virtual
void
PopAxes
() = 0;
196
virtual
void
NewTransform
(
double
a,
double
b,
double
c,
double
d,
double
x0,
double
y0) = 0;
197
virtual
void
NewTransform
(
const
double
*d);
198
virtual
void
PushAndNewTransform
(
const
double
*m);
199
virtual
void
PushAndNewAxes
(
flatpoint
p,
flatpoint
x,
flatpoint
y);
200
virtual
void
NewAxis
(
flatpoint
o,
flatpoint
xtip);
201
virtual
void
NewAxis
(
flatpoint
o,
flatvector
x,
flatvector
y);
202
virtual
void
ShiftScreen
(
int
dx,
int
dy);
203
virtual
void
ShiftReal
(
double
dx,
double
dy);
204
virtual
void
Center
(
double
minx,
double
maxx,
double
miny,
double
maxy);
205
virtual
void
Center
(
const
double
*m,DoubleBBox *bbox);
206
virtual
void
Center
(DoubleBBox *bbox);
207
virtual
void
CenterPoint
(
flatpoint
p);
208
virtual
void
CenterReal
();
209
virtual
void
Newangle
(
double
angle
,
int
dir=0,
int
dec=-1);
210
virtual
void
Rotate
(
double
angle
,
int
x,
int
y,
int
dec=-1);
211
virtual
void
Zoomr
(
double
m,
flatpoint
p);
212
virtual
void
Zoom
(
double
m,
int
x,
int
y);
213
virtual
void
Zoom
(
double
m);
214
virtual
double
Getmag
(
int
y=0);
215
virtual
double
GetVMag
(
int
x,
int
y);
216
virtual
void
Newmag
(
double
xs,
double
ys=-1);
217
virtual
void
SetView
(
double
minx,
double
maxx,
double
miny,
double
maxy);
218
virtual
int
SetSpace
(
double
minx,
double
maxx,
double
miny,
double
maxy);
219
virtual
void
GetSpace
(
double
*minx,
double
*maxx,
double
*miny,
double
*maxy);
220
virtual
void
GetTransformedSpace
(
long
*minx,
long
*maxx,
long
*miny,
long
*maxy);
222
};
223
224
225
//--------------------------------------- Default Renderer Stuff ---------------------------
226
227
typedef
Displayer
*(*NewDisplayerFunc)(
aDrawable
*w);
228
extern
NewDisplayerFunc
newDisplayer
;
229
int
SetNewDisplayerFunc
(
const
char
*backend);
230
231
int
SetDefaultDisplayer
(
Displayer
*displayer);
232
Displayer
*
GetDefaultDisplayer
();
233
234
}
// namespace Laxkit
235
236
#endif
Mon Feb 17 2014 11:52:56, Laxkit