Browse Source

# revisions: 32730,32817

git-svn-id: branches/fixes_3_0@33798 -
marco 9 years ago
parent
commit
9e6c8dd735
3 changed files with 29 additions and 2 deletions
  1. 2 2
      rtl/objpas/sysutils/syshelp.inc
  2. 2 0
      rtl/objpas/sysutils/syshelph.inc
  3. 25 0
      rtl/objpas/types.pp

+ 2 - 2
rtl/objpas/sysutils/syshelp.inc

@@ -1184,7 +1184,7 @@ begin
     begin
     begin
     T:=SubString(LastSep,Sep-LastSep);
     T:=SubString(LastSep,Sep-LastSep);
 //    Writeln('Examining >',T,'< at pos,',LastSep,' till pos ',Sep);
 //    Writeln('Examining >',T,'< at pos,',LastSep,' till pos ',Sep);
-    If (T<>'') or (not (ExcludeEmpty=Options)) then
+    If (T<>'') or (not (TStringSplitOptions.ExcludeEmpty=Options)) then
       begin
       begin
       MaybeGrow(Len);
       MaybeGrow(Len);
       Result[Len]:=T;
       Result[Len]:=T;
@@ -1267,7 +1267,7 @@ begin
   While (Sep<>-1) and ((ACount=0) or (Len<ACount)) do
   While (Sep<>-1) and ((ACount=0) or (Len<ACount)) do
     begin
     begin
     T:=SubString(LastSep,Sep-LastSep);
     T:=SubString(LastSep,Sep-LastSep);
-    If (T<>'') or (not (ExcludeEmpty=Options)) then
+    If (T<>'') or (not (TStringSplitOptions.ExcludeEmpty=Options)) then
       begin
       begin
       MaybeGrow(Len);
       MaybeGrow(Len);
       Result[Len]:=T;
       Result[Len]:=T;

+ 2 - 0
rtl/objpas/sysutils/syshelph.inc

@@ -31,7 +31,9 @@ Type
   TCompareOption = system.TCompareOption;
   TCompareOption = system.TCompareOption;
   TCompareOptions = system.TCompareOptions;
   TCompareOptions = system.TCompareOptions;
 
 
+{$SCOPEDENUMS ON}
   TStringSplitOptions = (None, ExcludeEmpty);
   TStringSplitOptions = (None, ExcludeEmpty);
+{$SCOPEDENUMS OFF}
 
 
   { TStringHelper }
   { TStringHelper }
 
 

+ 25 - 0
rtl/objpas/types.pp

@@ -120,6 +120,10 @@ type
           class operator <> (const apt1, apt2 : TPointF): Boolean;
           class operator <> (const apt1, apt2 : TPointF): Boolean;
           class operator + (const apt1, apt2 : TPointF): TPointF;
           class operator + (const apt1, apt2 : TPointF): TPointF;
           class operator - (const apt1, apt2 : TPointF): TPointF;
           class operator - (const apt1, apt2 : TPointF): TPointF;
+          class operator - (const apt1 : TPointF): TPointF;
+          class operator * (const apt1, apt2: TPointF): Single; // scalar product
+          class operator * (const apt1: TPointF; afactor: single): TPointF;
+          class operator * (afactor: single; const apt1: TPointF): TPointF;
        end;
        end;
   { TRectF }
   { TRectF }
 
 
@@ -596,6 +600,21 @@ begin
   result:=NOT (SameValue(apt1.x,apt2.x) and Samevalue(apt1.y,apt2.y));
   result:=NOT (SameValue(apt1.x,apt2.x) and Samevalue(apt1.y,apt2.y));
 end;
 end;
 
 
+class operator TPointF. * (const apt1, apt2: TPointF): Single;
+begin
+  result:=apt1.x*apt2.x + apt1.y*apt2.y;
+end;
+
+class operator TPointF. * (afactor: single; const apt1: TPointF): TPointF;
+begin
+  result:=apt1.Scale(afactor);
+end;
+
+class operator TPointF. * (const apt1: TPointF; afactor: single): TPointF;
+begin
+  result:=apt1.Scale(afactor);
+end;
+
 class operator TPointF.+ (const apt1, apt2 : TPointF): TPointF;
 class operator TPointF.+ (const apt1, apt2 : TPointF): TPointF;
 begin
 begin
   result.x:=apt1.x+apt2.x;
   result.x:=apt1.x+apt2.x;
@@ -608,6 +627,12 @@ begin
   result.y:=apt1.y-apt2.y;
   result.y:=apt1.y-apt2.y;
 end;
 end;
 
 
+class operator TPointF. - (const apt1: TPointF): TPointF;
+begin
+  Result.x:=-apt1.x;
+  Result.y:=-apt1.y;
+end;
+
 procedure TPointF.SetLocation(const apt :TPointF);
 procedure TPointF.SetLocation(const apt :TPointF);
 begin
 begin
  x:=apt.x; y:=apt.y;
  x:=apt.x; y:=apt.y;