CAD Import VCL and Rotate

Discuss and ask questions about CAD VCL (Delphi and C++ Builder).

Moderators: SDS, support, admin

Post Reply
tepper
Posts: 3
Joined: 17 Jul 2006, 16:19
Location: Germany

CAD Import VCL and Rotate

Post by tepper » 19 Jul 2006, 16:06

Hi there!

I am using your Example on Rotation from the documentation file. I have somehow translated it to C++ as:

<i>sgDXFImage->Rotate(axisZ,dAngle);
TRect R = Rect(0, 0, sgCADImage->Width, sgCADImage->Height);
sgCADImage->Canvas->StretchDraw(R,sgDXFImage);</i>

The rotation itself works fine, but my problem is that after rotating the image, there is always a part of the image not shown. This means if the width is larger then the height of the image after rotating 90 degrees the upper and lower part of the image is not shown. After rotating another 90 degrees everything is fine. Hope you got an idea of my problem and maybe you can help.

Cheers
Stephan

PoltP
Posts: 8
Joined: 20 Jul 2006, 12:47
Location: Russia
Contact:

Post by PoltP » 20 Jul 2006, 15:34

After CAD drawing's rotation the rect (where CAD darwings is displayed, for example below this is sgPaintBox) size has to be renewed.
We reccomend to follow the next way (based on the CADImportVCL CBuilder Demo Viewer):

Code: Select all

{ Drawing's rotation on 15 degrees clockwise)
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  TsgDXFImage *vImg;
  if (sgPaintBox->Picture->Graphic->InheritsFrom(__classid(TsgDXFImage)))
  {
    vImg = dynamic_cast<TsgDXFImage *>(sgPaintBox->Picture->Graphic);
    vImg->Rotate(axisZ, -15);
    /* Apply new extents */
    vImg->GetExtents();
    // 1 way
    sgPaintBox->Width = vImg->Width;
    sgPaintBox->Height = vImg->Height;
    //...
    // or 2 way
    //sgPaintBox->Align = alClient;
    //...
  }
}
- - -
Yours faithfully,
Pavel Poltavets,
senior developer Soft Gold Ltd.

Post Reply