📄 unt_gra.pas
字号:
unit Unt_Gra;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Unt_Base, DB, Grids, DBGrids, StdCtrls, Buttons, ExtCtrls,
DBCtrls, Mask, ActnList;
type
TPointRecord=record
Point_Id:integer;
Graph_Id:integer;
X,Y,Z:single;
Bugle,SWidth,EWidth:single;
end;
TFrm_Gra = class(TFrm_Base)
Panel8: TPanel;
Label6: TLabel;
Label1: TLabel;
OpenCADfile: TSpeedButton;
Label14: TLabel;
DBEdtGraphName: TDBEdit;
EdtCADfilename: TEdit;
CBoxScale: TDBComboBox;
Btn_DealGra: TBitBtn;
BtnGetCADData: TBitBtn;
Btn_Graphic: TBitBtn;
OpenDialog1: TOpenDialog;
RGup_G: TDBRadioGroup;
procedure OpenCADfileClick(Sender: TObject);
procedure Btn_AddClick(Sender: TObject);
procedure BtnGetCADDataClick(Sender: TObject);
procedure Btn_DealGraClick(Sender: TObject);
procedure Btn_GraphicClick(Sender: TObject);
procedure Btn_DelClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
PointR:array of TPointRecord;
TempPoint:TPointRecord;
end;
var
Frm_Gra: TFrm_Gra;
implementation
Uses Unt_Data,Unt_CAD_Pro_Tool,Unt_ReadGra,Hint_Unt;
{$R *.dfm}
procedure TFrm_Gra.OpenCADfileClick(Sender: TObject);
begin
inherited;
if OpenDialog1.Execute then EdtCADfilename.Text:=OpenDialog1.FileName;
end;
procedure TFrm_Gra.Btn_AddClick(Sender: TObject);
var Id:integer;
begin
inherited;
with frm_data.ADOT_Graph do
begin
if not active then open;
Id:=GetId(frm_data.ADOT_Graph,'Graphic_Id');
Append;
fieldbyname('Graphic_Id').asinteger:=Id+1;
fieldbyname('shaft_Id').asinteger:=1;
fieldbyname('IsSimple').AsString:='简单获取(工作面、巷道和断层)';
fieldbyname('Entity').AsInteger:=0;
fieldbyname('IsDeal').AsBoolean:=false;
post;
end;
DBEdtGraphName.SetFocus;
end;
procedure TFrm_Gra.BtnGetCADDataClick(Sender: TObject);
var pathname:string;
i,j:integer;
begin
inherited;
if DBEditIsNull(DBEdtGraphName) or EditIsNull(EdtCADfilename) or DBComboBoxIsNull(CBoxScale)
then begin
showmessage('参数不能为空值,请输入正确的值!');
Read_Graph.Free;
exit;
end;
if MessageDlg('请确认图纸名、图纸文件名、比例尺和获取图形数据方式是否正确,继续吗?',
mtConfirmation, [mbYes, mbNo], 0) = mrNo then exit;
with frm_data.ADOT_Graph do
begin
edit;
fieldbyname('IsDeal').AsBoolean:=false;
post;
end;
Read_Graph:=TRead_Graph.Create;
Read_Graph.IsSimple:=RGup_G.ItemIndex;//图纸读取方式
pathname:=EdtCADfilename.Text;
Hint_Frm:=THint_Frm.Create(self);
Read_Graph.ReadGraph(pathname);//获取图纸信息
//对“点”表中的数据进行排序
with frm_Data.ADOT_Points do
begin
if not active then open;
setlength(PointR,Recordcount+1);
first;
i:=1;
while not eof do
begin
PointR[i].Point_Id:=FieldByname('Point_Id').AsInteger;
PointR[i].Graph_Id:=FieldByname('Graphic_Id').AsInteger;
PointR[i].X:=FieldByName('X').AsFloat;
PointR[i].Y:=FieldByName('Y').AsFloat;
PointR[i].Z:=FieldByName('Z').AsFloat;
PointR[i].Bugle:=FieldByName('Bugle').AsFloat;
PointR[i].EWidth:=FieldByName('EWidth').AsFloat;
PointR[i].SWidth:=FieldByName('SWidth').AsFloat;
next;
i:=i+1;
end;
end;
for i:=1 to High(PointR) do
begin
if PointR[i].Point_Id=i then continue;
for j:=1 to High(PointR) do
begin
if PointR[j].Point_Id=i then
begin
TempPoint.Point_Id:=PointR[i].Point_Id;
TempPoint.Graph_Id:=PointR[i].Graph_Id;
TempPoint.X:=PointR[i].X;
TempPoint.Y:=PointR[i].Y;
TempPoint.Z:=PointR[i].Z;
TempPoint.Bugle:=PointR[i].Bugle;
TempPoint.SWidth:=PointR[i].SWidth;
TempPoint.EWidth:=PointR[i].EWidth;
PointR[i].Point_Id:=PointR[j].Point_Id;
PointR[i].Graph_Id:=PointR[j].Graph_Id;
PointR[i].X:=PointR[j].X;
PointR[i].Y:=PointR[j].Y;
PointR[i].Z:=PointR[j].Z;
PointR[i].Bugle:=PointR[j].Bugle;
PointR[i].SWidth:=PointR[j].SWidth;
PointR[i].EWidth:=PointR[j].EWidth;
PointR[j].Point_Id:=TempPoint.Point_Id;
PointR[j].Graph_Id:=TempPoint.Graph_Id;
PointR[j].X:=TempPoint.X;
PointR[j].Y:=TempPoint.Y;
PointR[j].Z:=TempPoint.Z;
PointR[j].Bugle:=TempPoint.Bugle;
PointR[j].SWidth:=TempPoint.SWidth;
PointR[j].EWidth:=TempPoint.EWidth;
break;
end;
end;
end;
//将排好序的数据写入“点”表中
with frm_data.ADOT_Points do
begin
if not active then open;
if Recordcount>0 then
begin
first;
while not eof do
begin
delete;
end;
end;
for i:=1 to High(PointR) do
begin
append;
FieldByName('Point_Id').AsInteger:=PointR[i].Point_Id;
FieldByName('Graphic_Id').AsInteger:=PointR[i].Graph_Id;
FieldByName('X').AsFloat:=PointR[i].X;
FieldByName('Y').AsFloat:=PointR[i].Y;
FieldByName('Z').AsFloat:=PointR[i].Z;
FieldByName('Bugle').AsFloat:=PointR[i].Bugle;
FieldByName('SWidth').AsFloat:=PointR[i].SWidth;
FieldByName('EWidth').AsFloat:=PointR[i].EWidth;
post;
end;
end;
showmessage('图纸读取完毕');
Read_Graph.Free;
Hint_Frm.Free;
Hint_Frm:=nil;
end;
procedure TFrm_Gra.Btn_DealGraClick(Sender: TObject);
var
i,j:integer;
begin
inherited;
if MessageDlg('确定对该图纸进行处理吗?',
mtConfirmation, [mbYes, mbNo], 0)=mrNo
then exit;
if frm_data.ADOT_Graph.FieldByName('IsDeal').AsBoolean=true then exit;
Read_Graph:=TRead_Graph.Create;
//处理辨识后的数据
Hint_Frm:=THint_Frm.Create(self);
Read_Graph.Deal_Area_lane;
//Hint_Frm.Close;
Hint_Frm.Label1.Caption:='数据处理……';
//Hint_Frm.Button1.Enabled:=true;
Frm_Gra.Refresh;
Hint_Frm.Refresh;
//Hint_Frm.Timer1.Interval:=6000;
//Hint_Frm.Timer1.Enabled:=true;
//Hint_Frm.ShowModal;
//对“点”表中的数据进行排序
with frm_Data.ADOT_Points do
begin
if not active then open;
setlength(PointR,Recordcount+1);
first;
i:=1;
while not eof do
begin
PointR[i].Point_Id:=FieldByname('Point_Id').AsInteger;
PointR[i].Graph_Id:=FieldByname('Graphic_Id').AsInteger;
PointR[i].X:=FieldByName('X').AsFloat;
PointR[i].Y:=FieldByName('Y').AsFloat;
PointR[i].Z:=FieldByName('Z').AsFloat;
PointR[i].Bugle:=FieldByName('Bugle').AsFloat;
PointR[i].EWidth:=FieldByName('EWidth').AsFloat;
PointR[i].SWidth:=FieldByName('SWidth').AsFloat;
next;
i:=i+1;
end;
end;
for i:=1 to High(PointR) do
begin
if PointR[i].Point_Id=i then continue;
for j:=1 to High(PointR) do
begin
if PointR[j].Point_Id=i then
begin
TempPoint.Point_Id:=PointR[i].Point_Id;
TempPoint.Graph_Id:=PointR[i].Graph_Id;
TempPoint.X:=PointR[i].X;
TempPoint.Y:=PointR[i].Y;
TempPoint.Z:=PointR[i].Z;
TempPoint.Bugle:=PointR[i].Bugle;
TempPoint.SWidth:=PointR[i].SWidth;
TempPoint.EWidth:=PointR[i].EWidth;
PointR[i].Point_Id:=PointR[j].Point_Id;
PointR[i].Graph_Id:=PointR[j].Graph_Id;
PointR[i].X:=PointR[j].X;
PointR[i].Y:=PointR[j].Y;
PointR[i].Z:=PointR[j].Z;
PointR[i].Bugle:=PointR[j].Bugle;
PointR[i].SWidth:=PointR[j].SWidth;
PointR[i].EWidth:=PointR[j].EWidth;
PointR[j].Point_Id:=TempPoint.Point_Id;
PointR[j].Graph_Id:=TempPoint.Graph_Id;
PointR[j].X:=TempPoint.X;
PointR[j].Y:=TempPoint.Y;
PointR[j].Z:=TempPoint.Z;
PointR[j].Bugle:=TempPoint.Bugle;
PointR[j].SWidth:=TempPoint.SWidth;
PointR[j].EWidth:=TempPoint.EWidth;
break;
end;
end;
end;
//将排好序的数据写入“点”表中
with frm_data.ADOT_Points do
begin
if not active then open;
if Recordcount>0 then
begin
first;
while not eof do
begin
delete;
end;
end;
for i:=1 to High(PointR) do
begin
append;
FieldByName('Point_Id').AsInteger:=PointR[i].Point_Id;
FieldByName('Graphic_Id').AsInteger:=PointR[i].Graph_Id;
FieldByName('X').AsFloat:=PointR[i].X;
FieldByName('Y').AsFloat:=PointR[i].Y;
FieldByName('Z').AsFloat:=PointR[i].Z;
FieldByName('Bugle').AsFloat:=PointR[i].Bugle;
FieldByName('SWidth').AsFloat:=PointR[i].SWidth;
FieldByName('EWidth').AsFloat:=PointR[i].EWidth;
post;
end;
end;
with frm_data.ADOT_Graph do
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -