📄 arccpic.pas
字号:
Left := Min(StartPos.x, endpos.x);
Top := Min(StartPos.y, endpos.y);
Right := Max(StartPos.x, endpos.x);
Bottom := Max(StartPos.y, endpos.y);
end;
PicRect:=tmpRect;
ACanvas.Pen := PicPen;
ACanvas.Brush := PicBrush;
ACanvas.Font := PicFont;
DrawArccPic(ACanvas, StartPos,EndPos,ArcStartPos,ArcEndPos);
fDrawState:=ARC_SET;
end;
ARC_SET: //确定圆弧的终点 圆弧绘制完毕
begin
//设置pen的格式
ACanvas.Pen:=PicPen;
ACanvas.Pen.Mode:=pmXor;
//设置Brush的格式
ACanvas.Brush:=PicBrush;
centerX := (EndPos.x + StartPos.x) div 2; //圆心
centerY := (EndPos.y + StartPos.y) div 2;
//清除前一次绘制的图形
DrawArccPic(ACanvas,StartPos,EndPos,ArcStartPos,ArcEndPos);
//if fArccType<>ARCC_SECTOR then begin
ACanvas.MoveTo(centerX, centerY);
ACanvas.LineTo(arcStartPos.x, arcStartPos.y);
ACanvas.MoveTo(centerX, centerY);
ACanvas.LineTo(arcEndPos.x, arcEndPos.y);
//end;
//重画图象用来擦除
arcEndPos := APoint;
pp[1] := arcEndPos;
DpToLp(ACanvas.Handle, pp[1], 1);
arcEndPos :=PointToCirclePoint(StartPos,EndPos,pp[1]);
//由于arcEndpoint是变化的,因此先确定刷新区域,
//以保证最后根线即使在Arc的区域外也能被清除
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);
end;
PicRect:=tmpRect;
ACanvas.Pen := PicPen;
ACanvas.Brush := PicBrush;
ACanvas.Font := PicFont;
DrawArccPic(ACanvas, StartPos,EndPos,ArcStartPos,ArcEndPos);
FDrawState:=ARC_DRAW;
if Assigned(DrawEndEvent) then DrawEndEvent(Self);
end;
end;
end;
//键盘响应
procedure TArccPic.ParentKeyDown(ACanvas:TCanvas;CursorNum:Integer; var Key: Word;
mouse: TPoint; Shift:TShiftState);
begin
//
end;
procedure TArccPic.ParentKeyUp(ACanvas:TCanvas;CursorNum:Integer; var Key: Word;
mouse: TPoint; Shift: TShiftState);
begin
//
end;
//图象改变
procedure TArccPic.PicChangeing(ACanvas:TCanvas; mouseInPos: MOUSE_POS; chooseRect:TRect;
mouseDownOldX, mouseDownOldY, mouseOldX, mouseOldY, mouseX, mouseY:Integer);
var
mouseDiffX: Integer;
mouseDiffY: Integer;
tmpSP, tmpEp: TPoint;
tmpArcSp,tmparcep:TPoint;
RectW,RectH:Integer;
Center:TPoint;
ratex,ratey:Single;
pp: array[1..4] of TPoint;
StartToEnd:Boolean;
procedure ConverPointXY;
begin
tmpsp.X:=Center.X+ Round((StartPos.x - Center.x) * rateX);
tmpsp.Y:=Center.Y+ Round((StartPos.Y - Center.Y) * rateY);
tmpep.X:=Center.X+ Round((endPos.x - Center.x) * rateX);
tmpep.Y:=Center.Y+ Round((EndPos.Y - Center.Y) * rateY);
tmparcsp.X:=Center.X+ Round((ArcStartPos.x - Center.x) * rateX);
tmparcsp.Y:=Center.Y+ Round((ArcStartPos.Y - Center.Y) * rateY);
tmparcep.X:=Center.X+ Round((ArcendPos.x - Center.x) * rateX);
tmparcep.Y:=Center.Y+ Round((ArcendPos.Y - Center.Y) * rateY);
end;
procedure ChangPointXY; //坐标变换 是否交换起点和钟点
begin
pp[1]:=tmpsp;
pp[2]:=tmpep;
pp[3]:=tmparcsp;
pp[4]:=tmparcep;
LptoDp(ACanvas.Handle,pp[1],4);
if StartToEnd then
DrawArccPic(ACanvas, pp[1],pp[2],pp[4],pp[3])
else
DrawArccPic(ACanvas, pp[1],pp[2],pp[3],pp[4]);
end;
begin
//ArccKeyState:=GetPicKeyState;
//坐标变换
pp[1]:=Point(mouseDownOldX,mouseDownOldY);
pp[2]:=Point(mouseOldX, mouseOldY);
pp[3]:=Point(mouseX, mouseY);
DPtoLP(ACanvas.Handle, pp, 3);
mouseDownOldX := pp[1].x;
mouseDownOldY := pp[1].y;
mouseOldX := pp[2].x;
mouseOldY := pp[2].y;
mouseX := pp[3].x;
mouseY := pp[3].y;
//设置绘图方式
ACanvas.Pen.Width := 1;
ACanvas.Pen.Mode := pmXor;
ACanvas.Pen.Style := psDot;
ACanvas.Brush.Style := bsClear;
//初始化变量值
RectW:=EndPos.X-StartPos.X;
RectH:=EndPos.Y-StartPos.Y;
Center :=Point ((StartPos.x + Endpos.x) div 2,(StartPos.y + Endpos.y) div 2);
StartToEnd:=False;
//计算选择图元的宽度和高度
case mouseInPos of
POS_LEFTTOP: // :Integer = 1 ; //左上
begin
{if (ssCtrl in ArccKeyState) then begin
//清除前一次
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
rateX := (RectW-MouseDiffX)/RectW;
rateY := (RectH-MouseDiffY)/RectH;
//坐标变换
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
rateX := (RectW-MouseDiffX)/RectW;
rateY := (RectH-MouseDiffY)/RectH;
//坐标变换
ChangPointXY;
end else begin }
//清除前一次
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
rateX := (RectW-MouseDiffX)/RectW;
rateY := (RectH-MouseDiffY)/RectH;
ConverPointXY;
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
rateX := (RectW-MouseDiffX)/RectW;
rateY := (RectH-MouseDiffY)/RectH;
//坐标变换
ConverPointXY;
ChangPointXY;
//end;
end;
POS_RIGHTTOP: // :Integer = 2 ; //右上
begin
{if (ssCtrl in ArccKeyState) then begin
//清除前一次
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
rateX := (RectW+MouseDiffX)/RectW;
rateY := (RectH-MouseDiffY)/RectH;
//坐标变换
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
rateX := (RectW+MouseDiffX)/RectW;
rateY := (RectH-MouseDiffY)/RectH;
//坐标变换
ChangPointXY;
end else begin }
//清除前一次
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
rateX := (RectW+MouseDiffX)/RectW;
rateY := (RectH-MouseDiffY)/RectH;
ConverPointXY;
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
rateX := (RectW+MouseDiffX)/RectW;
rateY := (RectH-MouseDiffY)/RectH;
//坐标变换
ConverPointXY;
ChangPointXY;
//end;
end;
POS_RIGHTBOTTOM: // :Integer = 3 ; //右下
begin
{if (ssCtrl in ArccKeyState) then begin
//清除前一次
Center :=Point ((StartPos.x + Endpos.x) div 2,(StartPos.y + Endpos.y) div 2);
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tmpsp :=Point(startPos.x - mouseDiffX, startPos.y - mouseDiffY);
tmpep :=Point(endPos.x + mouseDiffX, endPos.y + mouseDiffY);
//坐标变换
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tmpsp :=Point(startPos.x - mouseDiffX, startPos.y - mouseDiffY);
tmpep :=Point(endPos.x + mouseDiffX, endPos.y + mouseDiffY);
//坐标变换
ChangPointXY;
end else begin }
//清除前一次
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
rateX := (RectW+MouseDiffX)/RectW;
rateY := (RectH+MouseDiffY)/RectH;
ConverPointXY;
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
rateX := (RectW+MouseDiffX)/RectW;
rateY := (RectH+MouseDiffY)/RectH;
//坐标变换
ConverPointXY;
ChangPointXY;
//end;
end;
POS_LEFTBOTTOM: // :Integer = 4 ; //左下
begin
{if (ssCtrl in ArccKeyState) then begin
//清除前一次
Center :=Point ((StartPos.x + Endpos.x) div 2,(StartPos.y + Endpos.y) div 2);
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tmpsp :=Point(startPos.x + mouseDiffX, startPos.y - mouseDiffY);
tmpep :=Point(endPos.x - mouseDiffX, endPos.y + mouseDiffY);
//坐标变换
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tmpsp :=Point(startPos.x + mouseDiffX, startPos.y - mouseDiffY);
tmpep :=Point(endPos.x - mouseDiffX, endPos.y + mouseDiffY);
//坐标变换
ChangPointXY;
end else begin }
//清除前一次
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
rateX := (RectW-MouseDiffX)/RectW;
rateY := (RectH+MouseDiffY)/RectH;
ConverPointXY;
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
rateX := (RectW-MouseDiffX)/RectW;
rateY := (RectH+MouseDiffY)/RectH;
//坐标变换
ConverPointXY;
ChangPointXY;
//end;
end;
POS_CENTERTOP: // :Integer = 5 ; //上中
begin
{if (ssCtrl in ArccKeyState) then begin
//清除前一次
Center :=Point ((StartPos.x + Endpos.x) div 2,(StartPos.y + Endpos.y) div 2);
//mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tmpsp.X:=StartPos.X;
tmpsp.Y:=StartPos.Y+MouseDiffY;
tmpep.X :=EndPos.X;
tmpep.Y :=EndPos.Y-MouseDiffY;
//坐标变换
ChangPointXY;
//绘制当前虚线图元
//mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tmpsp.X:=StartPos.X;
tmpsp.Y:=StartPos.Y+MouseDiffY;
tmpep.X :=EndPos.X;
tmpep.Y :=EndPos.Y-MouseDiffY;
//坐标变换
ChangPointXY;
end else begin }
//清除前一次
//mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
rateX := 1; //(RectW-MouseDiffX)/RectW;
rateY := (RectH-MouseDiffY)/RectH;
ConverPointXY;
ChangPointXY;
//绘制当前虚线图元
//mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
rateX :=1; // (RectW-MouseDiffX)/RectW;
rateY := (RectH-MouseDiffY)/RectH;
//坐标变换
ConverPointXY;
ChangPointXY;
//end;
end;
POS_RIGHTCENTER: // :Integer = 6 ; //右中
begin
{if (ssCtrl in ArccKeyState) then begin
//清除前一次
Center :=Point ((StartPos.x + Endpos.x) div 2,(StartPos.y + Endpos.y) div 2);
mouseDiffX := mouseOldX - mouseDownOldX;
//mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tmpsp.X:=StartPos.X-MouseDiffX;
tmpsp.Y:=StartPos.Y;
tmpep.X :=EndPos.X+MouseDiffX;
tmpep.Y :=EndPos.Y;
//坐标变换
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
//mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tmpsp.X:=StartPos.X-MouseDiffX;
tmpsp.Y:=StartPos.Y;
tmpep.X :=EndPos.X+MouseDiffX;
tmpep.Y :=EndPos.Y;
//坐标变换
ChangPointXY;
end else begin }
//清除前一次
mouseDiffX := mouseOldX - mouseDownOldX;
//mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
rateX := (RectW+MouseDiffX)/RectW;
rateY :=1; // (RectH-MouseDiffY)/RectH;
ConverPointXY;
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
//mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
rateX := (RectW+MouseDiffX)/RectW;
rateY :=1; // (RectH-MouseDiffY)/RectH;
//坐标变换
ConverPointXY;
ChangPointXY;
//end;
end;
POS_CENTERBUTTOM: // :Integer = 7 ; //下中
begin
{if (ssCtrl in ArccKeyState) then begin
//清除前一次
Center :=Point ((StartPos.x + Endpos.x) div 2,(StartPos.y + Endpos.y) div 2);
//mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tmpsp.X:=StartPos.X;
tmpsp.Y:=StartPos.Y-MousediffY;
tmpep.X :=EndPos.X;
tmpep.Y :=EndPos.Y+MouseDiffY;
//坐标变换
ChangPointXY;
//绘制当前虚线图元
//mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tmpsp.X:=StartPos.X;
tmpsp.Y:=StartPos.Y-MouseDiffY;
tmpep.X :=EndPos.X;
tmpep.Y :=EndPos.Y+MouseDiffY;
//坐标变换
ChangPointXY;
end else begin }
//清除前一次
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -