Do not use PS* functions.

This commit is contained in:
Bill Currie 2010-09-24 20:44:07 +09:00
parent 940d9613f5
commit b141de8d09
4 changed files with 109 additions and 71 deletions

View file

@ -1,7 +1,3 @@
#include <AppKit/NSGraphics.h>
#include <AppKit/DPSOperators.h>
#include "QF/sys.h" #include "QF/sys.h"
#include "Clipper.h" #include "Clipper.h"
@ -12,6 +8,7 @@
#include "QuakeEd.h" #include "QuakeEd.h"
id clipper_i; id clipper_i;
extern NSBezierPath *path;
@implementation Clipper @implementation Clipper
@ -185,41 +182,52 @@ XYDrag
-XYDrawSelf -XYDrawSelf
{ {
int i; int i;
char text[8]; NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
PSsetrgbcolor (1, 0.5, 0); [[NSColor colorWithCalibratedRed: 1.0 green: 0.5 blue: 0.0 alpha: 1.0]
set];
[[NSFont systemFontOfSize: 10 / [xyview_i currentScale]] set]; [[NSFont systemFontOfSize: 10 / [xyview_i currentScale]] set];
PSrotate (0);
[path removeAllPoints];
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
PSmoveto (pos[i][0] - 4, pos[i][1] - 4); NSString *s = [NSString stringWithFormat: @"%i", i];
sprintf (text, "%i", i); [s drawAtPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)
PSshow (text); withAttributes: attribs];
PSstroke (); //[path moveToPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)];
PSarc (pos[i][0], pos[i][1], 10, 0, 360); [path appendBezierPathWithArcWithCenter: NSMakePoint (pos[i][0],
PSstroke (); pos[i][1])
radius: 10
startAngle: 0
endAngle: 360];
} }
[path stroke];
return self; return self;
} }
-ZDrawSelf -ZDrawSelf
{ {
int i; int i;
char text[8]; NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
PSsetrgbcolor (1, 0.5, 0); [[NSColor colorWithCalibratedRed: 1.0 green: 0.5 blue: 0.0 alpha: 1.0]
[[NSFont systemFontOfSize: 10 / [zview_i currentScale]] set]; set];
PSrotate (0);
[[NSFont systemFontOfSize: 10 / [xyview_i currentScale]] set];
[path removeAllPoints];
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
PSmoveto (-28 + i * 8 - 4, pos[i][2] - 4); NSString *s = [NSString stringWithFormat: @"%i", i];
sprintf (text, "%i", i); [s drawAtPoint: NSMakePoint (-28 + i * 8 - 4, pos[i][2] - 4)
PSshow (text); withAttributes: attribs];
PSstroke (); //[path moveToPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)];
PSarc (-28 + i * 8, pos[i][2], 10, 0, 360); [path appendBezierPathWithArcWithCenter: NSMakePoint (-28 + i * 8,
PSstroke (); pos[i][2])
radius: 10
startAngle: 0
endAngle: 360];
} }
[path stroke];
return self; return self;
} }

View file

