2016-05-17 03:04:11 +12:00
|
|
|
#pragma once
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
#ifndef FUNCTION_SEGMENT_VIEWER_H
|
|
|
|
#define FUNCTION_SEGMENT_VIEWER_H
|
|
|
|
|
2018-09-06 05:07:46 +12:00
|
|
|
#include <array>
|
2016-03-19 06:57:51 +13:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QComboBox>
|
|
|
|
|
|
|
|
#include "tdoubleparam.h"
|
2018-06-04 15:18:43 +12:00
|
|
|
#include "tdoublekeyframe.h"
|
2016-03-19 06:57:51 +13:00
|
|
|
#include "toonzqt/lineedit.h"
|
|
|
|
|
|
|
|
#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 FunctionSegmentPage;
|
|
|
|
class FunctionSheet;
|
|
|
|
class TXsheetHandle;
|
|
|
|
class KeyframeSetter;
|
|
|
|
class FunctionPanel;
|
|
|
|
class QPushButton;
|
|
|
|
class QStackedWidget;
|
2016-06-15 18:43:10 +12:00
|
|
|
namespace DVGui {
|
2016-03-19 06:57:51 +13:00
|
|
|
class MeasuredDoubleLineEdit;
|
|
|
|
class ExpressionField;
|
2018-06-04 15:18:43 +12:00
|
|
|
class FileField;
|
2019-08-02 18:48:26 +12:00
|
|
|
} // namespace DVGui
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class FunctionSegmentViewer final : public QFrame, public TParamObserver {
|
2016-06-15 18:43:10 +12:00
|
|
|
Q_OBJECT
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TDoubleParam *m_curve;
|
|
|
|
int m_segmentIndex;
|
|
|
|
int m_r0, m_r1;
|
|
|
|
QWidget *m_topbar;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QLineEdit *m_fromFld;
|
|
|
|
QLineEdit *m_toFld;
|
|
|
|
QLabel *m_paramNameLabel;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QComboBox *m_typeCombo;
|
|
|
|
DVGui::LineEdit *m_stepFld;
|
|
|
|
QStackedWidget *m_parametersPanel;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2018-09-06 05:07:46 +12:00
|
|
|
std::array<FunctionSegmentPage *, 9> m_pages;
|
|
|
|
std::array<int, 9> m_typeId;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionSheet *m_sheet;
|
|
|
|
TXsheetHandle *m_xshHandle;
|
|
|
|
FunctionPanel *m_panel;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// buttons for move segments
|
|
|
|
QPushButton *m_prevCurveButton;
|
|
|
|
QPushButton *m_nextCurveButton;
|
|
|
|
QPushButton *m_prevLinkButton;
|
|
|
|
QPushButton *m_nextLinkButton;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionSegmentViewer(QWidget *parent, FunctionSheet *sheet = 0,
|
|
|
|
FunctionPanel *panel = 0);
|
|
|
|
~FunctionSegmentViewer();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TDoubleParam *getCurve() const { return m_curve; }
|
|
|
|
int getR0() const { return m_r0; }
|
|
|
|
int getR1() const { return m_r1; }
|
|
|
|
int getSegmentIndex() const { return m_segmentIndex; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void refresh();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// overriden from TDoubleParamObserver
|
2016-06-19 20:06:29 +12:00
|
|
|
void onChange(const TParamChange &) override { refresh(); }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void setXsheetHandle(TXsheetHandle *xshHandle) { m_xshHandle = xshHandle; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool anyWidgetHasFocus();
|
|
|
|
// in order to avoid FunctionViewer to get focus while editing the expression
|
|
|
|
bool isExpressionPageActive();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
private:
|
2016-06-15 18:43:10 +12:00
|
|
|
int typeToIndex(int type) const;
|
|
|
|
int indexToType(int typeIndex) const { return m_typeId[typeIndex]; }
|
|
|
|
bool segmentIsValid() const;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// for displaying the types of neighbor segments
|
|
|
|
QString typeToString(int type) const;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
private slots:
|
2016-06-15 18:43:10 +12:00
|
|
|
void onSegmentTypeChanged(int type);
|
|
|
|
void onCurveChanged();
|
|
|
|
void onStepFieldChanged(const QString &);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void onApplyButtonPressed();
|
|
|
|
void onPrevCurveButtonPressed();
|
|
|
|
void onNextCurveButtonPressed();
|
|
|
|
void onPrevLinkButtonPressed();
|
|
|
|
void onNextLinkButtonPressed();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public slots:
|
2016-06-15 18:43:10 +12:00
|
|
|
void setSegment(TDoubleParam *curve, int segmentIndex);
|
|
|
|
void setSegmentByFrame(TDoubleParam *curve, int frame);
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
class FunctionSegmentPage : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
FunctionSegmentViewer *m_viewer;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionSegmentPage(FunctionSegmentViewer *parent);
|
|
|
|
~FunctionSegmentPage();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionSegmentViewer *getViewer() const { return m_viewer; }
|
|
|
|
TDoubleParam *getCurve() const { return m_viewer->getCurve(); }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
int getR0() const { return m_viewer->getR0(); }
|
|
|
|
int getR1() const { return m_viewer->getR1(); }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
virtual void refresh() = 0;
|
|
|
|
virtual void apply() = 0;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
virtual void init(int segmentLength) = 0;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public slots:
|
2016-06-15 18:43:10 +12:00
|
|
|
void onFieldChanged() { apply(); }
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class SpeedInOutSegmentPage final : public FunctionSegmentPage {
|
2016-06-15 18:43:10 +12:00
|
|
|
Q_OBJECT
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
DVGui::LineEdit *m_speed0xFld;
|
|
|
|
DVGui::MeasuredDoubleLineEdit *m_speed0yFld;
|
|
|
|
DVGui::LineEdit *m_speed1xFld;
|
|
|
|
DVGui::MeasuredDoubleLineEdit *m_speed1yFld;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
DVGui::MeasuredDoubleLineEdit *m_firstSpeedFld;
|
|
|
|
DVGui::MeasuredDoubleLineEdit *m_lastSpeedFld;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
SpeedInOutSegmentPage(FunctionSegmentViewer *parent = 0);
|
2016-06-19 20:06:29 +12:00
|
|
|
void refresh() override;
|
2016-06-20 14:23:05 +12:00
|
|
|
void apply() override{};
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void getGuiValues(TPointD &speedIn, TPointD &speedOut);
|
2016-06-19 20:06:29 +12:00
|
|
|
void init(int segmentLength) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public slots:
|
2016-06-15 18:43:10 +12:00
|
|
|
void onFirstHandleXChanged();
|
|
|
|
void onFirstHandleYChanged();
|
|
|
|
void onLastHandleXChanged();
|
|
|
|
void onLastHandleYChanged();
|
|
|
|
void onFirstSpeedChanged();
|
|
|
|
void onLastSpeedChanged();
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class EaseInOutSegmentPage final : public FunctionSegmentPage {
|
2016-06-15 18:43:10 +12:00
|
|
|
Q_OBJECT
|
|
|
|
DVGui::MeasuredDoubleLineEdit *m_ease0Fld, *m_ease1Fld;
|
|
|
|
double m_fieldScale;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool m_isPercentage;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
EaseInOutSegmentPage(bool percentage, FunctionSegmentViewer *parent = 0);
|
2016-06-19 20:06:29 +12:00
|
|
|
void refresh() override;
|
|
|
|
void apply() override {}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void getGuiValues(TPointD &easeIn, TPointD &easeOut);
|
2016-06-19 20:06:29 +12:00
|
|
|
void init(int segmentLength) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public slots:
|
2016-06-15 18:43:10 +12:00
|
|
|
void onEase0Changed();
|
|
|
|
void onEase1Changed();
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class FunctionExpressionSegmentPage final : public FunctionSegmentPage {
|
2016-06-15 18:43:10 +12:00
|
|
|
Q_OBJECT
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
DVGui::ExpressionField *m_expressionFld;
|
|
|
|
DVGui::LineEdit *m_unitFld;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
FunctionExpressionSegmentPage(FunctionSegmentViewer *parent = 0);
|
2016-06-19 20:06:29 +12:00
|
|
|
void refresh() override;
|
|
|
|
void apply() override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// return false if a circular reference is occured
|
|
|
|
bool getGuiValues(std::string &expressionText, std::string &unitName);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
void init(int segmentLength) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class SimilarShapeSegmentPage final : public FunctionSegmentPage {
|
2016-06-15 18:43:10 +12:00
|
|
|
Q_OBJECT
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
DVGui::ExpressionField *m_expressionFld;
|
|
|
|
DVGui::LineEdit *m_offsetFld;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
SimilarShapeSegmentPage(FunctionSegmentViewer *parent = 0);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
void refresh() override;
|
|
|
|
void apply() override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
void init(int segmentLength) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void getGuiValues(std::string &expressionText, double &similarShapeOffset);
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
2018-06-04 15:18:43 +12:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class FileSegmentPage final : public FunctionSegmentPage {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
DVGui::FileField *m_fileFld;
|
|
|
|
DVGui::LineEdit *m_fieldIndexFld;
|
|
|
|
DVGui::LineEdit *m_measureFld;
|
|
|
|
|
|
|
|
public:
|
|
|
|
FileSegmentPage(FunctionSegmentViewer *parent = 0);
|
|
|
|
void refresh() override;
|
|
|
|
void init(int segmentLength) override;
|
|
|
|
void apply() override;
|
|
|
|
void getGuiValues(TDoubleKeyframe::FileParams &fileParam,
|
|
|
|
std::string &unitName);
|
|
|
|
};
|
|
|
|
|
2016-03-19 06:57:51 +13:00
|
|
|
#endif
|