diff --git a/components/lazmapviewer/examples/plugin_demos/markerselectdrag_demo/main.lfm b/components/lazmapviewer/examples/plugin_demos/markerselectdrag_demo/main.lfm index 6395db829..248b85bfb 100644 --- a/components/lazmapviewer/examples/plugin_demos/markerselectdrag_demo/main.lfm +++ b/components/lazmapviewer/examples/plugin_demos/markerselectdrag_demo/main.lfm @@ -1,18 +1,18 @@ object MainForm: TMainForm Left = 513 - Height = 505 + Height = 566 Top = 157 - Width = 756 + Width = 796 Caption = 'Marker Select & Drag Demo' - ClientHeight = 505 - ClientWidth = 756 + ClientHeight = 566 + ClientWidth = 796 LCLVersion = '4.99.0.0' OnCreate = FormCreate object MapView: TMapView Left = 0 - Height = 396 + Height = 457 Top = 0 - Width = 756 + Width = 796 Align = alClient DownloadEngine = MapView.BuiltInDLE DrawingEngine = MapView.BuiltInDE @@ -25,7 +25,7 @@ object MainForm: TMainForm object Bevel1: TBevel AnchorSideLeft.Control = Owner AnchorSideLeft.Side = asrCenter - Left = 375 + Left = 395 Height = 50 Top = 108 Width = 6 @@ -34,13 +34,13 @@ object MainForm: TMainForm object Panel1: TPanel Left = 0 Height = 109 - Top = 396 - Width = 756 + Top = 457 + Width = 796 Align = alBottom AutoSize = True BevelOuter = bvNone ClientHeight = 109 - ClientWidth = 756 + ClientWidth = 796 TabOrder = 1 object cgPointTypes: TCheckGroup AnchorSideLeft.Control = Panel1 @@ -112,12 +112,12 @@ object MainForm: TMainForm AnchorSideLeft.Control = cgPointTypes AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = cgPointTypes - AnchorSideBottom.Control = cgPointTypes + AnchorSideBottom.Control = cbMultiSelect AnchorSideBottom.Side = asrBottom Left = 379 - Height = 70 + Height = 95 Top = 8 - Width = 133 + Width = 166 Anchors = [akTop, akLeft, akBottom] AutoFill = True AutoSize = True @@ -130,24 +130,27 @@ object MainForm: TMainForm ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 - ClientHeight = 50 - ClientWidth = 129 + ClientHeight = 75 + ClientWidth = 162 ItemIndex = 0 Items.Strings = ( - 'Add to selection' - 'Toggle selection' + 'Add point to selection' + 'Add shape to selection' + 'Toggle selected point' ) TabOrder = 1 OnClick = rgClickModeClick end object cbMultiSelect: TCheckBox - AnchorSideLeft.Control = rgClickMode + AnchorSideLeft.Control = Label2 + AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = Label1 AnchorSideTop.Side = asrCenter - Left = 379 + Left = 219 Height = 19 Top = 84 Width = 77 + BorderSpacing.Left = 24 Caption = 'MultiSelect' TabOrder = 2 OnChange = cbMultiSelectChange @@ -156,7 +159,7 @@ object MainForm: TMainForm AnchorSideLeft.Control = rgClickMode AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = rgClickMode - Left = 520 + Left = 553 Height = 25 Top = 8 Width = 109 @@ -170,7 +173,7 @@ object MainForm: TMainForm AnchorSideLeft.Control = btnDeleteSelection AnchorSideTop.Control = btnDeleteSelection AnchorSideTop.Side = asrBottom - Left = 520 + Left = 553 Height = 25 Top = 33 Width = 111 @@ -183,7 +186,7 @@ object MainForm: TMainForm AnchorSideLeft.Control = btnDeleteSelection AnchorSideTop.Control = btnConvertToTrack AnchorSideTop.Side = asrBottom - Left = 520 + Left = 553 Height = 25 Top = 58 Width = 107 @@ -198,7 +201,7 @@ object MainForm: TMainForm AnchorSideTop.Control = btnDeleteSelection AnchorSideBottom.Control = btnConvertToArea AnchorSideBottom.Side = asrBottom - Left = 639 + Left = 672 Height = 63 Top = 20 Width = 103 diff --git a/components/lazmapviewer/source/addons/plugins/markers/mvmarkerplugins.pas b/components/lazmapviewer/source/addons/plugins/markers/mvmarkerplugins.pas index c7f72ae1e..8b5bec70d 100644 --- a/components/lazmapviewer/source/addons/plugins/markers/mvmarkerplugins.pas +++ b/components/lazmapviewer/source/addons/plugins/markers/mvmarkerplugins.pas @@ -96,7 +96,7 @@ type ADrawingEngine: TMvCustomDrawingEngine; AGPSPoint: TGPSPoint; AScreenPoint: TPoint; AMarkerSize: Integer) of object; - TMarkerClickMode = (mcmAddToSelection, mcmToggleSelection); + TMarkerClickMode = (mcmAddPointToSelection, mcmAddShapeToSelection, mcmToggleSelectedPoint); TMarkerSelectAndDragPlugin = class(TMarkerClickPlugin) private @@ -137,9 +137,10 @@ type function ConvertSelectedPointsToGPSTrack(AMapView: TMapView; ATrackID: Integer): TGPSTrack; function ConvertSelectedPointsToMapTrack(AMapView: TMapView; ALayer: TMapLayer): TMapTrack; procedure DeleteSelectedPoints(AMapView: TMapView); + procedure SelectAllPointsOfShape(AMapView: TMapView; APoint: TGPSPoint); property Selection: TGPSPointList read FSelection; published - property ClickMode: TMarkerClickMode read FClickMode write FClickMode default mcmAddToSelection; + property ClickMode: TMarkerClickMode read FClickMode write FClickMode default mcmAddPointToSelection; property DragCursor: TCursor read FDragCursor write FDragCursor default crSizeAll; property MultiSelect: Boolean read FMultiSelect write SetMultiSelect default false; property OnDrawPoint: TMarkerDrawPointEvent read FOnDrawPoint write FOnDrawPoint; @@ -738,8 +739,9 @@ begin if FMouseDownOnMarker then begin case FClickMode of - mcmAddToSelection : AddToSelection(AMapView, FOrigGPSPoint); - mcmToggleSelection: ToggleSelected(AMapView, FOrigGPSPoint); + mcmAddPointToSelection: AddToSelection(AMapView, FOrigGPSPoint); + mcmAddShapeToSelection: SelectAllPointsOfShape(AMapView, FOrigGPSPoint); + mcmToggleSelectedPoint: ToggleSelected(AMapView, FOrigGPSPoint); end; Update; Handled := true; @@ -786,6 +788,126 @@ begin DragEnd(AMapView); end; +procedure TMarkerSelectAndDragPlugin.SelectAllPointsOfShape(AMapView: TMapView; + APoint: TGPSPoint); +var + i, j, k, L: Integer; + gpsLayer: TGPSObjectList; + gpsPOI: TGPSPointOfInterest; + gpsPolyline: TGPSPolyLine; + item: TGPSObj; + p: TMapPoint; + mapLayer: TMapLayer; + mapTrack: TMapTrack; + mapArea: TMapArea; + + function IsSamePoint(AItem: TGPSObj): Boolean; + begin + Result := (AItem is TGPSPoint) and TGPSPoint(AItem).RealPoint.Equal(APoint.RealPoint); + end; + + procedure Finished; + begin + AddToSelection(AMapView, APoint); // Mark APoint as being focused + Update; + DoSelectionChange(AMapView); + end; + +begin + // Check the 10 layers of GPSItems + for i := 0 to 9 do + begin + gpsLayer := AMapView.GPSLayer[i]; + for j := 0 to gpsLayer.Count-1 do + begin + item := gpsLayer[j]; + if (item is TGPSPointOfInterest) then + begin + gpsPOI := TGPSPointOfInterest(item); + if gpsPOI.RealPoint.Equal(APoint.RealPoint) then + begin + AddToSelection(AMapView, TGPSPoint(item)); + Finished; + Exit; + end; + end; + if (item is TGPSPolyline) then + begin + gpsPolyLine := TGPSPolyLine(item); + for k := 0 to gpsPolyLine.Points.Count-1 do + begin + item := gpsPolyLine.Points[k]; + if IsSamePoint(item) then + begin + for L := 0 to GPSPolyLine.Points.Count-1 do + begin + item := gpsPolyLine.Points[L]; + AddToSelection(AMapView, TGPSPoint(item)); + end; + Finished; + exit; + end; + end; + end; + end; + end; + + // Check the map layers + for i := 0 to AMapView.Layers.Count-1 do + begin + mapLayer := AMapView.Layers[i]; + // Points of interest? + for j := 0 to mapLayer.PointsOfInterest.Count-1 do + begin + p := mapLayer.PointsOfInterest[j]; + if IsSamePoint(p.GPSObj) then + begin + AddToSelection(AMapView, TGPSPoint(p.GPSObj)); + Finished; + Exit; + end; + end; + // Tracks? + for j := 0 to mapLayer.Tracks.Count-1 do + begin + mapTrack := mapLayer.Tracks[j]; + for k := 0 to mapTrack.Points.Count-1 do + begin + p := mapTrack.Points[k]; + if IsSamePoint(p.GPSObj) then + begin + for L := 0 to mapTrack.Points.Count-1 do + begin + p := mapTrack.Points[L]; + AddToSelection(AMapView, TGPSPoint(p.GPSObj)); + end; + Finished; + exit; + end; + end; + end; + // Areas? + for j := 0 to mapLayer.Areas.Count-1 do + begin + mapArea := mapLayer.Areas[j]; + for k := 0 to mapArea.Points.Count-1 do + begin + p := mapArea.Points[k]; + if IsSamePoint(p.GPSObj) then + begin + for L := 0 to mapArea.Points.Count-1 do + begin + p := mapArea.Points[L]; + AddToSelection(AMapView, TGPSPoint(p.GPSObj)); + end; + Finished; + exit; + end; + end; + end; + end; +end; + procedure TMarkerSelectAndDragPlugin.SetMultiSelect(AValue: Boolean); begin if FMultiSelect = AValue then exit;