?? arccpic.pas
字號:
//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_LEFTCENTER: // :Integer = 8 ; //左中
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;
//坐標變換
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_ARCSTART: //圓弧起點
begin
//繪制圖元
{if fARccType=ARCC_ARC Then} StartToEnd:=True;
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
tmpsp :=StartPos;
tmpep := EndPos;
pp[1].X:=arcstartpos.X+mouseDiffX;
pp[1].Y:=arcstartPos.Y+mouseDiffY;
tmparcsp:=PointToCirclePoint(StartPos,EndPos,pp[1]);
tmparcep:=ArcEndPos;
ChangPointXY;
//繪制當前虛線圖元
//繪制圖元
mouseDiffX := Mousex-mouseDownOldX;
mouseDiffY := MouseY-mouseDownOldY;
tmpsp :=StartPos;
tmpep := EndPos;
pp[1].X:=arcstartpos.X+mouseDiffX;
pp[1].Y:=arcstartPos.Y+mouseDiffY;
tmparcsp:=PointToCirclePoint(StartPos,EndPos,pp[1]);
tmparcep:=ArcEndPos;
ChangPointXY;
end;
POS_ARCEND: //圓角左
begin
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
tmpsp :=StartPos;
tmpep := EndPos;
pp[1].X:=arcendpos.X+mouseDiffX;
pp[1].Y:=arcendPos.Y+mouseDiffY;
tmparcsp:=ArcStartPos;
tmparcep:=PointToCirclePoint(StartPos,EndPos,pp[1]);
ChangPointXY;
//繪制當前虛線圖元
//繪制圖元
mouseDiffX := Mousex-mouseDownOldX;
mouseDiffY := MouseY-mouseDownOldY;
tmpsp :=StartPos;
tmpep := EndPos;
pp[1].X:=arcendpos.X+mouseDiffX;
pp[1].Y:=arcendPos.Y+mouseDiffY;
tmparcsp:=ArcStartPos;
tmparcep:=PointToCirclePoint(StartPos,EndPos,pp[1]);
ChangPointXY;
end;
POS_CENTER: // :Integer = 9 ; //矩形中央
begin
//繪制圖元
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
tmpsp :=Point( startPos.x + mouseDiffX,startPos.y + mouseDiffY);
tmpep := Point( endPos.x + mouseDiffX,endPos.y + mouseDiffY);
tmparcsp :=Point( arcstartPos.x + mouseDiffX,arcstartPos.y + mouseDiffY);
tmparcep := Point( arcendPos.x + mouseDiffX,arcendPos.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);
tmparcsp :=Point( arcstartPos.x + mouseDiffX,arcstartPos.y + mouseDiffY);
tmparcep := Point( arcendPos.x + mouseDiffX,arcendPos.y + mouseDiffY);
//坐標變換
ChangPointXY;
end;
end;
end;
procedure TArccPic.PicChangedUpdate(ACanvas:TCanvas; mouseInPos: MOUSE_POS;chooseRect: TRect; //選擇圖元形成的矩形
mouseDownOldX, mouseDownOldY: Integer; mouseX, mouseY: Integer); //鼠標當前的坐標
var
tmprect:TRect;
MouseDiffX,MouseDiffY:Integer;
Center:TPoint;
ratex,ratey:Single;
rectw,recth:Integer;
procedure UpdateConverPointXY;
begin
StartPos.X:=Center.X+ Round((StartPos.x - Center.x) * rateX);
StartPos.Y:=Center.Y+ Round((StartPos.Y - Center.Y) * rateY);
endPos.X:=Center.X+ Round((endPos.x - Center.x) * rateX);
endPos.Y:=Center.Y+ Round((EndPos.Y - Center.Y) * rateY);
arcstartPos.X:=Center.X+ Round((ArcStartPos.x - Center.x) * rateX);
arcstartpos.Y:=Center.Y+ Round((ArcStartPos.Y - Center.Y) * rateY);
arcendpos.X:=Center.X+ Round((ArcendPos.x - Center.x) * rateX);
arcendpos.Y:=Center.Y+ Round((ArcendPos.Y - Center.Y) * rateY);
end;
begin
//計算選擇圖元的寬度和高度
MouseDiffX:=Mousex-MouseDownOldX;
MouseDiffY:=MouseY-MouseDownOldY;
RectW:=EndPos.X-StartPos.X;
RectH:=EndPos.Y-StartPos.Y;
Center :=Point ((StartPos.x + Endpos.x) div 2,(StartPos.y + Endpos.y) div 2);
case mouseInPos of
POS_LEFTTOP: // :Integer = 1 ; //左上
begin
//確定基準點
{if (ssCtrl in ArccKeyState) then begin
StartPos:=Point(Mousex,mouseY);
EndPos.X:=EndPos.X-MouseDiffX;
EndPos.Y:=EndPos.Y-MouseDiffY;
end else begin }
rateX := (RectW-MouseDiffX)/RectW;
rateY := (RectH-MouseDiffY)/RectH;
UpdateConverPointXY;
//end;
end;
POS_RIGHTTOP: // :Integer = 2 ; //右上
begin
//確定基準點
{if (ssCtrl in ArccKeyState) then begin
StartPos.X:=StartPos.X-MouseDiffX;
StartPos.Y:=MouseY;
EndPos.X:=MouseX;
EndPos.Y:=EndPos.Y-MouseDiffY;
end else begin }
rateX := (RectW+MouseDiffX)/RectW;
rateY := (RectH-MouseDiffY)/RectH;
UpdateConverPointXY;
//end;
end;
POS_RIGHTBOTTOM: // :Integer = 3 ; //右下
begin
{if (ssCtrl in ArccKeyState) then begin
StartPos.X:=StartPos.X-MouseDiffX;
StartPos.Y:=StartPos.Y-MouseDiffY;
EndPos.X:=MouseX;
EndPos.Y:=MouseY;
end else begin }
rateX := (RectW+MouseDiffX)/RectW;
rateY := (RectH+MouseDiffY)/RectH;
UpdateConverPointXY;
//end;
end;
POS_LEFTBOTTOM: // :Integer = 4 ; //左下
begin
{if (ssCtrl in ArccKeyState) then begin
StartPos.X:=MouseX;
StartPos.Y:=StartPos.Y-MouseDiffY;
EndPos.X:=EndPos.X-MouseDiffX;
EndPos.Y:=MouseY;
end else begin }
rateX := (RectW-MouseDiffX)/RectW;
rateY := (RectH+MouseDiffY)/RectH;
UpdateConverPointXY;
//end;
end;
POS_CENTERTOP: // :Integer = 5 ; //上中
begin
{if (ssCtrl in ArccKeyState) then begin
StartPos.Y:=MouseY;
EndPos.Y:=EndPos.Y-MouseDiffY;
end else begin }
rateX :=1; // (RectW-MouseDiffX)/RectW;
rateY := (RectH-MouseDiffY)/RectH;
UpdateConverPointXY;
//end;
end;
POS_RIGHTCENTER: // :Integer = 6 ; //右中
begin
{if (ssCtrl in ArccKeyState) then begin
StartPos.X:=StartPos.X-MouseDiffX;
EndPos.X:=EndPos.X+MouseDiffX;
end else begin }
rateX := (RectW+MouseDiffX)/RectW;
rateY :=1; // (RectH-MouseDiffY)/RectH;
UpdateConverPointXY;
//end;
end;
POS_CENTERBUTTOM: // :Integer = 7 ; //下中
begin
{if (ssCtrl in ArccKeyState) then begin
StartPos.Y:=StartPos.Y-MouseDiffY;
EndPos.Y:=MouseY;
end else begin }
rateX :=1; // (RectW-MouseDiffX)/RectW;
rateY := (RectH+MouseDiffY)/RectH;
UpdateConverPointXY;
//end;
end;
POS_LEFTCENTER: // :Integer = 8 ; //左中
begin
{if (ssCtrl in ArccKeyState) then begin
StartPos.X:=StartPos.X+MouseDiffX;
EndPos.X:=EndPos.X-MouseDiffX;
end else begin }
rateX := (RectW-MouseDiffX)/RectW;
rateY :=1; // (RectH-MouseDiffY)/RectH;
UpdateConverPointXY;
//end;
end;
POS_ARCSTART: //圓角上
begin
center.X:=arcstartpos.X+mouseDiffX;
center.Y:=arcstartPos.Y+mouseDiffY;
ArcStartPos:=PointToCirclePoint(StartPos,EndPos,Center);
end;
POS_ARCEND: //圓角左
begin
center.X:=arcendpos.X+mouseDiffX;
center.Y:=arcendPos.Y+mouseDiffY;
ArcEndPos:=PointToCirclePoint(StartPos,EndPos,Center);
end;
POS_CENTER: // :Integer = 9 ; //矩形中央
begin
Inc(startPos.x, MouseDiffx);
Inc(startPos.y, MouseDiffY);
Inc(endPos.x, MouseDiffx);
Inc(endPos.y, MouseDiffY);
Inc(arcstartPos.x, MouseDiffx);
Inc(arcstartPos.y, MouseDiffY);
Inc(arcendPos.x, MouseDiffx);
Inc(arcendPos.y, MouseDiffY);
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);
//更新坐標點
end;
StartPos:=tmpRect.TopLeft;
EndPos:=tmpRect.BottomRight;
PicRect:=tmpRect;
end;
//位置代碼可參見 PicConst.pas
procedure TArccPic.AssignPic(SourcePic: TPicBase);
begin
inherited AssignPic(SourcePic);
StartPos := TArccPic(SourcePic).PicStartPoint;
EndPos := TArccPic(SourcePic).PicEndPoint;
ArcStartPos:= TArccPic(SourcePic).PicArcStart;
ArcEndPos:=TArccPic(SourcePic).PicArcStop;
fArccType:=TArccPic(SourcePic).PicArccType;
end;
//非重載函數
//繪圖函數
procedure TArccPic.DrawArccPic(ACanvas: TCanvas; startPoint:TPoint; endPoint:TPoint;ArcsPoint:TPoint;ArcePoint:TPoint);
begin
Case fArccType of //Arcc_Arc,Arcc_Sector,Acrr_Chord
Arcc_Arc: // Arc
begin
ACanvas.Arc(StartPoint.X,StartPoint.Y, EndPoint.X, EndPoint.Y, ArcSPoint.X,
ArcSPoint.Y,ArcePoint.X, ArcePoint.Y);
end;
Arcc_Sector: //PIE
begin
ACanvas.Pie(StartPoint.X,StartPoint.Y, EndPoint.X, EndPoint.Y, ArcSPoint.X,
ArcSPoint.Y,ArcePoint.X, ArcePoint.Y);
end;
Arcc_Chord: //Chord
begin
ACanvas.Chord(StartPoint.X,StartPoint.Y, EndPoint.X, EndPoint.Y, ArcSPoint.X,
ArcSPoint.Y,ArcePoint.X, ArcePoint.Y);
end;
end;
PicId:=PIC_ARCC;
end;
procedure TArccPic.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;
fArccType:=TArccType(PByte(P)^);
Inc(PByte(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));
ArcStartPos.X:=PInteger(P)^;
Inc(PInteger(P));
ArcStartPos.Y:=PInteger(P)^;
Inc(PInteger(P));
ArcEndPos.X:=PInteger(P)^;
Inc(PInteger(P));
ArcEndPos.Y:=PInteger(P)^;
Inc(PInteger(P));
//Len:=oLen+AddrOffSet(op,P);
Len:=oLen+LongInt(P)-LongInt(Op);
end;
procedure TArccPic.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;
PByte(P)^:=Ord(fArccType);
Inc(PByte(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));
PInteger(P)^:=ArcStartPos.X;
Inc(PInteger(P));
PInteger(P)^:=ArcStartPos.Y;
Inc(PInteger(P));
PInteger(P)^:=ArcEndPos.X;
Inc(PInteger(P));
PInteger(P)^:=ArcEndPos.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 + -