Title: Brainstorming general solutions to the "undo" problem · Issue #1475 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: Brainstorming general solutions to the "undo" problem · Issue #1475 · IfcOpenShell/IfcOpenShell
X Title: Brainstorming general solutions to the "undo" problem · Issue #1475 · IfcOpenShell/IfcOpenShell
Description: I have never designed an undo system before, so I just wanted to brainstorm if there were any "general" solutions which were able to save states prior to a change actioned by the IfcOpenShell Python API, and then optionally store it in a...
Open Graph Description: I have never designed an undo system before, so I just wanted to brainstorm if there were any "general" solutions which were able to save states prior to a change actioned by the IfcOpenShell Pytho...
X Description: I have never designed an undo system before, so I just wanted to brainstorm if there were any "general" solutions which were able to save states prior to a change actioned by the IfcOpenS...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/1475
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Brainstorming general solutions to the \"undo\" problem","articleBody":"I have never designed an undo system before, so I just wanted to brainstorm if there were any \"general\" solutions which were able to save states prior to a change actioned by the IfcOpenShell Python API, and then optionally store it in an ordered list, and then restore that state if the user selects it.\r\n\r\nActions may be:\r\n\r\n 1. Editing: element.Name = 'foo'\r\n 2. Adding: ifc_file.create_entity(\"IfcFoo\")\r\n 3. Removal: ifc_file.remove(element)\r\n\r\nComplex actions (remove_deep, copy_deep, etc) are basically just the three fundamental actions just repeated.\r\n\r\nNaturally, the undo stack should store the final result of the element, such that if I do ifc_file.createIfcRootedFoo(ifcopenshell.guid.new(), ...) - the GlobalId does not change. Similarly, since STEP IDs are used to sync objects in the Blender client to the the IFC dataset, STEP IDs should be preserved.\r\n\r\nNot an urgent issue to solve, but something I probably can't ignore forever :)\r\n\r\nA naive suggestion would be that a flag can be set to start recording state changes. e.g. ifc_file.begin_transaction(). Then, the transaction consists of an ordered list. Each item in the list is either an \"edit\", an \"add\", or a \"remove\". The \"edit\" will store the element prior to the edit, the \"add\" will store the new element, and the remove will store the old element. Then, when all the operations are finished, state recording finishes e.g. undo = ifc_file.end_transaction(). This undo object can then call undo.restore() or something.\r\n\r\nIn theory this could be implemented in Python by wrapping all calls. This is however just my naive Wednesday morning idea of how undo systems work. I should probably do more research on it.\r\n\r\nThoughts?\r\n\r\nEdit: Here's a TODO list to track undo support for operations.\r\n\r\n - [x] non-module operators (e.g. import / export) @moult\r\n - [x] aggregate @moult\r\n - [x] attribute @moult\r\n - [x] augin @moult\r\n - [ ] bcf\r\n - [x] bimtester @moult\r\n - [x] boundary @moult\r\n - [x] clash @moult\r\n - [x] classification @Jesusbill \r\n - [x] cobie @moult\r\n - [x] constraint @Jesusbill \r\n - [x] context @moult\r\n - [x] cost @myoualid \r\n - [x] covetool @moult\r\n - [x] csv @Jesusbill \r\n - [x] debug @moult\r\n - [x] diff @moult\r\n - [x] document @Jesusbill \r\n - [x] drawing @moult\r\n - [x] geometry @moult\r\n - [x] georeference @moult\r\n - [x] group @moult\r\n - [x] layer @Jesusbill \r\n - [x] material @moult\r\n - [x] model @moult\r\n - [x] owner @Jesusbill\r\n - [x] patch @Jesusbill \r\n - [x] project @moult\r\n - [x] pset @moult\r\n - [x] pset_template @moult\r\n - [x] qto @moult\r\n - [x] resource @myoualid \r\n - [x] root @moult\r\n - [x] search @Jesusbill\r\n - [x] sequence @myoualid \r\n - [x] spatial @moult\r\n - [x] structural @Jesusbill \r\n - [x] style @moult\r\n - [x] type @moult\r\n - [x] unit @moult\r\n - [x] void @moult","author":{"url":"https://github.com/Moult","@type":"Person","name":"Moult"},"datePublished":"2021-05-19T03:53:47Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/1475"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d62f6172-7445-17e6-3568-567dbbe26743 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8DA0:24C069:9C5795:D56AC3:6B04834C |
| html-safe-nonce | a6e6dea8e786917e2a7bf11626e5b2d85af4b1faae4b324784798e982eabcd77 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4REEwOjI0QzA2OTo5QzU3OTU6RDU2QUMzOjZCMDQ4MzRDIiwidmlzaXRvcl9pZCI6IjM5NjQwMTcwMzM3MjkwNDk0MjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c84ae868343be21c91902cfa1bbda1b6e349a6f89d5d102c515b3c65bce4c525 |
| hovercard-subject-tag | issue:894962998 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/IfcOpenShell/IfcOpenShell/1475/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9f88f79ea45dfc803e939025a0e3f06786ffa47bc04ce7ed2fd2bd739d7ee537/IfcOpenShell/IfcOpenShell/issues/1475 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9f88f79ea45dfc803e939025a0e3f06786ffa47bc04ce7ed2fd2bd739d7ee537/IfcOpenShell/IfcOpenShell/issues/1475 |
| og:image:alt | I have never designed an undo system before, so I just wanted to brainstorm if there were any "general" solutions which were able to save states prior to a change actioned by the IfcOpenShell Pytho... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Moult |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1d5c152376e38b7d2e37f3d5179be29a73bee93b85110da28a4eebe1159cdc70 |
| turbo-cache-control | no-preview |
| go-import | github.com/IfcOpenShell/IfcOpenShell git https://github.com/IfcOpenShell/IfcOpenShell.git |
| octolytics-dimension-user_id | 13692563 |
| octolytics-dimension-user_login | IfcOpenShell |
| octolytics-dimension-repository_id | 40473201 |
| octolytics-dimension-repository_nwo | IfcOpenShell/IfcOpenShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 40473201 |
| octolytics-dimension-repository_network_root_nwo | IfcOpenShell/IfcOpenShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f5017e8ff4ea25a8011fcf0f2a0e430c60dc86c8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width