Alexey Vanzhula Posted December 1, 2013 Share Posted December 1, 2013 Is it possible to find position and geometry of current viewport (not floating) with inline C functions? Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted December 2, 2013 Share Posted December 2, 2013 (edited) I don't get what you are asking. You want to know viewport position and it's pane information or do you want information about GU_Detail processed currently by viewport on the level you are at? EDIT: OK. One fresh drink later and I get what you are asking about . Probably it's possible, the question is where you want to access this information? in the viewport hook or in the node? Why do you need this? EDIT2: There are couple RE_Window classes (with NT, OSX, X letters for each system) that deals with windows but it's nothing that will give you information with one method. It's typical low level window management stuff you can find in any GUI framework. Edited December 2, 2013 by mantragora Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted December 2, 2013 Share Posted December 2, 2013 #include <RE\RE_window.h> auto list = r->getWindowList(); auto wincount = list->getNumWindows(); cout << wincount << endl; auto i = 0; while (i < wincount) { auto currentWindow = list->getWindow(i); cout << "[" << currentWindow->getW() << ", " << currentWindow->getH() << "]" << endl; i++; } With this I can get info how many windows Houdini created. Now, if you have only Houdini open you will get MainWindowSize and ViewportSize. All you have to do is to figure out which is which Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted December 2, 2013 Share Posted December 2, 2013 (edited) One more drink later... If you add this: cout << "[" << currentWindow->getX() << ", " << currentWindow->getY() << "]" << endl; you will get corner (I think top-left) of each window from which you can calculate other corners and your position (and you can because you have W and H already). If Houdini always creates MainWindow and then Viewport than we can safely assume that the smaller one is a viewport. Maybe there is possibility to get it directly thru some ID check. Edited December 2, 2013 by mantragora Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted December 3, 2013 Author Share Posted December 3, 2013 (edited) I work on maya<>houdini pipeline tool and want to snap maya viewport on top of houdini viewport from python script So, when maya get focus i want to update its widget geometry Edited December 3, 2013 by Alexey Vanzhula Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted December 3, 2013 Author Share Posted December 3, 2013 (edited) Why your example does not work for me? import inlinecppmymodule = inlinecpp.createLibrary(name='test',includes="#include <RE/RE_window.h>",function_sources=['''int windowCount(){auto list = r->getWindowList();auto count = list->getNumWindows();return count;}'''])print mymodule.windowCount()[/CODE]what is [b]r[/b] object?And also forum formatting changed [b]RE/RE_window.h[/b] to [b]RE/RE_window.h[/b] Edited December 3, 2013 by Alexey Vanzhula Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted December 3, 2013 Share Posted December 3, 2013 (edited) I posted parts of the code here so if you can't figure out how I made this to work, here is the rest : https://www.mediafir...8kunl5zvfod28ez Just press "D" in viewport and activate "DM_WindowData". If you leave this menu open you will get data from three windows. EDIT: Oh yeah, compile and put it in your "dso" folder. EDIT2: Oh yeah Two, it's version for C++11, so you need Houdini and compiler version that supports it , otherwise you need to rewrite it. Edited December 3, 2013 by mantragora Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted December 3, 2013 Author Share Posted December 3, 2013 Thanx Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted December 3, 2013 Author Share Posted December 3, 2013 (edited) I dont know how can i use it in python? In HOM i can find current scene viewer, viewport, pane - but how to get render cpp object to use in inlinecpp? Edited December 3, 2013 by Alexey Vanzhula Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted December 3, 2013 Share Posted December 3, 2013 (edited) /* Gets Houdini windows information (count, width/height, corner position). author: Mantragora 2013. https://vimeo.com/mantragora */ import inlinecpp mymodule = inlinecpp.createLibrary( name="viewport_cpp", includes= """ #include <RE\RE_Render.h> #include <RE\RE_window.h> #include <ostream> """, function_sources=[ """ void WindowData() { // get renderer auto render = RE_Render::getMainRender(); // collect data auto list = render->getWindowList(); auto wincount = list->getNumWindows(); std::cout << wincount << std::endl; auto i = 0; while (i < wincount) { auto currentWindow = list->getWindow(i); std::cout << "Width/Height: " << "[" << currentWindow->getW() << ", " << currentWindow->getH() << "]" << std::endl; std::cout << "Corner Position: " << "[" << currentWindow->getX() << ", " << currentWindow->getY() << "]" << std::endl; std::cout << "ID: " << currentWindow->getWindowID() << std::endl; i++; } std::cout << "" << std::endl; } """]) print mymodule.WindowData() PS. Remember that f*cking formating changes "Window" to "window" here: #include <RE\RE_window.h> Edited December 3, 2013 by mantragora Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted December 3, 2013 Author Share Posted December 3, 2013 (edited) I dont know why, but this simple example does not work in my linux h13.0.248 gcc4.6: http://pastebin.com/LQF5RUpV and error: http://pastebin.com/V3sZpvst Is it C++11 problem ? Edited December 3, 2013 by Alexey Vanzhula Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted December 3, 2013 Share Posted December 3, 2013 (edited) 1) Your function is called "test" while you trying to call "windowCount". 2) Change this line to RE_Render* render = RE_Render::getMainRender(); But if it's not this, I don't know. gcc4.6 should support "auto" keyword. Edited December 3, 2013 by mantragora Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted December 3, 2013 Author Share Posted December 3, 2013 Thanx a lot !!! Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted December 3, 2013 Author Share Posted December 3, 2013 (edited) mantragora, you very much helped me. But you probably not correctly understood a question about viewport. At now with simple cpp lines i can manage separate (floating) windows. But i need catch info about embedded viewport position\size. maybe I approached close to the answer Still need to find solution Edited December 3, 2013 by Alexey Vanzhula Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted December 3, 2013 Share Posted December 3, 2013 But i need catch info about embedded viewport position\size. Than I still don't get it. What you mean by embedded viewport? Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted December 3, 2013 Author Share Posted December 3, 2013 viewport that in main houdini window - not in floating window. render->getWindowList() give me all separated windows. Windows with ID=0 (ID in list) is a main houdini window - and i can control it. But what further? How to get viewport in it? Sory for bad english. Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted December 3, 2013 Author Share Posted December 3, 2013 maybe it is some sort of get active opengl areas and get it dimensions ? Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted December 3, 2013 Share Posted December 3, 2013 Than we need E.D.W.A.R.D od TWOD because I have no idea how to manipulate panes. Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted December 3, 2013 Author Share Posted December 3, 2013 I was mistaken. This windows (returned by render->getWindowList()) is a panes Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted December 3, 2013 Share Posted December 3, 2013 (edited) is a panes No it's not. Position 0 in list is a Main window. Position 1 is Viewport, the one you can see your geometry. Any other position there is another window that you open, like the one when you press "D". But you can't manipulate panes with this. Panes split window. You can have multiple panes in window. I don't know how to get them. But if you need only Viewport size and position you got all the info there, just like I said couple posts ago. Widht/Height and top-left corner is all you need. You just don't get pane this window reside in. Edited December 3, 2013 by mantragora Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.