mirror of
https://github.com/moparisthebest/Simba
synced 2024-12-22 15:28:50 -05:00
Added some stuff.. :)
This commit is contained in:
parent
ca34d1011c
commit
487e5e5144
@ -586,8 +586,8 @@ begin
|
|||||||
OwnerSheet := TTabSheet(TheOwner);
|
OwnerSheet := TTabSheet(TheOwner);
|
||||||
OwnerPage := TPageControl(OwnerSheet.Owner);
|
OwnerPage := TPageControl(OwnerSheet.Owner);
|
||||||
|
|
||||||
if FileExists(MainDir + DS + 'default.simba') then
|
if FileExistsUTF8(SimbaForm.DefScriptPath) then
|
||||||
SynEdit.Lines.LoadFromFile(MainDir + DS + 'default.simba');
|
SynEdit.Lines.LoadFromFile(SimbaForm.DefScriptPath);
|
||||||
StartText:= SynEdit.Lines.text;
|
StartText:= SynEdit.Lines.text;
|
||||||
ScriptDefault:= StartText;
|
ScriptDefault:= StartText;
|
||||||
ScriptName:= 'Untitled';
|
ScriptName:= 'Untitled';
|
||||||
|
@ -355,6 +355,7 @@ type
|
|||||||
procedure HandleOpenFileData;
|
procedure HandleOpenFileData;
|
||||||
procedure HandleWriteFileData;
|
procedure HandleWriteFileData;
|
||||||
procedure HandleScriptStartData;
|
procedure HandleScriptStartData;
|
||||||
|
function GetDefScriptPath: string;
|
||||||
function GetScriptPath : string;
|
function GetScriptPath : string;
|
||||||
function GetExtPath: string;
|
function GetExtPath: string;
|
||||||
function GetFontPath: String;
|
function GetFontPath: String;
|
||||||
@ -365,6 +366,7 @@ type
|
|||||||
function GetShowParamHintAuto: boolean;
|
function GetShowParamHintAuto: boolean;
|
||||||
function GetShowCodeCompletionAuto: Boolean;
|
function GetShowCodeCompletionAuto: Boolean;
|
||||||
function GetSimbaNews: String;
|
function GetSimbaNews: String;
|
||||||
|
procedure SetDefScriptPath(const AValue: string);
|
||||||
procedure SetExtPath(const AValue: string);
|
procedure SetExtPath(const AValue: string);
|
||||||
procedure SetFontPath(const AValue: String);
|
procedure SetFontPath(const AValue: String);
|
||||||
procedure SetIncludePath(const AValue: String);
|
procedure SetIncludePath(const AValue: String);
|
||||||
@ -434,6 +436,7 @@ type
|
|||||||
property PluginPath : string read GetPluginPath write SetPluginPath;
|
property PluginPath : string read GetPluginPath write SetPluginPath;
|
||||||
property ExtPath : string read GetExtPath write SetExtPath;
|
property ExtPath : string read GetExtPath write SetExtPath;
|
||||||
property ScriptDir : string read GetScriptPath write SetScriptPath;
|
property ScriptDir : string read GetScriptPath write SetScriptPath;
|
||||||
|
property DefScriptPath : string read GetDefScriptPath write SetDefScriptPath;
|
||||||
property CurrHighlighter : TSynCustomHighlighter read GetHighlighter;
|
property CurrHighlighter : TSynCustomHighlighter read GetHighlighter;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -594,6 +597,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TSimbaForm.GetDefScriptPath: string;
|
||||||
|
begin
|
||||||
|
result :=LoadSettingDef('Settings/SourceEditor/DefScriptPath', ExpandFileName(MainDir+DS+'default.simba'));
|
||||||
|
end;
|
||||||
|
|
||||||
function TSimbaForm.GetScriptPath: string;
|
function TSimbaForm.GetScriptPath: string;
|
||||||
begin
|
begin
|
||||||
result :=IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Scripts/Path', ExpandFileName(MainDir+DS+'Scripts' + DS)));
|
result :=IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Scripts/Path', ExpandFileName(MainDir+DS+'Scripts' + DS)));
|
||||||
@ -1956,7 +1964,7 @@ end;
|
|||||||
|
|
||||||
procedure TSimbaForm.MenuItemHandbookClick(Sender: TObject);
|
procedure TSimbaForm.MenuItemHandbookClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
OpenURL('http://wizzup.org/static/Simba/doc/ps_handbook/');
|
OpenURL('http://wizzup.org/static/simba/doc/ps_handbook/');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSimbaForm.MenuItemColourHistoryClick(Sender: TObject);
|
procedure TSimbaForm.MenuItemColourHistoryClick(Sender: TObject);
|
||||||
@ -2031,6 +2039,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
FunctionListTimer.Enabled:= false;
|
FunctionListTimer.Enabled:= false;
|
||||||
|
CloseAction := caFree;
|
||||||
FreeAndNil(ExtManager);
|
FreeAndNil(ExtManager);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2182,7 +2191,7 @@ begin
|
|||||||
for i := 0 to high(RecentFileItems) do
|
for i := 0 to high(RecentFileItems) do
|
||||||
RecentFileItems[i].Free;
|
RecentFileItems[i].Free;
|
||||||
if ExtManager <> nil then
|
if ExtManager <> nil then
|
||||||
ExtManager.free;
|
FreeAndNil(extmanager);
|
||||||
Tabs.free;
|
Tabs.free;
|
||||||
Selector.Free;
|
Selector.Free;
|
||||||
Picker.Free;
|
Picker.Free;
|
||||||
@ -2445,6 +2454,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSimbaForm.SetDefScriptPath(const AValue: string);
|
||||||
|
begin
|
||||||
|
SetSetting('Settings/SourceEditor/DefScriptPath',AValue,True);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSimbaForm.SetExtPath(const AValue: string);
|
procedure TSimbaForm.SetExtPath(const AValue: string);
|
||||||
begin
|
begin
|
||||||
SetSetting('Settings/Extensions/Path',AValue,true);
|
SetSetting('Settings/Extensions/Path',AValue,true);
|
||||||
@ -2989,7 +3003,7 @@ begin
|
|||||||
with CurrScript do
|
with CurrScript do
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
SynEdit.Lines.SaveToFile(MainDir + DS + 'default.simba');
|
SynEdit.Lines.SaveToFile(DefScriptPath);
|
||||||
mDebugLn('Script saved as default.');
|
mDebugLn('Script saved as default.');
|
||||||
Result := True;
|
Result := True;
|
||||||
except
|
except
|
||||||
|
@ -70,8 +70,7 @@ end;
|
|||||||
|
|
||||||
function ps_DTMFromString(const DTMString: String): Integer; extdecl;
|
function ps_DTMFromString(const DTMString: String): Integer; extdecl;
|
||||||
begin
|
begin
|
||||||
With CurrThread.Client.MDTMs do
|
Result := CurrThread.Client.MDTMs.StringToDTM(DTMString);
|
||||||
Result := AddDTM(StringToDTM(DTMString));
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ps_FreeDTM(DTM: Integer); extdecl;
|
procedure ps_FreeDTM(DTM: Integer); extdecl;
|
||||||
@ -108,3 +107,8 @@ function ps_SDTMToMDTM(Const DTM: TSDTM): TMDTM;extdecl;
|
|||||||
begin
|
begin
|
||||||
result := SDTMToMDTM(DTM);
|
result := SDTMToMDTM(DTM);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ps_CreateDTMPoint(x,y,c,t,asz : integer; bp : boolean) : TMDTMPoint;
|
||||||
|
begin
|
||||||
|
result := CreateDTMPoint(x,y,c,t,asz,bp);
|
||||||
|
end;
|
||||||
|
@ -91,6 +91,10 @@ begin
|
|||||||
RegisterProperty('Name','String',iptrw);
|
RegisterProperty('Name','String',iptrw);
|
||||||
RegisterMethod('function ToString : string');
|
RegisterMethod('function ToString : string');
|
||||||
RegisterMethod('function Valid:boolean');
|
RegisterMethod('function Valid:boolean');
|
||||||
|
RegisterMethod('procedure DeletePoint( Point : integer);');
|
||||||
|
RegisterMethod('procedure SwapPoint(p1,p2 : integer);');
|
||||||
|
RegisterMethod('procedure MovePoint(fromIndex,toIndex : integer);');
|
||||||
|
RegisterMethod('procedure AddPoint( Point : TMDTMPoint);');
|
||||||
RegisterProperty('Count','Integer',iptrw);
|
RegisterProperty('Count','Integer',iptrw);
|
||||||
RegisterProperty('Points','TMDTMPointArray',iptr);
|
RegisterProperty('Points','TMDTMPointArray',iptr);
|
||||||
end;
|
end;
|
||||||
|
@ -44,6 +44,7 @@ AddFunction(@ps_PrintDTM, 'procedure PrintDTM(const DTM : TMDTM);');
|
|||||||
AddFunction(@ps_GetDTM ,'function GetDTM(index: Integer) : TMDTM');
|
AddFunction(@ps_GetDTM ,'function GetDTM(index: Integer) : TMDTM');
|
||||||
AddFunction(@ps_MDTMToSDTM, 'function MDTMToSDTM(Const DTM: TMDTM): TSDTM;');
|
AddFunction(@ps_MDTMToSDTM, 'function MDTMToSDTM(Const DTM: TMDTM): TSDTM;');
|
||||||
AddFunction(@ps_SDTMToMDTM, 'function SDTMToMDTM(Const DTM: TSDTM): TMDTM;');
|
AddFunction(@ps_SDTMToMDTM, 'function SDTMToMDTM(Const DTM: TSDTM): TMDTM;');
|
||||||
|
AddFunction(@ps_CreateDTMPoint,'function CreateDTMPoint(x,y,c,t,asz : integer; bp : boolean) : TMDTMPoint;');
|
||||||
|
|
||||||
{maths}
|
{maths}
|
||||||
SetCurrSection('Math');
|
SetCurrSection('Math');
|
||||||
|
@ -139,7 +139,11 @@ begin;
|
|||||||
RegisterMethod(@TMDTM.Free,'Free');
|
RegisterMethod(@TMDTM.Free,'Free');
|
||||||
RegisterMethod(@TMDTM.ToString,'ToString');
|
RegisterMethod(@TMDTM.ToString,'ToString');
|
||||||
RegisterMethod(@TMDTM.Valid,'Valid');
|
RegisterMethod(@TMDTM.Valid,'Valid');
|
||||||
|
RegisterMethod(@TMDTM.DeletePoint,'DeletePoint');
|
||||||
|
RegisterMethod(@TMDTM.SwapPoint,'SwapPoint');
|
||||||
|
Registermethod(@TMDTM.MovePoint,'MovePoint');
|
||||||
|
RegisterMethod(@TMDTM.AddPoint,'AddPoint');
|
||||||
RegisterPropertyHelper(@TMDTMCount_R,@TMDTMCount_W,'Count');
|
RegisterPropertyHelper(@TMDTMCount_R,@TMDTMCount_W,'Count');
|
||||||
RegisterPropertyHelper(@TMDTMPoints_R,nil,'Points');
|
RegisterMethod(@TMDTMPoints_R,nil,'Points');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -92,7 +92,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
if compress(BufferString,destlen,PChar(Str),length(str)) = Z_OK then
|
if compress(BufferString,destlen,PChar(Str),length(str)) = Z_OK then
|
||||||
begin
|
begin
|
||||||
setlength(result,Destlen + 4);
|
setlength(result,Destlen + SizeOf(Integer));
|
||||||
PInteger(@result[1])^ := Length(str);
|
PInteger(@result[1])^ := Length(str);
|
||||||
Move(bufferstring[0],result[5],Destlen);
|
Move(bufferstring[0],result[5],Destlen);
|
||||||
end;
|
end;
|
||||||
|
@ -47,6 +47,10 @@ type
|
|||||||
Index : integer;
|
Index : integer;
|
||||||
function ToString : string;
|
function ToString : string;
|
||||||
function Valid : boolean;
|
function Valid : boolean;
|
||||||
|
procedure DeletePoint( Point : integer);
|
||||||
|
procedure SwapPoint(p1,p2 : integer);
|
||||||
|
procedure MovePoint(fromIndex,toIndex : integer);
|
||||||
|
procedure AddPoint( Point : TMDTMPoint);
|
||||||
property PPoints : PMDTMPoint read GetPointerPoints;
|
property PPoints : PMDTMPoint read GetPointerPoints;
|
||||||
property Count : integer read FLen write SetPointCount;
|
property Count : integer read FLen write SetPointCount;
|
||||||
property Points : TMDTMPointArray read FPoints;
|
property Points : TMDTMPointArray read FPoints;
|
||||||
@ -62,7 +66,7 @@ type
|
|||||||
function AddDTM(const d: TMDTM): Integer;overload;
|
function AddDTM(const d: TMDTM): Integer;overload;
|
||||||
function GetDTM(index: Integer) :TMDTM;
|
function GetDTM(index: Integer) :TMDTM;
|
||||||
procedure FreeDTM(DTM: Integer);
|
procedure FreeDTM(DTM: Integer);
|
||||||
function StringToDTM(const S: String): TMDTM;
|
function StringToDTM(const S: String): Integer;
|
||||||
property DTM[Index : integer]: TMDTM read GetDTM; default;
|
property DTM[Index : integer]: TMDTM read GetDTM; default;
|
||||||
constructor Create(Owner: TObject);
|
constructor Create(Owner: TObject);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -72,6 +76,7 @@ implementation
|
|||||||
uses
|
uses
|
||||||
dtmutil, paszlib,
|
dtmutil, paszlib,
|
||||||
client,
|
client,
|
||||||
|
DCPbase64,
|
||||||
graphics, // for TColor
|
graphics, // for TColor
|
||||||
math // for max
|
math // for max
|
||||||
;
|
;
|
||||||
@ -139,41 +144,92 @@ begin
|
|||||||
Result:=StrToInt('$' + HexNum);
|
Result:=StrToInt('$' + HexNum);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMDTMS.StringToDTM(const S: String): TMDTM;
|
function TMDTMS.StringToDTM(const S: String): Integer;
|
||||||
var
|
var
|
||||||
b: PBufferByteArray;
|
b: PBufferByteArray;
|
||||||
|
MDTM : TMDTM;
|
||||||
Source : String;
|
Source : String;
|
||||||
DestLen : longword;
|
DestLen : longword;
|
||||||
i,ii,c : integer;
|
i,ii,c : integer;
|
||||||
DPoints : PMDTMPoint;
|
DPoints : PMDTMPoint;
|
||||||
|
Ptr : Pointer;
|
||||||
|
function ReadInteger : integer;
|
||||||
begin
|
begin
|
||||||
Result := TMDTM.Create;
|
Result := PInteger(ptr)^;
|
||||||
|
inc(ptr,sizeof(integer));
|
||||||
|
end;
|
||||||
|
function ReadBoolean : boolean;
|
||||||
|
begin
|
||||||
|
result := PBoolean(ptr)^;
|
||||||
|
inc(ptr,sizeof(boolean));
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
MDTM := TMDTM.Create;
|
||||||
|
Result := AddDTM(MDTM);
|
||||||
ii := Length(S);
|
ii := Length(S);
|
||||||
if (ii = 0) or (ii mod 2 <> 0) then
|
if (ii = 0) then
|
||||||
Exit;
|
exit;
|
||||||
ii := ii div 2;
|
if S[1] = 'm' then
|
||||||
SetLength(Source,ii);
|
begin
|
||||||
for i := 1 to ii do
|
if ii < 9 then
|
||||||
Source[i] := Chr(HexToInt(S[i * 2 - 1] + S[i * 2]));
|
raise Exception.CreateFMT('Invalid DTM-String passed to StringToDTM: %s',[s]);
|
||||||
DestLen := BufferLen;
|
Writeln(copy(s,2,ii-1));
|
||||||
if uncompress(Bufferstring,Destlen,pchar(Source), ii) = Z_OK then
|
Source := Base64DecodeStr(copy(s,2,ii-1));
|
||||||
begin;
|
i:= PLongint(@source[1])^; //The 4 four bytes should contain the dest len!
|
||||||
if (Destlen mod 36) > 0 then
|
if i < 1 then
|
||||||
raise Exception.CreateFmt('Invalid DTM passed to StringToDTM: %s',[s]);
|
raise Exception.CreateFMT('Invalid DTM-String passed to StringToDTM: %s',[s]);
|
||||||
DestLen := DestLen div 36;
|
DestLen := BufferLen;
|
||||||
Result.Count:= DestLen;
|
ptr := @Source[1 + sizeof(longint)];
|
||||||
DPoints := result.PPoints;
|
if uncompress(BufferString,DestLen,ptr,length(source)-sizeof(integer)) = Z_OK then
|
||||||
b := PBufferByteArray(BufferString);
|
begin
|
||||||
for i := 0 to DestLen - 1 do
|
ptr := BufferString;
|
||||||
|
MDTM.Count:= ReadInteger;
|
||||||
|
ii := MDTM.Count;
|
||||||
|
if (MDTM.Count * TMDTMPointSize) <> (Destlen - SizeOf(integer)) then
|
||||||
|
raise Exception.CreateFMT('Invalid DTM-String passed to StringToDTM: %s',[s]);
|
||||||
|
DPoints := MDTM.PPoints;
|
||||||
|
for i := 0 to ii-1 do
|
||||||
|
DPoints[i].x := ReadInteger;
|
||||||
|
for i := 0 to ii-1 do
|
||||||
|
DPoints[i].y := ReadInteger;
|
||||||
|
for i := 0 to ii-1 do
|
||||||
|
DPoints[i].c := ReadInteger;
|
||||||
|
for i := 0 to ii-1 do
|
||||||
|
DPoints[i].t := ReadInteger;
|
||||||
|
for i := 0 to ii-1 do
|
||||||
|
DPoints[i].asz := ReadInteger;
|
||||||
|
for i := 0 to ii-1 do
|
||||||
|
DPoints[i].bp := ReadBoolean;
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
if (ii mod 2 <> 0) then
|
||||||
|
exit;
|
||||||
|
ii := ii div 2;
|
||||||
|
SetLength(Source,ii);
|
||||||
|
for i := 1 to ii do
|
||||||
|
Source[i] := Chr(HexToInt(S[i * 2 - 1] + S[i * 2]));
|
||||||
|
DestLen := BufferLen;
|
||||||
|
if uncompress(Bufferstring,Destlen,pchar(Source), ii) = Z_OK then
|
||||||
begin;
|
begin;
|
||||||
c := i * 36;
|
if (Destlen mod 36) > 0 then
|
||||||
DPoints[i].x := PInteger(@b^[c+1])^;
|
raise Exception.CreateFMT('Invalid DTM-String passed to StringToDTM: %s',[s]);
|
||||||
DPoints[i].y := PInteger(@b^[c+5])^;
|
DestLen := DestLen div 36;
|
||||||
DPoints[i].asz := PInteger(@b^[c+12])^;
|
MDTM.Count:= DestLen;
|
||||||
// Result.ash[i] := PInteger(@b^[c+16])^;
|
DPoints := MDTM.PPoints;
|
||||||
DPoints[i].c := PInteger(@b^[c+20])^;
|
b := PBufferByteArray(BufferString);
|
||||||
DPoints[i].t := PInteger(@b^[c+24])^;
|
for i := 0 to DestLen - 1 do
|
||||||
DPoints[i].bp := False;
|
begin;
|
||||||
|
c := i * 36;
|
||||||
|
DPoints[i].x := PInteger(@b^[c+1])^;
|
||||||
|
DPoints[i].y := PInteger(@b^[c+5])^;
|
||||||
|
DPoints[i].asz := PInteger(@b^[c+12])^;
|
||||||
|
// DPoints.ash[i] := PInteger(@b^[c+16])^;
|
||||||
|
DPoints[i].c := PInteger(@b^[c+20])^;
|
||||||
|
DPoints[i].t := PInteger(@b^[c+24])^;
|
||||||
|
DPoints[i].bp := False;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -254,9 +310,59 @@ begin
|
|||||||
FLen := AValue;
|
FLen := AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMDTM.ToString: string;
|
//We save the data as arrays for each point (so we can add features to DTMs without having to change
|
||||||
begin
|
//the way the ToString is done..
|
||||||
|
//E.G. A DTM with 3 points would become
|
||||||
|
//LenXXXYYYCCCTTTASZASZASZBPBPBP
|
||||||
|
|
||||||
|
function TMDTM.ToString: string;
|
||||||
|
var
|
||||||
|
i,len : integer;
|
||||||
|
Ptr,Start : Pointer;
|
||||||
|
Destlen : Longword;
|
||||||
|
procedure WriteInteger(int : integer);
|
||||||
|
begin
|
||||||
|
PLongInt(Ptr)^ := int;
|
||||||
|
Inc(ptr,sizeof(int));
|
||||||
|
end;
|
||||||
|
procedure WriteBool(bool : boolean);
|
||||||
|
begin;
|
||||||
|
PBoolean(Ptr)^ := bool;
|
||||||
|
inc(ptr,sizeof(boolean));
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
result := '';
|
||||||
|
if Count < 1 then
|
||||||
|
exit;
|
||||||
|
len := Count * TMDTMPointSize + SizeOf(Integer);
|
||||||
|
Start:= GetMem(len);
|
||||||
|
Ptr := Start;
|
||||||
|
WriteInteger(FLen);
|
||||||
|
for i := 0 to FLen-1 do
|
||||||
|
WriteInteger(FPoints[i].x);
|
||||||
|
for i := 0 to FLen-1 do
|
||||||
|
WriteInteger(FPoints[i].y);
|
||||||
|
for i := 0 to FLen-1 do
|
||||||
|
WriteInteger(FPoints[i].c);
|
||||||
|
for i := 0 to FLen-1 do
|
||||||
|
WriteInteger(FPoints[i].t);
|
||||||
|
for i := 0 to FLen-1 do
|
||||||
|
WriteInteger(FPoints[i].asz);
|
||||||
|
for i := 0 to FLen-1 do
|
||||||
|
WriteBool(FPoints[i].bp);
|
||||||
|
Destlen :=BufferLen;
|
||||||
|
if compress(BufferString,destlen,pchar(start),len) = Z_OK then
|
||||||
|
begin
|
||||||
|
setlength(result,Destlen + SizeOf(Integer));
|
||||||
|
PInteger(@result[1])^ := len;
|
||||||
|
Writeln(len);
|
||||||
|
Move(bufferstring[0],result[1 + sizeof(integer)],Destlen);
|
||||||
|
//We now have Size + Compressed data.. Lets Base64Encrypt it!
|
||||||
|
Result := 'm' + Base64EncodeStr(result);
|
||||||
|
//It now looks like m + base64encoded data! The 'm' is to indicate we used this encryption method.
|
||||||
|
end;
|
||||||
|
Freemem(start,len);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMDTM.Valid: boolean;
|
function TMDTM.Valid: boolean;
|
||||||
@ -264,8 +370,43 @@ begin
|
|||||||
result := false;
|
result := false;
|
||||||
if Count < 1 then
|
if Count < 1 then
|
||||||
exit;
|
exit;
|
||||||
|
NormalizeDTM(self);
|
||||||
result := true;
|
result := true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMDTM.DeletePoint(Point: integer);
|
||||||
|
begin
|
||||||
|
MovePoint(Point,FLen-1);
|
||||||
|
Count := Count - 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMDTM.SwapPoint(p1, p2: integer);
|
||||||
|
var
|
||||||
|
Temp : TMDTMPoint;
|
||||||
|
begin
|
||||||
|
Temp := FPoints[p1];
|
||||||
|
FPoints[p1] := FPoints[p2];
|
||||||
|
FPoints[p2] := Temp;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMDTM.MovePoint(fromIndex, toIndex: integer);
|
||||||
|
var
|
||||||
|
i : integer;
|
||||||
|
begin
|
||||||
|
if fromIndex > toIndex then //We are going down
|
||||||
|
begin
|
||||||
|
for i := fromindex downto Toindex+1 do
|
||||||
|
SwapPoint(i,i-1);
|
||||||
|
end else if fromIndex < toIndex then
|
||||||
|
for i := fromindex to toindex - 1 do
|
||||||
|
SwapPoint(i,i+1);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMDTM.AddPoint(Point: TMDTMPoint);
|
||||||
|
begin
|
||||||
|
Count:= Count + 1;
|
||||||
|
FPoints[FLen-1] := Point;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ uses
|
|||||||
function MDTMToSDTM(Const DTM: TMDTM): TSDTM;
|
function MDTMToSDTM(Const DTM: TMDTM): TSDTM;
|
||||||
function SDTMToMDTM(Const DTM: TSDTM): TMDTM;
|
function SDTMToMDTM(Const DTM: TSDTM): TMDTM;
|
||||||
procedure PrintDTM(const aDTM : TMDTM);
|
procedure PrintDTM(const aDTM : TMDTM);
|
||||||
|
function CreateDTMPoint(x,y,c,t,asz : integer; bp : boolean) : TMDTMPoint;
|
||||||
|
|
||||||
{procedure iniTSDTM(out d: TMDTM; len: integer);}
|
{procedure iniTSDTM(out d: TMDTM; len: integer);}
|
||||||
function ValidMainPointBox(var dtm: TMDTM; const x1, y1, x2, y2: Integer): TBox;
|
function ValidMainPointBox(var dtm: TMDTM; const x1, y1, x2, y2: Integer): TBox;
|
||||||
@ -54,24 +55,16 @@ const
|
|||||||
implementation
|
implementation
|
||||||
uses math,MufasaBase;
|
uses math,MufasaBase;
|
||||||
|
|
||||||
procedure RotatePoints_(Var P: TPointArray; A, cx, cy: Extended);
|
|
||||||
Var
|
|
||||||
I, L: Integer;
|
|
||||||
CosA,SinA : extended;
|
|
||||||
|
|
||||||
Begin
|
|
||||||
L := High(P);
|
|
||||||
CosA := Cos(a);
|
|
||||||
SinA := Sin(a);
|
|
||||||
For I := 0 To L Do
|
|
||||||
Begin
|
|
||||||
P[I].X := Trunc(cx + CosA * (p[i].x - cx) - SinA * (p[i].y - cy));
|
|
||||||
P[I].Y := Trunc(cy + SinA * (p[i].x - cx) + CosA * (p[i].y - cy));
|
|
||||||
End;
|
|
||||||
// I recon it's faster than Point().
|
|
||||||
End;
|
|
||||||
|
|
||||||
|
|
||||||
|
function CreateDTMPoint(x,y,c,t,asz : integer; bp : boolean) : TMDTMPoint;
|
||||||
|
begin
|
||||||
|
result.x := x;
|
||||||
|
result.y := y;
|
||||||
|
result.c := c;
|
||||||
|
result.t := t;
|
||||||
|
result.asz := asz;
|
||||||
|
result.bp := bp;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure PrintDTM(const aDTM : TMDTM);
|
procedure PrintDTM(const aDTM : TMDTM);
|
||||||
var
|
var
|
||||||
|
@ -117,6 +117,9 @@ type
|
|||||||
Asz: Area size;
|
Asz: Area size;
|
||||||
bp: Bad Point;
|
bp: Bad Point;
|
||||||
}
|
}
|
||||||
|
const
|
||||||
|
TMDTMPointSize = 5*SizeOf(integer)+Sizeof(boolean);
|
||||||
|
type
|
||||||
TMDTMPoint = record //TMufasaDTMPoint
|
TMDTMPoint = record //TMufasaDTMPoint
|
||||||
x,y,c,t,asz : integer;
|
x,y,c,t,asz : integer;
|
||||||
bp : boolean;
|
bp : boolean;
|
||||||
|
Loading…
Reference in New Issue
Block a user