Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!oitnews.harvard.edu!purdue!lerc.nasa.gov!magnus.acs.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!xlink.net!ins.net!heeg.de!gustav!hmm
From: hmm@gustav (Hans-Martin Mosner)
Subject: Re: Help with PolyLine in VisualWorks 2.0 for SGI
Message-ID: <DEH35L.7KK@heeg.de>
Sender: uucp@heeg.de
Organization: Georg Heeg Objektorientierte Systeme, Dortmund, FRG
X-Newsreader: TIN [version 1.2 PL2]
References: <42en5e$a2j@mailer.york.ac.uk>
Date: Wed, 6 Sep 1995 07:22:32 GMT
Lines: 41

John 'john..' Tuffen (jat5@york.ac.uk) wrote:
: Simple problem:

: I'm plotting some graphs. The data is stored as Points in an OrderedCollection (dataPoints).
: I have a CompositeView (compa) into which I am storing the various graphic items, and the
: PolyLine is added to it as follows:

: compa add: ((GraphicsAttributesWrapper on: (Polyline vertices: dataPoints asArray) asStroker)
: 	attributes: (GraphicsAttributes new paint: ColorValue red)).


: Now, this is fine for most data, and everything plots beautifully(!).... BUT when the data
: to be plotted is:

: 	OrderedCollection (50@20 100@20 150@20 200@20 250@20 300@20 350@20 400@20 450@20 500@20)

: The line is not shown!! 

: If I edit one of the `Y' values to be anything other than 20, the line is plotted...


: Why?? Why should a PolyLine not be plotted unless it's component points have different Y values???

The problem is that the bounding box computation for Polylines returns a
degenerate rectangle when the x or y values of the points are all equal.
For the given polyline, the bounding box, which is used to decide
whether the part should be drawn at all, has a height of 0.

To work around this, you need to fix the method #boundingRectangleForPoints:
in Geometric class. Just add 1 to corner before returning the rectangle.
This prevents the method from returning an empty rectangle, which would
always answer false in intersection tests.
The fix is probably not mathematically waterproof, but the method is
mainly used in cases such as yours, where the fixed version is better.

Hans-Martin
--
+--- Hans-Martin Mosner -------- Senior Smalltalk Guru ---+
| These opinions are entirely ficticious.  Any similarity |
| to real opinions is purely coincidental and unintended. |
+--- <hmm@heeg.de> ------ URL:http://www.heeg.de/~hmm/ ---+
