27 lines
868 B
CoffeeScript
27 lines
868 B
CoffeeScript
attr = DS.attr
|
|
App.SvgElementMixin = Ember.Mixin.create
|
|
name: attr 'string'
|
|
dpm: attr 'number'
|
|
box_width: attr 'number'
|
|
box_height: attr 'number'
|
|
svg: attr('string')
|
|
|
|
width: Ember.computed 'dpm', 'box_width', ->
|
|
(@get('box_width') || 0 ) / (@get('dpm') || 1)
|
|
height: Ember.computed 'dpm', 'box_height', ->
|
|
(@get('box_height') || 0 ) / (@get('dpm') || 1)
|
|
|
|
# Rotation box size in [m]
|
|
box_size: Ember.computed 'dpm', 'box_height', 'box_width', ->
|
|
bw = @get('box_width')
|
|
bh = @get('box_height')
|
|
dpm = @get('dpm') ? 1
|
|
Math.sqrt( (bw * bw) + (bh * bh)) / dpm
|
|
|
|
copy_values: (similar_object)->
|
|
@set 'name', similar_object.get('name')
|
|
@set 'dpm', similar_object.get('dpm')
|
|
@set 'box_width', similar_object.get('box_width')
|
|
@set 'box_height', similar_object.get('box_height')
|
|
@set 'svg', similar_object.get('svg')
|