App.ActiveContainer

Discussion about the development of the Assembly workbench.
DeepSOIC
Posts: 4699
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

App.ActiveContainer

Postby DeepSOIC » Fri Apr 14, 2017 10:43 am

Hi!
I think I'm going to implement App.ActiveContainer, and automatic addition of new objects to it over this weekend.
Plan:
1. App.ActiveContainer (either a groupextension, or ==App.ActiveDocument
2. App.ActiveDocument.addObject to be redirected to App.ActiveContainer.newObject, and mark it deprecated
3. add App.ActiveDocument.newObject()
4. slowly passively transplant all "App.ActiveDocument.addObject(...)" to "App.ActiveContainer.newObject(...)"
triplus
Posts: 5019
Joined: Mon Dec 12, 2011 4:45 pm

Re: App.ActiveContainer

Postby triplus » Fri Apr 14, 2017 10:48 am

Sounds like a good weekend plan.

P.S. Given the fact you won't spend all available weekend time working on this. ;)
User avatar
yorik
Site Admin
Posts: 8684
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: App.ActiveContainer

Postby yorik » Fri Apr 14, 2017 9:39 pm

Nice!
Why point 3, by the way?
DeepSOIC
Posts: 4699
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: App.ActiveContainer

Postby DeepSOIC » Sat Apr 15, 2017 8:43 am

yorik wrote:Why point 3, by the way?
For point 4 to be possible.
DeepSOIC
Posts: 4699
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: App.ActiveContainer

Postby DeepSOIC » Sun Apr 16, 2017 1:52 pm

I have implemented App.ActiveContaainer to point to either a document, or to a feature. It is somewhat OK to use from python, but when using from C++, one always has to check if it is a document or a feature, and do the appropriate pointer cast. I think it is very annoying, so I think I will introduce an interface object, ObjectContainer, which is to take such a pointer, and offer a standard interface of a container, such as newObject, addObject, removeObject, hasObject, isAllowed, Objects, etc. It is also to expose its Py interface, and offer an attribute/function to obtain the original pointer.

This is what I've done with ActiveContainer so far,:
https://github.com/DeepSOIC/FreeCAD-ell ... Container0
This will need a rewrite once I write up the ObjectContainer. Unfortunately, I'm running out of weekend, so this has a high chance of becoming stale.
DeepSOIC
Posts: 4699
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: App.ActiveContainer

Postby DeepSOIC » Mon Apr 17, 2017 11:11 am

I decided to push the approach I started with forward, to see how much is the common container interface required. I'm now porting PartDesign, and it feels like the common container interface is very much required.

I have implemented automatic addition of new objects. Also made highlighting work, and patched up double-click activation/deactivation.

Things are getting interesting. For example, when a PD Body is active, creation of Part primitives fails. It would be nice if I could disable the command instead, but that will require a whole new system... The scope of the changes widens quickly.
DeepSOIC
Posts: 4699
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: App.ActiveContainer

Postby DeepSOIC » Mon Apr 17, 2017 10:22 pm

Ported PartDesign... hopefully it still works.
Gave some attention to duplication and copy-paste. They don't work with groups and parts and bodies. But individual features, when copied, are added to active container.

I felt an itch to fix it, but I think this can cause serious collision with what ickby is busy on. So I don't fix it any further.

Now on to porting Draft Autogroup...
triplus
Posts: 5019
Joined: Mon Dec 12, 2011 4:45 pm

Re: App.ActiveContainer

Postby triplus » Tue Apr 18, 2017 4:46 pm

It looks like you already made a lot of progress.

P.S. As for not being able to finish the work over the weekend. This sounds like a multi-weekend task anyway. ;)
DeepSOIC
Posts: 4699
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: App.ActiveContainer

Postby DeepSOIC » Tue Apr 18, 2017 8:31 pm

yorik wrote:Nice!
Hi, Yorik! Could you please have a glance at what I've done to Draft AutoGroup?
https://github.com/FreeCAD/FreeCAD/pull ... b4d69ea08c
It seems AutoGroup has something to do with Arch, too. Since I don't know Arch at all, things might get broken because of that.

Essentially, I changed AutoGroup to be merely a display/set widget for App.ActiveContainer. The automatic addition to groups should happen automatically, as I redirected App.ActiveDocument.addObject to App.ActiveContainer.newObject. But it is important that the "autogroup" object Arch will assign to App.ActiveContainer remains group-like. In particular, it must have GroupExtension or any derivative.

I have no clue if ["Site","Building","Floor"] have GroupExtension. That is specifically what I ask about.
User avatar
yorik
Site Admin
Posts: 8684
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: App.ActiveContainer

Postby yorik » Sun Apr 23, 2017 10:07 pm

sorry for the delay DeepSOIC, i had a look now, this looks cool!

One question, though. If you select a group, that group becomes the active container, right? So the active container can change while the draft autogroup is on, which is why you added an observer that updates the draft autogroup when needed. But wouldn't that be a bit against the very idea of that autogroup, that you have a "fixed" auto group that you are sure that it doesn't change? I have no clear idea on this...

Probablyonly by testing we will know, so for me your proposal can be merged. If needed we change the behaviour of draft autogroup later on.

About arch: currently both Building and Floor are derived from documentObjectGroup, so they are a group extension. The Site not, it's a Part Feature with only a "Group" PropertyLinkList. It was done before the extensions system came in, and I was always too lazy to convert :)

But I'm actually wanting to convert the building and floor to be App::Parts. So they could be moved around and benefit from future features of App Parts...