Multiple Child Windows

Technical discussions
Post Reply
Claude
Posts: 23
Joined: Thu Jan 05, 2017 3:58 am

Multiple Child Windows

Post by Claude »

Hello
My next question:

My application works on the principle of multiple Child windows, i.e. an MDI interface, where a 3D model is displayed in each window.

Can I have a model attached to each of these windows ? Of is a model attached to all displayed windows ?

Thanks, Claude

nickz
Site Admin
Posts: 236
Joined: Fri Jul 26, 2013 3:58 am

Sharing objects between child windows

Post by nickz »

Claude,
There is no limit on the number of KC windows in an application. At runtime each window creates its own model, but there are options to share or copy objects between models.

1. Objects can be shared via the .glm model file the ModelPath property (http://www.dynoinsight.com/Help/KernCAD ... #ModelPath) points to. When the files are different everything (by default) is completely independent. If the file is the same, each component loads and shows the same model perhaps at a different angle/zoom or other viewing options like wireframe.
When a .glm file has changed, a KC window, which refers to it, is updated only when the application redisplays the model (recalculation of some rendering attributes called presentation). This happens when ModelPath property is (re)assigned; KC.UpdateSurface() (http://www.dynoinsight.com/Help/KernCAD ... ateSurface) or IModel.Update() is called
This is the easiest way to share the objects: Set the model path to the same file and call KC.UpdateSurface() when needed

2. Another method is to use the external model functionality: http://www.dynoinsight.com/Help/Geom/Ex ... odels.aspx. In this case KC.UpdateSurface() automatically clones all objects of the other (external) model and adds it to the model of the caller window. If this component did not create or load any objects (model path is empty) the result will be a cloned model (all objects)

3. To share an object by reference (without copying anything) you can just obtain ISection reference from the first model and add it to the second model: Dim iSect As ISection = iModel.GetSection(0)
Dim iMod2Other As IModel2 = iModelOther
iMod2Other.Add(iSect)
This method also requires recalculation of presentation via UpdateSurface(), etc.
We have been thinking from time to time that to simplify the method 3 we could add something like KC.AttachModel(iModOther As IModel) and do the above automatically, but never got to it

Regards
Nick

Post Reply