-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Viewer Guides #5960
Comments
I think it is possible to implement such a thing in pure Python. The closest example code might be the CropWindowTool, which draws a camera-relative overlay. Unfortunately that is written in C++, but it might be good enough to give you the gist of things : https://github.com/GafferHQ/gaffer/blob/main/src/GafferSceneUI/CropWindowTool.cpp. There are two main components :
Both Tools and Gadgets can be subclassed in Python, but the only examples are the boilerplate we have in the unit tests : https://github.com/GafferHQ/gaffer/blob/main/python/GafferUITest/GadgetTest.py#L84-L106 If you do take a stab at this, feel free to keep asking questions on here and I'll do my best to answer them. Ideally I think this would be best implemented natively as part of the Viewer's camera overlay, with the options being in the Camera menu. But that would involve C++... |
Thanks @johnhaddon! I'll have a look. I can handle C++ to a limited extent, but it would be more cumbersome for sure, having to set up all the dependencies and compile everything. I think I could probably adapt the crop tool C++ to be a button click and draw some lines in the viewer. But I'll look into the Python way first. |
@johnhaddon My first question is to ask if there's a way to run the unit test code, or a version of it, "live" from the Python Editor? For example, to create that TestTool sample in the existing viewer. |
You should be able to run this direct in the PythonEditor :
The only change from the unit test is that I've registered the tool against This will get you to your first error (always a good development milestone!) :
That's just because the Viewer is looking for an icon that doesn't exist - if you make the icon then you should be getting somewhere... |
Cool, that worked. I duplicated one of the existing icons and renamed it and the new tool showed up on the toolbar. I'm super busy these days but I'll keep chipping away at this in my free time. Will be fun! |
@johnhaddon I'm finding some time to look at this again. I'm feeling confident with how the Tool works, but I haven't been able to target the Gadget at the Viewer in the current Gaffer window. I can get a new Gaffer window to pop up though. I tried sticking GafferSceneUI.SceneView in various spots, but I couldn't figure it out. Any tips? On a related note, I found the resolutionGate stuff in SceneView.cpp. It looks like style->renderRectangle() is what creates the resolution gate when looking through a camera? Maybe there's a way to activate that through Python to draw, for example, two new rectangles, one for action safe and one for title safe? I figured I'd start simple with that before trying rule of thirds. |
Here's some example code that shows how you can do some drawing relative to the resolution gate (assuming you are looking through a camera). The drawing is all delegated to a Gadget subclass, which is currently just drawing a really thick white rectangle over the top. I'll leave it to you to fill in the maths to render different areas of interest. To have different modes, you'd want to add a plug to specify the mode on your Tool class, and then use metadata to provide an appropriate UI for it in a toolbar in the viewer. Then connect to
|
Cool! That works great and it's very clear what everything does. I'm surprised how similar it is to the C++ syntax. I'm off to the races now, will report back when I get more features added. |
@johnhaddon Ok, getting close! All the math is done for action safe, title safe and rule of thirds rectangles. Working well. I'd like to put the guide options in the Camera menu, if possible. I added dummy entries, but I don't know how to link them to the gadget(s). Do you have some sample code for that? Thanks a lot! |
Nice! Did you add your menu items by editing I originally suggested the Python-based Tool approach as a way of avoiding C++ and making a non-intrusive extension that could be loaded as a plugin. With that approach I think the best we can do is add the guides as a menu in a toolbar at the bottom of the screen, active when the tool is activated from the toolbar. I do agree though that from a UX perspective, putting this in the main camera menu is best. So I think maybe the question is : how would you feel about learning a little bit of C++? |
Yep, I was messing around in SceneViewUI,py. I was trying to copy how the grid toggle works. I was confused since it looks like the menu was populated and then magic, but I understand why now. I'm definitely game for C++. I have some experience with it already and SceneView.cpp looks like my kind of C++, i.e. not many pointers! Should be straightforward to port the rectangle math. Let me know what my next steps should be. As far as general features for this, I was thinking:
|
I don't know of others, but then I'm pretty ignorant in this area - feels likely that someone might want something additional though? In Gaffer we'd usually support that by providing an API something like
Later, it would be straightforward to add a public API for registering additional guide definitions in the static map. Does that make sense? If I'm not describing things clearly or in enough detail then just ask...
We tend not to provide too much user-facing configurability of this sort, partly because we want to keep Gaffer as simple as we can, and partly because we think it can often be a crutch used to avoid just making the defaults work well in the first place. |
I think that makes sense! I looked around a bit more and those three seem to be the main guides in video editing apps. I agree about the line thickness/color customization, I already talked myself out of it. I guess my main question now is how best to create a build environment on Windows where I can start messing around with C++, assuming that's the best way to go. Once I get set up I'm sure I'll have some questions about how to structure the new code and where to put it. Usually the easiest thing for me is to find stuff that mostly already does what I want and repurpose it, so hopefully I can use things like the existing resolution gate code and, for example, the grid toggle in the scene menu. The math for all the features seems to be working fine in Python, so porting that over will be the easy part. |
We're just starting to transition to MSVC 2022 for Gaffer 1.5, so I'm not sure if it's best for you to jump straight to that, or to set up with the existing MSVC and dependencies. @ericmehl, any thoughts? |
I'd say go with 2019 for now since that will definitely work with current releases. When we get 2022 support rolled out, it should be very close to a drop-in replacement. |
I like to use VS Code and it's built-in terminal for doing builds. You may be tempted to launch it with It's kind of annoying, but instead I duplicate the Lines 161 to 165 in bc2ff07
code and it will launch VS Code. Then you'll have the environment set up and the DLL files won't be locked.
I also add a few lines to that batch script :
These can go anywhere before the I also replace Lines 5 to 6 in bc2ff07
with set GAFFER_ROOT=YourGafferBuildDirectory . That way you can have the duplicated script above in a different directory from your Gaffer build directory to keep things separated.
Finally, launch VS Code from the duplicated launch script. To make a build, from the VS Code terminal, go to the Gaffer source code directory and run
Replace Let me know if I can clarify any of that or if you're having trouble getting it started. It's been a while since I first set this up so I may have overlooked something. |
Thanks so much for the detailed info @ericmehl! I also usually use VS Code and its terminal. I'll start chipping away at this soon. Bear with me as I'm sure I'll have more questions! |
Ok, I've made a fair bit of progress and I have a few questions @ericmehl:
Any idea how to fix that?
Hopefully that all made sense. Thanks! |
That should work fine, and it's good that they are not in the same directory as your Gaffer source. So in your case you'd set
Yes, that's the best dependencies to use. The 9.0 release will be the one John mentioned will be built using MSVC 2022. I'm wrestling those into submission as we speak.
I think the first error may be fixed by telling VS Code where to find header files. Try adding this to the "settings" entry in your workspace file.
And the second error should be fixed by adding something like
in the "settings" block of your code workspace file. That will define some global macros that the Scons build script normally defines when it does a build. That way the intellisense in VS Code will get the same values.
There are a couple of options for this :
Option #2 will pollute Gaffer's Python installation somewhat, so I think ideally you'd go with option 1. But I'm not sure there's really anything wrong with option 2. |
Great thanks, making progress. Got scons running, installed Inkscape, but it can't find Qt: "Checking for Qt...no." Do I need to install it separately? If so, any particular version? |
That might be a slightly misleading error message. It's actually trying to build a super-simple program linking to Qt to see if it succeeds. So it may be not finding Qt, or that quick build may be failing. It will output more information to a file in the source code directory called |
file C:\Source\gaffer\SConstruct,line 714: scons: Configure: Checking for Sphinx... scons: Configure: Checking for Qt... |
Gah, I mis-typed when I told you to set the |
Success, it's building now! 👀 |
Oops, failed on 3Delight: Cannot open include file: 'nsi.h': No such file or directory, etc. Can I just turn off 3DL or do I need to update another envar? |
In the startup script you made, try |
Hmm, it didn't like that either. DELIGHT= and DELIGHT='' also failed. I just installed 3Delight again, back in business! |
Getting close! The build finished without any obvious errors. I find gaffer.cmd now in C:\Source\gaffer-build\bin. Double-clicking on it launches the Gaffer UI... sort of. The console is full of errors like:
|
I noticed the title bar said 1.5 so I tried again with 1.4, same problem. My build is missing some files compared to the official release. For example, AnaglyphUI.py is missing. My workflow so far is:
and
And that's where we're at now. Any ideas where I'm going wrong? Thanks! |
It sounds like the step Try running There are some nodes that are actually just wrappers around an internal node network, and But as I mentioned, this should all be happening as part of |
When you copied the |
Success! I renamed gaffer.cmd and everything works perfectly now. Thanks for getting me up and running, this was the easiest build environment setup I've ever experienced. |
Awesome! I'm happy it's working for you now. Onwards to the fun stuff! |
Thanks! Speaking of fun stuff, hi @johnhaddon. 🙂 Before getting started I wanted to check in about which source files I should look to for adapting to this project. I'm thinking all I need is SceneView.cpp for the resolution gate and whichever Python file populates the camera menu. I was thinking of looking at the grid toggle for a model how to create a toggle for each viewer guide. Let me know if that sounds like a good starting place and anything else I might need to know. Thanks again! |
Yes, I think all your work will be in SceneView.cpp and SceneViewUI.py. I think something like this :
|
@ericmehl Making good progress over here! I just turned my attention to SceneViewUI.py though and I'm having build problems. I added some stuff that I had a feeling wasn't going to work, built the project, then the viewer refused to load in my test scene. I undid the changes, built again, same problem. I can't get back to the state things were in before even though all the source code has been reverted. The error messages are below. Any idea what I did wrong and how to fix it? Thanks!
|
Never mind. For some reason launching Gaffer from the VS Code terminal causes this error, but not so outside of VS Code. No clue why this suddenly started happening, but we're back in business for now. |
Good morning @johnhaddon: it's working! I have a separate set of variables and functions for each guide, so it's not very streamlined. I wanted to get it working and then turn my attention to refining the code. I don't know how best to combine everything into one function. I was thinking it needs something that includes the names of each guide and then a related boolean on or off for each. The C++ could loop through each name and check its state and the Python could populate the menu by iterating over each name and checking or setting its state. You mentioned a StringVectorDataPlug, but I'm not sure how that would work. Let me know if this makes any sense at all. Maybe I should open a PR so you can see what I've done so far? guides.mp4 |
Nice one!
It may be that I was too optimistic in thinking it could be consolidated into one. But let me sketch out one approach. You could have a static "registry" mapping from the names of guides to their definitions :
Then on the View you could add a StringVectorDataPlug which contains the names of the guides that should be rendered. The UI would just add and remove names from this list. Then the rendering would look something like this :
The main thing I like about this is that later on we could easily expose a public function for people to add their own definitions into the registry. But the big question I've left unanswered here is "what does GuideDefinition contain?". It may be that it's not easy to define it flexibly enough to do everything we want without making such a mess that we'd have been better with individual functions in the first place. But perhaps it could just contain a list of lines to draw, specified in a normalised
That would be great, or if you'd like to avoid the public gaze for a bit, you could just send me the URL for your branch on GitHub and we can discuss there. |
I think I understand how that would work, makes sense in terms of making things amenable to future expansion. I sent you an invite for my mini repo. It's just the two source code files and some stuff to help me get up and running quickly with the build environment. Looking forward to your thoughts! I marked all my additions with BHGC and made some notes about what I'm not sure about. |
Hi @johnhaddon, just bumping this. Did you get the invite? |
Sorry Brian, I did get the invite but I've been a bit slammed.
Could I trouble you to do it as a regular fork of the Gaffer repo and a commit that adds your stuff on top? It's easier for me to view and test the changes that way, and would be a necessary step for getting it merged in the end anyway. |
Sure, will do! |
Hey @ericmehl, I'd like to start building 1.5+ and I wanted to check if there are any differences in the process or other things I should know about. Thanks! |
Hi Brian! I think the only difference should be that you need to use MSVC 2022 now, and the latest dependencies release : https://github.com/GafferHQ/dependencies/releases/tag/9.0.0 I think you can use any version of MSVC, including the latest to build Gaffer. But if you don't need the full Visual Studio installation (the full IDE and all the tools that come with it), you might be best off using the version 17.8 build tools : https://aka.ms/vs/17/release.ltsc.17.8/vs_buildtools.exe I needed to use that to build the dependencies because of a change they made to more recent versions of the compiler, which is why I'm not using the latest release. If you use the default installation location, you'll need to change the line in your VS Code launcher script that sets up the build environment to |
Thanks Eric, sounds pretty straightforward! I'll try getting it set up soon. |
Success! It initially complained about an incorrect MSVC version, so I just switched back to VS Community 2022 and then it built no problem. Thanks! |
Howdy all, it would be nice to have some guide options to help setting up a camera. For example, darken the out of frame area, rule of thirds, title safe area, etc. I'm always game to try implementing stuff myself if it's doable in Python, so let me know if that's a possibility. Thanks!
The text was updated successfully, but these errors were encountered: