Layer drawing order
Moderators: SDS, support, admin
-
- Posts: 8
- Joined: 10 Oct 2006, 12:08
- Location: United Kingdom
Layer drawing order
Hi,
How can I control the drawing order of the layers? i.e. how can I send a layer to the back of the drawing so that if it's a solid colour, I can still the the other entities on top of it.
...Andy
How can I control the drawing order of the layers? i.e. how can I send a layer to the back of the drawing so that if it's a solid colour, I can still the the other entities on top of it.
...Andy
Hello Andy,
The following code demonstrates how to draw entities from the layer <font color="blue">BottomLayer</font id="blue"> in the first turn (under all the other entities).
Sergey.
please post questions to the forum or write to support@cadsofttools.com
The following code demonstrates how to draw entities from the layer <font color="blue">BottomLayer</font id="blue"> in the first turn (under all the other entities).
Code: Select all
<b>uses</b>
... DXFImage, SGImage, DXFConv, sgConsts;
<b>type</b>
TForm1 = <b>class</b>(TForm)
...
sgImage1: TsgImage;
btnOpen: TButton;
bntLayousOrder: TButton;
<b>procedure</b> btnOpenClick(Sender: TObject);
<b>procedure</b> bntLayousOrderClick(Sender: TObject);
<b>private</b>
FImg: TsgDXFImage;
...
<b>procedure</b> TForm1.btnOpenClick(Sender: TObject);
<b>begin</b>
sgImage1.LoadFromFile(<font color="blue">'c:\Layers.dxf'</font id="blue">);
<b>if</b> sgImage1.Picture.Graphic <b>is</b> TsgDXFImage <b>then</b>
FImg := TsgDXFImage(sgImage1.Picture.Graphic)
<b>else
begin</b>
FImg := <b>nil</b>;
Exit;
<b>end</b>;
sgImage1.Align := alClient;
<b>end</b>;
<b>procedure</b> TForm4.bntLayousOrderClick(Sender: TObject);
<b>var</b>
I, BottomHandle : Integer;
vEntity: TsgDXFEntity;
SortTable: TsgDXFSortEntsTable;
HandleList: TList;
<b>begin
if</b> FImg = <b>nil then</b>
Exit;
HandleList := TList.Create;
SortTable := TsgDXFSortEntsTable.Create;
BottomHandle := MaxInt;
<b>for</b> I := <font color="blue">0</font id="blue"> <b>to</b> FImg.Converter.Counts[csEntities] - <font color="blue">1</font id="blue"> <b>do
begin</b>
vEntity := FImg.Converter.Sections[csEntities].Entities[I];
SortTable.HandlesOld.Add(Pointer(vEntity.Handle));
<b>if</b> vEntity.Layer.Name = <font color="blue">'BottomLayer'</font id="blue"> <b>then</b>
HandleList.Add(vEntity);
<b>if</b> BottomHandle > vEntity.Handle <b>then</b>
BottomHandle := vEntity.Handle;
<b>end</b>;
Inc(BottomHandle);
<b>for</b> I := <font color="blue">0</font id="blue"> <b>to</b> FImg.Converter.Counts[csEntities] - <font color="blue">1</font id="blue"> <b>do
begin</b>
FImg.Converter.Sections[csEntities].Entities[I].Handle := BottomHandle + HandleList.Count + I;
SortTable.HandlesNew.Add(Pointer(TsgDXFEntity(FImg.Converter.Sections[csEntities].Entities[I]).Handle));
<b>end</b>;
<b>for</b> I := <font color="blue">0</font id="blue"> <b>to</b> HandleList.Count - <font color="blue">1</font id="blue"> <b>do</b>
TsgDXFEntity(HandleList[I]).Handle := BottomHandle + I;
FImg.Converter.Sections[csTables].AddEntity(SortTable);
FImg.Converter.Loads(SortTable);
FImg.Converter.SortEntities;
<b>end</b>;
please post questions to the forum or write to support@cadsofttools.com