@@ -273,23 +273,21 @@ Pane {
273273 // Spacer
274274 Item { Layout .fillWidth : true }
275275
276- // Shape
276+ // Right toolbar
277277 RowLayout {
278278 spacing: 0
279279
280- // Shape create observation
280+ // Shape not keyable, set/remove observation
281281 Loader {
282- active: isShape
282+ active: isShape && isAttribute && ! model . shapeKeyable
283283 sourceComponent: MaterialToolButton {
284284 font .pointSize : 11
285285 padding: 2
286- text: (! model .shapeKeyable || ! isAttributeInitialized) ? MaterialIcons .edit : MaterialIcons .noise_control_off
287- checkable: model .shapeKeyable
288- checked: model .shapeKeyable ? hasShapeObservation : false
289- visible: (model .shapeKeyable || (isAttributeEnabled && ! isAttributeInitialized))
286+ text: isAttributeInitialized ? MaterialIcons .clear : MaterialIcons .edit
287+ checkable: false
290288 enabled: isAttributeEnabled
291289 onClicked: {
292- if (model . shapeKeyable && hasShapeObservation )
290+ if (isAttributeInitialized )
293291 {
294292 // remove key
295293 _reconstruction .removeObservation (model, _reconstruction .selectedViewId )
@@ -301,7 +299,88 @@ Pane {
301299 _reconstruction .setObservation (model, _reconstruction .selectedViewId , ShapeViewerHelper .getDefaultObservation (model .type ))
302300 ShapeViewerHelper .selectedShapeName = model .fullName
303301 }
302+ }
303+ }
304+ }
305+
306+ // Shape keyable, set/remove observation
307+ Loader {
308+ active: isShape && model .shapeKeyable
309+ sourceComponent: RowLayout {
310+ spacing: 0
311+
312+ function getViewPath (viewId ) {
313+ for (var i = 0 ; i < _reconstruction .viewpoints .count ; i++ )
314+ {
315+ var vp = _reconstruction .viewpoints .at (i)
316+ if (vp .childAttribute (" viewId" ).value == viewId)
317+ return vp .childAttribute (" path" ).value
318+ }
319+ return undefined
320+ }
321+
322+ function getPrevViewId (viewIds , currentViewId ) {
323+ const currentViewPath = getViewPath (currentViewId)
324+ const prevIds = viewIds .filter (viewId => getViewPath (viewId) < currentViewPath)
325+ if (prevIds .length === 0 )
326+ return " -1" ;
327+ prevIds .sort ((a , b ) => getViewPath (b).localeCompare (getViewPath (a)))
328+ return prevIds[0 ]
329+ }
330+
331+ function getNextViewId (viewIds , currentViewId ) {
332+ const currentViewPath = getViewPath (currentViewId)
333+ const nextIds = viewIds .filter (viewId => getViewPath (viewId) > currentViewPath)
334+ if (nextIds .length === 0 )
335+ return " -1" ;
336+ nextIds .sort ((a , b ) => getViewPath (a).localeCompare (getViewPath (b)))
337+ return nextIds[0 ]
338+ }
339+
340+ // Previous key
341+ MaterialToolButton {
342+ property string prevViewId: getPrevViewId (model .observationKeys , _reconstruction .selectedViewId )
343+ font .pointSize : 11
344+ padding: 2
345+ text: MaterialIcons .keyboard_arrow_left
346+ checkable: false
347+ enabled: prevViewId !== " -1"
348+ onClicked: { _reconstruction .selectedViewId = prevViewId }
349+ }
350+
351+ // Current key
352+ MaterialToolButton {
353+ font .pointSize : 11
354+ padding: 2
355+ text: MaterialIcons .noise_control_off
356+ checkable: model .shapeKeyable
357+ checked: model .shapeKeyable ? hasShapeObservation : false
358+ enabled: isAttributeEnabled
359+ onClicked: {
360+ if (hasShapeObservation)
361+ {
362+ // remove key
363+ _reconstruction .removeObservation (model, _reconstruction .selectedViewId )
364+ ShapeViewerHelper .selectedShapeName = " "
365+ }
366+ else
367+ {
368+ // add key
369+ _reconstruction .setObservation (model, _reconstruction .selectedViewId , ShapeViewerHelper .getDefaultObservation (model .type ))
370+ ShapeViewerHelper .selectedShapeName = model .fullName
371+ }
372+ }
373+ }
304374
375+ // Next key
376+ MaterialToolButton {
377+ property string nextViewId: getNextViewId (model .observationKeys , _reconstruction .selectedViewId )
378+ font .pointSize : 11
379+ padding: 2
380+ text: MaterialIcons .keyboard_arrow_right
381+ checkable: false
382+ enabled: nextViewId !== " -1"
383+ onClicked: { _reconstruction .selectedViewId = nextViewId }
305384 }
306385 }
307386 }
0 commit comments