App.ActiveContainer

Discussion about the development of the Assembly workbench.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

App.ActiveContainer

Post by DeepSOIC »

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
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: App.ActiveContainer

Post by triplus »

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
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: App.ActiveContainer

Post by yorik »

Nice!
Why point 3, by the way?
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: App.ActiveContainer

Post by DeepSOIC »

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

Re: App.ActiveContainer

Post by DeepSOIC »

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.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: App.ActiveContainer

Post by DeepSOIC »

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.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: App.ActiveContainer

Post by DeepSOIC »

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
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: App.ActiveContainer

Post by triplus »

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. ;)
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: App.ActiveContainer

Post by DeepSOIC »

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
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: App.ActiveContainer

Post by yorik »

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...
Post Reply