From 73aca3a46eb2e705e1767989fff5ee3c2f370735 Mon Sep 17 00:00:00 2001
From: Xiao Gui <xgui3783@gmail.com>
Date: Fri, 22 Jul 2022 18:36:00 +0200
Subject: [PATCH] bugfix: status card reset nav exp: swc rendering

---
 docs/releases/v2.7.3.md                       |  2 ++
 .../nehubaViewerGlue.component.ts             | 27 ++++++++++++++++++-
 .../nehuba/statusCard/statusCard.component.ts |  9 +++----
 3 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/docs/releases/v2.7.3.md b/docs/releases/v2.7.3.md
index c87171421..ec24dc460 100644
--- a/docs/releases/v2.7.3.md
+++ b/docs/releases/v2.7.3.md
@@ -4,8 +4,10 @@
 
 - fixed matomo visitor counting (broke since 2.7.0 release)
 - fixed sane url generation
+- fixed reset navigation buttons in navigation card
 
 ## Under the hood
 
 - minor refactor of unused code
 - added mirrors to siibra-api
+- experimental support for drag and drop swc
diff --git a/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.component.ts b/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.component.ts
index 0c7b084eb..fea191126 100644
--- a/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.component.ts
+++ b/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.component.ts
@@ -284,8 +284,33 @@ export class NehubaGlueCmp implements IViewer<'nehuba'>, OnDestroy, AfterViewIni
     /**
      * TODO check extension?
      */
-     
     this.dismissAllAddedLayers()
+
+    if (/\.swc$/i.test(file.name)) {
+      const url = URL.createObjectURL(file)
+      this.droppedLayerNames.push({
+        layerName: randomUuid,
+        resourceUrl: url
+      })
+      this.store$.dispatch(
+        atlasAppearance.actions.addCustomLayer({
+          customLayer: {
+            id: randomUuid,
+            source: `swc://${url}`,
+            segments: ["1"],
+            transform: [
+              [1e3, 0, 0, 0],
+              [0, 1e3, 0, 0],
+              [0, 0, 1e3, 0],
+              [0, 0, 0, 1],
+            ],
+            clType: 'customlayer/nglayer' as const
+          }
+        })
+      )
+      return
+    }
+     
     
     // Get file, try to inflate, if files, use original array buffer
     const buf = await file.arrayBuffer()
diff --git a/src/viewerModule/nehuba/statusCard/statusCard.component.ts b/src/viewerModule/nehuba/statusCard/statusCard.component.ts
index 26d6786e8..58bbdf911 100644
--- a/src/viewerModule/nehuba/statusCard/statusCard.component.ts
+++ b/src/viewerModule/nehuba/statusCard/statusCard.component.ts
@@ -177,10 +177,7 @@ export class StatusCardComponent implements OnInit, OnChanges{
    */
   public resetNavigation({rotation: rotationFlag = false, position: positionFlag = false, zoom : zoomFlag = false}: {rotation?: boolean, position?: boolean, zoom?: boolean}): void {
     const config = getNehubaConfig(this.selectedTemplate)
-    const {
-      orientation,
-      position
-    } = config.dataset.initialNgState.navigation.pose
+
     const {
       zoomFactor: zoom
     } = config.dataset.initialNgState.navigation
@@ -189,8 +186,8 @@ export class StatusCardComponent implements OnInit, OnChanges{
       actions.navigateTo({
         navigation: {
           ...this.currentNavigation,
-          ...(rotationFlag ? { orientation: orientation } : {}),
-          ...(positionFlag ? { position: position } : {}),
+          ...(rotationFlag ? { orientation: [0, 0, 0, 1] } : {}),
+          ...(positionFlag ? { position: [0, 0, 0] } : {}),
           ...(zoomFlag ? { zoom: zoom } : {}),
         },
         physical: true,
-- 
GitLab