summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bltGrMarkerBitmap.C64
-rw-r--r--bltGrMarkerBitmap.h14
-rw-r--r--src/bltGrMarkerLine.h14
-rw-r--r--src/bltGrMarkerPolygon.C118
-rw-r--r--src/bltGrMarkerPolygon.h14
-rw-r--r--src/bltGrMarkerText.C67
-rw-r--r--src/bltGrMarkerText.h14
7 files changed, 140 insertions, 165 deletions
diff --git a/bltGrMarkerBitmap.C b/bltGrMarkerBitmap.C
index bac9682..d10083d 100644
--- a/bltGrMarkerBitmap.C
+++ b/bltGrMarkerBitmap.C
@@ -114,25 +114,26 @@ static int ConfigureBitmapProc(Marker* markerPtr)
{
Graph* graphPtr = markerPtr->obj.graphPtr;
BitmapMarker* bmPtr = (BitmapMarker*)markerPtr;
+ BitmapMarkerOptions* ops = (BitmapMarkerOptions*)bmPtr->ops;
- if (bmPtr->ops->bitmap == None)
+ if (ops->bitmap == None)
return TCL_OK;
XGCValues gcValues;
unsigned long gcMask = 0;
- if (bmPtr->ops->outlineColor) {
+ if (ops->outlineColor) {
gcMask |= GCForeground;
- gcValues.foreground = bmPtr->ops->outlineColor->pixel;
+ gcValues.foreground = ops->outlineColor->pixel;
}
- if (bmPtr->ops->fillColor) {
+ if (ops->fillColor) {
// Opaque bitmap: both foreground and background (fill) colors are used
- gcValues.background = bmPtr->ops->fillColor->pixel;
+ gcValues.background = ops->fillColor->pixel;
gcMask |= GCBackground;
}
else {
// Transparent bitmap: set the clip mask to the current bitmap
- gcValues.clip_mask = bmPtr->ops->bitmap;
+ gcValues.clip_mask = ops->bitmap;
gcMask |= GCClipMask;
}
@@ -146,8 +147,8 @@ static int ConfigureBitmapProc(Marker* markerPtr)
bmPtr->gc = newGC;
// Create the background GC containing the fill color
- if (bmPtr->ops->fillColor) {
- gcValues.foreground = bmPtr->ops->fillColor->pixel;
+ if (ops->fillColor) {
+ gcValues.foreground = ops->fillColor->pixel;
newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues);
if (bmPtr->fillGC)
Tk_FreeGC(graphPtr->display, bmPtr->fillGC);
@@ -160,23 +161,24 @@ static int ConfigureBitmapProc(Marker* markerPtr)
static void MapBitmapProc(Marker* markerPtr)
{
BitmapMarker* bmPtr = (BitmapMarker*)markerPtr;
+ BitmapMarkerOptions* ops = (BitmapMarkerOptions*)bmPtr->ops;
Graph* graphPtr = markerPtr->obj.graphPtr;
- if (bmPtr->ops->bitmap == None)
+ if (ops->bitmap == None)
return;
- if (!bmPtr->ops->worldPts || (bmPtr->ops->worldPts->num < 1))
+ if (!ops->worldPts || (ops->worldPts->num < 1))
return;
int width, height;
- Tk_SizeOfBitmap(graphPtr->display, bmPtr->ops->bitmap, &width, &height);
+ Tk_SizeOfBitmap(graphPtr->display, ops->bitmap, &width, &height);
Point2d anchorPt =
- Blt_MapPoint(bmPtr->ops->worldPts->points, &bmPtr->ops->axes);
+ Blt_MapPoint(ops->worldPts->points, &ops->axes);
anchorPt = Blt_AnchorPoint(anchorPt.x, anchorPt.y, width, height,
- bmPtr->ops->anchor);
- anchorPt.x += bmPtr->ops->xOffset;
- anchorPt.y += bmPtr->ops->yOffset;
+ ops->anchor);
+ anchorPt.x += ops->xOffset;
+ anchorPt.y += ops->yOffset;
Region2d extents;
extents.left = anchorPt.x;
@@ -219,8 +221,9 @@ static void MapBitmapProc(Marker* markerPtr)
static int PointInBitmapProc(Marker* markerPtr, Point2d *samplePtr)
{
BitmapMarker* bmPtr = (BitmapMarker*)markerPtr;
+ BitmapMarkerOptions* ops = (BitmapMarkerOptions*)bmPtr->ops;
- if (bmPtr->ops->bitmap == None)
+ if (ops->bitmap == None)
return 0;
return ((samplePtr->x >= bmPtr->anchorPt.x) &&
@@ -251,11 +254,13 @@ static void DrawBitmapProc(Marker* markerPtr, Drawable drawable)
{
Graph* graphPtr = markerPtr->obj.graphPtr;
BitmapMarker* bmPtr = (BitmapMarker*)markerPtr;
- if ((bmPtr->ops->bitmap == None) || (bmPtr->width < 1) || (bmPtr->height < 1))
+ BitmapMarkerOptions* ops = (BitmapMarkerOptions*)bmPtr->ops;
+
+ if ((ops->bitmap == None) || (bmPtr->width < 1) || (bmPtr->height < 1))
return;
- if (bmPtr->ops->fillColor == NULL) {
- XSetClipMask(graphPtr->display, bmPtr->gc, bmPtr->ops->bitmap);
+ if (ops->fillColor == NULL) {
+ XSetClipMask(graphPtr->display, bmPtr->gc, ops->bitmap);
XSetClipOrigin(graphPtr->display, bmPtr->gc, bmPtr->anchorPt.x,
bmPtr->anchorPt.y);
}
@@ -263,7 +268,7 @@ static void DrawBitmapProc(Marker* markerPtr, Drawable drawable)
XSetClipMask(graphPtr->display, bmPtr->gc, None);
XSetClipOrigin(graphPtr->display, bmPtr->gc, 0, 0);
}
- XCopyPlane(graphPtr->display, bmPtr->ops->bitmap, drawable, bmPtr->gc, 0, 0,
+ XCopyPlane(graphPtr->display, ops->bitmap, drawable, bmPtr->gc, 0, 0,
bmPtr->width, bmPtr->height, bmPtr->anchorPt.x,
bmPtr->anchorPt.y, 1);
}
@@ -272,14 +277,16 @@ static void BitmapToPostscriptProc(Marker* markerPtr, Blt_Ps ps)
{
Graph* graphPtr = markerPtr->obj.graphPtr;
BitmapMarker* bmPtr = (BitmapMarker*)markerPtr;
- if ((bmPtr->ops->bitmap == None) || (bmPtr->width < 1) || (bmPtr->height < 1))
+ BitmapMarkerOptions* ops = (BitmapMarkerOptions*)bmPtr->ops;
+
+ if ((ops->bitmap == None) || (bmPtr->width < 1) || (bmPtr->height < 1))
return;
- if (bmPtr->ops->fillColor) {
- Blt_Ps_XSetBackground(ps, bmPtr->ops->fillColor);
+ if (ops->fillColor) {
+ Blt_Ps_XSetBackground(ps, ops->fillColor);
Blt_Ps_XFillPolygon(ps, bmPtr->outline, 4);
}
- Blt_Ps_XSetForeground(ps, bmPtr->ops->outlineColor);
+ Blt_Ps_XSetForeground(ps, ops->outlineColor);
Blt_Ps_Format(ps,
" gsave\n %g %g translate\n %d %d scale\n",
@@ -288,7 +295,7 @@ static void BitmapToPostscriptProc(Marker* markerPtr, Blt_Ps ps)
Blt_Ps_Format(ps, " %d %d true [%d 0 0 %d 0 %d] {",
bmPtr->width, bmPtr->height, bmPtr->width,
-bmPtr->height, bmPtr->height);
- Blt_Ps_XSetBitmapData(ps, graphPtr->display, bmPtr->ops->bitmap,
+ Blt_Ps_XSetBitmapData(ps, graphPtr->display, ops->bitmap,
bmPtr->width, bmPtr->height);
Blt_Ps_VarAppend(ps,
" } imagemask\n",
@@ -297,8 +304,9 @@ static void BitmapToPostscriptProc(Marker* markerPtr, Blt_Ps ps)
static void FreeBitmapProc(Marker* markerPtr)
{
- BitmapMarker* bmPtr = (BitmapMarker*)markerPtr;
Graph* graphPtr = markerPtr->obj.graphPtr;
+ BitmapMarker* bmPtr = (BitmapMarker*)markerPtr;
+ BitmapMarkerOptions* ops = (BitmapMarkerOptions*)bmPtr->ops;
if (bmPtr->gc)
Tk_FreeGC(graphPtr->display, bmPtr->gc);
@@ -306,7 +314,7 @@ static void FreeBitmapProc(Marker* markerPtr)
if (bmPtr->fillGC)
Tk_FreeGC(graphPtr->display, bmPtr->fillGC);
- if (bmPtr->ops)
- free(bmPtr->ops);
+ if (ops)
+ free(ops);
}
diff --git a/bltGrMarkerBitmap.h b/bltGrMarkerBitmap.h
index 8661399..48d4a19 100644
--- a/bltGrMarkerBitmap.h
+++ b/bltGrMarkerBitmap.h
@@ -49,20 +49,8 @@ typedef struct {
XColor* outlineColor;
} BitmapMarkerOptions;
-class BitmapMarker {
+class BitmapMarker : public Marker {
public:
- GraphObj obj;
- MarkerClass *classPtr;
- Tk_OptionTable optionTable;
- Tcl_HashEntry *hashPtr;
- Blt_ChainLink link;
- int clipped;
- unsigned int flags;
-
- void* ops;
-
- // Fields specific to bitmap
-
Point2d anchorPt;
GC gc;
GC fillGC;
diff --git a/src/bltGrMarkerLine.h b/src/bltGrMarkerLine.h
index 5c1cb5f..bd03898 100644
--- a/src/bltGrMarkerLine.h
+++ b/src/bltGrMarkerLine.h
@@ -52,20 +52,8 @@ typedef struct {
int xorr;
} LineMarkerOptions;
-class LineMarker {
+class LineMarker : public Marker {
public:
- GraphObj obj;
- MarkerClass *classPtr;
- Tk_OptionTable optionTable;
- Tcl_HashEntry *hashPtr;
- Blt_ChainLink link;
- int clipped;
- unsigned int flags;
-
- void* ops;
-
- // Fields specific to line
-
GC gc;
Segment2d *segments;
int nSegments;
diff --git a/src/bltGrMarkerPolygon.C b/src/bltGrMarkerPolygon.C
index 55af0cf..4364c2e 100644
--- a/src/bltGrMarkerPolygon.C
+++ b/src/bltGrMarkerPolygon.C
@@ -127,12 +127,13 @@ Marker* Blt_CreatePolygonProc(Graph* graphPtr)
static int PointInPolygonProc(Marker *markerPtr, Point2d *samplePtr)
{
PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
+ PolygonMarkerOptions* ops = (PolygonMarkerOptions*)pmPtr->ops;
- if (pmPtr->ops->worldPts &&
- (pmPtr->ops->worldPts->num >= 3) &&
+ if (ops->worldPts &&
+ (ops->worldPts->num >= 3) &&
(pmPtr->screenPts))
return Blt_PointInPolygon(samplePtr, pmPtr->screenPts,
- pmPtr->ops->worldPts->num + 1);
+ ops->worldPts->num + 1);
return FALSE;
}
@@ -141,12 +142,13 @@ static int RegionInPolygonProc(Marker *markerPtr, Region2d *extsPtr,
int enclosed)
{
PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
+ PolygonMarkerOptions* ops = (PolygonMarkerOptions*)pmPtr->ops;
- if (pmPtr->ops->worldPts &&
- (pmPtr->ops->worldPts->num >= 3) &&
+ if (ops->worldPts &&
+ (ops->worldPts->num >= 3) &&
(pmPtr->screenPts))
return Blt_RegionInPolygon(extsPtr, pmPtr->screenPts,
- pmPtr->ops->worldPts->num, enclosed);
+ ops->worldPts->num, enclosed);
return FALSE;
}
@@ -155,9 +157,10 @@ static void DrawPolygonProc(Marker *markerPtr, Drawable drawable)
{
Graph* graphPtr = markerPtr->obj.graphPtr;
PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
+ PolygonMarkerOptions* ops = (PolygonMarkerOptions*)pmPtr->ops;
/* Draw polygon fill region */
- if ((pmPtr->nFillPts > 0) && (pmPtr->ops->fill)) {
+ if ((pmPtr->nFillPts > 0) && (ops->fill)) {
XPoint* points = (XPoint*)malloc(pmPtr->nFillPts * sizeof(XPoint));
if (!points)
return;
@@ -176,8 +179,8 @@ static void DrawPolygonProc(Marker *markerPtr, Drawable drawable)
free(points);
}
/* and then the outline */
- if ((pmPtr->nOutlinePts > 0) && (pmPtr->ops->lineWidth > 0) &&
- (pmPtr->ops->outline)) {
+ if ((pmPtr->nOutlinePts > 0) && (ops->lineWidth > 0) &&
+ (ops->outline)) {
Blt_Draw2DSegments(graphPtr->display, drawable, pmPtr->outlineGC,
pmPtr->outlinePts, pmPtr->nOutlinePts);
}
@@ -187,8 +190,9 @@ static void PolygonToPostscriptProc(Marker *markerPtr, Blt_Ps ps)
{
Graph* graphPtr = markerPtr->obj.graphPtr;
PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
+ PolygonMarkerOptions* ops = (PolygonMarkerOptions*)pmPtr->ops;
- if (pmPtr->ops->fill) {
+ if (ops->fill) {
/*
* Options: fg bg
@@ -202,40 +206,40 @@ static void PolygonToPostscriptProc(Marker *markerPtr, Blt_Ps ps)
/* If the background fill color was specified, draw the polygon in a
* solid fashion with that color. */
- if (pmPtr->ops->fillBg) {
+ if (ops->fillBg) {
/* Draw the solid background as the background layer of the opaque
* stipple */
- Blt_Ps_XSetBackground(ps, pmPtr->ops->fillBg);
+ Blt_Ps_XSetBackground(ps, ops->fillBg);
/* Retain the path. We'll need it for the foreground layer. */
Blt_Ps_Append(ps, "gsave fill grestore\n");
}
- Blt_Ps_XSetForeground(ps, pmPtr->ops->fill);
- if (pmPtr->ops->stipple != None) {
+ Blt_Ps_XSetForeground(ps, ops->fill);
+ if (ops->stipple != None) {
/* Draw the stipple in the foreground color. */
- Blt_Ps_XSetStipple(ps, graphPtr->display, pmPtr->ops->stipple);
+ Blt_Ps_XSetStipple(ps, graphPtr->display, ops->stipple);
} else {
Blt_Ps_Append(ps, "fill\n");
}
}
/* Draw the outline in the foreground color. */
- if ((pmPtr->ops->lineWidth > 0) && (pmPtr->ops->outline)) {
+ if ((ops->lineWidth > 0) && (ops->outline)) {
/* Set up the line attributes. */
- Blt_Ps_XSetLineAttributes(ps, pmPtr->ops->outline,
- pmPtr->ops->lineWidth,
- &pmPtr->ops->dashes,
- pmPtr->ops->capStyle,
- pmPtr->ops->joinStyle);
+ Blt_Ps_XSetLineAttributes(ps, ops->outline,
+ ops->lineWidth,
+ &ops->dashes,
+ ops->capStyle,
+ ops->joinStyle);
/*
* Define on-the-fly a PostScript macro "DashesProc" that will be
* executed for each call to the Polygon drawing routine. If the line
* isn't dashed, simply make this an empty definition.
*/
- if ((pmPtr->ops->outlineBg) && (LineIsDashed(pmPtr->ops->dashes))) {
+ if ((ops->outlineBg) && (LineIsDashed(ops->dashes))) {
Blt_Ps_Append(ps, "/DashesProc {\ngsave\n ");
- Blt_Ps_XSetBackground(ps, pmPtr->ops->outlineBg);
+ Blt_Ps_XSetBackground(ps, ops->outlineBg);
Blt_Ps_Append(ps, " ");
Blt_Ps_XSetDashes(ps, (Blt_Dashes *)NULL);
Blt_Ps_Append(ps, "stroke\n grestore\n} def\n");
@@ -250,6 +254,8 @@ static int ConfigurePolygonProc(Marker *markerPtr)
{
Graph* graphPtr = markerPtr->obj.graphPtr;
PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
+ PolygonMarkerOptions* ops = (PolygonMarkerOptions*)pmPtr->ops;
+
GC newGC;
XGCValues gcValues;
unsigned long gcMask;
@@ -257,25 +263,25 @@ static int ConfigurePolygonProc(Marker *markerPtr)
drawable = Tk_WindowId(graphPtr->tkwin);
gcMask = (GCLineWidth | GCLineStyle);
- if (pmPtr->ops->outline) {
+ if (ops->outline) {
gcMask |= GCForeground;
- gcValues.foreground = pmPtr->ops->outline->pixel;
+ gcValues.foreground = ops->outline->pixel;
}
- if (pmPtr->ops->outlineBg) {
+ if (ops->outlineBg) {
gcMask |= GCBackground;
- gcValues.background = pmPtr->ops->outlineBg->pixel;
+ gcValues.background = ops->outlineBg->pixel;
}
gcMask |= (GCCapStyle | GCJoinStyle);
- gcValues.cap_style = pmPtr->ops->capStyle;
- gcValues.join_style = pmPtr->ops->joinStyle;
+ gcValues.cap_style = ops->capStyle;
+ gcValues.join_style = ops->joinStyle;
gcValues.line_style = LineSolid;
gcValues.dash_offset = 0;
- gcValues.line_width = LineWidth(pmPtr->ops->lineWidth);
- if (LineIsDashed(pmPtr->ops->dashes)) {
- gcValues.line_style = (pmPtr->ops->outlineBg == NULL)
+ gcValues.line_width = LineWidth(ops->lineWidth);
+ if (LineIsDashed(ops->dashes)) {
+ gcValues.line_style = (ops->outlineBg == NULL)
? LineOnOffDash : LineDoubleDash;
}
- if (pmPtr->ops->xorr) {
+ if (ops->xorr) {
unsigned long pixel;
gcValues.function = GXxor;
@@ -290,8 +296,8 @@ static int ConfigurePolygonProc(Marker *markerPtr)
}
}
newGC = Blt_GetPrivateGC(graphPtr->tkwin, gcMask, &gcValues);
- if (LineIsDashed(pmPtr->ops->dashes)) {
- Blt_SetDashes(graphPtr->display, newGC, &pmPtr->ops->dashes);
+ if (LineIsDashed(ops->dashes)) {
+ Blt_SetDashes(graphPtr->display, newGC, &ops->dashes);
}
if (pmPtr->outlineGC) {
Blt_FreePrivateGC(graphPtr->display, pmPtr->outlineGC);
@@ -299,17 +305,17 @@ static int ConfigurePolygonProc(Marker *markerPtr)
pmPtr->outlineGC = newGC;
gcMask = 0;
- if (pmPtr->ops->fill) {
+ if (ops->fill) {
gcMask |= GCForeground;
- gcValues.foreground = pmPtr->ops->fill->pixel;
+ gcValues.foreground = ops->fill->pixel;
}
- if (pmPtr->ops->fillBg) {
+ if (ops->fillBg) {
gcMask |= GCBackground;
- gcValues.background = pmPtr->ops->fillBg->pixel;
+ gcValues.background = ops->fillBg->pixel;
}
- if (pmPtr->ops->stipple != None) {
- gcValues.stipple = pmPtr->ops->stipple;
- gcValues.fill_style = (pmPtr->ops->fillBg)
+ if (ops->stipple != None) {
+ gcValues.stipple = ops->stipple;
+ gcValues.fill_style = (ops->fillBg)
? FillOpaqueStippled : FillStippled;
gcMask |= (GCStipple | GCFillStyle);
}
@@ -319,7 +325,7 @@ static int ConfigurePolygonProc(Marker *markerPtr)
}
pmPtr->fillGC = newGC;
- if ((gcMask == 0) && !(graphPtr->flags & RESET_AXES) && (pmPtr->ops->xorr)) {
+ if ((gcMask == 0) && !(graphPtr->flags & RESET_AXES) && (ops->xorr)) {
if (drawable != None) {
MapPolygonProc(markerPtr);
DrawPolygonProc(markerPtr, drawable);
@@ -332,8 +338,9 @@ static int ConfigurePolygonProc(Marker *markerPtr)
static void FreePolygonProc(Marker *markerPtr)
{
- PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
Graph* graphPtr = markerPtr->obj.graphPtr;
+ PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
+ PolygonMarkerOptions* ops = (PolygonMarkerOptions*)pmPtr->ops;
if (pmPtr->fillGC)
Tk_FreeGC(graphPtr->display, pmPtr->fillGC);
@@ -350,14 +357,15 @@ static void FreePolygonProc(Marker *markerPtr)
if (pmPtr->screenPts)
free(pmPtr->screenPts);
- if (pmPtr->ops)
- free(pmPtr->ops);
+ if (ops)
+ free(ops);
}
static void MapPolygonProc(Marker *markerPtr)
{
Graph* graphPtr = markerPtr->obj.graphPtr;
PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
+ PolygonMarkerOptions* ops = (PolygonMarkerOptions*)pmPtr->ops;
if (pmPtr->outlinePts) {
free(pmPtr->outlinePts);
@@ -373,24 +381,24 @@ static void MapPolygonProc(Marker *markerPtr)
free(pmPtr->screenPts);
pmPtr->screenPts = NULL;
}
- if (!pmPtr->ops->worldPts || pmPtr->ops->worldPts->num < 3)
+ if (!ops->worldPts || ops->worldPts->num < 3)
return;
/*
* Allocate and fill a temporary array to hold the screen coordinates of
* the polygon.
*/
- int nScreenPts = pmPtr->ops->worldPts->num + 1;
+ int nScreenPts = ops->worldPts->num + 1;
Point2d* screenPts = (Point2d*)malloc((nScreenPts + 1) * sizeof(Point2d));
{
Point2d *sp, *dp, *send;
dp = screenPts;
- for (sp = pmPtr->ops->worldPts->points, send = sp + pmPtr->ops->worldPts->num;
+ for (sp = ops->worldPts->points, send = sp + ops->worldPts->num;
sp < send; sp++) {
- *dp = Blt_MapPoint(sp, &pmPtr->ops->axes);
- dp->x += pmPtr->ops->xOffset;
- dp->y += pmPtr->ops->yOffset;
+ *dp = Blt_MapPoint(sp, &ops->axes);
+ dp->x += ops->xOffset;
+ dp->y += ops->yOffset;
dp++;
}
*dp = screenPts[0];
@@ -398,10 +406,10 @@ static void MapPolygonProc(Marker *markerPtr)
Region2d extents;
Blt_GraphExtents(graphPtr, &extents);
pmPtr->clipped = TRUE;
- if (pmPtr->ops->fill) {
+ if (ops->fill) {
Point2d* fillPts = (Point2d*)malloc(sizeof(Point2d) * nScreenPts * 3);
int n =
- Blt_PolyRectClip(&extents, screenPts, pmPtr->ops->worldPts->num,fillPts);
+ Blt_PolyRectClip(&extents, screenPts, ops->worldPts->num,fillPts);
if (n < 3)
free(fillPts);
else {
@@ -410,7 +418,7 @@ static void MapPolygonProc(Marker *markerPtr)
pmPtr->clipped = FALSE;
}
}
- if ((pmPtr->ops->outline) && (pmPtr->ops->lineWidth > 0)) {
+ if ((ops->outline) && (ops->lineWidth > 0)) {
Segment2d *segPtr;
Point2d *sp, *send;
diff --git a/src/bltGrMarkerPolygon.h b/src/bltGrMarkerPolygon.h
index a70c14b..330c729 100644
--- a/src/bltGrMarkerPolygon.h
+++ b/src/bltGrMarkerPolygon.h
@@ -55,20 +55,8 @@ typedef struct {
int xorr;
} PolygonMarkerOptions;
-class PolygonMarker {
+class PolygonMarker : public Marker {
public:
- GraphObj obj;
- MarkerClass *classPtr;
- Tk_OptionTable optionTable;
- Tcl_HashEntry *hashPtr;
- Blt_ChainLink link;
- int clipped;
- unsigned int flags;
-
- void* ops;
-
- // Fields specific to polygon
-
Point2d *screenPts;
GC outlineGC;
GC fillGC;
diff --git a/src/bltGrMarkerText.C b/src/bltGrMarkerText.C
index c26042d..207221c 100644
--- a/src/bltGrMarkerText.C
+++ b/src/bltGrMarkerText.C
@@ -108,8 +108,9 @@ Marker* Blt_CreateTextProc(Graph* graphPtr)
TextMarker* tmPtr = (TextMarker*)calloc(1, sizeof(TextMarker));
tmPtr->classPtr = &textMarkerClass;
tmPtr->ops = (TextMarkerOptions*)calloc(1, sizeof(TextMarkerOptions));
+ TextMarkerOptions* ops = (TextMarkerOptions*)tmPtr->ops;
- Blt_Ts_InitStyle(tmPtr->ops->style);
+ Blt_Ts_InitStyle(ops->style);
tmPtr->optionTable = Tk_CreateOptionTable(graphPtr->interp, optionSpecs);
return (Marker*)tmPtr;
@@ -119,18 +120,18 @@ static int ConfigureTextProc(Marker* markerPtr)
{
Graph* graphPtr = markerPtr->obj.graphPtr;
TextMarker* tmPtr = (TextMarker*)markerPtr;
+ TextMarkerOptions* ops = (TextMarkerOptions*)tmPtr->ops;
- tmPtr->ops->style.angle = (float)fmod(tmPtr->ops->style.angle, 360.0);
- if (tmPtr->ops->style.angle < 0.0f) {
- tmPtr->ops->style.angle += 360.0f;
- }
+ ops->style.angle = (float)fmod(ops->style.angle, 360.0);
+ if (ops->style.angle < 0.0f)
+ ops->style.angle += 360.0f;
GC newGC = NULL;
XGCValues gcValues;
unsigned long gcMask;
- if (tmPtr->ops->fillColor) {
+ if (ops->fillColor) {
gcMask = GCForeground;
- gcValues.foreground = tmPtr->ops->fillColor->pixel;
+ gcValues.foreground = ops->fillColor->pixel;
newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues);
}
if (tmPtr->fillGC)
@@ -144,21 +145,22 @@ static void MapTextProc(Marker* markerPtr)
{
Graph* graphPtr = markerPtr->obj.graphPtr;
TextMarker* tmPtr = (TextMarker*)markerPtr;
+ TextMarkerOptions* ops = (TextMarkerOptions*)tmPtr->ops;
- if (!tmPtr->ops->string)
+ if (!ops->string)
return;
- if (!tmPtr->ops->worldPts || (tmPtr->ops->worldPts->num < 1))
+ if (!ops->worldPts || (ops->worldPts->num < 1))
return;
tmPtr->width =0;
tmPtr->height =0;
unsigned int w, h;
- Blt_Ts_GetExtents(&tmPtr->ops->style, tmPtr->ops->string, &w, &h);
+ Blt_Ts_GetExtents(&ops->style, ops->string, &w, &h);
double rw, rh;
- Blt_GetBoundingBox(w, h, tmPtr->ops->style.angle, &rw, &rh, tmPtr->outline);
+ Blt_GetBoundingBox(w, h, ops->style.angle, &rw, &rh, tmPtr->outline);
tmPtr->width = ROUND(rw);
tmPtr->height = ROUND(rh);
for (int ii=0; ii<4; ii++) {
@@ -169,11 +171,11 @@ static void MapTextProc(Marker* markerPtr)
tmPtr->outline[4].y = tmPtr->outline[0].y;
Point2d anchorPt =
- Blt_MapPoint(tmPtr->ops->worldPts->points, &tmPtr->ops->axes);
+ Blt_MapPoint(ops->worldPts->points, &ops->axes);
anchorPt = Blt_AnchorPoint(anchorPt.x, anchorPt.y, tmPtr->width,
- tmPtr->height, tmPtr->ops->anchor);
- anchorPt.x += tmPtr->ops->xOffset;
- anchorPt.y += tmPtr->ops->yOffset;
+ tmPtr->height, ops->anchor);
+ anchorPt.x += ops->xOffset;
+ anchorPt.y += ops->yOffset;
Region2d extents;
extents.left = anchorPt.x;
@@ -187,11 +189,12 @@ static void MapTextProc(Marker* markerPtr)
static int PointInTextProc(Marker* markerPtr, Point2d *samplePtr)
{
TextMarker* tmPtr = (TextMarker*)markerPtr;
+ TextMarkerOptions* ops = (TextMarkerOptions*)tmPtr->ops;
- if (!tmPtr->ops->string)
+ if (!ops->string)
return 0;
- if (tmPtr->ops->style.angle != 0.0f) {
+ if (ops->style.angle != 0.0f) {
Point2d points[5];
// Figure out the bounding polygon (isolateral) for the text and see
@@ -212,8 +215,9 @@ static int PointInTextProc(Marker* markerPtr, Point2d *samplePtr)
static int RegionInTextProc(Marker* markerPtr, Region2d *extsPtr, int enclosed)
{
TextMarker* tmPtr = (TextMarker*)markerPtr;
+ TextMarkerOptions* ops = (TextMarkerOptions*)tmPtr->ops;
- if (tmPtr->ops->style.angle != 0.0f) {
+ if (ops->style.angle != 0.0f) {
// Generate the bounding polygon (isolateral) for the bitmap and see
// if the point is inside of it.
Point2d points[5];
@@ -238,10 +242,11 @@ static int RegionInTextProc(Marker* markerPtr, Region2d *extsPtr, int enclosed)
static void DrawTextProc(Marker* markerPtr, Drawable drawable)
{
- TextMarker* tmPtr = (TextMarker*)markerPtr;
Graph* graphPtr = markerPtr->obj.graphPtr;
+ TextMarker* tmPtr = (TextMarker*)markerPtr;
+ TextMarkerOptions* ops = (TextMarkerOptions*)tmPtr->ops;
- if (!tmPtr->ops->string)
+ if (!ops->string)
return;
if (tmPtr->fillGC) {
@@ -257,16 +262,17 @@ static void DrawTextProc(Marker* markerPtr, Drawable drawable)
}
// be sure to update style->gc, things might have changed
- tmPtr->ops->style.flags |= UPDATE_GC;
- Blt_Ts_DrawText(graphPtr->tkwin, drawable, tmPtr->ops->string, -1,
- &tmPtr->ops->style, tmPtr->anchorPt.x, tmPtr->anchorPt.y);
+ ops->style.flags |= UPDATE_GC;
+ Blt_Ts_DrawText(graphPtr->tkwin, drawable, ops->string, -1,
+ &ops->style, tmPtr->anchorPt.x, tmPtr->anchorPt.y);
}
static void TextToPostscriptProc(Marker* markerPtr, Blt_Ps ps)
{
TextMarker* tmPtr = (TextMarker*)markerPtr;
+ TextMarkerOptions* ops = (TextMarkerOptions*)tmPtr->ops;
- if (!tmPtr->ops->string)
+ if (!ops->string)
return;
if (tmPtr->fillGC) {
@@ -277,22 +283,23 @@ static void TextToPostscriptProc(Marker* markerPtr, Blt_Ps ps)
points[ii].x = tmPtr->outline[ii].x + tmPtr->anchorPt.x;
points[ii].y = tmPtr->outline[ii].y + tmPtr->anchorPt.y;
}
- Blt_Ps_XSetBackground(ps, tmPtr->ops->fillColor);
+ Blt_Ps_XSetBackground(ps, ops->fillColor);
Blt_Ps_XFillPolygon(ps, points, 4);
}
- Blt_Ps_DrawText(ps, tmPtr->ops->string, &tmPtr->ops->style,
+ Blt_Ps_DrawText(ps, ops->string, &ops->style,
tmPtr->anchorPt.x, tmPtr->anchorPt.y);
}
static void FreeTextProc(Marker* markerPtr)
{
- TextMarker* tmPtr = (TextMarker*)markerPtr;
Graph* graphPtr = markerPtr->obj.graphPtr;
+ TextMarker* tmPtr = (TextMarker*)markerPtr;
+ TextMarkerOptions* ops = (TextMarkerOptions*)tmPtr->ops;
- Blt_Ts_FreeStyle(graphPtr->display, &tmPtr->ops->style);
+ Blt_Ts_FreeStyle(graphPtr->display, &ops->style);
- if (tmPtr->ops)
- free(tmPtr->ops);
+ if (ops)
+ free(ops);
}
diff --git a/src/bltGrMarkerText.h b/src/bltGrMarkerText.h
index 7414521..a022f5b 100644
--- a/src/bltGrMarkerText.h
+++ b/src/bltGrMarkerText.h
@@ -49,20 +49,8 @@ typedef struct {
const char* string;
} TextMarkerOptions;
-class TextMarker {
+class TextMarker : public Marker {
public:
- GraphObj obj;
- MarkerClass *classPtr;
- Tk_OptionTable optionTable;
- Tcl_HashEntry *hashPtr;
- Blt_ChainLink link;
- int clipped;
- unsigned int flags;
-
- void* ops;
-
- // Fields specific to text
-
Point2d anchorPt;
int width;
int height;