mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-10-09 23:26:31 +00:00
reverse
This commit is contained in:
1 parent
a48608840f
commit
290f4d8c44
8 files changed
+213
-28
No files matched your search
@@ -180,7 +180,7 @@
|
||||
variant="outline"
|
||||
class="gap-1 text-xs px-1.5 py-1.5 h-fit"
|
||||
disabled={!validSelection}
|
||||
onclick={fileActions.createRoundTripForSelection}
|
||||
onclick={() => engine.roundTrip()}
|
||||
>
|
||||
<Repeat class="size-3" />{i18n._('toolbar.routing.round_trip.button')}
|
||||
</ButtonWithTooltip>
|
||||
|
||||
@@ -645,6 +645,15 @@ class Engine {
|
||||
return this.run((w) => w.reverse());
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes each selected segment (or the segments of the selected files and tracks) come back to
|
||||
* where it started: a reversed copy of it is added after its last trackpoint (which is not
|
||||
* repeated), and goes on in time. Resolves to `false` when no segment has the two trackpoints that a way back needs.
|
||||
*/
|
||||
roundTrip() {
|
||||
return this.run((w) => w.round_trip());
|
||||
}
|
||||
|
||||
metadata(name: string, desc: string) {
|
||||
return this.run((w) => w.metadata(name, desc));
|
||||
}
|
||||
|
||||
@@ -101,32 +101,6 @@ export async function loadFiles(list: FileList | File[]): Promise<string[]> {
|
||||
|
||||
// Helper functions for file operations
|
||||
export const fileActions = {
|
||||
createRoundTripForSelection() {
|
||||
if (!get(selection).hasAnyChildren(new ListRootItem(), true, ['waypoints'])) {
|
||||
return;
|
||||
}
|
||||
fileActionManager.applyGlobal((draft) => {
|
||||
selection.applyToOrderedSelectedItemsFromFile((fileId, level, items) => {
|
||||
let file = draft.get(fileId);
|
||||
if (file) {
|
||||
if (level === ListLevel.FILE) {
|
||||
file.roundTrip();
|
||||
} else if (level === ListLevel.TRACK) {
|
||||
for (let item of items) {
|
||||
let trackIndex = (item as ListTrackItem).getTrackIndex();
|
||||
file.roundTripTrack(trackIndex);
|
||||
}
|
||||
} else if (level === ListLevel.SEGMENT) {
|
||||
for (let item of items) {
|
||||
let trackIndex = (item as ListTrackSegmentItem).getTrackIndex();
|
||||
let segmentIndex = (item as ListTrackSegmentItem).getSegmentIndex();
|
||||
file.roundTripTrackSegment(trackIndex, segmentIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
mergeSelection: (mergeTraces: boolean, removeGaps: boolean) => {
|
||||
fileActionManager.applyGlobal((draft) => {
|
||||
let first = true;
|
||||
|
||||
Reference in new issue
Block a user