Dragable LineInspector?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Dragable LineInspector?

Stephan Helma
Hi all,

I based an application heavily upon the 2D function inspector
(demo/advanced/scalar_image_function_inspector.py). In the current
implementation the crosshair moves whenever the mouse moves and when the
mouse leaves the window the crosshair vanishes. I tried to modify it
such that I can move the crosshair by dragging the mouse (grabbing the
crosshair with the left mouse button and moving it) because I want to
keep a certain position in the plot for closer inspection.

Is there a way to keep the LineInspector tool from automatically moving
with the mouse? Is there any other way to accomplish this behaviour?

Any comments are highly welcome.

Stephan
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Dragable LineInspector?

John Wiggins
Stephan,

It's funny that you bring this up because I had the same problem the
other day. What I ended up doing was modifying the LineInspector tool
by replacing all of the mouse handling code. My version is somewhat
limited right now, but there's no reason why it couldn't eventually be
improved and added to Chaco.

- John

On Thu, Mar 24, 2011 at 12:08 PM, Stephan Helma <[hidden email]> wrote:

> Hi all,
>
> I based an application heavily upon the 2D function inspector
> (demo/advanced/scalar_image_function_inspector.py). In the current
> implementation the crosshair moves whenever the mouse moves and when the
> mouse leaves the window the crosshair vanishes. I tried to modify it
> such that I can move the crosshair by dragging the mouse (grabbing the
> crosshair with the left mouse button and moving it) because I want to
> keep a certain position in the plot for closer inspection.
>
> Is there a way to keep the LineInspector tool from automatically moving
> with the mouse? Is there any other way to accomplish this behaviour?
>
> Any comments are highly welcome.
>
> Stephan
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
>
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Dragable LineInspector?

Warren Weckesser
Stephan,

Here' a "quick and probably dirty" (i.e. barely tested) DraggableLineInspector that subclasses from LineInspector and munges its event handling. (For a better implementation, I'd probably first refactor LineInspector to better separate the drawing code from the event handling code, to make it easier to reuse in a subclass or in a new class.)  Also attached is a modified version of scalar_image_function_inspector.py as a demonstration. It was changed to use DraggableLineInspector as a drop-in replacement for LineInspector; it also doesn't add the PanTool to its plot, so only the DraggableLineInspectors handle the left-click-drag events.

Warren


On Thu, Mar 24, 2011 at 2:46 PM, John Wiggins <[hidden email]> wrote:
Stephan,

It's funny that you bring this up because I had the same problem the
other day. What I ended up doing was modifying the LineInspector tool
by replacing all of the mouse handling code. My version is somewhat
limited right now, but there's no reason why it couldn't eventually be
improved and added to Chaco.

- John

On Thu, Mar 24, 2011 at 12:08 PM, Stephan Helma <[hidden email]> wrote:
> Hi all,
>
> I based an application heavily upon the 2D function inspector
> (demo/advanced/scalar_image_function_inspector.py). In the current
> implementation the crosshair moves whenever the mouse moves and when the
> mouse leaves the window the crosshair vanishes. I tried to modify it
> such that I can move the crosshair by dragging the mouse (grabbing the
> crosshair with the left mouse button and moving it) because I want to
> keep a certain position in the plot for closer inspection.
>
> Is there a way to keep the LineInspector tool from automatically moving
> with the mouse? Is there any other way to accomplish this behaviour?
>
> Any comments are highly welcome.
>
> Stephan
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
>
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev

draggable_line_inspector.py (2K) Download Attachment
mod_scalar_image_function_inspector.py (24K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Dragable LineInspector?

Warren Weckesser
There are a few lines in the DraggableLineInspector's method that are not needed.  Attached is an even simpler version.

Warren


On Thu, Mar 24, 2011 at 3:14 PM, Warren Weckesser <[hidden email]> wrote:
Stephan,

Here' a "quick and probably dirty" (i.e. barely tested) DraggableLineInspector that subclasses from LineInspector and munges its event handling. (For a better implementation, I'd probably first refactor LineInspector to better separate the drawing code from the event handling code, to make it easier to reuse in a subclass or in a new class.)  Also attached is a modified version of scalar_image_function_inspector.py as a demonstration. It was changed to use DraggableLineInspector as a drop-in replacement for LineInspector; it also doesn't add the PanTool to its plot, so only the DraggableLineInspectors handle the left-click-drag events.

Warren



On Thu, Mar 24, 2011 at 2:46 PM, John Wiggins <[hidden email]> wrote:
Stephan,

It's funny that you bring this up because I had the same problem the
other day. What I ended up doing was modifying the LineInspector tool
by replacing all of the mouse handling code. My version is somewhat
limited right now, but there's no reason why it couldn't eventually be
improved and added to Chaco.

- John

