Does anyone have a simple x-y plot control written in asm?
Posted on 2003-06-25 21:02:36 by msmith
What features would you be looking for in an x-y plot control?

I was thinking of desgning one myself, but no promises.

Posted on 2003-06-27 21:56:48 by NaN

I was looking for something simple. An example of the kind of control I was looking for is GraphLite. Unfortunately, it was written in VB and carries with it the need for the huge VB runtime dll.

Most of the chart controls try to throw in everything but the kitchen sink. Simple is better.

I just want to have a simple x-y plot control.


Posted on 2003-06-28 12:35:06 by msmith
So you want a square grid where you can plot x,y points. Kind of like... oh I don't know... an image buffer. ;)
Posted on 2003-06-28 18:05:14 by iblis
This link has 2 examples of what I want. They are the 2 with black background and green pens.
Posted on 2003-06-28 18:21:47 by msmith
So step 1, before any coding is started, list the qualities is should have.

    [*]Be resizeable
    [*]Scale data in x/y (perhaps)
    [*]Have a means to indicate how much x data is viewed in the control window
    [*]Have x and maybe y scroll bars
    [*]Copy and hold x/y data
    [*]Selectable line and background colors
    [*]Perhaps a grid (and selectable color)
    [*]Couple of Draw styles (Lines and 'x's or just Lines)

    Too much, too little, anything else?
Posted on 2003-07-01 12:54:47 by NaN
Hi Nan,

Your list sounds like a good start.

Some of the things like scroll bars are more than I need, but maybe someone else would need them.

The control in the link I gave has you fill an array with all of the data to be displayed. If you want to add another data point later, you must completely reload the array.

I have added somef 'frills' to the control in the form of external code that tracks mouse movement, extrapolates x position, and displays the date, shot #, and y value of the point under the mouse in a tool tip rectangle.

The control I am using allows 15 pens. I use 1 of them. For some things, a grid might be nice.


Posted on 2003-07-01 15:22:45 by msmith
I have written a very basic x-y plot control. It doesn't have many of the features NaN listed, but I just required something very basic - I only even needed one pen, to show a trend. Anyway, I'm new to all this!

It scales data in x/y, any number of pens can be used, colours for the pens can be set when they are created. The 'paper' colour can be set at will. Data points can added and removed at will, so long as you can keep track of the index of the point.

No grid. Should be easy enough to add.
No extra draw styles, should be easy enough to add 'x's.
No x or y scrolling. I am interested in this, but am not sure how to do it, suggestions?

I'm just learning, so anything anyone finds that is wrong/could be better please say. I was a bit unsure about the freeing of resources, I think it's correct. I think that the loops can be improved upon...!

Anyway, it seems to run fine on Win98 and WinXP.
Hope it's some use to someone else!

edit: updated attachment to the latest one
Posted on 2003-08-03 14:07:53 by adamjjackson
got a GPF on startup with win2k SP4.. gonna figure out why..
Posted on 2003-08-03 15:11:40 by X05
Ah, great, good start. <sarcasm>

I've probably done something really stupid? Thanks for any help...
Posted on 2003-08-03 15:30:20 by adamjjackson
Looks good to me! Do you plan to put it into a dll?
Posted on 2003-08-03 22:43:16 by msmith
Thanks :), I'm still a bit worried about the GPF though! :eek: What OS were you using?

I hadn't planned to put it in a DLL, it hadn't even crossed my mind. If you think it's a good idea I might try it. What are the advantages of putting it in a DLL?
Posted on 2003-08-04 04:51:13 by adamjjackson
it crashes on the 1st sendmessage in wm_create example.
only have windows 2000. can only think a handle (lost?) is wrong. or something dont work on my PC
Posted on 2003-08-04 05:13:21 by X05
I tested the code on Win98 SE.

No particular advantage to the dll except it provides "off the shelf" use. Also, it's a bit of a pain to convert masm code to fasm.

I could try the code on XP, but I see you already have.
Posted on 2003-08-04 08:56:04 by msmith
It worked on my win98se.

Its a good start! Its ironic really. I had a long car ride yesterday, so i took the time to do the same with my laptop. Im not finished yet, but close. I will post what i got probably sometime this week (still trying to work out the legistics of all the various data types (signed/unsigned byte/word/dword/real4/real8/real10 )

Posted on 2003-08-04 11:34:34 by NaN
Okay thanks, I'll have a look at it again sometime, nice weather at the moment though :)

I'd guessed that NaN would make something anyway... but thought I may as well make something basic to meet my needs, and it was a good way to learn. I didn't consider data types, I didn't need to, and I haven't really come across them yet anyway. Hopefully I'll learn a bit about them soon!
Posted on 2003-08-06 12:55:38 by adamjjackson
From glancing at you asm source, it looks like the data type is a dword (32 bit integer). That is exactly what I would want.

In the VB application that I want to switch to asm, I convert all floating point to scalled integer. For my purposes, the only data type I would ever plot would be long integers.

It might be good to see what is causing the GPL on 2000.

BTW My wife and I were looking at the Isle of Man web sites. What a neat place! I was in Ayr Scotland many times in the middle '60's and came close to visiting your island, but never made it.
Posted on 2003-08-06 14:26:46 by msmith
Got the GPF too, on Win2000 SP 4.

I noticed that in xyPlot.asm, section "Do_create", memory is allocated with the line

invoke HeapAlloc,eax,NULL,SIZEOF xyData ; Allocate Private Data.

I changed that into

invoke HeapAlloc,eax,HEAP_ZERO_MEMORY,SIZEOF xyData ; Allocate Private Data.

After recompiling both the LIB and the EXE, the program worked like a charm.
Posted on 2003-08-06 15:48:10 by Frank
Im not trying to compete.. I think its a fun project as well.. Always good experience from such things ;)

Im personally thinking about following Thomas' lead and doing something simular to his x-y graphs from his Neural Network 2 example. He drew his plots on a DC that is 2 x the required size, and then when done, bitblt reduced it to the proper size. Doing so gives the lines a smooth anti-aliased look. I thought it was a neat trick, and kinda want to test it out for myself ;)

Posted on 2003-08-06 17:39:07 by NaN
But why the About box claims that this program is copyrighted by Microsoft :confused: :confused: :confused:
Posted on 2003-08-07 01:01:24 by JohnFound