Home Information - Your home, your data, organized.
Python
Added SvgItemFactory to better isolate SVG styling.
Anthony Cassandra7a897d271052
diff --git a/src/hi/apps/collection/edit/views.py b/src/hi/apps/collection/edit/views.pyindex eab61269..92bc0e09 100644--- a/src/hi/apps/collection/edit/views.py+++ b/src/hi/apps/collection/edit/views.py@@ -48,8 +48,9 @@ class CollectionDetailsView( View ):location = location_view.location,).first()if collection_position:- location_item_position_form = LocationItemPositionForm.from_svg_position_model(- collection_position,+ location_item_position_form = LocationItemPositionForm.from_models(+ location_item = collection_position.collection,+ location_item_position = collection_position,)context = {diff --git a/src/hi/apps/collection/enums.py b/src/hi/apps/collection/enums.pyindex f355506e..a689d42c 100644--- a/src/hi/apps/collection/enums.py+++ b/src/hi/apps/collection/enums.py@@ -1,5 +1,4 @@from hi.apps.common.enums import LabeledEnum-from hi.apps.common.svg_models import SvgPathStyle, SvgViewBoxclass CollectionType(LabeledEnum):@@ -35,42 +34,3 @@ class CollectionType(LabeledEnum):@propertydef is_icon(self):return bool( not self.is_path )-- @property- def svg_icon_bounding_box(self):- """- This defines the bounding box or extents of the SVG drawing commands,- which we need in order to properly position, rotate and scale the icon.- We need to be ab le to comute the center, since the adjustable location- is defining the center point of the icon.- """- # TODO: Change this after creating initial icons- return SvgViewBox( x = 0, y = 0, width = 32, height = 32 )-- @property- def svg_icon_template_name(self):- """- A template containing SVG drawing commands for the icon. It should not- contain the <svg> tag as this template will be inserted as part of- the basr location SVG. This file can be one or more SVG drawing- commands. A <g> tag will be automatically provided to wrap the- content os this since that <g> wrapper also need to define the SVG- transformations needed to properly position, scale and rotate the- icon. For entities with states, this should also use the "hi-state"- attribute in order to adjust its appearance (via CSS) based on its- state.- """- # TODO: Change this after creating initial icons- #- # return f'templates/entity/svg/type.{self.name.lower()}.svg'- return 'entity/svg/type.other.svg'-- @property- def svg_path_style(self):- # TODO: Change this to be based on type- return SvgPathStyle(- stroke_color = '#40f040',- stroke_width = 5.0,- fill_color = 'none',- )-diff --git a/src/hi/apps/collection/models.py b/src/hi/apps/collection/models.pyindex dadec95a..c752937e 100644--- a/src/hi/apps/collection/models.py+++ b/src/hi/apps/collection/models.py@@ -1,6 +1,5 @@from django.db import models-from hi.apps.common.svg_models import SvgIconItem, SvgPathItemfrom hi.apps.entity.models import Entityfrom hi.apps.location.models import (Location,@@ -10,12 +9,11 @@ from hi.apps.location.models import (LocationView,)from hi.enums import ItemType-from hi.models import ItemTypeModelMixinfrom .enums import CollectionType-class Collection( models.Model, ItemTypeModelMixin, LocationItemModelMixin ):+class Collection( models.Model, LocationItemModelMixin ):name = models.CharField('Name',@@ -118,18 +116,10 @@ class CollectionPosition( LocationItemPositionModel ):name = 'collection_position_location_entity',),]-+@property- def svg_icon_item(self) -> SvgIconItem:- return SvgIconItem(- html_id = f'hi-collection-{self.collection.id}',- template_name = self.collection.collection_type.svg_icon_template_name,- position_x = float( self.svg_x ),- position_y = float( self.svg_y ),- bounding_box = self.collection.collection_type.svg_icon_bounding_box,- rotate = float( self.svg_rotate ),- scale = float( self.svg_scale ),- )+ def location_item(self) -> LocationItemModelMixin:+ return self.collectionclass CollectionPath( LocationItemPathModel ):@@ -169,14 +159,10 @@ class CollectionPath( LocationItemPathModel ):fields = [ 'location', 'collection' ],name = 'collection_path_location_collection', ),]-+@property- def svg_path_item(self) -> SvgPathItem:- return SvgPathItem(- html_id = f'hi-collection-{self.collection.id}',- svg_path = self.svg_path,- path_style = self.collection.collection_type.svg_path_style,- )+ def location_item(self) -> LocationItemModelMixin:+ return self.collectionclass CollectionView(models.Model):diff --git a/src/hi/apps/common/svg_models.py b/src/hi/apps/common/svg_models.pyindex 55f86e9b..d043513e 100644--- a/src/hi/apps/common/svg_models.py+++ b/src/hi/apps/common/svg_models.py@@ -53,20 +53,6 @@ class SvgViewBox:}-@dataclass-class SvgPathStyle:- stroke_color : str- stroke_width : float- fill_color : str-- def to_dict(self):- return {- 'stroke_color': self.stroke_color,- 'stroke_width': self.stroke_width,- 'fill_color': self.fill_color,- }--@dataclassclass SvgIconItem:"""@@ -74,20 +60,35 @@ class SvgIconItem:icon is defined as a sequence of drawing commands stored in a templatefile. The shape that the icon drawing commands define can betransformed to scale, roate and change its position as provided.- """- # The SVG Transformations needed to move, scale and rotate SVG- # fragments are tricky and inconsistent.- #- # - Scaling changes the coordinate system.- # - Translation does not dirrectly move the item, but insteadmodifies- # the coordinate systems zero point.- # - Scaling has to be accounted for in the translation cooridinates.- # - Translation does not affect the rotate center point.- # - Scaling does not affect the rotate center point- # - Thus, though the transformation order matters, things that- # come before can impact things that come after.- # - Scaling does not always have to be taken into account.+ The template contains SVG drawing commands for the icon. It should not+ contain the <svg> tag as this template will be inserted as part of+ the base location SVG. This file can be one or more SVG drawing+ commands. A <g> tag will be automatically provided to wrap the+ content os this since that <g> wrapper also need to define the SVG+ transformations needed to properly position, scale and rotate the+ icon. For entities with states, this should also use the "hi-state"+ attribute in order to adjust its appearance (via CSS) based on its+ state.++ The bounding box or extents of the SVG drawing commands, is needed+ in order to properly position, rotate and scale the icon. We need to+ be able to compute the center, since the adjustable icon location is+ defining the center point of the icon.++ The SVG Transformations needed to move, scale and rotate SVG+ fragments are tricky and inconsistent.++ - Scaling changes the coordinate system.+ - Translation does not dirrectly move the item, but insteadmodifies+ the coordinate systems zero point.+ - Scaling has to be accounted for in the translation cooridinates.+ - Translation does not affect the rotate center point.+ - Scaling does not affect the rotate center point+ - Thus, though the transformation order matters, things that+ come before can impact things that come after.+ - Scaling does not always have to be taken into account.+ """html_id : strtemplate_name : str@@ -127,11 +128,13 @@ class SvgIconItem:@dataclassclass SvgPathItem:"""- Encapsulates an item to be inserted in a base SVG file as a path. A path item is a- sequence of drawing commands defined in 'svg_path'.+ Encapsulates an item to be inserted in a base SVG file as a path. A+ path item is a sequence of drawing commands defined in 'svg_path'."""- html_id : str- svg_path : str- path_style : SvgPathStyle+ html_id : str+ svg_path : str+ stroke_color : str+ stroke_width : float+ fill_color : strdiff --git a/src/hi/apps/entity/edit/views.py b/src/hi/apps/entity/edit/views.pyindex ad23854e..18097643 100644--- a/src/hi/apps/entity/edit/views.py+++ b/src/hi/apps/entity/edit/views.py@@ -45,8 +45,9 @@ class EntityDetailsView( View ):location = location_view.location,).first()if entity_position:- location_item_position_form = LocationItemPositionForm.from_svg_position_model(- entity_position,+ location_item_position_form = LocationItemPositionForm.from_models(+ location_item = entity_position.entity,+ location_item_position = entity_position,)context = {diff --git a/src/hi/apps/entity/enums.py b/src/hi/apps/entity/enums.pyindex 6eb9dcca..09493315 100644--- a/src/hi/apps/entity/enums.py+++ b/src/hi/apps/entity/enums.py@@ -1,5 +1,4 @@from hi.apps.common.enums import LabeledEnum-from hi.apps.common.svg_models import SvgPathStyle, SvgViewBoxclass EntityType(LabeledEnum):@@ -81,45 +80,7 @@ class EntityType(LabeledEnum):@propertydef is_icon(self):return bool( not self.is_path )-- @property- def svg_icon_bounding_box(self):- """- This defines the bounding box or extents of the SVG drawing commands,- which we need in order to properly position, rotate and scale the icon.- We need to be ab le to comute the center, since the adjustable location- is defining the center point of the icon.- """- # TODO: Change this after creating initial icons- return SvgViewBox( x = 0, y = 0, width = 32, height = 32 )-- @property- def svg_icon_template_name(self):- """- A template containing SVG drawing commands for the icon. It should not- contain the <svg> tag as this template will be inserted as part of- the basr location SVG. This file can be one or more SVG drawing- commands. A <g> tag will be automatically provided to wrap the- content os this since that <g> wrapper also need to define the SVG- transformations needed to properly position, scale and rotate the- icon. For entities with states, this should also use the "hi-state"- attribute in order to adjust its appearance (via CSS) based on its- state.- """- # TODO: Change this after creating initial icons- #- # return f'templates/entity/svg/type.{self.name.lower()}.svg'- return 'entity/svg/type.other.svg'-- @property- def svg_path_style(self):- # TODO: Change this to be based on type- return SvgPathStyle(- stroke_color = '#40f040',- stroke_width = 5.0,- fill_color = 'none',- )-+class EntityStateType(LabeledEnum):diff --git a/src/hi/apps/entity/models.py b/src/hi/apps/entity/models.pyindex 0762b1a9..b0fd631b 100644--- a/src/hi/apps/entity/models.py+++ b/src/hi/apps/entity/models.py@@ -1,6 +1,5 @@from django.db import models-from hi.apps.common.svg_models import SvgIconItem, SvgPathItemfrom hi.apps.location.models import (Location,LocationItemModelMixin,@@ -10,7 +9,6 @@ from hi.apps.location.models import ()from hi.integrations.core.models import IntegrationIdModelfrom hi.enums import ItemType-from hi.models import ItemTypeModelMixinfrom .enums import (EntityType,@@ -20,7 +18,7 @@ from .enums import ()-class Entity( IntegrationIdModel, ItemTypeModelMixin, LocationItemModelMixin ):+class Entity( IntegrationIdModel, LocationItemModelMixin ):"""- A physical feature, device or software artifact.- May have a fixed physical location (or can just be part of a collection)@@ -334,20 +332,12 @@ class EntityPosition( LocationItemPositionModel ):name = 'entity_position_location_entity',),]-- @property- def svg_icon_item(self) -> SvgIconItem:- return SvgIconItem(- html_id = f'hi-entity-{self.entity.id}',- template_name = self.entity.entity_type.svg_icon_template_name,- position_x = float( self.svg_x ),- position_y = float( self.svg_y ),- bounding_box = self.entity.entity_type.svg_icon_bounding_box,- rotate = float( self.svg_rotate ),- scale = float( self.svg_scale ),- )+ @property+ def location_item(self) -> LocationItemModelMixin:+ return self.entity+class EntityPath( LocationItemPathModel ):"""- For entities represented by an arbitary SVG path. e.g., The path of a utility line,@@ -385,14 +375,10 @@ class EntityPath( LocationItemPathModel ):fields = [ 'location', 'entity' ],name = 'entity_path_location_entity', ),]-+@property- def svg_path_item(self) -> SvgPathItem:- return SvgPathItem(- html_id = f'hi-entity-{self.entity.id}',- svg_path = self.svg_path,- path_style = self.entity.entity_type.svg_path_style,- )+ def location_item(self) -> LocationItemModelMixin:+ return self.entityclass EntityView(models.Model):diff --git a/src/hi/apps/location/edit/views.py b/src/hi/apps/location/edit/views.pyindex 7cbf10eb..3ded929d 100644--- a/src/hi/apps/location/edit/views.py+++ b/src/hi/apps/location/edit/views.py@@ -19,6 +19,7 @@ from hi.apps.entity.models import Entityfrom hi.apps.location.forms import LocationItemPositionFormfrom hi.apps.location.location_view_manager import LocationViewManagerfrom hi.apps.location.models import LocationView+from hi.apps.location.svg_item_factory import SvgItemFactoryfrom hi.decorators import edit_requiredfrom hi.enums import ItemType, ViewTypefrom hi.hi_grid_view import HiGridView@@ -362,12 +363,12 @@ class LocationItemPositionView( View ):location_view = request.view_parameters.location_viewif item_type == ItemType.ENTITY:- svg_position_model = EntityManager().get_entity_position(+ location_item_position_model = EntityManager().get_entity_position(entity_id = item_id,location = location_view.location,)elif item_type == ItemType.COLLECTION:- svg_position_model = CollectionManager().get_collection_position(+ location_item_position_model = CollectionManager().get_collection_position(collection_id = item_id,location = location_view.location,)@@ -376,13 +377,17 @@ class LocationItemPositionView( View ):location_item_position_form = LocationItemPositionForm(request.POST,- item_html_id = svg_position_model.svg_icon_item.html_id,+ item_html_id = location_item_position_model.location_item.html_id,)if location_item_position_form.is_valid():- location_item_position_form.to_svg_position_model( svg_position_model )- svg_position_model.save()+ location_item_position_form.to_location_item_position_model( location_item_position_model )+ location_item_position_model.save()- svg_icon_item = svg_position_model.svg_icon_item+ svg_icon_item = SvgItemFactory().create_svg_icon_item(+ item = location_item_position_model.location_item,+ position = location_item_position_model,+ )+context = {'location_item_position_form': location_item_position_form,}diff --git a/src/hi/apps/location/forms.py b/src/hi/apps/location/forms.pyindex 724c6db9..bd79f3cb 100644--- a/src/hi/apps/location/forms.py+++ b/src/hi/apps/location/forms.py@@ -2,7 +2,9 @@ from decimal import Decimalfrom django import forms-from .models import LocationItemPositionModel+from hi.enums import ItemType++from .models import LocationItemModelMixin, LocationItemPositionModelclass LocationItemPositionForm(forms.Form):@@ -38,30 +40,24 @@ class LocationItemPositionForm(forms.Form):return f'{self.item_html_id}-svg-position'@classmethod- def from_svg_position_model( cls, svg_position_model : LocationItemPositionModel ):- if svg_position_model:- return cls(- item_html_id = svg_position_model.svg_icon_item.html_id,- initial = {- 'svg_x': svg_position_model.svg_x,- 'svg_y': svg_position_model.svg_y,- 'svg_scale': svg_position_model.svg_scale,- 'svg_rotate': svg_position_model.svg_rotate,- },- )+ def from_models( cls,+ location_item : LocationItemModelMixin,+ location_item_position : LocationItemPositionModel ):return cls(- item_html_id = svg_position_model.svg_icon_item.html_id,+ item_html_id = location_item.html_id,initial = {- 'svg_scale': Decimal( 1.0 ),- 'svg_rotate': Decimal( 0.0 ),+ 'svg_x': location_item_position.svg_x,+ 'svg_y': location_item_position.svg_y,+ 'svg_scale': location_item_position.svg_scale,+ 'svg_rotate': location_item_position.svg_rotate,},)- def to_svg_position_model( self, svg_position_model : LocationItemPositionModel ):+ def to_location_item_position_model( self, location_item_position_model : LocationItemPositionModel ):cleaned_data = self.clean()- svg_position_model.svg_x = cleaned_data.get( 'svg_x' )- svg_position_model.svg_y = cleaned_data.get( 'svg_y' )- svg_position_model.svg_scale = cleaned_data.get( 'svg_scale' )- svg_position_model.svg_rotate = cleaned_data.get( 'svg_rotate' )+ location_item_position_model.svg_x = cleaned_data.get( 'svg_x' )+ location_item_position_model.svg_y = cleaned_data.get( 'svg_y' )+ location_item_position_model.svg_scale = cleaned_data.get( 'svg_scale' )+ location_item_position_model.svg_rotate = cleaned_data.get( 'svg_rotate' )returndiff --git a/src/hi/apps/location/location_view_data.py b/src/hi/apps/location/location_view_data.pyindex 057efc23..ccbe5d70 100644--- a/src/hi/apps/location/location_view_data.py+++ b/src/hi/apps/location/location_view_data.py@@ -2,11 +2,9 @@ from dataclasses import dataclassfrom typing import Generator, List, Setfrom hi.apps.collection.models import Collection, CollectionPath, CollectionPosition+from hi.apps.common.svg_models import SvgIconItem, SvgPathItemfrom hi.apps.entity.models import Entity, EntityPosition, EntityPath-from hi.apps.location.models import (- LocationItemPositionModel,- LocationItemPathModel,-)+from hi.apps.location.svg_item_factory import SvgItemFactoryfrom .models import LocationView@@ -26,22 +24,40 @@ class LocationViewData:orphan_entities : Set[ Entity ]@property- def location_item_positions(self) -> Generator[ LocationItemPositionModel, None, None ]:+ def svg_icon_items(self) -> Generator[ SvgIconItem, None, None ]:+ svg_item_factory = SvgItemFactory()for entity_position in self.entity_positions:- yield entity_position+ svg_icon_item = svg_item_factory.create_svg_icon_item(+ item = entity_position.entity,+ position = entity_position,+ )+ yield svg_icon_itemcontinuefor collection_position in self.collection_positions:- yield collection_position+ svg_icon_item = svg_item_factory.create_svg_icon_item(+ item = collection_position.collection,+ position = collection_position,+ )+ yield svg_icon_itemcontinuereturn@property- def location_item_paths(self) -> Generator[ LocationItemPathModel, None, None ]:+ def svg_path_items(self) -> Generator[ SvgPathItem, None, None ]:+ svg_item_factory = SvgItemFactory()for entity_path in self.entity_paths:- yield entity_path+ svg_path_item = svg_item_factory.create_svg_path_item(+ item = entity_path.entity,+ path = entity_path,+ )+ yield svg_path_itemcontinuefor collection_path in self.collection_paths:- yield collection_path+ svg_path_item = svg_item_factory.create_svg_path_item(+ item = collection_path.collection,+ path = collection_path,+ )+ yield svg_path_itemcontinuereturndiff --git a/src/hi/apps/location/models.py b/src/hi/apps/location/models.pyindex c9b8cada..100ba660 100644--- a/src/hi/apps/location/models.py+++ b/src/hi/apps/location/models.py@@ -153,7 +153,7 @@ class LocationView( models.Model, ItemTypeModelMixin ):return-class LocationItemModelMixin:+class LocationItemModelMixin( ItemTypeModelMixin ):# A Location Item is a model that can be associated with a Location# and that can visually appeay in one or more Location Views. This# defined an interface that specific instance need to conform to.@@ -193,10 +193,10 @@ class LocationItemPositionModel( models.Model ):)@property- def svg_icon_item(self) -> SvgIconItem:+ def location_item(self) -> LocationItemModelMixin:raise NotImplementedError('Subclasses must implement this method.')-+class LocationItemPathModel( models.Model ):"""For models that have a visual representaion that can be overlayed on@@ -212,5 +212,5 @@ class LocationItemPathModel( models.Model ):)@property- def svg_path_item(self) -> SvgPathItem:+ def location_item(self) -> LocationItemModelMixin:raise NotImplementedError('Subclasses must implement this method.')diff --git a/src/hi/apps/location/svg_item_factory.py b/src/hi/apps/location/svg_item_factory.pynew file mode 100644index 00000000..f5018547--- /dev/null+++ b/src/hi/apps/location/svg_item_factory.py@@ -0,0 +1,37 @@+from hi.apps.common.singleton import Singleton+from hi.apps.common.svg_models import SvgIconItem, SvgPathItem, SvgViewBox+from hi.apps.location.models import (+ LocationItemModelMixin,+ LocationItemPositionModel,+ LocationItemPathModel,+)+++class SvgItemFactory( Singleton ):++ def __init_singleton__(self):+ return++ def create_svg_icon_item( self,+ item : LocationItemModelMixin,+ position : LocationItemPositionModel ) -> SvgIconItem:+ return SvgIconItem(+ html_id = item.html_id,+ position_x = float( position.svg_x ),+ position_y = float( position.svg_y ),+ rotate = float( position.svg_rotate ),+ scale = float( position.svg_scale ),+ template_name = 'entity/svg/type.other.svg',+ bounding_box = SvgViewBox( x = 0, y = 0, width = 32, height = 32 ),+ )++ def create_svg_path_item( self,+ item : LocationItemModelMixin,+ path : LocationItemPathModel ) -> SvgPathItem:+ return SvgPathItem(+ html_id = item.html_id,+ svg_path = path.svg_path,+ stroke_color = '#40f040',+ stroke_width = 5.0,+ fill_color = 'none',+ )diff --git a/src/hi/apps/location/templates/location/location_view.html b/src/hi/apps/location/templates/location/location_view.htmlindex eb9aedf8..145c5a1d 100644--- a/src/hi/apps/location/templates/location/location_view.html+++ b/src/hi/apps/location/templates/location/location_view.html@@ -10,12 +10,12 @@transform="rotate({{ location_view_data.location_view.svg_rotate }} 0 0)">{% include_media_template location_view_data.location_view.location.svg_filename %}- {% for location_item_path in location_view_data.location_item_paths %}- {% include "location/svg_path_item.html" with svg_path_item=location_item_path.svg_path_item %}+ {% for svg_path_item in location_view_data.svg_path_items %}+ {% include "location/svg_path_item.html" with svg_path_item=svg_path_item %}{% endfor %}- {% for location_item_position in location_view_data.location_item_positions %}- {% include "location/svg_icon_item.html" with svg_icon_item=location_item_position.svg_icon_item %}+ {% for svg_icon_item in location_view_data.svg_icon_items %}+ {% include "location/svg_icon_item.html" with svg_icon_item=svg_icon_item %}{% endfor %}</svg>diff --git a/src/hi/apps/location/templates/location/svg_path_item.html b/src/hi/apps/location/templates/location/svg_path_item.htmlindex 53836245..04aba4ba 100644--- a/src/hi/apps/location/templates/location/svg_path_item.html+++ b/src/hi/apps/location/templates/location/svg_path_item.html@@ -1,7 +1,7 @@<g id="{{ svg_path_item.html_id }}" class="selectable" data-type="svg-path">- <path fill="{{ svg_path_item.path_style.fill_color }}"- stroke="{{ svg_path_item.path_style.stroke_color }}"- stroke-width="{{ svg_path_item.path_style.stroke_width }}"+ <path fill="{{ svg_path_item.fill_color }}"+ stroke="{{ svg_path_item.stroke_color }}"+ stroke-width="{{ svg_path_item.stroke_width }}"vector-effect="non-scaling-stroke"d="{{ svg_path_item.svg_path }}"></path></g>diff --git a/src/hi/enums.py b/src/hi/enums.pyindex 22ecdec4..2f177fe9 100644--- a/src/hi/enums.py+++ b/src/hi/enums.py@@ -63,7 +63,7 @@ class ItemType(LabeledEnum):def html_id( self, item_id : int ):return f'hi-{self}-{item_id}'-+@classmethoddef parse_html_id( self, html_id_str : str ) -> Tuple[ 'ItemType', int ]:m = re.match( r'^hi-([\w\-]+)-(\d+)$', html_id_str )diff --git a/src/hi/static/js/edit-svg-icon.js b/src/hi/static/js/edit-svg-icon.jsindex 4250077d..2d72bb6c 100644--- a/src/hi/static/js/edit-svg-icon.js+++ b/src/hi/static/js/edit-svg-icon.js@@ -40,7 +40,7 @@const CURSOR_MOVEMENT_THRESHOLD_PIXELS = 3; // Differentiate between move events and sloppy clicksconst ZOOM_SCALE_FACTOR_PERCENT = 10.0;- const API_EDIT_SVG_POSITION_URL = '/location/edit/location-item/position';+ const API_EDIT_LOCATION_ITEM_POSITION_URL = '/location/edit/location-item/position';const SvgActionStateType = {MOVE: 'move',@@ -213,65 +213,57 @@}function handleKeyDown( event ) {- if ( $(event.target).is('input[type="text"], textarea') ) {+ if ( $(event.target).is('input, textarea') ) {return;}if ( gSelectedIconSvgGroup ) {- if ( Hi.DEBUG ) { console.log( `Key Down [${MODULE_NAME}]`, event ); }- handleSvgIconSelectedKeyDown( event );- event.preventDefault();- event.stopImmediatePropagation();- return;+ const targetArea = $(Hi.LOCATION_VIEW_AREA_SELECTOR);+ const targetOffset = targetArea.offset();+ const targetWidth = targetArea.outerWidth();+ const targetHeight = targetArea.outerHeight();++ if (( gLastMousePosition.x >= targetOffset.left )+ && ( gLastMousePosition.x <= ( targetOffset.left + targetWidth ))+ && ( gLastMousePosition.y >= targetOffset.top )+ && ( gLastMousePosition.y <= ( targetOffset.top + targetHeight ))) {++ if ( Hi.DEBUG ) { console.log( `Key Down [${MODULE_NAME}]`, event ); }++ if ( event.key == ICON_ACTION_SCALE_KEY ) {+ iconActionRotateAbort();+ iconActionScaleStart();++ } else if ( event.key == ICON_ACTION_ROTATE_KEY ) {+ iconActionScaleAbort();+ iconActionRotateStart();++ } else if ( event.key == ICON_ACTION_ZOOM_IN_KEY ) {+ iconActionScaleAbort();+ iconActionRotateAbort();+ iconActionZoomIn();++ } else if ( event.key == ICON_ACTION_ZOOM_OUT_KEY ) {+ iconActionScaleAbort();+ iconActionRotateAbort();+ iconActionZoomOut();++ } else if ( event.key == 'Escape' ) {+ iconActionScaleAbort();+ iconActionRotateAbort();+ gSvgIconActionState = SvgActionStateType.MOVE;+ $(Hi.BASE_SVG_SELECTOR).attr( Hi.SVG_ACTION_STATE_ATTR_NAME, '');++ } else {+ return;+ }++ event.preventDefault();+ event.stopImmediatePropagation();+ }}if ( Hi.DEBUG ) { console.log( `Key down skipped [${MODULE_NAME}]` ); }}- function handleSvgIconSelectedKeyDown( event ) {- const targetArea = $(Hi.LOCATION_VIEW_AREA_SELECTOR);- const targetOffset = targetArea.offset();- const targetWidth = targetArea.outerWidth();- const targetHeight = targetArea.outerHeight();-- if (( gLastMousePosition.x >= targetOffset.left )- && ( gLastMousePosition.x <= ( targetOffset.left + targetWidth ))- && ( gLastMousePosition.y >= targetOffset.top )- && ( gLastMousePosition.y <= ( targetOffset.top + targetHeight ))) {-- if ( Hi.DEBUG ) { Hi.displayEventInfo( 'Key Down', event ); }-- if ( event.key == ICON_ACTION_SCALE_KEY ) {- iconActionRotateAbort();- iconActionScaleStart();-- } else if ( event.key == ICON_ACTION_ROTATE_KEY ) {- iconActionScaleAbort();- iconActionRotateStart();-- } else if ( event.key == ICON_ACTION_ZOOM_IN_KEY ) {- iconActionScaleAbort();- iconActionRotateAbort();- iconActionZoomIn();-- } else if ( event.key == ICON_ACTION_ZOOM_OUT_KEY ) {- iconActionScaleAbort();- iconActionRotateAbort();- iconActionZoomOut();-- } else if ( event.key == 'Escape' ) {- iconActionScaleAbort();- iconActionRotateAbort();- gSvgIconActionState = SvgActionStateType.MOVE;- $(Hi.BASE_SVG_SELECTOR).attr( Hi.SVG_ACTION_STATE_ATTR_NAME, '');-- } else {- return;- }-- event.preventDefault();- event.stopImmediatePropagation();- }- }-function handleSvgIconClick( event, enclosingSvgGroup ) {const svgItemId = $(enclosingSvgGroup).attr('id');clearSelectedIconSvgGroup();@@ -376,7 +368,7 @@svg_scale: gSvgIconDragData.originalSvgScale.x,svg_rotate: gSvgIconDragData.originalSvgRotate.angle};- AN.post( `${API_EDIT_SVG_POSITION_URL}/${svgItemId}`, data );+ AN.post( `${API_EDIT_LOCATION_ITEM_POSITION_URL}/${svgItemId}`, data );gSvgIconDragData = null;}@@ -396,7 +388,7 @@svg_scale: scale.x,svg_rotate: rotate.angle,};- AN.post( `${API_EDIT_SVG_POSITION_URL}/${svgItemId}`, data );+ AN.post( `${API_EDIT_LOCATION_ITEM_POSITION_URL}/${svgItemId}`, data );}function createIconEditActionData( actionState ) {