News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

graph procs

Started by allynm, December 28, 2009, 02:01:20 AM

Previous topic - Next topic

allynm

Hello everyone,

I have searched MASM forum topics but not able to find anything that is immediately useful to my problem.

I am trying slowly, slowly to build an application in Windows (of course, using MASM32) in which the user can select different queuing models and get results.  As part of this application, I would like to be able to plot certain continuous distributions, such as, for example, the exponential (among others, to be specified by the user). 

At least conceptually, there would be a dialog box and the user would specify a distribution with parameters like mean and st deveiation, etc. and then get a plot back representing visually what the user had specified.  It is the plot proc I'm looking for.

Frankly, writing the assembly code is daunting for a rank amatuer like me and at this point I would like to defer to those experts who have been here before me.  Has anyone got plotting procs written in MASM that I could call?

Thanks very much,

Mark Allyn

Farabi

If you are asking about 2D graphics you could search about GDI (Not GDI+ I hearsay it was slow).
Or as an alternative, you could use donkey graphics library.
And for 3D you could use OpenGL.

Thats all I know.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

jj2007

Mark,
Don't be scared of graphics. What you want to do is fairly simple: Calculate an x and y value from a given function, taking into account the available drawing space, set a pixel, repeat until you are ready. I attach a simple example - run and click "PushMe". The core proc is this one:

MyProc proc
LOCAL hDC, px, py
invoke ShowWindow, hEdit, SW_HIDE ; hide the edit control
invoke GetDC, hMainWnd ; use handle to main window
mov hDC, eax
mov px, 3
mov py, 3
.Repeat
invoke SetPixel, hDC, px, py, 0
add px, 2
inc py
.Until py>80
.Repeat
invoke SetPixel, hDC, px, py, 0
sub px, 2
inc py
.Until py>200
invoke ReleaseDC, hDC, hMainWnd
ret
MyProc endp


And don't worry about speed - the human eye is utterly slow compared to a Windows API call :bg

dedndave

that's a pretty cool little app Jochen
it even has an icon   :bg

allynm

Hi JJ -

Hmmm....Dave is certainly right that it is a pretty cool proc.  Even I can follow the code!

Yes, what I want to do is pretty simple.  Way back in the 60's/70's IBM had a Fortran program in its
Scientific Subroutine package called Plot (I think that was what it was called)...it made little x's and had x axis and
y axis (with labels!).  That's the sort of thing I'm looking for.  I think you basically have done this, but without the label capability.
I guess with a couple of 'static' child windows one could stick labels on the axes.

One point of clarification would help me:  when you say "...taking account of the available drawing space", I am not sure what you mean and how to implement this.

Thanks very much for your help and for the proc.

Mark

jj2007

Quote from: allynm on December 28, 2009, 01:20:07 PM

Hi Mark,
> I guess with a couple of 'static' child windows one could stick labels on the axes.
You draw directly on the client area of your main window. No need for statics.

> One point of clarification would help me:  when you say "...taking account of the available drawing space", I am not sure what you mean and how to implement this.
The "drawing space" is the client area of your main window. You need some rescaling formula to translate your points into screen points. I would suggest to introduce xOffset, yOffset, xScale and yScale. Here are some bits, not tested - you will need another proc for the PixX=... formula.

MyProc proc
LOCAL hDC, px, py
LOCAL rc:RECT
.data
xOffset dd 20 ; some space for the labels
yOffset dd 20
xMax dd 12345 ; whatever...
yMax dd 54321
xScale dd 0 ; or REAL8 1.0
yScale dd 0 ; or REAL8 1.0
.code
invoke GetClientRect, hMainWnd, addr rc
mov eax, rc.right ; width
sub eax, xOffset ; margin
cdq ; sign extend
div xMax ; rescaling: PixX=Margin+xScale*SourceX -> xScale=(MaxPixX-Margin)/MaxSourceX
mov xScale, eax ; could be done with a float, too

mov eax, rc.bottom ; height
sub eax, yOffset ; margin
cdq ; sign extend
div yMax ; rescaling: PixY=Margin+yScale*SourceY -> yScale=(MaxPixY-Margin)/MaxSourceY
mov yScale, eax ; could be done with a float, too

WryBugz

Thanks for that app Jochen. I wasn't aware of the 'AppendMenu' api. Gives me some ideas on dynamic menus. I usually run test beds from a script engine design. So I can pretty up my test prog now.
(Once I finish a half dozen other things).