void FiberSelector::updateBranch( int branch ) { //qDebug() << "update branch" << branch; int current = 0; bool neg = Models::r()->data( createIndex( branch, current, (int)Fn::ROI::NEG ), Qt::DisplayRole ).toBool(); if ( neg ) { for ( int k = 0; k < m_numLines; ++k ) { m_branchfields[branch][k] = !m_bitfields[branch][current][k]; } } else { for ( int k = 0; k < m_numLines; ++k ) { m_branchfields[branch][k] = m_bitfields[branch][current][k]; } } ++current; while ( current < m_bitfields[branch].size() ) { if ( Models::r()->data( createIndex( branch, current, (int)Fn::ROI::ACTIVE ), Qt::DisplayRole ).toBool() ) { bool neg = Models::r()->data( createIndex( branch, current, (int)Fn::ROI::NEG ), Qt::DisplayRole ).toBool(); if ( neg ) { for ( int k = 0; k < m_numLines; ++k ) { m_branchfields[branch][k] &= !m_bitfields[branch][current][k]; } } else { for ( int k = 0; k < m_numLines; ++k ) { m_branchfields[branch][k] &= m_bitfields[branch][current][k]; } } ++current; } else { ++current; } } updateRoot(); }
void FiberSelector::roiDeleted( const QModelIndex &parent, int start, int end ) { //qDebug() << "roi deleted" << parent.row() << start << end; if ( parent.row() == -1 ) { m_bitfields.removeAt( start ); m_branchfields.removeAt( start ); updateRoot(); } else { m_bitfields[parent.row()].removeAt( start + 1 ); updateBranch( parent.row() ); } }
virtual void targetAddedHandler(AbstractComponent::Ptr ctrl, NodePtr target) { if (targets().size() > 1) throw std::logic_error("This component cannot have more than 1 target."); auto cb = std::bind( &AbstractRootDataComponent::addedOrRemovedHandler, this->shared_from_this(), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3 ); _addedSlot = target->added()->connect(cb); _removedSlot = target->removed()->connect(cb); updateRoot(target->root()); }
virtual void addedOrRemovedHandler(NodePtr node, NodePtr target, NodePtr ancestor) { updateRoot(node->root()); }
virtual void targetRemovedHandler(AbstractComponent::Ptr ctrl, NodePtr target) { updateRoot(nullptr); }