Menu

Code clean up

I have cleaned up the code a lot after the implementation of a canvas that support some short of world transformation. Now instead of each object asking the owner to translate the coordinates before painting and then feeding them to the canvas methods the owner sets offset and scaling transformation data to the canvas and the objects continue working in their own little world of coordinates as if nothing has changed.

TevsGraphCanvas is based on the TControlCanvas and is replacing the default controlCanvas of SimpleGraph during creation, you should not inherit from it unless you are writing a descendant of simplegraph and you want different functionality than the one already provided.

In order to help create custom canvases that are aware of this transformation variables a new class has been introduced as well, TEvsCustomCanvas is based on the TCanvas instead of the TControlCanvas that TEvsGraphCanvas uses. That's because I wanted to be able to change the canvas used at run time.

If you are thinking of creating a custom canvas you are advised to use the TEvsCustomCanvas as the parent class and set the CustomCanvas property of TEvsSimpleGraph. This will force simplegraph to create a canvas during painting, pass all the transformation data and the handle of the control's canvas and use it to draw everything. If you take a look at the code of TEvsCustomCanvas you will see that a number of DoXXXXXX procedures have been introduced, that's because the public procedures have been modified to translate the coordinates and then they call those protected methods. This way I can override the protected ones and redirect the drawing to any library I want with out giving a second thought on the world transformation that might be needed.

Everything has been checked in at GIT no new files yet I might publish one at the weekend.

Enjoy.

Posted by Taazz 2013-07-18

Log in to post a comment.