[GRASS-dev] Re: wxGUI: MapDisplay mouse events

Vasek,

What are the *.bin files that download from your html links?

Michael
______________________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
Tempe, AZ 85287-2402
USA

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671(SHESC), 480-727-0709 (CSDC)
www: http://csdc.asu.edu, http://shesc.asu.edu
    http://www.public.asu.edu/~cmbarton

On Aug 18, 2011, at 9:00 AM, grass-dev-request@lists.osgeo.org wrote:

Date: Tue, 16 Aug 2011 19:44:11 +0200
From: Wenzeslaus <wenzeslaus@gmail.com>
Subject: [GRASS-dev] Re: wxGUI: MapDisplay mouse events
To: grass-dev@lists.osgeo.org
Message-ID:
  <CABo5uVvujWSzK4CQrKefUxZ7H7bziSs1orYVC6tXiQ_1STFErg@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi list,

I have suggestion about processing mouse events from MapDisplay
(BufferedWindow, GLWindow). In mapdisplay_mouse_events.diff is
implementation of API which should be enough generic to be used by
more than one module.

You can bind your own handler to MapDisplay (MapWindow to be precise)
MouseEvents by public API. It is no longer necessary to edit code in
*mapdisp*.py files. (It is the main advantage.)

I have attached test code (mapdisplay_mouse_events_example.diff). It
gets coordinates from MapDisplay. I think it is
something like Margarita needs in her rstream module. Example is also
included in doc string.

Suggested code works with both 2D (BufferedWindow) and 3D (GLWindow)
and with multiple MapDisplays. It is also possible to override
current cursor.

It doesn't work with Digitizer (VDigitWindow) (no errors but functions
report unsuccessful binds).

The handler can be also unbound with this API. However all other
handlers will be unbounded (and only MapWindow handlers will be
bounded again). Unbind only one handler is not possible in wxPython.

I'm not sure how to handle standard behaviour of mouse events in
MapWindow and its subclasses. Now, functions connected with
mouse['use'] are disabled by setting mouse['use'] to other value. But
there are also other aproaches. Functions can be disabled in wxPython
way by Unbind() or we can let functions to do what they do usualy, but
it will be very confusing, I think.

Vasek
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mapdisplay_mouse_events.diff
Type: text/x-patch
Size: 5626 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20110816/da6ba927/mapdisplay_mouse_events-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mapdisplay_mouse_events_example.diff
Type: text/x-patch
Size: 2018 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20110816/da6ba927/mapdisplay_mouse_events_example-0001.bin

------------------------------

Hi Michael,

it is file with patch
mapdisplay_mouse_events.diff
and simple example how to use API also in diff file
mapdisplay_mouse_events_example.diff

I'm not sure why, but mailing list thinks that MIME type text/x-patch
is a binary file. Then it produces the text and links you see. Some
mail clients can handle it and instead of links they displays
attachments but some cannot.

I don't understand it completely and I don't know how to avoid it.
I'll try to attach the patch with txt suffix to find out how it works.

Vasek

On 17 August 2011 20:06, Michael Barton <michael.barton@asu.edu> wrote:

Vasek,

What are the *.bin files that download from your html links?

Michael

(attachments)

mapdisplay_mouse_events.diff (5.5 KB)

I need to look at this in more detail, but at first glance, it add another method that does things that are already done by other methods.

Michael
______________________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
Tempe, AZ 85287-2402
USA

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671(SHESC), 480-727-0709 (CSDC)
www: http://csdc.asu.edu, http://shesc.asu.edu
    http://www.public.asu.edu/~cmbarton

On Aug 17, 2011, at 2:13 PM, Wenzeslaus wrote:

Hi Michael,

it is file with patch
mapdisplay_mouse_events.diff
and simple example how to use API also in diff file
mapdisplay_mouse_events_example.diff

