/[projects]/dao/DelphiScanner/Components/tpsystools_4.04/examples/CBuilder/Ex3DArrU.cpp
ViewVC logotype

Annotation of /dao/DelphiScanner/Components/tpsystools_4.04/examples/CBuilder/Ex3DArrU.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2671 - (hide annotations) (download)
Tue Aug 25 18:15:15 2015 UTC (8 years, 9 months ago) by torben
File size: 3275 byte(s)
Added tpsystools component
1 torben 2671 // ***** BEGIN LICENSE BLOCK *****
2     // * Version: MPL 1.1
3     // *
4     // * The contents of this file are subject to the Mozilla Public License Version
5     // * 1.1 (the "License"); you may not use this file except in compliance with
6     // * the License. You may obtain a copy of the License at
7     // * http://www.mozilla.org/MPL/
8     // *
9     // * Software distributed under the License is distributed on an "AS IS" basis,
10     // * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11     // * for the specific language governing rights and limitations under the
12     // * License.
13     // *
14     // * The Original Code is TurboPower SysTools
15     // *
16     // * The Initial Developer of the Original Code is
17     // * TurboPower Software
18     // *
19     // * Portions created by the Initial Developer are Copyright (C) 1996-2002
20     // * the Initial Developer. All Rights Reserved.
21     // *
22     // * Contributor(s):
23     // *
24     // * ***** END LICENSE BLOCK *****
25     //---------------------------------------------------------------------------
26     #include <vcl\vcl.h>
27     #pragma hdrstop
28    
29     #include "Ex3DArrU.h"
30     //---------------------------------------------------------------------------
31     #pragma package(smart_init)
32     #pragma link "StLArr"
33    
34     #pragma resource "*.dfm"
35     TForm1 *Form1;
36     //---------------------------------------------------------------------------
37     __fastcall TMy3D::TMy3D(Cardinal X, Cardinal Y, Cardinal Z)
38     : TStLArray(Z, 4/*sizeof(TStLMatrix)*/)
39     {
40     long row, col, up, Value;
41     TStLMatrix* A;
42    
43     XMax = X;
44     YMax = Y;
45     ZMax = Z;
46    
47     for (up = 0; up < ZMax; up++) {
48     A = new TStLMatrix(XMax, YMax, sizeof(long));
49     for (row = 0; row < YMax; row++) {
50     for (col = 0; col < XMax; col++) {
51     Value = up + 100 * col + 10000 * row;
52     A->Put(row, col, &Value);
53     };
54     };
55     Put(up, &A);
56     };
57     }
58     //---------------------------------------------------------------------------
59     __fastcall TMy3D::~TMy3D(void)
60     {
61     long Up;
62     TStLMatrix* A;
63    
64     for (Up = 0; Up < ZMax; Up++) {
65     Get(Up, &A);
66     if (A)
67     delete A;
68     };
69     }
70     //---------------------------------------------------------------------------
71     __fastcall TForm1::TForm1(TComponent* Owner)
72     : TForm(Owner)
73     {
74     }
75     //---------------------------------------------------------------------------
76     void __fastcall TForm1::FormCreate(TObject *Sender)
77     {
78     My3D = new TMy3D(50, 50, 50);
79     }
80     //---------------------------------------------------------------------------
81     void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
82     {
83     delete My3D;
84     }
85     //---------------------------------------------------------------------------
86     void __fastcall TForm1::Button1Click(TObject *Sender)
87     {
88     long XV, YV, ZV, Value;
89     TStLMatrix *Z;
90    
91     XV = StrToInt(Edit1->Text);
92     YV = StrToInt(Edit2->Text);
93     ZV = StrToInt(Edit3->Text);
94     if ((XV < 0) || (XV >= 50)) {
95     Edit1->Text = "0";
96     XV = StrToInt(Edit1->Text);
97     };
98     if ((YV < 0) || (YV >= 50)) {
99     Edit2->Text = "0";
100     YV = StrToInt(Edit2->Text);
101     };
102     if ((ZV < 0) || (ZV >= 50)) {
103     Edit3->Text = "0";
104     ZV = StrToInt(Edit3->Text);
105     };
106    
107     My3D->Get(ZV, &Z);
108     Z->Get(XV, YV, &Value);
109     Edit4->Text = IntToStr((int)Value);
110     }
111     //---------------------------------------------------------------------------

  ViewVC Help
Powered by ViewVC 1.1.20