Mercurial > hg > svgui
comparison layer/TimeInstantLayer.cpp @ 43:78515b1e29eb
* Rejig project file a bit to do pkg-config detection &c
and change some HAVE_* symbol names accordingly
* Add selection move/resize/delete
* First stubs for add layer / pane commands
author | Chris Cannam |
---|---|
date | Wed, 01 Mar 2006 18:13:01 +0000 |
parents | 202d1dca67d2 |
children | ad214997dddb |
comparison
equal
deleted
inserted
replaced
42:1bdf285c4eac | 43:78515b1e29eb |
---|---|
570 } | 570 } |
571 m_editingCommand = 0; | 571 m_editingCommand = 0; |
572 m_editing = false; | 572 m_editing = false; |
573 } | 573 } |
574 | 574 |
575 void | |
576 TimeInstantLayer::moveSelection(Selection s, size_t newStartFrame) | |
577 { | |
578 SparseOneDimensionalModel::EditCommand *command = | |
579 new SparseOneDimensionalModel::EditCommand(m_model, | |
580 tr("Drag Selection")); | |
581 | |
582 SparseOneDimensionalModel::PointList points = | |
583 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | |
584 | |
585 for (SparseOneDimensionalModel::PointList::iterator i = points.begin(); | |
586 i != points.end(); ++i) { | |
587 | |
588 if (s.contains(i->frame)) { | |
589 SparseOneDimensionalModel::Point newPoint(*i); | |
590 newPoint.frame = i->frame + newStartFrame - s.getStartFrame(); | |
591 command->deletePoint(*i); | |
592 command->addPoint(newPoint); | |
593 } | |
594 } | |
595 | |
596 command->finish(); | |
597 } | |
598 | |
599 void | |
600 TimeInstantLayer::resizeSelection(Selection s, Selection newSize) | |
601 { | |
602 SparseOneDimensionalModel::EditCommand *command = | |
603 new SparseOneDimensionalModel::EditCommand(m_model, | |
604 tr("Resize Selection")); | |
605 | |
606 SparseOneDimensionalModel::PointList points = | |
607 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | |
608 | |
609 double ratio = | |
610 double(newSize.getEndFrame() - newSize.getStartFrame()) / | |
611 double(s.getEndFrame() - s.getStartFrame()); | |
612 | |
613 for (SparseOneDimensionalModel::PointList::iterator i = points.begin(); | |
614 i != points.end(); ++i) { | |
615 | |
616 if (s.contains(i->frame)) { | |
617 | |
618 double target = i->frame; | |
619 target = newSize.getStartFrame() + | |
620 double(target - s.getStartFrame()) * ratio; | |
621 | |
622 SparseOneDimensionalModel::Point newPoint(*i); | |
623 newPoint.frame = lrint(target); | |
624 command->deletePoint(*i); | |
625 command->addPoint(newPoint); | |
626 } | |
627 } | |
628 | |
629 command->finish(); | |
630 } | |
631 | |
632 void | |
633 TimeInstantLayer::deleteSelection(Selection s) | |
634 { | |
635 SparseOneDimensionalModel::EditCommand *command = | |
636 new SparseOneDimensionalModel::EditCommand(m_model, | |
637 tr("Delete Selection")); | |
638 | |
639 SparseOneDimensionalModel::PointList points = | |
640 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | |
641 | |
642 for (SparseOneDimensionalModel::PointList::iterator i = points.begin(); | |
643 i != points.end(); ++i) { | |
644 if (s.contains(i->frame)) command->deletePoint(*i); | |
645 } | |
646 | |
647 command->finish(); | |
648 } | |
649 | |
650 | |
575 QString | 651 QString |
576 TimeInstantLayer::toXmlString(QString indent, QString extraAttributes) const | 652 TimeInstantLayer::toXmlString(QString indent, QString extraAttributes) const |
577 { | 653 { |
578 return Layer::toXmlString(indent, extraAttributes + | 654 return Layer::toXmlString(indent, extraAttributes + |
579 QString(" colour=\"%1\" plotStyle=\"%2\"") | 655 QString(" colour=\"%1\" plotStyle=\"%2\"") |