Excluding from undo stack
-
Hello All,
I have been working on adapting Sketchup to Virtual Reality displays. Since regular windows and toolbars are not visible in virtual environments, I create custom floating 3D menus (pie menus) that the user can interact with to select tools, components etc. The menus are just faces and groups with textures applied on them that show up in a particular way (Please see attached image). Since these are regular geometries, their creation also ends up becoming part of the undo stack. As a result, when I continue to undo, the menu components get erased.
Start_operation allows you to make an operation transparent, but it still is part of the stack. Is there a way to eliminate or exclude a set of operations from the undo stack? That would be of great help.
Thanks,
Arun
-
Arun,
Interesting idea!
If you are within a tool, you can control Undo events since you receive the onCancel event.
If not, you can trap the event with Model Observers (in particular onTransactionUndo).
In your case, I guess the best is to
- be notified of the event
- if your 'pseudo' buttons have disappeared, just recreate them (this should be very fast). You can also create the wheel as a component which definition is kept in the model (and on file) and just reloaded to create an instance.
Fredo
-
Thanks Fredo. I will try that.
Pardon my ignorance, but could you please explain what you mean by trapping? I'm able to attach a modelobserver and receive a call during transactionUndo. I assume you mean some way of prematurely exiting so the Undo would not happen, but since this is just an observer and not a subclass, I'm not sure how that could be done. Any explanation would be of great help.
Thanks again for your help
Arun -
@arunyoganandan said:
Thanks Fredo. I will try that.
Pardon my ignorance, but could you please explain what you mean by trapping? I'm able to attach a modelobserver and receive a call during transactionUndo. I assume you mean some way of prematurely exiting so the Undo would not happen, but since this is just an observer and not a subclass, I'm not sure how that could be done. Any explanation would be of great help.
Thanks again for your help
ArunI would need to know more on what you do in Ruby.
Simply, with a Sketchup Tool, you can prevent the Undo to happen, or let it go and then rebuild your button Wheel.Fredo
-
No way to omit operations form the undo stack. The API wasn't designed for geometry to act as UI elements.
Only way to remove an operation would be to abort it. If you start an operation before you display your geometry and then abort it before they trigger their command it should be gone from the undo stack. But it's prone to being interfered with by other operation thee user might trigger or other extensions that have observers active.
-
Arun,
Menus are transient elements so it doesn't make sense to use a persistent SU representation. And you'll start rubbing up against stuff like Undo because its kinda abusing the intended use.
You should be simply generating draw commands as needed.
-
Hi Everyone,
Thanks for your replies and suggestions. Yes, I do agree that I'm twisting the application in a manner that the architecture does not intend to support. I just wanted to see if there were ways to get around the issue I am facing. I will try aborting operations to see if that does what I need.
Thanks again!
Arun -
If this system is entirely under your control, it would be easy to include all the geometry in the template model. Then when the user opens a new model, all those components are there without any possibility of being undone.
Advertisement