⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmmain.pas

📁 用于建筑的测斜数据处理!把测试设备的数据下载电脑,通过本系统进行分析,然后生成所需要的数据!
💻 PAS
📖 第 1 页 / 共 2 页
字号:
//-------------------以下代码是设置stringgrid的右对齐-----------------------////////////
procedure Tmain.StringGridDrawCell(Sender: TObject; ACol, ARow: Integer;         //////
  Rect: TRect; State: TGridDrawState);                                              ///
VAR                                                                                 ///
   vCol, vRow : LongInt;                                                            ///
begin                                                                               ///
        vCol := ACol; vRow := ARow;                                                 ///
        WITH Sender AS TStringGrid, Canvas DO                                       ///
        begin                                                                       ///
                SetTextAlign(Handle, TA_RIGHT);                                     ///
                FillRect(Rect);                                                     ///
                TextRect(Rect, Rect.RIGHT-2, Rect.Top+2,Cells[vCol, vRow]);         ///
        end;                                                                        ///
end;                                                                                ///
//-------------------END代码是设置stringgrid的右对齐--------------------------------///



procedure Tmain.N1Click(Sender: TObject);
begin
edtjz.Text:=filelistbox1.FileName;
end;

procedure Tmain.FileListBox1Click(Sender: TObject);
var
    filename:string;
    data_file:textfile;
    data_str:string;
    i:integer;
begin
        memo_head.Lines.Clear;
        filename:=self.FileListBox1.FileName;
        assignfile(data_file,filename);
        reset(data_file);
        //头文件部分
        for i:=1 to 8 do
        begin
                readln(data_file,data_str);
                memo_head.Lines.Append(copy(data_str,2,length(data_str)-2));  //去调前后的""分号;
        end;
        //一行空格+一行标题+一行单位+一方空格------------总共四行
        for i:=1 to 4 do
                readln(data_file,data_str);
        //以下是数据文件
        i:=1;
        while not eof(data_file) do
        begin
                readln(data_file,data_str);
                stringgrid.cells[1,i]:=copy(data_str,1,pos(',',data_str)-1);
                data_str:=copy(data_str,pos(',',data_str)+1,length(data_str)-pos(',',data_str));
                stringgrid.cells[2,i]:=formatfloat('0.0000',strtofloat(copy(data_str,1,pos(',',data_str)-1)));
                data_str:=copy(data_str,pos(',',data_str)+1,length(data_str)-pos(',',data_str));
                stringgrid.cells[3,i]:=formatfloat('0.0000',strtofloat(copy(data_str,1,pos(',',data_str)-1)));
                data_str:=copy(data_str,pos(',',data_str)+1,length(data_str)-pos(',',data_str));
                stringgrid.cells[4,i]:=formatfloat('0.0000',strtofloat(copy(data_str,1,pos(',',data_str)-1)));
                data_str:=copy(data_str,pos(',',data_str)+1,length(data_str)-pos(',',data_str));
                stringgrid.cells[5,i]:=formatfloat('0.0000',strtofloat(data_str));
                inc(i);
        end;
        stringgrid.ColWidths[1]:=40;
        stringgrid.ColWidths[2]:=65;
        stringgrid.ColWidths[3]:=65;
        stringgrid.ColWidths[4]:=65;
        stringgrid.ColWidths[5]:=65;
        closefile(data_file);
        stringgrid.rowcount:=i;
end;

procedure Tmain.Button1Click(Sender: TObject);
var i,j:integer;
    filename:string;
    data_file:textfile;
    data_str:string;
    dir:string;
    filestr:array[1..100] of string;
    filedate:array[1..100] of string;
