Monday, May 20, 2013
Google Custom Search

Our Community

Membership Membership:
Latest New User Latest: charmaine.gabat
New Today New Today: 1
New Yesterday New Yesterday: 2
User Count Overall: 28635

People Online People Online:
Visitors Visitors: 6
Members Members: 0
Total Total: 6

Online Now Online Now:

ClearCanvas Community Forums

We've moved our Developer Forums!
To better assist our open source community, we have moved our repository and developer forums to GitHub. You can access the new developer forums on our ClearCanvas GitHub issues board.

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

--
2012-06-07 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.

stewart
Senior Member
Senior Member
Posts:2336

--
2012-06-11 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.
Live and real-time support available for Personal and Team Edition customers
stewart
Senior Member
Senior Member
Posts:2336

--
2012-06-11 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).
Live and real-time support available for Personal and Team Edition customers
You are not authorized to post a reply.

Active Forums 4.1
Copyright 2013 ClearCanvas Inc. All Rights Reserved