Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef FUNCTIONVIEWER_H
Toshihiro Shimizu 890ddd
#define FUNCTIONVIEWER_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Jeremy Bullock 4ce953
#include "saveloadqsettings.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzLib includes
Toshihiro Shimizu 890ddd
#include "toonz/tframehandle.h"
Jeremy Bullock 4ce953
#include "toonz/preferences.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzQt includes
Toshihiro Shimizu 890ddd
#include "toonzqt/treemodel.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Qt includes
Toshihiro Shimizu 890ddd
#include <qsplitter></qsplitter>
Jeremy Bullock 4ce953
#include <qsettings></qsettings>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TOONZQT_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//    Forward declarations
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TParam;
Toshihiro Shimizu 890ddd
class TDoubleParam;
Toshihiro Shimizu 890ddd
class TXsheetHandle;
Toshihiro Shimizu 890ddd
class TObjectHandle;
Toshihiro Shimizu 890ddd
class TFxHandle;
Toshihiro Shimizu 890ddd
class TColumnHandle;
Toshihiro Shimizu 890ddd
class TStageObject;
Toshihiro Shimizu 890ddd
class TSceneHandle;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class FrameNavigator;
Toshihiro Shimizu 890ddd
class FunctionTreeView;
Toshihiro Shimizu 890ddd
class FunctionPanel;
Toshihiro Shimizu 890ddd
class FunctionSheet;
Toshihiro Shimizu 890ddd
class FunctionKeyframeNavigator;
Toshihiro Shimizu 890ddd
class FunctionSegmentViewer;
Toshihiro Shimizu 890ddd
class FunctionToolbar;
Toshihiro Shimizu 890ddd
class FunctionSelection;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class QStackedWidget;
Toshihiro Shimizu 890ddd
class QAction;
Toshihiro Shimizu 890ddd
class QScrollArea;
Toshihiro Shimizu 890ddd
class QSplitter;
Jeremy Bullock 15fcba
class QVBoxLayout;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace DVGui {
Toshihiro Shimizu 890ddd
class ValueField;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//************************************************************************
Toshihiro Shimizu 890ddd
//    FunctionViewer  declaration
Toshihiro Shimizu 890ddd
//************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Function editor widget
Jeremy Bullock 4ce953
class DVAPI FunctionViewer final : public QSplitter, public SaveLoadQSettings {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  enum IoType { eSaveCurve, eLoadCurve, eExportCurve };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
shun-iwasawa 443318
  FunctionViewer(QWidget *parent       = 0,
shun-iwasawa 443318
                 Qt::WindowFlags flags = Qt::WindowFlags());
Shinya Kitaoka 120a6e
  ~FunctionViewer();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setXsheetHandle(TXsheetHandle *xshHandle);  //!< Associates an xsheet to
Shinya Kitaoka 38fd86
                                                   //! the function editor.
Shinya Kitaoka 120a6e
  void setFrameHandle(TFrameHandle *frameHandle);  //!< Synchronizes an external
Shinya Kitaoka 38fd86
  //! timeline with the function
Shinya Kitaoka 38fd86
  //! editor.
Shinya Kitaoka 120a6e
  void setObjectHandle(TObjectHandle *objectHandle);  //!< Associates a stage
Shinya Kitaoka 38fd86
  //! objects selector to the
Shinya Kitaoka 38fd86
  //! function editor.
Shinya Kitaoka 120a6e
  void setFxHandle(TFxHandle *fxHandle);  //!< Associates an fx selector to the
Shinya Kitaoka 38fd86
                                          //! function editor.
Shinya Kitaoka 120a6e
  void setColumnHandle(TColumnHandle *columnHandle);  //!< Associates a column
Shinya Kitaoka 38fd86
                                                      //! selector to the
Shinya Kitaoka 38fd86
  //! function editor.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  FunctionSelection *getSelection() const { return m_selection; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void openContextMenu(TreeModel::Item *item, const QPoint &globalPos);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void addParameter(TParam *parameter,
Shinya Kitaoka 120a6e
                    const TFilePath &folder = TFilePath());  //!< Adds the
Shinya Kitaoka 38fd86
                                                             //! specified
Shinya Kitaoka 38fd86
  //! parameter to the
Shinya Kitaoka 38fd86
  //! function editor.
Shinya Kitaoka 38fd86
  //!\param parameter
Shinya Kitaoka 38fd86
  //! Parameter to be
Shinya Kitaoka 38fd86
  //! added. Ownership
Shinya Kitaoka 38fd86
  //! remains \a
Shinya Kitaoka 38fd86
  //! external. \param
Shinya Kitaoka 38fd86
  //! folder Host
Shinya Kitaoka 38fd86
  //! folder (created
Shinya Kitaoka 38fd86
  //! if necessary)
Shinya Kitaoka 38fd86
  //! the parameter
Shinya Kitaoka 38fd86
  //! will be added
Shinya Kitaoka 38fd86
  //! to.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setFocusColumnsOrGraph();
Shinya Kitaoka 120a6e
  void clearFocusColumnsAndGraph();
Shinya Kitaoka 120a6e
  bool columnsOrGraphHasFocus();
Shinya Kitaoka 120a6e
  void setSceneHandle(TSceneHandle *sceneHandle);
shun_iwasawa 768e20
  TSceneHandle *getSceneHandle() const { return m_sceneHandle; }
shun-iwasawa 4a3868
  TXsheetHandle *getXsheetHandle() const { return m_xshHandle; }
shun_iwasawa 768e20
Jeremy Bullock 4ce953
  // SaveLoadQSettings
Jeremy Bullock 4ce953
  virtual void save(QSettings &settings) const override;
Jeremy Bullock 4ce953
  virtual void load(QSettings &settings) override;
Toshihiro Shimizu 890ddd
shun-iwasawa 2ce475
  // refer to the preferences' "Current Column Color"
shun-iwasawa 2ce475
  QColor getCurrentTextColor() const;
shun-iwasawa 2ce475
Toshihiro Shimizu 890ddd
signals:
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void curveChanged();
Shinya Kitaoka 120a6e
  void curveIo(int type, TDoubleParam *curve, const std::string &name);
Shinya Kitaoka 120a6e
  void editObject();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public slots:
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void refreshModel();
Shinya Kitaoka 120a6e
  void rebuildModel();
Shinya Kitaoka 120a6e
  void onFrameSwitched();
Shinya Kitaoka 120a6e
  void toggleMode();
Shinya Kitaoka 120a6e
  void onValueFieldChanged();
Shinya Kitaoka 120a6e
  void onXsheetChanged();
Shinya Kitaoka 120a6e
  void onStageObjectSwitched();
Shinya Kitaoka 120a6e
  void onStageObjectChanged(bool isDragging = false);
Shinya Kitaoka 120a6e
  void onFxSwitched();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void onCurveChanged(bool isDragging);
Shinya Kitaoka 120a6e
  void onCurveSelected(TDoubleParam *);
Shinya Kitaoka 120a6e
  void onSelectionChanged();
shun-iwasawa 855b12
  void onPreferenceChanged(const QString &);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void doSwitchCurrentObject(TStageObject *obj);
Shinya Kitaoka 120a6e
  void doSwitchCurrentFx(TFx *fx);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // in order to avoid FunctionViewer to get focus while editing the expression
Shinya Kitaoka 120a6e
  bool isExpressionPageActive();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  // Handles
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TXsheetHandle *m_xshHandle;
Shinya Kitaoka 120a6e
  TFrameHandle *m_frameHandle;
Shinya Kitaoka 120a6e
  TObjectHandle *m_objectHandle;
Shinya Kitaoka 120a6e
  TFxHandle *m_fxHandle;
Shinya Kitaoka 120a6e
  TColumnHandle *m_columnHandle;
Shinya Kitaoka 120a6e
  TSceneHandle *m_sceneHandle;
Jeremy Bullock 15fcba
  QVBoxLayout *m_leftLayout;
Jeremy Bullock 4ce953
  int m_spacing;
Jeremy Bullock 4ce953
  int m_toggleStatus = 0;
Jeremy Bullock 4ce953
  Preferences::FunctionEditorToggle m_toggleStart;
Shinya Kitaoka 120a6e
  TFrameHandle
Shinya Kitaoka 120a6e
      m_localFrame;  //!< Internal timeline - which is attached to m_frameHandle
Shinya Kitaoka 120a6e
                     //!  in case it is not zero.
Shinya Kitaoka 120a6e
  // Widgets
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  FunctionTreeView *m_treeView;  //!< Tree view on the left side of the viewer.
Shinya Kitaoka 120a6e
  FunctionToolbar *m_toolbar;    //!< Central area's toolbar
Shinya Kitaoka 120a6e
  FunctionPanel *m_functionGraph;     //!< The function graph view widget.
Shinya Kitaoka 120a6e
  FunctionSheet *m_numericalColumns;  //!< The numerical columns view widget.
Shinya Kitaoka 120a6e
  FunctionSegmentViewer *m_segmentViewer;  //!< Lower segment editor.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // Current objects
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TDoubleParam *m_curve;
Shinya Kitaoka 120a6e
  FunctionSelection *m_selection;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 473e70
  void showEvent(QShowEvent *) override;
Shinya Kitaoka 473e70
  void hideEvent(QHideEvent *) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
public:  //  :(
Shinya Kitaoka 120a6e
  void emitCurveChanged() {
Shinya Kitaoka 120a6e
    emit curveChanged();
Shinya Kitaoka 120a6e
  }  //!< \deprecated  Should not be public.
Shinya Kitaoka 120a6e
  void emitIoCurve(int type, TDoubleParam *curve, const std::string &name) {
Shinya Kitaoka 120a6e
    emit curveIo(type, curve, name);
Shinya Kitaoka 120a6e
  }  //!< \deprecated  Should not be public.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private slots:
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void propagateExternalSetFrame();  //!< Forwards m_frameHandle's setFrame()
Shinya Kitaoka 38fd86
                                     //! invocations to m_localFrame.
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // FUNCTIONEDITORVIEWER_H