From 8b41f09ef2680885f65cffbe4f43ea7917a3685f Mon Sep 17 00:00:00 2001 From: Justin Georgi Date: Thu, 24 Oct 2024 21:09:53 -0700 Subject: [PATCH] Add annotation set functionality Signed-off-by: Justin Georgi --- includes/GlModelViewer.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/includes/GlModelViewer.php b/includes/GlModelViewer.php index 6a73aad..22f9e41 100644 --- a/includes/GlModelViewer.php +++ b/includes/GlModelViewer.php @@ -65,22 +65,35 @@ class GlModelViewer extends ImageHandler { if (isset($frameParams['class'])) { preg_match('/view-(\S*)/',$frameParams['class'],$viewClassExtract); $viewClass = ($viewClassExtract[1]) ? $viewClassExtract[1] : 'default'; + preg_match('/hsset-(\S*)/',$frameParams['class'],$hsSetClassExtract); + $hsSetClass = ($hsSetClassExtract[1]) ? $hsSetClassExtract[1] : 'default'; } else { $viewClass = 'default'; + $hsSetClass = 'default'; } if (isset($metadata['annotations'])) { $hotspots = []; - foreach($metadata['annotations'] as $idx => $an) { - $elAnnot = Html::rawElement('div',['class' => 'HotspotAnnotation HiddenAnnotation'],$an['label']); + $annotations = []; + if ($hsSetClass != 'default' && isset($metadata['annotationSets'])) { + foreach($metadata['annotationSets'][$hsSetClass] as $includeAn) { + if (isset($metadata['annotations'][$includeAn])) { + $annotations[$includeAn] = $metadata['annotations'][$includeAn]; + } + } + } else { + $annotations = $metadata['annotations']; + } + foreach($annotations as $label => $an) { + $elAnnot = Html::rawElement('div',['class' => 'HotspotAnnotation HiddenAnnotation'],$label); $hsDefault = array( 'class' => 'Hotspot', - 'slot' => 'hotspot-'.($idx +1), + 'slot' => 'hotspot-'.(count($hotspots) +1), 'onmousedown' => 'event.stopPropagation()', 'ontouchstart' => 'event.stopPropagation()', 'onclick' => 'onAnnotation(event)' ); $attrHotspot = array_merge($hsDefault, $an); - $elHotspot = Html::rawElement('button',$attrHotspot,$elAnnot.($idx +1)); + $elHotspot = Html::rawElement('button',$attrHotspot,$elAnnot.(count($hotspots) +1)); array_push($hotspots, $elHotspot); } }