[comp.windows.interviews] Problems programming a small graph-editor

fraus@forwiss.uni-passau.de (Uli Fraus) (06/20/91)

Hello all InterViews 2.6 experts,

I am trying to programm to program a small IV application for drawing simple
graphs (nodes & edges). This application should come up with an empty
GraphicBlock plus some Buttons and a Panner. I used the graphics demo as an
example. So I have Tray with the GraphicBlock (containing an empty Graphic)
and a VBox (containing Buttons and Panner). This seem ok to me.

But I have to two nasty problems:
 - First my window is coming up at minimal size (0x0) if the Graphic is empty.
   (I found no possibility to use a predefined Canvas! like SetCanvas() ??? )

 - Second: If I click inside the GraphicBlock to set a new node, the node
   appears about 2 inch left and up of the click-point. BUT if I click on a
   node for moving (function from graphics) it work quite well. So I think
   I have a problem with relative and absolute coordinates.

If you have any solutions or hints for these problems please tell me.
Thanks
				Uli Fraus.

-- 
Ulrich Fraus, FORWISS Passau, University of Passau, Germany        ||====
 E-Mail: fraus@forwiss.uni-passau.de      ||    ||  ||     ()	   ||__
 Phone : +49 851/509-496                  ||    ||  ||     ||      ||
 Fax   : +49 851/509-497                   \\==//   ||===  ||	   || o

haiying@menaik.scapa (Haiying Wang) (06/23/91)

In article <1991Jun19.172322.27647@forwiss.uni-passau.de> fraus@forwiss.uni-passau.de (Uli Fraus) writes:

...
   But I have to two nasty problems:

    - Second: If I click inside the GraphicBlock to set a new node, the node
      appears about 2 inch left and up of the click-point. BUT if I click on a
      node for moving (function from graphics) it work quite well. So I think
      I have a problem with relative and absolute coordinates.


I had this problem before. 
A picture object's state is concatenated with the state of its
components when it is drawn. That is when the picture is draw each
component's transformer is postmultiplied by the picture's
transformer. When you pick a point from a picture object, its
coordinates has been transfomed the picture's transformer. If you use
this coordinates as a reference point to create another graphical
object and append this graphical object to the picture, this graphical
object will be transformed by the picture transformer again when the
picture is drawn. This is the reason that the new component is in the
wrong place. I have used two methods to avoid this problem:
a) Before you append the new graphical object to the picture, call
Picture::Propagate() method. This method concatenates each component's
state with the picture's own state (modifying each component's transformer
by postmultiplying the picture's transformer). The picture's
transformer is set to nil;
b) Before you use the coordinate of the picked point, get the
picture's transformer (GetTransformer) and undo the transform on the
coordinate (Transformer::InvTransform()).

I perfer the second one which keeps the picture's transformer.

Haiying Wang
University of Alberta
haiying@cs.ualberta.ca