I'm not sure why, but mailing list thinks that MIME type text/x-patch
is a binary file. Then it produces the text and links you see. Some
mail clients can handle it and instead of links they displays
attachments but some cannot.

I don't understand it completely and I don't know how to avoid it.
I'll try to attach the patch with txt suffix to find out how it works.

Vasek

On 17 August 2011 20:06, Michael Barton <michael.barton@asu.edu> wrote:

Vasek,

What are the *.bin files that download from your html links?

Michael

<mapdisplay_mouse_events.txt>

Michael,

as far as I know, now if you want to get mouse click coordinates from
MapDisplay (MapWindow) you have to edit file mapdisp_window.py (for 2D
mode) and nviz_mapdisp.py (if you also want coordinates from 3D).

With my suggested API there is no need to edit these 'core files'. You
simply register your handler. And it can be done even if you are
writing a addon and you can not change 'core files'.

I don't think that we should change existing code. Some functions
(features) are very connected to MapWindow and very complex and
writing code just into 'core files' is the best solution. But in my
opinion suggested API is the best solution for simple tasks like 'get
mouse click coordinates to MyDialog'.

Vasek

On 17 August 2011 23:21, Michael Barton <Michael.Barton@asu.edu> wrote:

I need to look at this in more detail, but at first glance, it add another method that does things that are already done by other methods.

Michael
______________________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
Tempe, AZ 85287-2402
USA

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671(SHESC), 480-727-0709 (CSDC)
www: http://csdc.asu.edu, http://shesc.asu.edu
http://www.public.asu.edu/~cmbarton

On Aug 17, 2011, at 2:13 PM, Wenzeslaus wrote:

Hi Michael,

it is file with patch
mapdisplay_mouse_events.diff
and simple example how to use API also in diff file
mapdisplay_mouse_events_example.diff

I'm not sure why, but mailing list thinks that MIME type text/x-patch
is a binary file. Then it produces the text and links you see. Some
mail clients can handle it and instead of links they displays
attachments but some cannot.

I don't understand it completely and I don't know how to avoid it.
I'll try to attach the patch with txt suffix to find out how it works.

Vasek

On 17 August 2011 20:06, Michael Barton <michael.barton@asu.edu> wrote:

Vasek,

What are the *.bin files that download from your html links?

Michael

<mapdisplay_mouse_events.txt>

Vasek,

mapdisp_window.mouse['end'] returns a tuple with the window xy coodinates of the mouse click position on a LeftUp event (releasing the mouse button).

mapdisp_window.Pixel2Cell(self.mouse['end']) will return a tuple with the geographic xy coordinates of the mouse click position.

No need to edit mapdisp_window.py

Getting the 3D coordinates is different.

Michael
____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

On Aug 18, 2011, at 12:57 AM, Wenzeslaus wrote:

Michael,

as far as I know, now if you want to get mouse click coordinates from
MapDisplay (MapWindow) you have to edit file mapdisp_window.py (for 2D
mode) and nviz_mapdisp.py (if you also want coordinates from 3D).

With my suggested API there is no need to edit these 'core files'. You
simply register your handler. And it can be done even if you are
writing a addon and you can not change 'core files'.

I don't think that we should change existing code. Some functions
(features) are very connected to MapWindow and very complex and
writing code just into 'core files' is the best solution. But in my
opinion suggested API is the best solution for simple tasks like 'get
mouse click coordinates to MyDialog'.

Vasek

On 17 August 2011 23:21, Michael Barton <Michael.Barton@asu.edu> wrote:

I need to look at this in more detail, but at first glance, it add another method that does things that are already done by other methods.

Michael
______________________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
Tempe, AZ 85287-2402
USA

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671(SHESC), 480-727-0709 (CSDC)
www: http://csdc.asu.edu, http://shesc.asu.edu
               http://www.public.asu.edu/~cmbarton

On Aug 17, 2011, at 2:13 PM, Wenzeslaus wrote:

Hi Michael,

