Mercurial > hg > svgui
comparison layer/ImageLayer.cpp @ 810:b68af2be4545 tonioni
Merge from branch warnfix_no_size_t
| author | Chris Cannam |
|---|---|
| date | Wed, 18 Jun 2014 13:42:25 +0100 |
| parents | 4c8ca536b54f |
| children | b66fb15de477 |
comparison
equal
deleted
inserted
replaced
| 802:584b11df8e4f | 810:b68af2be4545 |
|---|---|
| 76 { | 76 { |
| 77 return Layer::getProperties(); | 77 return Layer::getProperties(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 QString | 80 QString |
| 81 ImageLayer::getPropertyLabel(const PropertyName &name) const | 81 ImageLayer::getPropertyLabel(const PropertyName &) const |
| 82 { | 82 { |
| 83 return ""; | 83 return ""; |
| 84 } | 84 } |
| 85 | 85 |
| 86 Layer::PropertyType | 86 Layer::PropertyType |
| 114 { | 114 { |
| 115 return false; | 115 return false; |
| 116 } | 116 } |
| 117 | 117 |
| 118 bool | 118 bool |
| 119 ImageLayer::isLayerScrollable(const View *v) const | 119 ImageLayer::isLayerScrollable(const View *) const |
| 120 { | 120 { |
| 121 return true; | 121 return true; |
| 122 } | 122 } |
| 123 | 123 |
| 124 | 124 |
| 125 ImageModel::PointList | 125 ImageModel::PointList |
| 126 ImageLayer::getLocalPoints(View *v, int x, int y) const | 126 ImageLayer::getLocalPoints(View *v, int x, int ) const |
| 127 { | 127 { |
| 128 if (!m_model) return ImageModel::PointList(); | 128 if (!m_model) return ImageModel::PointList(); |
| 129 | 129 |
| 130 // SVDEBUG << "ImageLayer::getLocalPoints(" << x << "," << y << "):"; | 130 // SVDEBUG << "ImageLayer::getLocalPoints(" << x << "," << y << "):"; |
| 131 const ImageModel::PointList &points(m_model->getPoints()); | 131 const ImageModel::PointList &points(m_model->getPoints()); |
| 183 } else { | 183 } else { |
| 184 return ""; | 184 return ""; |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 | 187 |
| 188 long useFrame = points.begin()->frame; | 188 // int useFrame = points.begin()->frame; |
| 189 | 189 |
| 190 RealTime rt = RealTime::frame2RealTime(useFrame, m_model->getSampleRate()); | 190 // RealTime rt = RealTime::frame2RealTime(useFrame, m_model->getSampleRate()); |
| 191 | 191 |
| 192 QString text; | 192 QString text; |
| 193 /* | 193 /* |
| 194 if (points.begin()->label == "") { | 194 if (points.begin()->label == "") { |
| 195 text = QString(tr("Time:\t%1\nHeight:\t%2\nLabel:\t%3")) | 195 text = QString(tr("Time:\t%1\nHeight:\t%2\nLabel:\t%3")) |
| 207 | 207 |
| 208 //!!! too much overlap with TimeValueLayer/TimeInstantLayer/TextLayer | 208 //!!! too much overlap with TimeValueLayer/TimeInstantLayer/TextLayer |
| 209 | 209 |
| 210 bool | 210 bool |
| 211 ImageLayer::snapToFeatureFrame(View *v, int &frame, | 211 ImageLayer::snapToFeatureFrame(View *v, int &frame, |
| 212 size_t &resolution, | 212 int &resolution, |
| 213 SnapType snap) const | 213 SnapType snap) const |
| 214 { | 214 { |
| 215 if (!m_model) { | 215 if (!m_model) { |
| 216 return Layer::snapToFeatureFrame(v, frame, resolution, snap); | 216 return Layer::snapToFeatureFrame(v, frame, resolution, snap); |
| 217 } | 217 } |
| 290 // Profiler profiler("ImageLayer::paint", true); | 290 // Profiler profiler("ImageLayer::paint", true); |
| 291 | 291 |
| 292 // int x0 = rect.left(), x1 = rect.right(); | 292 // int x0 = rect.left(), x1 = rect.right(); |
| 293 int x0 = 0, x1 = v->width(); | 293 int x0 = 0, x1 = v->width(); |
| 294 | 294 |
| 295 long frame0 = v->getFrameForX(x0); | 295 int frame0 = v->getFrameForX(x0); |
| 296 long frame1 = v->getFrameForX(x1); | 296 int frame1 = v->getFrameForX(x1); |
| 297 | 297 |
| 298 ImageModel::PointList points(m_model->getPoints(frame0, frame1)); | 298 ImageModel::PointList points(m_model->getPoints(frame0, frame1)); |
| 299 if (points.empty()) return; | 299 if (points.empty()) return; |
| 300 | 300 |
| 301 paint.save(); | 301 paint.save(); |
| 517 } | 517 } |
| 518 | 518 |
| 519 QImage | 519 QImage |
| 520 ImageLayer::getImage(View *v, QString name, QSize maxSize) const | 520 ImageLayer::getImage(View *v, QString name, QSize maxSize) const |
| 521 { | 521 { |
| 522 bool need = false; | |
| 523 | |
| 524 // SVDEBUG << "ImageLayer::getImage(" << v << ", " << name << ", (" | 522 // SVDEBUG << "ImageLayer::getImage(" << v << ", " << name << ", (" |
| 525 // << maxSize.width() << "x" << maxSize.height() << "))" << endl; | 523 // << maxSize.width() << "x" << maxSize.height() << "))" << endl; |
| 526 | 524 |
| 527 if (!m_scaled[v][name].isNull() && | 525 if (!m_scaled[v][name].isNull() && |
| 528 ((m_scaled[v][name].width() == maxSize.width() && | 526 ((m_scaled[v][name].width() == maxSize.width() && |
| 563 if (!m_model) { | 561 if (!m_model) { |
| 564 SVDEBUG << "ImageLayer::drawStart: no model" << endl; | 562 SVDEBUG << "ImageLayer::drawStart: no model" << endl; |
| 565 return; | 563 return; |
| 566 } | 564 } |
| 567 | 565 |
| 568 long frame = v->getFrameForX(e->x()); | 566 int frame = v->getFrameForX(e->x()); |
| 569 if (frame < 0) frame = 0; | 567 if (frame < 0) frame = 0; |
| 570 frame = frame / m_model->getResolution() * m_model->getResolution(); | 568 frame = frame / m_model->getResolution() * m_model->getResolution(); |
| 571 | 569 |
| 572 m_editingPoint = ImageModel::Point(frame, "", ""); | 570 m_editingPoint = ImageModel::Point(frame, "", ""); |
| 573 m_originalPoint = m_editingPoint; | 571 m_originalPoint = m_editingPoint; |
| 584 { | 582 { |
| 585 // SVDEBUG << "ImageLayer::drawDrag(" << e->x() << "," << e->y() << ")" << endl; | 583 // SVDEBUG << "ImageLayer::drawDrag(" << e->x() << "," << e->y() << ")" << endl; |
| 586 | 584 |
| 587 if (!m_model || !m_editing) return; | 585 if (!m_model || !m_editing) return; |
| 588 | 586 |
| 589 long frame = v->getFrameForX(e->x()); | 587 int frame = v->getFrameForX(e->x()); |
| 590 if (frame < 0) frame = 0; | 588 if (frame < 0) frame = 0; |
| 591 frame = frame / m_model->getResolution() * m_model->getResolution(); | 589 frame = frame / m_model->getResolution() * m_model->getResolution(); |
| 592 | 590 |
| 593 m_editingCommand->deletePoint(m_editingPoint); | 591 m_editingCommand->deletePoint(m_editingPoint); |
| 594 m_editingPoint.frame = frame; | 592 m_editingPoint.frame = frame; |
| 595 m_editingCommand->addPoint(m_editingPoint); | 593 m_editingCommand->addPoint(m_editingPoint); |
| 596 } | 594 } |
| 597 | 595 |
| 598 void | 596 void |
| 599 ImageLayer::drawEnd(View *v, QMouseEvent *) | 597 ImageLayer::drawEnd(View *, QMouseEvent *) |
| 600 { | 598 { |
| 601 // SVDEBUG << "ImageLayer::drawEnd(" << e->x() << "," << e->y() << ")" << endl; | 599 // SVDEBUG << "ImageLayer::drawEnd(" << e->x() << "," << e->y() << ")" << endl; |
| 602 if (!m_model || !m_editing) return; | 600 if (!m_model || !m_editing) return; |
| 603 | |
| 604 bool ok = false; | |
| 605 | 601 |
| 606 ImageDialog dialog(tr("Select image"), "", ""); | 602 ImageDialog dialog(tr("Select image"), "", ""); |
| 607 | 603 |
| 608 if (dialog.exec() == QDialog::Accepted) { | 604 if (dialog.exec() == QDialog::Accepted) { |
| 609 | 605 |
| 621 m_editingCommand = 0; | 617 m_editingCommand = 0; |
| 622 m_editing = false; | 618 m_editing = false; |
| 623 } | 619 } |
| 624 | 620 |
| 625 bool | 621 bool |
| 626 ImageLayer::addImage(long frame, QString url) | 622 ImageLayer::addImage(int frame, QString url) |
| 627 { | 623 { |
| 628 QImage image(getLocalFilename(url)); | 624 QImage image(getLocalFilename(url)); |
| 629 if (image.isNull()) { | 625 if (image.isNull()) { |
| 630 cerr << "Failed to open image from url \"" << url << "\" (local filename \"" << getLocalFilename(url) << "\"" << endl; | 626 cerr << "Failed to open image from url \"" << url << "\" (local filename \"" << getLocalFilename(url) << "\"" << endl; |
| 631 delete m_fileSources[url]; | 627 delete m_fileSources[url]; |
| 666 void | 662 void |
| 667 ImageLayer::editDrag(View *v, QMouseEvent *e) | 663 ImageLayer::editDrag(View *v, QMouseEvent *e) |
| 668 { | 664 { |
| 669 if (!m_model || !m_editing) return; | 665 if (!m_model || !m_editing) return; |
| 670 | 666 |
| 671 long frameDiff = v->getFrameForX(e->x()) - v->getFrameForX(m_editOrigin.x()); | 667 int frameDiff = v->getFrameForX(e->x()) - v->getFrameForX(m_editOrigin.x()); |
| 672 long frame = m_originalPoint.frame + frameDiff; | 668 int frame = m_originalPoint.frame + frameDiff; |
| 673 | 669 |
| 674 if (frame < 0) frame = 0; | 670 if (frame < 0) frame = 0; |
| 675 frame = (frame / m_model->getResolution()) * m_model->getResolution(); | 671 frame = (frame / m_model->getResolution()) * m_model->getResolution(); |
| 676 | 672 |
| 677 if (!m_editingCommand) { | 673 if (!m_editingCommand) { |
| 725 | 721 |
| 726 return true; | 722 return true; |
| 727 } | 723 } |
| 728 | 724 |
| 729 void | 725 void |
| 730 ImageLayer::moveSelection(Selection s, size_t newStartFrame) | 726 ImageLayer::moveSelection(Selection s, int newStartFrame) |
| 731 { | 727 { |
| 732 if (!m_model) return; | 728 if (!m_model) return; |
| 733 | 729 |
| 734 ImageModel::EditCommand *command = | 730 ImageModel::EditCommand *command = |
| 735 new ImageModel::EditCommand(m_model, tr("Drag Selection")); | 731 new ImageModel::EditCommand(m_model, tr("Drag Selection")); |
| 821 } | 817 } |
| 822 } | 818 } |
| 823 } | 819 } |
| 824 | 820 |
| 825 bool | 821 bool |
| 826 ImageLayer::paste(View *v, const Clipboard &from, int frameOffset, bool /* interactive */) | 822 ImageLayer::paste(View *v, const Clipboard &from, int /* frameOffset */, bool /* interactive */) |
| 827 { | 823 { |
| 828 if (!m_model) return false; | 824 if (!m_model) return false; |
| 829 | 825 |
| 830 const Clipboard::PointList &points = from.getPoints(); | 826 const Clipboard::PointList &points = from.getPoints(); |
| 831 | 827 |
| 854 for (Clipboard::PointList::const_iterator i = points.begin(); | 850 for (Clipboard::PointList::const_iterator i = points.begin(); |
| 855 i != points.end(); ++i) { | 851 i != points.end(); ++i) { |
| 856 | 852 |
| 857 if (!i->haveFrame()) continue; | 853 if (!i->haveFrame()) continue; |
| 858 | 854 |
| 859 size_t frame = 0; | 855 int frame = 0; |
| 860 | 856 |
| 861 if (!realign) { | 857 if (!realign) { |
| 862 | 858 |
| 863 frame = i->getFrame(); | 859 frame = i->getFrame(); |
| 864 | 860 |
| 968 { | 964 { |
| 969 Layer::toXml(stream, indent, extraAttributes); | 965 Layer::toXml(stream, indent, extraAttributes); |
| 970 } | 966 } |
| 971 | 967 |
| 972 void | 968 void |
| 973 ImageLayer::setProperties(const QXmlAttributes &attributes) | 969 ImageLayer::setProperties(const QXmlAttributes &) |
| 974 { | 970 { |
| 975 } | 971 } |
| 976 | 972 |
