Links

Discussion about the development of the Assembly workbench.
realthunder
Posts: 1536
Joined: Tue Jan 03, 2017 10:55 am

Re: Links

Postby realthunder » Thu May 04, 2017 9:09 pm

Here is a summary of the changes:

* SoFCUnifiedSelection is changed to deliver selection action to coin path instead of view provider root node, in order to distinguish shared coin nodes. Two api is added to ViewProvider, getDetailPath, getElementPicked to return node path formation.

* SoFCSelectionRoot is added to store selection context for other node to render selection. View provider can use SoFCSelectionRoot to replace a linked children's viewprovider root node, and share other geometry nodes under it. Other geometry nodes, SoBrepPointSet, SoBrepEdgeSet, SoBrepFaceSet, and the following SoFCSelection node is modified to query and store the selection information inside SoFCSelectionRoot. Multiple SoFCSelectionRoot can appear along the path for multi-level linking. The sequence of traversed instances of SoFCSelectionRoot is used as key to store and retrieve selection context. The context is always stored in the first encountered SoFCSelectionRoot.

* SoFCSelection is changed to be unified under SoFCUnifiselection. SoFCSelection no longer handles mouse event, but is only responsible for rendering the highlight. This change is necessary for selection disambiguation of shared nodes that uses SoFCSelection, such as Origin inside App::Part.

* ViewProviderDocumentObject api addition: getLinkedView() and getLinks() is added to allow tree view handle links.

* ViewProviderExtension: extensionGetLinks() to return all links that links to itself.

* ViewProviderLink: dynamically installs an extension called Observer to linked view provider to observe various changes. The observer holds a reference to LinkInfo which holds the replaced root node and shared coin tree. The tree gets rebuild once the linked view provider changes. Each linked object will have maximum three type of cloned coin representation, 1) with overriden placement (i.e. the cloned tree removes the original SoTransform node) and with override visibility (i.e replaced pcModeSwitch), 2) with original placement but with overridden visibility. 3) with original placement and visibility, this is for child object under App::Part. ViewProviderLink will retrieve the cloned coin tree and insert it into its own tree. It also implements the above getElementPicked and getDetailPath to disambiguate the shared nodes.

* ViewProviderLink does not require a specific DocumentObject counter part. It has a configurable list of property names and types. Any document object having those properties can use ViewProviderLink. App::LinkExtension is an example that holds those properties, and it also implements the following methods for sub object retrieval.

* DocumentObject api addition: change getPySubObjects() to accept a Base::Matrix4D to support transformation aggregation. getLinkedObject() is added to return final linked object with aggregated transformation matrix.

* Both App::Link and Part::Link uses App::LinkExtension to do the work. Part:Link::execute will also use getLinkedObject() to retrieve the final linked object and shallow copy its Shape object, so that it can be used inside other Part objects.

* Gui::Application add's convenient function getLinkedVewOfType to query a specific type of the linked object. This is used in PartGui, see below.

* PartGui: various view provider inside now use the above getLinkedViewOfType to transparently and safely access the child if it is (or is linked to) a view provider of type ViewProviderPart. This is essential for Part::Link to work.

Other modification are not essential for realization of Link.
Last edited by realthunder on Sat May 06, 2017 9:27 am, edited 2 times in total.
Try Assembly3 (latest version 0.11) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
DeepSOIC
Posts: 7600
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Links

Postby DeepSOIC » Thu May 04, 2017 9:27 pm

Almost built.....
.... done! Let's see what we have.
User avatar
DeepSOIC
Posts: 7600
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Links

Postby DeepSOIC » Thu May 04, 2017 10:24 pm

I just tried.
1. Part Cube
2. Part Link of cube
3. changed scaling
-> Part Link has Shape property, which has the scaled cube (all b-spline surfaces now, not unexpectedly).
-> Property window also shows all properties the Cube has. But in Py console, I don't see them as attributes of PartLink. I assume it's by design, and property view shows the properties of the actual Cube (@realthunder said the properties are merged).
4. Changed "LinkShape" property to False.
->The Shape attribute still holds the last shape the link had, but this shape doesn't react to changes to LinkScale property. Is it normal?
User avatar
DeepSOIC
Posts: 7600
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Links

Postby DeepSOIC » Thu May 04, 2017 10:33 pm

... and this latent shape is revealed if I use the link in, say, Fusion. That's a bug, I think.
User avatar
DeepSOIC
Posts: 7600
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Links

Postby DeepSOIC » Thu May 04, 2017 10:48 pm

Crash.
1. PartDesign Part.
2. Part Cube, move it into Part
3. Part Link the Part
4. Move Link into Part.
-> infinite recursion, crash
User avatar
DeepSOIC
Posts: 7600
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Links

Postby DeepSOIC » Thu May 04, 2017 10:51 pm

What's the purpose of PartLink's Viewprovider "show in tree", I wonder... I hides a link from the tree. But what for??
User avatar
DeepSOIC
Posts: 7600
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Links

Postby DeepSOIC » Thu May 04, 2017 11:05 pm

Now I loaded your example file. I did something, and now I can't see any properties except "Base":
lost-properties.png
lost-properties.png (279.97 KiB) Viewed 711 times
Now I need to figure out, what did cause it.
User avatar
DeepSOIC
Posts: 7600
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Links

Postby DeepSOIC » Thu May 04, 2017 11:15 pm

Figured out. That happens when I select linkGroups, and click the link in property editor saying "groups". That selects a deeply hidden object, "groups", which it looks like cannot be deselected easily.
User avatar
DeepSOIC
Posts: 7600
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Links

Postby DeepSOIC » Thu May 04, 2017 11:21 pm

DeepSOIC wrote:What's the purpose of PartLink's Viewprovider "show in tree", I wonder... I hides a link from the tree. But what for??
I now see it's part of your first message. I didn't notice it at first. I still don't get why would one want to hide something from tree. That makes things even more confusing.
User avatar
DeepSOIC
Posts: 7600
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Links

Postby DeepSOIC » Thu May 04, 2017 11:37 pm

One more thing.
App::Link now has property "LinkPlacement". When I tried moving link by editing Placement property, I ended up moving the original object instead of the instance. That's confusing. Can it be renamed back into Placement?