[comp.windows.interviews] World Coordinates in InterViews

steinarb@idt.unit.no (Steinar Bang) (06/24/91)

I am currently working on an application in InterViews 2.6 (I only
have g++, so IV-3.0 is out, unfortunately).

In this application I whish to specify coordinates in "World
Coordinates" for objects (a graph or plot actually) from the Graphic
structured graphics library. 

Unfortunately, this is impossible, because the constructors of, say,
MultiLine will only take Coords as arguments. In IV2.6 or IV3.0 when
compiling with 2.6 compatiblity, Coords are ints, so even though you
can specify the transformations from the "World Coordinates" to your
canvas, you can't specify the object in World Coordinates.

This is because the drawing operations of Painter takes only Coords
as arguments, even though it uses floats to carry out transformation
calculation. Looking at the Painter code, it wouldn't have taken much
code to create painter operations with float coordinates, you would
have needed a float to Coord Map function, and you would have needed
overloaded drawing functions.

I thought about deriving a class from Painter, and add the needed float
MultiLine drawing function. But again unfortunately, this wouldn't
help me much, because the drawing functions and Painter handling is
buried very deep inside the Graphic base class ("private:"
declarations without "protected:" access methods.... Grrr! :-) 

This leaves me with two possibilities using the libgraphic.a classes:
   i) - Derive a class from MultiLine, with float coordinates of the
        line and a float defined "World" bounding box.
      - In the constructor, do the transformation from World coords
        into a MultiLine in integer coordinates.
      This would give me a graphic representation of my real world
      object, that will behave as expected. Unfortunately, the
      quantization will show up clearly during zooming or resizing the
      object.
  ii) - Derive a class from MultiLine, with the curve in float real
        world coordinates, and a float real world bounding box.
      - Create a transformation matrix that transformes the my object
        from the real world coordinates, to the coordinates of the
        Picture I am inserting it in.
      - Add a Map operation similar to the one found in the Painter
        class, but here mapping from real world to canvas.
      - Redefine the draw(Canvas*,Graphic* gs) operation to:
        - Copy gs to another graphic, nil the other graphics
          transformer, and call update() with this
        - Run the Map operation from the float array to a Coord array.
        - Call pMultiLine using the Coord array.
      But:
       1. This may be too slow
       2. It may not work

A third possibility is installing Unidraw into the IV2.6 source tree,
and compiling it. I don't know if this would help me any, I have
barely looked at Unidraw.

I am thankful for any hints and/or comments.

- Steinar