1
0
mirror of https://bitbucket.org/Dennis07/lina-components.git synced 2025-08-24 21:49:04 +02:00

Version 1.0 DEV 1.16e

Signed-off-by: Dennis07 <den.goehlert@t-online.de>
This commit is contained in:
Dennis07
2017-05-28 23:52:33 +02:00
parent b76acc8ab0
commit edf2a95e7b
15 changed files with 279 additions and 27 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -31,6 +31,7 @@ type
TListBoxManagerMode = (lmmNone,lmmEdit,lmmComboBox);
TDiagramLayout = (dloColumns,dloPoints,dloLines,dloCustom);
TDiagramGridLines = (dglHorizontal,dglVertical,dglBoth);
TDiagramTrendLineMethod = (dtlFirstLast,dtlAvgAll,dtlAvgLeftRight);
{ Ereignisse }
TSplashScreenCreateEvent = procedure(Sender: TObject) of object;
@@ -517,6 +518,13 @@ type
private
{ Private-Deklarationen }
FDiagram: TDiagram;
function GetMinValue: Integer;
function GetMaxValue: Integer;
function GetMidValue: Integer;
function GetAvgValue: Integer;
function GetFirst: Integer;
function GetLast: Integer;
function GetVisibleCount: Integer;
protected
{ Protected-Deklarationen }
procedure Update(Item: TCollectionItem); override;
@@ -524,13 +532,13 @@ type
{ Public-Deklarationen }
constructor Create(ADiagram: TDiagram);
destructor Destroy; override;
function MinValue: Integer;
function MaxValue: Integer;
function MidValue: Integer;
function AvgValue: Integer;
function First: Integer;
function Last: Integer;
function VisibleCount: Integer;
property MinValue: Integer read GetMinValue;
property MaxValue: Integer read GetMaxValue;
property MidValue: Integer read GetMidValue;
property AvgValue: Integer read GetAvgValue;
property First: Integer read GetFirst;
property Last: Integer read GetLast;
property VisibleCount: Integer read GetVisibleCount;
end;
TDiagramScaleValueArtLines = class(TPersistent)
@@ -738,6 +746,34 @@ type
property Negative: TColor read FNegative write SetNegative default clRed;
end;
TDiagramTrendLine = class(TPersistent)
private
{ Private-Deklarationen }
FDiagram: TDiagram;
FVisible: Boolean;
FColor: TColor;
FDotted: Boolean;
FWidth: Integer;
FMethod: TDiagramTrendLineMethod;
{ Methoden }
procedure SetVisible(Value: Boolean);
procedure SetColor(Value: TColor);
procedure SetDotted(Value: Boolean);
procedure SetWidth(Value: Integer);
procedure SetMethod(Value: TDiagramTrendLineMethod);
public
{ Public-Deklarationen }
constructor Create(ADiagram: TDiagram);
destructor Destroy; override;
published
{ Published-Deklarationen }
property Visible: Boolean read FVisible write SetVisible default False;
property Color: TColor read FColor write SetColor default clNone;
property Dotted: Boolean read FDotted write SetDotted default False;
property Width: Integer read FWidth write SetWidth default 1;
property Method: TDiagramTrendLineMethod read FMethod write SetMethod default dtlAvgLeftRight;
end;
{$IFNDEF NO_MULTIPLATFORM}
[ComponentPlatformsAttribute(pidWin32 or pidWin64)]
{$ENDIF}
@@ -752,6 +788,7 @@ type
FScale: TDiagramScale;
FAutoColors: TDiagramAutoColors;
FAlignment: TAlignment;
FTrendLine: TDiagramTrendLine;
{ Ereignisse }
FDrawValueEvent: TDiagramDrawValueEvent;
FCustomDrawValueEvent: TDiagramCustomDrawValueEvent;
@@ -770,6 +807,7 @@ type
procedure DrawGrid; virtual;
procedure DrawValueArtLines; virtual;
procedure DrawCursorArtLines; virtual;
procedure DrawTrendLine; virtual;
procedure DrawValue(Index: Integer); virtual;
procedure DrawColumn(Index: Integer); virtual;
procedure DrawPoint(Index: Integer); virtual;
@@ -829,6 +867,7 @@ type
property Padding: TDiagramPadding read FPadding write SetPadding;
property Scale: TDiagramScale read FScale write SetScale;
property AutoColors: TDiagramAutoColors read FAutoColors write FAutoColors;
property TrendLine: TDiagramTrendLine read FTrendLine write FTrendLine;
end;
{ ShowMessage-Varianten }
@@ -2353,13 +2392,7 @@ begin
inherited;
end;
procedure TDiagramValues.Update(Item: TCollectionItem);
begin
inherited;
FDiagram.Repaint;
end;
function TDiagramValues.MinValue: Integer;
function TDiagramValues.GetMinValue: Integer;
var
Index: Integer;
begin
@@ -2379,7 +2412,7 @@ begin
end;
end;
function TDiagramValues.MaxValue: Integer;
function TDiagramValues.GetMaxValue: Integer;
var
Index: Integer;
begin
@@ -2399,12 +2432,12 @@ begin
end;
end;
function TDiagramValues.MidValue: Integer;
function TDiagramValues.GetMidValue: Integer;
begin
Result := MaxValue - MinValue div 2;
Result := MinValue + (MaxValue - MinValue) div 2;
end;
function TDiagramValues.AvgValue: Integer;
function TDiagramValues.GetAvgValue: Integer;
var
Index: Integer;
begin
@@ -2416,10 +2449,10 @@ begin
Result := Result + (Items[Index] as TDiagramValue).Value;
end;
end;
Result := Result div Index;
Result := Result div VisibleCount;
end;
function TDiagramValues.First: Integer;
function TDiagramValues.GetFirst: Integer;
begin
for Result := 0 to Count - 1 do
begin
@@ -2431,7 +2464,7 @@ begin
Result := -1;
end;
function TDiagramValues.Last: Integer;
function TDiagramValues.GetLast: Integer;
begin
for Result := Count - 1 downto 0 do
begin
@@ -2442,7 +2475,7 @@ begin
end;
end;
function TDiagramValues.VisibleCount: Integer;
function TDiagramValues.GetVisibleCount: Integer;
var
Index: Integer;
begin
@@ -2456,6 +2489,12 @@ begin
end;
end;
procedure TDiagramValues.Update(Item: TCollectionItem);
begin
inherited;
FDiagram.Repaint;
end;
{ ----------------------------------------------------------------------------
TDiagramScaleValueArtLines
---------------------------------------------------------------------------- }
@@ -2809,6 +2848,56 @@ begin
FDiagram.Repaint;
end;
{ ----------------------------------------------------------------------------
TDiagramTrendLine
---------------------------------------------------------------------------- }
constructor TDiagramTrendLine.Create(ADiagram: TDiagram);
begin
inherited Create;
FDiagram := ADiagram;
FVisible := False;
FColor := clNone;
FDotted := False;
FMethod := dtlAvgLeftRight;
end;
destructor TDiagramTrendLine.Destroy;
begin
//...
inherited;
end;
procedure TDiagramTrendLine.SetVisible(Value: Boolean);
begin
FVisible := Value;
FDiagram.Repaint;
end;
procedure TDiagramTrendLine.SetColor(Value: TColor);
begin
FColor := Value;
FDiagram.Repaint;
end;
procedure TDiagramTrendLine.SetDotted(Value: Boolean);
begin
FDotted := Value;
FDiagram.Repaint;
end;
procedure TDiagramTrendLine.SetWidth(Value: Integer);
begin
FWidth := Value;
FDiagram.Repaint;
end;
procedure TDiagramTrendLine.SetMethod(Value: TDiagramTrendLineMethod);
begin
FMethod := Value;
FDiagram.Repaint;
end;
{ ----------------------------------------------------------------------------
TDiagram
---------------------------------------------------------------------------- }
@@ -2825,6 +2914,7 @@ begin
FPadding := TDiagramPadding.Create(Self);
FScale := TDiagramScale.Create(Self);
FAutoColors := TDiagramAutoColors.Create(Self);
FTrendLine := TDiagramTrendLine.Create(Self);
//OnChange-Ereignisse
FCaption.Font.OnChange := PropertyChange;
FScale.Values.Font.OnChange := PropertyChange;
@@ -2838,6 +2928,7 @@ begin
FPadding.Free;
FScale.Free;
FAutoColors.Free;
FTrendLine.Free;
inherited;
end;
@@ -2952,6 +3043,14 @@ begin
end;
end;
end;
if TrendLine.Visible and (FValues.VisibleCount > 1) then
begin
DrawTrendLine;
end;
if Scale.ArtLines.Cursor.Visible then
begin
DrawCursorArtLines;
end;
if Scale.Values.Visible then
begin
for Index := 0 to Values.Count - 1 do
@@ -2959,10 +3058,6 @@ begin
DrawValue(Index);
end;
end;
if Scale.ArtLines.Cursor.Visible then
begin
DrawCursorArtLines;
end;
end;
procedure TDiagram.DrawBackground;
@@ -3175,6 +3270,73 @@ begin
end;
end;
procedure TDiagram.DrawTrendLine;
var
Line: TLine;
Index: Integer;
VisibleIndex: Integer;
LeftY: Integer;
RightY: Integer;
begin
with Canvas do
begin
if TrendLine.Dotted then
begin
Canvas.Pen.Style := psDot;
end else
begin
Canvas.Pen.Style := psSolid;
end;
Canvas.Pen.Color := TrendLine.Color;
Canvas.Pen.Width := TrendLine.Width;
Line := TLine.Create;
case TrendLine.Method of
dtlFirstLast: begin
Line.LoadFromPoints(Point(ValueLeft(Values.First), ValueHeight((Values.Items[Values.First] as TDiagramValue).Value)) ,
Point(ValueLeft(Values.Last ) + ValueWidth,ValueHeight((Values.Items[Values.Last ] as TDiagramValue).Value)));
end;
dtlAvgAll: begin
Line.Offset := ValueHeight(Values.AvgValue);
Line.Slope := 0;
end;
dtlAvgLeftRight: begin
LeftY := 0;
RightY := 0;
Index := 0;
VisibleIndex := 0;
while (Index < Values.Count) and (VisibleIndex < (Values.VisibleCount + 1) div 2) do
begin
if (Values.Items[Index] as TDiagramValue).Visible then
begin
Inc(LeftY,(Values.Items[Index] as TDiagramValue).Value);
Inc(VisibleIndex);
end;
Inc(Index);
end;
LeftY := LeftY div ((Values.VisibleCount + 1) div 2);
if Odd(Values.VisibleCount) then
begin
Dec(VisibleIndex);
Dec(Index);
end;
while (Index < Values.Count) and (VisibleIndex < Values.VisibleCount) do
begin
if (Values.Items[Index] as TDiagramValue).Visible then
begin
Inc(RightY,(Values.Items[Index] as TDiagramValue).Value);
end;
Inc(Index);
end;
RightY := RightY div ((Values.VisibleCount + 1) div 2);
Line.LoadFromPoints(Point( (Width - ZeroWidth) div 4,ValueHeight(LeftY)) ,
Point(Width - (Width - ZeroWidth) div 4,ValueHeight(RightY)));
end;
end;
MoveTo(ZeroWidth,Line.Offset);
LineTo(Width,Line.Y[Width]);
end;
end;
procedure TDiagram.DrawValue(Index: Integer);
begin
with Canvas do

