summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoye <joye>2014-06-16 17:21:59 (GMT)
committerjoye <joye>2014-06-16 17:21:59 (GMT)
commit92531dc3020f4dfdca47d47085105840af77cfa3 (patch)
tree025ebdc91d109714695f9292bafe1c11a37fc360
parent4a8a61cafdadefd581f7c8815f8d196da00e5752 (diff)
downloadblt-92531dc3020f4dfdca47d47085105840af77cfa3.zip
blt-92531dc3020f4dfdca47d47085105840af77cfa3.tar.gz
blt-92531dc3020f4dfdca47d47085105840af77cfa3.tar.bz2
*** empty log message ***
-rw-r--r--src/bltGrPSOutput.C180
-rw-r--r--src/bltGrPSOutput.h1
-rw-r--r--src/bltGrText.C15
3 files changed, 24 insertions, 172 deletions
diff --git a/src/bltGrPSOutput.C b/src/bltGrPSOutput.C
index 68cd2ab..729560f 100644
--- a/src/bltGrPSOutput.C
+++ b/src/bltGrPSOutput.C
@@ -577,12 +577,6 @@ void PostScript::byteToHex(unsigned char byte, char* string)
string[1] = hexDigits[byte & 0x0F];
}
-void PostScript::printText(const char* string, double x, double y)
-{
- if (!string || !(*string))
- return;
-}
-
void PostScript::prolog()
{
append(
@@ -621,9 +615,7 @@ void PostScript::prolog()
"200 dict begin\n"
"\n"
"/BaseRatio 1.3467736870885982 def % Ratio triangle base / symbol size\n"
-"/BgColorProc 0 def % Background color routine (symbols)\n"
"/DrawSymbolProc 0 def % Routine to draw symbol outline/fill\n"
-"/StippleProc 0 def % Stipple routine (bar segments)\n"
"/DashesProc 0 def % Dashes routine (line segments)\n"
"\n"
"% Define the array ISOLatin1Encoding (which specifies how characters are \n"
@@ -723,89 +715,6 @@ void PostScript::prolog()
" closepath\n"
"} def\n"
"\n"
-"% The next two definitions are taken from '$tk_library/prolog.ps'\n"
-"\n"
-"% desiredSize EvenPixels closestSize\n"
-"%\n"
-"% The procedure below is used for stippling. Given the optimal size\n"
-"% of a dot in a stipple pattern in the current user coordinate system,\n"
-"% compute the closest size that is an exact multiple of the device's\n"
-"% pixel size. This allows stipple patterns to be displayed without\n"
-"% aliasing effects.\n"
-"\n"
-"/EvenPixels {\n"
-" % Compute exact number of device pixels per stipple dot.\n"
-" dup 0 matrix currentmatrix dtransform\n"
-" dup mul exch dup mul add sqrt\n"
-"\n"
-" % Round to an integer, make sure the number is at least 1, and compute\n"
-" % user coord distance corresponding to this.\n"
-" dup round dup 1 lt {pop 1} if\n"
-" exch div mul\n"
-"} bind def\n"
-"\n"
-"% width height string filled StippleFill --\n"
-"%\n"
-"% Given a path and other graphics information already set up, this\n"
-"% procedure will fill the current path in a stippled fashion. 'String'\n"
-"% contains a proper image description of the stipple pattern and\n"
-"% 'width' and 'height' give its dimensions. If 'filled' is true then\n"
-"% it means that the area to be stippled is gotten by filling the\n"
-"% current path (e.g. the interior of a polygon); if it's false, the\n"
-"% area is gotten by stroking the current path (e.g. a wide line).\n"
-"% Each stipple dot is assumed to be about one unit across in the\n"
-"% current user coordinate system.\n"
-"\n"
-"% width height string StippleFill --\n"
-"%\n"
-"% Given a path already set up and a clipping region generated from\n"
-"% it, this procedure will fill the clipping region with a stipple\n"
-"% pattern. 'String' contains a proper image description of the\n"
-"% stipple pattern and 'width' and 'height' give its dimensions. Each\n"
-"% stipple dot is assumed to be about one unit across in the current\n"
-"% user coordinate system. This procedure trashes the graphics state.\n"
-"\n"
-"/StippleFill {\n"
-" % The following code is needed to work around a NeWSprint bug.\n"
-"\n"
-" /tmpstip 1 index def\n"
-"\n"
-" % Change the scaling so that one user unit in user coordinates\n"
-" % corresponds to the size of one stipple dot.\n"
-" 1 EvenPixels dup scale\n"
-"\n"
-" % Compute the bounding box occupied by the path (which is now\n"
-" % the clipping region), and round the lower coordinates down\n"
-" % to the nearest starting point for the stipple pattern. Be\n"
-" % careful about negative numbers, since the rounding works\n"
-" % differently on them.\n"
-"\n"
-" pathbbox\n"
-" 4 2 roll\n"
-" 5 index div dup 0 lt {1 sub} if cvi 5 index mul 4 1 roll\n"
-" 6 index div dup 0 lt {1 sub} if cvi 6 index mul 3 2 roll\n"
-"\n"
-" % Stack now: width height string y1 y2 x1 x2\n"
-" % Below is a doubly-nested for loop to iterate across this area\n"
-" % in units of the stipple pattern size, going up columns then\n"
-" % across rows, blasting out a stipple-pattern-sized rectangle at\n"
-" % each position\n"
-"\n"
-" 6 index exch {\n"
-" 2 index 5 index 3 index {\n"
-" % Stack now: width height string y1 y2 x y\n"
-"\n"
-" gsave\n"
-" 1 index exch translate\n"
-" 5 index 5 index true matrix tmpstip imagemask\n"
-" grestore\n"
-" } for\n"
-" pop\n"
-" } for\n"
-" pop pop pop pop pop\n"
-"} bind def\n"
-"\n"
-"\n"
"/LS { % Stack: x1 y1 x2 y2\n"
" newpath \n"
" 4 2 roll moveto \n"
@@ -814,14 +723,6 @@ void PostScript::prolog()
" stroke\n"
"} def\n"
"\n"
-"/baseline 0 def\n"
-"/height 0 def\n"
-"/justify 0 def\n"
-"/lineLength 0 def\n"
-"/spacing 0 def\n"
-"/strings 0 def\n"
-"/xoffset 0 def\n"
-"/yoffset 0 def\n"
"/baselineSampler ( TXygqPZ) def\n"
"% Put an extra-tall character in; done this way to avoid encoding trouble\n"
"baselineSampler 0 196 put\n"
@@ -852,40 +753,34 @@ void PostScript::prolog()
" /justify exch def\n"
" /yoffset exch def\n"
" /xoffset exch def\n"
-" /spacing exch def\n"
" /strings exch def\n"
-" % First scan through all of the text to find the widest line.\n"
-" /lineLength 0 def\n"
-" strings {\n"
-" cstringwidth pop\n"
-" dup lineLength gt {/lineLength exch def} {pop} ifelse\n"
-" newpath\n"
-" } forall\n"
" % Compute the baseline offset and the actual font height.\n"
" 0 0 moveto baselineSampler false charpath\n"
" pathbbox dup /baseline exch def\n"
" exch pop exch sub /height exch def pop\n"
" newpath\n"
-" % Translate and rotate coordinates first so that the origin is at\n"
-" % the upper-left corner of the text's bounding box. Remember that\n"
-" % angle for rotating, and x and y for positioning are still on the\n"
-" % stack.\n"
+" % overall width\n"
+" /ww 0 def\n"
+" strings {\n"
+" cstringwidth pop\n"
+" dup ww gt {/ww exch def} {pop} ifelse\n"
+" newpath\n"
+" } forall\n"
+" % overall height\n"
+" /hh 0 def\n"
+" strings length height mul /hh exch def\n"
+" newpath\n"
+" % Translate to x,y\n"
" translate\n"
-"%% rotate\n"
-" lineLength xoffset mul\n"
-" strings length 1 sub spacing mul height add yoffset mul translate\n"
-" % center, rotate, -center\n"
-" lineLength 2 div baseline 2 div translate\n"
+" % Translate to offset\n"
+" ww xoffset mul hh yoffset mul translate\n"
+" % rotate\n"
+" ww 2 div hh 2 div translate\n"
" neg rotate\n"
-" lineLength -2 div baseline -2 div translate\n"
-" % Now use the baseline and justification information to translate\n"
-" % so that the origin is at the baseline and positioning point for\n"
-" % the first line of text.\n"
-" justify lineLength mul baseline translate\n"
-"%% justify lineLength mul baseline neg translate\n"
-" % Iterate over each of the lines to output it. For each line,\n"
-" % compute its width again so it can be properly justified, then\n"
-" % display it.\n"
+" ww -2 div hh -2 div translate\n"
+" % Translate to justify and baseline\n"
+" justify ww mul baseline translate\n"
+" % For each line, justify and display\n"
" strings {\n"
" dup cstringwidth pop\n"
" justify neg mul 0 moveto\n"
@@ -893,44 +788,11 @@ void PostScript::prolog()
" 1 -1 scale\n"
" cstringshow\n"
" grestore\n"
-" 0 spacing translate\n"
-"%% 0 spacing neg translate\n"
+" 0 height translate\n"
" } forall\n"
" grestore\n"
"} bind def \n"
"\n"
-"/DrawBitmap {\n"
-" % Stack: ?bgColorProc? boolean centerX centerY width height theta imageStr\n"
-" gsave\n"
-" 6 -2 roll translate % Translate to center of bounding box\n"
-" 4 1 roll neg rotate % Rotate by theta\n"
-" \n"
-" % Find upperleft corner of bounding box\n"
-" \n"
-" 2 copy -.5 mul exch -.5 mul exch translate\n"
-" 2 copy scale % Make pixel unit scale\n"
-" newpath\n"
-" 0 0 moveto \n"
-" 0 1 lineto \n"
-" 1 1 lineto \n"
-" 1 0 lineto\n"
-" closepath\n"
-" \n"
-" % Fill rectangle with background color\n"
-" \n"
-" 4 -1 roll { \n"
-" gsave \n"
-" 4 -1 roll exec fill \n"
-" grestore \n"
-" } if\n"
-" \n"
-" % Paint the image string into the unit rectangle\n"
-" \n"
-" 2 copy true 3 -1 roll 0 0 5 -1 roll 0 0 6 array astore 5 -1 roll\n"
-" imagemask\n"
-" grestore\n"
-"} def\n"
-"\n"
"% Symbols:\n"
"\n"
"% Skinny-cross\n"
diff --git a/src/bltGrPSOutput.h b/src/bltGrPSOutput.h
index b963d5d..0845fe7 100644
--- a/src/bltGrPSOutput.h
+++ b/src/bltGrPSOutput.h
@@ -63,7 +63,6 @@ class PostScript {
void printRectangle(int, int, int, int);
void printPolygon(Point2d*, int);
void print3DRectangle(Tk_3DBorder, double, double, int, int, int, int);
- void printText(const char*, double, double);
void fillRectangle(double, double, int, int);
void fillRectangles(XRectangle*, int);
diff --git a/src/bltGrText.C b/src/bltGrText.C
index e80e7ca..315b59f 100644
--- a/src/bltGrText.C
+++ b/src/bltGrText.C
@@ -141,12 +141,6 @@ void TextStyle::printText(PostScript* psPtr, const char *text, int x, int y)
Tk_TextLayout layout = Tk_ComputeTextLayout(ops->font, text, -1, -1,
ops->justify, 0, &w1, &h1);
- Tk_FontMetrics fm;
- Tk_GetFontMetrics(ops->font, &fm);
-
- psPtr->setFont(ops->font);
- psPtr->setForeground(ops->color);
-
int xx =0;
int yy =0;
switch (ops->anchor) {
@@ -168,18 +162,15 @@ void TextStyle::printText(PostScript* psPtr, const char *text, int x, int y)
case TK_JUSTIFY_RIGHT: justify = "1"; break;
}
- // cerr << text << ' ' << ops->angle << ' ' << '(' << x << ',' << y << ')'
- // << ' ' << '(' << xx << ',' << yy << ')' << ' ' << justify << endl;
+ psPtr->setFont(ops->font);
+ psPtr->setForeground(ops->color);
psPtr->format("%g %d %d [\n", ops->angle, x, y);
Tcl_ResetResult(graphPtr_->interp_);
Tk_TextLayoutToPostscript(graphPtr_->interp_, layout);
psPtr->append(Tcl_GetStringResult(graphPtr_->interp_));
Tcl_ResetResult(graphPtr_->interp_);
- psPtr->format("] %d %g %g %s DrawText\n",
- fm.linespace, xx/-2.0, yy/-2.0, justify);
-
- // psPtr->printText(text, x, y);
+ psPtr->format("] %g %g %s DrawText\n", xx/-2.0, yy/-2.0, justify);
}
void TextStyle::resetStyle()