Exemple #1
0
  void CellCursor::addBefore(Cell *newCell)
  {
    // 2006-04-27 AF,
    cursorIsMoved();

    if(parentCell()->child() == this)
    { //first in line.
      newCell->setParentCell(parentCell());
      newCell->setNext(this);
      newCell->setPrevious(0);
      parentCell()->setChild(newCell);
      setPrevious(newCell);
    }
    else
    {
      newCell->setParentCell(parentCell());
      newCell->setPrevious(previous());
      previous()->setNext(newCell);
      setPrevious(newCell);
      newCell->setNext(this);
    }

    parentCell()->addCellWidget(newCell);

    // TMP EMIT
    emit changedPosition();
  }
Exemple #2
0
  /*
  * \bug fel  om vi flyttas till att vara första barn..
  */
  void CellCursor::moveBefore(Cell *current)
  {
    // 2006-04-27 AF,
    cursorIsMoved();

    removeFromCurrentPosition();

    //Remove all widgets from currents parent.
    current->parentCell()->removeCellWidgets();

    //Move to new position.
    if(current->hasParentCell())
    {
      setParentCell(current->parentCell());
      if(!current->hasPrevious())
        current->parentCell()->setChild(this);
      else
        current->previous()->setNext(this);

    }
    else
      throw runtime_error("Could not insert before root");

    setPrevious(current->previous());
    current->setPrevious(this);
    setNext(current);

    //Insert widgets to parents layout.
    parentCell()->addCellWidgets();

    // TMP EMIT
    emit changedPosition();
    //      emit positionChanged(x(), y(), 5, 5);
  }
Exemple #3
0
size_t ReadsLayout::reverseComplement(size_t index) {
    
    if (getNext(index) != 0) {
        cout << "size_t ReadsLayout::reverseComplement(size_t index) problem\n";
        sendBugReportPlease(cerr);
    }

    unsigned int reversePos = getPosition(index) + 1;
    size_t pTmp;
    size_t previous;

    do {
        setDirection(index, !getDirection(index));
        setPosition(index, reversePos - getPosition(index));
        //swap links
        pTmp = getNext(index);
        setNext(index, getPrevious(index));
        setPrevious(index, pTmp);
        previous = index;
        index = getNext(index);

    } while (index != 0);

    return previous;
}
Exemple #4
0
void Model::addSortedSegment(SegmentModel* m)
{
  insertSegment(m);

  // Add points if necessary
  // If there is an existing previous segment, its end point also exists
  auto createStartPoint = [&]() {
    auto pt = new PointModel{getStrongId(m_points), this};
    pt->setFollowing(m->id());
    pt->setPos(m->start());
    addPoint(pt);
    return pt;
  };
  auto createEndPoint = [&]() {
    auto pt = new PointModel{getStrongId(m_points), this};
    pt->setPrevious(m->id());
    pt->setPos(m->end());
    addPoint(pt);
    return pt;
  };

  if (!m->previous())
  {
    createStartPoint();
  }
  else
  {
    // The previous segment has already been inserted,
    // hence the previous point is present.
    m_points.back()->setFollowing(m->id());
  }

  createEndPoint();
}
Exemple #5
0
  /*!
  * Removes a cell and all its subcells from the tree.
  *
  * This should work for all cells. But it will leave an empty
  * cellgroup if last cell is deleted in cellgroup.
  *
  * This does not delete the cell, it just removes the cell from the
  * celltree.
  */
  void CellCursor::removeCurrentCell()
  {
    if(hasPrevious()) //If cursor has previous
    {
      // 2006-04-27 AF,
      cursorIsMoved();

      Cell *current = previous();

      removeFromCurrentPosition();

      if(current->hasPrevious())
        current->previous()->setNext(this);
      else
        parentCell()->setChild(this);

      setPrevious(current->previous());

      current->setParentCell(0);
      current->setPrevious(0);
      current->setNext(0);
      current->setChild(0);
      current->setLast(0);

      current->hide();
      parentCell()->addCellWidgets();
    }
  }
