mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-27 08:28:30 +02:00
fpvectorial: Starts rotation support
git-svn-id: trunk@41503 -
This commit is contained in:
parent
aab787525a
commit
957f9973d0
@ -1622,6 +1622,7 @@ var
|
|||||||
lName: string;
|
lName: string;
|
||||||
lBlock: TvBlock;
|
lBlock: TvBlock;
|
||||||
PosX, PosY, PosZ: Double;
|
PosX, PosY, PosZ: Double;
|
||||||
|
lRotationAngle: Double;
|
||||||
begin
|
begin
|
||||||
PosX := 0.0;
|
PosX := 0.0;
|
||||||
PosY := 0.0;
|
PosY := 0.0;
|
||||||
@ -1634,7 +1635,7 @@ begin
|
|||||||
CurToken := TDXFToken(ATokens.Items[i]);
|
CurToken := TDXFToken(ATokens.Items[i]);
|
||||||
|
|
||||||
// Avoid an exception by previously checking if the conversion can be made
|
// Avoid an exception by previously checking if the conversion can be made
|
||||||
if CurToken.GroupCode in [10, 20, 30] then
|
if CurToken.GroupCode in [10, 20, 30, 50] then
|
||||||
begin
|
begin
|
||||||
CurToken.FloatValue := StrToFloat(Trim(CurToken.StrValue), FPointSeparator);
|
CurToken.FloatValue := StrToFloat(Trim(CurToken.StrValue), FPointSeparator);
|
||||||
end;
|
end;
|
||||||
@ -1644,6 +1645,7 @@ begin
|
|||||||
10: PosX := CurToken.FloatValue;
|
10: PosX := CurToken.FloatValue;
|
||||||
20: PosY := CurToken.FloatValue;
|
20: PosY := CurToken.FloatValue;
|
||||||
30: PosZ := CurToken.FloatValue;
|
30: PosZ := CurToken.FloatValue;
|
||||||
|
50: lRotationAngle := CurToken.FloatValue;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1657,6 +1659,7 @@ begin
|
|||||||
Result.Y := PosY;
|
Result.Y := PosY;
|
||||||
Result.Z := PosZ;
|
Result.Z := PosZ;
|
||||||
Result.InsertEntity := lBlock;
|
Result.InsertEntity := lBlock;
|
||||||
|
Result.RotationAngle := lRotationAngle;
|
||||||
if not AOnlyCreate then AData.AddEntity(Result);
|
if not AOnlyCreate then AData.AddEntity(Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -246,6 +246,7 @@ type
|
|||||||
procedure MoveSubpart(ADeltaX, ADeltaY: Double; ASubpart: Cardinal); virtual;
|
procedure MoveSubpart(ADeltaX, ADeltaY: Double; ASubpart: Cardinal); virtual;
|
||||||
function GetSubpartCount: Integer; virtual;
|
function GetSubpartCount: Integer; virtual;
|
||||||
procedure PositionSubparts(ADest: TFPCustomCanvas; ABaseX, ABaseY: Double); virtual;
|
procedure PositionSubparts(ADest: TFPCustomCanvas; ABaseX, ABaseY: Double); virtual;
|
||||||
|
procedure Rotate(AAngle: Double); virtual;
|
||||||
procedure Render(ADest: TFPCustomCanvas; ARenderInfo: TvRenderInfo; ADestX: Integer = 0;
|
procedure Render(ADest: TFPCustomCanvas; ARenderInfo: TvRenderInfo; ADestX: Integer = 0;
|
||||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); virtual;
|
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); virtual;
|
||||||
function AdjustColorToBackground(AColor: TFPColor; ARenderInfo: TvRenderInfo): TFPColor;
|
function AdjustColorToBackground(AColor: TFPColor; ARenderInfo: TvRenderInfo): TFPColor;
|
||||||
@ -660,6 +661,7 @@ type
|
|||||||
function GetFirstEntity: TvEntity;
|
function GetFirstEntity: TvEntity;
|
||||||
function GetNextEntity: TvEntity;
|
function GetNextEntity: TvEntity;
|
||||||
procedure AddEntity(AEntity: TvEntity);
|
procedure AddEntity(AEntity: TvEntity);
|
||||||
|
procedure Rotate(AAngle: Double);
|
||||||
procedure Clear; override;
|
procedure Clear; override;
|
||||||
procedure Render(ADest: TFPCustomCanvas; ARenderInfo: TvRenderInfo; ADestX: Integer = 0;
|
procedure Render(ADest: TFPCustomCanvas; ARenderInfo: TvRenderInfo; ADestX: Integer = 0;
|
||||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||||
@ -689,6 +691,7 @@ type
|
|||||||
TvInsert = class(TvNamedEntity)
|
TvInsert = class(TvNamedEntity)
|
||||||
public
|
public
|
||||||
InsertEntity: TvEntity; // The entity to be inserted
|
InsertEntity: TvEntity; // The entity to be inserted
|
||||||
|
RotationAngle: Double; // in degrees, normal is zero
|
||||||
procedure Render(ADest: TFPCustomCanvas; ARenderInfo: TvRenderInfo; ADestX: Integer = 0;
|
procedure Render(ADest: TFPCustomCanvas; ARenderInfo: TvRenderInfo; ADestX: Integer = 0;
|
||||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||||
end;
|
end;
|
||||||
@ -1189,6 +1192,11 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TvEntity.Rotate(AAngle: Double);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TvEntity.Render(ADest: TFPCustomCanvas; ARenderInfo: TvRenderInfo; ADestX: Integer;
|
procedure TvEntity.Render(ADest: TFPCustomCanvas; ARenderInfo: TvRenderInfo; ADestX: Integer;
|
||||||
ADestY: Integer; AMulX: Double; AMulY: Double);
|
ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||||
begin
|
begin
|
||||||
@ -3270,6 +3278,16 @@ begin
|
|||||||
FElements.Add(AEntity);
|
FElements.Add(AEntity);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TvEntityWithSubEntities.Rotate(AAngle: Double);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
for i := 0 to FElements.Count-1 do
|
||||||
|
begin
|
||||||
|
TvEntity(FElements.Items[i]).Rotate(AAngle);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TvEntityWithSubEntities.Clear;
|
procedure TvEntityWithSubEntities.Clear;
|
||||||
begin
|
begin
|
||||||
inherited Clear;
|
inherited Clear;
|
||||||
@ -3351,8 +3369,18 @@ begin
|
|||||||
ARenderInfo.ForceRenderBlock := True;
|
ARenderInfo.ForceRenderBlock := True;
|
||||||
// Alter the position of the elements to consider the positioning of the BLOCK and of the INSERT
|
// Alter the position of the elements to consider the positioning of the BLOCK and of the INSERT
|
||||||
InsertEntity.Move(X, Y);
|
InsertEntity.Move(X, Y);
|
||||||
|
// If necessary rotate the canvas
|
||||||
|
if RotationAngle <> 0 then
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
// Render
|
// Render
|
||||||
InsertEntity.Render(ADest, ARenderInfo, ADestX, ADestY, AMulX, AMuly);
|
InsertEntity.Render(ADest, ARenderInfo, ADestX, ADestY, AMulX, AMuly);
|
||||||
|
// And unrotate it back again
|
||||||
|
if RotationAngle <> 0 then
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
// Change them back
|
// Change them back
|
||||||
InsertEntity.Move(-X, -Y);
|
InsertEntity.Move(-X, -Y);
|
||||||
ARenderInfo.ForceRenderBlock := OldForceRenderBlock;
|
ARenderInfo.ForceRenderBlock := OldForceRenderBlock;
|
||||||
|
Loading…
Reference in New Issue
Block a user