Einzelnen Beitrag anzeigen

Benutzerbild von LoCrux
LoCrux

Registriert seit: 5. Mär 2007
Ort: Gwang-Yang-City
48 Beiträge
 
Delphi 2009 Enterprise
 
#1

[D7] PropertyEditor für TCollection durch eigenen ersetzen.

  Alt 5. Mär 2007, 15:06
Hallo @All (bin neu hier) und hab gleich ne Frage.

Ich schreibe seit geraumer Zeit an ein paar Komponenten rum. Da ich für eine Firma arbeite, die Schwerlasttransporter (genauer gesagt sog. SSC - Ship-Section-Carrier so ab 300t Last aufwärts) herstellt, will ich die Transporter als Delphi-Komponenten schreiben.

Für Interessierte : TITAN-Elevating Transporter

Pi Mal Daumen aufbau der Struktur.....

1.) TArea [Zeichenfläche abgeleitet von TPaintBox32 des Graphics32 Package] u.a. mit PROPERTY TPoleItems (TCollection) hält die u.a. die Komponente TPole (TComponent).

2.) TPole(TComponent) [ist für die Steuerung der einzelnen Achsen eines Transporters / Transporterverbandes zuständig]
und hält u.a. die PROPERTY TTransporterItems (TCollection) welche die einzelnen TTransporter (TComponent) hält...

3.) ..um es kurz zu halten, hat jeder Transporter wieder eine Collection die die einzelen Achsen hält.

Das ganze sieht dann in der IDE so aus (hier nur ein Transporter dargestellt):

http://www.djbommel.de/Pictures/BILD-IDE.jpg

Als fertiges Proggi (hier nur ein Test Projekt - Darstellung Finit [Drehmomente]):

http://www.djbommel.de/Pictures/BILD-RUN.jpg

Nur zum Beispiel der INTERFACE teil der UNIT TTransporters.pas

Delphi-Quellcode:
UNIT TTransporters;

INTERFACE

{$R TTransporters.dcr}
{$REALCOMPATIBILITY ON}

USES
  TMasses,
  TAxles,
  TPoints,
  TAngles,
  TGeometrys,
  TitanConstants,
  Classes,
  Graphics;

TYPE

//----------------------------------------------------------------------------//
// TO KNOW THEM ALL //
//----------------------------------------------------------------------------//

   TTransporterItem = CLASS;
   TTransporterItemClass = CLASS OF TTransporterItem;
   TTransporterItems = CLASS;
   TTransporterItemsPtr = ^TTransporterItems;
   TTransporter = CLASS;

//----------------------------------------------------------------------------//
// TTransporterItem = CLASS(TCollectionItem) //
//----------------------------------------------------------------------------//

  TTransporterItem = CLASS(TCollectionItem)
  PRIVATE
    FItem : TTransporter;
  PROTECTED
    PROCEDURE DoOnChangeInt(Sender:TObject);
  PUBLIC
    CONSTRUCTOR Create(ACollection: TCollection); OVERRIDE;
    DESTRUCTOR Destroy; OVERRIDE;
    PROCEDURE SetItem(Item:TTransporter);
  PUBLISHED
    PROPERTY Index;
    PROPERTY Item:TTransporter READ FItem WRITE SetItem;
  END;

//----------------------------------------------------------------------------//
// TTransporterItems = CLASS(TCollection) //
//----------------------------------------------------------------------------//

  TTransporterItems = CLASS(TCollection)
  PRIVATE
    FOwner : TPersistent;
    FOnChangeInt : TNotifyEvent;
    FUNCTION GetItem(Index:Integer):TTransporterItem;
    PROCEDURE SetItem(Index:Integer;Value:TTransporterItem);
  PROTECTED
    FUNCTION GetOwner: TPersistent;
    PROCEDURE Update(Item: TCollectionItem); OVERRIDE;
    PROCEDURE SubmitChangeInternal(Sender:TObject);
  PUBLIC
    // Whole Class //
    CLASS PROCEDURE SetInternalNotificationOnly(VAR porter:TTransporterItems;Notifi:TNotifyEvent);
    // This Instance //
    CONSTRUCTOR Create(AOwner: TPersistent; ItemClass: TTransporterItemClass);
    DESTRUCTOR Destroy; OVERRIDE;
    FUNCTION Add:TTransporterItem;
    PROCEDURE CreateAddSet(AOwner:TComponent;VAR Porter:TTransporter);
    PROCEDURE UpdateOnBoundsChange;
    PROPERTY Items[Index:Integer]:TTransporterItem READ GetItem WRITE SetItem; //default;
  PUBLISHED
  END;

