Skip to content

Commit 9e01621

Browse files
committed
Added quick drawing mode for Orbits view. Added speed metrics. Fix IE/Edge cursor issue.
1 parent 61a8efc commit 9e01621

7 files changed

Lines changed: 80 additions & 8 deletions

File tree

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svc-ng",
3-
"version": "1.4.13",
3+
"version": "1.4.14",
44
"license": "MIT AND GPL-3.0-or-later",
55
"author": "Kerry Shetline <kerry@shetline.com>",
66
"scripts": {

src/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="about-dialog">
33
<img src="/assets/resources/svc_lunar_eclipse.png" alt="lunar eclipse" width="64" height="64">
44
<h2>Sky View Café NP</h2>
5-
Version 1.4.13<br><br>
5+
Version 1.4.14<br><br>
66
Copyright © 2016-2018 Kerry Shetline.
77
</div>
88
</p-dialog>

src/app/svc/generic-view.ts

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,20 @@
2020
other uses are restricted.
2121
*/
2222

23-
import { AfterViewInit } from '@angular/core';
23+
import { AfterViewInit, ElementRef, ViewChild } from '@angular/core';
2424
import { AppService, CurrentTab } from '../app.service';
2525
import {
2626
ASTEROID_BASE, COMET_BASE, EARTH, FIRST_PLANET, HALF_MINUTE, ISkyObserver, LAST_PLANET, NO_MATCH, SkyObserver, SolarSystem,
2727
StarCatalog, UT_to_TDB
2828
} from 'ks-astronomy';
2929
import { ceil, max, round, sqrt } from 'ks-math';
30-
import { FontMetrics, getFontMetrics, isSafari } from 'ks-util';
30+
import { FontMetrics, getFontMetrics, isSafari, padLeft } from 'ks-util';
3131
import * as _ from 'lodash';
3232
import { KsDateTime } from 'ks-date-time-zone';
3333
import { SafeStyle } from '@angular/platform-browser';
3434
import { Subscription, BehaviorSubject, Observable } from 'rxjs';
3535
import { getXYForTouchEvent } from '../util/ks-touch-events';
36+
import { KsMarqueeComponent } from '../widgets/ks-marquee/ks-marquee.component';
3637

3738
export const PROPERTY_ADDITIONALS = 'additionals';
3839
export enum ADDITIONALS {NONE, ALL_ASTEROIDS, ALL_COMETS, ALL}
@@ -69,6 +70,9 @@ export abstract class GenericView implements AfterViewInit {
6970

7071
protected wrapper: HTMLDivElement;
7172
protected canvas: HTMLCanvasElement;
73+
protected marquee: HTMLElement;
74+
protected lastMarqueeClick = 0;
75+
protected marqueeClickCount = 0;
7276
protected canvasScaling = 1;
7377
protected touchGuard: HTMLDivElement;
7478
protected lastWidth = -1;
@@ -99,13 +103,19 @@ export abstract class GenericView implements AfterViewInit {
99103
protected planetsToDraw: number[] = [];
100104
protected additional: ADDITIONALS | string = ADDITIONALS.NONE;
101105

106+
protected showMetrics = false;
107+
protected lastDrawStart = 0;
108+
protected lastFullDrawTime: number;
109+
102110
protected sanitizedHandCursor: SafeStyle;
103111
protected sanitizedLabelCrosshair: SafeStyle;
104112

105113
protected readonly largeLabelFont = '12px Arial, Helvetica, sans-serif';
106114
protected readonly mediumLabelFont = '11px Arial, Helvetica, sans-serif';
107115
protected readonly smallLabelFont = '10px Arial, Helvetica, sans-serif';
108116

117+
@ViewChild(KsMarqueeComponent, {read: ElementRef}) protected marqueeRef: ElementRef;
118+
109119
public marqueeText = '';
110120

111121
cursor: SafeStyle;
@@ -184,6 +194,47 @@ export abstract class GenericView implements AfterViewInit {
184194
GenericView.getPrintingUpdate(printing => {
185195
this.doResize(printing);
186196
});
197+
198+
if (this.marqueeRef) {
199+
this.marquee = this.marqueeRef.nativeElement as HTMLElement;
200+
this.marquee.addEventListener('click', event => this.marqueeClick(event));
201+
this.marquee.addEventListener('touchstart', event => this.marqueeTouch(event));
202+
}
203+
}
204+
205+
private marqueeClick(event: MouseEvent): void {
206+
if (event.detail === 3)
207+
this.toggleMarqueeMetrics();
208+
else if (event.detail === 0 || event.detail === undefined)
209+
this.countMarqueeClicks();
210+
}
211+
212+
private marqueeTouch(event: TouchEvent): void {
213+
if (event.touches.length > 2)
214+
this.toggleMarqueeMetrics();
215+
else if (event.touches.length === 1)
216+
this.countMarqueeClicks();
217+
}
218+
219+
private countMarqueeClicks(): void {
220+
const now = performance.now();
221+
222+
if (now > this.lastMarqueeClick + 500)
223+
this.marqueeClickCount = 1;
224+
else if (++this.marqueeClickCount === 3)
225+
this.toggleMarqueeMetrics();
226+
227+
this.lastMarqueeClick = now;
228+
}
229+
230+
private toggleMarqueeMetrics(): void {
231+
const saveBackground = this.marquee.style.backgroundColor;
232+
233+
this.showMetrics = !this.showMetrics;
234+
this.marqueeText = '';
235+
this.clearMouseHighlighting();
236+
this.marquee.style.backgroundColor = 'cyan';
237+
setTimeout(() => this.marquee.style.backgroundColor = saveBackground, 500);
187238
}
188239

189240
onResize(): void {
@@ -410,14 +461,15 @@ export abstract class GenericView implements AfterViewInit {
410461
this.lastDrawingContext = dc;
411462

412463
const now = performance.now();
464+
const drawingTime = now - startTime;
413465

414466
if (dc.fullDraw) {
415-
const fullDrawingTime = now - startTime;
467+
this.lastFullDrawTime = max(drawingTime, 1);
416468

417469
if (forceFullDraw)
418470
this.slowFrameCount = 0;
419471

420-
if (fullDrawingTime > SLOW_DRAWING_THRESHOLD) {
472+
if (this.lastFullDrawTime > SLOW_DRAWING_THRESHOLD) {
421473
++this.slowFrameCount;
422474
this.lastSlowFrameTime = now;
423475
}
@@ -426,6 +478,18 @@ export abstract class GenericView implements AfterViewInit {
426478
this.debouncedFullRedraw();
427479
this.lastSlowFrameTime = now;
428480
}
481+
482+
if (this.showMetrics) {
483+
const interval = max(startTime - this.lastDrawStart, 1);
484+
485+
this.marqueeText = padLeft(drawingTime.toFixed(1), 6, '\u2007') + (dc.fullDraw ? 'F' : 'Q') + ', ' +
486+
padLeft(interval.toFixed(1), 6, '\u2007');
487+
488+
if (!dc.fullDraw)
489+
this.marqueeText += ', ' + padLeft(this.lastFullDrawTime.toFixed(1), 6, '\u2007') + 'F';
490+
}
491+
492+
this.lastDrawStart = startTime;
429493
}
430494

431495
protected additionalDrawingSetup(dc: DrawingContext): void {

src/app/svc/svc-orbit-view/svc-orbit-view.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ const EYE_OFFSET_DIVISOR = 30.0;
7474

7575
const MARKER_SIZE = 9;
7676
const MARKER_SIZE2 = floor(MARKER_SIZE / 2);
77-
const MARKER_GAP = 2;
7877

7978
const DRAG_LOCK_DELTA = 5;
8079

@@ -277,6 +276,9 @@ export class SvcOrbitViewComponent extends GenericPlanetaryView implements After
277276
let colorIndex = planet;
278277

279278
if (SolarSystem.isAsteroidOrComet(planet)) {
279+
if (!dc.fullDraw)
280+
continue;
281+
280282
// Don't use this orbit drawing method for highly eccentric asteroids and comets.
281283
if (!oe || oe.e > 0.98) {
282284
specialCases.push(planet);

src/app/widgets/ks-sequence-editor/ks-sequence-editor.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export class KsSequenceEditorComponent implements AfterViewInit, OnInit, OnDestr
8787
private static useHiddenInput = isAndroid();
8888
private static addFocusOutline = isEdge() || isIE() || isIOS();
8989
private static checkForRepeatedKeyTimestamps = isIOS();
90+
private static disableContentEditable = isEdge() || isIE();
9091

9192
private keyTimer: Subscription;
9293
private clickTimer: Subscription;
@@ -228,6 +229,9 @@ export class KsSequenceEditorComponent implements AfterViewInit, OnInit, OnDestr
228229
this.canvas.setAttribute('tabindex', '-1');
229230
}
230231

232+
if (KsSequenceEditorComponent.disableContentEditable)
233+
this.canvas.contentEditable = 'false';
234+
231235
this.computeSize();
232236
this.draw();
233237
}

src/assets/about.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
<h2 class="header-sans"><a name="history">What's New / Version History</a></h2>
6161
<div style="padding-left: 1em; text-indent: -1em">
6262

63+
<p><b>1.4.14, 2018-08-14:</b> Added quick drawing mode for Orbits view. Added speed metrics.</p>
64+
6365
<p><b>1.4.13, 2018-08-13:</b> Increased graphics resolution for high resolution displays. Added quick,
6466
lower-resolution drawing mode for slow devices. Added three-finger gesture for escaping "zoom traps".</p>
6567

0 commit comments

Comments
 (0)