3 #include "PointMeasureTreeModel.h" 8 #include <QFutureWatcher> 11 #include <QtConcurrentMap> 17 #include "TreeViewContent.h" 18 #include "PointParentItem.h" 19 #include "MeasureLeafItem.h" 27 PointMeasureTreeModel::PointMeasureTreeModel(ControlNet *controlNet,
29 AbstractTreeModel(controlNet, v, parent) {
34 PointMeasureTreeModel::~PointMeasureTreeModel() {
38 PointMeasureTreeModel::CreateRootItemFunctor::CreateRootItemFunctor(
39 AbstractTreeModel *tm,
QThread *tt) {
42 m_avgCharWidth = QFontMetrics(
43 m_treeModel->getView()->getContentFont()).averageCharWidth();
47 PointMeasureTreeModel::CreateRootItemFunctor::CreateRootItemFunctor(
48 const CreateRootItemFunctor &other) {
49 m_treeModel = other.m_treeModel;
50 m_targetThread = other.m_targetThread;
51 m_avgCharWidth = other.m_avgCharWidth;
54 PointMeasureTreeModel::CreateRootItemFunctor::~CreateRootItemFunctor() {
59 PointParentItem *PointMeasureTreeModel::CreateRootItemFunctor::operator()(
60 ControlPoint *
const &point)
const {
61 PointParentItem *pointItem =
new PointParentItem(point, m_avgCharWidth);
62 pointItem->moveToThread(m_targetThread);
64 for (
int j = 0; j < point->GetNumMeasures(); j++) {
65 const ControlMeasure *measure = point->GetMeasure(j);
68 MeasureLeafItem *measureItem =
new MeasureLeafItem(
69 const_cast< ControlMeasure * >(measure), m_avgCharWidth, pointItem);
70 measureItem->moveToThread(m_targetThread);
72 pointItem->addChild(measureItem);
79 void PointMeasureTreeModel::CreateRootItemFunctor::addToRootItem(
83 if (root.testAndSetOrdered(NULL,
new RootItem)) {
84 root.loadAcquire()->moveToThread(item->thread());
88 root.loadAcquire()->addChild(item);
92 PointMeasureTreeModel::CreateRootItemFunctor &
93 PointMeasureTreeModel::CreateRootItemFunctor::operator=(
94 const CreateRootItemFunctor &other) {
96 m_treeModel = other.m_treeModel;
97 m_avgCharWidth = other.m_avgCharWidth;
103 void PointMeasureTreeModel::rebuildItems() {
108 QFuture< QAtomicPointer< RootItem > > futureRoot;
109 if (getRebuildWatcher()->isStarted()) {
110 futureRoot = getRebuildWatcher()->future();
114 ASSERT(getControlNetwork());
115 futureRoot = QtConcurrent::mappedReduced(
116 getControlNetwork()->GetPoints(),
117 CreateRootItemFunctor(
this, QThread::currentThread()),
118 &CreateRootItemFunctor::addToRootItem,
119 QtConcurrent::OrderedReduce | QtConcurrent::SequentialReduce);
121 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.