Recent

Author Topic: Idle thought - about Syntax Charts  (Read 895 times)

tfurnivall

  • Jr. Member
  • **
  • Posts: 85
Idle thought - about Syntax Charts
« on: July 29, 2025, 05:11:45 pm »
One of the most enjoyable parts about learning Pascal, back in the 70s, was the use of syntax charts, rather than BNF. I have, however, been unable to find any widget that provides this capability (specifically, the ability to round off a vertex by inserting an arc of radius r of a circle located at some point (x,y)).

So, my question and idle thought takes two parts:

1) Is anyone aware of a tool that does this already (ie I can select such a widget, and set the radius of the circle, then draw the series of line segments, and have the vertices rounded off cleanly)? And if so, where can I find it?

2) If I do decide to create such a tool myself, how do I post progress and questions without taking up valuable space from those who have weightier issues to discuss? I suspect this will be a niche interest, but I know that my graphical programming experiences is approximately (nay, exactly) zero, and I know I will be looking for all sorts of assistance and coaching.

As a first take on how this tool would be used, after selecting the tool (and setting the appropriate radius), the first click of the mouse would specify the anchor point, and each subsequent click would add a new segment to the line. A double-click would terminate the process, and cause all the intervening vertices to be adjusted to a rounded position.
In terms of saving the final structure we would need a count of the line segments, and for each vertex, the radius of the circle used to smooth out the vertex. For most vertices, of course, this radius would be the same.

The process of creating the segmented line is started by the first click, and terminated by the double-click. I would imagine that a useful case would be if the shift-key were held down, thus constraining the angles at the vertices to being right-angles.
The movement of the mouse from one vertex to the next would be accompanied by the skinny line which I generally take to mean "this is where I am, right now", which line would, of course, disappear once the newly defined vertex is completed.

Some questions - with no basis for any answers as of yet:

1) Should I complete the rounding for each vertex as soon as possible (ie when I have defined the two lines that enclose the vertex), or shouldI wait until the whole set of line segments is defined, and then iterate over the set of vertices? This would save time and reduce the code path by eliminating too much calculation during event handling. OTOH, it would be a major visual wrench to see these sharp points suddenly assume an unaccustomed shapeliness due to curves being added!

2)  If I have the skinny line showing "where I am, right now", how come the palette doesn't become full with skinny lines? I had never thought about this, but it's as if the line has to be calculated each time a MouseMove event is detected - and then destroyed to make way or the next mouse move. (Lots of research necessary on this!)

I hope this makes sense, and that some kind soul can point me in the ways in which I should travel!

Tony

tfurnivall

  • Jr. Member
  • **
  • Posts: 85
Re: Idle thought - about Syntax Charts
« Reply #1 on: July 31, 2025, 06:49:53 pm »
So I've started my little Lab Project. At the moment I have a (more-or-less) functional model that can draw the line segments (uploaded as Graphics Workbench, along with a Word doc - Using Graphics Workbench to create syntax charts).

I have run into the problem that I anticipated - which is that if I try to get a thin line drawn on each Mouse Move event, it fills up the screen with a line back to the starting point, from every point that the mouse encounters. Not what I wanted. I've seen the behavior I want in Word, when inserting a line. The cursor becomes a cross, and as it moves, it drags a line behind it. The line does not expand to fill up the screen - it seems to clear and re-create itself every time the MouseMove event is fired.

Things I don't know
1) How often does the MouseMove fire? It must be often enough to give the impression of smooth movement, but I have no idea how often this is. Can some one give me either the frequency with which it fires, or point me in the right direction?

2) How much time can I spend on clearing the Canvas each time the  MouseMove event fires? It seems to me that saving the canvas as I accumulate each little line segment (ie the lines I really want) and then copying it back into the Image where I am drawing is as easy a way to clear out all the accumulated crud. However, since the canvas is about 1400 * 600, and (AFAIK) it's capable of drawing different colors, that's an awful lot of bits and bytes to be shunted around. Is the approach of saving the canvas as I finish a line segment and then copying it back each time I do a Mouse Move, realistic? Or is there some hidden spell that I have yet to learn? (And how do I do the restore - I can save the canvas to another canvas, but it doesn't seem to like it if I do it in the reverse order
Code: Pascal  [Select][+][-]
  1. OneOffCanvas  := imgPaint.Canvas ;
  2.  
works, but
Code: Pascal  [Select][+][-]
  1. imgPaint.Canvas := OneOffCanvas;
  2.  
throws an error "No member is provided to access property")

3) I think I have gotten a handle on the problem of constraining the cursor to move only in right angles, at least I can draw nice step patterns all over the place!

Things I want to learn
a)  How to solve my problem with MouseMove

As usual, any thoughts, suggestions are most welcome. I'm learning a lot - it just doesn't feel like it yet!

Tony

PS I suppose this is a feature request, but if we can upload a .doc file, can we (soon?) acquire the capability to upload a .docx file?

 

TinyPortal © 2005-2018