Permalink
Browse files

Continue work on Drawing Objects

  • Loading branch information...
1 parent 06b2a4c commit dddaf4df0755ac2e80db2f336bbd0df4dce5ac60 @dziesig committed Apr 17, 2012
Showing with 109 additions and 49 deletions.
  1. +79 −37 MagicTracks.lpi
  2. +30 −12 drawingframe1.pas
View
@@ -151,8 +151,8 @@
<IsVisibleTab Value="True"/>
<EditorIndex Value="0"/>
<WindowIndex Value="0"/>
- <TopLine Value="265"/>
- <CursorPos X="1" Y="356"/>
+ <TopLine Value="277"/>
+ <CursorPos X="1" Y="291"/>
<UsageCount Value="201"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
@@ -193,7 +193,7 @@
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="1" Y="20"/>
- <UsageCount Value="196"/>
+ <UsageCount Value="197"/>
</Unit15>
<Unit16>
<Filename Value="Notes.txt"/>
@@ -226,7 +226,7 @@
<WindowIndex Value="0"/>
<TopLine Value="6"/>
<CursorPos X="45" Y="77"/>
- <UsageCount Value="183"/>
+ <UsageCount Value="184"/>
</Unit19>
<Unit20>
<Filename Value="internals1.pas"/>
@@ -237,7 +237,7 @@
<WindowIndex Value="0"/>
<TopLine Value="113"/>
<CursorPos X="1" Y="20"/>
- <UsageCount Value="147"/>
+ <UsageCount Value="148"/>
</Unit20>
<Unit21>
<Filename Value="C:\lazarus\lcl\grids.pas"/>
@@ -270,7 +270,7 @@
<WindowIndex Value="0"/>
<TopLine Value="44"/>
<CursorPos X="43" Y="63"/>
- <UsageCount Value="104"/>
+ <UsageCount Value="105"/>
<Loaded Value="True"/>
</Unit24>
<Unit25>
@@ -280,7 +280,7 @@
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="1" Y="20"/>
- <UsageCount Value="104"/>
+ <UsageCount Value="105"/>
</Unit25>
<Unit26>
<Filename Value="rectangularsolid1.pas"/>
@@ -289,7 +289,7 @@
<WindowIndex Value="0"/>
<TopLine Value="80"/>
<CursorPos X="57" Y="95"/>
- <UsageCount Value="98"/>
+ <UsageCount Value="99"/>
</Unit26>
<Unit27>
<Filename Value="sphere1.pas"/>
@@ -298,7 +298,7 @@
<WindowIndex Value="0"/>
<TopLine Value="172"/>
<CursorPos X="47" Y="181"/>
- <UsageCount Value="88"/>
+ <UsageCount Value="89"/>
</Unit27>
<Unit28>
<Filename Value="C:\lazarus\lcl\menus.pp"/>
@@ -336,7 +336,7 @@
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="25" Y="18"/>
- <UsageCount Value="36"/>
+ <UsageCount Value="37"/>
</Unit32>
<Unit33>
<Filename Value="Persistent1.pas"/>
@@ -345,7 +345,7 @@
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="1" Y="20"/>
- <UsageCount Value="36"/>
+ <UsageCount Value="37"/>
</Unit33>
<Unit34>
<Filename Value="README"/>
@@ -363,7 +363,7 @@
<WindowIndex Value="0"/>
<TopLine Value="94"/>
<CursorPos X="37" Y="105"/>
- <UsageCount Value="34"/>
+ <UsageCount Value="35"/>
<Loaded Value="True"/>
</Unit35>
<Unit36>
@@ -373,7 +373,7 @@
<WindowIndex Value="0"/>
<TopLine Value="47"/>
<CursorPos X="14" Y="55"/>
- <UsageCount Value="31"/>
+ <UsageCount Value="32"/>
</Unit36>
<Unit37>
<Filename Value="C:\lazarus\lcl\forms.pp"/>
@@ -384,91 +384,127 @@
<UsageCount Value="12"/>
</Unit37>
</Units>
- <JumpHistory Count="21" HistoryIndex="20">
+ <JumpHistory Count="30" HistoryIndex="29">
<Position1>
- <Filename Value="straightline1.pas"/>
- <Caret Line="35" Column="43" TopLine="17"/>
+ <Filename Value="drawingframe1.pas"/>
+ <Caret Line="365" Column="1" TopLine="343"/>
</Position1>
<Position2>
<Filename Value="drawingframe1.pas"/>
- <Caret Line="133" Column="70" TopLine="119"/>
+ <Caret Line="372" Column="82" TopLine="347"/>
</Position2>
<Position3>
- <Filename Value="straightline1.pas"/>
- <Caret Line="107" Column="47" TopLine="85"/>
+ <Filename Value="drawingframe1.pas"/>
+ <Caret Line="369" Column="1" TopLine="347"/>
</Position3>
<Position4>
<Filename Value="drawingframe1.pas"/>
- <Caret Line="548" Column="29" TopLine="527"/>
+ <Caret Line="367" Column="18" TopLine="350"/>
</Position4>
<Position5>
<Filename Value="drawingframe1.pas"/>
- <Caret Line="549" Column="23" TopLine="538"/>
+ <Caret Line="371" Column="1" TopLine="350"/>
</Position5>
<Position6>
<Filename Value="drawingframe1.pas"/>
- <Caret Line="290" Column="48" TopLine="266"/>
+ <Caret Line="374" Column="1" TopLine="596"/>
</Position6>
<Position7>
<Filename Value="drawingframe1.pas"/>
- <Caret Line="349" Column="1" TopLine="361"/>
+ <Caret Line="302" Column="3" TopLine="300"/>
</Position7>
<Position8>
<Filename Value="drawingframe1.pas"/>
- <Caret Line="302" Column="3" TopLine="300"/>
+ <Caret Line="307" Column="33" TopLine="298"/>
</Position8>
<Position9>
<Filename Value="drawingframe1.pas"/>
- <Caret Line="303" Column="1" TopLine="298"/>
+ <Caret Line="308" Column="1" TopLine="298"/>
</Position9>
<Position10>
<Filename Value="drawingframe1.pas"/>
- <Caret Line="349" Column="1" TopLine="336"/>
+ <Caret Line="306" Column="1" TopLine="298"/>
</Position10>
<Position11>
<Filename Value="drawingframe1.pas"/>
- <Caret Line="350" Column="1" TopLine="336"/>
+ <Caret Line="308" Column="1" TopLine="298"/>
</Position11>
<Position12>
<Filename Value="drawingframe1.pas"/>
- <Caret Line="289" Column="1" TopLine="276"/>
+ <Caret Line="306" Column="1" TopLine="298"/>
</Position12>
<Position13>
<Filename Value="drawingframe1.pas"/>
- <Caret Line="350" Column="59" TopLine="336"/>
+ <Caret Line="308" Column="1" TopLine="298"/>
</Position13>
<Position14>
<Filename Value="drawingframe1.pas"/>
- <Caret Line="349" Column="54" TopLine="336"/>
+ <Caret Line="306" Column="1" TopLine="298"/>
</Position14>
<Position15>
<Filename Value="drawingframe1.pas"/>
- <Caret Line="303" Column="1" TopLine="290"/>
+ <Caret Line="308" Column="1" TopLine="298"/>
</Position15>
<Position16>
<Filename Value="drawingframe1.pas"/>
- <Caret Line="351" Column="27" TopLine="337"/>
+ <Caret Line="306" Column="1" TopLine="298"/>
</Position16>
<Position17>
<Filename Value="drawingframe1.pas"/>
- <Caret Line="352" Column="14" TopLine="337"/>
+ <Caret Line="308" Column="1" TopLine="298"/>
</Position17>
<Position18>
<Filename Value="drawingframe1.pas"/>
- <Caret Line="351" Column="17" TopLine="337"/>
+ <Caret Line="306" Column="1" TopLine="298"/>
</Position18>
<Position19>
<Filename Value="drawingframe1.pas"/>
- <Caret Line="355" Column="3" TopLine="337"/>
+ <Caret Line="308" Column="1" TopLine="298"/>
</Position19>
<Position20>
<Filename Value="drawingframe1.pas"/>
- <Caret Line="356" Column="1" TopLine="395"/>
+ <Caret Line="306" Column="1" TopLine="298"/>
</Position20>
<Position21>
<Filename Value="drawingframe1.pas"/>
- <Caret Line="303" Column="66" TopLine="294"/>
+ <Caret Line="308" Column="1" TopLine="298"/>
</Position21>
+ <Position22>
+ <Filename Value="drawingframe1.pas"/>
+ <Caret Line="306" Column="1" TopLine="298"/>
+ </Position22>
+ <Position23>
+ <Filename Value="drawingframe1.pas"/>
+ <Caret Line="308" Column="1" TopLine="298"/>
+ </Position23>
+ <Position24>
+ <Filename Value="drawingframe1.pas"/>
+ <Caret Line="306" Column="1" TopLine="298"/>
+ </Position24>
+ <Position25>
+ <Filename Value="drawingframe1.pas"/>
+ <Caret Line="308" Column="1" TopLine="298"/>
+ </Position25>
+ <Position26>
+ <Filename Value="drawingframe1.pas"/>
+ <Caret Line="306" Column="1" TopLine="298"/>
+ </Position26>
+ <Position27>
+ <Filename Value="drawingframe1.pas"/>
+ <Caret Line="308" Column="1" TopLine="298"/>
+ </Position27>
+ <Position28>
+ <Filename Value="drawingframe1.pas"/>
+ <Caret Line="306" Column="1" TopLine="298"/>
+ </Position28>
+ <Position29>
+ <Filename Value="drawingframe1.pas"/>
+ <Caret Line="308" Column="1" TopLine="298"/>
+ </Position29>
+ <Position30>
+ <Filename Value="drawingframe1.pas"/>
+ <Caret Line="369" Column="18" TopLine="347"/>
+ </Position30>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>
@@ -504,6 +540,12 @@
</Other>
</CompilerOptions>
<Debugging>
+ <BreakPoints Count="1">
+ <Item1>
+ <Source Value="drawingframe1.pas"/>
+ <Line Value="378"/>
+ </Item1>
+ </BreakPoints>
<Watches Count="2">
<Item1>
<Expression Value="State"/>
View
@@ -284,10 +284,10 @@ procedure TDrawingFrame.PaintDrawingBackground;
Drawing.Draw( Self );
- for X := 0 to PaintBox1.Canvas.Width - 1 do
- for Y := 0 to PaintBox1.Canvas.Height - 1 do
- if DrawingObject(X, Y) <> nil then
- PaintBox1.Canvas.Pixels[X,Y] := clGreen;
+ //for X := 0 to PaintBox1.Canvas.Width - 1 do
+ // for Y := 0 to PaintBox1.Canvas.Height - 1 do
+ // if DrawingObject(X, Y) <> nil then
+ // PaintBox1.Canvas.Pixels[X,Y] := clGreen;
end;
@@ -298,9 +298,13 @@ procedure TDrawingFrame.PaintBox1Paint(Sender: TObject);
end;
procedure TDrawingFrame.PaintBox1Resize(Sender: TObject);
+var
+ L : Integer;
begin
InternalsForm1.PutEvent('Resize ' + Name,Height);
- SetLength( vDrawingObjects, PaintBox1.Canvas.Width * PaintBox1.Canvas.Height)
+ L := PaintBox1.Canvas.Width * PaintBox1.Canvas.Height;
+ SetLength( vDrawingObjects, L );
+ L := Length( VDrawingObjects);
end;
function TDrawingFrame.GetGuide1X: Double;
@@ -346,19 +350,33 @@ procedure TDrawingFrame.Invalidate;
function TDrawingFrame.DrawingObject(X, Y: Integer): TDrawingObject;
var
- H, W, L, S : Integer;
+ H, W : Integer;
begin
Result := nil;
- H := Height; W := Width; L := Length(vDrawingObjects);
- S := X * Y;
- if ((X * Y) < 0) or ((X * Y) > L) then exit;
-// raise Exception.Create('Drawing object bounds check');
- Result := vDrawingObjects[ X * Y ];
+ H := PaintBox1.Height;
+ W := PaintBox1.Width;
+ if (X < 0) or (Y < 0) or (X >= W) or (Y >= H) then
+ raise Exception.Create('Drawing object bounds check');
+ Result := vDrawingObjects[ X + Y * W];
end;
procedure TDrawingFrame.SetDrawingObject(X, Y: Integer; Obj: TDrawingObject);
+var
+ H, W, L, I : Integer;
+ S : String;
begin
- vDrawingObjects[ X * Y ] := Obj;
+ H := PaintBox1.Height;
+ W := PaintBox1.Width;
+ L := Length(vDrawingObjects);
+ I := X + (Y*W);
+ if (X < 0) or (Y < 0) or (X >= W) or (Y >= H) then
+ raise Exception.Create('Drawing object bounds check');
+ try
+ vDrawingObjects[ X + Y * W] := Obj;
+
+ except
+ S := IntToStr(X) + ' ' + IntToStr(Y) + ' ' + IntToStr(H) + ' ' + IntToStr(W);
+ end;
end;
procedure TDrawingFrame.MenuItem1Click(Sender: TObject);

0 comments on commit dddaf4d

Please sign in to comment.