|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef BRUSHTOOL_H
|
|
Toshihiro Shimizu |
890ddd |
#define BRUSHTOOL_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tgeometry.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tproperty.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trasterimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ttoonzimage.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/strokegenerator.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/tool.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/cursors.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <qcoreapplication></qcoreapplication>
|
|
Toshihiro Shimizu |
890ddd |
#include <qradialgradient></qradialgradient>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Forward declarations
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TTileSetCM32;
|
|
Toshihiro Shimizu |
890ddd |
class TTileSaverCM32;
|
|
Toshihiro Shimizu |
890ddd |
class RasterStrokeGenerator;
|
|
Toshihiro Shimizu |
890ddd |
class BluredBrush;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Brush Data declaration
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
struct BrushData : public TPersist {
|
|
Toshihiro Shimizu |
890ddd |
PERSIST_DECLARATION(BrushData)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::wstring m_name;
|
|
Toshihiro Shimizu |
890ddd |
double m_min, m_max, m_acc, m_hardness, m_opacityMin, m_opacityMax;
|
|
Toshihiro Shimizu |
890ddd |
bool m_selective, m_pencil, m_breakAngles, m_pressure;
|
|
Toshihiro Shimizu |
890ddd |
int m_cap, m_join, m_miter;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
BrushData();
|
|
Toshihiro Shimizu |
890ddd |
BrushData(const std::wstring &name);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool operator<(const BrushData &other) const { return m_name < other.m_name; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void saveData(TOStream &os);
|
|
Toshihiro Shimizu |
890ddd |
void loadData(TIStream &is);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Brush Preset Manager declaration
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class BrushPresetManager
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFilePath m_fp; //!< Presets file path
|
|
Toshihiro Shimizu |
890ddd |
std::set<brushdata> m_presets; //!< Current presets container</brushdata>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
BrushPresetManager() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void load(const TFilePath &fp);
|
|
Toshihiro Shimizu |
890ddd |
void save();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const TFilePath &path() { return m_fp; };
|
|
Toshihiro Shimizu |
890ddd |
const std::set<brushdata> &presets() const { return m_presets; }</brushdata>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void addPreset(const BrushData &data);
|
|
Shinya Kitaoka |
3bfa54 |
void removePreset(const std::wstring &name);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Brush Tool declaration
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class BrushTool : public TTool
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Q_DECLARE_TR_FUNCTIONS(BrushTool)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
3bfa54 |
BrushTool(std::string name, int targetType);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToolType getToolType() const { return TTool::LevelWriteTool; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToolOptionsBox *createOptionsBox();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void updateTranslation();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void onActivate();
|
|
Toshihiro Shimizu |
890ddd |
void onDeactivate();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool preLeftButtonDown();
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDown(const TPointD &pos, const TMouseEvent &e);
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &e);
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonUp(const TPointD &pos, const TMouseEvent &e);
|
|
Toshihiro Shimizu |
890ddd |
void mouseMove(const TPointD &pos, const TMouseEvent &e);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void draw();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void onEnter();
|
|
Toshihiro Shimizu |
890ddd |
void onLeave();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getCursorId() const { return ToolCursor::PenCursor; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPropertyGroup *getProperties(int targetType);
|
|
Shinya Kitaoka |
3bfa54 |
bool onPropertyChanged(std::string propertyName);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void onImageChanged();
|
|
Toshihiro Shimizu |
890ddd |
void setWorkAndBackupImages();
|
|
Toshihiro Shimizu |
890ddd |
void updateWorkAndBackupRasters(const TRect &rect);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void initPresets();
|
|
Toshihiro Shimizu |
890ddd |
void loadPreset();
|
|
Toshihiro Shimizu |
890ddd |
void addPreset(QString name);
|
|
Toshihiro Shimizu |
890ddd |
void removePreset();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void finishRasterBrush(const TPointD &pos, int pressureVal);
|
|
Toshihiro Shimizu |
890ddd |
//return true if the pencil mode is active in the Brush / PaintBrush / Eraser Tools.
|
|
Toshihiro Shimizu |
890ddd |
bool isPencilModeActive();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
TPropertyGroup m_prop[2];
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDoublePairProperty m_thickness;
|
|
Toshihiro Shimizu |
890ddd |
TDoublePairProperty m_rasThickness;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleProperty m_accuracy;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleProperty m_hardness;
|
|
Toshihiro Shimizu |
890ddd |
TEnumProperty m_preset;
|
|
Toshihiro Shimizu |
890ddd |
TBoolProperty m_selective;
|
|
Toshihiro Shimizu |
890ddd |
TBoolProperty m_breakAngles;
|
|
Toshihiro Shimizu |
890ddd |
TBoolProperty m_pencil;
|
|
Toshihiro Shimizu |
890ddd |
TBoolProperty m_pressure;
|
|
Toshihiro Shimizu |
890ddd |
TEnumProperty m_capStyle;
|
|
Toshihiro Shimizu |
890ddd |
TEnumProperty m_joinStyle;
|
|
Toshihiro Shimizu |
890ddd |
TIntProperty m_miterJoinLimit;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
StrokeGenerator m_track;
|
|
Toshihiro Shimizu |
890ddd |
RasterStrokeGenerator *m_rasterTrack;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TTileSetCM32 *m_tileSet;
|
|
Toshihiro Shimizu |
890ddd |
TTileSaverCM32 *m_tileSaver;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPixel32 m_currentColor;
|
|
Toshihiro Shimizu |
890ddd |
int m_styleId;
|
|
Toshihiro Shimizu |
890ddd |
double m_minThick, m_maxThick;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRectD m_modifiedRegion;
|
|
Toshihiro Shimizu |
890ddd |
TPointD m_dpiScale,
|
|
Toshihiro Shimizu |
890ddd |
m_mousePos, //!< Current mouse position, in world coordinates.
|
|
Toshihiro Shimizu |
890ddd |
m_brushPos; //!< World position the brush will be painted at.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
BluredBrush *m_bluredBrush;
|
|
Toshihiro Shimizu |
890ddd |
QRadialGradient m_brushPad;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRasterCM32P m_backupRas;
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P m_workRas;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tthickpoint> m_points;</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
TRect m_strokeRect,
|
|
Toshihiro Shimizu |
890ddd |
m_lastRect;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
BrushPresetManager m_presetsManager; //!< Manager for presets of this tool instance
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool m_active,
|
|
Toshihiro Shimizu |
890ddd |
m_enabled,
|
|
Toshihiro Shimizu |
890ddd |
m_isPrompting, //!< Whether the tool is prompting for spline substitution.
|
|
Toshihiro Shimizu |
890ddd |
m_firstTime,
|
|
Toshihiro Shimizu |
890ddd |
m_isPath,
|
|
Toshihiro Shimizu |
890ddd |
m_presetsLoaded;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*--- 作業中のFrameIdをクリック時に保存し、マウスリリース時(Undoの登録時)に別のフレームに
|
|
Toshihiro Shimizu |
890ddd |
移動していたときの不具合を修正する。---*/
|
|
Toshihiro Shimizu |
890ddd |
TFrameId m_workingFrameId;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
static void drawLine(const TPointD &point, const TPointD ¢re, bool horizontal, bool isDecimal);
|
|
Toshihiro Shimizu |
890ddd |
static void drawEmptyCircle(TPointD point, int thick, bool isLxEven, bool isLyEven, bool isPencil);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif //BRUSHTOOL_H
|