ofs-object 0.1.0-beta.2 → 0.1.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1071,6 +1071,8 @@ export declare const DEFAULT_MAX_NETWORK_POINTS = 5000;
1071
1071
 
1072
1072
  export declare const DEFAULT_POLAR_TRACKING: PolarTrackingSettings;
1073
1073
 
1074
+ export declare const DEFAULT_PREVIEW_STYLE: DrawPreviewStyle;
1075
+
1074
1076
  /**
1075
1077
  * How far the stored polyline may sag away from the true arc, in meters. Five centimeters is below
1076
1078
  * the positional accuracy of the survey data these plans are drawn over, and is deliberately a
@@ -1253,6 +1255,21 @@ export declare type DrawMode = 'point' | 'line' | 'polygon' | 'circle' | 'rectan
1253
1255
  */
1254
1256
  export declare function drawNorthArrow(ctx: DrawingContext, x: number, y: number, size?: number, bearingDeg?: number): void;
1255
1257
 
1258
+ export declare interface DrawPreviewStyle {
1259
+ pointColor: string;
1260
+ pointRadius: number;
1261
+ pointStrokeColor: string;
1262
+ pointStrokeWidth: number;
1263
+ lineColor: string;
1264
+ lineWidth: number;
1265
+ /** Dash pattern in multiples of the line width; an empty list draws a solid line */
1266
+ lineDash: number[];
1267
+ fillColor: string;
1268
+ fillOpacity: number;
1269
+ /** Applied to points and lines together, so the whole preview can be dimmed at once */
1270
+ opacity: number;
1271
+ }
1272
+
1256
1273
  /** Draw a scale bar with its left end at (x, y) (y is the bottom of the bar) */
1257
1274
  export declare function drawScaleBar(ctx: DrawingContext, plan: ScaleBarPlan, x: number, y: number, style?: ScaleBarStyle): void;
1258
1275
 
@@ -2847,12 +2864,64 @@ export declare interface OFSDataSourceEvents {
2847
2864
  */
2848
2865
  export declare type OFSDiagnosticHandler = (scope: string, error: unknown) => void;
2849
2866
 
2867
+ export declare class OFSDrawPreview {
2868
+ private mapAdapter;
2869
+ private sourceId;
2870
+ private style;
2871
+ private current;
2872
+ /** Layer ids in draw order, bottom first */
2873
+ get layerIds(): string[];
2874
+ constructor(mapAdapter: IMapAdapter);
2875
+ private raw;
2876
+ /**
2877
+ * Create the source and layers. Called for you the first time anything is drawn, so a caller that
2878
+ * only ever uses `set` never has to think about it.
2879
+ */
2880
+ setupLayers(): void;
2881
+ /**
2882
+ * Replace what the preview shows. Safe to call on every mouse move: it writes one GeoJSON payload
2883
+ * and touches nothing else.
2884
+ *
2885
+ * Points, lines and polygons can be mixed freely. A feature may carry `color`, `opacity`, `width`,
2886
+ * `radius`, `fillOpacity`, `strokeColor` or `strokeWidth` in its properties to depart from the
2887
+ * style for itself.
2888
+ */
2889
+ set(features: Feature<Geometry, any>[] | FeatureCollection | null): void;
2890
+ /**
2891
+ * Take the preview off the map.
2892
+ *
2893
+ * This is never called for you when a drawing finishes or is cancelled. The preview belongs to the
2894
+ * caller and only the caller knows whether it has gone stale, so scaffolding tied to a drawing
2895
+ * session is cleared from a `draw:complete` and `draw:cancel` handler.
2896
+ */
2897
+ clear(): void;
2898
+ /** What the preview is currently showing */
2899
+ getFeatures(): Feature<Geometry, any>[];
2900
+ isEmpty(): boolean;
2901
+ /** Change the look of the preview. Anything left out keeps its current value. */
2902
+ setStyle(style: Partial<DrawPreviewStyle>): void;
2903
+ getStyle(): DrawPreviewStyle;
2904
+ /**
2905
+ * Lift the preview above the data layers. The drawing guides are raised after this, so the rubber
2906
+ * band and the measurements stay readable over whatever the preview is showing.
2907
+ */
2908
+ bringToFront(): void;
2909
+ /** Remove the layers and the source, for when the draw tools are torn down */
2910
+ destroy(): void;
2911
+ }
2912
+
2850
2913
  export declare class OFSDrawTools extends TypedEventEmitter<DrawEvents> {
2851
2914
  private dataSource;
2852
2915
  private mapAdapter;
2853
2916
  readonly snapping: SnappingEngine;
2854
2917
  readonly grips: OFSGripsEditor;
2855
2918
  readonly selectionOverlay: OFSSelectionOverlay;
2919
+ /**
2920
+ * A scratch layer for the host application to draw on while a tool is in use - a planting grid
2921
+ * following the line being drawn, the parcels a cutting line is about to divide. Nothing put here
2922
+ * reaches the data source, the undo history or an export. See `preview/draw-preview.ts`.
2923
+ */
2924
+ readonly preview: OFSDrawPreview;
2856
2925
  orthoEnabled: boolean;
2857
2926
  polarTracking: PolarTrackingSettings;
2858
2927
  /** Angle convention and UCS used for typed angles, relative coordinates, ortho and polar tracking */