1

I have a new project but I'm really not sure where to start, other than I think GNAT Ada would be good. I taught myself Ada three years ago and I have managed some static graphics with GNAT but this is different.

Please bear with me, all I need is a pointer or two towards where I might start, I'm not asking for a solution. My history is in back-end languages that are now mostly obsolete, so graphics is still a bit of a challenge.

So, the project:

With a static background image (a photograph) - and a moveable line with an adjustable cursor somewhere between the ends of the line. I need to rotate the line and adjust the length, as well as to move it around the screen and slide the cursor along the line; I have no problem calculating the positions of each element of the line. Once in place, I need to report on the position of the cursor relative to the overall length of the line. I can probably handle the reporting with what I already know but I have no clue as to how to create a graphic that I can slide around over another image. In the past I have failed to detect mouse events in GNAT Ada and I am sure I will need to get on top of that - in fact if I could, I would probably manage to control the line but doing it over an existing image is beyond me.

If I am wrong to choose GNAT Ada for this, please suggest an alternative.

I have looked in Stackoverflow for anything similar but have found answers only for Blackberry and Java, neither of which seems relevant.

For background, this will be a useful means of measuring relative lengths of the features of insect bodies from photographs, hopefully to set up some definitive identification guides for closely-related species.

  • 2
    Ada is a general purpose language and thus you can do anything with it. However, from what you describe you will need to use GtkAda or perhaps the Gnoga framework to do what you want. – Joakim Strandberg Aug 05 '21 at 11:10
  • 1
    See also [_GUI in Ada programming language_](https://stackoverflow.com/q/54171368/230513). – trashgod Aug 05 '21 at 12:54
  • 1
    Besides the library options already provided, I'd say ASFML would be a good match for this project: https://mgrojo.github.io/ASFML/ – Gneuromante Aug 06 '21 at 14:36
  • 1
    You can use an open-source OpenGL binding such as OpenGLAda http://flyx.github.io/OpenGLAda/, or GLOBE_3D https://globe3d.sourceforge.io/ . You can find on the latter site a screenshot of a bioinformatics application similar to what you intend to do. OpenGL can run within windowing systems like GtkAda or GWindows. – Zerte Aug 06 '21 at 16:12
  • 1
    Also consider [`ImageJ`](https://imagej.nih.gov/ij/), which includes [feature analysis](https://imagej.nih.gov/ij/features.html) and integrates well with command-line toolchains that include Ada. – trashgod Aug 07 '21 at 23:03

1 Answers1

2

With a static background image (a photograph)

So first you need a window to put your interface in. You can get this from any GUI framework (link as given by trashgod in the comments).

and a moveable line with an adjustable cursor somewhere between the ends of the line. I need to rotate the line and adjust the length, as well as to move it around the screen and slide the cursor along the line; I have no problem calculating the positions of each element of the line.

These are affine transformations. They are commonly employed in low-level graphics rendering. You can, like Zerte suggested, employ OpenGL – however modern OpenGL has a steep learning curve for beginners.

GtkAda includes a binding to the Cairo graphics library which supports such transformations, so you can create a window with GtkAda with a Cairo surface and then render your image & line on it. Cairo does have a learning curve and I never used the Ada binding, so I cannot really give an opinion about how complex this will be.

Another library that fully supports what you want to do is SDL which has Ada bindings here. The difference to GtkAda is that SDL is a pure graphics drawing library so you need to „draw“ any interactive controls yourself. On the other hand, setting up a window via SDL and drawing things will be somewhat simpler than doing it via GtkAda & Cairo.

SFML which has also been mentioned in comments is on the same level as SDL. I do not know it well enough to give a more informed opinion but what I said about SDL will most probably also apply to SFML.

In the past I have failed to detect mouse events in GNAT Ada and I am sure I will need to get on top of that - in fact if I could, I would probably manage to control the line but doing it over an existing image is beyond me.

HID event processing is handled by whatever GUI library you use. If you use SDL, you'll get mouse events from SDL; if you use GTK, you'll get mouse events from GTK, and so on.

flyx
  • 35,506
  • 7
  • 89
  • 126