View File

@@ -162,8 +162,23 @@ type
TByteSet = set of Byte;
TCharSet = set of Char;
TVector = TFloatArray;
TVector = TIntegerArray;
TVector1D = array [1..1] of Integer;
TVector2D = array [1..2] of Integer;
TVector3D = array [1..3] of Integer;
TMatrix = array of TVector;
TMatrix1D = array of TVector1D;
TMatrix2D = array of TVector2D;
TMatrix3D = array of TVector3D;
TVectorF = TDoubleArray;
TVectorF1D = array [1..1] of Double;
TVectorF2D = array [1..2] of Double;
TVectorF3D = array [1..3] of Double;
TMatrixF = array of TVectorF;
TMatrixF1D = array of TVectorF1D;
TMatrixF2D = array of TVectorF2D;
TMatrixF3D = array of TVectorF3D;
TRGBTripleArray = array [Word] of TRGBTriple;
PRGBTripleArray = ^TRGBTripleArray;
@@ -180,6 +195,27 @@ type
TLonelyDouble = array [0..0] of Double;
TLonelyExtended = array [0..0] of Extended;
TLine = class
private
{ Private-Deklarationen }
FOffset: Integer;
FSlope: Extended;
function GetY(X: Integer): Integer;
public
{ Public-Deklarationen }
constructor Create(AOffset: Integer; ASlope: Extended); overload;
constructor Create(A,B: TPoint); overload;
destructor Destroy; override;
procedure LoadFromPoints(A,B: TPoint);
function Contains(Point: TPoint): Boolean;
function Subtends(Line: TLine): Boolean;
function Equals(Line: TLine): Boolean;
function Parallel(Line: TLine): Boolean;
property Offset: Integer read FOffset write FOffset default 0;
property Slope: Extended read FSlope write FSlope;
property Y[X: Integer]: Integer read GetY; default;
end;
TCycle = class
private
{ Private-Deklarationen }
@@ -3516,6 +3552,60 @@ begin
//... MUSS NOCH GESCHRIEBEN WERDEN!!!
end;
{ ----------------------------------------------------------------------------
TLine
---------------------------------------------------------------------------- }
constructor TLine.Create(AOffset: Integer; ASlope: Extended);
begin
inherited Create;
FOffset := AOffset;
FSlope := ASlope;
end;
constructor TLine.Create(A,B: TPoint);
begin
inherited Create;
LoadFromPoints(A,B);
end;
destructor TLine.Destroy;
begin
//...
inherited;
end;
procedure TLine.LoadFromPoints(A,B: TPoint);
begin
Slope := (A.Y - B.Y) / (A.X - B.X);
Offset := Round(A.Y - Slope * A.X);
end;
function TLine.GetY(X: Integer): Integer;
begin
Result := Round(Slope * X + Offset);
end;
function TLine.Contains(Point: TPoint): Boolean;
begin
Result := Y[Point.X] = Point.Y;
end;
function TLine.Subtends(Line: TLine): Boolean;
begin
end;
function TLine.Equals(Line: TLine): Boolean;
begin
Result := (Line.Slope = Slope) and (Line.Offset = Offset);
end;
function TLine.Parallel(Line: TLine): Boolean;
begin
Result := Line.Slope = Slope;
end;
{ ----------------------------------------------------------------------------
TCycle
---------------------------------------------------------------------------- }