Toshihiro Shimizu 890ddd
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"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzLib includes
Toshihiro Shimizu 890ddd
#include "toonz/tframehandle.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>
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;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
namespace DVGui
Toshihiro Shimizu 890ddd
{
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
Toshihiro Shimizu 890ddd
class DVAPI FunctionViewer : public QSplitter
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	enum IoType { eSaveCurve,
Toshihiro Shimizu 890ddd
				  eLoadCurve,
Toshihiro Shimizu 890ddd
				  eExportCurve };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
#if QT_VERSION >= 0x050500
Toshihiro Shimizu 890ddd
	FunctionViewer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
	FunctionViewer(QWidget *parent = 0, Qt::WFlags flags = 0);
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
	~FunctionViewer();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setXsheetHandle(TXsheetHandle *xshHandle);	//!< Associates an xsheet to the function editor.
Toshihiro Shimizu 890ddd
	void setFrameHandle(TFrameHandle *frameHandle);	//!< Synchronizes an external timeline with the function editor.
Toshihiro Shimizu 890ddd
	void setObjectHandle(TObjectHandle *objectHandle); //!< Associates a stage objects selector to the function editor.
Toshihiro Shimizu 890ddd
	void setFxHandle(TFxHandle *fxHandle);			   //!< Associates an fx selector to the function editor.
Toshihiro Shimizu 890ddd
	void setColumnHandle(TColumnHandle *columnHandle); //!< Associates a column selector to the function editor.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	FunctionSelection *getSelection() const
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		return m_selection;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void openContextMenu(TreeModel::Item *item, const QPoint &globalPos);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void addParameter(TParam *parameter,
Toshihiro Shimizu 890ddd
					  const TFilePath &folder = TFilePath()); //!< Adds the specified parameter to the function editor.               \param parameter Parameter to be added. Ownership remains \a external. \param folder Host folder (created if necessary) the parameter will be added to.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setFocusColumnsOrGraph();
Toshihiro Shimizu 890ddd
	void clearFocusColumnsAndGraph();
Toshihiro Shimizu 890ddd
	bool columnsOrGraphHasFocus();
Toshihiro Shimizu 890ddd
	void setSceneHandle(TSceneHandle *sceneHandle);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
signals:
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void curveChanged();
Shinya Kitaoka 3bfa54
	void curveIo(int type, TDoubleParam *curve, const std::string &name);
Toshihiro Shimizu 890ddd
	void editObject();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public slots:
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void refreshModel();
Toshihiro Shimizu 890ddd
	void rebuildModel();
Toshihiro Shimizu 890ddd
	void onFrameSwitched();
Toshihiro Shimizu 890ddd
	void toggleMode();
Toshihiro Shimizu 890ddd
	void onValueFieldChanged();
Toshihiro Shimizu 890ddd
	void onXsheetChanged();
Toshihiro Shimizu 890ddd
	void onStageObjectSwitched();
Toshihiro Shimizu 890ddd
	void onStageObjectChanged(bool isDragging = false);
Toshihiro Shimizu 890ddd
	void onFxSwitched();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onCurveChanged(bool isDragging);
Toshihiro Shimizu 890ddd
	void onCurveSelected(TDoubleParam *);
Toshihiro Shimizu 890ddd
	void onSelectionChanged();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void doSwitchCurrentObject(TStageObject *obj);
Toshihiro Shimizu 890ddd
	void doSwitchCurrentFx(TFx *fx);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//in order to avoid FunctionViewer to get focus while editing the expression
Toshihiro Shimizu 890ddd
	bool isExpressionPageActive();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	// Handles
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TXsheetHandle *m_xshHandle;
Toshihiro Shimizu 890ddd
	TFrameHandle *m_frameHandle;
Toshihiro Shimizu 890ddd
	TObjectHandle *m_objectHandle;
Toshihiro Shimizu 890ddd
	TFxHandle *m_fxHandle;
Toshihiro Shimizu 890ddd
	TColumnHandle *m_columnHandle;
Toshihiro Shimizu 890ddd
	TSceneHandle *m_sceneHandle;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TFrameHandle m_localFrame; //!< Internal timeline - which is attached to m_frameHandle
Toshihiro Shimizu 890ddd
							   //!  in case it is not zero.
Toshihiro Shimizu 890ddd
	// Widgets
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	FunctionTreeView *m_treeView;			//!< Tree view on the left side of the viewer.
Toshihiro Shimizu 890ddd
	FunctionToolbar *m_toolbar;				//!< Central area's toolbar
Toshihiro Shimizu 890ddd
	FunctionPanel *m_functionGraph;			//!< The function graph view widget.
Toshihiro Shimizu 890ddd
	FunctionSheet *m_numericalColumns;		//!< The numerical columns view widget.
Toshihiro Shimizu 890ddd
	FunctionSegmentViewer *m_segmentViewer; //!< Lower segment editor.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Current objects
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TDoubleParam *m_curve;
Toshihiro Shimizu 890ddd
	FunctionSelection *m_selection;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	void showEvent(QShowEvent *);
Toshihiro Shimizu 890ddd
	void hideEvent(QHideEvent *);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:												 //  :(
Toshihiro Shimizu 890ddd
	void emitCurveChanged() { emit curveChanged(); } //!< \deprecated  Should not be public.
Shinya Kitaoka 3bfa54
	void emitIoCurve(int type, TDoubleParam *curve, const std::string &name)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		emit curveIo(type, curve, name);
Toshihiro Shimizu 890ddd
	} //!< \deprecated  Should not be public.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private slots:
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void propagateExternalSetFrame(); //!< Forwards m_frameHandle's setFrame() invocations to m_localFrame.
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif // FUNCTIONEDITORVIEWER_H