Recent

Author Topic: Question about Design or Implentation or Both  (Read 9600 times)

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Question about Design or Implentation or Both
« on: April 07, 2018, 05:46:53 am »
In this project I will be dealing with 100's of labels. Using labels to display both parsed record data and descriptive tag.

A few labels (8)  are on the form permanently and a few more are sorta reserved - (10 - 15).
Right now I call a function passing a record and a TLabel, The record describes the Data item and sub-type. The function looks up the positions for the label, assigns Left, Top and Caption.
   
The rest of the labels will come and go depending what record(s) are selected to be parsed.

I would estimate there would be  between 950 to 1,100 labels if I have to assign a specific label to a parsed data item; i.e.  lbl101.Caption := CenterlineLatitude;

Is there a magic bullet in Free Pascal for this kind of problem.

 
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Question about Design or Implentation or Both
« Reply #1 on: April 07, 2018, 06:24:20 am »
have you tried to use a grid?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Handoko

  • Hero Member
  • *****
  • Posts: 5151
  • My goal: build my own game engine using Lazarus
Re: Question about Design or Implentation or Both
« Reply #2 on: April 07, 2018, 06:29:25 am »
Maybe something like this below. It's only uses 2 TLabels to show the data, which makes maintaining the UI and code much easier especially when there are lots of data to be shown.

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, StdCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     btnPrevious: TButton;
  16.     btnNext: TButton;
  17.     Label1: TLabel;
  18.     Label2: TLabel;
  19.     procedure btnNextClick(Sender: TObject);
  20.     procedure btnPreviousClick(Sender: TObject);
  21.     procedure FormCreate(Sender: TObject);
  22.   end;
  23.  
  24. var
  25.   Form1: TForm1;
  26.   Index: Integer = 1;
  27.  
  28. implementation
  29.  
  30. type
  31.   TMember   = record
  32.     Name    : string;
  33.     Country : string;
  34.     Age     : Byte;
  35.     Job     : string;
  36.   end;
  37.  
  38. var
  39.   Members: array[1..5] of TMember;
  40.  
  41. procedure RefreshData;
  42. var
  43.   S: string;
  44. begin
  45.   with Members[Index] do begin
  46.     Form1.Label2.Caption := Name          + LineEnding +
  47.                             Country       + LineEnding +
  48.                             IntToStr(Age) + LineEnding +
  49.                             Job;
  50.   end;
  51. end;
  52.  
  53. {$R *.lfm}
  54.  
  55. { TForm1 }
  56.  
  57. procedure TForm1.FormCreate(Sender: TObject);
  58. begin
  59.  
  60.   Label1.Alignment := taRightJustify;
  61.   Label1.Caption   := 'Name :'    + LineEnding +
  62.                       'Country :' + LineEnding +
  63.                       'Age :'     + LineEnding +
  64.                       'Job :'     + LineEnding;
  65.  
  66.   Members[1].Name    := 'Linda Rosa';
  67.   Members[1].Country := 'Australia';
  68.   Members[1].Age     := 32;
  69.   Members[1].Job     := 'Accountant';
  70.   Members[2].Name    := 'Billy Graham';
  71.   Members[2].Country := 'Colombia';
  72.   Members[2].Age     := 45;
  73.   Members[2].Job     := 'Lawyer';
  74.   Members[3].Name    := 'Igor Ramolla';
  75.   Members[3].Country := 'Spain';
  76.   Members[3].Age     := 28;
  77.   Members[3].Job     := 'Singer';
  78.   Members[4].Name    := 'Lila Zimnani';
  79.   Members[4].Country := 'Argentina';
  80.   Members[4].Age     := 19;
  81.   Members[4].Job     := 'Student';
  82.   Members[5].Name    := 'Zimmy Chen';
  83.   Members[5].Country := 'Hong Kong';
  84.   Members[5].Age     := 46;
  85.   Members[5].Job     := 'Technician';
  86.  
  87.   RefreshData;
  88.  
  89. end;
  90.  
  91. procedure TForm1.btnPreviousClick(Sender: TObject);
  92. begin
  93.   if Index > Low(Members) then Dec(Index);
  94.   RefreshData;
  95. end;
  96.  
  97. procedure TForm1.btnNextClick(Sender: TObject);
  98. begin
  99.   if Index < High(Members) then Inc(Index);
  100.   RefreshData;
  101. end;
  102.  
  103. end.
« Last Edit: April 07, 2018, 06:35:29 am by Handoko »

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: Question about Design or Implentation or Both
« Reply #3 on: April 07, 2018, 07:02:01 am »
have you tried to use a grid?

Well I laid one of the records out in EXCEL with:

          Label                                 Data
 Rway Center Line Longitude:  47.124585879

for some records it works. For others not so much.
But maybe I don't understand the working of the grid that well.

     
   
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: Question about Design or Implentation or Both
« Reply #4 on: April 07, 2018, 07:05:02 am »
Handako I downloaded and will try to figure it out.

Thanks.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Question about Design or Implentation or Both
« Reply #5 on: April 07, 2018, 07:09:34 am »
have you tried to use a grid?

Well I laid one of the records out in EXCEL with:

          Label                                 Data
 Rway Center Line Longitude:  47.124585879

