diff --git a/includes/AnnotationHandler.php b/includes/AnnotationHandler.php index 45c05d2..165b3c4 100644 --- a/includes/AnnotationHandler.php +++ b/includes/AnnotationHandler.php @@ -127,9 +127,11 @@ class AnnotationHandler extends CodeContentHandler { 'style' => 'width: 100%; height: auto;' ); - + $elCompass = ''; + $useCompass = ''; if (isset($metadata['view'])) { $viewLabels = self::getCompassLabels($metadata['view']['direction'], $metadata['view']['rostral']); + /* $attrCompass = array( 'id' => "compass{$svgID}", 'viewBox' => '0 0 100 100', @@ -155,6 +157,38 @@ class AnnotationHandler extends CodeContentHandler { array_push($compass, Html::rawElement('path',$attrCompBkArrow)); array_push($compass,Html::closeElement('symbol')); + */ + $rotate = $metadata['view']['rotate'] ?? 0; + $textRotate = $rotate * -1; + $elCompass = << + + + + + {$viewLabels[0]} + {$viewLabels[1]} + {$viewLabels[2]} + {$viewLabels[3]} + {$viewLabels[4]} + + comp; + + //TODO: Right and Bottom and/or negative positioning + $compLeft = $metadata['view']['left'] ?? 0; + $compTop = $metadata['view']['top'] ?? 0; + $compRotX = $compLeft + (($metadata['view']['size'] ?? 25) * .5); + $compRotY = $compTop + (($metadata['view']['size'] ?? 25) * .5); + $attrCompass = array( + 'href'=> "#compass" . $svgID, + 'transform' => "scale( $fixScale ) rotate( $rotate $compRotX $compRotY)", + 'x' => $compLeft, + 'y' => $compTop, + 'width' => $metadata['view']['size'] ?? 25, + 'height' => $metadata['view']['size'] ?? 25, + 'style' => "transform-box: fill-box;" + ); + $useCompass = Html::rawElement('use', $attrCompass); } if (isset($metadata['annotation'])) { @@ -163,7 +197,7 @@ class AnnotationHandler extends CodeContentHandler { $leadLines = []; foreach($metadata['annotation'] as $label => $annot) { if (isset($annot['position'])) { - $marker = array(Html::openElement('g',array('transform' => "scale( {$fixScale} {$fixScale})"))); + $marker = array(Html::openElement('g',array('transform' => "scale( {$fixScale} )"))); $attrMask = array( 'cx' => $annot['position']['0'], 'cy' => $annot['position']['1'], @@ -215,7 +249,7 @@ class AnnotationHandler extends CodeContentHandler { $svgDefs = Html::rawElement('defs',array(),$markMask); } - return Html::rawElement('svg', $attrSvg, $svgDefs. implode($compass) . $elBaseImg . implode($annotations) ); + return Html::rawElement('svg', $attrSvg, $svgDefs. $elCompass . $elBaseImg . implode($annotations) . $useCompass ); } public function validateSave( Content $content, ValidationParams $validationParams ) {