@ -486,7 +486,10 @@ lineflush (void)
if ([path isEmpty]) if ([path isEmpty])
return; return;
// endUserPath (upath, dps_ustroke); // endUserPath (upath, dps_ustroke);
PSsetrgbcolor (cur_linecolor[0], cur_linecolor[1], cur_linecolor[2]); [[NSColor colorWithCalibratedRed: cur_linecolor[0]
green: cur_linecolor[1]
blue: cur_linecolor[2]
alpha: 1.0] set];
[path stroke]; [path stroke];
[path removeAllPoints]; [path removeAllPoints];
} }
@ -531,7 +534,7 @@ Rect is in global world (unscaled) coordinates
{ {
int x, y, stopx, stopy; int x, y, stopx, stopy;
float top, bottom, right, left; float top, bottom, right, left;
char text[10]; NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
BOOL showcoords; BOOL showcoords;
NSPoint point; NSPoint point;
@ -542,7 +545,8 @@ Rect is in global world (unscaled) coordinates
right = rect.origin.x + rect.size.width + 2; right = rect.origin.x + rect.size.width + 2;
top = rect.origin.y + rect.size.height + 2; top = rect.origin.y + rect.size.height + 2;
PSsetlinewidth (0.15); [path removeAllPoints];
[path setLineWidth: 0.15];
// //
// grid // grid
@ -589,14 +593,18 @@ Rect is in global world (unscaled) coordinates
[path lineToPoint:point]; [path lineToPoint:point];
} }
// endUserPath (upath, dps_ustroke); // endUserPath (upath, dps_ustroke);
PSsetrgbcolor (0.8, 0.8, 1.0); // thin grid color [[NSColor colorWithCalibratedRed: 0.8
green: 0.8
blue: 1.0
alpha: 1.0] set]; // thin grid color
[path stroke]; [path stroke];
} }
// //
// tiles // tiles
// //
PSsetgray (0); // for text [[NSColor colorWithCalibratedWhite: 0.0 / 16.0 alpha: 1.0]
set]; // for text
if (scale > 4.0 / 64) { if (scale > 4.0 / 64) {
y = floor (bottom / 64); y = floor (bottom / 64);
@ -621,9 +629,8 @@ Rect is in global world (unscaled) coordinates
for (; y <= stopy; y += 64) { for (; y <= stopy; y += 64) {
if (showcoords) { if (showcoords) {
sprintf (text, "%i", y); NSString *s = [NSString stringWithFormat: @"%i", y];
PSmoveto (left, y); [s drawAtPoint: NSMakePoint (left, y) withAttributes: attribs];
PSshow (text);
} }
[path moveToPoint:point]; [path moveToPoint:point];
point.x = right; point.x = right;
@ -632,9 +639,9 @@ Rect is in global world (unscaled) coordinates
for (; x <= stopx; x += 64) { for (; x <= stopx; x += 64) {
if (showcoords) { if (showcoords) {
sprintf (text, "%i", x); NSString *s = [NSString stringWithFormat: @"%i", x];
PSmoveto (x, bottom + 2); [s drawAtPoint: NSMakePoint (x, bottom + 2)
PSshow (text); withAttributes: attribs];
} }
point.x = x; point.x = x;
point.y = top; point.y = top;
@ -644,9 +651,11 @@ Rect is in global world (unscaled) coordinates
} }
// endUserPath (upath, dps_ustroke); // endUserPath (upath, dps_ustroke);
PSsetgray (12.0 / 16); [[NSColor colorWithCalibratedWhite: 12.0 / 16.0 alpha: 1.0]
set];
[path stroke]; [path stroke];
} }
[path setLineWidth: 1];
return self; return self;
} }
@ -663,6 +672,7 @@ drawWire
id ent, brush; id ent, brush;
vec3_t mins, maxs; vec3_t mins, maxs;
BOOL drawnames; BOOL drawnames;
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
drawnames =[quakeed_i showNames]; drawnames =[quakeed_i showNames];
@ -701,10 +711,13 @@ drawWire
if (i > 0 && drawnames) { // draw entity names if (i > 0 && drawnames) { // draw entity names
brush =[ent objectAtIndex:0]; brush =[ent objectAtIndex:0];
if (![brush regioned]) { if (![brush regioned]) {
const char *classname = [ent valueForQKey:"classname"];
NSString *s = [NSString stringWithCString: classname];
[[NSColor colorWithCalibratedWhite: 0.0 / 16.0 alpha: 1.0]
set];
[brush getMins: mins maxs:maxs]; [brush getMins: mins maxs:maxs];
PSmoveto (mins[0], mins[1]); [s drawAtPoint: NSMakePoint (mins[0], mins[1])
PSsetrgbcolor (0, 0, 0); withAttributes: attribs];
PSshow ([ent valueForQKey:"classname"]);
} }
} }
} }
@ -810,9 +823,7 @@ NSRect xy_draw_rect;
newrect.size.width = newrect.size.height = -2 * 99999; newrect.size.width = newrect.size.height = -2 * 99999;
// setup for text // setup for text
// PSselectfont("Helvetica-Medium",10/scale);
[[NSFont systemFontOfSize: 10] set]; [[NSFont systemFontOfSize: 10] set];
PSrotate (0);
if (drawmode == dr_texture || drawmode == dr_flat) if (drawmode == dr_texture || drawmode == dr_flat)
[self drawSolid]; [self drawSolid];

View file

@ -22,6 +22,8 @@ extern float zplanedir;
float scale; float scale;
vec3_t origin; vec3_t origin;
NSBezierPath *checker;
} }
-clearBounds; -clearBounds;

View file

