2 Replies Latest reply: Mar 3, 2013 7:43 PM by Royt2011 RSS

    how to draw AI annotation on document view during mouse drag

    Royt2011 Community Member

      I created a AI tool plugin, when use the tool, I hope press mouse left key and drag in document view, AI will draw a rectangle, when mouse up, the rectangle disappears, just like ordinary select tool. So I wrote a class to implement AIAnnotation, during mouse drag, just let the annotation been invalidated. but I see nothing displayed. In the draw funtion I just use DefineClipStart() and then draw a rectangle using AIAnnotation drawer, at last call DefineClipEnd(). After mouse up call ClearClip(). Could anyone tell me if I made something wrong? Thanks in advance.

        • 1. Re: how to draw AI annotation on document view during mouse drag
          JLGJeanLouis

          Hello,

           

           

          At the begining of ToolMouseDrag(AIToolMessage* message)

          add the five following lines, so toolAnnotate(AIAnnotatorMessage *message) will be called each the mouse will be dragged.

           

          AIDocumentViewHandle view;

          AIReal zoomview;

          AIErr error=kNoErr;

           

          //To call toolAnnotate.

          error=sDocView->GetNthDocumentView (0, &view);

          error=sDocView->GetDocumentViewZoom(vue, & zoomview);

           

          I used this method in my tools for Illustrator JLG.Dimension for instance and it works well.

           

          JLG.

          • 2. Re: how to draw AI annotation on document view during mouse drag
            Royt2011 Community Member

            Thanks. Actually I don't understand GetDocumentViewZoon here. But I made my tool work during mouse drag:

            {

                sDocumentView->GetNthDocumentView(0, &view);

                if (view)

                {

                    sDocumentView->GetDocumentViewBounds(view, &viewBounds);

                    ArtBoundsToViewPort(view, viewBounds, clipRect);

                    sAnnotator->InvalAnnotationRect(view, &clipRect);

                }

            }

             

            And draw the rectangle in corresponding drawer function.

            {

                sDocumentView->GetDocumentViewBounds(message->view, &viewBounds);

                ArtBoundsToViewPort(message->view, viewBounds, clipRect);

                sAnnotatorDrawer->DefineClipStart(message->drawer);

                sAnnotatorDrawer->DrawRect(message->drawer, clipRect, true);

                sAnnotatorDrawer->DefineClipEnd(message->drawer);

                //

                // here is the code for actual drawing in view port cordinate.

                //

                sAnnotatorDrawer->ClearClip(message->drawer);

            }

             

            But I don't know what's the relation between the 'message->view' fetched from AI and the so called current view gotten by 'GetNthDocumentView(0, &view)'