Skip navigation
Currently Being Moderated

Peculiar annotator behavior, please help.

Jun 20, 2011 1:19 PM

I am writting a tool similar to AI selection tool.

User clicks and drags a path, I use the annotator to draw the shape of the path new path to be, user releases the mouse, I stop the annotator and update the path to its new shape.

So, I open AI, start dragging an anchor of a path, I see the annotator draws then clear then draw etc.so you can see it flickers on and off very fast.

So, I switch to a different application, then switch back to AI and start again, thereafer it works, no more flickering.

Why switching back to AI makes it work? I hope I don't have to ask user to switch back to AI for it to work, that would be silly!

Has anybody experience the same thing? Is there a solution?

 

Thank you

 
Replies
  • Currently Being Moderated
    Jun 20, 2011 2:38 PM   in reply to minimum99

    It seems like your annotations may be drawing/erasing themselves too often.  Are you ever forcing a redraw or just drawing the annotations when you get the kCallerAIAnnotation message?

     

    The only painting issue I've really had with annotations is that sometimes they won't update at the right time (for example, every so often when the user clicks on the plug-in tool, the annotation won't draw until the user moves the mouse over the view).  For the most part, all my annotation problems were fixed by invaliding the annotation rectangle.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2011 7:47 AM   in reply to minimum99

    I agree.  The annotations need some work as they don't work correctly all the time.

     

    I invalidate the annotation rectangle in several different places, and together it seems fairly consistent with the other AI tools.  It's invalidated when the tool is selected and deselected and at the end of ToolMouseDown and ToolMouseUp.  When I draw my annotation I keep track of its bounds and use those bounds for the InvalAnnotationsRect call.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2011 8:01 AM   in reply to Meate

    I've had little trouble getting annotators to do what I want but I find that the redraw problems mostly only show up when you start using opacities. As long as I'm working with 100% alpha, you don't see any flicker. I've managed to get even that down to mostly good using a variety of tricks, but I'm still punished if I have alpha if you cause a scroll with the tool (ie. bump up against the side). Then the flicker becomes crazy; my tricks don't work on the slew of rects I get from AI after that.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2011 12:55 PM   in reply to minimum99

    This won't help when the tool starts scrolling the view, but it seemed to help when I checked the incoming annotation message to see if there were any invalidation rects. Specifically, I ignored any where numInvalidationRects was zero. Unfortunately, when you trigger a scroll it gives you extraneous messages that I couldn't figure out how to filter, but I didn't find that to be an issue so long as I had no opacity (or at least, it wasn't very noticeable).

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2011 2:17 PM   in reply to minimum99

    I think at the moment I just always redraw my annotation so long as numInvalidationRects is non-zero. Easier & faster than figuring out if its in an invalidation rect, particularly since AI ignores anything outside that box anyways.

     

    When I say ignore when the rects is zero, I mean in response to kSelectorAIDrawAnnotation. For kSelectorAIInvalAnnotation I just iterate the list and call InvalAnnotationRect() on each (after converting to view coordinates of course). I'm not sure if I have to or not, that's some old code. Maybe its not needed. At any rate, I don't do anything else.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 22, 2011 6:51 AM   in reply to minimum99

    The annotation flickering has nothing to do with threads. It's because it sends multiple draw requests when it should be sending one. So you end up drawing, it clears that and then you draw again. If you're doing something that's requiring additional drawing, you get this repeatedly. The trouble is you can't just ignore the first draw because you might not get two draws, in which case you're screwed. There's a bunch of developers who've had this discussion in a beta program and we're still hoping that the AI team either explains to us how to detect when we really should draw, or that they fix it in the next version of Illustrator.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 22, 2011 10:22 AM   in reply to A. Patterson

    Out of curiosity, do you know if it's possible to draw annotations with partial transparency?  The AIAnnotatorDrawer color functions only take an RGB color, but is there another way to set the color?

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 22, 2011 12:06 PM   in reply to Meate

    There's a SetOpacity() method in CS5. Nothing in CS4 unfortunately.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 22, 2011 2:21 PM   in reply to minimum99

    Hold on. You're clearing, then drawing in the same method? Like this (pseudo-code to follow):

     

    function foo()

    {

      ClearSomeRect();

      DrawSomething();

    }

     

    You're supposed to clearn a rect then wait for a kSelectorAIDrawAnnotation message from AI before drawing. If you're drawing outside of a kSelectorAIDrawAnnotation that might be why you're seeing odd behaviour. It should look more like:

     

    function foo()

    {

      ClearSomeRect();

    }

     

    function CalledWhenDrawMessageFromIllustratorArrives()
    {

      DrawSomething();

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 23, 2011 6:54 AM   in reply to minimum99

    Ok, I was just checking You're right, you shouldn't be able to draw outside of that message, but sometimes people manage strange things!

     

    That said, you shouldn't be clearing inside a draw. You're supposed to be just drawing, not clearing. I'd go back to clearing on drag and try ignoring any draw messages that don't contain invalidation rects. The combination might fix your flicker.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 22, 2011 8:46 AM   in reply to minimum99

    My annotations were flicker-free until this morning, when I added some additional filled rectangles with text on them.  That's when the flickering became really noticeable.  Checking AIAnnotatorMessage->numInvalidationRect for values > 0 fixed the problem completely.  I didn't realize the kCallerAIAnnotation message was being called as much as it was (with values == 0), and my annotations were being drawn each time unnecessarily.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points