Do you have a question?

First Name:
Surname:
Email:
Phone:
Message:
Get Audio Code

Setting cursor to a custom cursor in the selected Tile
Last Post 11 Jun 2012 09:14 AM by stewart. 2 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Not Resolved
Yung-Min CUser is Offline
New Member
New Member
Posts:2

--
07 Jun 2012 06:05 PM  

 I am trying to create an ImageViewer tool which, when activated, would load a custom cursor so that user can use the cursor to probe any specific point in the selected image. The cursor would revert back to the default arrow when the tool is deactivated.

I create a class by inheriting ClearCanvas.ImageViewer.BaseTools.MouseImageViewerTool and load my custom cursor in the constructor:

  this.CursorToken = new CursorToken("MyCursor.png");

By doing this, my cursor would only appear when the mouse button is down and it would revert back to the default arrow as soon as the mouse button is released. I try to set the CursorToken in the Track() method, but it didn't work. Any suggestion on how I can implement this?

Thanks in advance for your help.

stewartUser is Offline
Veteran Member
Veteran Member
Posts:2359

--
11 Jun 2012 09:12 AM  
Hmm, that approach doesn't really mesh well with the assumptions the ClearCanvas framework makes about how tools use cursors. Because the architecture is plugin-based, and plugins from different people can interact in unexpected ways, the framework is purposely rigid when it comes to mouse interactions. Basically, we expect that a tool must be active (e.g. checked in the toolbar and has captured the mouse through at least one mouse down) before it can change the cursor. This is because there can be multiple mouse tools checked in the toolbar (one per mouse button) and unless one has capture, there's no way to decide which one takes precedence.

However, if it's necessary, it can be done. You would need to inject a graphic into the scene for each presentation image that constantly sets the cursor, but only when your tool is active/checked (Make sure to always return true from Track). Your graphic must implement IMouseButtonHandler and ICursorTokenProvider. Note, too, that your proposed behaviour will interfere with any ROIs drawn on the image because they also change the cursor to indicate to the user when the ROI can be moved/stretched. To circumvent that, you'd need to make sure your graphic is always "above" the ROIs in the scene (e.g. last in the overlays list).

Anyway, I can't say I'd recommend you do any of this because I don't think it'll work well, especially when it comes to potential interactions with other graphics and tools. But, it is possible.
stewartUser is Offline
Veteran Member
Veteran Member
Posts:2359

--
11 Jun 2012 09:14 AM  
Oh, just re-read your post, and if one mouse down is ok to activate your tool, you can just keep returning true from your Stop override to maintain capture, and you will keep capture until your tool is done doing whatever it needs to do. This is how all the ROIs work, for example (the require 2 clicks from the user to draw).
You are not authorized to post a reply.

Active Forums 4.1