DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Terminate command

Started by Dr PR, March 16, 2010, 10:03:33 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dr PR

I would like to see a key function to terminate any command in progress immediately. Right now the ESCape key is supposed to stop screen redraw, but it doesn't.

If you are trying to find the intersection of two surfaces (Draw/Lines/Surface Intersection) and accidentally click on two points of a large grid the program will try to find the intersection of every grid facet with every other facet of the same grid (this is in itself a bug - it shouldn't try to find the intersection of a surface with itself). When this happens the program may be locked up for 10 to 15 minutes, even on a fast computer.

Rendering of large drawings can take forever and cannot be stopped.

Once again, CTRL-ALT-DEL is the only option, and all recent drawing changes are lost.

For the Terminate function to work commands must periodically look at keyboard input. The best way to do this would be a periodic interrupt about every second. The Terminate function may leave incomplete drawing elements, so it should be followed by an undo to the state immediately prior to the command that was terminated.
DesignCAD user since 1987

Dempsey

One can dream can't you.

If they are unable to program the proper functioning of the ESC key then what makes you think that they can do it right when another key is hit?
Dempsey

Rob S

We have already got the proper functioning of the esc key as a long outstanding bug.

It is currently the second highest rated bug in our "most important to fix" list, so hopefully, next round we'll see something done there.

I agree, lets not give it a new name, they may take advantage of the "divide and conquer" strategy.
User since forever

paulerens

I would be happy with the opportunity to return to the situation before the last operation. (Command or macro).

Dr PR

I agree that proper functioning of the ESCape key is on the list, but other than stopping redraw is it supposed to do anything else?

The ESCape key is the proper key to use to terminate commands. It is not a normal typing character and is typically out of the way in the upper left corner of the keyboard. However, I do not think it is currently supposed to terminate all commands.

So, if the programmers do try to make the ESCape key function to stop drawing, maybe they can also implement the broader "terminate anything" function.

I do realize what this is asking the programmers to do, and in Windows it may be impossible.
DesignCAD user since 1987

edgar

Quote from: Dr PR on March 18, 2010, 09:12:24 AM
So, if the programmers do try to make the ESCape key function to stop drawing, maybe they can also implement the broader "terminate anything" function.

I do realize what this is asking the programmers to do, and in Windows it may be impossible.

Not impossible but yields a nasty side effect. To "notice" the keypress of a key a program must scan through all (typically lots) of the waiting events which have piled up since last clearing them. This is a function with a lot of overhead (potentially a LOT of overhead--especially if an event MUST be acted upon).

The "normal" implementation is to scan the events until one is found to act upon (or maybe scan them all and make a separate list of those which are of interest); then the event triggers a sequence of events which in DCad might end up in (f.i.) subtracting one solid from another. There are many computational steps to complete in this subtraction process. If we want to be able to interupt this sequence we must choose interupt points throughout and insert scans for events. This can a lot of processor overhead depending upon the granularity we want! The speed of the program could come to a crawl but judicious use of event scans can be done  especially now that we have multi-gH CPUs.
-Ed

Lar

Maybe there should be a timer running and after a certain length of time it would pop up asking if you want to kill the command execution. Dcad seems to know when something is taking more than a certain amount of time because, for example, the meter bar doesn't pop up when an import or a save-as-2d takes a small amount of time.

Lar

Dr PR

edgar,

Thanks. By "events" I assume you mean not just keyboard presses but all other program generated requests/answers to/from the operating system. So in order to determine if the ESCape key is pressed a program must look through everything that is happening. That could be a lot of overhead!

Of course what is really needed is a hardware interrupt produced by the ESCape key that would catch the operating system's attention. The OS should allow programs to request immediate notification of this unique event so when it happens the OS would interrupt the program immediately without the program having to watch for anything. At least that is the way any decent operating system would work.

The PC keyboard doesn't generate unique hardware interrupts. However, the OS keyboard handler could generate a software interrupt for a requesting program. I seem to recall that there was some way to do this with Windows, but it may have been with Windows CS. However, I wasn't implementing it. One of the other fellows at work who does flail with Windows programming was trying to figure it out.
DesignCAD user since 1987

edgar

Quote from: Dr PR on March 19, 2010, 11:50:24 PM
By "events" I assume you mean not just keyboard presses ... That could be a lot of overhead!

Yes.

Quote from: Dr PR on March 19, 2010, 11:50:24 PM
OS keyboard handler could generate a software interrupt for a requesting program. I seem to recall that there was some way to do this with Windows

I am no Windows programming Guru. I expect you can do something like what you mention but it may not be common practice. For one thing, programmers are often encouraged to process all the backed up events because of a few considerations (one of which is that the event list storage is rather limited and as new events come in the oldest events can be discarded by the OS).

Quote from: Lar on March 19, 2010, 03:03:37 PM
Maybe there should be a timer running

This would be even more overhead as the program would still have to poll constantly for timer events (just like watching for keypress events) and you would have the added overhead of building and running the timer; then the code and resources needed to pop up the "Do you want to abort?" requester.

Watching for the ESCape key would probably be OK on very fast machines with lots of RAM.
-Ed

Rob S

If esc can't be made to work, surely CTRL+Break creates a special interrupt that can be tested for without significant overhead???
User since forever

Dempsey

This is where multiple threads come in. A Windows application has a single main thread. While that thread is busy executing a 15-minute chore, there are no messages/events (like keystrokes) being processed by that thread.

Before the 15-minute chore is started the program should spawn off another thread, and have it do the heavy work. While it is doing this heavy work, it needs to check to see if it has been told to stop. That is typically a Boolean flag that when true the thread continues, but when false it terminates itself. Only a thread can terminate itself. The main thread would simply watch for some key stroke, such as "VK_ESC". When that key stroke is encountered, it adjusts the Boolean in the spawned thread. That spawned thread will then eventually see the flag change and terminate.

This is a good programming technique to interrupt a long running task. I don't know in what language DesignCAD is coded, but with (Visual) C++ this should be a piece of cake.
Dempsey