-
Notifications
You must be signed in to change notification settings - Fork 68
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
VCS 2D Interactivity #1058
VCS 2D Interactivity #1058
Conversation
vtk_ui package included in install buttons now set state correctly on copy
Configurator intercepts click events on the canvas It then determines what DP template attribute was clicked on. It logs double clicks, and then will "activate" that member.
Changing tactics on how to approach configuration; moved configurable logic out of template, will move to attributes directly.
Can now detect clicks in arbitrary fillarea polygons
UI Widgets now render on their own renderer; not quite ironed out the issues with that technique yet, but the renderer is contained by the manager class, which is a singleton per render window. Also created the editors subpackage, which integrates vtk_ui elements directly with the things they that can configure, starting with the fillarea.
UI widgets will now show up on the top most layer, and will actually persist between canvas.update() calls. Woo!
Conflicts: Packages/vcs/Lib/VTKPlots.py
Allows editing of color and fill style, though that appears to not work properly currently.
Extracted click/drag logic into mixin classes. Other editors will be able to use the exact same logic, woohoo. Interacting with a toolbar is still a bit fiddly, and there's tons of flashing; what's that all about?
Integrated into editors.fillarea and editors.line
@chaosphere2112 please rebase -i this branch. There are lot of commits with WIP and merge from master. Its going to make git history look bad. 👎 for now 😿 |
@aashish24 @chaosphere2112 I merged master in your branch and pushed to my repo, new PR is at: |
@chaosphere2112 and @doutriaux1 just looked at it on Ubunut a few comments 1- Change name of widget to whiuch label is selected 2- colorpicker error AttributeError Traceback (most recent call last) AttributeError: 'ColorPicker' object has no attribute 'render_window' 3- widget only show up after doing x.interact ???? 4- Make sure widgets show up on top of plot 5- floating window before x.interact() ??????? (maybe 2.3) |
also |
7- ALt (is not documented on mouseover or anything) AND it is also used for moving window on Ubunutu |
self.render_window.Render() | ||
|
||
|
||
def close(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dlonie @aashish24 I think I'm having some issues with closing a render window here. I read this tutorial to figure out how to close a window, but when I call TeminateApp() on the interactor I created for this window, the VCS interactor also stops. I'm pretty sure this is causing some bugs; I will sometimes get a segmentation fault when I press "q" to leave the main interactor if I skip this line, and it looks like in Ubuntu, the colorpicker window won't close at all. Any ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's hard to say. Can you get a stack trace of the segmentation fault with something like gdb?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can sure try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if you have any trouble (getting a system-installed gdb to play nice with a non-system Python can be a pain sometimes).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#0 0x000000010b8959fd in vtkSubjectHelper::InvokeEvent (this=0x11681c880, event=13, callData=0x0, self=0x11686b4b0) at /Users/fries2/build/build/VTK/Common/Core/vtkObject.cxx:601
#1 0x000000010b8961a2 in vtkObject::InvokeEvent (this=0x11686b4b0, event=13, callData=0x0) at /Users/fries2/build/build/VTK/Common/Core/vtkObject.cxx:785
#2 0x0000000114738c44 in -[vtkCocoaGLView invokeVTKButtonEvent:cocoaEvent:] (self=0x11656f9c0, _cmd=0x114785328, theEventId=13, theEvent=0x116687230) at /Users/fries2/build/build/VTK/Rendering/OpenGL/vtkCocoaGLView.mm:350
#3 0x0000000114739158 in -[vtkCocoaGLView mouseUp:] (self=0x11656f9c0, _cmd=0x7fff8d0e43a1, theEvent=0x116687230) at /Users/fries2/build/build/VTK/Rendering/OpenGL/vtkCocoaGLView.mm:491
#4 0x00007fff8c97c5d6 in -[NSWindow sendEvent:] ()
#5 0x00007fff8c978644 in -[NSApplication sendEvent:] ()
#6 0x00007fff8c88e21a in -[NSApplication run] ()
#7 0x0000000114724fd5 in VTKStartNSApplicationEventLoop () at /Users/fries2/build/build/VTK/Rendering/OpenGL/vtkCocoaRenderWindowInteractor.mm:182
#8 0x0000000114724f91 in vtkCocoaRenderWindowInteractor::StartEventLoop (this=0x11686b4b0) at /Users/fries2/build/build/VTK/Rendering/OpenGL/vtkCocoaRenderWindowInteractor.mm:243
#9 0x000000010fb075cc in vtkRenderWindowInteractor::Start (this=0x11686b4b0) at /Users/fries2/build/build/VTK/Rendering/Core/vtkRenderWindowInteractor.cxx:219
#10 0x000000010f674ffb in PyvtkRenderWindowInteractor_Start (self=0x116d37a10, args=0x100247050) at /Users/fries2/build/build/VTK-build/Wrapping/Python/vtkRenderWindowInteractorPython.cxx:209
#11 0x00000001000b05e6 in PyEval_EvalFrameEx (f=0x11f0159f0, throwflag=<value temporarily unavailable, due to optimizations>) at Python/ceval.c:4033
#12 0x00000001000ab36d in PyEval_EvalCodeEx (co=<value temporarily unavailable, due to optimizations>, globals=<value temporarily unavailable, due to optimizations>, locals=<value temporarily unavailable, due to optimizations>, args=<value temporarily unavailable, due to optimizations>, argcount=<value temporarily unavailable, due to optimizations>, kws=<value temporarily unavailable, due to optimizations>, kwcount=<value temporarily unavailable, due to optimizations>, defs=<value temporarily unavailable, due to optimizations>, defcount=<value temporarily unavailable, due to optimizations>, closure=<value temporarily unavailable, due to optimizations>) at Python/ceval.c:3265
#13 0x000000010003704c in function_call (func=0x115ed2758, arg=<value temporarily unavailable, due to optimizations>, kw=<value temporarily unavailable, due to optimizations>) at Objects/funcobject.c:526
#14 0x0000000100011473 in PyObject_Call (func=0x115ed2758, arg=0x11632cf50, kw=0x116d61e88) at Objects/abstract.c:2529
#15 0x00000001000aeaad in PyEval_EvalFrameEx (f=<value temporarily unavailable, due to optimizations>, throwflag=<value temporarily unavailable, due to optimizations>) at Python/ceval.c:4346
#16 0x00000001000ab36d in PyEval_EvalCodeEx (co=<value temporarily unavailable, due to optimizations>, globals=<value temporarily unavailable, due to optimizations>, locals=<value temporarily unavailable, due to optimizations>, args=<value temporarily unavailable, due to optimizations>, argcount=<value temporarily unavailable, due to optimizations>, kws=<value temporarily unavailable, due to optimizations>, kwcount=<value temporarily unavailable, due to optimizations>, defs=<value temporarily unavailable, due to optimizations>, defcount=<value temporarily unavailable, due to optimizations>, closure=<value temporarily unavailable, due to optimizations>) at Python/ceval.c:3265
#17 0x00000001000b2f19 in fast_function (func=<value temporarily unavailable, due to optimizations>, pp_stack=<value temporarily unavailable, due to optimizations>, n=<value temporarily unavailable, due to optimizations>, na=<value temporarily unavailable, due to optimizations>, nk=<value temporarily unavailable, due to optimizations>) at Python/ceval.c:4129
#18 0x00000001000ae785 in PyEval_EvalFrameEx (f=0x1002b0050, throwflag=<value temporarily unavailable, due to optimizations>) at Python/ceval.c:4054
#19 0x00000001000ab36d in PyEval_EvalCodeEx (co=<value temporarily unavailable, due to optimizations>, globals=<value temporarily unavailable, due to optimizations>, locals=<value temporarily unavailable, due to optimizations>, args=<value temporarily unavailable, due to optimizations>, argcount=<value temporarily unavailable, due to optimizations>, kws=<value temporarily unavailable, due to optimizations>, kwcount=<value temporarily unavailable, due to optimizations>, defs=<value temporarily unavailable, due to optimizations>, defcount=<value temporarily unavailable, due to optimizations>, closure=<value temporarily unavailable, due to optimizations>) at Python/ceval.c:3265
#20 0x00000001000aaca6 in PyEval_EvalCode (co=0x116d37a10, globals=0x100247050, locals=0x116687230) at Python/ceval.c:667
#21 0x00000001000d4794 in run_mod [inlined] () at /Users/fries2/build/build/Python/Python/pythonrun.c:1371
#22 0x00000001000d4794 in PyRun_FileExFlags (fp=<value temporarily unavailable, due to optimizations>, filename=<value temporarily unavailable, due to optimizations>, start=<value temporarily unavailable, due to optimizations>, globals=0x10029c168, locals=0x10029c168, closeit=<value temporarily unavailable, due to optimizations>, flags=<value temporarily unavailable, due to optimizations>) at Python/pythonrun.c:1357
#23 0x00000001000d4311 in PyRun_SimpleFileExFlags (fp=0x7fff7b6eb0a0, filename=0x7fff5fbff69e "run.py", closeit=1, flags=0x7fff5fbff390) at Python/pythonrun.c:949
#24 0x00000001000e932e in Py_Main (argc=<value temporarily unavailable, due to optimizations>, argv=<value temporarily unavailable, due to optimizations>) at Modules/main.c:640
#25 0x00007fff956f67e1 in start ()
Current language: auto; currently c++
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't been pressing q/e in the colorpicker; I've got a button widget that, when clicked, will call this close function. This (on a mac, but not ubuntu) would close the window, and I could go on messing around with the plot. When I did finally "q" on the main render window, I would then get the segfault.
That said, I'm currently not dealing with a situation where users press q/e on the colorpicker; I probably ought to!
I'm using a custom vtkInteractorStyle right now (which just no-ops all mouse events). I'll try switching over to the vtkInteractorStyleUser and setting an observer for CharEvent, and seeing if that fixes any of my issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I think I've got the fix for my issue. Go figure, you don't need to call .Start()
on an interactor if you're already in interaction mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so it doesn't segfault, but it still isn't closing the window in Ubuntu. Hm... something must be holding on to a reference, but what is definitely a major question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Figured it out; there were a couple of circular references that weren't getting cleaned up by the GC on ubuntu, but apparently were on my mac. This should be fine now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds nasty -- glad you figured it out!
@aashish24 I'd be happy to rebase, but it's not something I've had to do before. I tried googling around on how to do it, but nothing I was reading was terribly helpful, and when I tried to do rebase -i master on a new branch I created from this one, it wound up not doing anything, despite me attempting to squash some commits and reword the ones they were being squashed into. Do you know of any resources I can go through so I can do this? |
https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase-i/ looks to have a decent example of how it should work. Can you give an example of what you tried in the rebase editor, and what (if anything) was printed out on the command line? |
Is this good to go now? I can do a UVCDAT build/test/merge "review" if it's ready. |
I've got one more thing coming down the pipeline (adding a tooltip option for buttons), and then I still need to do the rebase; should be able to knock it out in the next hour or so. |
OK, I did the rebase; I think it'll be easiest to just close this PR and submit a new one? I dunno, I'll see what happens. I did just hit the segfault again, so I'm going to do a little bit more testing and submit after I get some food. |
Alright, I've double checked the segfault stuff, and figured out what was causing it again. Really do have to call TerminateApp, apparently 😄 I'm going to close this and resubmit. |
This is the mega-pull-request for VCS2D Interactivity. It adds 2 subpackages to vcs–
editors
andvtk_ui
.editors
contains classes that give a VTK based UI to edit VCS objects on the canvas; this is where the bulk of the actual functionality of this PR is located. Due to time constraints, there are only three enabled editors: LabelEditor, TextEditor, and MarkerEditor. Labels are any static text objects, like the min, max, and mean labels in the template, and Text objects are textcombined objects. The Fillarea, Line, Box, Data, and Legend editors all mostly work, but they didn't make the cut for this release. There's also a GroupEditor, which is a little slow and probably still a little buggy, but allows for grouped selections of items via the "shift" key, and will provide a toolbar that exposes common functionality to all grouped items (if you've got text and label items, every text config will be available, if you only have markers, all of the marker configs will be available, and if you have both text and markers, you'll basically only get access to color).vtk_ui
contains a bunch of UI wrapper classes to make it easier to use VTK Widgets– I've got a button class, a toolbar, a slider, a label, an editable text box, and a toolbar. To make things easier to reason about, all widgets in the vtk_ui module attach themselves to a "manager" object that handles hooking them up to a renderer, based on which VTK Render Window Interactor is passed in.vtk_ui.behaviors
is a subpackage of vtk_ui, which contains some Mix-in classes that provide basic interactivity to an object. There's the ClickableMixin, the DraggableMixin, and the KeyableMixin, which all pretty much do what you'd think. You add them as a parent class of the object you're working on, implement some methods, and they wire everything up appropriately so your object can now be clicked/dragged/typed/whatever.configurator.py
contains the bulk to the logic for setting things up and tearing them down; it'll determine what gets clicked on, and what should be activated. It also does most of the interfacing with the "outside" world (the rest of VCS, via canvas.py/VTKPlots.py).colorpicker.py
is a (very mediocre looking) visual color palette. It needs some love, but it does allow you to actually pick out which color you want to use without having to have a colormap memorized, which I totally don't yet.I'm sure there's more I haven't mentioned, but those are the highlights.
@doutriaux1 @aashish24 @williams13 @dlonie and whoever else, please give this a look. I've ironed out all of the kinks I notice, but I've gotten pretty used to this stuff over the last 4-5 months.