begin
if trim(edtjz.Text)<>'' then
begin
        for i:=1 to 100 do      //初始化数组
        begin
                jzdatacl[i].az:=0;
                jzdatacl[i].af:=0;
                jzdatacl[i].bz:=0;
                jzdatacl[i].bf:=0;
                jzdatacl[i].depth:=0;
                self.ProgressBar1.Position:=self.ProgressBar1.Position+2;
        end;
        filename:=trim(edtjz.Text);
        assignfile(data_file,filename);
        reset(data_file);
        for i:=1 to 12 do
                readln(data_file,data_str);
        i:=1;
        while not eof(data_file) do
        begin
                readln(data_file,data_str);
                jzdatacl[i].depth:=strtofloat(copy(data_str,1,pos(',',data_str)-1));
                data_str:=copy(data_str,pos(',',data_str)+1,length(data_str)-pos(',',data_str));
                jzdatacl[i].az:=strtofloat(copy(data_str,1,pos(',',data_str)-1));
                data_str:=copy(data_str,pos(',',data_str)+1,length(data_str)-pos(',',data_str));
                jzdatacl[i].af:=strtofloat(copy(data_str,1,pos(',',data_str)-1));
                data_str:=copy(data_str,pos(',',data_str)+1,length(data_str)-pos(',',data_str));
                jzdatacl[i].bz:=strtofloat(copy(data_str,1,pos(',',data_str)-1));
                data_str:=copy(data_str,pos(',',data_str)+1,length(data_str)-pos(',',data_str));
                jzdatacl[i].bf:=strtofloat(data_str);
                inc(i);
        end;
        depthnum:=i-1;
        for i:=1 to depthnum do
        begin
                jzdatacl[i].fmca:=strtofloat(formatfloat('0.0000',(jzdatacl[i].az+jzdatacl[i].af)*1000));
                jzdatacl[i].fjca:=strtofloat(formatfloat('0.0000',(jzdatacl[i].az-jzdatacl[i].af)/2*1000));
                jzdatacl[i].fmcb:=strtofloat(formatfloat('0.0000',(jzdatacl[i].bz+jzdatacl[i].bf)*1000)); 
                jzdatacl[i].fjcb:=strtofloat(formatfloat('0.0000',(jzdatacl[i].bz-jzdatacl[i].bf)/2*1000));
                self.ProgressBar1.Position:=self.ProgressBar1.Position+2;
        end;
        //最深处的jzdatacl[i].ztxa=jzdatacl[i].fjca;
        jzdatacl[depthnum].ztxa:=jzdatacl[depthnum].fjca;
        jzdatacl[depthnum].ztxb:=jzdatacl[depthnum].fjcb;
        //jzdatacl[i].ztxa是通过最深的jzdatacl[i+1].ztxa通过相加求的;
        for i:=depthnum-1 downto 1 do
        begin
                jzdatacl[i].ztxa:=jzdatacl[i+1].ztxa+jzdatacl[i].fjca;
                jzdatacl[i].ztxb:=jzdatacl[i+1].ztxb+jzdatacl[i].fjcb;
                self.ProgressBar1.Position:=self.ProgressBar1.Position+2;
        end;
        showmessage('生成完毕');
        self.ProgressBar1.Position:=0;
        dir:=extractfiledir(application.ExeName);
        //一下显示是为了是数据文件的排序按照日期
        for i:=0 to filelistbox1.Count-1 do
        begin
                filestr[getfilenum(trim(filelistbox1.Items[i]))]:=filelistbox1.Items[i];
                filename:=filelistbox1.Items[i];
                filedate[getfilenum(trim(filelistbox1.Items[i]))]:=getfiletime(filename);
        end;
        cklistbox.Items.Clear;
        for i:=1 to filelistbox1.Count do
        begin
                cklistbox.Items.Append(filestr[i]+'-'+filedate[i]);
                cklistbox.Checked[i-1]:=true;
        end;
        btncldata.Enabled:=true;
        closefile(data_file);
end
else
begin
        btncldata.Enabled:=false;
        showmessage('请选择基准值');

end;
end;

procedure Tmain.btncldataClick(Sender: TObject);
var
        dir:string;
        i,j,k,a:integer;
        tempstr:string;
        filename:string;
        data_file:textfile;
        data_str:string;
