|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
98926d |
#ifndef TOONZRASTERBRUSHTOOL_H
|
|
shun-iwasawa |
98926d |
#define TOONZRASTERBRUSHTOOL_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"
|
|
Jeremy Bullock |
cd00fd |
#include "tstroke.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/strokegenerator.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/tool.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/cursors.h"
|
|
shun-iwasawa |
98926d |
#include "mypainttoonzbrush.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <qcoreapplication></qcoreapplication>
|
|
Toshihiro Shimizu |
890ddd |
#include <qradialgradient></qradialgradient>
|
|
shun-iwasawa |
98926d |
#include <qelapsedtimer></qelapsedtimer>
|
|
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;
|
|
shun-iwasawa |
98926d |
class ToonzRasterBrushToolNotifier;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
shun-iwasawa |
98926d |
// Toonz Raster Brush Data declaration
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
struct BrushData final : public TPersist {
|
|
Shinya Kitaoka |
120a6e |
PERSIST_DECLARATION(BrushData)
|
|
Jeremy Bullock |
e84aac |
// frameRange, snapSensitivity and snap are not included
|
|
shun-iwasawa |
7f1e30 |
// Those options are not really a part of the brush settings,
|
|
shun-iwasawa |
7f1e30 |
// just the overall tool.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::wstring m_name;
|
|
shun-iwasawa |
98926d |
double m_min, m_max, m_smooth, m_hardness, m_opacityMin, m_opacityMax;
|
|
shun-iwasawa |
98926d |
bool m_pencil, m_pressure;
|
|
shun-iwasawa |
98926d |
int m_drawOrder;
|
|
|
bf1d82 |
double m_modifierSize, m_modifierOpacity;
|
|
|
572ed1 |
bool m_modifierEraser, m_modifierLockAlpha;
|
|
|
9380d5 |
bool m_assistants;
|
|
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 |
473e70 |
void saveData(TOStream &os) override;
|
|
Shinya Kitaoka |
473e70 |
void loadData(TIStream &is) override;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
shun-iwasawa |
98926d |
// Toonz Raster 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 |
//************************************************************************
|
|
walkerka |
57fb3c |
// Smooth Stroke declaration
|
|
walkerka |
57fb3c |
// Brush stroke smoothing buffer.
|
|
walkerka |
57fb3c |
//************************************************************************
|
|
walkerka |
22f456 |
class SmoothStroke {
|
|
walkerka |
57fb3c |
public:
|
|
walkerka |
22f456 |
SmoothStroke() {}
|
|
walkerka |
22f456 |
~SmoothStroke() {}
|
|
walkerka |
22f456 |
|
|
walkerka |
22f456 |
// begin stroke
|
|
walkerka |
22f456 |
// smooth is smooth strength, from 0 to 100
|
|
walkerka |
22f456 |
void beginStroke(int smooth);
|
|
walkerka |
22f456 |
// add stroke point
|
|
walkerka |
22f456 |
void addPoint(const TThickPoint &point);
|
|
walkerka |
22f456 |
// end stroke
|
|
walkerka |
22f456 |
void endStroke();
|
|
walkerka |
22f456 |
// Get generated stroke points which has been smoothed.
|
|
walkerka |
22f456 |
// Both addPoint() and endStroke() generate new smoothed points.
|
|
walkerka |
22f456 |
// This method will removed generated points
|
|
walkerka |
22f456 |
void getSmoothPoints(std::vector<tthickpoint> &smoothPoints);</tthickpoint>
|
|
Jeremy Bullock |
7f2044 |
// Remove all points - used for straight lines
|
|
Jeremy Bullock |
7f2044 |
void clearPoints();
|
|
walkerka |
57fb3c |
|
|
walkerka |
57fb3c |
private:
|
|
walkerka |
22f456 |
void generatePoints();
|
|
walkerka |
57fb3c |
|
|
walkerka |
57fb3c |
private:
|
|
walkerka |
22f456 |
int m_smooth;
|
|
walkerka |
22f456 |
int m_outputIndex;
|
|
walkerka |
22f456 |
int m_readIndex;
|
|
walkerka |
22f456 |
std::vector<tthickpoint> m_rawPoints;</tthickpoint>
|
|
walkerka |
22f456 |
std::vector<tthickpoint> m_outputPoints;</tthickpoint>
|
|
shun-iwasawa |
28636d |
|
|
shun-iwasawa |
28636d |
int m_resampledIndex;
|
|
shun-iwasawa |
28636d |
std::vector<tthickpoint> m_resampledPoints;</tthickpoint>
|
|
walkerka |
57fb3c |
};
|
|
walkerka |
57fb3c |
//************************************************************************
|
|
shun-iwasawa |
98926d |
// Toonz Raster Brush Tool declaration
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
98926d |
class ToonzRasterBrushTool final : public TTool, public RasterController {
|
|
shun-iwasawa |
98926d |
Q_DECLARE_TR_FUNCTIONS(ToonzRasterBrushTool)
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
void updateCurrentStyle();
|
|
shun-iwasawa |
98926d |
double restartBrushTimer();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
shun-iwasawa |
98926d |
ToonzRasterBrushTool(std::string name, int targetType);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
ToolType getToolType() const override { return TTool::LevelWriteTool; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
ToolOptionsBox *createOptionsBox() override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void updateTranslation() override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void onActivate() override;
|
|
Shinya Kitaoka |
473e70 |
void onDeactivate() override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
bool preLeftButtonDown() override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDown(const TPointD &pos, const TMouseEvent &e) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonUp(const TPointD &pos, const TMouseEvent &e) override;
|
|
Shinya Kitaoka |
473e70 |
void mouseMove(const TPointD &pos, const TMouseEvent &e) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void draw() override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void onEnter() override;
|
|
Shinya Kitaoka |
473e70 |
void onLeave() override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
int getCursorId() const override { return ToolCursor::PenCursor; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
TPropertyGroup *getProperties(int targetType) override;
|
|
Shinya Kitaoka |
473e70 |
bool onPropertyChanged(std::string propertyName) override;
|
|
Shinya Kitaoka |
473e70 |
void onImageChanged() override;
|
|
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 |
|
|
manongjohn |
df5842 |
void loadLastBrush();
|
|
manongjohn |
df5842 |
|
|
shun-iwasawa |
600da6 |
void finishRasterBrush(const TPointD &pos, double pressureVal);
|
|
Shinya Kitaoka |
120a6e |
// return true if the pencil mode is active in the Brush / PaintBrush / Eraser
|
|
Shinya Kitaoka |
120a6e |
// Tools.
|
|
Shinya Kitaoka |
473e70 |
bool isPencilModeActive() override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
98926d |
void onColorStyleChanged();
|
|
shun-iwasawa |
98926d |
bool askRead(const TRect &rect) override;
|
|
shun-iwasawa |
98926d |
bool askWrite(const TRect &rect) override;
|
|
shun-iwasawa |
98926d |
bool isMyPaintStyleSelected() { return m_isMyPaintStyleSelected; }
|
|
walkerka |
57fb3c |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
TPropertyGroup m_prop[2];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TDoublePairProperty m_rasThickness;
|
|
walkerka |
bb91cd |
TDoubleProperty m_smooth;
|
|
Shinya Kitaoka |
120a6e |
TDoubleProperty m_hardness;
|
|
Shinya Kitaoka |
120a6e |
TEnumProperty m_preset;
|
|
shun-iwasawa |
975eb1 |
TEnumProperty m_drawOrder;
|
|
Shinya Kitaoka |
120a6e |
TBoolProperty m_pencil;
|
|
Shinya Kitaoka |
120a6e |
TBoolProperty m_pressure;
|
|
shun-iwasawa |
98926d |
TDoubleProperty m_modifierSize;
|
|
manongjohn |
f936c0 |
TBoolProperty m_modifierLockAlpha;
|
|
shun-iwasawa |
98926d |
|
|
Shinya Kitaoka |
120a6e |
RasterStrokeGenerator *m_rasterTrack;
|
|
Shinya Kitaoka |
120a6e |
TTileSetCM32 *m_tileSet;
|
|
Shinya Kitaoka |
120a6e |
TTileSaverCM32 *m_tileSaver;
|
|
Shinya Kitaoka |
120a6e |
TPixel32 m_currentColor;
|
|
Shinya Kitaoka |
120a6e |
int m_styleId;
|
|
Shinya Kitaoka |
120a6e |
double m_minThick, m_maxThick;
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
98926d |
int m_targetType;
|
|
Shinya Kitaoka |
120a6e |
TPointD m_dpiScale,
|
|
Shinya Kitaoka |
120a6e |
m_mousePos, //!< Current mouse position, in world coordinates.
|
|
shun-iwasawa |
98926d |
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>
|
|
shun-iwasawa |
98926d |
TRect m_strokeRect, m_lastRect,
|
|
shun-iwasawa |
98926d |
m_strokeSegmentRect; // used with mypaint brush
|
|
Shinya Kitaoka |
120a6e |
|
|
walkerka |
bb91cd |
SmoothStroke m_smoothStroke;
|
|
walkerka |
bb91cd |
|
|
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
|
|
walkerka |
22f456 |
//! substitution.
|
|
shun-iwasawa |
98926d |
m_firstTime, 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 |
|
|
shun-iwasawa |
98926d |
ToonzRasterBrushToolNotifier *m_notifier;
|
|
shun-iwasawa |
98926d |
bool m_isMyPaintStyleSelected = false;
|
|
shun-iwasawa |
98926d |
MyPaintToonzBrush *m_toonz_brush = 0;
|
|
shun-iwasawa |
98926d |
QElapsedTimer m_brushTimer;
|
|
shun-iwasawa |
98926d |
int m_minCursorThick, m_maxCursorThick;
|
|
shun-iwasawa |
98926d |
|
|
manongjohn |
5a2268 |
bool m_propertyUpdating = false;
|
|
manongjohn |
5a2268 |
|
|
justburner |
e250b7 |
bool m_isStraight = false;
|
|
justburner |
e250b7 |
TPointD m_firstPoint;
|
|
justburner |
e250b7 |
TPointD m_lastPoint;
|
|
justburner |
e250b7 |
double m_maxPressure = -1.0;
|
|
justburner |
e250b7 |
|
|
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);
|
|
Martin van Zijl |
e9b900 |
|
|
manongjohn |
fe8e5c |
TPointD getCenteredCursorPos(const TPointD &originalCursorPos);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
98926d |
//------------------------------------------------------------
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
class ToonzRasterBrushToolNotifier final : public QObject {
|
|
shun-iwasawa |
98926d |
Q_OBJECT
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
ToonzRasterBrushTool *m_tool;
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
public:
|
|
shun-iwasawa |
98926d |
ToonzRasterBrushToolNotifier(ToonzRasterBrushTool *tool);
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
protected slots:
|
|
shun-iwasawa |
98926d |
// void onCanvasSizeChanged() { m_tool->onCanvasSizeChanged(); }
|
|
shun-iwasawa |
98926d |
void onColorStyleChanged() { m_tool->onColorStyleChanged(); }
|
|
shun-iwasawa |
98926d |
};
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
#endif // TOONZRASTERBRUSHTOOL_H
|