📄 iplotannotation.pas
字号:
X := FMouseDownXValue + DeltaX;
Y := FMouseDownYValue + DeltaY;
X2 := FMouseDownX2Value + DeltaX;
Y2 := FMouseDownY2Value + DeltaY;
end
else
begin
FY := PixelsXToPosition(MouseData.X - FMouseDownX + FMouseDownPositionPixelsX);
FX := PixelsYToPosition(MouseData.Y - FMouseDownY + FMouseDownPositionPixelsY);
end;
FRectChange := True;
TriggerChange(Self);
TiPlotComponentAccess(Owner).DoAnnotationCoordinatesChange(Self);
end
else
begin
if FStyle = ipasRectangle then
begin
NewRect := FMouseDownRect;
OffsetRect(NewRect, MouseData.X - FMouseDownX, MouseData.Y - FMouseDownY);
SetupRectangle(NewRect);
end
else if FStyle = ipasEllipse then
begin
DeltaX := PixelsXToPosition(MouseData.X) - PixelsXToPosition(FMouseDownX);
DeltaY := PixelsYToPosition(MouseData.Y) - PixelsYToPosition(FMouseDownY);
X := FMouseDownXValue + DeltaX;
Y := FMouseDownYValue + DeltaY;
X2 := FMouseDownX2Value + DeltaX;
Y2 := FMouseDownY2Value + DeltaY;
end
else
begin
FX := PixelsXToPosition(MouseData.X - FMouseDownX + FMouseDownPositionPixelsX);
FY := PixelsYToPosition(MouseData.Y - FMouseDownY + FMouseDownPositionPixelsY);
end;
FRectChange := True;
TriggerChange(Self);
TiPlotComponentAccess(Owner).DoAnnotationCoordinatesChange(Self);
end;
ipassSizeTopLeft : begin
NewRect := FMouseDownRect;
NewRect.Top := FMouseDownRect.Top + MouseData.Y - FMouseDownY;
NewRect.Left := FMouseDownRect.Left + MouseData.X - FMouseDownX;
SetupRectangle(NewRect);
end;
ipassSizeTopRight : begin
NewRect := FMouseDownRect;
NewRect.Top := FMouseDownRect.Top + MouseData.Y - FMouseDownY;
NewRect.Right := FMouseDownRect.Right + MouseData.X - FMouseDownX;
SetupRectangle(NewRect);
end;
ipassSizeBottomLeft : begin
NewRect := FMouseDownRect;
NewRect.Bottom := FMouseDownRect.Bottom + MouseData.Y - FMouseDownY;
NewRect.Left := FMouseDownRect.Left + MouseData.X - FMouseDownX;
SetupRectangle(NewRect);
end;
ipassSizeBottomRight : begin
NewRect := FMouseDownRect;
NewRect.Bottom := FMouseDownRect.Bottom + MouseData.Y - FMouseDownY;
NewRect.Right := FMouseDownRect.Right + MouseData.X - FMouseDownX;
SetupRectangle(NewRect);
end;
end;
TriggerChange(Self);
end;
end;
//****************************************************************************************************************************************************
procedure TiPlotAnnotation.DoMouseUp(MouseData: TiPlotMouseData);
begin
if FMouseDown then
begin
FMouseDown := False;
if PtInRect(FClickRect, Point(MouseData.X, MouseData.Y)) then TiPlotComponentAccess(Owner).DoObjectClick(Self);
if FRectChange then TiPlotComponentAccess(Owner).DoAnnotationCoordinatesChangeFinished(Self);
end;
FSelectStyle := ipassNone;
end;
//****************************************************************************************************************************************************
procedure TiPlotAnnotation.SetupRectangle(ARect: TRect);
begin
with ARect do
begin
if XYAxesReversed then
begin
if FStyle <> ipasEllipse then
begin
FX := (PixelsYToPosition(Top) + PixelsYToPosition(Bottom))/2;
FY := (PixelsXToPosition(Left) + PixelsXToPosition(Right))/2;
FWidth := ABS(PixelsYToPosition(Bottom) - PixelsYToPosition(Top));
FHeight := ABS(PixelsXToPosition(Right) - PixelsXToPosition(Left));
end
else
begin
FY := PixelsXToPosition(Left);
FX := PixelsYToPosition(Top);
FY2 := PixelsXToPosition(Right);
FX2 := PixelsYToPosition(Bottom);
end;
end
else
begin
if FStyle <> ipasEllipse then
begin
FX := (PixelsXToPosition(Left) + PixelsXToPosition(Right))/2;
FY := (PixelsYToPosition(Top) + PixelsYToPosition(Bottom))/2;
FWidth := ABS(PixelsXToPosition(Right) - PixelsXToPosition(Left));
FHeight := ABS(PixelsYToPosition(Bottom) - PixelsYToPosition(Top));
end
else
begin
FX := PixelsXToPosition(Left);
FY := PixelsYToPosition(Top);
FX2 := PixelsXToPosition(Right);
FY2 := PixelsYToPosition(Bottom);
end;
end
end;
FRectChange := True;
TriggerChange(Self);
TiPlotComponentAccess(Owner).DoAnnotationCoordinatesChange(Self);
end;
//****************************************************************************************************************************************************
function TiPlotAnnotation.PositionXToPixels(Value: Double): Integer;
begin
Result := 0;
case Reference of
iprtDataView,
iprtXDataViewYChannel : begin
if not Assigned(FDataView) then Exit;
if XYAxesReversed then
Result := FDataView.PositionPercentToPixelsY(Value)
else
Result := FDataView.PositionPercentToPixelsX(Value)
end;
iprtChannel,
iprtXChannelYDataView : begin
if not Assigned(Channel) then Exit;
if not Assigned(Channel.XAxis) then Exit;
Result := Channel.XAxis.PositionToPixels(Value);
end;
end;
end;
//****************************************************************************************************************************************************
function TiPlotAnnotation.PositionYToPixels(Value: Double): Integer;
begin
Result := 0;
case Reference of
iprtDataView,
iprtXChannelYDataView : begin
if not Assigned(FDataView) then Exit;
if XYAxesReversed then
Result := FDataView.PositionPercentToPixelsX(Value)
else
Result := FDataView.PositionPercentToPixelsY(Value)
end;
iprtChannel,
iprtXDataViewYChannel : begin
if not Assigned(Channel) then Exit;
if not Assigned(TiPlotChannelCustomAccess(Channel).YAxis) then Exit;
Result := TiPlotChannelCustomAccess(Channel).YAxis.PositionToPixels(Value);
end;
end;
end;
//****************************************************************************************************************************************************
function TiPlotAnnotation.PixelsXToPosition(Value: Integer): Double;
begin
Result := 0;
case Reference of
iprtDataView,
iprtXDataViewYChannel : begin
if not Assigned(FDataView) then Exit;
if XYAxesReversed then
Result := FDataView.PixelsYToPositionPercent(Value)
else
Result := FDataView.PixelsXToPositionPercent(Value)
end;
iprtChannel,
iprtXChannelYDataView : begin
if not Assigned(Channel) then Exit;
if not Assigned(TiPlotChannelCustomAccess(Channel).XAxis) then Exit;
if not Assigned(TiPlotChannelCustomAccess(Channel).YAxis) then Exit;
if XYAxesReversed then
Result := TiPlotChannelCustomAccess(Channel).YAxis.PixelsToPosition(Value)
else
Result := TiPlotChannelCustomAccess(Channel).XAxis.PixelsToPosition(Value);
end;
end;
end;
//****************************************************************************************************************************************************
function TiPlotAnnotation.PixelsYToPosition(Value: Integer): Double;
begin
Result := 0;
case Reference of
iprtDataView,
iprtXChannelYDataView : begin
if not Assigned(FDataView) then Exit;
if XYAxesReversed then
Result := FDataView.PixelsXToPositionPercent(Value)
else
Result := FDataView.PixelsYToPositionPercent(Value)
end;
iprtChannel,
iprtXDataViewYChannel : begin
if not Assigned(Channel) then Exit;
if not Assigned(TiPlotChannelCustomAccess(Channel).XAxis) then Exit;
if not Assigned(TiPlotChannelCustomAccess(Channel).YAxis) then Exit;
if XYAxesReversed then
Result := TiPlotChannelCustomAccess(Channel).XAxis.PixelsToPosition(Value)
else
Result := TiPlotChannelCustomAccess(Channel).YAxis.PixelsToPosition(Value);
end;
end;
end;
//****************************************************************************************************************************************************
function TiPlotAnnotation.MousePointToXPos(APoint: TPoint): Double;
begin
Result := 0;
case Reference of
iprtDataView,
iprtXDataViewYChannel : begin
if not Assigned(FDataView) then Exit;
if XYAxesReversed then
Result := FDataView.PixelsYToPositionPercent(APoint.Y)
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -