0

I have to build a graph digitizer to make the user have a graph by points from an image. This could be an example of an imported graph Text

What I'd like is that the user graphically defines, at first, the X axis domain (in the picture from 0 to 2000) and the Y axis domain (in the picture from 0 to 180) and then picks some points on the curve and, once this procedure has ended, I need to have the points added to a Datagridview that I've already done. Could anyone suggest me where to start?


Edit: I've set the way to store the mouse position, when the mouse button is pressed:

Private Sub PictureBox1_MouseClick(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseClick
    If PictureBox1.Image IsNot Nothing Then
        Form3.ListBox1.Items.Add(e.X)
    End If
End Sub

I need to activate this sub when I press a specified button. Until I press the button, the mouse position, even if clicking inside the picturebox, must not be stored. If tried to put the picturebox sub inside the Button_click sub but It doesn't work.

Another event that I have to program is that - when pressing the mouse button inside the picturebox - on the first click, Form4 must be shown; at the second click, Form5 must be shown; at the third click, Form6 must be shown. From the fourth click (until the user has ended to pick points), the mouse position must be stored.

  • ummm...Excel? :) – Jeremy Dec 11 '20 at 12:48
  • @Jeremy Thanks for commenting. Could you explain me how do I have to use Excel? I don't need Excel for this purpose, since when the points are picked and added to datagridview, the graph will be plotted and I did an Excel exporting command yet – telemaco10399 Dec 11 '20 at 12:55
  • Explain to me (not an English speaker): Do you mean that you show image to user, user clicks to some point on image and you need to add clicked coordinates to datagridview? How does user define axis domains visually - you have some non-graph areas too? (All this tends to go out of SO scope - helping with specific errors and/or code problems.) – Arvo Dec 11 '20 at 13:58
  • @Arvo thanks for commenting. At first, the user must pick on the picture three points: the origin of the XY reference system, the X upper bound and the Y upper bound. Obviously when the user clicks the mouse button, the software asks to type the coordinates of these points. After these three points have been defined, then the user picks other points on the picture and the "local coordinates" of these points are stored in order to build the diagram by points. – telemaco10399 Dec 11 '20 at 14:13
  • And what is your question then? You can handle mouse click events, you can get mouse cooridnates in click event, you know, in which mode user interaction is (selecting area or clicking points), you can easily convert click cooridnates to graph values - what else you need? – Arvo Dec 11 '20 at 14:39
  • @Arvo I've edited my answer – telemaco10399 Dec 11 '20 at 14:43
  • 1
    You need to implement simple state machine (NB! this is my opinion only!) and store your intermediate data or open forms only in specific states/events. Simple state machine may consist of one big `select case active_state` statement and many small `select case current_event` statements inside it (which do things and change states), big one is run from user events (click, button press etc) :) – Arvo Dec 11 '20 at 15:02
  • @Arvo thanks for your suggestion. Could you provide me any examples of this command? I've never used it before. – telemaco10399 Dec 11 '20 at 15:09
  • What command - `select case`? Look at official docs: https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/select-case-statement – Arvo Dec 11 '20 at 15:12
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/225831/discussion-between-telemaco10399-and-arvo). – telemaco10399 Dec 11 '20 at 15:14

0 Answers0