How to get mouse position in pyton programming?

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

How to get mouse position in pyton programming?

yehe_008
 Hello,

I'm trying to write a semi-automatic segmentation module on Slicer4.1(Linux 64-Bits). An important step of that is choosing sample points by hand and record their coordinate data.

But
unfortunately, I'm a newbie of python and Slicer. I read some python tutorials and " Hello Python Programming tutorial" in last two weeks, so I can write some modules with buttons and check boxes. But I still have no idea how to write a mouse press-release event and archive its position.

Who can give me some tips or simple example codes?

Best regards!

Lisa



_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
Reply | Threaded
Open this post in threaded view
|

Re: How to get mouse position in pyton programming?

Julien Finet
Hi,

By droping points, it creates MRML nodes which contain the position of each point. That location can be retrieved from a python module

Julien.

On Fri, Jun 8, 2012 at 4:40 PM, yehe_008 <[hidden email]> wrote:
 Hello,

I'm trying to write a semi-automatic segmentation module on Slicer4.1(Linux 64-Bits). An important step of that is choosing sample points by hand and record their coordinate data.

But
unfortunately, I'm a newbie of python and Slicer. I read some python tutorials and " Hello Python Programming tutorial" in last two weeks, so I can write some modules with buttons and check boxes. But I still have no idea how to write a mouse press-release event and archive its position.

Who can give me some tips or simple example codes?

Best regards!

Lisa



_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject


_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
Reply | Threaded
Open this post in threaded view
|

Re: How to get mouse position in pyton programming?

Aucoin, Nicole
In reply to this post by yehe_008
Hi Lisa,

I'm replying here and on the developers list since you're developing a
new module. I've recently walked someone else through using the
annotation fiducials to get points from the scene, but I'm not sure how
much detail you'll need. I just saw Julien's note as I was writing this,
and it reminded me to update the developers section here with the
pointers I sent the other developer:
http://www.slicer.org/slicerWiki/index.php/Documentation/4.1/Modules/Annotations#Information_for_Developers

I'd strongly suggest that you use the built in interface to place a
fiducial to translate a mouse click into a 3D location. This will add a
vtkMRMLAnnotationFiducialNode to the scene. You'll have to observe the
scene for node added events and check if it's a fiducial that has been
added. Once you've determined that, you can get the node data and get
the FiducialCoordinates from the newly added node.
You can look at the code in the Annotations module, and check out the
scripted modules in
Slicer4/Modules/Scripted/Scripts
to see how to access fiducials via python.

If you can write a command line interface module that takes in already
created lists of fiducials, that will probably be easier for you. See
the code in:
Slicer4/Modules/CLI/FiducialRegistration

Nicole


On 06/08/2012 04:40 PM, yehe_008 wrote:

> Hello,
>
> I'm trying to write a semi-automatic segmentation module on
> Slicer4.1(Linux 64-Bits). An important step of that is choosing sample
> points by hand and record their coordinate data.
>
> But unfortunately, I'm a newbie of python and Slicer. I read some
> python tutorialsand " Hello Python Programming tutorial" in last two
> weeks, so I can write some modules with buttons and check boxes. But I
> still have no idea how to write a mouse press-release event and
> archive its position.
>
> Who can give me some tips or simple example codes?
>
> Best regards!
>
> Lisa
>
>
>
> _______________________________________________
> slicer-users mailing list
> [hidden email]
> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
> To unsubscribe: send email to [hidden email] with unsubscribe as the subject

_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject