Extend python document observer capabilities

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

Extend python document observer capabilities

Postby ickby » Mon Oct 08, 2018 6:01 am

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
Posts: 3870
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Extend python document observer capabilities

Postby microelly2 » Mon Oct 08, 2018 6:29 am

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

Re: Extend python document observer capabilities

Postby damian » Mon Oct 08, 2018 6:32 am

microelly2 wrote:
Mon Oct 08, 2018 6:29 am
Thank you
+1
DeepSOIC
Posts: 5982
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Extend python document observer capabilities

Postby DeepSOIC » Mon Oct 08, 2018 8:45 am

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

Re: Extend python document observer capabilities

Postby ickby » Tue Oct 09, 2018 1:29 pm

Werner merged and also considered DeepSOICs whiches. Thanks!
wmayer
Site Admin
Posts: 13170
Joined: Thu Feb 19, 2009 10:32 am

Re: Extend python document observer capabilities

Postby wmayer » 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
User avatar
yorik
Site Admin
Posts: 10027
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Extend python document observer capabilities

Postby yorik » Tue Oct 09, 2018 1:42 pm

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

Re: Extend python document observer capabilities

Postby Kunda1 » Tue Oct 09, 2018 1:48 pm

Can someone with technical understanding volunteer to document this ?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
Kunda1
Posts: 2958
Joined: Thu Jan 05, 2017 9:03 pm

Re: Extend python document observer capabilities

Postby Kunda1 » Fri Oct 12, 2018 6:20 pm

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
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
DeepSOIC
Posts: 5982
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Extend python document observer capabilities

Postby DeepSOIC » Fri Oct 12, 2018 6:24 pm

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!