void MqttBridge::received(const QMQTT::Message &message){
    //Now we have to pass on the different command to the DBUS command
    //That will be done by emitting signals, as we have no
    //knowlege of the dBus class, We will try to have a clean interface

    qDebug()<<"Message Topic and payload "<<message.topic() << message.payload();
    if      (message.topic()==mediaPlayCommand) emit setPlay();
    else if (message.topic()==mediaNextCommand) emit setNext();
    else if (message.topic()==mediaPrevCommand) emit setPrevious();
    else if (message.topic()==mediaVolumeCommand) {
        double volume = message.payload().toDouble()/100;
        emit setVolume(volume);
        }
    else if (message.topic()==mediaPlayIdCommand) {
     QDBusObjectPath _path;
     _path.setPath(message.payload());
     emit setPlayId(_path);
    }
    else if (message.topic()==mediaPlayPauseCommand) emit setPlayPause();
    else if (message.topic()==mediaRepeatCommand){
        if (message.payload()=="0") emit setLoop("None");
        else emit setLoop("Playlist");
    }
    else if (message.topic()==mediaMixCommand){
     if (message.payload()=="0") emit setShuffle(false);
     else emit setShuffle(true);
    }



}
Exemple #7
0
template <class Type> bool MyList<Type>::push(Type _element, const int &_position){
	if(id == _position){

		MyList<Type> *newElement = new MyList(_element);
		newElement->setID(id);
		newElement->setNext(this);
		newElement->setPrevious(previous);
		
//		std::cout<<"created\n";

		if(previous!=NULL){
			previous->setNext(newElement);
		}


		setPrevious(newElement);

//		std::cout<<"links set\n";

		this->changeID(id + 1);

//		std::cout<<"id changed\n";

		return true;
	}
	else{
		if(next != NULL){
			return next->push(_element, _position);
		}
		else{
			return false;
		}
	}
}
Exemple #8
0
void nLight::registerNode(nRenderer *r) {
	if(r->tailLight) {
		r->tailLight->setNext(this);
		setPrevious(r->tailLight);
	} else {
		r->frontLight = this;
	}
	r->tailLight = this;
	renderer = r;
}
void CurvePresenter::removeSelection()
{
    // We remove all that is selected,
    // And set the bounds correctly
    QSet<id_type<CurveSegmentModel>> segmentsToDelete;

    for(const auto& elt : m_model->selectedChildren())
    {
        if(auto point = dynamic_cast<const CurvePointModel*>(elt))
        {
            if(point->previous())
                segmentsToDelete.insert(point->previous());
            if(point->following())
                segmentsToDelete.insert(point->following());
        }

        if(auto segmt = dynamic_cast<const CurveSegmentModel*>(elt))
        {
            segmentsToDelete.insert(segmt->id());
        }
    }

    QVector<QByteArray> newSegments;
    newSegments.resize(m_model->segments().size() - segmentsToDelete.size());
    int i = 0;
    for(const CurveSegmentModel* segment : m_model->segments())
    {
        if(!segmentsToDelete.contains(segment->id()))
        {
            auto cp = segment->clone(segment->id(), nullptr);
            if(segment->previous() && !segmentsToDelete.contains(segment->previous()))
                cp->setPrevious(segment->previous());
            if(segment->following() && !segmentsToDelete.contains(segment->following()))
                cp->setFollowing(segment->following());

            Serializer<DataStream> s{&newSegments[i++]};
            s.readFrom(*cp);
        }
    }

    m_commandDispatcher.submitCommand(
                new UpdateCurve{
                    iscore::IDocument::path(m_model),
                    std::move(newSegments)
                });
}
Exemple #10
0
  /*!
  * \bug Fel vid flytt så cursor hamnar som sista barn.
  */
  void CellCursor::moveAfter(Cell *current)
  {
    // 2006-04-27 AF,
    cursorIsMoved();

    removeFromCurrentPosition();

    //if(!current->hasParentCell())
    //  throw runtime_error("Could not insert after root");

    if(current->hasParentCell())
    {
      current->parentCell()->removeCellWidgets();

      if(current->hasNext() == 0)
      {
        current->parentCell()->setLast(this);
      }
      else
        current->next()->setPrevious(this);

      setParentCell(current->parentCell());
      setNext(current->next());
      current->setNext(this);
      setPrevious(current);

      //insert widgets to parents layout.
      parentCell()->addCellWidgets();
    }
    else
    {
      //If current does not have a parent. That is current is not
      //in the celltree at all or that current is the root of the
      //tree. It should not be possible to move after the root of
      //the tree. Do nothing!
    }

    // TMP EMIT
    emit changedPosition();
    //      emit positionChanged(x(), y(), 5,5);
  }
