Turning layers on and off
Moderators: SDS, support, admin
-
- Posts: 8
- Joined: 10 Oct 2006, 12:08
- Location: United Kingdom
Turning layers on and off
Hi,
I am using the following code snippets to turn layers on and off:
sgImagePlan.LoadFromFile(DBTextPlanFilename.Caption);
sgImagePlan.Align := alNone;
sgImagePlan.Align := alClient;
Fimg := TsgDXFImage(sgImagePlan.Picture.Graphic);
Fimg.Converter.LayerByName(LayerName).Visible := true; //on
or
Fimg.Converter.LayerByName(LayerName).Visible := false; //on
sgImagePlan.Refresh;
It all works fine. But, the refresh call updates all of the drawing, so it's quite a visible flicker. Is there a better way to do this so that a minimalist repaint occurs?
...Andy
I am using the following code snippets to turn layers on and off:
sgImagePlan.LoadFromFile(DBTextPlanFilename.Caption);
sgImagePlan.Align := alNone;
sgImagePlan.Align := alClient;
Fimg := TsgDXFImage(sgImagePlan.Picture.Graphic);
Fimg.Converter.LayerByName(LayerName).Visible := true; //on
or
Fimg.Converter.LayerByName(LayerName).Visible := false; //on
sgImagePlan.Refresh;
It all works fine. But, the refresh call updates all of the drawing, so it's quite a visible flicker. Is there a better way to do this so that a minimalist repaint occurs?
...Andy
Hello Andy,
Set the following property to true:
Sergey.
please post questions to the forum or write to support@cadsofttools.com
Set the following property to true:
Code: Select all
TsgImage.Parent.DoubleBuffered := true;
please post questions to the forum or write to support@cadsofttools.com
-
- Posts: 8
- Joined: 10 Oct 2006, 12:08
- Location: United Kingdom
Hello Andy,
The following example demonstrates how to redarw only necessary part of the drawing:
Two conditions:
<ul><li>You have to know what layer has to be frosen</li>
<li>You have to know the drawing coordinates of the area to be redrawn. Use this coordinates when calling function <b>TsgDXFImage.GetPoint</b></li></ul>
Sergey.
please post questions to the forum or write to support@cadsofttools.com
The following example demonstrates how to redarw only necessary part of the drawing:
Code: Select all
<b>uses</b>
... sgConsts, SGImage, DXFImage, DXFConv;
<b>type</b>
TForm1 = <b>class</b>(TForm)
..
<b>procedure</b> btnSwitchLayerOnOffClick(Sender: TObject);
<b>private</b>
<i><font color="blue">{ Private declarations }</font id="blue"></i>
FImg: TsgDXFImage;
<b>procedure</b> TForm1.btnSwitchLayerOnOffClick(Sender: TObject);
<b>var</b>
I: Integer;
vRect: TRect;
<b>begin
if</b> FImg = <b>nil then</b>
Exit;
<b>for</b> I := <font color="blue">0</font id="blue"> <b>to</b> FImg.Converter.Counts[csLayers] - <font color="blue">1</font id="blue"> <b>do
begin
if</b> TsgDXFLayer(FImg.Converter.Sections[csLayers].Entities[I]).Name = '<font color="blue">LayerToFreeze</font id="blue">' <b>then</b>
TsgDXFLayer(FImg.Converter.Sections[csLayers].Entities[I]).Frozen := <b>not</b> TsgDXFLayer(FImg.Converter.Sections[csLayers].Entities[I]).Frozen;
<b>end</b>;
vRect.TopLeft := FImg.GetPoint(MakeFPoint(<font color="blue">..</font id="blue">, <font color="blue">..</font id="blue">, <font color="blue">..</font id="blue">));
vRect.BottomRight := FImg.GetPoint(MakeFPoint(<font color="blue">..</font id="blue">, <font color="blue">..</font id="blue">, <font color="blue">..</font id="blue">));
vRect.Left := vRect.Left + sgImage1.Left;
vRect.Right := vRect.Right + sgImage1.Left + <font color="blue">1</font id="blue">;
vRect.Top := vRect.Top + sgImage1.Top + <font color="blue">1</font id="blue">;
vRect.Bottom := vRect.Bottom + sgImage1.Top;
InvalidateRect(sgImage1.Parent.Handle, @vRect,false);
UpdateWindow(sgImage1.Parent.Handle)
<b>end</b>;
<ul><li>You have to know what layer has to be frosen</li>
<li>You have to know the drawing coordinates of the area to be redrawn. Use this coordinates when calling function <b>TsgDXFImage.GetPoint</b></li></ul>
Sergey.
please post questions to the forum or write to support@cadsofttools.com