for some records it works. For others not so much.
But maybe I don't understand the working of the grid that well.
You convert your data to properties and items. The Items are the rows and the properties are the columns titles
eg
Code: [Select]
Line                Longitude         Latitude          No of Airways.
Rway Center Line    47.124585879      xxxxxxx           yyyyyyyyyy
on second thought I might have to take a look on the data in order to see how the RDBMS can be designed.
I'll need a complete sample of the data (as complete as possible).
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: Question about Design or Implentation or Both
« Reply #6 on: April 07, 2018, 07:38:28 am »
have you tried to use a grid?

Well I laid one of the records out in EXCEL with:

          Label                                 Data
 Rway Center Line Longitude:  47.124585879

for some records it works. For others not so much.
But maybe I don't understand the working of the grid that well.
You convert your data to properties and items. The Items are the rows and the properties are the columns titles
eg
Code: [Select]
Line                Longitude         Latitude          No of Airways.
Rway Center Line    47.124585879      xxxxxxx           yyyyyyyyyy
on second thought I might have to take a look on the data in order to see how the RDBMS can be designed.
I'll need a complete sample of the data (as complete as possible).

Can send my project with one apt.dat file. It works now.
or
a PDF doc describing the file and record(s) layout
or both if they will zip to an acceptable size.

FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

dsiders

  • Hero Member
  • *****
  • Posts: 1080
Re: Question about Design or Implentation or Both
« Reply #7 on: April 07, 2018, 07:52:36 am »
have you tried to use a grid?

Well I laid one of the records out in EXCEL with:

          Label                                 Data
 Rway Center Line Longitude:  47.124585879

for some records it works. For others not so much.
But maybe I don't understand the working of the grid that well.
You convert your data to properties and items. The Items are the rows and the properties are the columns titles
eg
Code: [Select]
Line                Longitude         Latitude          No of Airways.
Rway Center Line    47.124585879      xxxxxxx           yyyyyyyyyy
on second thought I might have to take a look on the data in order to see how the RDBMS can be designed.
I'll need a complete sample of the data (as complete as possible).

Can send my project with one apt.dat file. It works now.
or
a PDF doc describing the file and record(s) layout
or both if they will zip to an acceptable size.

Or just point him to the docs.

https://developer.x-plane.com/?article=airport-data-apt-dat-file-format-specification
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: Question about Design or Implentation or Both
« Reply #8 on: April 07, 2018, 07:55:35 am »
Here is v5.
I'm parsing 3 records - but only displaying the first two 1, and 1302's Both of these stay on the form all the time.

ROWCODE        1            (my def is HDRLAND)
ROWCODE   1302           (RC1302)
ROWCODE     100           (RC100)

Install anywhere make a sub dir called files and run.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: Question about Design or Implentation or Both
« Reply #9 on: April 07, 2018, 08:00:53 am »
desider - Do you know about X-Plane or did you just google it.

Yea, you can get a copy of the file spec there.
 
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

dsiders

  • Hero Member
  • *****
  • Posts: 1080
Re: Question about Design or Implentation or Both
« Reply #10 on: April 07, 2018, 08:14:16 am »
desider - Do you know about X-Plane or did you just google it.

Yea, you can get a copy of the file spec there.

I was just curious... having read some of your other posts, so I went to the website. I'm also curious why you don't just use the World Developer. It says it's Open Source.
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: Question about Design or Implentation or Both
« Reply #11 on: April 07, 2018, 08:34:06 am »
Oh, I do use WED (World Editor); I'm not very good at designing airports.

WED dosn't actually parse an apt.dat file. It reads it in and uses it to draw the airport flat on the ground (One Dimensional). Then from there you can add stuff. Buildings, planes, cars. trucks, baggage carts to make it look like a real airport. Some of this stuff is out of this world realistic.

In X-Plane there is an add-on product you can buy called WT3. It provides air traffic at your takeoff and destination airport. In order to do this it needs what is call Taxi Routes. They are invisible lines drawn on the runways, taxiways and ramps which lead to a tie down or gate called a RampStart. Without Taxi Routes WT3 can't generate traffic.

So - Could I parse the apt dot dat file, draw the airport flat on the ground , apply Taxi Routes programmatically.

All of this is probably way over my head.  But I thought I'd try.
 
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

dsiders

  • Hero Member
  • *****
  • Posts: 1080
Re: Question about Design or Implentation or Both
« Reply #12 on: April 07, 2018, 08:46:25 am »
All of this is probably way over my head.  But I thought I'd try.

In 1999, I was captivated by this ultralight kit plane called the DreamWings Valkyrie.

http://www.ultralightnews.com/sunfun99/dreamwings.html

But before I could write a hot little check for the kit, they went bankrupt.

http://www2.ljworld.com/photos/2001/aug/25/21668/

I came across XPlane and thought it would be cool to make an aircraft model for the Valkyrie and flight sim it. Until I saw what was actually involved. 

I hope it works out for you.
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: Question about Design or Implentation or Both
« Reply #13 on: April 07, 2018, 07:52:22 pm »
With my project after you select the data file on the opening Form it displays the parser Form and loads the apt dot dat file in the ListBox. Click on the 100 record it the listbox and it actual parses the record. About 46 fields. I don't display.

Here is where I started looking for a better way to manage the display and all those labels.


FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Question about Design or Implentation or Both
« Reply #14 on: April 08, 2018, 03:38:00 am »
seems I've bitten more than I was expecting. Oh well, I'll download the pdf and take a look after the holidays.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018