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