📄 ezactionlaunch.pas
字号:
Point2D( 0.0, 0.0 ), Rotangle, ScaleX, ScaleY );
FCurrentAction:= TAddEntityAction.CreateAction( FCmdLine, Entity, Point(0,0) );
PushAction( TrackID );
end;
procedure TEzActionLauncher.TrackBuffer(const TrackID: string);
begin
Assert( FCmdLine <> Nil );
FCurrentAction:= TBufferSelectAction.CreateAction( FCmdLine );
PushAction( TrackID );
end;
procedure TEzActionLauncher.TrackCircle(const TrackID: string; DrawType: TEzCircleDrawType);
begin
Assert( FCmdLine <> Nil );
case DrawType of
ct2P, ct3P, ctCR:
FCurrentAction:= TDrawCircleAction.CreateAction( FCmdLine, DrawType );
else
FCurrentAction:= TDrawCircleAction.CreateAction( FCmdLine, ctCR );
end;
PushAction( TrackID );
end;
procedure TEzActionLauncher.TrackEntity(const TrackID: string; TrackedEntity: TEzEntity);
var
ImageDimensions: TPoint;
IsCompressed: Boolean;
FullName: string;
GL: TEzGraphicLink;
begin
Assert( (FCmdLine <> Nil) And (TrackedEntity <> Nil) );
FCurrentAction:= Nil;
if TrackedEntity.EntityID = idTrueTypeText then
begin
FCurrentAction:= TAddTextAction.CreateAction( FCmdLine );
FCurrentAction.Launcher:= Self;
end else if TrackedEntity.EntityID = idGroup then
begin
end else if TrackedEntity.EntityID = idRtfText then
begin
{ pendiente de implementar rich text }
end else if TrackedEntity.EntityID = idJustifVectText then
begin
FCurrentAction:= TAddVectorialTextAction.CreateAction( FCmdLine, TrackedEntity,
true, tbsNone );
FCurrentAction.Launcher:= Self;
end else if TrackedEntity.EntityID = idFittedVectText then
begin
FCurrentAction:= TAddVectorialTextAction.CreateAction( FCmdLine, TrackedEntity,
false, TEzFittedVectorText( TrackedEntity ).TextBorderStyle );
FCurrentAction.Launcher:= Self;
end else if TrackedEntity.EntityID in [idDimHorizontal, idDimVertical, idDimParallel] then
begin
FCurrentAction:= TDimAction.CreateAction( FCmdLine, TrackedEntity );
FCurrentAction.Launcher := Self;
end else if TrackedEntity.EntityID = idPictureRef then
begin
FullName:= AddSlash( Ez_Preferences.CommonSubdir ) +
TEzPictureRef( TrackedEntity ).FileName;
GL:= TEzGraphicLink.Create;
try
GL.ReadGeneric(FullName);
ImageDimensions.X:= GL.Bitmap.Width;
ImageDimensions.Y:= GL.Bitmap.Height;
FCurrentAction:= TAddEntityAction.CreateAction( FCmdLine, TrackedEntity, ImageDimensions );
FCurrentAction.Launcher := Self;
finally
Gl.Free;
end;
end else if TrackedEntity.EntityID = idBandsBitmap then
begin
{ Get the bitmap dimensions}
FullName:= AddSlash( Ez_Preferences.CommonSubdir ) +
TEzBandsBitmap( TrackedEntity ).FileName;
case TEzBandsBitmap(TrackedEntity).GetFormat of
ifBitmap:
GetDIBDimensions( FullName, nil, ImageDimensions.X, ImageDimensions.Y, IsCompressed);
ifTiff:
GetTiffDimensions( FullName, nil, ImageDimensions.X, ImageDimensions.Y, IsCompressed);
ifBIL:
GetBILDimensions( FullName, ImageDimensions.X, ImageDimensions.Y);
end;
FCurrentAction:= TAddEntityAction.CreateAction( FCmdLine, TrackedEntity, ImageDimensions );
FCurrentAction.Launcher := Self;
end else
begin
FCurrentAction:= TAddEntityAction.CreateAction( FCmdLine, TrackedEntity, Point(0,0) );
FCurrentAction.Launcher := Self;
end;
if Assigned( FCurrentAction ) then
begin
PushAction( TrackID );
end;
end;
procedure TEzActionLauncher.TrackEntityClick( const TrackID: string;
Const LayerName: string = ''; HighlightClicked: Boolean = True );
begin
Assert( FCmdLine <> Nil );
FCurrentAction:= TEntityClickAction.CreateAction(FCmdLine, LayerName);
TEntityClickAction( FCurrentAction ).FHighlightClicked := HighlightClicked;
PushAction( TrackID );
end;
function TEzActionLauncher.GetCaption: String;
begin
Assert( FCmdLine <> Nil );
Result:= FCmdLine.Caption;
end;
procedure TEzActionLauncher.SetCaption(const Value: String);
begin
Assert( FCmdLine <> Nil );
FCmdLine.Caption:= Value;
end;
function TEzActionLauncher.GetCurrentTrackID: string;
begin
Assert( FCmdLine <> Nil );
Result:= FCmdLine.CurrentActionID;
end;
function TEzActionLauncher.IsRunning: Boolean;
begin
Assert( FCmdLine <> Nil );
Result:= FCurrentAction <> Nil;
end;
function TEzActionLauncher.GetStatusMessage: string;
begin
Result:='';
end;
procedure TEzActionLauncher.SetStatusMessage(const Value: string);
begin
Assert( FCmdLine <> Nil );
FCmdLine.StatusMessage:= Value;
end;
procedure TEzActionLauncher.TrackEntityDragDrop( const TrackID: string );
begin
Assert( FCmdLine <> Nil );
FCurrentAction:= TDragDropAction.CreateAction( FCmdLine, Ez_Preferences.ApertureWidth );
PushAction( TrackID );
end;
procedure TEzActionLauncher.TrackEntityMouseMove(const TrackID: string;
Const LayerName: string = ''; HighlightDetected: Boolean = True);
begin
Assert( FCmdLine <> Nil );
FCurrentAction:= TMouseMoveAction.CreateAction(FCmdLine, LayerName);
TMouseMoveAction( FCurrentAction ).FHighlightDetected := HighlightDetected;
PushAction( TrackID );
end;
procedure TEzActionLauncher.TrackGenericAction(const TrackID: string);
begin
Assert( FCmdLine <> Nil );
FFinished:= False;
FCurrentAction:= TGenericAction.CreateAction( FCmdLine, Self );
PushAction( TrackID );
end;
function TEzActionLauncher.GetDefaultAction: Boolean;
begin
Result:= False; // how to know ?
end;
procedure TEzActionLauncher.SetDefaultAction(const Value: Boolean);
begin
Assert( FCmdLine <> Nil );
if Value then
FCmdLine.TheDefaultAction := TGenericAction.CreateAction( FCmdLine, Self )
else
FCmdLine.TheDefaultAction := Nil; // this causes to reset the default action
end;
{-------------------------------------------------------------------------------}
// TAddEntityAction - class implementation
{-------------------------------------------------------------------------------}
Constructor TAddEntityAction.CreateAction( CmdLine: TEzCmdLine; Ent: TEzEntity;
Const ImgDims: TPoint );
Begin
Inherited CreateAction( CmdLine );
FEntity := Ent;
FImgDims := ImgDims;
FIsImage := Not((FImgDims.X=0) And (FImgDims.Y=0));
FDrawImmediately:= Ent.EntityID in [idPlace, idNode, idBlockInsert];
CanDoOsnap := True;
CanDoAccuDraw:= True;
If CmdLine.UseFullViewCursor Then
MouseDrawElements:= [mdCursorFrame, mdFullViewCursor]
Else
MouseDrawElements:= [mdCursor];
OnMouseDown := MyMouseDown;
OnMouseMove := MyMouseMove;
OnKeyPress := MyKeyPress;
OnPaint := MyPaint;
OnSuspendOperation := Self.SuspendOperation;
OnContinueOperation := Self.ContinueOperation;
// set line width to the default
If Ent Is TEzOpenedEntity Then
TEzOpenedEntity( Ent ).Pentool.Width := Ez_Preferences.DefPenStyle.Width;
If Ent.EntityID In [idPlace, idNode] Then
Begin
With TEzPlace( Ent ), CmdLine.ActiveDrawBox Do
Begin
Symboltool.Height := Grapher.GetRealSize( Ez_Preferences.DefSymbolStyle.Height );
If (Grapher.DistToPointsY(Symboltool.Height) < 8 ) Or
(Grapher.DistToPointsY(Symboltool.Height) > 48 ) Then
Symboltool.Height := Grapher.PointsToDistY(14);
End;
End;
{ this is used for snapping to this entity also because this entity is not yet
saved to the database }
EzSystem.GlobalTempEntity:= Ent;
// define the cursor for this action
Cursor:= crDrawCross;
WaitingMouseClick := True;
SetAddActionCaption;
CmdLine.All_Invalidate;
End;
Destructor TAddEntityAction.Destroy;
Begin
{ If not nil then the entity was not added to the file/symbol and we must delete it }
If FEntity <> Nil Then FEntity.Free;
EzSystem.GlobalTempEntity:= Nil;
Inherited Destroy;
End;
Procedure TAddEntityAction.SetCurrentPoint( Pt: TEzPoint; Orto: Boolean );
Var
I: Integer;
ImgWidth, ImgHeight: Double;
Begin
If Orto And ( FCurrentIndex > 0 ) And
( FEntity.EntityID In [idPolyline, idPolygon] ) Then
Pt := ChangeToOrtogonal( FEntity.Points[FCurrentIndex - 1], Pt );
If ( FEntity.EntityID = idSpline ) And ( fCurrentIndex > 0 ) And
( ( TEzSpline( FEntity ).PointsInCurve / fCurrentIndex ) < 10 ) Then
TEzSpline( FEntity ).PointsInCurve := fCurrentIndex * 10 + 100;
FEntity.Points[FCurrentIndex] := Pt;
For I := FCurrentIndex + 1 To FEntity.Points.Count - 1 Do
FEntity.Points[I] := Pt;
{ set the image entity dimension proportional to source image }
If FIsImage And ( FCurrentIndex = 1 ) Then
Begin
{ the rectangle must be proportional to the bitmap dimensions }
ImgWidth := FEntity.Points[1].X - FEntity.Points[0].X;
ImgHeight := ( Abs( ImgWidth ) / FImgDims.X ) * FImgDims.Y;
If FEntity.Points[1].Y < FEntity.Points[0].Y Then
ImgHeight := -ImgHeight;
FEntity.Points[1] := Point2d( FEntity.Points[0].X + ImgWidth,
FEntity.Points[0].Y + ImgHeight );
End;
If FCurrentIndex = 0 Then
WaitingMouseClick := False;
End;
Procedure TAddEntityAction.AddPoint( const CurrPoint: TEzPoint );
Var
I: Integer;
s: String;
Begin
with CmdLine.ActiveDrawBox do
begin
{ "mark" the clicked point }
DrawCross( Canvas, Grapher.RealToPoint( CurrPoint ) );
SetCurrentPoint( CurrPoint, CmdLine.UseOrto );
{ set AccuDraw position }
If FCurrentIndex = 0 Then
CmdLine.AccuDraw.UpdatePosition( CurrPoint, CurrPoint ) // this activates AccuDraw
Else If FCurrentIndex > 0 Then
Begin
If FEntity.EntityID In [idRtfText,idPictureRef,idPersistBitmap,
idCustomPicture,idBandsBitmap,idEllipse,idRectangle,idTable] Then
CmdLine.AccuDraw.UpdatePosition( CurrPoint, CurrPoint )
Else
CmdLine.AccuDraw.UpdatePosition( FEntity.Points[FCurrentIndex-1], CurrPoint );
End;
If Not FEntity.Points.CanGrow And ( FCurrentIndex >= FEntity.Points.Size - 1 ) Then
Begin
CmdLine.All_DrawEntity2DRubberBand( FEntity );
if Assigned( Launcher ) then
begin
if Assigned( TEzActionLauncher( Launcher ).OnTrackedEntity ) then
TEzActionLauncher( Launcher ).OnTrackedEntity( Launcher, Self.ActionID, FEntity );
CmdLine.All_Invalidate;
End else
ActionAddNewEntity( CmdLine, FEntity );
Self.Finished := true;
Exit;
End
Else
Inc( FCurrentIndex );
{ if end user holds down the ALT key, display an informative dialog form }
If ( GetAsyncKeyState( VK_menu ) Shr 1 ) <> 0 Then
Begin
For I := 0 To FEntity.Points.Count - 1 Do
s := s + Format( '(%f, %f),' + CrLf, [FEntity.Points[I].X, FEntity.Points[I].Y] );
Clipboard.SetTextBuf( PChar( s ) );
End;
SetAddActionCaption;
end;
End;
Procedure TAddEntityAction.MyMouseDown( Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer; Const WX, WY: Double );
Var
Key: Char;
CurrPoint: TEzPoint;
Begin
If Button = mbRight Then
begin
Key:= #13 ;
MyKeyPress( Nil, Key );
Exit;
end;
CurrPoint := CmdLine.GetSnappedPoint;
AddPoint( CurrPoint );
End;
Procedure TAddEntityAction.SetAddActionCaption;
Begin
Case fCurrentIndex Of
0: Caption := SFirstPoint;
1: Caption := SSecondPoint;
2: Caption := SThirdPoint;
3: Caption := SFourthPoint;
4: Caption := SFifthPoint;
Else
Caption := SNextPoint;
End;
End;
Procedure TAddEntityAction.DrawEntityRubberToAll( DrawBox: TEzBaseDrawBox );
//var
// TempEnt: TEzEntity;
Begin
{If (FEntity.EntityID In [idPolygon]) And (FEntity.Points.Count > 2) then
begin
// Create a clone entity in order to draw closed polygon
TempEnt:= FEntity.Clone();
Try
NormalizePolygon( TempEnt );
If DrawBox = Nil then
CmdLine.All_DrawEntity2DRubberBand( TempEnt )
Else
DrawBox.DrawEntity2DRubberBand( TempEnt );
Finally
TempEnt.Free;
End;
end else
begin }
If DrawBox = Nil then
CmdLine.All_DrawEntity2DRubberBand( FEntity )
Else
DrawBox.DrawEntity2DRubberBand( FEntity );
//end;
End;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -