mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-28 03:17:14 +01:00
create default sketcher layers in viewer constructor
This commit is contained in:
parent
b51361fa3c
commit
85afe6d6fe
2 changed files with 14 additions and 11 deletions
|
|
@ -19,15 +19,6 @@ function initializeSketcherApplication() {
|
|||
app.loadFromLocalStorage();
|
||||
app.fit();
|
||||
|
||||
function addLayer(name, style) {
|
||||
if (app.viewer.findLayerByName(name) === null) {
|
||||
app.viewer.layers.push(new Layer(name, style));
|
||||
}
|
||||
}
|
||||
|
||||
addLayer("sketch", Styles.DEFAULT);
|
||||
addLayer("_construction_", Styles.CONSTRUCTION);
|
||||
|
||||
var actionsWin = new ui.Window($('#actions'), app.winManager);
|
||||
|
||||
ui.bindOpening( $('#showActions'), actionsWin );
|
||||
|
|
|
|||
|
|
@ -53,7 +53,10 @@ function Viewer(canvas, IO) {
|
|||
this.bus = new Bus();
|
||||
this.ctx = this.canvas.getContext("2d");
|
||||
this._activeLayer = null;
|
||||
this.layers = [];
|
||||
this.layers = [
|
||||
new Layer("sketch", Styles.DEFAULT),
|
||||
new Layer("_construction_", Styles.CONSTRUCTION)
|
||||
];
|
||||
this.dimLayer = new Layer("_dim", Styles.DIM);
|
||||
this.dimLayers = [this.dimLayer];
|
||||
this.bus.defineObservable(this, 'dimScale', 1);
|
||||
|
|
@ -401,12 +404,21 @@ Viewer.prototype.getActiveLayer = function() {
|
|||
}
|
||||
}
|
||||
if (layer == null) {
|
||||
layer = new Layer("JustALayer", Styles.DEFAULT);
|
||||
layer = new Layer("sketch", Styles.DEFAULT);
|
||||
this.layers.push(layer);
|
||||
}
|
||||
return layer;
|
||||
};
|
||||
|
||||
Viewer.prototype.setActiveLayerName = function(layerName) {
|
||||
let layer = this.findLayerByName(layerName);
|
||||
if (layer) {
|
||||
this.activeLayer = layer;
|
||||
} else {
|
||||
console.warn("layer doesn't exist: " + layerName);
|
||||
}
|
||||
};
|
||||
|
||||
Viewer.prototype.setActiveLayer = function(layer) {
|
||||
if (!layer.readOnly) {
|
||||
this._activeLayer = layer;
|
||||
|
|
|
|||
Loading…
Reference in a new issue