📄 circpic.pas
字号:
tempendPoint.Y:=endpos.Y;
//坐标变换
ChangPointXY;
end;
end;
POS_CENTERBUTTOM: // :Integer = 7 ; //下中
begin
if (ssCtrl in CircKeyState) then begin
//清除前一次
Center :=Point ((StartPos.x + Endpos.x) div 2,(StartPos.y + Endpos.y) div 2);
//mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tempStartPoint.X:=StartPos.X;
tempStartPoint.Y:=StartPos.Y-MousediffY;
tempendPoint.X :=EndPos.X;
tempendPoint.Y :=EndPos.Y+MouseDiffY;
//坐标变换
ChangPointXY;
//绘制当前虚线图元
//mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tempStartPoint.X:=StartPos.X;
tempStartPoint.Y:=StartPos.Y-MouseDiffY;
tempendPoint.X :=EndPos.X;
tempendPoint.Y :=EndPos.Y+MouseDiffY;
//坐标变换
ChangPointXY;
end else begin
//清除前一次
//mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tempStartPoint:=StartPos;
tempendPoint.X:=EndPos.X;
tempendPoint.Y:=endpos.Y+MouseDiffY;
ChangPointXY;
//绘制当前虚线图元
//mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tempStartPoint:=StartPos;
tempendPoint.X:=EndPos.X;
tempendPoint.Y:=endpos.Y+MouseDiffY;
//坐标变换
ChangPointXY;
end;
end;
POS_LEFTCENTER: // :Integer = 8 ; //左中
begin
if (ssCtrl in CircKeyState) then begin
//清除前一次
Center :=Point ((StartPos.x + Endpos.x) div 2,(StartPos.y + Endpos.y) div 2);
mouseDiffX := mouseOldX - mouseDownOldX;
//mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tempStartPoint.X:=StartPos.X+MouseDiffX;
tempStartPoint.Y:=StartPos.Y;
tempendPoint.X :=EndPos.X-MouseDiffX;
tempendPoint.Y :=EndPos.Y;
//坐标变换
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
//mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tempStartPoint.X:=StartPos.X+MouseDiffX;
tempStartPoint.Y:=StartPos.Y;
tempendPoint.X :=EndPos.X-MouseDiffX;
tempendPoint.Y :=EndPos.Y;
//坐标变换
ChangPointXY;
end else begin
//清除前一次
mouseDiffX := mouseOldX - mouseDownOldX;
//mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tempStartPoint.X:=StartPos.X+MouseDiffX;
tempStartPoint.Y:=StartPos.Y;
tempendPoint:=endpos;
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
//mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tempStartPoint.X:=StartPos.X+MouseDiffX;
tempStartPoint.Y:=StartPos.Y;
tempendPoint:=endpos;
//坐标变换
ChangPointXY;
end;
end;
POS_CENTER: // :Integer = 9 ; //矩形中央
begin
//绘制图元
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
tempStartPoint :=Point( startPos.x + mouseDiffX,startPos.y + mouseDiffY);
tempEndPoint := Point( endPos.x + mouseDiffX,endPos.y + mouseDiffY);
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tempStartPoint :=Point(startPos.x + mouseDiffX, startPos.y + mouseDiffY);
tempEndPoint := Point(endPos.x + mouseDiffX,endPos.y + mouseDiffY);
//坐标变换
ChangPointXY;
end;
end;
end;
procedure TCircPic.PicChangedUpdate(ACanvas:TCanvas; mouseInPos: MOUSE_POS; chooseRect: TRect; //选择图元形成的矩形
mouseDownOldX, mouseDownOldY: Integer; mouseX, mouseY: Integer); //鼠标当前的坐标
//鼠标响应
var
tmprect:TRect;
MouseDiffX,MouseDiffY:Integer;
begin
//计算选择图元的宽度和高度
MouseDiffX:=Mousex-MouseDownOldX;
MouseDiffY:=MouseY-MouseDownOldY;
case mouseInPos of
POS_LEFTTOP: // :Integer = 1 ; //左上
begin
//确定基准点
if (ssCtrl in CircKeyState) then begin
StartPos:=Point(Mousex,mouseY);
EndPos.X:=EndPos.X-MouseDiffX;
EndPos.Y:=EndPos.Y-MouseDiffY;
end else begin
Inc(startPos.x, MouseDiffX);
Inc(startPos.y, MousediffY);
end;
end;
POS_RIGHTTOP: // :Integer = 2 ; //右上
begin
//确定基准点
if (ssCtrl in CircKeyState) then begin
StartPos.X:=StartPos.X-MouseDiffX;
StartPos.Y:=MouseY;
EndPos.X:=MouseX;
EndPos.Y:=EndPos.Y-MouseDiffY;
end else begin
Inc(startPos.y, MouseDiffY);
Inc(endPos.x, MouseDiffX);
end;
end;
POS_RIGHTBOTTOM: // :Integer = 3 ; //右下
begin
if (ssCtrl in CircKeyState) then begin
StartPos.X:=StartPos.X-MouseDiffX;
StartPos.Y:=StartPos.Y-MouseDiffY;
EndPos.X:=MouseX;
EndPos.Y:=MouseY;
end else begin
Inc(endPos.x, mouseX - mouseDownOldX);
Inc(endPos.y, mouseY - mouseDownOldY);
end;
end;
POS_LEFTBOTTOM: // :Integer = 4 ; //左下
begin
if (ssCtrl in CircKeyState) then begin
StartPos.X:=MouseX;
StartPos.Y:=StartPos.Y-MouseDiffY;
EndPos.X:=EndPos.X-MouseDiffX;
EndPos.Y:=MouseY;
end else begin
Inc(startPos.x, mouseX - mouseDownOldX);
Inc(endPos.Y, mouseY - mouseDownOldY);
end;
end;
POS_CENTERTOP: // :Integer = 5 ; //上中
begin
if (ssCtrl in CircKeyState) then begin
StartPos.Y:=MouseY;
EndPos.Y:=EndPos.Y-MouseDiffY;
end else begin
Inc(startPos.Y, mouseY - mouseDownOldY);
end;
end;
POS_RIGHTCENTER: // :Integer = 6 ; //右中
begin
if (ssCtrl in CircKeyState) then begin
StartPos.X:=StartPos.X-MouseDiffX;
EndPos.X:=EndPos.X+MouseDiffX;
end else begin
Inc(endPos.X, mouseX - mouseDownOldX);
end;
end;
POS_CENTERBUTTOM: // :Integer = 7 ; //下中
begin
if (ssCtrl in CircKeyState) then begin
StartPos.Y:=StartPos.Y-MouseDiffY;
EndPos.Y:=MouseY;
end else begin
Inc(endPos.Y, mouseY - mouseDownOldY);
end;
end;
POS_LEFTCENTER: // :Integer = 8 ; //左中
begin
if (ssCtrl in CircKeyState) then begin
StartPos.X:=StartPos.X+MouseDiffX;
EndPos.X:=EndPos.X-MouseDiffX;
end else begin
Inc(StartPos.X, mouseX - mouseDownOldX);
end;
end;
POS_CENTER: // :Integer = 9 ; //矩形中央
begin
Inc(startPos.x, mouseX - mouseDownOldX);
Inc(startPos.y, mouseY - mouseDownOldY);
Inc(endPos.x, mouseX - mouseDownOldX);
Inc(endPos.y, mouseY - mouseDownOldY);
end;
end;
//统一调整图元矩形区域和起点和终点的位置
//保证起点坐标小于终点坐标
with tmpRect do begin //调整图元矩形区域
Left := Min(startPos.x, endPos.x);
Top := Min(startPos.y, endpos.Y);
Right := Max(startPos.x, endPos.x);
Bottom := Max(startPos.y, endPos.y);
if Right = Left then Inc(Right, 2);
if Top = Bottom then Inc(Bottom, 2);
//更新坐标点
StartPos.X:=Left;StartPos.Y:=Top;
EndPos.X:=Right;EndPos.Y:=Bottom;
end;
PicRect:=tmpRect;
end;
procedure TCircPic.AssignPic(SourcePic: TPicBase);
begin
inherited AssignPic(SourcePic);
StartPos := TCircPic(SourcePic).PicStartPoint;
EndPos := TCircPic(SourcePic).PicEndPoint;
end;
//绘图函数
procedure TCircPic.DrawCircPic(ACanvas: TCanvas; startPoint:TPoint; endPoint:TPoint);
begin
ACanvas.Ellipse(StartPoint.X,StartPoint.Y,EndPoint.X,EndPoint.Y);
PicId:=PIC_CIRC;
end;
procedure TCircPic.GetClassDataFromChar(var Len:Integer; var Buf:Array of Char);
var
op,P:Pointer;
oLen:Integer;
begin
inherited GetClassDataFromChar(Len,Buf);
olen:=Len;
p:=Pointer(@Buf[Len]);
op:=p;
StartPos.X:=PInteger(P)^;
Inc(PInteger(P));
StartPos.Y:=PInteger(P)^;
Inc(PInteger(P));
EndPos.X:=PInteger(P)^;
Inc(PInteger(P));
EndPos.Y:=PInteger(P)^;
Inc(PInteger(P));
//Len:=oLen+AddrOffSet(op,P);
Len:=oLen+LongInt(P)-LongInt(Op);
end;
procedure TCircPic.SaveClassDataToChar(var Len:Integer; var Buf:Array of Char);
var
op,P:Pointer;
oLen:Integer;
begin
inherited SaveClassDataToChar(Len,Buf);
olen:=Len;
p:=Pointer(@Buf[Len]);
op:=p;
PInteger(P)^:=StartPos.X;
Inc(PInteger(P));
PInteger(P)^:=StartPos.Y;
Inc(PInteger(P));
PInteger(P)^:=EndPos.X;
Inc(PInteger(P));
PInteger(P)^:=EndPos.Y;
Inc(PInteger(P));
//Len:=oLen+AddrOffSet(op,P);
Len:=oLen+LongInt(P)-LongInt(Op);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -