|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef _EDITTOOLGADGETS_H_
|
|
Toshihiro Shimizu |
890ddd |
#define _EDITTOOLGADGETS_H_
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tgeometry.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tgl.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzBase includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamchange.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tdoubleparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamset.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Qt includes
|
|
Toshihiro Shimizu |
890ddd |
#include <qobject></qobject>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Forward declarations
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TMouseEvent;
|
|
Toshihiro Shimizu |
890ddd |
class TFxHandle;
|
|
Toshihiro Shimizu |
890ddd |
class TTool;
|
|
Toshihiro Shimizu |
890ddd |
class FxParamsGraphicEditor;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class FxGadgetController;
|
|
Toshihiro Shimizu |
890ddd |
class TUndo;
|
|
Toshihiro Shimizu |
890ddd |
class TParamUIConcept;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class FxGadget : public TParamObserver {
|
|
Shinya Kitaoka |
120a6e |
GLuint m_id;
|
|
Shinya Kitaoka |
120a6e |
bool m_selected;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::vector<tdoubleparamp> m_params;</tdoubleparamp>
|
|
Shinya Kitaoka |
120a6e |
double m_pixelSize;
|
|
Shinya Kitaoka |
120a6e |
std::string m_label;
|
|
Shinya Kitaoka |
120a6e |
TUndo *m_undo;
|
|
Shinya Kitaoka |
120a6e |
double m_scaleFactor;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
FxGadgetController *m_controller;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
static GLdouble m_selectedColor[3]; // rgb
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
FxGadget(FxGadgetController *controller);
|
|
Shinya Kitaoka |
120a6e |
virtual ~FxGadget();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setLabel(std::string label) { m_label = label; }
|
|
Shinya Kitaoka |
120a6e |
std::string getLabel() const { return m_label; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
FxGadgetController *getController() const { return m_controller; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void addParam(const TDoubleParamP ¶m);
|
|
Shinya Kitaoka |
120a6e |
double getValue(const TDoubleParamP ¶m) const;
|
|
Shinya Kitaoka |
120a6e |
void setValue(const TDoubleParamP ¶m, double value);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPointD getValue(const TPointParamP ¶m) const;
|
|
Shinya Kitaoka |
120a6e |
void setValue(const TPointParamP ¶m, const TPointD &pos);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setId(GLuint id) { m_id = id; }
|
|
Shinya Kitaoka |
120a6e |
GLuint getId() const { return m_id; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void select(bool selected) { m_selected = selected; }
|
|
Shinya Kitaoka |
120a6e |
bool isSelected() const { return m_selected; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setPixelSize(); // uses tglGetPixelSize2()
|
|
Shinya Kitaoka |
120a6e |
void setPixelSize(double pixelSize) { m_pixelSize = pixelSize; }
|
|
Shinya Kitaoka |
120a6e |
inline double getPixelSize() const { return m_pixelSize; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void drawDot(const TPointD &pos);
|
|
Shinya Kitaoka |
120a6e |
void drawDot(double x, double y) { drawDot(TPointD(x, y)); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void drawTooltip(const TPointD &tooltipPos, std::string tooltipPosText);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual void draw(bool picking) = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual void leftButtonDown(const TPointD &pos, const TMouseEvent &) {}
|
|
Shinya Kitaoka |
120a6e |
virtual void leftButtonDrag(const TPointD &pos, const TMouseEvent &) {}
|
|
Shinya Kitaoka |
120a6e |
virtual void leftButtonUp(const TPointD &pos, const TMouseEvent &) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void onChange(const TParamChange &);
|
|
Shinya Kitaoka |
120a6e |
void createUndo();
|
|
Shinya Kitaoka |
120a6e |
void commitUndo();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setScaleFactor(double s) { m_scaleFactor = s; }
|
|
Shinya Kitaoka |
120a6e |
double getScaleFactor() const { return m_scaleFactor; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace EditToolGadgets {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// DragTool
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DragTool {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
virtual void leftButtonDown(const TPointD &pos, const TMouseEvent &) = 0;
|
|
Shinya Kitaoka |
120a6e |
virtual void leftButtonDrag(const TPointD &pos, const TMouseEvent &) = 0;
|
|
Shinya Kitaoka |
120a6e |
virtual void leftButtonUp(const TPointD &pos, const TMouseEvent &) = 0;
|
|
Shinya Kitaoka |
120a6e |
virtual ~DragTool() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual void enableGlobalKeyframes(bool enabled) {}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // EditToolGadgets namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class FxGadgetController : public QObject {
|
|
Shinya Kitaoka |
120a6e |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TTool *m_tool;
|
|
Shinya Kitaoka |
120a6e |
TFxHandle *m_fxHandle;
|
|
Shinya Kitaoka |
120a6e |
std::vector<fxgadget *=""> m_gadgets;</fxgadget>
|
|
Shinya Kitaoka |
120a6e |
unsigned long m_idBase, m_nextId;
|
|
Shinya Kitaoka |
120a6e |
std::map<gluint, *="" fxgadget=""> m_idTable;</gluint,>
|
|
Shinya Kitaoka |
120a6e |
FxGadget *m_selectedGadget;
|
|
Shinya Kitaoka |
120a6e |
bool m_editingNonZeraryFx;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
FxGadgetController(TTool *tool);
|
|
Shinya Kitaoka |
120a6e |
~FxGadgetController();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void clearGadgets();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TAffine getMatrix();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void draw(bool picking = false);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void selectById(unsigned int id);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
EditToolGadgets::DragTool *createDragTool(int gadgetId);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void assignId(FxGadget *gadget);
|
|
Shinya Kitaoka |
120a6e |
void addGadget(FxGadget *gadget);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int getCurrentFrame() const;
|
|
Shinya Kitaoka |
120a6e |
void invalidateViewer();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool isEditingNonZeraryFx() const { return m_editingNonZeraryFx; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool hasGadget() { return m_gadgets.size() != 0; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public slots:
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void onFxSwitched();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
FxGadget *allocateGadget(const TParamUIConcept &uiConcept);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|