void CurvePresenter::updateSegmentsType(const QString& segmentName)
{
    // They keep their start / end and previous / following but change type.
    // TODO maybe it would be better to encapsulate this ?
    auto factory = SingletonCurveSegmentList::instance().get(segmentName);

    QVector<QByteArray> newSegments;
    newSegments.resize(m_model->segments().size());
    int i = 0;
    for(CurveSegmentModel* segment : m_model->segments())
    {
        CurveSegmentModel* current;
        if(segment->selection.get())
        {
            auto ns = factory->make(segment->id(), nullptr);
            ns->setStart(segment->start());
            ns->setEnd(segment->end());
            ns->setPrevious(segment->previous());
            ns->setFollowing(segment->following());

            current = ns;
        }
        else
        {
            current = segment;
        }

        Serializer<DataStream> s{&newSegments[i++]};
        s.readFrom(*current);
    }

    m_commandDispatcher.submitCommand(
                new UpdateCurve{
                    iscore::IDocument::path(m_model),
                    std::move(newSegments)
                });
}
Exemple #12
0
void MergeNode::run(ExecutionNode* previous)
{
    if(nullptr == previous)
    {
        m_errors.insert(ExecutionNode::NO_PREVIOUS_ERROR, QObject::tr("No previous node before Merge operator"));
        return;
    }

    m_previousNode= previous;
    m_result->setPrevious(previous->getResult());
    ExecutionNode* previousLast= nullptr;
    std::vector<Result*> pastResult;
    for(auto start : *m_startList)
    {
        ExecutionNode* last= getLatestNode(start);
        if(nullptr != last)
        {
            if(nullptr != previousLast)
            {
                auto startResult= start->getResult();
                startResult->setPrevious(previousLast->getResult());
                previousLast->setNextNode(start);
            }
            previousLast= last;
            Result* tmpResult= last->getResult();
            while(nullptr != tmpResult)
            {
                DiceResult* dice= dynamic_cast<DiceResult*>(tmpResult);
                if(nullptr != dice)
                {
                    ///@todo TODO improve here to set homogeneous while is really
                    m_diceResult->setHomogeneous(false);
                    for(auto& die : dice->getResultList())
                    {
                        if(!m_diceResult->getResultList().contains(die) && (!die->hasBeenDisplayed()))
                        {
                            Die* tmpdie= new Die();
                            *tmpdie= *die;
                            die->displayed();
                            m_diceResult->getResultList().append(tmpdie);
                        }
                    }
                }
                auto it= std::find_if(pastResult.begin(), pastResult.end(),
                    [tmpResult](const Result* a) { return (a == tmpResult->getPrevious()); });
                if(it == pastResult.end())
                {
                    pastResult.push_back(previousLast->getResult());
                    tmpResult= tmpResult->getPrevious();
                }
                else
                {
                    tmpResult->setPrevious(nullptr);
                    tmpResult= nullptr;
                }
            }
        }
    }

    auto first= m_startList->front();
    m_startList->clear();
    m_startList->push_back(first);

    if(nullptr != m_nextNode)
    {
        m_nextNode->run(this);
    }
}
Exemple #13
0
void Model::addSegment(SegmentModel* m)
{
  insertSegment(m);

  // Add points if necessary
  // If there is an existing previous segment, its end point also exists
  auto createStartPoint = [&]() {
    auto pt = new PointModel{getStrongId(m_points), this};
    pt->setFollowing(m->id());
    pt->setPos(m->start());
    addPoint(pt);
    return pt;
  };
  auto createEndPoint = [&]() {
    auto pt = new PointModel{getStrongId(m_points), this};
    pt->setPrevious(m->id());
    pt->setPos(m->end());
    addPoint(pt);
    return pt;
  };

  if (m->previous())
  {
    auto previousSegment = std::find_if(
        m_segments.begin(), m_segments.end(), [&](const auto& seg) {
          return seg.following() == m->id();
        });
    if (previousSegment != m_segments.end())
    {
      auto thePt = std::find_if(
          m_points.begin(), m_points.end(), [&](PointModel* pt) {
            return pt->previous() == (*previousSegment).id();
          });

      if (thePt != m_points.end())
      {
        // The previous segments and points both exist
        (*thePt)->setFollowing(m->id());
      }
      else
      {
        // The previous segment exists but not the end point.
        auto pt = createStartPoint();
        pt->setPrevious((*previousSegment).id());
      }
    }
    else // The previous segment has not yet been added.
    {
      createStartPoint();
    }
  }
  else if (std::none_of(m_points.begin(), m_points.end(), [&](PointModel* pt) {
             return pt->following() == m->id();
           }))
  {
    createStartPoint();
  }

  if (m->following())
  {
    auto followingSegment = std::find_if(
        m_segments.begin(), m_segments.end(), [&](const auto& seg) {
          return seg.previous() == m->id();
        });
    if (followingSegment != m_segments.end())
    {
      auto thePt = std::find_if(
          m_points.begin(), m_points.end(), [&](PointModel* pt) {
            return pt->following() == (*followingSegment).id();
          });

      if (thePt != m_points.end())
      {
        (*thePt)->setPrevious(m->id());
      }
      else
      {
        auto pt = createEndPoint();
        pt->setFollowing((*followingSegment).id());
      }
    }
    else
    {
      createEndPoint();
    }
  }
  else if (std::none_of(m_points.begin(), m_points.end(), [&](PointModel* pt) {
             return pt->previous() == m->id();
           }))
  {
    // Note : if one day a buggy case happens here, check that set
    // following/previous
    // are correctly set after cloning the segment.
    createEndPoint();
  }
}
// release python objects
void FilterBase::release (void)
{
	// release previous filter object
	setPrevious(NULL);
}
Exemple #15
0
size_t ReadsLayout::merge(size_t l1, size_t l2, bool direct, int shift) {
    
    if (getNext(l1) != 0 || getNext(l2) != 0 || l1 == 0 || l2 == 0) {
        cout << "size_t ReadsLayout::merge(size_t l1, size_t l2, bool direct, int shift) problem\n";
        sendBugReportPlease(cerr);
    }
    size_t pTmp;

    if (direct == false)
        l2 = reverseComplement(l2);

    if (shift < 0) {
        shift = -shift;
        pTmp = l1;
        l1 = l2;
        l2 = pTmp;
    }

    pTmp = l2;

    while (pTmp != 0) {
        setPosition(pTmp, getPosition(pTmp) + shift);
        pTmp = getPrevious(pTmp);
    }

    size_t p1 = l1;
    size_t p2 = l2;


    while (getPosition(getPrevious(p2)) >= getPosition(p1)) {
        p2 = getPrevious(p2);
    }

    if (getPosition(p2) >= getPosition(p1)) //add the overhanging part
    {
        pTmp = getPrevious(p2);
        setPrevious(p2, p1);
        setNext(p1, p2);

        p2 = pTmp;
        l1 = l2;
    }

    while (p2 != 0) {
        if (getPosition(p2) >= getPosition(p1)) {
            //insert p2 after p1
            pTmp = getPrevious(p2);

            setPrevious(p2, p1);
            setNext(p2, getNext(p1));
            setNext(p1, p2);
            setPrevious(getNext(p2), p2);

            p1 = p2;
            p2 = pTmp;
        } else
            p1 = getPrevious(p1);

    }

    return l1;
}
 void clearLinks(ItemLink position)
 {
     setNext(position, NoMore);
     setPrevious(position, NoMore);
 }
/**
	Equivaut a setPrevious()
	@return l'OrientationSet courant
*/
const OrientationSet OrientationSet::operator--() {
    setPrevious();
    return(*this);
}
/**
	Equivaut a setPrevious()
	@return l'OrientationSet precedent
*/
const OrientationSet OrientationSet::operator--(int) {
    OrientationSet before(*this);
    setPrevious();
    return(before);
}