it is file with patch
mapdisplay_mouse_events.diff
and simple example how to use API also in diff file
mapdisplay_mouse_events_example.diff

I'm not sure why, but mailing list thinks that MIME type text/x-patch
is a binary file. Then it produces the text and links you see. Some
mail clients can handle it and instead of links they displays
attachments but some cannot.

I don't understand it completely and I don't know how to avoid it.
I'll try to attach the patch with txt suffix to find out how it works.

Vasek

On 17 August 2011 20:06, Michael Barton <michael.barton@asu.edu> wrote:

Vasek,

What are the *.bin files that download from your html links?

Michael

<mapdisplay_mouse_events.txt>

Yes, right. However you don't know when mouse button was released (in
the case of mouse leftup event). In order to know when this happens
registering (binding) of callback (handler) is necessary. Binding and
unbindig (which is also useful) was not possible with existing public
API.

Without binding user have to - after click on MapDisplay (1) - click
on button in dialog in order to get coordinates to dialog. It works
but it is not much intuitive.

With binding user will first click on button in dialog and coordinates
will appear in dialog immediately after user clicks on MapDisplay. To
implement this behaviour dialog has to listen MapDisplay mouse events.

Vasek

(1) MapDisplay is not the right class name, I mean BufferdWindow or
GLWindow which are childs of MapWindow where the new API is.

On 18 August 2011 21:05, Michael Barton <Michael.Barton@asu.edu> wrote:

Vasek,

mapdisp_window.mouse['end'] returns a tuple with the window xy coodinates of the mouse click position on a LeftUp event (releasing the mouse button).

mapdisp_window.Pixel2Cell(self.mouse['end']) will return a tuple with the geographic xy coordinates of the mouse click position.

No need to edit mapdisp_window.py

Getting the 3D coordinates is different.

Michael
____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

On Aug 18, 2011, at 12:57 AM, Wenzeslaus wrote:

Michael,

as far as I know, now if you want to get mouse click coordinates from
MapDisplay (MapWindow) you have to edit file mapdisp_window.py (for 2D
mode) and nviz_mapdisp.py (if you also want coordinates from 3D).

With my suggested API there is no need to edit these 'core files'. You
simply register your handler. And it can be done even if you are
writing a addon and you can not change 'core files'.

I don't think that we should change existing code. Some functions
(features) are very connected to MapWindow and very complex and
writing code just into 'core files' is the best solution. But in my
opinion suggested API is the best solution for simple tasks like 'get
mouse click coordinates to MyDialog'.

Vasek

On 17 August 2011 23:21, Michael Barton <Michael.Barton@asu.edu> wrote:

I need to look at this in more detail, but at first glance, it add another method that does things that are already done by other methods.

Michael
______________________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
Tempe, AZ 85287-2402
USA

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671(SHESC), 480-727-0709 (CSDC)
www: http://csdc.asu.edu, http://shesc.asu.edu
http://www.public.asu.edu/~cmbarton

On Aug 17, 2011, at 2:13 PM, Wenzeslaus wrote:

Hi Michael,

it is file with patch
mapdisplay_mouse_events.diff
and simple example how to use API also in diff file
mapdisplay_mouse_events_example.diff

I'm not sure why, but mailing list thinks that MIME type text/x-patch
is a binary file. Then it produces the text and links you see. Some
mail clients can handle it and instead of links they displays
attachments but some cannot.

I don't understand it completely and I don't know how to avoid it.
I'll try to attach the patch with txt suffix to find out how it works.

Vasek

On 17 August 2011 20:06, Michael Barton <michael.barton@asu.edu> wrote:

Vasek,

What are the *.bin files that download from your html links?

Michael

<mapdisplay_mouse_events.txt>

I think I see what you're getting at. But it will be good to see what Martin thinks.

Michael
____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

On Aug 18, 2011, at 1:35 PM, Wenzeslaus wrote:

