Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2005-10-05 01:45:49


Andy Little wrote:

>
> "Vladimir Prus" <ghost_at_[hidden]> wrote
>> Andy Little wrote:
>
>>> Just provide alternative unit systems. Then we can all choose the ones
>>> we want, when we want.
>>>
>>> Hows that? :-)
>>
>> template<class CoordinateUnit>
>> class Widget {};
>>
>> ?
>> Well, over my dead body ;-)
>
>
> The cleanest way to deal with units would be as a world to device
> transform which is applied to the window at runtime as has been mentioned
> before. So it would be:
>
> Transform t;
> Widget w(t);
>
> ... code dealing with coordinates needs only use floats or ints ,
>
> Now you can change the transform to whatever unit you wish. and your code
> will
> be units independent. Of course the default could be pixels so that "old
> timers" such as yourself who may be slightly frightened of units dont ever
> have to see them. ;-)

Good. In fact, that's why I meant by "2D graphics can be scaled as you
like". Specifically, take a look at:
   
   QPainter::setWindow
   http://doc.trolltech.com/4.0/qpainter.html#setWindow-2

that establish logical coordinates for drawing, and

   QPainter::setMatrix
   http://doc.trolltech.com/4.0/qpainter.html#setMatrix

that establish translate/scale transformations.

Is that what you're after?

- Volodya


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk