AnnRotate example for C++ Builder

Note:

This topic is for Document/Medical only.

/*This example uses the AnnFlip, AnnReverse, and AnnRotate methods. To code this example, add a command button named Test to the example you created in Loading and Displaying an Image. For best results when you run the example, draw two objects in opposite corners, and use the right mouse button to select all annotation objects. The command button then lets you cycle through the AnnFlip, AnnReverse, and AnnRotate methods.*/
//Global declarations
LEADRasterAnnotation * pRasterAnn= NULL;
LEADRasterAnnToolBar* pRasterAnnToolbar= NULL;
 
void __fastcall TForm1::Button1Click(TObject *Sender)
{
   CoCreateInstance(CLSID_LEADRasterAnnotation, NULL, CLSCTX_ALL, IID_ILEADRasterAnnotation, (void**)&pRasterAnn);
   CoCreateInstance(CLSID_LEADRasterAnnToolBar, NULL, CLSCTX_ALL, IID_ILEADRasterAnnToolBar, (void**)&pRasterAnnToolbar);
   pRasterAnn->AnnParentRasterView = LEADRasterView1->Raster;
   LEADEventSink1->Connect (pRasterAnn, DIID__LEADRasterAnnotationEvents);
   pRasterAnn->AnnUserMode = ANN_USERMODE_DESIGN ;
}
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
   if (pRasterAnn)
      pRasterAnn->Release ();
   if (pRasterAnnToolbar)
      pRasterAnnToolbar-> Release();
}

void __fastcall TForm1::AnnRotateClick(TObject *Sender)
{
   AnsiString MyCaption;

   MyCaption = AnnRotate->Caption;
   if (MyCaption == "Flip")
   {
      //Flip using the center of the bitmap as the axis->
      pRasterAnn->AnnFlip (True, LEADRasterView1->Raster->BitmapHeight / 2, True);
      AnnRotate ->Caption = "Reverse";
   }
   else
   {
      if (MyCaption == "Reverse")
      {
         //Reverse using the center of the bitmap as the axis->
         pRasterAnn->AnnReverse (True, LEADRasterView1->Raster->BitmapWidth / 2, True);
         AnnRotate->Caption = "Rotate";
      }
      else
      {
         if (MyCaption == "Rotate")
         {
            //Rotate 90 degrees using the center of the bitmap as the axis->
            pRasterAnn->AnnRotate (True, LEADRasterView1->Raster->BitmapWidth / 2, LEADRasterView1->Raster->BitmapHeight / 2, 90, True);
            AnnRotate->Caption = "Flip";
         }
         else
         {
            AnnRotate->Caption = "Flip";
             pRasterAnn->AnnUserMode = ANN_USERMODE_DESIGN;
             pRasterAnn->AnnTool = ANN_TOOL_REDACT;
             ShowMessage ("Draw two objects, use the right mouse button to select all, then click the command button");
         }
      }
   }
}