Subview always stays at Left-Bottom regardless the arguments of V3d_View::SetWindow

Hi guys,

I want to place OCC subview at some position inside the main view, but no matter how I input the V3d_View::SetWindow arguments (theCorner, theOffset, theMargins), my subview always stays at the Left-Bottom of the main view, it looks like only theSize is able to control. Do you know an alternate way to control the position of OCC view or subview, I don't want to render entire windows?

Yours,
Dang Thai Hung

gkv311 n's picture

Could you share the complete code defining main V3d_View and it's subviews V3d_View?

Hoong Dang's picture

Hi, Thanks for your response. The code is in fact the QML Android example with little modification, compiling and run in Windows. 

// In AndroidQt.h declaring one more view

Handle(V3d_View) hostView;

// In AndroidQt.cxx

    hostView = myViewer->CreateView();
    hostView->SetImmediateUpdate(Standard_False);
    myView = myViewer->CreateView();
    myView->SetImmediateUpdate(Standard_False);

#ifdef __ANDROID__
    myView->SetWindow(aWindow, (Aspect_RenderingContext)anEglContext);
#else
    hostView->SetWindow(aWindow, (Aspect_RenderingContext)aRendCtx);
#endif    
    myView->SetWindow(hostView, Graphic3d_Vec2d(500, 300), Aspect_TOTP_LEFT_UPPER, Graphic3d_Vec2d(100, 100));

gkv311 n's picture

Have you tried marking host view as a composer (Graphic3d_CView::SetSubviewComposer(), if you don't want it to display viewer contents? Note that you need also passing this host view to AIS_ViewController instead of subview to flush events and perform redraw.

Hoong Dang's picture

Hi,

Thanks for the suggestion. SetSubviewComposer doesn't really work, OCC still renders things at the Lower-Left. I tried to dig into OCC codes:
* The glViewport calls always start at (0,0), that means always render from (0,0)
* Aspect_Window has a method named Aspect_Window::Position, but it's never called while the Aspect_Window::Size is. That means the position or offset of the Aspect_Window never takes affect.

Any idea?

Yours,

gkv311 n's picture

The glViewport calls always start at (0,0), that means always render from (0,0)

Subview API doesn't affect viewport definition. Subviews render contents into offscreen framebuffers (hense, no viewport offset), while composition View fills entire window and blits subviews into designated regions.

Aspect_Window has a method named Aspect_Window::Position, but it's never called...

This method returns window position on the screen, it doesn't define viewport offset.

Hoong Dang's picture

Thanks for the clarification. That's informative.
The SubView is positioned relative to View via a Aspect_NeutralWindow. The position of Aspect_NeutralWindow is relative to main WNT_Window but it's never used in composition phase to place it at the right region. I don't think Subview Offset/Margin ever works as designed.

I want to shift the Subview ex. 200px*200px from Left-Bottom, how do I do?

kndscan's picture

hi, i was trapped by the same trouble. have you figured it out?

gkv311 n's picture

I don't think Subview Offset/Margin ever works as designed.

It DOES work as designed - Subview interface is propagated to Draw Harness, so that you may play with it using vinit command, find source code of this command and check related test cases (tests/opengl/data/general/multiview*)