Locking graphics in GUI / disable resize, rotate or translate [message #90501] |
Thu, 05 March 2015 08:43  |
PMan
Messages: 61 Registered: January 2011
|
Member |
|
|
Hello,
I created a fancy GUI for a project and showed my 10 year old son it. He is interesting in programming and I wanted show off the sorts of things you can make.
Anyway, within about three seconds he can screwed up all the graphics with in the Gui. My question is, is there a way to lock graphics in a GUi? I am using window_widgets with either a map() graphic or image () graphics. I still need the user to be able to click on the map so I can get points from the user clicks, but I don't want the user to be able to zoom, rotate or translate the graphic.
Any idea how to do this?
Best Regards,
Paul
|
|
|
|
Re: Locking graphics in GUI / disable resize, rotate or translate [message #90503 is a reply to message #90501] |
Thu, 05 March 2015 08:56   |
chris_torrence@NOSPAM
Messages: 528 Registered: March 2007
|
Senior Member |
|
|
On Thursday, March 5, 2015 at 9:43:18 AM UTC-7, Paul Mallas wrote:
> Hello,
>
> I created a fancy GUI for a project and showed my 10 year old son it. He is interesting in programming and I wanted show off the sorts of things you can make.
>
> Anyway, within about three seconds he can screwed up all the graphics with in the Gui. My question is, is there a way to lock graphics in a GUi? I am using window_widgets with either a map() graphic or image () graphics. I still need the user to be able to click on the map so I can get points from the user clicks, but I don't want the user to be able to zoom, rotate or translate the graphic.
>
>
> Any idea how to do this?
>
> Best Regards,
> Paul
Hi Paul,
You can use the EVENT_HANDLER keyword on the Window object, then override a bunch of the methods, and return "0" to skip the default event handling.
Look in the docs under the Widget_Window.
Cheers,
Chris
|
|
|
|
Re: Locking graphics in GUI / disable resize, rotate or translate [message #90505 is a reply to message #90503] |
Thu, 05 March 2015 09:03   |
PMan
Messages: 61 Registered: January 2011
|
Member |
|
|
On Thursday, March 5, 2015 at 11:56:13 AM UTC-5, Chris Torrence wrote:
> On Thursday, March 5, 2015 at 9:43:18 AM UTC-7, Paul Mallas wrote:
>> Hello,
>>
>> I created a fancy GUI for a project and showed my 10 year old son it. He is interesting in programming and I wanted show off the sorts of things you can make.
>>
>> Anyway, within about three seconds he can screwed up all the graphics with in the Gui. My question is, is there a way to lock graphics in a GUi? I am using window_widgets with either a map() graphic or image () graphics. I still need the user to be able to click on the map so I can get points from the user clicks, but I don't want the user to be able to zoom, rotate or translate the graphic.
>>
>>
>> Any idea how to do this?
>>
>> Best Regards,
>> Paul
>
> Hi Paul,
>
> You can use the EVENT_HANDLER keyword on the Window object, then override a bunch of the methods, and return "0" to skip the default event handling.
>
> Look in the docs under the Widget_Window.
>
> Cheers,
> Chris
Thanks Chris, I will look into it.
|
|
|
Re: Locking graphics in GUI / disable resize, rotate or translate [message #90508 is a reply to message #90503] |
Thu, 05 March 2015 10:21   |
PMan
Messages: 61 Registered: January 2011
|
Member |
|
|
On Thursday, March 5, 2015 at 11:56:13 AM UTC-5, Chris Torrence wrote:
> On Thursday, March 5, 2015 at 9:43:18 AM UTC-7, Paul Mallas wrote:
>> Hello,
>>
>> I created a fancy GUI for a project and showed my 10 year old son it. He is interesting in programming and I wanted show off the sorts of things you can make.
>>
>> Anyway, within about three seconds he can screwed up all the graphics with in the Gui. My question is, is there a way to lock graphics in a GUi? I am using window_widgets with either a map() graphic or image () graphics. I still need the user to be able to click on the map so I can get points from the user clicks, but I don't want the user to be able to zoom, rotate or translate the graphic.
>>
>>
>> Any idea how to do this?
>>
>> Best Regards,
>> Paul
>
> Hi Paul,
>
> You can use the EVENT_HANDLER keyword on the Window object, then override a bunch of the methods, and return "0" to skip the default event handling.
>
> Look in the docs under the Widget_Window.
>
> Cheers,
> Chris
Great - it works just fine. Thanks for pointing it out.
|
|
|
Re: Locking graphics in GUI / disable resize, rotate or translate [message #90514 is a reply to message #90508] |
Thu, 05 March 2015 12:53   |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
On Thursday, March 5, 2015 at 7:21:05 PM UTC+1, Paul Mallas wrote:
> On Thursday, March 5, 2015 at 11:56:13 AM UTC-5, Chris Torrence wrote:
>> On Thursday, March 5, 2015 at 9:43:18 AM UTC-7, Paul Mallas wrote:
>>> Hello,
>>>
>>> I created a fancy GUI for a project and showed my 10 year old son it. He is interesting in programming and I wanted show off the sorts of things you can make.
>>>
>>> Anyway, within about three seconds he can screwed up all the graphics with in the Gui. My question is, is there a way to lock graphics in a GUi? I am using window_widgets with either a map() graphic or image () graphics. I still need the user to be able to click on the map so I can get points from the user clicks, but I don't want the user to be able to zoom, rotate or translate the graphic.
>>>
>>>
>>> Any idea how to do this?
>>>
>>> Best Regards,
>>> Paul
>>
>> Hi Paul,
>>
>> You can use the EVENT_HANDLER keyword on the Window object, then override a bunch of the methods, and return "0" to skip the default event handling.
>>
>> Look in the docs under the Widget_Window.
>>
>> Cheers,
>> Chris
>
> Great - it works just fine. Thanks for pointing it out.
I'll just add this link where I posted a similar question (although my heir where not the cause for this inquiry).
https://groups.google.com/d/msg/comp.lang.idl-pvwave/JaoG-Ra 9Cms/REMp4vvrn2UJ
Cheers,
Helder
|
|
|
Re: Locking graphics in GUI / disable resize, rotate or translate [message #90547 is a reply to message #90503] |
Mon, 09 March 2015 12:09   |
PMan
Messages: 61 Registered: January 2011
|
Member |
|
|
On Thursday, March 5, 2015 at 11:56:13 AM UTC-5, Chris Torrence wrote:
> On Thursday, March 5, 2015 at 9:43:18 AM UTC-7, Paul Mallas wrote:
>> Hello,
>>
>> I created a fancy GUI for a project and showed my 10 year old son it. He is interesting in programming and I wanted show off the sorts of things you can make.
>>
>> Anyway, within about three seconds he can screwed up all the graphics with in the Gui. My question is, is there a way to lock graphics in a GUi? I am using window_widgets with either a map() graphic or image () graphics. I still need the user to be able to click on the map so I can get points from the user clicks, but I don't want the user to be able to zoom, rotate or translate the graphic.
>>
>>
>> Any idea how to do this?
>>
>> Best Regards,
>> Paul
>
> Hi Paul,
>
> You can use the EVENT_HANDLER keyword on the Window object, then override a bunch of the methods, and return "0" to skip the default event handling.
>
> Look in the docs under the Widget_Window.
>
> Cheers,
> Chris
Hi Chris,
I have been working creating a class for handling events. Things are moving along slowly but I think I can do all the stuff I need with this. But I have one question - I am trying to override the selectChange method. How do I change the selection of the graphic directly? I can't do graphic.select (or graphic.select, /clear) since this calls the method I am trying to override and I end up with an infinite loop. Does this make any sense?
Thanks,
Paul
|
|
|
Re: Locking graphics in GUI / disable resize, rotate or translate [message #90549 is a reply to message #90547] |
Mon, 09 March 2015 14:40   |
chris_torrence@NOSPAM
Messages: 528 Registered: March 2007
|
Senior Member |
|
|
On Monday, March 9, 2015 at 1:09:07 PM UTC-6, Paul Mallas wrote:
> Hi Chris,
>
> I have been working creating a class for handling events. Things are moving along slowly but I think I can do all the stuff I need with this. But I have one question - I am trying to override the selectChange method. How do I change the selection of the graphic directly? I can't do graphic.select (or graphic.select, /clear) since this calls the method I am trying to override and I end up with an infinite loop. Does this make any sense?
>
> Thanks,
> Paul
Would it be possible to have some sort of state variable in your class, like "self.selecting=1"? Then call graphic.Select, and check for this variable within your handler, and then return,1 if that were true (after turning the variable back off).
-Chris
|
|
|
Re: Locking graphics in GUI / disable resize, rotate or translate [message #90555 is a reply to message #90549] |
Tue, 10 March 2015 06:42   |
PMan
Messages: 61 Registered: January 2011
|
Member |
|
|
On Monday, March 9, 2015 at 5:40:31 PM UTC-4, Chris Torrence wrote:
> On Monday, March 9, 2015 at 1:09:07 PM UTC-6, Paul Mallas wrote:
>> Hi Chris,
>>
>> I have been working creating a class for handling events. Things are moving along slowly but I think I can do all the stuff I need with this. But I have one question - I am trying to override the selectChange method. How do I change the selection of the graphic directly? I can't do graphic.select (or graphic.select, /clear) since this calls the method I am trying to override and I end up with an infinite loop. Does this make any sense?
>>
>> Thanks,
>> Paul
>
> Would it be possible to have some sort of state variable in your class, like "self.selecting=1"? Then call graphic.Select, and check for this variable within your handler, and then return,1 if that were true (after turning the variable back off).
> -Chris
I tried something similar to this - managing the selection at a higher level (sort of above where IDL considers a graphic selected). But I had no luck. But let me take another look. Thanks.
|
|
|
Re: Locking graphics in GUI / disable resize, rotate or translate [message #90556 is a reply to message #90555] |
Tue, 10 March 2015 07:03   |
PMan
Messages: 61 Registered: January 2011
|
Member |
|
|
On Tuesday, March 10, 2015 at 9:42:52 AM UTC-4, Paul Mallas wrote:
> On Monday, March 9, 2015 at 5:40:31 PM UTC-4, Chris Torrence wrote:
>> On Monday, March 9, 2015 at 1:09:07 PM UTC-6, Paul Mallas wrote:
>>> Hi Chris,
>>>
>>> I have been working creating a class for handling events. Things are moving along slowly but I think I can do all the stuff I need with this. But I have one question - I am trying to override the selectChange method. How do I change the selection of the graphic directly? I can't do graphic.select (or graphic.select, /clear) since this calls the method I am trying to override and I end up with an infinite loop. Does this make any sense?
>>>
>>> Thanks,
>>> Paul
>>
>> Would it be possible to have some sort of state variable in your class, like "self.selecting=1"? Then call graphic.Select, and check for this variable within your handler, and then return,1 if that were true (after turning the variable back off).
>> -Chris
>
> I tried something similar to this - managing the selection at a higher level (sort of above where IDL considers a graphic selected). But I had no luck. But let me take another look. Thanks.
Part of problem here is that for one 'select' event, my selectChange method gets called twice. Seems to be a bug (I reported this to the support folks) or perhaps some shortfall in my understanding.
|
|
|
Re: Locking graphics in GUI / disable resize, rotate or translate [message #90557 is a reply to message #90556] |
Tue, 10 March 2015 08:00   |
PMan
Messages: 61 Registered: January 2011
|
Member |
|
|
On Tuesday, March 10, 2015 at 10:03:13 AM UTC-4, Paul Mallas wrote:
> On Tuesday, March 10, 2015 at 9:42:52 AM UTC-4, Paul Mallas wrote:
>> On Monday, March 9, 2015 at 5:40:31 PM UTC-4, Chris Torrence wrote:
>>> On Monday, March 9, 2015 at 1:09:07 PM UTC-6, Paul Mallas wrote:
>>>> Hi Chris,
>>>>
>>>> I have been working creating a class for handling events. Things are moving along slowly but I think I can do all the stuff I need with this. But I have one question - I am trying to override the selectChange method. How do I change the selection of the graphic directly? I can't do graphic.select (or graphic.select, /clear) since this calls the method I am trying to override and I end up with an infinite loop. Does this make any sense?
>>>>
>>>> Thanks,
>>>> Paul
>>>
>>> Would it be possible to have some sort of state variable in your class, like "self.selecting=1"? Then call graphic.Select, and check for this variable within your handler, and then return,1 if that were true (after turning the variable back off).
>>> -Chris
>>
>> I tried something similar to this - managing the selection at a higher level (sort of above where IDL considers a graphic selected). But I had no luck. But let me take another look. Thanks.
>
> Part of problem here is that for one 'select' event, my selectChange method gets called twice. Seems to be a bug (I reported this to the support folks) or perhaps some shortfall in my understanding.
Here is my barest bones example. Run the code below, the graphics name gets printed twice per one click:
FUNCTION ExWid2Win::Init
self.select = 0
return, 1
END
FUNCTION ExWid2Win::SelectChange, oWin, graphic, mode, wasSelected
print, graphic.name
return, 0
END
PRO ExWid2Win__define
void = {ExWid2Win, $
inherits GraphicsEventAdapter, $
select: 0L}
END
PRO ExWidget2WindowEvents_event, event
w = WIDGET_EVENT(/NOWAIT)
print, 'do nothing'
END
PRO ExWidget2WindowEvents
wBase = WIDGET_BASE(/COLUMN, /TLB_RESIZE_NODRAW, MAP=0)
wDraw = WIDGET_WINDOW(wBase)
WIDGET_CONTROL, wBase, /REALIZE
WIDGET_CONTROL, wDraw, GET_VALUE=win
win.Select
p = PLOT(/TEST, /CURRENT)
handler = OBJ_NEW('ExWid2Win')
win.EVENT_HANDLER = handler
WIDGET_CONTROL, wBase, /MAP
XMANAGER, 'ExWidget2WindowEvents', wBase, /NO_BLOCK
END
|
|
|
|
Re: Locking graphics in GUI / disable resize, rotate or translate [message #90563 is a reply to message #90560] |
Tue, 10 March 2015 11:23   |
PMan
Messages: 61 Registered: January 2011
|
Member |
|
|
On Tuesday, March 10, 2015 at 12:17:31 PM UTC-4, Chris Torrence wrote:
> Hi Paul,
>
> You are getting what looks like two select events because the first time it is trying to directly select the plot while the second time it is trying to use a "select box" to select anything within the box. If you change your handler to return "1", then it only goes in there once, because the selection was successful.
>
> So the short answer is that you need to take that into account when you're designing your handler.
>
> Hope this helps.
>
> -Chris
If I change the SelectChange to return '1', I still get two events in for 'data space' plus one more for the 'plot.' But the plot is easy to id and ignore. But I see what your saying, about the call from idlitmanipselectbox__define.pro when return is '0'. When return is '1' there is second call from graphicsmanip__define.pro instead.
Anyway, it seems either way there are at least two calls to selectChange. The only way I can differentiate is using scope_traceback() and just look for the calls from _idlitmanipulator__define.pro and only consider those valid.
|
|
|
Re: Locking graphics in GUI / disable resize, rotate or translate [message #90564 is a reply to message #90563] |
Tue, 10 March 2015 11:40  |
PMan
Messages: 61 Registered: January 2011
|
Member |
|
|
On Tuesday, March 10, 2015 at 2:23:22 PM UTC-4, Paul Mallas wrote:
> On Tuesday, March 10, 2015 at 12:17:31 PM UTC-4, Chris Torrence wrote:
>> Hi Paul,
>>
>> You are getting what looks like two select events because the first time it is trying to directly select the plot while the second time it is trying to use a "select box" to select anything within the box. If you change your handler to return "1", then it only goes in there once, because the selection was successful.
>>
>> So the short answer is that you need to take that into account when you're designing your handler.
>>
>> Hope this helps.
>>
>> -Chris
>
> If I change the SelectChange to return '1', I still get two events in for 'data space' plus one more for the 'plot.' But the plot is easy to id and ignore. But I see what your saying, about the call from idlitmanipselectbox__define.pro when return is '0'. When return is '1' there is second call from graphicsmanip__define.pro instead.
>
> Anyway, it seems either way there are at least two calls to selectChange. The only way I can differentiate is using scope_traceback() and just look for the calls from _idlitmanipulator__define.pro and only consider those valid.
But if change plot(/test) to image(/test), it works just as you described.
|
|
|