📄 iplotdataview.pas
字号:
procedure TiPlotDataView.NotificationRename(Sender: TObject);
begin
if Sender = FXAxis then FGridXAxisName := (Sender as TiPlotXAxis).Name;
if Sender = FYAxis then FGridYAxisName := (Sender as TiPlotYAxis).Name;
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.AddMenuItems(PopupMenu: TPopUpMenu);
begin
inherited AddMenuItems(PopupMenu);
AddEditMenuItems(PopupMenu);
end;
//****************************************************************************************************************************************************
function TiPlotDataView.GetMousePointer(APoint: TPoint): TCursor;
begin
Result := inherited GetMousePointer(APoint);
if MouseOverObject = Self then
case Mode of
ipdvmZoomBox : Result := crDrag;
ipdvmScrollZoom : Result := crHandPoint
else Result := crDefault;
end;
end;
//****************************************************************************************************************************************************
function TiPlotDataView.GetMouseObject(X, Y: Integer): TiPlotObject;
begin
Result := Self;
MouseOverObject := Result;
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.DoMouseLeft(MouseData: TiPlotMouseData);
var
x : Integer;
begin
FDirectionLock := False;
FMouseDown := True;
case Mode of
ipdvmScrollZoom : begin
FMouseDownX := MouseData.X;
FMouseDownY := MouseData.Y;
for x := 0 to (Owner as TiPlotComponent).XAxisCount-1 do
TiPlotObjectAccess((Owner as TiPlotComponent).XAxis[x]).DoMouseLeft(MouseData);
for x := 0 to (Owner as TiPlotComponent).YAxisCount-1 do
TiPlotObjectAccess((Owner as TiPlotComponent).YAxis[x]).DoMouseLeft(MouseData);
end;
ipdvmZoomBox : begin
TiPlotComponentAccess(Owner).DisableAllTracking;
FMouseDownX := MouseData.X;
FMouseDownY := MouseData.Y;
FMouseMoveX := MouseData.X;
FMouseMoveY := MouseData.Y;
TriggerInvalidateNow(Self);
end;
end;
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.DoMouseMove(MouseData: TiPlotMouseData);
var
x : Integer;
begin
if not FMouseDown then Exit;
case Mode of
ipdvmScrollZoom : begin
case FAxesControlMouseStyle of
ipacsXAxis : if GetShiftDown then
begin
FDirectionLock := True;
FDirectionLockXAxis := False;
end
else
begin
FDirectionLock := True;
FDirectionLockXAxis := True;
end;
ipacsYAxis : if GetShiftDown then
begin
FDirectionLock := True;
FDirectionLockXAxis := True;
end
else
begin
FDirectionLock := True;
FDirectionLockXAxis := False;
end;
ipacsBoth : begin
if not FDirectionLock then if GetShiftDown then
begin
if ABS(MouseData.X - FMouseDownX) > 3 then
begin
FDirectionLock := True;
FDirectionLockXAxis := True;
end;
if ABS(MouseData.Y - FMouseDownY) > 3 then
begin
FDirectionLock := True;
FDirectionLockXAxis := False;
end;
end;
end;
end;
if not FDirectionLock or FDirectionLockXAxis then
for x := 0 to (Owner as TiPlotComponent).XAxisCount-1 do
TiPlotObjectAccess((Owner as TiPlotComponent).XAxis[x]).DoMouseMove(MouseData);
if not FDirectionLock or not FDirectionLockXAxis then
for x := 0 to (Owner as TiPlotComponent).YAxisCount-1 do
TiPlotObjectAccess((Owner as TiPlotComponent).YAxis[x]).DoMouseMove(MouseData);
end;
ipdvmZoomBox : begin
if not MouseData.DblClickActive then
begin
FMouseMoveX := MouseData.X;
FMouseMoveY := MouseData.Y;
TriggerInvalidateNow(Self);
end;
end;
end;
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.DoMouseUp(MouseData: TiPlotMouseData);
var
x : Integer;
begin
if FMouseDown then
begin
case Mode of
ipdvmScrollZoom : begin
for x := 0 to (Owner as TiPlotComponent).XAxisCount-1 do
TiPlotObjectAccess((Owner as TiPlotComponent).XAxis[x]).DoMouseUp(MouseData);
for x := 0 to (Owner as TiPlotComponent).YAxisCount-1 do
TiPlotObjectAccess((Owner as TiPlotComponent).YAxis[x]).DoMouseUp(MouseData);
end;
ipdvmZoomBox : begin
if not MouseData.DblClickActive then
begin
if (FMouseMoveX > FMouseDownX) and (FMouseMoveY > FMouseDownY) then
begin
DoZoom(Rect(FMouseDownX, FMouseDownY, FMouseMoveX, FMouseMoveY));
TriggerInvalidateNow(Self);
end;
end;
end;
end;
if PtInRect(DrawRect, Point(MouseData.X, MouseData.Y)) then TiPlotComponentAccess(Owner).DoObjectClick(Self);
FMouseDown := False;
TriggerInvalidateNow(Self);
end;
end;
//****************************************************************************************************************************************************
function TiPlotDataView.iMouseWheel(WheelDelta: Integer; Shift: TShiftState; const MousePos: TPoint): Boolean;
var
x : Integer;
begin
Result := False;
case Mode of
ipdvmScrollZoom : begin
case FAxesControlWheelStyle of
ipacsXAxis : if GetShiftDown then
begin
FDirectionLock := True;
FDirectionLockXAxis := False;
end
else
begin
FDirectionLock := True;
FDirectionLockXAxis := True;
end;
ipacsYAxis : if GetShiftDown then
begin
FDirectionLock := True;
FDirectionLockXAxis := True;
end
else
begin
FDirectionLock := True;
FDirectionLockXAxis := False;
end;
ipacsBoth : begin
FDirectionLock := False;
end;
end;
if not FDirectionLock or FDirectionLockXAxis then
for x := 0 to (Owner as TiPlotComponent).XAxisCount-1 do
TiPlotObjectAccess((Owner as TiPlotComponent).XAxis[x]).iMouseWheel(WheelDelta, Shift, MousePos);
if not FDirectionLock or not FDirectionLockXAxis then
for x := 0 to (Owner as TiPlotComponent).YAxisCount-1 do
TiPlotObjectAccess((Owner as TiPlotComponent).YAxis[x]).iMouseWheel(WheelDelta, Shift, MousePos);
Result := True;
end;
end;
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.DoZoom(ARect: TRect);
var
x : Integer;
Cancel : Boolean;
ZoomRect : TRect;
begin
Cancel := False;
ZoomRect := ARect;
if Assigned(TiPlotComponentAccess(Owner).OnBeforeZoomBox) then TiPlotComponentAccess(Owner).OnBeforeZoomBox(ZoomRect, Cancel);
if not Cancel then
begin
with TiPlotComponentAccess(Owner) do
begin
for x := 0 to XAxisCount-1 do
TiPlotAxisAccess(XAxis[x]).ZoomRect(ZoomRect);
for x := 0 to YAxisCount-1 do
TiPlotAxisAccess(YAxis[x]).ZoomRect(ZoomRect);
end;
end;
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.SetTitle (const Value:String );begin SetStringProperty (Value,FTitle, TriggerChange );end;
procedure TiPlotDataView.SetBackgroundColor (const Value:TColor );begin SetColorProperty (Value,FBackgroundColor, TriggerChange );end;
procedure TiPlotDataView.SetBackgroundTransparent(const Value:Boolean);begin SetBooleanProperty(Value,FBackgroundTransparent,TriggerChange );end;
procedure TiPlotDataView.SetGridShow (const Value:Boolean);begin SetBooleanProperty(Value,FGridShow, TriggerChange );end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.SetGridLineColor (const Value:TColor );begin SetColorProperty (Value,FGridLineColor, TriggerChange);end;
procedure TiPlotDataView.SetGridLineShowLeft (const Value:Boolean);begin SetBooleanProperty(Value,FGridLineShowLeft, TriggerChange);end;
procedure TiPlotDataView.SetGridLineShowTop (const Value:Boolean);begin SetBooleanProperty(Value,FGridLineShowTop, TriggerChange);end;
procedure TiPlotDataView.SetGridLineShowRight (const Value:Boolean);begin SetBooleanProperty(Value,FGridLineShowRight, TriggerChange);end;
procedure TiPlotDataView.SetGridLineShowBottom (const Value:Boolean);begin SetBooleanProperty(Value,FGridLineShowBottom, TriggerChange);end;
procedure TiPlotDataView.SetGridLineShowXMajors(const Value:Boolean);begin SetBooleanProperty(Value,FGridLineShowXMajors,TriggerChange);end;
procedure TiPlotDataView.SetGridLineShowXMinors(const Value:Boolean);begin SetBooleanProperty(Value,FGridLineShowXMinors,TriggerChange);end;
procedure TiPlotDataView.SetGridLineShowYMajors(const Value:Boolean);begin SetBooleanProperty(Value,FGridLineShowYMajors,TriggerChange);end;
procedure TiPlotDataView.SetGridLineShowYMinors(const Value:Boolean);begin SetBooleanProperty(Value,FGridLineShowYMinors,TriggerChange);end;
procedure TiPlotDataView.SetGridLineXMajorCustom(const Value:Boolean);begin SetBooleanProperty(Value,FGridLineXMajorCustom,TriggerChange);end;
procedure TiPlotDataView.SetGridLineXMajorColor (const Value:TColor );begin SetColorProperty (Value,FGridLineXMajorColor, TriggerChange);end;
procedure TiPlotDataView.SetGridLineXMajorWidth (const Value:Integer);begin SetIntegerProperty(Value,FGridLineXMajorWidth, TriggerChange);end;
procedure TiPlotDataView.SetGridLineXMinorCustom(const Value:Boolean);begin SetBooleanProperty(Value,FGridLineXMinorCustom,TriggerChange);end;
procedure TiPlotDataView.SetGridLineXMinorColor (const Value:TColor );begin SetColorProperty (Value,FGridLineXMinorColor, TriggerChange);end;
procedure TiPlotDataView.SetGridLineXMinorWidth (const Value:Integer);begin SetIntegerProperty(Value,FGridLineXMinorWidth, TriggerChange);end;
procedure TiPlotDataView.SetGridLineYMajorCustom(const Value:Boolean);begin SetBooleanProperty(Value,FGridLineYMajorCustom,TriggerChange);end;
procedure TiPlotDataView.SetGridLineYMajorColor (const Value:TColor );begin SetColorProperty (Value,FGridLineYMajorColor, TriggerChange);end;
procedure TiPlotDataView.SetGridLineYMajorWidth (const Value:Integer);begin SetIntegerProperty(Value,FGridLineYMajorWidth, TriggerChange);end;
procedure TiPlotDataView.SetGridLineYMinorCustom(const Value:Boolean);begin SetBooleanProperty(Value,FGridLineYMinorCustom,TriggerChange);end;
procedure TiPlotDataView.SetGridLineYMinorColor (const Value:TColor );begin SetColorProperty (Value,FGridLineYMinorColor, TriggerChange);end;
procedure TiPlotDataView.SetGridLineYMinorWidth (const Value:Integer);begin SetIntegerProperty(Value,FGridLineYMinorWidth, TriggerChange);end;
procedure TiPlotDataView.SetAxesControlEnabled (const Value: Boolean);begin SetBooleanProperty(Value,FAxesControlEnabled, nil );end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.SetGridXAxisName(const Value:String );
begin
if FGridXAxisName <> Value then
begin
FGridXAxisName := Value;
FXAxis := nil;
TriggerChange(Self);
end;
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.SetGridYAxisName(const Value:String );
begin
if FGridYAxisName <> Value then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -