3 #include "ImagePointTreeModel.h" 8 #include <QFutureWatcher> 10 #include <QModelIndex> 12 #include <QtConcurrentMap> 19 #include "TreeViewContent.h" 20 #include "PointLeafItem.h" 22 #include "ImageParentItem.h" 31 ImagePointTreeModel::ImagePointTreeModel(ControlNet *controlNet,
33 AbstractTreeModel(controlNet, v, parent) {
38 ImagePointTreeModel::~ImagePointTreeModel() {
42 ImagePointTreeModel::CreateRootItemFunctor::CreateRootItemFunctor(
43 AbstractTreeModel *tm, ControlNet *net,
QThread *tt) {
47 m_avgCharWidth = QFontMetrics(
48 m_treeModel->getView()->getContentFont()).averageCharWidth();
52 ImagePointTreeModel::CreateRootItemFunctor::CreateRootItemFunctor(
53 const CreateRootItemFunctor &other) {
54 m_treeModel = other.m_treeModel;
55 m_controlNet = other.m_controlNet;
56 m_targetThread = other.m_targetThread;
57 m_avgCharWidth = other.m_avgCharWidth;
61 ImagePointTreeModel::CreateRootItemFunctor::~CreateRootItemFunctor() {
62 m_targetThread = NULL;
68 ImageParentItem *ImagePointTreeModel::CreateRootItemFunctor::operator()(
69 QString imageSerial)
const {
70 ImageParentItem *imageItem = NULL;
74 imageItem =
new ImageParentItem(imageSerial, m_controlNet, m_avgCharWidth);
75 imageItem->setSelectable(
false);
76 imageItem->moveToThread(m_targetThread);
78 for (
int j = 0; j < measures.size(); j++) {
80 ControlPoint *point = measures[j]->Parent();
83 PointLeafItem *pointItem =
new PointLeafItem(
84 point, m_avgCharWidth, imageItem);
85 pointItem->setSelectable(
false);
86 pointItem->moveToThread(m_targetThread);
88 imageItem->addChild(pointItem);
95 void ImagePointTreeModel::CreateRootItemFunctor::addToRootItem(
99 if (root.testAndSetOrdered(NULL,
new RootItem)) {
100 root.loadAcquire()->moveToThread(item->thread());
104 root.loadAcquire()->addChild(item);
108 ImagePointTreeModel::CreateRootItemFunctor &
109 ImagePointTreeModel::CreateRootItemFunctor::operator=(
110 const CreateRootItemFunctor &other) {
111 if (
this != &other) {
112 m_treeModel = other.m_treeModel;
113 m_avgCharWidth = other.m_avgCharWidth;
120 void ImagePointTreeModel::rebuildItems() {
126 QFuture< QAtomicPointer< RootItem > > futureRoot;
127 if (getRebuildWatcher()->isStarted()) {
128 futureRoot = getRebuildWatcher()->future();
135 futureRoot = QtConcurrent::mappedReduced(
136 getControlNetwork()->GetCubeSerials(),
137 CreateRootItemFunctor(
this, getControlNetwork(), QThread::currentThread()),
138 &CreateRootItemFunctor::addToRootItem,
139 QtConcurrent::OrderedReduce | QtConcurrent::SequentialReduce);
141 getRebuildWatcher()->setFuture(futureRoot);
void filterCountsChanged(int visibleTopLevelItemCount, int topLevelItemCount)
This signal is emitted after filtering to provide the number of visible top-level items remaining aft...
Namespace for ISIS/Bullet specific routines.