Jump to content

Making a moving line/trace graph

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
13 replies to this topic

#1
robhol

robhol

    Newbie

  • Members
  • PipPip
  • 14 posts
So, I need a way to make a dynamically moving trace graph and have no idea how/where to start. I've been searching the net for quite some time, as well as experimenting on my own with pictureboxes, but, unfortunately, found absolutely nothing of any use.

Can anybody give me an example/control, please?

(Oh, and.. hi ;))

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Can you explain a bit more? My first thought would be to render a graph, pause for a bit, then render the next one, but it really depends a lot on what you are trying to accomplish.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
robhol

robhol

    Newbie

  • Members
  • PipPip
  • 14 posts
Here's your side dish of in-depth information. ;)

I'm trying to make an ECG simulator (you know, heart monitor thingie)
So, what I'd ideally want to do is have a line graph with a "sweep" that moves "ahead" of the current drawing point, erasing the previous portion of the trace, then drawing the new data once the sweep has passed.

Something like this:
robhol.net/etc/SR.gif
(Dumb forum won't let me post links or pics... -.-')

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
All you really need to do is draw a black point and a horizontal white line a certain distance ahead of it. Have the x-coordinate of the white line be calculated with a modulus (%) so that it wraps properly.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Any sort of graphics you need to draw onto forms can be accomplished in .NET with the System.Drawing namespace. Here, the DrawLine() and perhaps DrawRectangle() may come in handy. Check the documentation (or the IntelliSense) to see its parameters.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#6
robhol

robhol

    Newbie

  • Members
  • PipPip
  • 14 posts
I've tried that and can't get it working. The different bugs that happen are too many to mention or, for that matter, remember.

Any chance someone could whip together a quick example for me?

#7
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Start by posting your code. It may be something simple.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#8
robhol

robhol

    Newbie

  • Members
  • PipPip
  • 14 posts
I haven't got any, at the moment. After the first 500000000000 tries or so I realized I might have missed something basic, which is why I'm asking for an example or some very detailed instructions now. ;P

#9
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Perhaps the issue you were having was that refreshing the form (for example, obscuring it with another window and then viewing it again) wil cause the custom drawings to be lost. To avoid this, save the lines to a bitmap object, and then draw the bitmap to the form every time the form isredrawn (with the form's Paint function).
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#10
robhol

robhol

    Newbie

  • Members
  • PipPip
  • 14 posts
Bitmaps don't natively support drawing lines, or for that matter, anything else except one-at-a-time pixel editing, and I'm not sure how to do it.

#11
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
You can't do anything with a direct bitmap. You have to create a Graphics object and then link it to the Bitmap.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#12
robhol

robhol

    Newbie

  • Members
  • PipPip
  • 14 posts
Yeah yeah... thing is, I don't know jack: can anybody please make me an example?