[vtk-developers] vtkCocoaRenderWindow qq

Clinton Stimpson clinton at elemtech.com
Wed Oct 1 21:24:30 EDT 2008


Sean McBride wrote:
> On 10/1/08 12:28 PM, clinton at elemtech.com said:
>
>   
>>>> What I would have expected was something like
>>>> vtkWindow concept       Cocoa concept       Carbon concept
>>>> DisplayId               -na-                    -na-
>>>> WindowId                NSView            HIView
>>>> ParentId                 NSView            HIView
>>>> RootWindow           NSWindow             Window
>>>>         
>>> In the Carbon column you have 2 HIViews.  Are these the same?  Do you
>>> mean WindowId and ParentId are synonymous?
>>>       
>> They are not the same.  The WindowId/HIView is a child of ParentId/HIView.
>> That gives the user the option of only setting the ParentId, and let VTK 
>> create the child window/view, and manage it.
>>     
>
> I'm not too familiar with HIViews... you seem to be describing some kind
> of subview relationship...
>
> Generally, in the Cocoa case, VTK creates both the NSView and NSWindow,
> and it sets the NSView as the NSWindow's contentView.  There isn't ever
> another NSView.
>
> I looked at the Carbon code, and I see it creates a WindowRef (stored in
> RootWindow) and stores the WindowRef's contentView as the WindowId.  The
> ParentId is never set, but it is read.  I guess I'm still not clear on
> ParentId's purpose.
>
> Anyway, this makes sense:
>
> vtkWindow concept       Cocoa concept     Carbon concept
> DisplayId               n/a               n/a
> WindowId                NSView            HIViewRef
> ParentId                ?                 HIViewRef
> RootWindow              NSWindow          WindowRef
>
> What, if anything, would you envision ParentId doing in the Cocoa case?
>
>   

Using plain VTK, you're right, there's only one NSView.  If you're 
making a GUI, there's a bunch of NSViews in a hierarchy, which can come 
from an nib file.

In the NSView reference:
<http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html>
An NSView can have a superview, and have subviews, that are other 
NSViews.  See the "Managing the View Hierarchy" section.
VTK's ParentId concept maps to an NSView that is a superview.  So the 
use case is that one can set a ParentId, and vtk*RenderWindow will 
create the WindowId as a child/subview.  I don't use ParentId because I 
just make a child window/subview and set the WindowId.

I forgot vtkCarbonRenderWindow didn't really implement ParentId.  The 
ParentId hack that is in there now, is for clipping the GL view to a 
region in the WindowRef if one doesn't have an HIView.  But that was for 
apps that don't use the better Carbon/HIView support in Mac OSX 10.2 and 
newer.
You can look at the X11 and Win32 code if you want to see how ParentId 
is supposed to be used.

Anyway, can we change vtkCocoaRenderWindow, or do we need to leave it alone?
I can use additional #ifdefs if we need to leave it alone.

Clint





More information about the vtk-developers mailing list