begin
        dir:=self.DirectoryListBox1.Directory;
        self.ProgressBar2.Max:=cklistbox.Items.Count;
        k:=1;
        for i:=0 to cklistbox.Items.Count-1 do
        begin
                if cklistbox.Checked[i] then
                begin
                        self.ProgressBar2.Position:=self.ProgressBar2.Position+1;
                        filename:=dir+'\'+copy(cklistbox.Items[i],1,pos('-',cklistbox.Items[i])-1);
                        assignfile(data_file,filename);
                        reset(data_file);
                        for a:=1 to 4 do
                                readln(data_file,data_str);
                        readln(data_file,data_str);
                        tempstr:=data_str;
                        datestr[k]:=copy(tempstr,pos('ON',tempstr)+2,length(tempstr)-pos('ON',tempstr)+1);
                        for a:=1 to 7 do
                                readln(data_file,data_str);
                        for j:=1 to depthnum do
                        begin
                                readln(data_file,data_str);
                                datadepth[i+1,j]:=strtofloat(copy(data_str,1,pos(',',data_str)-1));
                                data_str:=copy(data_str,pos(',',data_str)+1,length(data_str)-pos(',',data_str));
                                datacl[j].az:=strtofloat(copy(data_str,1,pos(',',data_str)-1));
                                data_str:=copy(data_str,pos(',',data_str)+1,length(data_str)-pos(',',data_str));
                                datacl[j].af:=strtofloat(copy(data_str,1,pos(',',data_str)-1));
                                data_str:=copy(data_str,pos(',',data_str)+1,length(data_str)-pos(',',data_str));
                                datacl[j].bz:=strtofloat(copy(data_str,1,pos(',',data_str)-1));
                                data_str:=copy(data_str,pos(',',data_str)+1,length(data_str)-pos(',',data_str));
                                datacl[j].bf:=strtofloat(data_str);
                                datacl[j].fmca:=strtofloat(formatfloat('0.0000',(datacl[j].az+datacl[j].af)*1000));
                                datacl[j].fjca:=strtofloat(formatfloat('0.0000',(datacl[j].az-datacl[j].af)/2*1000));
                                datapjca[k,j]:=datacl[j].fjca;
                                datapmca[k,j]:=datacl[j].fmca;
                                datacl[j].fmcb:=strtofloat(formatfloat('0.0000',(datacl[j].bz+datacl[j].bf)*1000));
                                datacl[j].fjcb:=strtofloat(formatfloat('0.0000',(datacl[j].bz-datacl[j].bf)/2*1000));
                                datapjcb[k,j]:=datacl[j].fjcb;
                                datapmcb[k,j]:=datacl[j].fmcb;
                        end;
                        closefile(data_file);
                        datacl[depthnum].ztxa:=datacl[depthnum].fjca;
                        datacl[depthnum].ztxb:=datacl[depthnum].fjcb;
                        for j:=depthnum-1 downto 1 do
                        begin
                                datacl[j].ztxa:=datacl[j+1].ztxa+datacl[j].fjca;
                                datazza[k,j]:=datacl[j].ztxa-jzdatacl[j].ztxa;    //max,min
                                dataljca[k,j]:=datacl[j].ztxa;                     //max,min
                                datacl[j].ztxb:=datacl[j+1].ztxb+datacl[j].fjcb;
                                datazzb[k,j]:=datacl[j].ztxb-jzdatacl[j].ztxb;
                                dataljcb[k,j]:=datacl[j].ztxb;
                        end;
                        inc(k);
                        if self.ProgressBar2.Position=self.ProgressBar2.Max then
                                self.ProgressBar2.Position:=0;
                end;
        end;
        datenum:=k-1;
        dataresult.ShowModal;
        self.ProgressBar2.Position:=0;  
end;

procedure Tmain.ToolButton1Click(Sender: TObject);
begin
expressions.ShowModal;
end;

procedure Tmain.ToolButton2Click(Sender: TObject);
begin
AboutBox.ShowModal;
end;

procedure Tmain.ToolButton5Click(Sender: TObject);
begin
chartexp.ShowModal;
end;

procedure Tmain.ToolButton4Click(Sender: TObject);
begin
close;
end;

procedure Tmain.N9Click(Sender: TObject);
begin
regsoft.ShowModal;
end;

procedure Tmain.N7Click(Sender: TObject);
var filename:string;
begin
        try
                self.OpenDialog1.Execute;
                filename:=self.OpenDialog1.FileName;
                openexcel(filename);
                openflag:=true;
        except
                exit;
        end;

end;

procedure Tmain.N3Click(Sender: TObject);
begin
chartexp.ShowModal;
end;

procedure Tmain.N8Click(Sender: TObject);
begin
close;
end;

procedure Tmain.N6Click(Sender: TObject);
begin
expressions.ShowModal;
end;

procedure Tmain.N5Click(Sender: TObject);
begin
aboutbox.ShowModal;
end;

procedure Tmain.FormDestroy(Sender: TObject);
begin
edtjz.Free;
end;

procedure Tmain.FormShow(Sender: TObject);
begin
start.Free;
end;

procedure Tmain.ToolButton3Click(Sender: TObject);
var filename:string;
begin
        try
                self.OpenDialog1.Execute;
                filename:=self.OpenDialog1.FileName;
                openexcel(filename);
                openflag:=true;
        except
                exit;
        end;


end;

procedure Tmain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if openflag then
        fvexcel.quit;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -