mirror of
http://gitlab.expertsoft.com.ua/git/expertcad
synced 2026-01-11 22:45:39 +02:00
160 lines
3.7 KiB
ObjectPascal
160 lines
3.7 KiB
ObjectPascal
unit PCLayerDlg;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
|
LayerDial,DlgBase,PCTypesUtils;
|
|
|
|
type
|
|
TPCLayerDlg = class(TDlgBase)
|
|
private
|
|
{ Private declarations }
|
|
Syncing: Boolean;
|
|
Dial : TLayerD;
|
|
Procedure GetCommand( comId: integer; values: string; valueI: integer );
|
|
Function GetVisible:boolean;
|
|
protected
|
|
{ Protected declarations }
|
|
public
|
|
{ Public declarations }
|
|
constructor create(Aowner: TComponent);override;
|
|
procedure show;override;
|
|
Procedure SyncronizeContext;
|
|
Procedure Syncronize;override;
|
|
Procedure Locate(px,py:Integer);override;
|
|
published
|
|
{ Published declarations }
|
|
|
|
Property CadControl;
|
|
Property Visible: Boolean read GetVisible;
|
|
end;
|
|
|
|
implementation
|
|
{$R *.DCR}
|
|
|
|
//uses PowerCad;
|
|
|
|
constructor TPCLayerDlg.create(Aowner: TComponent);
|
|
begin
|
|
inherited create(Aowner);
|
|
dial := TLayerD.create(self);
|
|
oncommand := GetCommand;
|
|
DlgName := 'Layers';
|
|
Syncing := False;
|
|
end;
|
|
|
|
Procedure TPCLayerDlg.GetCommand( comId: integer; values: string; valueI: integer );
|
|
begin
|
|
case ComId of
|
|
0 : //new layer
|
|
begin
|
|
CadControl.NewLayer(values);
|
|
end;
|
|
1 : // delete layer
|
|
begin
|
|
CadControl.DeleteLayerwithNbr(CadControl.ActiveLayer);
|
|
end;
|
|
2 : // Merge Visible
|
|
begin
|
|
CadControl.MergeVisibleLayers;
|
|
end;
|
|
3 : // Merge All
|
|
begin
|
|
CadControl.MergeAllLayers;
|
|
end;
|
|
4 : // Flue All Inactives
|
|
begin
|
|
CadControl.ExGrayLayer(CadControl.ActiveLayer);
|
|
end;
|
|
5 : // Hide All Inactives
|
|
begin
|
|
CadControl.ExHideLayer(CadControl.ActiveLayer);
|
|
end;
|
|
6 : // Select Layer
|
|
begin
|
|
if ValueI >= CadControl.Layers.Count then exit;
|
|
CadControl.ActiveLayer := valueI;
|
|
end;
|
|
7 : // Visible
|
|
begin
|
|
if ValueI >= CadControl.Layers.Count then exit;
|
|
if CadControl.GetLayerInfo(valueI).visible = false
|
|
then
|
|
CadControl.ShowLayer(valueI)
|
|
else
|
|
CadControl.HideLayer(valueI);
|
|
end;
|
|
8 : // Gray
|
|
begin
|
|
if ValueI >= CadControl.Layers.Count then exit;
|
|
if CadControl.GetLayerInfo(valueI).visible = false then exit;
|
|
if CadControl.GetLayerInfo(valueI).Grayed = false
|
|
then
|
|
CadControl.GrayLayer(valueI)
|
|
else
|
|
CadControl.ShowLayer(valueI) ;
|
|
end;
|
|
9 : // Show All
|
|
begin
|
|
CadControl.ShowAllLayers;
|
|
end;
|
|
end;
|
|
SyncronizeContext;
|
|
end;
|
|
|
|
Procedure TPCLayerDlg.SyncronizeContext;
|
|
var a: integer;
|
|
Info : TLayerInfo;
|
|
Count : Integer;
|
|
Begin
|
|
if syncing then exit;
|
|
Syncing := True;
|
|
If assigned(CadControl) then
|
|
begin
|
|
Count := CadControl.LayerCount;
|
|
Dial.Grid.RowCount := Count;
|
|
Dial.ActiveLabel.caption := CadControl.GetLayerInfo(CadControl.ActiveLayer).name;
|
|
For a := 0 to Count - 1 do
|
|
begin
|
|
Info := CadControl.GetLayerInfo(a);
|
|
Dial.Grid.Cells[0,a] := ' '+Info.Name;
|
|
If Info.visible
|
|
then
|
|
Dial.Grid.Cells[1,a] := ' V'
|
|
else
|
|
Dial.Grid.Cells[1,a] := '';
|
|
If Info.Grayed
|
|
then
|
|
Dial.Grid.Cells[2,a] := ' F'
|
|
else
|
|
Dial.Grid.Cells[2,a] := '';
|
|
end;
|
|
end;
|
|
Syncing := False;
|
|
end;
|
|
|
|
Procedure TPCLayerDlg.Show;
|
|
begin
|
|
SyncronizeContext;
|
|
dial.show;
|
|
end;
|
|
|
|
Procedure TPCLayerDlg.Locate(px,py:Integer);
|
|
begin
|
|
Dial.Left := px;
|
|
Dial.Top := py;
|
|
end;
|
|
|
|
Function TPCLayerDlg.GetVisible: Boolean;
|
|
begin
|
|
Result := Dial.Visible;
|
|
end;
|
|
|
|
Procedure TPCLayerDlg.Syncronize;
|
|
begin
|
|
If Dial.Visible then SyncronizeContext;
|
|
end;
|
|
|
|
end.
|