LazMapViewer: Toggle selection of a point in TMarkerEditorPlugin by CTRL + LeftClick
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9703 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
d9536cca8a
commit
3ca1ec96db
@ -10,7 +10,7 @@ object MainForm: TMainForm
|
|||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
object MapView: TMapView
|
object MapView: TMapView
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 468
|
Height = 453
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 908
|
Width = 908
|
||||||
Align = alClient
|
Align = alClient
|
||||||
@ -34,13 +34,13 @@ object MainForm: TMainForm
|
|||||||
end
|
end
|
||||||
object Panel1: TPanel
|
object Panel1: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 222
|
Height = 237
|
||||||
Top = 468
|
Top = 453
|
||||||
Width = 908
|
Width = 908
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 222
|
ClientHeight = 237
|
||||||
ClientWidth = 908
|
ClientWidth = 908
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
object cgPointTypes: TCheckGroup
|
object cgPointTypes: TCheckGroup
|
||||||
@ -186,11 +186,11 @@ object MainForm: TMainForm
|
|||||||
AnchorSideTop.Control = Label1
|
AnchorSideTop.Control = Label1
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 105
|
Height = 120
|
||||||
Top = 109
|
Top = 109
|
||||||
Width = 437
|
Width = 437
|
||||||
BorderSpacing.Bottom = 8
|
BorderSpacing.Bottom = 8
|
||||||
Caption = 'Select a single point --> Left-click'#13#10'Select all points of track or area --> SHIFT+left-click'#13#10'Select all points contained in dragged rectangle --> ALT + left-click'#13#10'Create a new point --> Right-click'#13#10'Extend selection --> Hold CTRL key down'#13#10'Delete selection --> DEL key (or click "Delete selection" button'#13#10'Move selection --> Drag with mouse(left button down) or press arrow keys (+/- 1°)'
|
Caption = 'Select a single point --> Left-click'#13#10'Select all points of track or area --> SHIFT+left-click'#13#10'Select all points contained in dragged rectangle --> ALT + left-click'#13#10'Create a new point --> Right-click'#13#10'Extend selection --> Hold CTRL key down and left-click'#13#10'Toggle selection of current point --> Hold CTRL key down and left-click'#13#10'Delete selection --> DEL key (or click "Delete selection" button'#13#10'Move selection --> Drag with mouse(left button down) or press arrow keys (+/- 1°)'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object PluginManager: TMvPluginManager
|
object PluginManager: TMvPluginManager
|
||||||
|
@ -142,15 +142,14 @@ type
|
|||||||
|
|
||||||
TMarkerStartDragEvent = procedure (AMapView: TMapView; var CanDrag: Boolean) of object;
|
TMarkerStartDragEvent = procedure (AMapView: TMapView; var CanDrag: Boolean) of object;
|
||||||
|
|
||||||
TMarkerClickMode = (cmNewPoint, cmSelectPoint, cmSelectShape,
|
TMarkerClickMode = (cmNewPoint, cmSelectPoint, cmSelectShape, cmRubberband);
|
||||||
cmTogglePoint, cmRubberband);
|
|
||||||
|
|
||||||
TMarkerNewPointType = (nptGPSPoint, nptMapPoint);
|
TMarkerNewPointType = (nptGPSPoint, nptMapPoint);
|
||||||
|
|
||||||
TMarkerEditorPlugin = class(TMarkerClickPlugin)
|
TMarkerEditorPlugin = class(TMarkerClickPlugin)
|
||||||
private
|
private
|
||||||
type
|
type
|
||||||
TPluginStateEnum = (psDragging, psRubberBandMode, psExtendingSelection);
|
TPluginStateEnum = (psDragging, psRubberBandMode, psExtendingSelection, psPendingUnselect);
|
||||||
TPluginState = set of TPluginStateEnum;
|
TPluginState = set of TPluginStateEnum;
|
||||||
const
|
const
|
||||||
DEFAULT_CLICKMODE = cmSelectPoint;
|
DEFAULT_CLICKMODE = cmSelectPoint;
|
||||||
@ -204,7 +203,7 @@ type
|
|||||||
procedure RubberbandStart(AMapView: TMapView; X, Y: Integer);
|
procedure RubberbandStart(AMapView: TMapView; X, Y: Integer);
|
||||||
procedure RubberbandTo(AMapView: TMapView; X, Y: Integer);
|
procedure RubberbandTo(AMapView: TMapView; X, Y: Integer);
|
||||||
procedure RubberbandEnd(AMapView: TMapView; X, Y: Integer);
|
procedure RubberbandEnd(AMapView: TMapView; X, Y: Integer);
|
||||||
procedure ToggleSelected(AMapView: TMapView; APoint: TGPSPoint);
|
procedure UnselectPoint(AMapView: TMapView; APoint: TGPSPoint);
|
||||||
protected
|
protected
|
||||||
procedure AfterDrawObjects(AMapView: TMapView; var {%H-}Handled: Boolean); override;
|
procedure AfterDrawObjects(AMapView: TMapView; var {%H-}Handled: Boolean); override;
|
||||||
procedure MouseDown(AMapView: TMapView; {%H-}Button: TMouseButton;
|
procedure MouseDown(AMapView: TMapView; {%H-}Button: TMouseButton;
|
||||||
@ -686,8 +685,8 @@ begin
|
|||||||
FOnStartDrag(AMapView, canDrag);
|
FOnStartDrag(AMapView, canDrag);
|
||||||
if not canDrag then exit;
|
if not canDrag then exit;
|
||||||
end;
|
end;
|
||||||
|
FState := FState + [psDragging] - [psPendingUnselect];
|
||||||
AMapView.Cursor := DragCursor;
|
AMapView.Cursor := DragCursor;
|
||||||
Include(FState, psDragging);
|
|
||||||
// Save original selection point coordinates in case they must be restored later.
|
// Save original selection point coordinates in case they must be restored later.
|
||||||
SetLength(FOrigSelection, FSelection.Count);
|
SetLength(FOrigSelection, FSelection.Count);
|
||||||
for i := 0 to High(FOrigSelection) do
|
for i := 0 to High(FOrigSelection) do
|
||||||
@ -1008,11 +1007,15 @@ begin
|
|||||||
begin
|
begin
|
||||||
case FClickMode of
|
case FClickMode of
|
||||||
cmSelectPoint:
|
cmSelectPoint:
|
||||||
AddToSelection(AMapView, FOrigGPSPoint, psExtendingSelection in FState);
|
if FSelection.IndexOf(FOrigGPSPoint) = -1 then
|
||||||
|
begin
|
||||||
|
AddToSelection(AMapView, FOrigGPSPoint, psExtendingSelection in FState);
|
||||||
|
Exclude(FState, psPendingUnselect);
|
||||||
|
end else
|
||||||
|
if (psExtendingSelection in FState) then
|
||||||
|
Include(FState, psPendingUnselect);
|
||||||
cmSelectShape:
|
cmSelectShape:
|
||||||
SelectAllPointsOfShape(AMapView, FOrigGPSPoint, psExtendingSelection in FState);
|
SelectAllPointsOfShape(AMapView, FOrigGPSPoint, psExtendingSelection in FState);
|
||||||
cmTogglePoint:
|
|
||||||
ToggleSelected(AMapView, FOrigGPSPoint);
|
|
||||||
end;
|
end;
|
||||||
Update;
|
Update;
|
||||||
Handled := true;
|
Handled := true;
|
||||||
@ -1028,10 +1031,10 @@ begin
|
|||||||
cmRubberband:
|
cmRubberband:
|
||||||
;
|
;
|
||||||
else
|
else
|
||||||
if (FSelection.Count > 0) and
|
if (FSelection.Count > 0) then
|
||||||
(MessageDlg('Do you really want to unselect these points?', mtConfirmation, [mbYes, mbNo], 0) = mrYes) then
|
|
||||||
begin
|
begin
|
||||||
FSelection.Clear;
|
if (MessageDlg('Do you really want to unselect these points?', mtConfirmation, [mbYes, mbNo], 0) = mrYes) then
|
||||||
|
FSelection.Clear;
|
||||||
Handled := true;
|
Handled := true;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1080,6 +1083,8 @@ begin
|
|||||||
DragEnd(AMapView);
|
DragEnd(AMapView);
|
||||||
if (psRubberbandMode in FState) then
|
if (psRubberbandMode in FState) then
|
||||||
RubberbandEnd(AMapView, X, Y);
|
RubberbandEnd(AMapView, X, Y);
|
||||||
|
if (psPendingUnselect in FState) then
|
||||||
|
UnselectPoint(AMapView, FOrigGPSPoint);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMarkerEditorPlugin.NewPoint(AMapView: TMapView;
|
function TMarkerEditorPlugin.NewPoint(AMapView: TMapView;
|
||||||
@ -1240,20 +1245,17 @@ begin
|
|||||||
Update;
|
Update;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMarkerEditorPlugin.ToggleSelected(AMapView: TMapView;
|
procedure TMarkerEditorPlugin.UnselectPoint(AMapView: TMapView;
|
||||||
APoint: TGPSPoint);
|
APoint: TGPSPoint);
|
||||||
var
|
var
|
||||||
idx: Integer;
|
idx: Integer;
|
||||||
begin
|
begin
|
||||||
idx := FSelection.IndexOf(APoint);
|
idx := FSelection.IndexOf(APoint);
|
||||||
if idx = -1 then
|
if idx > -1 then
|
||||||
begin
|
begin
|
||||||
if not (psExtendingSelection in FState)then
|
|
||||||
FSelection.Clear;
|
|
||||||
FSelection.Add(APoint);
|
|
||||||
end else
|
|
||||||
FSelection.Delete(idx);
|
FSelection.Delete(idx);
|
||||||
DoSelectionChange(AMapView);
|
DoSelectionChange(AMapView);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user