@ -25,6 +25,14 @@ initWithFrame:
- (id) initWithFrame:(NSRect) frameRect - (id) initWithFrame:(NSRect) frameRect
{ {
NSPoint pt; NSPoint pt;
NSBezierPath *path;
path = checker = [NSBezierPath new];
[path setLineWidth: 0.3];
[path moveToPoint: NSMakePoint (-16, -16)];
[path relativeLineToPoint: NSMakePoint (32, 32)];
[path moveToPoint: NSMakePoint (-16, 16)];
[path relativeLineToPoint: NSMakePoint (32, -32)];
origin[0] = 0.333; origin[0] = 0.333;
origin[1] = 0.333; origin[1] = 0.333;
@ -283,21 +291,17 @@ Rect is in global world (unscaled) coordinates
float top, bottom; float top, bottom;
int left, right; int left, right;
int gridsize; int gridsize;
char text[10];
BOOL showcoords; BOOL showcoords;
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
showcoords =[quakeed_i showCoordinates]; showcoords =[quakeed_i showCoordinates];
PSsetlinewidth (0);
gridsize =[xyview_i gridsize]; gridsize =[xyview_i gridsize];
left = _bounds.origin.x; left = _bounds.origin.x;
right = 24; right = 24;
//Sys_Printf ("gridsize: %d left: %d right: %d\n", gridsize, left, right);
bottom = rect.origin.y - 1; bottom = rect.origin.y - 1;
top = rect.origin.y + rect.size.height + 2; top = rect.origin.y + rect.size.height + 2;
// //
// grid // grid
// //
@ -321,7 +325,8 @@ Rect is in global world (unscaled) coordinates
[path lineToPoint:NSMakePoint (right, y)]; [path lineToPoint:NSMakePoint (right, y)];
} }
// endUserPath (upath, dps_ustroke); // endUserPath (upath, dps_ustroke);
PSsetrgbcolor (0.8, 0.8, 1.0); // thin grid color [[NSColor colorWithCalibratedRed: 0.8 green: 0.8 blue: 1.0 alpha: 1.0]
set]; // thin grid color
[path stroke]; [path stroke];
} }
// //
@ -345,7 +350,8 @@ Rect is in global world (unscaled) coordinates
} }
// endUserPath (upath, dps_ustroke); // endUserPath (upath, dps_ustroke);
PSsetgray (12.0 / 16.0); [[NSColor colorWithCalibratedWhite: 12.0 / 16.0 alpha: 1.0]
set];
[path stroke]; [path stroke];
// //
@ -362,15 +368,14 @@ Rect is in global world (unscaled) coordinates
stopy -= 64; stopy -= 64;
[path removeAllPoints]; [path removeAllPoints];
PSsetgray (0); // for text [[NSColor colorWithCalibratedWhite: 0.0 / 16.0 alpha: 1.0]
PSrotate (0); set]; // for text
[[NSFont systemFontOfSize: 10] set]; [[NSFont systemFontOfSize: 10] set];
for (; y <= stopy; y += 64) { for (; y <= stopy; y += 64) {
if (showcoords) { if (showcoords) {
sprintf (text, "%i", y); NSString *s = [NSString stringWithFormat: @"%i", y];
PSmoveto (left, y); [s drawAtPoint: NSMakePoint (left, y) withAttributes: attribs];
PSshow (text);
} }
[path moveToPoint:NSMakePoint (left + 24, y)]; [path moveToPoint:NSMakePoint (left + 24, y)];
[path lineToPoint:NSMakePoint (right, y)]; [path lineToPoint:NSMakePoint (right, y)];
@ -382,18 +387,21 @@ Rect is in global world (unscaled) coordinates
_bounds.origin.y + _bounds.size.height)]; _bounds.origin.y + _bounds.size.height)];
// endUserPath (upath, dps_ustroke); // endUserPath (upath, dps_ustroke);
PSsetgray (10.0 / 16.0); [[NSColor colorWithCalibratedWhite: 10.0 / 16.0 alpha: 1.0]
set];
[path stroke]; [path stroke];
// //
// origin // origin
// //
PSsetlinewidth (5); [[NSColor colorWithCalibratedWhite: 4.0 / 16.0 alpha: 1.0]
PSsetgray (4.0 / 16.0); set];
PSmoveto (right, 0); [path removeAllPoints];
PSlineto (left, 0); [path setLineWidth: 5];
PSstroke (); [path moveToPoint: NSMakePoint (right, 0)];
PSsetlinewidth (0.15); [path lineToPoint: NSMakePoint (left, 0)];
[path stroke];
[path setLineWidth: 1];
return self; return self;
} }
@ -401,9 +409,13 @@ Rect is in global world (unscaled) coordinates
-drawZplane -drawZplane
{ {
PSsetrgbcolor (0.2, 0.2, 0); [[NSColor colorWithCalibratedRed: 0.2 green: 0.2 blue: 0.0 alpha: 1.0]
PSarc (0, zplane, 4, 0, M_PI * 2); set];
PSfill (); [path appendBezierPathWithArcWithCenter: NSMakePoint (0, zplane)
radius: 4
startAngle: 0
endAngle: 180];
[path fill];
return self; return self;
} }
@ -422,7 +434,7 @@ drawSelf
// allways draw the entire bar // allways draw the entire bar
//visRect =[self visibleRect]; //visRect =[self visibleRect];
rects = [self bounds]; rects = [self visibleRect];
// erase window // erase window
NSEraseRect (rects); NSEraseRect (rects);
@ -431,7 +443,7 @@ drawSelf
[self drawGrid:rects]; [self drawGrid:rects];
// draw zplane // draw zplane
// [self drawZplane]; // [self drawZplane]; FIXME zplane doesn't do anything yet
// draw all entities // draw all entities
[map_i makeUnselectedPerform:@selector (ZDrawSelf)]; [map_i makeUnselectedPerform:@selector (ZDrawSelf)];
@ -449,13 +461,18 @@ XYDrawSelf
*/ */
-XYDrawSelf -XYDrawSelf
{ {
PSsetrgbcolor (0, 0.5, 1.0); NSBezierPath *path;
PSsetlinewidth (0.15); NSAffineTransform *trans;
PSmoveto (origin[0] - 16, origin[1] - 16);
PSrlineto (32, 32); [[NSColor colorWithCalibratedRed: 0 green: 0.5 blue: 1.0 alpha: 1.0] set];
PSmoveto (origin[0] - 16, origin[1] + 16);
PSrlineto (32, -32); trans = [NSAffineTransform transform];
PSstroke (); [trans translateXBy: origin[0] yBy: origin[1]];
path = [checker copy];
[path transformUsingAffineTransform: trans];
[path stroke];
[path release];
return self; return self;
} }