| #pragma once |
| |
| #ifndef FUNCTIONSELECTION_H |
| #define FUNCTIONSELECTION_H |
| |
| #include "tcommon.h" |
| #include "functiontreeviewer.h" |
| #include "toonzqt/selection.h" |
| #include "toonzqt/dvmimedata.h" |
| |
| #include "tdoublekeyframe.h" |
| |
| #include <QWidget> |
| #include <QList> |
| #include <QSet> |
| |
| #undef DVAPI |
| #undef DVVAR |
| #ifdef TOONZQT_EXPORTS |
| #define DVAPI DV_EXPORT_API |
| #define DVVAR DV_EXPORT_VAR |
| #else |
| #define DVAPI DV_IMPORT_API |
| #define DVVAR DV_IMPORT_VAR |
| #endif |
| |
| |
| class TDoubleParam; |
| class TFrameHandle; |
| |
| |
| |
| class ColumnToCurveMapper { |
| public: |
| virtual TDoubleParam *getCurve(int columnIndex) const = 0; |
| }; |
| |
| |
| |
| class FunctionSelection final : public QObject, public TSelection { |
| Q_OBJECT |
| QRect m_selectedCells; |
| |
| QList<QPair<TDoubleParam *, QSet<int>>> m_selectedKeyframes; |
| |
| |
| int m_selectedSegment; |
| |
| |
| |
| |
| TFrameHandle *m_frameHandle; |
| ColumnToCurveMapper *m_columnToCurveMapper; |
| |
| int getCurveIndex(TDoubleParam *curve) const; |
| |
| |
| int touchCurveIndex(TDoubleParam *curve); |
| |
| |
| public: |
| FunctionSelection(); |
| ~FunctionSelection(); |
| |
| void setFrameHandle(TFrameHandle *frameHandle) { |
| m_frameHandle = frameHandle; |
| } |
| |
| |
| void selectCurve(TDoubleParam *curve); |
| void deselectAllKeyframes(); |
| |
| |
| QRect getSelectedCells() const { return m_selectedCells; } |
| void selectCells(const QRect &selectedCells, |
| const QList<TDoubleParam *> &curves); |
| void selectCells(const QRect &selectedCells); |
| void deselectAllCells(); |
| |
| bool isEmpty() const override { return m_selectedKeyframes.empty(); } |
| void selectNone() override; |
| void select(TDoubleParam *curve, int k); |
| bool isSelected(TDoubleParam *curve, int k) const; |
| void selectSegment(TDoubleParam *, int k, |
| QRect selectedCells = QRect()); |
| |
| |
| |
| int getSelectedKeyframeCount() const; |
| QPair<TDoubleParam *, int> getSelectedKeyframe(int index) |
| const; |
| |
| QPair<TDoubleParam *, int> getSelectedSegment() |
| const; |
| bool isSegmentSelected(TDoubleParam *, int k) const; |
| |
| void setColumnToCurveMapper(ColumnToCurveMapper *mapper); |
| |
| TDoubleParam *getCurveFromColumn(int columnIndex) const { |
| return m_columnToCurveMapper ? m_columnToCurveMapper->getCurve(columnIndex) |
| : 0; |
| } |
| |
| void enableCommands() override; |
| |
| void doCopy(); |
| void doPaste(); |
| void doCut(); |
| void doDelete(); |
| void insertCells(); |
| |
| |
| void setStep(int, bool inclusive = true); |
| void setStep1() { setStep(1); } |
| void setStep2() { setStep(2); } |
| void setStep3() { setStep(3); } |
| void setStep4() { setStep(4); } |
| |
| |
| |
| |
| |
| int getCommonStep(bool inclusive = true); |
| |
| void setSegmentType(TDoubleKeyframe::Type type, bool inclusive = true); |
| |
| |
| |
| |
| |
| |
| int getCommonSegmentType(bool inclusive = true); |
| |
| signals: |
| void selectionChanged(); |
| }; |
| |
| |
| |
| class FunctionKeyframesData final : public DvMimeData { |
| public: |
| FunctionKeyframesData(); |
| ~FunctionKeyframesData(); |
| |
| typedef std::vector<TDoubleKeyframe> Keyframes; |
| |
| void setColumnCount(int columnCount); |
| int getColumnCount() const { return (int)m_keyframes.size(); } |
| |
| int getRowCount() const; |
| |
| void getData(int columnIndex, TDoubleParam *curve, double frame, |
| const QSet<int> &kIndices); |
| void setData(int columnIndex, TDoubleParam *curve, double frame) const; |
| |
| const Keyframes &getKeyframes(int columnIndex) const; |
| |
| DvMimeData *clone() const override; |
| |
| bool isCircularReferenceFree(int columnIndex, TDoubleParam *curve) const; |
| |
| private: |
| std::vector<Keyframes> m_keyframes; |
| }; |
| |
| #endif |