I'm stuck.  I'm using XE6 and the FMX.Graphics' TPathData object.  Problem is, I need to extend it so that its Points[] property contains an additional member.  The Points[] property is based on TPathPoint - that's what I need to extend.  But is there really a way to do it?  (extend a sub-object used by another object in both its private and public declarations?)  TPathPoint plays a pivotal role in TPathData.  I've already created an object the inherits TPathData, but I have no idea if it's possible to get that object to use my own TPathPoint variation instead of it's own.

Comments

  1. I recall shaking my head when I stumbled across this. If I recall correctly I modified it to allow dynamic additions and that there were some gotchas, I'll see if I can find the code again.

    ReplyDelete
  2. Yeah, I was also surprised that dynamic additions aren't supported, especially since the points are held in a TList. I'd appreciate seeing your modifications just for the curiosity of it. I think I'll be forced to completely replace the two objects with my own enhanced versions.

    ReplyDelete
  3. Ah here's what I did, I used MoveTo and LineTo to "draw" the path, and then scaled and translated it to where I wanted it. However that did not update the points properly, for that I needed access to a protected method:

    type
      TPathDataHelper = class helper for TPathData
        procedure Changed;
      end;
    { TPathDataHelper }
    procedure TPathDataHelper.Changed;
    begin
      OnChanged(Self);
    end;

    I called "myPath.Data.Changed;" after modifying the data.

    ReplyDelete
  4. You're welcome.

    Scaling and rotations always happen around the origin, so yeah you need to keep that in mind. Can get a bit tricky especially if you got multiple origins at work (for example, rotating around object's local origin while scaling globally along X axis). In that case it's usually best to just use matrix math.

    ReplyDelete

Post a Comment