Extend python document observer capabilities

Merged, abandoned or rejected pull requests are moved here to clear the main Pull Requests forum.
Post Reply
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Extend python document observer capabilities

Post by ickby »

Hello,

for a small python project of mine I need some comprehensive document observation capabilities. This is done via document observers, however, some key things are not yet observable. Hence I implemented some additions to the current capabilities:

- Finished recompute for objects and the whole document
- Transactions: open, commit and abort
- onBeforeChange for notifications of properties that are about to be changed
- document property changes
- Add/Remove dynamic properties to objects
- New Gui document observer, for added viewproviders and changes to viewprovider properties
- Start/Finish edit mode of viewproviders

Furthermore I added testcases for all the python document observer capabilities.

Pull request:
https://github.com/FreeCAD/FreeCAD/pull/1707

Regards,
Stefan
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Extend python document observer capabilities

Post by microelly2 »

Thank you for sharing this, I see nice new possibilities.
damian
Posts: 583
Joined: Sun May 31, 2015 6:16 pm

Re: Extend python document observer capabilities

Post by damian »

microelly2 wrote: Mon Oct 08, 2018 6:29 amThank you
+1
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Extend python document observer capabilities

Post by DeepSOIC »

Nice!
Also wanted:
* aboutToSaveDocument (for save, save-as, save a copy, save on exit, but not for auto backups)
* onDocumentSaved
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Extend python document observer capabilities

Post by ickby »

Werner merged and also considered DeepSOICs whiches. Thanks!
wmayer
Founder
Posts: 20300
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Extend python document observer capabilities

Post by wmayer »

There two further slots: slotStartSaveDocument and slotFinishSaveDocument.
In case you have to distinguish between the three save methods then:
* for saveAs you have to use slotBeforeChangeDocument or slotChangedDocument because it notifies you when the FileName property changes
* for saveCopy you can compare the passed file name with FileName. If they are different then saveCopy is invoked
User avatar
yorik
Founder
Posts: 13659
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Extend python document observer capabilities

Post by yorik »

This document observer is becoming a pretty powerful thing... Thanks folks!
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Extend python document observer capabilities

Post by Kunda1 »

Can someone with technical understanding volunteer to document this ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Extend python document observer capabilities

Post by Kunda1 »

Kunda1 wrote: Tue Oct 09, 2018 1:48 pm Can someone with technical understanding volunteer to document this ?
Opened a request on the FC Dev Blog, anyone interested in contributing ?
https://github.com/FreeCAD/FreeCAD-blog/issues/6
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Extend python document observer capabilities

Post by DeepSOIC »

wmayer wrote: Tue Oct 09, 2018 1:39 pm There two further slots: slotStartSaveDocument and slotFinishSaveDocument.
In case you have to distinguish between the three save methods then:
* for saveAs you have to use slotBeforeChangeDocument or slotChangedDocument because it notifies you when the FileName property changes
* for saveCopy you can compare the passed file name with FileName. If they are different then saveCopy is invoked
Thanks!
Post Reply