some new editor stuff, not really optimized yet...
This commit is contained in:
parent
29bfa4d098
commit
e051042bb9
@ -9,11 +9,13 @@ type
|
|||||||
TCustomDrawControl = class(TCustomControl)
|
TCustomDrawControl = class(TCustomControl)
|
||||||
private
|
private
|
||||||
FOnPaint: TNotifyEvent;
|
FOnPaint: TNotifyEvent;
|
||||||
|
FOnLeave: TNotifyEvent;
|
||||||
|
|
||||||
procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
|
procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
|
||||||
procedure WMSetFocus(var Message: TWMSetFocus); message WM_SETFOCUS;
|
procedure WMSetFocus(var Message: TWMSetFocus); message WM_SETFOCUS;
|
||||||
procedure WMKillFocus(var Message: TWMKillFocus); message WM_KILLFOCUS;
|
procedure WMKillFocus(var Message: TWMKillFocus); message WM_KILLFOCUS;
|
||||||
procedure WMGetDlgCode(var Message: TMessage); message WM_GETDLGCODE;
|
procedure WMGetDlgCode(var Message: TMessage); message WM_GETDLGCODE;
|
||||||
|
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
|
||||||
protected
|
protected
|
||||||
|
|
||||||
public
|
public
|
||||||
@ -34,6 +36,7 @@ type
|
|||||||
// property OnMouseWheelUp;
|
// property OnMouseWheelUp;
|
||||||
property OnEnter;
|
property OnEnter;
|
||||||
property OnExit;
|
property OnExit;
|
||||||
|
property OnMouseLeave: TNotifyEvent read FOnLeave write FOnLeave;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -60,6 +63,11 @@ begin
|
|||||||
Message.Result := Message.Result or DLGC_WANTARROWS;
|
Message.Result := Message.Result or DLGC_WANTARROWS;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomDrawControl.CMMouseLeave(var Message: TMessage);
|
||||||
|
begin
|
||||||
|
if Assigned(FOnLeave) then FOnLeave(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomDrawControl.Paint;
|
procedure TCustomDrawControl.Paint;
|
||||||
begin
|
begin
|
||||||
if Assigned(FOnPaint) then FOnPaint(Self);
|
if Assigned(FOnPaint) then FOnPaint(Self);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
object EditForm: TEditForm
|
object EditForm: TEditForm
|
||||||
Left = 377
|
Left = 350
|
||||||
Top = 179
|
Top = 163
|
||||||
Width = 586
|
Width = 586
|
||||||
Height = 600
|
Height = 586
|
||||||
Caption = 'Transform Editor'
|
Caption = 'Transform Editor'
|
||||||
Color = clBtnFace
|
Color = clBtnFace
|
||||||
Constraints.MinHeight = 400
|
Constraints.MinHeight = 400
|
||||||
@ -54,7 +54,7 @@ object EditForm: TEditForm
|
|||||||
TextHeight = 13
|
TextHeight = 13
|
||||||
object StatusBar: TStatusBar
|
object StatusBar: TStatusBar
|
||||||
Left = 0
|
Left = 0
|
||||||
Top = 557
|
Top = 543
|
||||||
Width = 578
|
Width = 578
|
||||||
Height = 15
|
Height = 15
|
||||||
Panels = <
|
Panels = <
|
||||||
@ -333,14 +333,14 @@ object EditForm: TEditForm
|
|||||||
Left = 0
|
Left = 0
|
||||||
Top = 24
|
Top = 24
|
||||||
Width = 578
|
Width = 578
|
||||||
Height = 533
|
Height = 519
|
||||||
Align = alClient
|
Align = alClient
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
object Splitter1: TSplitter
|
object Splitter1: TSplitter
|
||||||
Left = 396
|
Left = 396
|
||||||
Top = 1
|
Top = 1
|
||||||
Width = 9
|
Width = 9
|
||||||
Height = 531
|
Height = 517
|
||||||
Align = alRight
|
Align = alRight
|
||||||
AutoSnap = False
|
AutoSnap = False
|
||||||
Beveled = True
|
Beveled = True
|
||||||
@ -351,7 +351,7 @@ object EditForm: TEditForm
|
|||||||
Left = 1
|
Left = 1
|
||||||
Top = 1
|
Top = 1
|
||||||
Width = 395
|
Width = 395
|
||||||
Height = 531
|
Height = 517
|
||||||
Align = alClient
|
Align = alClient
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
Color = clAppWorkSpace
|
Color = clAppWorkSpace
|
||||||
@ -361,7 +361,7 @@ object EditForm: TEditForm
|
|||||||
Left = 405
|
Left = 405
|
||||||
Top = 1
|
Top = 1
|
||||||
Width = 172
|
Width = 172
|
||||||
Height = 531
|
Height = 517
|
||||||
Align = alRight
|
Align = alRight
|
||||||
Alignment = taLeftJustify
|
Alignment = taLeftJustify
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
@ -401,7 +401,7 @@ object EditForm: TEditForm
|
|||||||
Left = 0
|
Left = 0
|
||||||
Top = 136
|
Top = 136
|
||||||
Width = 172
|
Width = 172
|
||||||
Height = 395
|
Height = 381
|
||||||
Align = alClient
|
Align = alClient
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object lblTransform: TLabel
|
object lblTransform: TLabel
|
||||||
@ -434,7 +434,7 @@ object EditForm: TEditForm
|
|||||||
Left = 1
|
Left = 1
|
||||||
Top = 26
|
Top = 26
|
||||||
Width = 170
|
Width = 170
|
||||||
Height = 368
|
Height = 354
|
||||||
ActivePage = TriangleTab
|
ActivePage = TriangleTab
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
Anchors = [akLeft, akTop, akRight, akBottom]
|
Anchors = [akLeft, akTop, akRight, akBottom]
|
||||||
@ -447,7 +447,7 @@ object EditForm: TEditForm
|
|||||||
Left = 0
|
Left = 0
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 162
|
Width = 162
|
||||||
Height = 322
|
Height = 308
|
||||||
HorzScrollBar.Visible = False
|
HorzScrollBar.Visible = False
|
||||||
VertScrollBar.Smooth = True
|
VertScrollBar.Smooth = True
|
||||||
VertScrollBar.Style = ssFlat
|
VertScrollBar.Style = ssFlat
|
||||||
@ -1156,65 +1156,65 @@ object EditForm: TEditForm
|
|||||||
object tabXForm: TTabSheet
|
object tabXForm: TTabSheet
|
||||||
Caption = 'Transform'
|
Caption = 'Transform'
|
||||||
object lbla: TLabel
|
object lbla: TLabel
|
||||||
Left = 9
|
Left = 4
|
||||||
Top = 12
|
Top = 8
|
||||||
Width = 10
|
Width = 10
|
||||||
Height = 13
|
Height = 13
|
||||||
Caption = 'a:'
|
Caption = 'a:'
|
||||||
end
|
end
|
||||||
object Label1: TLabel
|
object Label1: TLabel
|
||||||
Left = 9
|
Left = 82
|
||||||
Top = 36
|
Top = 8
|
||||||
Width = 10
|
Width = 10
|
||||||
Height = 13
|
Height = 13
|
||||||
Caption = 'b:'
|
Caption = 'b:'
|
||||||
end
|
end
|
||||||
object Label2: TLabel
|
object Label2: TLabel
|
||||||
Left = 9
|
Left = 4
|
||||||
Top = 60
|
Top = 32
|
||||||
Width = 9
|
Width = 9
|
||||||
Height = 13
|
Height = 13
|
||||||
Caption = 'c:'
|
Caption = 'c:'
|
||||||
end
|
end
|
||||||
object Label3: TLabel
|
object Label3: TLabel
|
||||||
Left = 9
|
Left = 82
|
||||||
Top = 84
|
Top = 32
|
||||||
Width = 10
|
Width = 10
|
||||||
Height = 13
|
Height = 13
|
||||||
Caption = 'd:'
|
Caption = 'd:'
|
||||||
end
|
end
|
||||||
object Label4: TLabel
|
object Label4: TLabel
|
||||||
Left = 9
|
Left = 4
|
||||||
Top = 108
|
Top = 56
|
||||||
Width = 10
|
Width = 10
|
||||||
Height = 13
|
Height = 13
|
||||||
Caption = 'e:'
|
Caption = 'e:'
|
||||||
end
|
end
|
||||||
object Label5: TLabel
|
object Label5: TLabel
|
||||||
Left = 9
|
Left = 82
|
||||||
Top = 132
|
Top = 56
|
||||||
Width = 8
|
Width = 8
|
||||||
Height = 13
|
Height = 13
|
||||||
Caption = 'f:'
|
Caption = 'f:'
|
||||||
end
|
end
|
||||||
object Label6: TLabel
|
object Label6: TLabel
|
||||||
Left = 9
|
Left = 36
|
||||||
Top = 156
|
Top = 84
|
||||||
Width = 38
|
Width = 38
|
||||||
Height = 13
|
Height = 13
|
||||||
Caption = 'Weight:'
|
Caption = 'Weight:'
|
||||||
end
|
end
|
||||||
object Label29: TLabel
|
object Label29: TLabel
|
||||||
Left = 9
|
Left = 36
|
||||||
Top = 180
|
Top = 108
|
||||||
Width = 52
|
Width = 52
|
||||||
Height = 13
|
Height = 13
|
||||||
Caption = 'Symmetry:'
|
Caption = 'Symmetry:'
|
||||||
end
|
end
|
||||||
object txtA: TEdit
|
object txtA: TEdit
|
||||||
Left = 32
|
Left = 20
|
||||||
Top = 8
|
Top = 4
|
||||||
Width = 110
|
Width = 57
|
||||||
Height = 21
|
Height = 21
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
Text = '0'
|
Text = '0'
|
||||||
@ -1222,9 +1222,9 @@ object EditForm: TEditForm
|
|||||||
OnKeyPress = CoefKeyPress
|
OnKeyPress = CoefKeyPress
|
||||||
end
|
end
|
||||||
object txtB: TEdit
|
object txtB: TEdit
|
||||||
Left = 32
|
Left = 96
|
||||||
Top = 32
|
Top = 4
|
||||||
Width = 110
|
Width = 57
|
||||||
Height = 21
|
Height = 21
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
Text = '0'
|
Text = '0'
|
||||||
@ -1232,9 +1232,9 @@ object EditForm: TEditForm
|
|||||||
OnKeyPress = CoefKeyPress
|
OnKeyPress = CoefKeyPress
|
||||||
end
|
end
|
||||||
object txtC: TEdit
|
object txtC: TEdit
|
||||||
Left = 32
|
Left = 20
|
||||||
Top = 56
|
Top = 28
|
||||||
Width = 110
|
Width = 57
|
||||||
Height = 21
|
Height = 21
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
Text = '0'
|
Text = '0'
|
||||||
@ -1242,9 +1242,9 @@ object EditForm: TEditForm
|
|||||||
OnKeyPress = CoefKeyPress
|
OnKeyPress = CoefKeyPress
|
||||||
end
|
end
|
||||||
object txtD: TEdit
|
object txtD: TEdit
|
||||||
Left = 32
|
Left = 96
|
||||||
Top = 80
|
Top = 28
|
||||||
Width = 110
|
Width = 57
|
||||||
Height = 21
|
Height = 21
|
||||||
TabOrder = 3
|
TabOrder = 3
|
||||||
Text = '0'
|
Text = '0'
|
||||||
@ -1252,9 +1252,9 @@ object EditForm: TEditForm
|
|||||||
OnKeyPress = CoefKeyPress
|
OnKeyPress = CoefKeyPress
|
||||||
end
|
end
|
||||||
object txtE: TEdit
|
object txtE: TEdit
|
||||||
Left = 32
|
Left = 20
|
||||||
Top = 104
|
Top = 52
|
||||||
Width = 110
|
Width = 57
|
||||||
Height = 21
|
Height = 21
|
||||||
TabOrder = 4
|
TabOrder = 4
|
||||||
Text = '0'
|
Text = '0'
|
||||||
@ -1262,9 +1262,9 @@ object EditForm: TEditForm
|
|||||||
OnKeyPress = CoefKeyPress
|
OnKeyPress = CoefKeyPress
|
||||||
end
|
end
|
||||||
object txtF: TEdit
|
object txtF: TEdit
|
||||||
Left = 32
|
Left = 96
|
||||||
Top = 128
|
Top = 52
|
||||||
Width = 110
|
Width = 57
|
||||||
Height = 21
|
Height = 21
|
||||||
TabOrder = 5
|
TabOrder = 5
|
||||||
Text = '0'
|
Text = '0'
|
||||||
@ -1272,9 +1272,9 @@ object EditForm: TEditForm
|
|||||||
OnKeyPress = CoefKeyPress
|
OnKeyPress = CoefKeyPress
|
||||||
end
|
end
|
||||||
object txtP: TEdit
|
object txtP: TEdit
|
||||||
Left = 72
|
Left = 96
|
||||||
Top = 152
|
Top = 80
|
||||||
Width = 70
|
Width = 57
|
||||||
Height = 21
|
Height = 21
|
||||||
TabOrder = 6
|
TabOrder = 6
|
||||||
Text = '0'
|
Text = '0'
|
||||||
@ -1282,9 +1282,9 @@ object EditForm: TEditForm
|
|||||||
OnKeyPress = txtPKeyPress
|
OnKeyPress = txtPKeyPress
|
||||||
end
|
end
|
||||||
object txtSymmetry: TEdit
|
object txtSymmetry: TEdit
|
||||||
Left = 72
|
Left = 96
|
||||||
Top = 176
|
Top = 104
|
||||||
Width = 70
|
Width = 57
|
||||||
Height = 21
|
Height = 21
|
||||||
TabOrder = 7
|
TabOrder = 7
|
||||||
Text = '0'
|
Text = '0'
|
||||||
@ -1298,7 +1298,7 @@ object EditForm: TEditForm
|
|||||||
Left = 0
|
Left = 0
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 162
|
Width = 162
|
||||||
Height = 322
|
Height = 308
|
||||||
Align = alClient
|
Align = alClient
|
||||||
ScrollBars = ssVertical
|
ScrollBars = ssVertical
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
@ -1324,7 +1324,7 @@ object EditForm: TEditForm
|
|||||||
Left = 0
|
Left = 0
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 162
|
Width = 162
|
||||||
Height = 322
|
Height = 308
|
||||||
Align = alClient
|
Align = alClient
|
||||||
ScrollBars = ssVertical
|
ScrollBars = ssVertical
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
@ -1450,15 +1450,16 @@ object EditForm: TEditForm
|
|||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
OnClick = chkUseXFormColorClick
|
OnClick = chkUseXFormColorClick
|
||||||
end
|
end
|
||||||
object chkFlameBack: TCheckBox
|
object chkHelpers: TCheckBox
|
||||||
Left = 8
|
Left = 8
|
||||||
Top = 36
|
Top = 36
|
||||||
Width = 129
|
Width = 129
|
||||||
Height = 17
|
Height = 17
|
||||||
Caption = 'Use flame background'
|
Caption = 'Enable helpers'
|
||||||
Enabled = False
|
Checked = True
|
||||||
|
State = cbChecked
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
OnClick = chkFlameBackClick
|
OnClick = chkHelpersClick
|
||||||
end
|
end
|
||||||
object pnlReference: TPanel
|
object pnlReference: TPanel
|
||||||
Left = 8
|
Left = 8
|
||||||
@ -1502,7 +1503,7 @@ object EditForm: TEditForm
|
|||||||
object EditPopup: TPopupMenu
|
object EditPopup: TPopupMenu
|
||||||
AutoPopup = False
|
AutoPopup = False
|
||||||
Images = EditorTB
|
Images = EditorTB
|
||||||
Left = 360
|
Left = 352
|
||||||
Top = 40
|
Top = 40
|
||||||
object mnuAutoZoom: TMenuItem
|
object mnuAutoZoom: TMenuItem
|
||||||
Caption = 'Auto Zoom'
|
Caption = 'Auto Zoom'
|
||||||
@ -1613,7 +1614,7 @@ object EditForm: TEditForm
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
object EditorTB: TImageList
|
object EditorTB: TImageList
|
||||||
Left = 361
|
Left = 353
|
||||||
Top = 80
|
Top = 80
|
||||||
Bitmap = {
|
Bitmap = {
|
||||||
494C01010D000E00040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
|
494C01010D000E00040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
|
||||||
|
@ -88,7 +88,7 @@ type
|
|||||||
Label21: TLabel;
|
Label21: TLabel;
|
||||||
pnlBackColor: TPanel;
|
pnlBackColor: TPanel;
|
||||||
chkUseXFormColor: TCheckBox;
|
chkUseXFormColor: TCheckBox;
|
||||||
chkFlameBack: TCheckBox;
|
chkHelpers: TCheckBox;
|
||||||
pnlReference: TPanel;
|
pnlReference: TPanel;
|
||||||
TriangleScrollBox: TScrollBox;
|
TriangleScrollBox: TScrollBox;
|
||||||
TrianglePanel: TPanel;
|
TrianglePanel: TPanel;
|
||||||
@ -176,6 +176,7 @@ type
|
|||||||
procedure TriangleViewKeyUp(Sender: TObject; var Key: Word;
|
procedure TriangleViewKeyUp(Sender: TObject; var Key: Word;
|
||||||
Shift: TShiftState);
|
Shift: TShiftState);
|
||||||
procedure TriangleViewExit(Sender: TObject);
|
procedure TriangleViewExit(Sender: TObject);
|
||||||
|
procedure TriangleViewMouseLeave(Sender: TObject);
|
||||||
|
|
||||||
procedure FormShow(Sender: TObject);
|
procedure FormShow(Sender: TObject);
|
||||||
procedure mnuDeleteClick(Sender: TObject);
|
procedure mnuDeleteClick(Sender: TObject);
|
||||||
@ -208,7 +209,7 @@ type
|
|||||||
ScrollCode: TScrollCode; var ScrollPos: Integer);
|
ScrollCode: TScrollCode; var ScrollPos: Integer);
|
||||||
procedure scrlXFormColorChange(Sender: TObject);
|
procedure scrlXFormColorChange(Sender: TObject);
|
||||||
procedure chkUseXFormColorClick(Sender: TObject);
|
procedure chkUseXFormColorClick(Sender: TObject);
|
||||||
procedure chkFlameBackClick(Sender: TObject);
|
procedure chkHelpersClick(Sender: TObject);
|
||||||
procedure pnlBackColorClick(Sender: TObject);
|
procedure pnlBackColorClick(Sender: TObject);
|
||||||
procedure pnlReferenceClick(Sender: TObject);
|
procedure pnlReferenceClick(Sender: TObject);
|
||||||
procedure txtXFormColorExit(Sender: TObject);
|
procedure txtXFormColorExit(Sender: TObject);
|
||||||
@ -301,9 +302,7 @@ type
|
|||||||
SelectMode: boolean;
|
SelectMode: boolean;
|
||||||
HasChanged: boolean;
|
HasChanged: boolean;
|
||||||
|
|
||||||
oldx, oldy: double;
|
oldx, oldy, olddist: double;
|
||||||
// --Z--
|
|
||||||
olddist: double;
|
|
||||||
Pivot: TSPoint;
|
Pivot: TSPoint;
|
||||||
VarsCache: array[0..64] of double; // hack: to prevent slow valuelist redraw
|
VarsCache: array[0..64] of double; // hack: to prevent slow valuelist redraw
|
||||||
|
|
||||||
@ -375,6 +374,8 @@ var
|
|||||||
gCenterX: double;
|
gCenterX: double;
|
||||||
gCenterY: double;
|
gCenterY: double;
|
||||||
|
|
||||||
|
HelpersEnabled: boolean = true;
|
||||||
|
|
||||||
{$R *.DFM}
|
{$R *.DFM}
|
||||||
|
|
||||||
{ Triangle transformations }
|
{ Triangle transformations }
|
||||||
@ -880,6 +881,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEditForm.TriangleViewPaint(Sender: TObject);
|
procedure TEditForm.TriangleViewPaint(Sender: TObject);
|
||||||
|
const
|
||||||
|
foc_ofs = 4;
|
||||||
|
foc_size = 32;
|
||||||
var
|
var
|
||||||
ix, iy, sc: double;
|
ix, iy, sc: double;
|
||||||
|
|
||||||
@ -890,6 +894,8 @@ var
|
|||||||
end;
|
end;
|
||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
|
d, d1, dx, dy, k: double;
|
||||||
|
tx, ty: double;
|
||||||
|
|
||||||
ax, ay: integer;
|
ax, ay: integer;
|
||||||
a, b, c: TPoint;
|
a, b, c: TPoint;
|
||||||
@ -919,17 +925,10 @@ begin
|
|||||||
brush.Color := pnlBackColor.Color;
|
brush.Color := pnlBackColor.Color;
|
||||||
FillRect(Rect(0, 0, Width, Height));
|
FillRect(Rect(0, 0, Width, Height));
|
||||||
|
|
||||||
if TWinControl(Sender).Focused then
|
|
||||||
begin
|
|
||||||
brush.Color := GridColor1;
|
|
||||||
FrameRect(Rect(1, 1, Width-1, Height-1));
|
|
||||||
// Rectangle(Rect(1, 1, Width-1, Height-1));
|
|
||||||
brush.Color := pnlBackColor.Color;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// draw grid
|
|
||||||
Pen.Style := psSolid;
|
Pen.Style := psSolid;
|
||||||
Pen.Width := 1;
|
Pen.Width := 1;
|
||||||
|
|
||||||
|
// draw grid
|
||||||
Pen.Color := GridColor2;
|
Pen.Color := GridColor2;
|
||||||
gridX1:=gCenterX-ix/sc;
|
gridX1:=gCenterX-ix/sc;
|
||||||
gridX2:=gCenterX+(Width-ix)/sc;
|
gridX2:=gCenterX+(Width-ix)/sc;
|
||||||
@ -972,16 +971,15 @@ begin
|
|||||||
{Reference Triangle}
|
{Reference Triangle}
|
||||||
Pen.Style := psDot;
|
Pen.Style := psDot;
|
||||||
Pen.color := pnlReference.Color;
|
Pen.color := pnlReference.Color;
|
||||||
|
|
||||||
a := ToScreen(MainTriangles[-1].x[0], MainTriangles[-1].y[0]);
|
a := ToScreen(MainTriangles[-1].x[0], MainTriangles[-1].y[0]);
|
||||||
b := ToScreen(MainTriangles[-1].x[1], MainTriangles[-1].y[1]);
|
b := ToScreen(MainTriangles[-1].x[1], MainTriangles[-1].y[1]);
|
||||||
c := ToScreen(MainTriangles[-1].x[2], MainTriangles[-1].y[2]);
|
c := ToScreen(MainTriangles[-1].x[2], MainTriangles[-1].y[2]);
|
||||||
Polyline([a, b, c, a]);
|
Polyline([a, b, c, a]);
|
||||||
|
|
||||||
Font.color := Pen.color;
|
Font.color := Pen.color;
|
||||||
TextOut(a.x, a.y, 'A');
|
TextOut(a.x+2, a.y+1, 'A');
|
||||||
TextOut(b.x, b.y, 'B');
|
TextOut(b.x+2, b.y+1, 'B');
|
||||||
TextOut(c.x, c.y, 'C');
|
TextOut(c.x+2, c.y+1, 'C');
|
||||||
|
|
||||||
Pen.Style := psSolid;
|
Pen.Style := psSolid;
|
||||||
|
|
||||||
@ -1002,45 +1000,104 @@ begin
|
|||||||
Ellipse(c.x - 4, c.y - 4, c.x + 4, c.y + 4);
|
Ellipse(c.x - 4, c.y - 4, c.x + 4, c.y + 4);
|
||||||
|
|
||||||
Font.color := Pen.color;
|
Font.color := Pen.color;
|
||||||
TextOut(a.x, a.y, 'A');
|
TextOut(c.x+2, c.y+1, 'C');
|
||||||
TextOut(b.x, b.y, 'B');
|
TextOut(b.x+2, b.y+1, 'B');
|
||||||
TextOut(c.x, c.y, 'C');
|
TextOut(a.x+2, a.y+1, 'A');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// if dragging, draw pivot axis
|
|
||||||
if TriangleCaught or CornerCaught then
|
if (TriangleCaught or CornerCaught) then // if dragging, draw pivot axis
|
||||||
begin
|
begin
|
||||||
Pen.Mode := pmMerge;
|
if HelpersEnabled then
|
||||||
Pen.Color := $555555;
|
begin
|
||||||
Pen.Style := psDot;
|
pen.Color := $808080;
|
||||||
// ax := integer(round(ix + (Pivot.x - gCenterX)*sc));
|
//pen.Color := 0;
|
||||||
// ay := integer(round(iy + (gCentery - Pivot.y)*sc));
|
//brush.Color := $808080;
|
||||||
|
pen.Mode := pmMerge;
|
||||||
|
pen.Style := psSolid;//psDot;
|
||||||
a := ToScreen(Pivot.x, Pivot.y);
|
a := ToScreen(Pivot.x, Pivot.y);
|
||||||
MoveTo(a.x, 0);
|
MoveTo(a.x, 0);
|
||||||
LineTo(a.x, Height);
|
LineTo(a.x, Height);
|
||||||
MoveTo(0, a.y);
|
MoveTo(0, a.y);
|
||||||
LineTo(Width, a.y);
|
LineTo(Width, a.y);
|
||||||
Pen.Color := $808080;
|
if (editMode = modeRotate) or (editMode = modeScale) then // draw circle
|
||||||
Pen.Style := psSolid;
|
|
||||||
Pen.Mode := pmXor;
|
|
||||||
if CornerCaught then
|
|
||||||
begin
|
begin
|
||||||
// ax := integer(round(ix + (MainTriangles[SelectedTriangle].x[SelectedCorner] - gCenterX)*sc));
|
if CornerCaught then begin
|
||||||
// ay := integer(round(iy - (MainTriangles[SelectedTriangle].y[SelectedCorner] - gCenterY)*sc));
|
dx := MainTriangles[SelectedTriangle].x[SelectedCorner] - Pivot.x;
|
||||||
a := ToScreen(MainTriangles[SelectedTriangle].x[SelectedCorner],
|
dy := MainTriangles[SelectedTriangle].y[SelectedCorner] - Pivot.y;
|
||||||
MainTriangles[SelectedTriangle].y[SelectedCorner]);
|
d := Hypot(dx, dy);
|
||||||
|
// d := dist(Pivot.x, Pivot.y,
|
||||||
|
// MainTriangles[SelectedTriangle].x[SelectedCorner], MainTriangles[SelectedTriangle].y[SelectedCorner]);
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
// ax := integer(round(ix + (GetPivot.x - gCenterX)*sc));
|
// d := MinDouble;
|
||||||
// ay := integer(round(iy - (GetPivot.y - gCenterY)*sc));
|
dx := MainTriangles[SelectedTriangle].x[0] - Pivot.x;
|
||||||
a := ToScreen(GetPivot.x, GetPivot.y);
|
dy := MainTriangles[SelectedTriangle].y[0] - Pivot.y;
|
||||||
|
d := Hypot(dx, dy);
|
||||||
|
for i := 1 to 2 do
|
||||||
|
begin
|
||||||
|
// tx := MainTriangles[SelectedTriangle].x[i] - Pivot.x;
|
||||||
|
// ty := MainTriangles[SelectedTriangle].y[i] - Pivot.y;
|
||||||
|
d1 := Hypot(tx, ty);
|
||||||
|
d1 := dist(Pivot.x, Pivot.y, MainTriangles[SelectedTriangle].x[i], MainTriangles[SelectedTriangle].y[i]);
|
||||||
|
if d1 > d then begin
|
||||||
|
d := d1;
|
||||||
|
// dx := tx;
|
||||||
|
// dy := ty;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
d1 := Hypot(dx, dy);
|
||||||
|
if (d1 <> d) and (d1 <> 0) then
|
||||||
|
begin
|
||||||
|
dx := dx/d1 * d;
|
||||||
|
dy := dy/d1 * d;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
//i := min( min(Width, Height), integer(round(dmax * sc)));
|
||||||
|
i := integer(round(d * sc));
|
||||||
|
if i > 4 then begin
|
||||||
|
pen.Color := $808080;
|
||||||
|
brush.Style := bsClear;
|
||||||
|
Ellipse(a.x - i, a.y - i, a.x + i, a.y + i);
|
||||||
|
|
||||||
|
a := ToScreen(Pivot.x - dy, Pivot.y + dx);
|
||||||
|
b := ToScreen(Pivot.x + dy, Pivot.y - dx);
|
||||||
|
MoveTo(a.x, a.y);
|
||||||
|
LineTo(b.X, b.y);
|
||||||
|
end;
|
||||||
|
|
||||||
|
// rotated axis
|
||||||
|
if (dx <> 0) and (dy <> 0) then
|
||||||
|
begin
|
||||||
|
k := dy / dx;
|
||||||
|
if abs(k) < 1 then begin
|
||||||
|
MoveTo(0, round(iy - sc*(Pivot.y - ( ix/sc-GCenterX+Pivot.x)*k - GCenterY)));
|
||||||
|
LineTo(Width, round(iy - sc*(Pivot.y - (-ix/sc-GCenterX+Pivot.x)*k - GCenterY)));
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
MoveTo(round(ix + sc*(Pivot.x - (-iy/sc-GCenterY+Pivot.y)/k - GCenterX)), 0);
|
||||||
|
LineTo(round(ix + sc*(Pivot.x - ( iy/sc-GCenterY+Pivot.y)/k - GCenterX)), Height);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else //if editMode = modeMove then // draw target axis
|
||||||
|
begin
|
||||||
|
Pen.Color := $808080;
|
||||||
|
Pen.Mode := pmMerge;//Xor;
|
||||||
|
brush.Color := 0;
|
||||||
|
if CornerCaught then
|
||||||
|
a := ToScreen(MainTriangles[SelectedTriangle].x[SelectedCorner],
|
||||||
|
MainTriangles[SelectedTriangle].y[SelectedCorner])
|
||||||
|
else
|
||||||
|
a := ToScreen(GetPivot.x, GetPivot.y);
|
||||||
MoveTo(a.x, 0);
|
MoveTo(a.x, 0);
|
||||||
LineTo(a.x, Height);
|
LineTo(a.x, Height);
|
||||||
MoveTo(0, a.y);
|
MoveTo(0, a.y);
|
||||||
LineTo(Width, a.y);
|
LineTo(Width, a.y);
|
||||||
Pen.Mode := pmCopy;
|
Pen.Mode := pmCopy;
|
||||||
|
end;
|
||||||
|
end; // endif HelpersEnabled
|
||||||
mouseOverTriangle := SelectedTriangle;
|
mouseOverTriangle := SelectedTriangle;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1071,11 +1128,11 @@ begin
|
|||||||
begin
|
begin
|
||||||
font.Color := GetTriangleColor(mouseOverTriangle);
|
font.Color := GetTriangleColor(mouseOverTriangle);
|
||||||
brush.Style := bsClear;
|
brush.Style := bsClear;
|
||||||
ay := Height-3 + font.Height; // font.height < 0
|
ay := Height-foc_ofs*2 + font.Height; // font.height < 0
|
||||||
for i:= NRVAR - 1 downto 0 do
|
for i:= NRVAR - 1 downto 0 do
|
||||||
if cp.xform[mouseOverTriangle].vars[i] <> 0 then
|
if cp.xform[mouseOverTriangle].vars[i] <> 0 then
|
||||||
begin
|
begin
|
||||||
ax := Width-3 - TextWidth(Varnames(i));
|
ax := Width-foc_ofs*2 - TextWidth(Varnames(i));
|
||||||
TextOut(ax, ay, Varnames(i));
|
TextOut(ax, ay, Varnames(i));
|
||||||
Inc(ay, font.Height);
|
Inc(ay, font.Height);
|
||||||
end;
|
end;
|
||||||
@ -1087,28 +1144,39 @@ begin
|
|||||||
brush.Color:=clSilver;
|
brush.Color:=clSilver;
|
||||||
if CornerCaught then // draw selected corner
|
if CornerCaught then // draw selected corner
|
||||||
begin
|
begin
|
||||||
// ax := integer(round(ix + (MainTriangles[SelectedTriangle].x[SelectedCorner] - gCenterX) * sc));
|
|
||||||
// ay := integer(round(iy - (MainTriangles[SelectedTriangle].y[SelectedCorner] - gCenterY) * sc));
|
|
||||||
a := ToScreen(MainTriangles[SelectedTriangle].x[SelectedCorner], MainTriangles[SelectedTriangle].y[SelectedCorner]);
|
a := ToScreen(MainTriangles[SelectedTriangle].x[SelectedCorner], MainTriangles[SelectedTriangle].y[SelectedCorner]);
|
||||||
Ellipse(a.x - 4, a.y - 4, a.x + 4, a.y + 4);
|
Ellipse(a.x - 4, a.y - 4, a.x + 4, a.y + 4);
|
||||||
end
|
end
|
||||||
else if (mouseOverTriangle>=0) and (mouseOverCorner >= 0) then // highlight corner under cursor
|
else if (mouseOverTriangle>=0) and (mouseOverCorner >= 0) then // highlight corner under cursor
|
||||||
begin
|
begin
|
||||||
// ax := integer(round(ix + (MainTriangles[mouseOverTriangle].x[mouseOverCorner] - gCenterX) * sc));
|
|
||||||
// ay := integer(round(iy - (MainTriangles[mouseOverTriangle].y[mouseOverCorner] - gCenterY) * sc));
|
|
||||||
a := ToScreen(MainTriangles[mouseOverTriangle].x[mouseOverCorner], MainTriangles[mouseOverTriangle].y[mouseOverCorner]);
|
a := ToScreen(MainTriangles[mouseOverTriangle].x[mouseOverCorner], MainTriangles[mouseOverTriangle].y[mouseOverCorner]);
|
||||||
Ellipse(a.x - 4, a.y - 4, a.x + 4, a.y + 4);
|
Ellipse(a.x - 4, a.y - 4, a.x + 4, a.y + 4);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// draw pivot point
|
// draw pivot point
|
||||||
// ax := integer(round(ix + (GetPivot.x - gCenterX) * sc));
|
|
||||||
// ay := integer(round(iy - (GetPivot.y - gCenterY) * sc));
|
|
||||||
a := ToScreen(GetPivot.x, GetPivot.y);
|
a := ToScreen(GetPivot.x, GetPivot.y);
|
||||||
Pen.Style := psSolid;
|
Pen.Style := psSolid;
|
||||||
pen.Color := clWhite;
|
pen.Color := clWhite;
|
||||||
brush.Color := clSilver;
|
brush.Color := clSilver;
|
||||||
Ellipse(a.x - 2, a.y - 2, a.x + 2, a.y + 2);
|
Ellipse(a.x - 2, a.y - 2, a.x + 2, a.y + 2);
|
||||||
// --
|
|
||||||
|
if TWinControl(Sender).Focused then
|
||||||
|
begin
|
||||||
|
pen.Color := $808080;
|
||||||
|
pen.Mode := pmXor;
|
||||||
|
MoveTo(foc_ofs, foc_size);
|
||||||
|
LineTo(foc_ofs, foc_ofs);
|
||||||
|
LineTo(foc_size, foc_ofs);
|
||||||
|
MoveTo(Width-1-foc_ofs, foc_size);
|
||||||
|
LineTo(Width-1-foc_ofs, foc_ofs);
|
||||||
|
LineTo(Width-1-foc_size, foc_ofs);
|
||||||
|
MoveTo(Width-1-foc_ofs, Height-1-foc_size);
|
||||||
|
LineTo(Width-1-foc_ofs, Height-1-foc_ofs);
|
||||||
|
LineTo(Width-1-foc_size, Height-1-foc_ofs);
|
||||||
|
MoveTo(foc_ofs, Height-1-foc_size);
|
||||||
|
LineTo(foc_ofs, Height-1-foc_ofs);
|
||||||
|
LineTo(foc_size, Height-1-foc_ofs);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
TriangleView.Canvas.Draw(0, 0, Bitmap);
|
TriangleView.Canvas.Draw(0, 0, Bitmap);
|
||||||
finally
|
finally
|
||||||
@ -1138,8 +1206,9 @@ begin
|
|||||||
TriangleView.OnKeyDown := TriangleViewKeyDown;
|
TriangleView.OnKeyDown := TriangleViewKeyDown;
|
||||||
TriangleView.OnKeyUp := TriangleViewKeyUp;
|
TriangleView.OnKeyUp := TriangleViewKeyUp;
|
||||||
|
|
||||||
TriangleView.OnEnter := rgPivotClicked; // hack:
|
TriangleView.OnEnter := rgPivotClicked; // hack: it's only Invalidate() in there :)
|
||||||
TriangleView.OnExit := TriangleViewExit; // there's only Invalidate() in there :)
|
TriangleView.OnExit := TriangleViewExit;
|
||||||
|
TriangleView.OnMouseLeave := TriangleViewmouseLeave;
|
||||||
//
|
//
|
||||||
|
|
||||||
for i:= 0 to NRVAR - 1 do begin
|
for i:= 0 to NRVAR - 1 do begin
|
||||||
@ -1192,13 +1261,22 @@ var
|
|||||||
d: double;
|
d: double;
|
||||||
|
|
||||||
i0, i1: integer;
|
i0, i1: integer;
|
||||||
label FoundCorner;
|
label FoundCorner, Skip1, Skip2;
|
||||||
begin
|
begin
|
||||||
Scale(fx, fy, x, y);
|
Scale(fx, fy, x, y);
|
||||||
// --Z--
|
// --Z--
|
||||||
StatusBar.Panels[0].Text := Format('X: %f', [fx]);
|
StatusBar.Panels[0].Text := Format('X: %f', [fx]);
|
||||||
StatusBar.Panels[1].Text := Format('Y: %f', [fy]);
|
StatusBar.Panels[1].Text := Format('Y: %f', [fy]);
|
||||||
|
|
||||||
|
if viewDragMode then // graph panning
|
||||||
|
begin
|
||||||
|
viewDragged := true;
|
||||||
|
GcenterX := GcenterX - (fx - oldx);
|
||||||
|
GcenterY := GcenterY - (fy - oldy);
|
||||||
|
TriangleView.Refresh;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
mt:=mouseOverTriangle;
|
mt:=mouseOverTriangle;
|
||||||
mc:=MouseOverCorner;
|
mc:=MouseOverCorner;
|
||||||
|
|
||||||
@ -1241,40 +1319,52 @@ FoundCorner:
|
|||||||
else
|
else
|
||||||
TriangleView.Cursor := crArrow;
|
TriangleView.Cursor := crArrow;
|
||||||
|
|
||||||
if viewDragMode then // graph panning
|
|
||||||
begin
|
|
||||||
viewDragged := true;
|
|
||||||
GcenterX := GcenterX - (fx - oldx);
|
|
||||||
GcenterY := GcenterY - (fy - oldy);
|
|
||||||
TriangleView.Refresh;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Shift := Shift - [ssLeft];
|
Shift := Shift - [ssLeft];
|
||||||
|
|
||||||
if CornerCaught then
|
if CornerCaught then // Modify a point ///////////////////////////////////////
|
||||||
begin { Drag a corner }
|
begin
|
||||||
// if (Shift = [ssAlt]) or ((editMode = modeRotate) and (Shift = [])) then
|
// if (Shift = [ssAlt]) or ((editMode = modeRotate) and (Shift = [])) then
|
||||||
if (editMode = modeRotate) then // rotate point
|
if (editMode = modeRotate) then // rotate point
|
||||||
begin // rotate point around pivot
|
begin // rotate point around pivot
|
||||||
d := dist(Pivot.X, Pivot.Y, fx, fy);
|
d := dist(Pivot.X, Pivot.Y, fx, fy);
|
||||||
if d<>0 then begin
|
if d<>0 then begin
|
||||||
vx := (fx-Pivot.X)*olddist/d;
|
if ssShift in Shift then // angle snap
|
||||||
vy := (fy-Pivot.Y)*olddist/d;
|
begin
|
||||||
|
try
|
||||||
|
t := StrToFloat(txtTrgRotateValue.Text)/180*PI;
|
||||||
|
//assert(t<>0);
|
||||||
|
except
|
||||||
|
t := 15.0*PI/180.0;
|
||||||
|
txtTrgRotateValue.Text := '15';
|
||||||
|
end;
|
||||||
|
if t = 0 then goto Skip1; //?
|
||||||
|
|
||||||
|
a := Round(arctan2(fy-Pivot.Y, fx-Pivot.X)/t)*t;
|
||||||
|
vx := olddist*cos(a);
|
||||||
|
vy := olddist*sin(a);
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
vx := 0;
|
Skip1:
|
||||||
vy := 0;
|
vx := (fx-Pivot.X)*olddist/d;
|
||||||
|
vy := (fy-Pivot.Y)*olddist/d;
|
||||||
|
a := arctan2(vy,vx) - arctan2(oldy,oldx);
|
||||||
end;
|
end;
|
||||||
MainTriangles[SelectedTriangle].x[SelectedCorner] := Pivot.X+vx;
|
MainTriangles[SelectedTriangle].x[SelectedCorner] := Pivot.X+vx;
|
||||||
MainTriangles[SelectedTriangle].y[SelectedCorner] := Pivot.Y+vy;
|
MainTriangles[SelectedTriangle].y[SelectedCorner] := Pivot.Y+vy;
|
||||||
vx:=arctan2(vy,vx);
|
end
|
||||||
vy:=arctan2(oldy,oldx);
|
else a := 0;
|
||||||
StatusBar.Panels[2].Text := Format('Rotate: %3.2f°', [(vx-vy)*180/PI]);
|
vy := abs(
|
||||||
|
arctan2(MainTriangles[SelectedTriangle].y[0]-MainTriangles[SelectedTriangle].y[1],
|
||||||
|
MainTriangles[SelectedTriangle].x[0]-MainTriangles[SelectedTriangle].x[1])
|
||||||
|
-arctan2(MainTriangles[SelectedTriangle].y[2]-MainTriangles[SelectedTriangle].y[1],
|
||||||
|
MainTriangles[SelectedTriangle].x[2]-MainTriangles[SelectedTriangle].x[1])
|
||||||
|
);
|
||||||
|
if vy > PI then vy := 2*PI - vy;
|
||||||
|
StatusBar.Panels[2].Text := Format('Rotate: %3.2f° <ABC: %3.2f°', [a*180/PI, vy*180/PI]);
|
||||||
end
|
end
|
||||||
// else if (Shift = [ssCtrl]) or ((editMode = modeScale) and (Shift = [])) then
|
// else if (Shift = [ssCtrl]) or ((editMode = modeScale) and (Shift = [])) then
|
||||||
else if (editMode = modeScale) then
|
else if (editMode = modeScale) then
|
||||||
begin // move point along vector
|
begin // move point along vector ("scale")
|
||||||
if olddist<>0 then begin
|
if olddist<>0 then begin
|
||||||
vy := (oldx*(fx-Pivot.X) + oldy*(fy-Pivot.Y))/(olddist*olddist);
|
vy := (oldx*(fx-Pivot.X) + oldy*(fy-Pivot.Y))/(olddist*olddist);
|
||||||
MainTriangles[SelectedTriangle].x[SelectedCorner] := Pivot.X+oldx*vy;
|
MainTriangles[SelectedTriangle].x[SelectedCorner] := Pivot.X+oldx*vy;
|
||||||
@ -1313,26 +1403,36 @@ FoundCorner:
|
|||||||
StatusBar.Refresh;
|
StatusBar.Refresh;
|
||||||
exit;
|
exit;
|
||||||
end
|
end
|
||||||
else if TriangleCaught then { Modify a whole triangle }
|
else if TriangleCaught then // Modify a whole triangle ///////////////////////
|
||||||
begin
|
begin
|
||||||
// if (Shift = [ssAlt]) or ((editMode = modeRotate) and (Shift = [])) then // rotate
|
// if (Shift = [ssAlt]) or ((editMode = modeRotate) and (Shift = [])) then // rotate
|
||||||
if (editMode = modeRotate) then // rotate triangle
|
if (editMode = modeRotate) then // rotate triangle
|
||||||
begin
|
begin
|
||||||
a := arctan2(fy-Pivot.Y, fx-Pivot.X) - arctan2(oldy, oldx);
|
a := arctan2(fy-Pivot.Y, fx-Pivot.X) - arctan2(oldy, oldx);
|
||||||
if ssShift in Shift then
|
if ssShift in Shift then // angle snap
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
t := StrToFloat(txtTrgRotateValue.Text)/180*PI;
|
t := StrToFloat(txtTrgRotateValue.Text)/180*PI;
|
||||||
assert(t<>0);
|
//assert(t<>0);
|
||||||
except
|
except
|
||||||
t := 15.0*PI/180.0;
|
t := 15.0*PI/180.0;
|
||||||
txtTrgRotateValue.Text := '15';
|
txtTrgRotateValue.Text := '15';
|
||||||
end;
|
end;
|
||||||
|
if t = 0 then goto Skip2;
|
||||||
|
|
||||||
a := Round(a/t)*t
|
a := Round(a/t)*t
|
||||||
end;
|
end;
|
||||||
|
Skip2:
|
||||||
MainTriangles[SelectedTriangle] :=
|
MainTriangles[SelectedTriangle] :=
|
||||||
RotateTrianglePoint(OldTriangle, Pivot.X, Pivot.Y, a);
|
RotateTrianglePoint(OldTriangle, Pivot.X, Pivot.Y, a);
|
||||||
StatusBar.Panels[2].Text := Format('Rotate: %3.2f°', [a*180/PI]);
|
|
||||||
|
vx := MainTriangles[SelectedTriangle].x[0]-MainTriangles[SelectedTriangle].x[1];
|
||||||
|
vy := MainTriangles[SelectedTriangle].y[0]-MainTriangles[SelectedTriangle].y[1];
|
||||||
|
if abs(vx*(MainTriangles[SelectedTriangle].x[2]-MainTriangles[SelectedTriangle].x[1])+
|
||||||
|
vy*(MainTriangles[SelectedTriangle].y[2]-MainTriangles[SelectedTriangle].y[1])) < 0.001
|
||||||
|
then
|
||||||
|
StatusBar.Panels[2].Text := Format('Rotate: %3.2f° Local axis: %3.2f°', [a*180/PI, arctan2(vy, vx)*180/PI])
|
||||||
|
else StatusBar.Panels[2].Text := Format('Rotate: %3.2f°', [a*180/PI]);
|
||||||
end
|
end
|
||||||
// else if (Shift = [ssCtrl]) or ((editMode = modeScale) and (Shift = [])) then
|
// else if (Shift = [ssCtrl]) or ((editMode = modeScale) and (Shift = [])) then
|
||||||
else if (editMode = modeScale) then // scale
|
else if (editMode = modeScale) then // scale
|
||||||
@ -1433,7 +1533,7 @@ begin
|
|||||||
i := InsideTriangle(fx, fy);
|
i := InsideTriangle(fx, fy);
|
||||||
if i >= 0 then SelectedTriangle := i
|
if i >= 0 then SelectedTriangle := i
|
||||||
else
|
else
|
||||||
if Shift * [ssAlt,ssCtrl,ssShift] = [] then exit;
|
if oldMode = modeNone then exit;
|
||||||
end;
|
end;
|
||||||
TriangleCaught := True;
|
TriangleCaught := True;
|
||||||
|
|
||||||
@ -1475,7 +1575,7 @@ begin
|
|||||||
end
|
end
|
||||||
else TriangleView.Invalidate;
|
else TriangleView.Invalidate;
|
||||||
end
|
end
|
||||||
else if (Button = mbRight) and viewDragMode then // --Z-- panning
|
else if (Button = mbRight) and viewDragMode then
|
||||||
begin
|
begin
|
||||||
viewDragMode := false;
|
viewDragMode := false;
|
||||||
if viewDragged=false then // haven't dragged - popup menu then
|
if viewDragged=false then // haven't dragged - popup menu then
|
||||||
@ -1540,7 +1640,7 @@ begin
|
|||||||
if Registry.ValueExists('ReferenceTriangleColor') then
|
if Registry.ValueExists('ReferenceTriangleColor') then
|
||||||
ReferenceTriangleColor := Registry.ReadInteger('ReferenceTriangleColor')
|
ReferenceTriangleColor := Registry.ReadInteger('ReferenceTriangleColor')
|
||||||
else
|
else
|
||||||
ReferenceTriangleColor := integer(clGray);
|
ReferenceTriangleColor := $7f7f7f;
|
||||||
if Registry.ValueExists('ResetLocation') then
|
if Registry.ValueExists('ResetLocation') then
|
||||||
mnuResetLoc.checked := Registry.ReadBool('ResetLocation')
|
mnuResetLoc.checked := Registry.ReadBool('ResetLocation')
|
||||||
else mnuResetLoc.checked := true;
|
else mnuResetLoc.checked := true;
|
||||||
@ -1561,7 +1661,7 @@ begin
|
|||||||
Registry.Free;
|
Registry.Free;
|
||||||
end;
|
end;
|
||||||
chkUseXFormColor.checked := UseTransformColors;
|
chkUseXFormColor.checked := UseTransformColors;
|
||||||
chkFlameBack.checked := UseFlameBackground;
|
// chkFlameBack.checked := UseFlameBackground;
|
||||||
pnlBackColor.Color := TColor(BackgroundColor);
|
pnlBackColor.Color := TColor(BackgroundColor);
|
||||||
GrphPnl.Color := TColor(BackgroundColor);
|
GrphPnl.Color := TColor(BackgroundColor);
|
||||||
pnlGridColor1.Color := GridColor1;
|
pnlGridColor1.Color := GridColor1;
|
||||||
@ -2179,9 +2279,9 @@ begin
|
|||||||
TriangleView.Invalidate;
|
TriangleView.Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEditForm.chkFlameBackClick(Sender: TObject);
|
procedure TEditForm.chkHelpersClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
UseFlameBackground := chkFlameBack.checked;
|
HelpersEnabled := chkHelpers.checked;
|
||||||
TriangleView.Invalidate;
|
TriangleView.Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2451,8 +2551,8 @@ var
|
|||||||
cell: TGridCoord;
|
cell: TGridCoord;
|
||||||
begin
|
begin
|
||||||
if Button = mbLeft then begin
|
if Button = mbLeft then begin
|
||||||
|
varDragOld:=x;
|
||||||
cell := TValueListEditor(Sender).MouseCoord(x, y);
|
cell := TValueListEditor(Sender).MouseCoord(x, y);
|
||||||
|
|
||||||
if (cell.y < 1) or (cell.y >= TValueListEditor(Sender).RowCount) or
|
if (cell.y < 1) or (cell.y >= TValueListEditor(Sender).RowCount) or
|
||||||
(cell.x <> 0) then exit;
|
(cell.x <> 0) then exit;
|
||||||
|
|
||||||
@ -2465,8 +2565,7 @@ begin
|
|||||||
GetCursorPos(mousepos); // hmmm
|
GetCursorPos(mousepos); // hmmm
|
||||||
|
|
||||||
varDragMode:=true;
|
varDragMode:=true;
|
||||||
varDragOld:=x;
|
varDragPos:=0;
|
||||||
varDragPos:=x;
|
|
||||||
SetCaptureControl(TValueListEditor(Sender));
|
SetCaptureControl(TValueListEditor(Sender));
|
||||||
if Sender = VEVars then
|
if Sender = VEVars then
|
||||||
varDragValue := cp.xform[SelectedTriangle].vars[varDragIndex]
|
varDragValue := cp.xform[SelectedTriangle].vars[varDragIndex]
|
||||||
@ -2553,7 +2652,7 @@ var
|
|||||||
v: double;
|
v: double;
|
||||||
begin
|
begin
|
||||||
if (TValueListEditor(Sender).Values[VarNames(varDragIndex)] = '0') or
|
if (TValueListEditor(Sender).Values[VarNames(varDragIndex)] = '0') or
|
||||||
(varDragPos >= TValueListEditor(Sender).ColWidths[0]) then exit;
|
(varDragOld >= TValueListEditor(Sender).ColWidths[0]) then exit;
|
||||||
|
|
||||||
MainForm.UpdateUndo;
|
MainForm.UpdateUndo;
|
||||||
if Sender = VEVars then
|
if Sender = VEVars then
|
||||||
@ -2820,8 +2919,11 @@ procedure TEditForm.TriangleViewKeyUp(Sender: TObject; var Key: Word;
|
|||||||
Shift: TShiftState);
|
Shift: TShiftState);
|
||||||
begin
|
begin
|
||||||
|
|
||||||
if (oldMode <> modeNone) and
|
if (oldMode <> modeNone) and (
|
||||||
(key in [VK_SHIFT, VK_MENU, VK_CONTROL]) then
|
((key = VK_SHIFT) and (editMode = modeMove)) or
|
||||||
|
((key = VK_MENU) and (editMode = modeRotate)) or
|
||||||
|
((key = VK_CONTROL) and (editMode = modeScale))
|
||||||
|
) then
|
||||||
begin
|
begin
|
||||||
editMode := oldMode;
|
editMode := oldMode;
|
||||||
oldMode := modeNone;
|
oldMode := modeNone;
|
||||||
@ -2833,8 +2935,6 @@ end;
|
|||||||
|
|
||||||
procedure TEditForm.TriangleViewExit(Sender: TObject);
|
procedure TEditForm.TriangleViewExit(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
mouseOverTriangle := -1;
|
|
||||||
|
|
||||||
if oldMode <> modeNone then
|
if oldMode <> modeNone then
|
||||||
begin
|
begin
|
||||||
editMode := oldMode;
|
editMode := oldMode;
|
||||||
@ -2844,9 +2944,19 @@ begin
|
|||||||
tbScale.Down := (editMode = modeScale);
|
tbScale.Down := (editMode = modeScale);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
mouseOverTriangle := -1;
|
||||||
TriangleView.Invalidate;
|
TriangleView.Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TEditForm.TriangleViewMouseLeave(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if viewDragMode = false then
|
||||||
|
begin
|
||||||
|
mouseOverTriangle := -1;
|
||||||
|
TriangleView.Invalidate;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TEditForm.EditKeyDown(Sender: TObject; var Key: Word;
|
procedure TEditForm.EditKeyDown(Sender: TObject; var Key: Word;
|
||||||
Shift: TShiftState);
|
Shift: TShiftState);
|
||||||
begin
|
begin
|
||||||
@ -2863,6 +2973,8 @@ begin
|
|||||||
TriangleView.Invalidate;
|
TriangleView.Invalidate;
|
||||||
ShowSelectedInfo;
|
ShowSelectedInfo;
|
||||||
end;
|
end;
|
||||||
|
{ // these keys are not so good, must think about it...
|
||||||
|
|
||||||
VK_SPACE: EditForm.tbSelectClick(Sender);
|
VK_SPACE: EditForm.tbSelectClick(Sender);
|
||||||
|
|
||||||
Ord('Q'): EditForm.tbEditModeClick(tbMove);
|
Ord('Q'): EditForm.tbEditModeClick(tbMove);
|
||||||
@ -2879,6 +2991,7 @@ begin
|
|||||||
Ord('C'): EditForm.rgPivot.ItemIndex:=2;
|
Ord('C'): EditForm.rgPivot.ItemIndex:=2;
|
||||||
Ord('V'): EditForm.rgPivot.ItemIndex:=3;
|
Ord('V'): EditForm.rgPivot.ItemIndex:=3;
|
||||||
Ord('B'): EditForm.rgPivot.ItemIndex:=4;
|
Ord('B'): EditForm.rgPivot.ItemIndex:=4;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
key_handled := false;
|
key_handled := false;
|
||||||
exit;
|
exit;
|
||||||
@ -2911,7 +3024,7 @@ begin
|
|||||||
StatusBar.Panels[2].Text := 'Select OFF';
|
StatusBar.Panels[2].Text := 'Select OFF';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// hack (to generate MouseMove event):
|
// hack: to generate MouseMove event
|
||||||
GetCursorPos(MousePos);
|
GetCursorPos(MousePos);
|
||||||
SetCursorPos(MousePos.x, MousePos.y);
|
SetCursorPos(MousePos.x, MousePos.y);
|
||||||
end;
|
end;
|
||||||
|
@ -1916,9 +1916,9 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Triangles[-1].x[0] := 0; Triangles[-1].y[0] := 0;
|
Triangles[-1].x[0] := 1; Triangles[-1].y[0] := 0; // "x"
|
||||||
Triangles[-1].x[1] := 1; Triangles[-1].y[1] := 0;
|
Triangles[-1].x[1] := 0; Triangles[-1].y[1] := 0; // "0"
|
||||||
Triangles[-1].x[2] := 1; Triangles[-1].y[2] := 1.5;
|
Triangles[-1].x[2] := 0; Triangles[-1].y[2] := -1; // "y"
|
||||||
end;
|
end;
|
||||||
|
|
||||||
for j := 0 to xforms - 1 do
|
for j := 0 to xforms - 1 do
|
||||||
@ -1931,10 +1931,8 @@ begin
|
|||||||
f := cp1.xform[j].c[2][1];
|
f := cp1.xform[j].c[2][1];
|
||||||
for i := 0 to 2 do
|
for i := 0 to 2 do
|
||||||
begin
|
begin
|
||||||
triangles[j].x[i] := Triangles[-1].x[i] * a + Triangles[-1].y[i] *
|
triangles[j].x[i] := Triangles[-1].x[i] * a + Triangles[-1].y[i] * c + e;
|
||||||
c + e;
|
triangles[j].y[i] := Triangles[-1].x[i] * b + Triangles[-1].y[i] * d + f;
|
||||||
triangles[j].y[i] := Triangles[-1].x[i] * b + Triangles[-1].y[i] *
|
|
||||||
d + f;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
for i := -1 to xforms - 1 do
|
for i := -1 to xforms - 1 do
|
||||||
|
Loading…
Reference in New Issue
Block a user