|
From: Phil S. <p.s...@gn...> - 2005-03-15 01:38:37
|
Hi. I have joined Extgraph list as busy hacking SimpleGraph for my own application. Added jointed links and also a host of new node types for my application. However, I have got to an issue that might be of general interest. Simplegraph has relatively involved painting method. It paints to a bitmap which is then bitlblt to the canvas. This has a few downsides, particularly in that as you zoom in, instead of seeing more text, text is simply enlarged, lines are thickened etc. I want to zoom so that can see more text and keep lines at same weight. I also looked at less involved way of painting but see that it is done because zoom method includes arbitary rounding. This can be avoided but developer perhaps didn't spot it. I tried with setworldTransform or setviewport setwindowextext calls but hit the rounding issue as the code is structured at the moment. Proper scaling on zoom requires transforming the graph coords by x' = x*scale + scaledoffset. To avoid problem with rounding, think the actual calculation is x' = muldiv(x,M,D) + offset, where M is max(clientHeight, clientwidth) and D is M*100/Zoom percent The easier way to introduce this scaling would be a derivative of TCanvas say TScaleableCanvas with overriddern draw methods to scale the x,y coordinates before calling inherited draw methods. Sadly this approach is no go. MoveTo, LineTo etc etc are static methods in TCanvas. You can replace with static MoveTo, LineTo, but then the drawing calls have to reference TScaleCanvas to the replaced method. Once you do this, you cant pass TMetafileCanvas or Printer.Canvas to the draw methods. Unless someone has a better idea, I think the only way to achieve what I want is explicit scaling of coordinates in the drawing calls. This would a big impact on ExtGraph, perhaps rather more than you would want. ---------------------------------------------------------- Phil Scadden, Institute of Geological and Nuclear Sciences 764 Cumberland St, Private Bag 1930, Dunedin, New Zealand Ph +64 3 4799663, fax +64 3 477 5232 |