Jump to content

position and size of current viewport


Recommended Posts

So if at least one viewport show:

1. get window with ID=0 -> main window

2. get window with ID=1 -> viewport window

it is good

But

if all viewports in currect desktop are hidden and opened at least one floating window - we get wrong viewport window (with ID=1)

So, i need something like isFloatingWindow()

Link to comment
Share on other sites

Guest mantragora

if all viewports in currect desktop are hidden and opened at least one floating window - we get wrong viewport window (with ID=1)

So, i need something like isFloatingWindow()

Look at enum RE_WindowType:

http://www.sidefx.com/docs/hdk13.0/_r_e___types_8h_source.html

cout << currentWindow->getWindowType() << endl;

Main Window will return 0, that means RE_WINDOW_MAIN. Viewport will return 6, that means RE_WINDOW_CHILD. And it return 6 even if we tear of pane. Other windows (tooltips, parameter etc) return other values. I don't know is there any other window that return 6 beside another viewport.

Edited by mantragora
Link to comment
Share on other sites

Guest mantragora

Drag&drop your node to python shell and call on it cook(), so you should get something like this:

hou.node('yournode').cook(force=True)

Now try to change viewport size, then execute the same line in pythonshell and press button on your node. Does it help?

Edited by mantragora
Link to comment
Share on other sites

Guest mantragora

Than you are doing something wrong. If I don't recook the node I also get incorrect reading if I rescale viewport. But when I added to my button callback cook() it updates values correctly.

Link to comment
Share on other sites

Guest mantragora

You got some code in your button callback field? add after your callback cook(), so it look like this:

yourcallback(), hou.pwd().cook(True)

Does it help?

Link to comment
Share on other sites

this is my quick test (button callback) code


import inlinecpp

def alignMayaViewport( node ):
mymodule = inlinecpp.createLibrary(
name='test',
acquire_hom_lock=False,
includes=
'''
#include <RE/RE_Render.h>"
#include <RE/RE_window.h>"
''',
structs=[("IntArray", "*i")],
function_sources=[
"""
IntArray test()
{
RE_Render* render = RE_Render::getMainRender();
RE_WindowList* winList = render->getWindowList();
int winCount = winList->getNumWindows();

int i=0;
while (i < winCount)
{
RE_Window* win = winList->getWindow(i);
if ( win->getWindowType() == 6 )
{
int ints[] = {win->getX(), win->getY(), win->getW(), win->getH()};
std::vector<int> vec (ints, ints + sizeof(ints) / sizeof(int) );
return vec;
}
i++;
}

int ints[] = {0, 0, 0, 0};
std::vector<int> vec (ints, ints + sizeof(ints) / sizeof(int) );
return vec;

}
"""])

l = mymodule.test()

# print l[0], l[1], l[2], l[3]

# exec_ send cmd to Maya via commandPort
exec_( 'ui.qMayawindow.move({0},{1}); ui.qMayawindow.resize({2},{3})'.format(l[0],l[1],l[2],l[3]), node )[/CODE]

Edited by Alexey Vanzhula
Link to comment
Share on other sites

Guest mantragora

I took yours and added just button with callback to my node and also moved inlinecpp module outside of you function. I'm just calling it inside and printing values. This is all I can check since I don't have Maya.

Link to comment
Share on other sites

Guest mantragora

The only moment I get incorrect corner position is when I tearOff viewport pane. Then it always prints position as [12,119]. Beside this situation it updates OK.

ACTUALLY, It is correct if I tear off pane too BUT I just realized that viewport corner is counted from its parent corner. So if your viewport is inside your MainWindow and you move your MainWindow, to get correct corner position for the whole screen you need to take into account both positions.

If you tearoff viewport to separate window it always shows position as [12,119] because it doesn't change it's position like it is when you change pane size inside main window. In this situation the only changing value is the position of parent window that keeps the viewport.

Edited by mantragora
Link to comment
Share on other sites

Most likely it is not possible with HDK, but nevertheless... I need to emulate click on any pane border (border that change size of pane).

And in general: how to emulate mouse click? I see HDK documentation and think that it is possible but i still the layman in these questions )

Edited by Alexey Vanzhula
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...