Yes, right. However you don't know when mouse button was released (in
the case of mouse leftup event). In order to know when this happens
registering (binding) of callback (handler) is necessary. Binding and
unbindig (which is also useful) was not possible with existing public
API.

Without binding user have to - after click on MapDisplay (1) - click
on button in dialog in order to get coordinates to dialog. It works
but it is not much intuitive.

With binding user will first click on button in dialog and coordinates
will appear in dialog immediately after user clicks on MapDisplay. To
implement this behaviour dialog has to listen MapDisplay mouse events.

Vasek

(1) MapDisplay is not the right class name, I mean BufferdWindow or
GLWindow which are childs of MapWindow where the new API is.

On 18 August 2011 21:05, Michael Barton <Michael.Barton@asu.edu> wrote:

Vasek,

mapdisp_window.mouse['end'] returns a tuple with the window xy coodinates of the mouse click position on a LeftUp event (releasing the mouse button).

mapdisp_window.Pixel2Cell(self.mouse['end']) will return a tuple with the geographic xy coordinates of the mouse click position.

No need to edit mapdisp_window.py

Getting the 3D coordinates is different.

Michael
____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

On Aug 18, 2011, at 12:57 AM, Wenzeslaus wrote:

Michael,

as far as I know, now if you want to get mouse click coordinates from
MapDisplay (MapWindow) you have to edit file mapdisp_window.py (for 2D
mode) and nviz_mapdisp.py (if you also want coordinates from 3D).

With my suggested API there is no need to edit these 'core files'. You
simply register your handler. And it can be done even if you are
writing a addon and you can not change 'core files'.

I don't think that we should change existing code. Some functions
(features) are very connected to MapWindow and very complex and
writing code just into 'core files' is the best solution. But in my
opinion suggested API is the best solution for simple tasks like 'get
mouse click coordinates to MyDialog'.

Vasek

On 17 August 2011 23:21, Michael Barton <Michael.Barton@asu.edu> wrote:

I need to look at this in more detail, but at first glance, it add another method that does things that are already done by other methods.

Michael
______________________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
Tempe, AZ 85287-2402
USA

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671(SHESC), 480-727-0709 (CSDC)
www: http://csdc.asu.edu, http://shesc.asu.edu
               http://www.public.asu.edu/~cmbarton

On Aug 17, 2011, at 2:13 PM, Wenzeslaus wrote:

Hi Michael,

it is file with patch
mapdisplay_mouse_events.diff
and simple example how to use API also in diff file
mapdisplay_mouse_events_example.diff

I'm not sure why, but mailing list thinks that MIME type text/x-patch
is a binary file. Then it produces the text and links you see. Some
mail clients can handle it and instead of links they displays
attachments but some cannot.

I don't understand it completely and I don't know how to avoid it.
I'll try to attach the patch with txt suffix to find out how it works.

Vasek

On 17 August 2011 20:06, Michael Barton <michael.barton@asu.edu> wrote:

Vasek,

What are the *.bin files that download from your html links?

Michael

<mapdisplay_mouse_events.txt>

Hi,

2011/8/18 Michael Barton <Michael.Barton@asu.edu>:

I think I see what you're getting at. But it will be good to see what Martin thinks.

I think that this contribution makes wxGUI API more robust and usable
especially for coders who are going to write plugins for wxGUI. I have
committed this patch to trunk and devbr6 for testing.

Martin

--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa

Thanks Martin and Vasek

Michael
____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

On Aug 18, 2011, at 2:01 PM, Martin Landa wrote:

Hi,

2011/8/18 Michael Barton <Michael.Barton@asu.edu>:

I think I see what you're getting at. But it will be good to see what Martin thinks.

I think that this contribution makes wxGUI API more robust and usable
especially for coders who are going to write plugins for wxGUI. I have
committed this patch to trunk and devbr6 for testing.

Martin

--
Martin Landa <landa.martin gmail.com> * Studijní program Geodézie a kartografie – GeoWikiCZ