Skip to content

Commit 2e49556

Browse files
authored
Merge pull request #99 from NREL/katienfixes
north axis
2 parents 910b5af + 1a486ae commit 2e49556

3 files changed

Lines changed: 27 additions & 6 deletions

File tree

src/components/Canvas/Canvas.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Redistribution and use in source and binary forms, with or without modification,
77
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -->
88
<template>
99
<div id="canvas" ref="canvas">
10+
<svg id="north_axis" height="1792" viewBox="0 0 1792 1792" width="1792" xmlns="http://www.w3.org/2000/svg" :transform="`rotate(${northAxis})`">
11+
<path d="M1277 493q-9 19-29 19h-224v1248q0 14-9 23t-23 9H800q-14 0-23-9t-9-23V512H544q-21 0-29-19t5-35L870 74q10-10 23-10 14 0 24 10l355 384q13 16 5 35z"/>
12+
</svg>
1013
<map-view v-if="mapEnabled" v-show="mapVisible"></map-view>
1114
<images-view></images-view>
1215
</div>
@@ -27,7 +30,8 @@ export default {
2730
computed: {
2831
...mapState({
2932
mapEnabled: state => state.project.map.enabled,
30-
mapVisible: state => state.project.map.visible
33+
mapVisible: state => state.project.map.visible,
34+
northAxis: state => state.project.config.north_axis,
3135
})
3236
},
3337
components: {
@@ -39,7 +43,14 @@ export default {
3943

4044
<style lang="scss" scoped>
4145
@import "./../../scss/config";
42-
46+
svg#north_axis {
47+
height: 2.25rem;
48+
position: absolute;
49+
top: 1rem;
50+
left: 1rem;
51+
width: 3rem;
52+
z-index: 90;
53+
}
4354
#canvas {
4455
background: white;
4556
height: 100%;

src/components/Toolbar.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
2929
<label>spacing</label>
3030
<input v-model.number.lazy="spacing">
3131
</div>
32+
33+
<div class="input-number">
34+
<label>north axis</label>
35+
<input v-model.number.lazy="northAxis" :disabled="mapEnabled">
36+
</div>
3237

3338
<div id="import-export">
3439
<input ref="importLibrary" @change="importLibraryAsFile" type="file"/>
@@ -136,7 +141,10 @@ export default {
136141
// never display the map tool, it is only used when the map is initialized
137142
.filter(t => t !== 'Map');
138143
},
139-
144+
northAxis: {
145+
get () { return this.$store.state.project.config.north_axis + '°'; },
146+
set (val) { this.$store.dispatch('project/setNorthAxis', { north_axis: val }); }
147+
},
140148
gridVisible: {
141149
get () { return this.$store.state.project.grid.visible; },
142150
set (val) { this.$store.dispatch('project/setGridVisible', { visible: val }); }

src/store/modules/project/actions.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ export default {
1313
}
1414
},
1515
setNorthAxis (context, payload) {
16-
const validator = new Validator(payload);
17-
validator.validateFloat('north_axis');
18-
context.commit('setConfigNorthAxis', validator.validatedPayload);
16+
const { north_axis } = payload;
17+
if (north_axis > 360 || north_axis < 0) { return; }
18+
context.commit('setConfigNorthAxis', { north_axis });
1919
},
2020
setMapVisible (context, payload) {
2121
if (typeof payload.visible === 'boolean') {
@@ -96,7 +96,9 @@ export default {
9696
context.commit('setMapZoom', { zoom: payload.zoom });
9797
},
9898

99+
99100
setMapRotation (context, payload) {
101+
context.dispatch('setNorthAxis', { north_axis: (payload.rotation/(2*Math.PI)) * 360 });
100102
context.commit('setMapRotation', { rotation: payload.rotation });
101103
},
102104

0 commit comments

Comments
 (0)