On Thu, Mar 24, 2011 at 12:08 PM, Stephan Helma <[hidden email]> wrote:
> Hi all,
>
> I based an application heavily upon the 2D function inspector
> (demo/advanced/scalar_image_function_inspector.py). In the current
> implementation the crosshair moves whenever the mouse moves and when the
> mouse leaves the window the crosshair vanishes. I tried to modify it
> such that I can move the crosshair by dragging the mouse (grabbing the
> crosshair with the left mouse button and moving it) because I want to
> keep a certain position in the plot for closer inspection.
>
> Is there a way to keep the LineInspector tool from automatically moving
> with the mouse? Is there any other way to accomplish this behaviour?
>
> Any comments are highly welcome.
>
> Stephan
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
>
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev



_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev

draggable_line_inspector.py (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Dragable LineInspector?

Stephan Helma
On Thu, 2011-03-24 at 15:19 -0500, Warren Weckesser wrote:

Hi Warren,

Thank you. It works perfectly for me!

I took the liberty to change it a little bit: If you initiate
DraggableLineInspector with drag_only=True, you have to actually grab
the line to move it. You can even set the threshold for grabbing the
line with threshold=<any integer>. (Please note that I did not check
this feature for BaseXYPlots...)

It would be nice to have some feedback for the user when s/he is in the
hot zone of the line where it can be dragged by changing the cursor. I
tried to initiate DraggableLineInspector with pointer="right arrow" but
the cursor does not change when hovering over the line. How can I
achieve this?

Stephan

>         There are a few lines in the DraggableLineInspector's method
>         that are not
>         needed.  Attached is an even simpler version.
>        
>         Warren
>        
>        
>         On Thu, Mar 24, 2011 at 3:14 PM, Warren Weckesser <
>         [hidden email]> wrote:
>        
>         > Stephan,
>         >
>         > Here' a "quick and probably dirty" (i.e. barely tested)
>         > DraggableLineInspector that subclasses from LineInspector
>         and munges its
>         > event handling. (For a better implementation, I'd probably
>         first refactor
>         > LineInspector to better separate the drawing code from the
>         event handling
>         > code, to make it easier to reuse in a subclass or in a new
>         class.)  Also
>         > attached is a modified version of
>         scalar_image_function_inspector.py as a
>         > demonstration. It was changed to use DraggableLineInspector
>         as a drop-in
>         > replacement for LineInspector; it also doesn't add the
>         PanTool to its plot,
>         > so only the DraggableLineInspectors handle the
>         left-click-drag events.
>         >
>         > Warren
>         >
>         >
>         >
>         > On Thu, Mar 24, 2011 at 2:46 PM, John Wiggins
>         <[hidden email]>wrote:
>         >
>         >> Stephan,
>         >>
>         >> It's funny that you bring this up because I had the same
>         problem the
>         >> other day. What I ended up doing was modifying the
>         LineInspector tool
>         >> by replacing all of the mouse handling code. My version is
>         somewhat
>         >> limited right now, but there's no reason why it couldn't
>         eventually be
>         >> improved and added to Chaco.
>         >>
>         >> - John
>         >>
>         >> On Thu, Mar 24, 2011 at 12:08 PM, Stephan Helma
>         <[hidden email]>
>         >> wrote:
>         >> > Hi all,
>         >> >
>         >> > I based an application heavily upon the 2D function
>         inspector
>         >> > (demo/advanced/scalar_image_function_inspector.py). In
>         the current
>         >> > implementation the crosshair moves whenever the mouse
>         moves and when the
>         >> > mouse leaves the window the crosshair vanishes. I tried
>         to modify it
>         >> > such that I can move the crosshair by dragging the mouse
>         (grabbing the
>         >> > crosshair with the left mouse button and moving it)
>         because I want to
>         >> > keep a certain position in the plot for closer
>         inspection.
>         >> >
>         >> > Is there a way to keep the LineInspector tool from
>         automatically moving
>         >> > with the mouse? Is there any other way to accomplish this
>         behaviour?
>         >> >
>         >> > Any comments are highly welcome.
>         >> >
>         >> > Stephan
>         >> > _______________________________________________
>         >> > Enthought-Dev mailing list
>         >> > [hidden email]
>         >> > https://mail.enthought.com/mailman/listinfo/enthought-dev
>         >> >
>         >> _______________________________________________
>         >> Enthought-Dev mailing list
>         >> [hidden email]
>         >> https://mail.enthought.com/mailman/listinfo/enthought-dev
>         >>
>         >
>         >

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev

draggable_line_inspector.py (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Dragable LineInspector?

John Wiggins
This is (mostly) untested code, but you can handle mouse cursor hover
states in normal_mouse_move().

- John

On Fri, Mar 25, 2011 at 5:15 PM, Stephan Helma <[hidden email]> wrote:

> On Thu, 2011-03-24 at 15:19 -0500, Warren Weckesser wrote:
>
> Hi Warren,
>
> Thank you. It works perfectly for me!
>
> I took the liberty to change it a little bit: If you initiate
> DraggableLineInspector with drag_only=True, you have to actually grab
> the line to move it. You can even set the threshold for grabbing the
> line with threshold=<any integer>. (Please note that I did not check
> this feature for BaseXYPlots...)
>
> It would be nice to have some feedback for the user when s/he is in the
> hot zone of the line where it can be dragged by changing the cursor. I
> tried to initiate DraggableLineInspector with pointer="right arrow" but
> the cursor does not change when hovering over the line. How can I
> achieve this?
>
> Stephan
>
>>         There are a few lines in the DraggableLineInspector's method
>>         that are not
>>         needed.  Attached is an even simpler version.
>>
>>         Warren
>>
>>
>>         On Thu, Mar 24, 2011 at 3:14 PM, Warren Weckesser <
>>         [hidden email]> wrote:
>>
>>         > Stephan,
>>         >
>>         > Here' a "quick and probably dirty" (i.e. barely tested)
>>         > DraggableLineInspector that subclasses from LineInspector
>>         and munges its
>>         > event handling. (For a better implementation, I'd probably
>>         first refactor
>>         > LineInspector to better separate the drawing code from the
>>         event handling
>>         > code, to make it easier to reuse in a subclass or in a new
>>         class.)  Also
>>         > attached is a modified version of
>>         scalar_image_function_inspector.py as a
>>         > demonstration. It was changed to use DraggableLineInspector
>>         as a drop-in
>>         > replacement for LineInspector; it also doesn't add the
>>         PanTool to its plot,
>>         > so only the DraggableLineInspectors handle the
>>         left-click-drag events.
>>         >
>>         > Warren
>>         >
>>         >
>>         >
>>         > On Thu, Mar 24, 2011 at 2:46 PM, John Wiggins
>>         <[hidden email]>wrote:
>>         >
>>         >> Stephan,
>>         >>
>>         >> It's funny that you bring this up because I had the same
>>         problem the
>>         >> other day. What I ended up doing was modifying the
>>         LineInspector tool
>>         >> by replacing all of the mouse handling code. My version is
>>         somewhat
>>         >> limited right now, but there's no reason why it couldn't
>>         eventually be
>>         >> improved and added to Chaco.
>>         >>
>>         >> - John
>>         >>
>>         >> On Thu, Mar 24, 2011 at 12:08 PM, Stephan Helma
>>         <[hidden email]>
>>         >> wrote:
>>         >> > Hi all,
>>         >> >
>>         >> > I based an application heavily upon the 2D function
>>         inspector
>>         >> > (demo/advanced/scalar_image_function_inspector.py). In
>>         the current
>>         >> > implementation the crosshair moves whenever the mouse
>>         moves and when the
>>         >> > mouse leaves the window the crosshair vanishes. I tried
>>         to modify it
>>         >> > such that I can move the crosshair by dragging the mouse
>>         (grabbing the
>>         >> > crosshair with the left mouse button and moving it)
>>         because I want to
>>         >> > keep a certain position in the plot for closer
>>         inspection.
>>         >> >
>>         >> > Is there a way to keep the LineInspector tool from
>>         automatically moving
>>         >> > with the mouse? Is there any other way to accomplish this
>>         behaviour?
>>         >> >
>>         >> > Any comments are highly welcome.
>>         >> >
>>         >> > Stephan
>>         >> > _______________________________________________
>>         >> > Enthought-Dev mailing list
>>         >> > [hidden email]
>>         >> > https://mail.enthought.com/mailman/listinfo/enthought-dev
>>         >> >
>>         >> _______________________________________________
>>         >> Enthought-Dev mailing list
>>         >> [hidden email]
>>         >> https://mail.enthought.com/mailman/listinfo/enthought-dev
>>         >>
>>         >
>>         >
>
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
>
>

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev

draggable_line_inspector.py (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Dragable LineInspector?

Stephan Helma
On Fri, 2011-03-25 at 17:25 -0500, John Wiggins wrote:
> This is (mostly) untested code, but you can handle mouse cursor hover
> states in normal_mouse_move().

It works for me! Thanks for your great help.

I added code to handle index_x and index_y line inspectors (also
untested, but working for me). But there is a glitch: If (like in the
case of mod_scalar_image_function_inspector.py) two
DraggableLineInspectors are employed only one can set the cursor.

If you initiate DraggableLineInspector with linked=True they "know"
about the other line inspector by the common metadata_name and do not
"steal" the pointer and can even show a special pointer at their
intersection. The code is a quick hack (mainly because I could not find
any function which converts a value/index point back to screen
coordinates) but seems to work.

Probably it would make more sense to subclass LineInspector to make a
sort of DraggableCrossLineInspector?

Stephan

> - John
>
> On Fri, Mar 25, 2011 at 5:15 PM, Stephan Helma <[hidden email]> wrote:
> > On Thu, 2011-03-24 at 15:19 -0500, Warren Weckesser wrote:
> >
> > Hi Warren,
> >
> > Thank you. It works perfectly for me!
> >
> > I took the liberty to change it a little bit: If you initiate
> > DraggableLineInspector with drag_only=True, you have to actually grab
> > the line to move it. You can even set the threshold for grabbing the
> > line with threshold=<any integer>. (Please note that I did not check
> > this feature for BaseXYPlots...)
> >
> > It would be nice to have some feedback for the user when s/he is in the
> > hot zone of the line where it can be dragged by changing the cursor. I
> > tried to initiate DraggableLineInspector with pointer="right arrow" but
> > the cursor does not change when hovering over the line. How can I
> > achieve this?
> >
> > Stephan
> >
> >>         There are a few lines in the DraggableLineInspector's method
> >>         that are not
> >>         needed.  Attached is an even simpler version.
> >>
> >>         Warren
> >>
> >>
> >>         On Thu, Mar 24, 2011 at 3:14 PM, Warren Weckesser <
> >>         [hidden email]> wrote:
> >>
> >>         > Stephan,
> >>         >
> >>         > Here' a "quick and probably dirty" (i.e. barely tested)
> >>         > DraggableLineInspector that subclasses from LineInspector
> >>         and munges its
> >>         > event handling. (For a better implementation, I'd probably
> >>         first refactor
> >>         > LineInspector to better separate the drawing code from the
> >>         event handling
> >>         > code, to make it easier to reuse in a subclass or in a new
> >>         class.)  Also
> >>         > attached is a modified version of
> >>         scalar_image_function_inspector.py as a
> >>         > demonstration. It was changed to use DraggableLineInspector
> >>         as a drop-in
> >>         > replacement for LineInspector; it also doesn't add the
> >>         PanTool to its plot,
> >>         > so only the DraggableLineInspectors handle the
> >>         left-click-drag events.
> >>         >
> >>         > Warren
> >>         >
> >>         >
> >>         >
> >>         > On Thu, Mar 24, 2011 at 2:46 PM, John Wiggins
> >>         <[hidden email]>wrote:
> >>         >
> >>         >> Stephan,
> >>         >>
> >>         >> It's funny that you bring this up because I had the same
> >>         problem the
> >>         >> other day. What I ended up doing was modifying the
> >>         LineInspector tool
> >>         >> by replacing all of the mouse handling code. My version is
> >>         somewhat
> >>         >> limited right now, but there's no reason why it couldn't
> >>         eventually be
> >>         >> improved and added to Chaco.
> >>         >>
> >>         >> - John
> >>         >>
> >>         >> On Thu, Mar 24, 2011 at 12:08 PM, Stephan Helma
> >>         <[hidden email]>
> >>         >> wrote:
> >>         >> > Hi all,
> >>         >> >
> >>         >> > I based an application heavily upon the 2D function
> >>         inspector
> >>         >> > (demo/advanced/scalar_image_function_inspector.py). In
> >>         the current
> >>         >> > implementation the crosshair moves whenever the mouse
> >>         moves and when the
> >>         >> > mouse leaves the window the crosshair vanishes. I tried
> >>         to modify it
> >>         >> > such that I can move the crosshair by dragging the mouse
> >>         (grabbing the
> >>         >> > crosshair with the left mouse button and moving it)
> >>         because I want to
> >>         >> > keep a certain position in the plot for closer
> >>         inspection.
> >>         >> >
> >>         >> > Is there a way to keep the LineInspector tool from
> >>         automatically moving
> >>         >> > with the mouse? Is there any other way to accomplish this
> >>         behaviour?
> >>         >> >
> >>         >> > Any comments are highly welcome.
> >>         >> >
> >>         >> > Stephan
> >>         >> > _______________________________________________
> >>         >> > Enthought-Dev mailing list
> >>         >> > [hidden email]
> >>         >> > https://mail.enthought.com/mailman/listinfo/enthought-dev
> >>         >> >
> >>         >> _______________________________________________
> >>         >> Enthought-Dev mailing list
> >>         >> [hidden email]
> >>         >> https://mail.enthought.com/mailman/listinfo/enthought-dev
> >>         >>
> >>         >
> >>         >
> >
> > _______________________________________________
> > Enthought-Dev mailing list
> > [hidden email]
> > https://mail.enthought.com/mailman/listinfo/enthought-dev
> >
> >

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev

draggable_line_inspector.py (6K) Download Attachment