//----------------------------------------------------------------------------//
// TTransporter = CLASS(TComponent) //
//----------------------------------------------------------------------------//

  TTransporter = CLASS(TComponent)
  PRIVATE
    //-- For Handeling The Collection In TPoles ------------------------------//
    FCollection : TCollection;
    FIndex : INTEGER;
    //-- PUBLISHED PROPERTIES
    FAngle : TGlobalAngleClass;
    FAxles : TAxleItems;
    FCenter : TGlobalPointClass;
    FDriveMode : TDriveMode;
    FShow : BOOLEAN;
    FWidth : WORD;
    FLength : WORD;
    FPoleType : TPoleType;
    FRelativMin : TFloat;
    FRelativMax : TFloat;
    FFramePaint : TFramePaint;
    FFinitSize : INTEGER;
    FMasses : TMassItems;
    FSteerAxle : INTEGER;
    // SOME VARS
    FLastSelectedPnt : TNearestPoint;
    FDirVect : TDirectionVect;
    FSelectedAxle : Smallint;
    FShape : TShapeArray;
    FHalf : TGlobalPoint;
    FSelPoint : TShapePoint;
    FSelectedPnt : TShapePoint;
    FHoverPnt : TShapePoint;
    FLastChangedItem : TLastChangeingItem;
    FInternalCall : BOOLEAN;
    FIsMaster : BOOLEAN;
    // FINIT VARS
    FFinitX : INTEGER;
    FFinitY : INTEGER;
    FFinitForces : TFinitArray;
    FFinitForcesCol : TFinitForceColorArray;
    FFinitPoints : TFinitPointsArray;
    FDidFinitPoints : BOOLEAN;
    FDidFinitDist : BOOLEAN;
    FMaxFinitForce : TFloat;
    FMinFinitForce : TFloat;
    FFinitMode : TFinitMode;
    FColorMode : TColorMode;
    // COG VARS (NEEDS FINIT)
    FCOG : TTriplePoint;
    FHeights : THeightsArray;
    // NOTIFICATIONS
    FBeforeChangeInt : TNotifyEvent;
    FBeforeChangeExt : TNotifyEvent;
    FAfterChangeInt : TNotifyEvent;
    FAfterChangeExt : TNotifyEvent;
    FDoNotify : BOOLEAN;
  PROTECTED
    // NOTIFICATIONS
    FUNCTION GetBeforeChange:TNotifyEvent;
    PROCEDURE SetBeforeChange(Proc:TNotifyEvent);
    FUNCTION GetAfterChange:TNotifyEvent;
    PROCEDURE SetAfterChange(Proc:TNotifyEvent);
    PROCEDURE DoBeforeChangeNotifications;
    PROCEDURE DoAfterChangeNotifications;
    // PROPERTIES
    PROCEDURE SetPorterWidth(w:WORD);
    PROCEDURE SetPorterLength(l:WORD);
    PROCEDURE SetDriveMode(mode:TDriveMode);
    PROCEDURE SetSelectedAxle(axno:SMALLINT);
    PROCEDURE SetRelativMin(min:TFloat);
    PROCEDURE SetRelativMax(max:TFloat);
    PROCEDURE SetShow(bool:BOOLEAN);
    PROCEDURE SetFramePaint(FramePaintType:TFramePaint);
    PROCEDURE SetFinitSize(Size:INTEGER);
    PROCEDURE SetColorMode(mode:TColorMode);
    PROCEDURE SetFinitMode(mode:TFinitMode);
    FUNCTION GetHeights(group:TPressureGroup):TFloat;
    PROCEDURE SetHeights(group:TPressureGroup;Value:TFloat);
    PROCEDURE SetHeightA(Value:TFloat);
    PROCEDURE SetHeightB(Value:TFloat);
    PROCEDURE SetHeightC(Value:TFloat);
    PROCEDURE SetHeightD(Value:TFloat);
    // OTHER
    PROCEDURE SetVirginInternal;
    // FINIT CALCULATIONS
    PROCEDURE CalcFinit;
    PROCEDURE CalcAxleLoads;
    PROCEDURE CalcAxleMoments;
    PROCEDURE CalcFinitPointsArray;
    PROCEDURE CalcFinitDistanceArray(VAR AArray:TFinitArray;FromDistance:TGlobalPoint;VAR MaxDistance,SumDistance:EXTENDED);
    PROCEDURE CalcFinitForceArrayAxles;
    PROCEDURE CalcFinitForceArraySurface;
    PROCEDURE CalcFinitForceArrayCOG;
    PROCEDURE SearchMinMaxFinitForce;
    PROCEDURE DoFinitForceColors;
    // COG CALCULATIONS
    PROCEDURE CalcCOG;
    PROCEDURE CalcFrameTilt;
    // NOTIFICATION RECEIVE
    PROCEDURE TransporterRotationBeforeChange(Sender:TObject);
    PROCEDURE TransporterRotationAfterChange(Sender:TObject);
    PROCEDURE TransporterCenterBeforeChange(Sender:TObject);
    PROCEDURE TransporterCenterAfterChange(Sender:TObject);
    PROCEDURE AxleBeforeChange(Sender:TObject);
    PROCEDURE AxleAfterChange(Sender:TObject);
    PROCEDURE ForcePositionBeforeChange(Sender:TObject);
    PROCEDURE ForcePositionAfterChange(Sender:TObject);
    PROCEDURE LoadChanged(Sender:TObject);
  PUBLIC
    // FOR FINT
    FUNCTION IsFinit(val:Integer):BOOLEAN;
    PROCEDURE FindNextFinitSize;
    PROCEDURE FindPreviousFinitSize;
    // Whole Class //
    CLASS PROCEDURE InternalNotificationOnly(bool:BOOLEAN);
    CLASS PROCEDURE EnableInternalNotification;
    CLASS PROCEDURE DisableInternalNotification;
    // This Instance //
    CONSTRUCTOR Create(AOwner:TComponent); OVERRIDE;
    DESTRUCTOR Destroy; OVERRIDE;
    PROCEDURE SetVirgin;
    PROCEDURE Reincarnate;
    PROCEDURE UpdateOnBoundsChange;
    PROCEDURE SetRotation(Degree:TFloat);
    FUNCTION GetAxle(CONST AxleIndex:INTEGER):TAxleItem; OVERLOAD;
    FUNCTION GetAxle(CONST AxleIndex:INTEGER;VAR AAxle:TAxleItem):BOOLEAN; OVERLOAD;
    FUNCTION GetMass(CONST MassIndex:INTEGER):TMassItem; OVERLOAD;
    FUNCTION GetMass(CONST MassIndex:INTEGER; AMass:TMassItem):BOOLEAN; OVERLOAD;
    FUNCTION RunThroughAxles(VAR indexax:INTEGER;VAR AAxle:TAxleItem):BOOLEAN;
    FUNCTION RunThroughMasses(VAR indexm:INTEGER;VAR AMass:TMassItem):BOOLEAN;
    FUNCTION AddAxle(x,y:TFloat):TAxleItem;
    PROCEDURE CloneAxle(x,y:TFloat;CloneAxleNr:INTEGER);
    PROCEDURE CreateAxleGroup(x,y:TFloat;off:TTransOffset);
    PROCEDURE AllAxlesSameDegree(deg:TFloat);
    PROCEDURE GetMinMaxAxlePositions(VAR minx,maxx,miny,maxy:TFloat);
    PROCEDURE SteerToPoint(steer:TGlobalPoint);
    FUNCTION CalcAxleRepalcementPointFromPressuregroup(gr:TPressureGroup):TGlobalPoint;
    PROCEDURE AutoGroupAxles;
    PROCEDURE SetMaster(Sender:TObject;bool:BOOLEAN);
    PROCEDURE SetSteerAxle(AAxle:TAxleItem); OVERLOAD;
    PROCEDURE SetSteerAxle(indexax:INTEGER); OVERLOAD;
    // For The Area //
    PROPERTY LastSelectedPoint:TNearestPoint READ FLastSelectedPnt WRITE FLastSelectedPnt ;
    PROPERTY FinitPoints:TFinitPointsArray READ FFinitPoints;
    PROPERTY FinitForces:TFinitArray READ FFinitForces;
    PROPERTY FinitForcesColors:TFinitForceColorArray READ FFinitForcesCol;
    // For Myself //
    PROPERTY Shape:TShapeArray READ FShape; //WRITE FShape;
    PROPERTY SelectedPoint:TShapePoint READ FSelectedPnt WRITE FSelectedPnt;
    PROPERTY HoveredPoint:TShapePoint READ FHoverPnt WRITE FHoverPnt;
    PROPERTY DirectionVector:TDirectionVect READ FDirVect WRITE FDirVect;
    PROPERTY LastChangedItem:TLastChangeingItem READ FLastChangedItem;
    PROPERTY Heights[group:TPressureGroup]:TFloat READ GetHeights WRITE SetHeights;
    PROPERTY Master:BOOLEAN READ FIsMaster;
    PROPERTY CollectionIndex:INTEGER READ FIndex;
  PUBLISHED
    PROPERTY Angle:TGlobalAngleClass READ FAngle WRITE FAngle;
    PROPERTY Axles:TAxleItems READ FAxles WRITE FAxles;
    PROPERTY TPorterWidth:WORD READ FWidth WRITE SetPorterWidth;
    PROPERTY TPorterLength:WORD READ FLength WRITE SetPorterLength;
    PROPERTY Center:TGlobalPointClass READ FCenter WRITE FCenter;
    PROPERTY PoleType:TPoleType READ FPoleType WRITE FPoleType;
    PROPERTY DriveMode:TDriveMode READ FDriveMode WRITE SetDriveMode;
    PROPERTY SelectedAxle:SMALLINT READ FSelectedAxle WRITE SetSelectedAxle;
    PROPERTY AxleMinDegree:TFloat READ FRelativMin WRITE SetRelativMin;
    PROPERTY AxleMaxDegree:TFloat READ FRelativMax WRITE SetRelativMax;
    PROPERTY Show:BOOLEAN READ FShow WRITE SetShow;
    PROPERTY FramePaint:TFramePaint READ FFramePaint WRITE SetFramePaint;
    PROPERTY FinitSize:INTEGER READ FFinitSize WRITE SetFinitSize;
    PROPERTY Masses:TMassItems READ FMasses WRITE FMasses;
    PROPERTY COG:TTriplePoint READ FCOG WRITE FCOG;
    PROPERTY FinitColorMode:TColorMode READ FColorMode WRITE SetColorMode;
    PROPERTY FinitMode:TFinitMode READ FFinitMode WRITE SetFinitMode;
    PROPERTY HeightA:TFloat READ FHeights[pgA] WRITE SetHeightA;
    PROPERTY HeightB:TFloat READ FHeights[pgB] WRITE SetHeightB;
    PROPERTY HeightC:TFloat READ FHeights[pgC] WRITE SetHeightC;
    PROPERTY HeightD:TFloat READ FHeights[pgD] WRITE SetHeightD;
    // NOTIFICATIONS
    PROPERTY BeforeChange:TNotifyEvent READ GetBeforeChange WRITE SetBeforeChange;
    PROPERTY AfterChange:TNotifyEvent READ GetAfterChange WRITE SetAfterChange;
  END;
NACH DER "KURZEN" EINFÜHRUNG NUN ZU MEINEM EIGENTLICHEN PROBLEM.

Ich bekomme es nicht gebacken (und hab auch echt keinem richtigen Plan) wie ich den Property Editor für die CollectionItems
mit einem eigenen ersetze. Jedes (oder fast alle) Tutorial(s) beschreibt(beschreiben) nur die Standard PropertyEditoren (für z.B. TStringProperty, TIntegerProperty, etc..). Doch da ich vermutlich einen PopteryEditor abgeleitet von TClassProperty benötige wollte ich fragen, ob mir da jemand weiterhelfen kann). Hat einer schonmal einen Property bzw. Component Editor für komplexere Componenten geschrieben?
Ich hab echt keinem Plan wie ich aus dem Designtime Package auf die einzelenen Eigenschaften meiner Items zugreifen kann.

Wäre über ne Hilfestellung echt erfreut und schon Danke im voraus.

LoCrux
“C++ is an insult to the human brain.” [Niklaus Wirth]

2B OR NOT 2B (.. THAT IS FF)
  Mit Zitat antworten Zitat