XOR drawing function or some sort of alternative.

I'm working on a program in Cocoa that reads data from a server for a experiment at the University and displays it in graphs, but I'm having trouble with one function. I need a crosshair sort of thing so that you can pinpoint data on the graph with your mouse, but all it is currently is a NSBezier that draws lines to the mouse on the X and Y axes and refreshes the whole view.

This is obviously a terrible performer so I was looking for an alternative. I was thinking of using an XOR function to flip the bits where the crosshairs are, but it is apparent from the documentation for Quartz that XOR is no longer supported. Does anyone here know of a way to use XOR or is there a better alternative? All I really need to do is draw a cursor without redrawing the whole display.

PowerMac G5, Mac OS X (10.4.10), 2 Gigs of RAM, 22 In. Screen

Posted on Jun 27, 2007 12:57 PM

Reply
Question marked as ⚠️ Top-ranking reply

Posted on Jun 27, 2007 6:17 PM

To quote the developer docs for NSCursor:

crosshairCursor
Returns the cross-hair system cursor.

+ (NSCursor *)crosshairCursor

Return Value
The cross-hair cursor. This cursor is used for situations when precise location is required (where the lines cross is the hot spot).

Availability
Available in Mac OS X v10.3 and later.
3 replies
Sort By: 
Question marked as ⚠️ Top-ranking reply

Jun 27, 2007 6:17 PM in response to pddenhar

To quote the developer docs for NSCursor:

crosshairCursor
Returns the cross-hair system cursor.

+ (NSCursor *)crosshairCursor

Return Value
The cross-hair cursor. This cursor is used for situations when precise location is required (where the lines cross is the hot spot).

Availability
Available in Mac OS X v10.3 and later.
Reply

Jun 28, 2007 9:05 AM in response to etresoft

The crosshair cursor would be what I needed in any other case, but for this specific application I have 5 columns of graphs and what I need the crosshair to do is display a matching crosshair in each graph.
Here is a screenshot of what I need to do: http://www.imagebucket.net/bucket/18451/Picture_1.jpg

The green lines are what I need to have redraw when the user moves the mouse.

I'll keep the NSCursor in mind if there really is no other way to do this, but the way it is set up now does what it needs to, just not efficiently at all. The function it needs to fulfill is to compare the Y values at the X value where the mouse is.
Reply

Jun 28, 2007 11:38 AM in response to pddenhar

OK. I get it. You seem to know quite a bit more than I assumed.

Apple's Docs say:

In your QuickDraw application, you might have used region updating in conjunction with XOR to minimize the amount of drawing that needed to be done for animation or editing. Quartz does not support XOR, but it does support transparent windows. You create a transparent window, position it on top of your existing window, and then use the overlay to draw your animation or perform your text editing. When you’re done, you throw away the overlay and update the original window, if necessary. See “Using Overlay Windows,” which describes how to provide a selection rectangle (marching ants) around a user-selected shape and how to provide visual feedback when the user drags a selection.

So, I think you need a single transparent window over your entire frame. Draw a single green crosshair like you have been doing. Then, translate that across the screen for all your other graphs. It still seems pretty inefficient. Quickdraw is what I'm familiar with too. I think the idea behind Quartz is to rely on it to do all the drawing.

I don't think my original response is helpful for you at all. I don't think this response is any better. Perhaps search the Quartz-dev mailing list for the answer. If you can't find one, subscribe and post your own message.
Reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

XOR drawing function or some sort of alternative.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.