1、写在后面

之前,咱们曾经晓得 SkeyeARS 中怎么做到高下点摄像机关联显示了。

当初来看看具体的实现细节。

2、注释开始

首先,咱们曾经晓得相机是批量的。

简略来说,须要应用一个 Model 将相机数据包装起来。

当然,为了前面可能被合并,还要给数据加一些非凡的标记。

所以,我这里给每一个 table对象 增加 channel 数组,而后它的外面存储 合并后的相机数据

Item {    id: root        property var model: []        onModelChanged: {        let table = {}        for (let i = 0; i < model.length; i++) {            let channel = model[i].channel;            if (!table.hasOwnProperty(channel)) {                table[channel] = [];            }            table[channel].push(model[i]);        }        let result = [];        let keys = Object.keys(table);        for (let j = 0; j < keys.length; j++) {            result[j] = table[keys[j]];        }        correlationCameraView.model = result;    }        Repeater {        id: correlationCameraView        ......    }}

当初 correlationCameraView.model 曾经是 合并后的相机数据了

那么接下来咱们只须要正确展现进去即可:

  • 这里我抉择应用 Repeater,因为比拟不便。
  • SkeyeARS 中的圆形小弹窗本质为 Popup,也就是说,未合并的相机会被实例化为多个 Popup
    Repeater {        id: correlationCameraView        anchors.fill: parent        delegate: Item {            ....            Popup {                id: expandRect            }        }    }
  • 而后对于合并的相机,即最开始的 channel 数组,咱们再次应用一个 Repeater 即可。
  • 接下面的 Popup
    ......    Popup {        id: expandRect        Repeater {            id: repeater            anchors.fill: parent            model: modelData            delegate: Item {                id: rootItem                width: 30                height: width                transform: Rotation {                    angle: rootItem.angle                    origin.x : repeater.width / 2                    origin.y : repeater.height / 2                }                property real angle: (index * 360 / repeater.count) + 45                ......            }        }    }    ......

最初,咱们将 相机数据传入 root 即可:

    root.model = panoManager.currentPano.cameras;

最终 SkeyeARS 中的成果就是这样: