|
Try to write a subject that has anything to do with your question. A request for help is totally useless for distinguishing your thread from others, as almost every thread here is a request for help.
What you are asking for is impossibe. If you want to send a message in plain text format, you can't add any formatting to the text.
---
Year happy = new Year(2007);
|
|
|
|
|
thnx to your help
Ahmed El-Badry
|
|
|
|
|
I have been trying to adjust the X and Y axes on my graph so I can have a noticeable distinction between data point values.
The problem is my Y coordinate values range from 0.20 to 0.45, which displays almost a perfectly straight line across my graph.
Is there a way that I can set the Y axis to +1/-1 and the X axis to 0/+1025? Also is there a better way to center the data in the middle of the graph in order to better view the fluctuations?
Here is the portion of my code that prints the data to a panel on a form:
Dim xOne, yOne, xTwo, yTwo As Object
Dim penColor As New Pen(Color.Red, 0.01)
xTwo = 0
yTwo = 75 'center line in middle of graph
For I = 1 To 1024
xOne = I
yOne = Y - Voltage(I) + 75
WavGraph.CreateGraphics.DrawLine(penColor, xTwo, yTwo, xOne, yOne)
xTwo = xOne
yTwo = yOne
Next I
|
|
|
|
|
KojoAmuel wrote: s there a way that I can set the Y axis to +1/-1 and the X axis to 0/+1025? Also is there a better way to center the data in the middle of the graph in order to better view the fluctuations?
Yes, of course. But
KojoAmuel wrote: my Y coordinate values range from 0.20 to 0.45
and what about Voltage(I) range?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
The Voltage(I) is an array of 5000
Code:
Public Voltage(5000) As Single
|
|
|
|
|
KojoAmuel wrote: The Voltage(I) is an array of 5000
Sorry for the misunderstanding... but I need the min and max value of Voltage , because you wrote only about Y range, but in your code I see both Y and Voltage(I) (I don't know if you meant 0.20 < (Y - Voltage(I)) < 0.45 )
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
The Y values are:
MinValue -3.4028
MaxValue +3.4028
By running debug mode and viewing a watch function i found that Voltage is:
MinValue = -.0099
MaxValue = 0.21
I did mean to say 0.20 < (Y-Voltage(I)) < 0.45; I randomly grabbed those numbers after running a few tests. What is happening is I am converting a vb6 program to VB.Net, and I am not positive about the Voltage max/min value.
|
|
|
|
|
KojoAmuel wrote: I did mean to say 0.20 < (Y-Voltage(I)) < 0.45
OK, so you can do:
For I = 1 To 1024
xOne = I
yOne = (Y - Voltage(I)-0.20) * 150/(0.45-0.20) + 75
WavGraph.CreateGraphics.DrawLine(penColor, xTwo, yTwo, xOne, yOne)
xTwo = xOne
yTwo = yOne
Next I
supposing you have a 150 pixel height area, such code will use all of it.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
It worked, Thank you for all the help.
As another side note to other readers I had modified the DrawLine(....) properties to Integers to keep from having an unhandled exception. (exception was from having Single, and Integer mixed together)
WavGraph.CreateGraphics.DrawLine(penColor, CInt(xTwo), CInt(yTwo), CInt(xOne), CInt(yOne))
|
|
|
|
|
I'm really sorry, but I need to know how to be able to draw free hand on a picture box at runtime. I've looked around and tried bits of code but I can't get it to work. It only needs to be in one colour and the width of the pen is not really an issue. Please get back to me when you can.
Thanks for your time.
-- modified at 8:37 Wednesday 31st January, 2007
Thanks Chris, but I need example or source code to help as I am fairly new to this. As an exercise I need to allow the user to draw free handedly on to a picture box.
|
|
|
|
|
1- Create a form and Add a picturebox named PictureBox1
2- Add these codes to your form
------------
Private m_MouseIsDown As Boolean
Private m_Points() As Point
Dim m_path As New Drawing2D.GraphicsPath
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
m_Points = New Point() {New Point(e.X, e.Y)}
m_MouseIsDown = True
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If m_MouseIsDown Then
ReDim Preserve m_Points(m_Points.Length)
m_Points(m_Points.Length - 1) = New Point(e.X, e.Y)
Me.PictureBox1.Invalidate()
End If
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
m_path.StartFigure()
m_path.AddCurve(m_Points)
m_MouseIsDown = False
Me.PictureBox1.Invalidate()
End Sub
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
If m_Points IsNot Nothing Then
Using p As New System.Drawing.Pen(Color.Blue, 2)
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias
e.Graphics.DrawPath(p, m_path)
e.Graphics.DrawCurve(p, m_Points)
End Using
End If
End Sub
------------
3- Run your project
now by downing mouse left key and moving mouse, your freehand drawing is painting.
|
|
|
|
|
wrote: As an exercise I need to allow the user to draw free handedly on to a picture box.
If you just want to draw a single line, then the sample you have been given will work. However, drawing on a picturebox is a waste of time, you can take this sample and remove the picture box, it will still work on a form the same way. To draw on a picture box, you need to draw on a bitmap, and show it in the picture box. The picture box is, in every case, totally superfluous and useless. It just adds a needless layer to what you are doing.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi,
I need the user to draw line in panel control placed in form. For that I have defined mousedown, mouseup and mousemove events. But it draws the line continously, I need it to be as like drawing line in paint brush.
Dim oldX, oldY As Integer
Dim m_Down As Boolean
Private Sub Panel1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown
oldX = e.X
oldY = e.Y
m_Down = True
End Sub
Private Sub Panel1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove
If m_Down = True Then
Dim p As Point
Dim g As Graphics
Dim pn As Pen
p = New Point(e.X, e.Y)
g = Graphics.FromHwnd(Panel1.Handle)
pn = New Pen(Color.Red, 1)
g.DrawLine(pn, oldX, oldY, e.X, e.Y)
pn.Dispose()
g.Dispose()
End If
End Sub
Private Sub Panel1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseUp
m_Down = False
End Sub
Any help?
Be simple and Be sample.
|
|
|
|
|
Do you mean you want a straight line? Not freehand?
|
|
|
|
|
Keep it one thread, instead of starting a new thread for every post you make.
---
Year happy = new Year(2007);
|
|
|
|
|
When you move the mouse, you need to reset oldX and oldY, so your next line starts at the end of your previous one, not where you were when you first clicked the mouse.
What Guffa said, don't flood the forums, stick to a thread.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I need to draw a straigt line not the freehand drawing.
Rams.
Be simple and Be sample.
|
|
|
|
|
You want the user to click and drag the mouse to create a line right? The problem your having is that you never remove the old line. Basically every time the mouse moves you draw a new line and the old lines remain. Try adding the following change.
Private Sub Panel1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove
If m_Down = True Then
Dim p As Point
Dim g As Graphics
Dim pn As Pen
p = New Point(e.X, e.Y)
g = Graphics.FromHwnd(Panel1.Handle)
pn = New Pen(Color.Red, 1)
<code>g.Clear(Panel1.BackColor)</code>
g.DrawLine(pn, oldX, oldY, e.X, e.Y)
pn.Dispose()
g.Dispose()
End If
End Sub I should point out that as I've just recently learned your line will only stay until the control is redrawn. Your line is really only temporary. In addition the way it's done right now will only allow a single line. Every time you try to draw a new line the panel will be cleared. If you want a permanent line/lines you'll have to adjust your code. Either create the actual image on an image object and set the panels backgroundimage to that or you'll have to remember each drawn line and redraw them in the paint event.
|
|
|
|
|
I am trying to acuire data from a bluetooth serial port, do a little processing, and plot a continuous graph. The code which I have written works perfectly at low speeds but breaks down when receiving data at around 70 data lines a second faster than this and the "real time" nature is lost taking increasing lengths of time for the data to appear on screen. I am really enquireing whether this is a limitation in VB and/or the .NET framework and if it is not can anyone suggest a stratergy that could help. For information there are approximatly 80 lines of code to be executed for every incoming data line.
Thanks
James
|
|
|
|
|
Hi James,
I doubt that the limitation you are encountering can be found in any programming language. Generally speaking, 80 lines of code is next to nothing, where processing time is concerned. However if you run it on a machine with a Xeon processor, ofcourse it will be executed much faster than on a machine with a 386. What I mean to say, is that it is near impossible to predict whether your app will encounter this problem on every possible hardware configuration, or whether it specifically will not encounter it on a certain configuration.
Otherwise, you could look into buffering the data lines. After all if you are creating a graph, it is obviously meant for a user to look at. If the graph plots at say 140 points (point per data line) per second, its going to be a blur for the user anyway.
You could on the other hand have your graph plot at real time speed, up until that 70 data lines / sec limit, then level off, and have it take its subsequent data from the buffer. If you like, you could just inform the user that the actual speed is in excess of x.
I hope this helps you,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hi,
I would like my users to draw line on form. How could I make my users to draw line in the form.
Any luck?
Thanks in advance,
Rams.
Be simple and Be sample.
|
|
|
|
|
See my answer below. To do that, you need to makange mouse events and control the drawing of a bitmap that you will draw the lines to.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
How to include .Net framework while building setup projects in VB.Net?
Manas
|
|
|
|
|
This should help
http://msdn2.microsoft.com/en-us/library/ms994427.aspx
|
|
|
|
|
|