|
shun-iwasawa |
98926d |
#pragma once
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
#ifndef TOONZVECTORBRUSHTOOL_H
|
|
shun-iwasawa |
98926d |
#define TOONZVECTORBRUSHTOOL_H
|
|
shun-iwasawa |
98926d |
|
|
|
fa009d |
#include <tgeometry.h></tgeometry.h>
|
|
|
fa009d |
#include <tproperty.h></tproperty.h>
|
|
|
fa009d |
#include <trasterimage.h></trasterimage.h>
|
|
|
fa009d |
#include <ttoonzimage.h></ttoonzimage.h>
|
|
|
fa009d |
#include <tstroke.h></tstroke.h>
|
|
|
fa009d |
#include <toonz strokegenerator.h=""></toonz>
|
|
|
fa009d |
|
|
|
fa009d |
#include <tools tool.h=""></tools>
|
|
|
fa009d |
#include <tools cursors.h=""></tools>
|
|
|
fa009d |
|
|
|
fa009d |
#include <tools inputmanager.h=""></tools>
|
|
|
fa009d |
#include <tools modifierline.h="" modifiers=""></tools>
|
|
|
fa009d |
#include <tools modifiers="" modifiertangents.h=""></tools>
|
|
|
fa009d |
#include <tools modifierassistants.h="" modifiers=""></tools>
|
|
|
fa009d |
#include <tools modifiers="" modifiersegmentation.h=""></tools>
|
|
|
fa009d |
#include <tools modifiers="" modifiersimplify.h=""></tools>
|
|
|
fa009d |
#include <tools modifiers="" modifiersmooth.h=""></tools>
|
|
|
fa009d |
#ifndef NDEBUG
|
|
|
fa009d |
#include <tools modifiers="" modifiertest.h=""></tools>
|
|
|
fa009d |
#endif
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
#include <qcoreapplication></qcoreapplication>
|
|
shun-iwasawa |
98926d |
#include <qradialgradient></qradialgradient>
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
//--------------------------------------------------------------
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
// Forward declarations
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
class TTileSetCM32;
|
|
shun-iwasawa |
98926d |
class TTileSaverCM32;
|
|
shun-iwasawa |
98926d |
class RasterStrokeGenerator;
|
|
shun-iwasawa |
98926d |
class BluredBrush;
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
//--------------------------------------------------------------
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
//************************************************************************
|
|
shun-iwasawa |
98926d |
// Brush Data declaration
|
|
shun-iwasawa |
98926d |
//************************************************************************
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
struct VectorBrushData final : public TPersist {
|
|
shun-iwasawa |
98926d |
PERSIST_DECLARATION(VectorBrushData)
|
|
shun-iwasawa |
98926d |
// frameRange, snapSensitivity and snap are not included
|
|
shun-iwasawa |
98926d |
// Those options are not really a part of the brush settings,
|
|
shun-iwasawa |
98926d |
// just the overall tool.
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
std::wstring m_name;
|
|
shun-iwasawa |
98926d |
double m_min, m_max, m_acc, m_smooth;
|
|
shun-iwasawa |
98926d |
bool m_breakAngles, m_pressure;
|
|
shun-iwasawa |
98926d |
int m_cap, m_join, m_miter;
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
VectorBrushData();
|
|
shun-iwasawa |
98926d |
VectorBrushData(const std::wstring &name);
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
bool operator<(const VectorBrushData &other) const {
|
|
shun-iwasawa |
98926d |
return m_name < other.m_name;
|
|
shun-iwasawa |
98926d |
}
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
void saveData(TOStream &os) override;
|
|
shun-iwasawa |
98926d |
void loadData(TIStream &is) override;
|
|
shun-iwasawa |
98926d |
};
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
//************************************************************************
|
|
shun-iwasawa |
98926d |
// Brush Preset Manager declaration
|
|
shun-iwasawa |
98926d |
//************************************************************************
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
class VectorBrushPresetManager {
|
|
shun-iwasawa |
98926d |
TFilePath m_fp; //!< Presets file path
|
|
shun-iwasawa |
98926d |
std::set<vectorbrushdata> m_presets; //!< Current presets container</vectorbrushdata>
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
public:
|
|
shun-iwasawa |
98926d |
VectorBrushPresetManager() {}
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
void load(const TFilePath &fp);
|
|
shun-iwasawa |
98926d |
void save();
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
const TFilePath &path() { return m_fp; };
|
|
shun-iwasawa |
98926d |
const std::set<vectorbrushdata> &presets() const { return m_presets; }</vectorbrushdata>
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
void addPreset(const VectorBrushData &data);
|
|
shun-iwasawa |
98926d |
void removePreset(const std::wstring &name);
|
|
shun-iwasawa |
98926d |
};
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
//************************************************************************
|
|
shun-iwasawa |
98926d |
// Brush Tool declaration
|
|
shun-iwasawa |
98926d |
//************************************************************************
|
|
shun-iwasawa |
98926d |
|
|
|
fa009d |
class ToonzVectorBrushTool final : public TTool,
|
|
|
fa009d |
public TInputHandler
|
|
|
fa009d |
{
|
|
shun-iwasawa |
085210 |
Q_DECLARE_TR_FUNCTIONS(ToonzVectorBrushTool)
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
public:
|
|
shun-iwasawa |
98926d |
ToonzVectorBrushTool(std::string name, int targetType);
|
|
shun-iwasawa |
98926d |
|
|
|
fa009d |
ToolType getToolType() const override
|
|
|
fa009d |
{ return TTool::LevelWriteTool; }
|
|
|
da847a |
unsigned int getToolHints() const override;
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
ToolOptionsBox *createOptionsBox() override;
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
void updateTranslation() override;
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
void onActivate() override;
|
|
shun-iwasawa |
98926d |
void onDeactivate() override;
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
bool preLeftButtonDown() override;
|
|
shun-iwasawa |
98926d |
void leftButtonDown(const TPointD &pos, const TMouseEvent &e) override;
|
|
shun-iwasawa |
98926d |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override;
|
|
shun-iwasawa |
98926d |
void leftButtonUp(const TPointD &pos, const TMouseEvent &e) override;
|
|
shun-iwasawa |
98926d |
void mouseMove(const TPointD &pos, const TMouseEvent &e) override;
|
|
shun-iwasawa |
98926d |
bool keyDown(QKeyEvent *event) override;
|
|
shun-iwasawa |
98926d |
|
|
|
fa009d |
void inputMouseMove(const TPointD &position,
|
|
|
fa009d |
const TInputState &state) override;
|
|
|
fa009d |
void inputSetBusy(bool busy) override;
|
|
|
fa009d |
void inputPaintTracks(const TTrackList &tracks) override;
|
|
|
fa009d |
void inputInvalidateRect(const TRectD &bounds) override { invalidate(bounds); }
|
|
|
fa009d |
TTool *inputGetTool() override { return this; };
|
|
|
fa009d |
|
|
shun-iwasawa |
98926d |
void draw() override;
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
void onEnter() override;
|
|
shun-iwasawa |
98926d |
void onLeave() override;
|
|
shun-iwasawa |
98926d |
|
|
manongjohn |
40a40e |
int getCursorId() const override {
|
|
manongjohn |
40a40e |
if (m_viewer && m_viewer->getGuidedStrokePickerMode())
|
|
manongjohn |
40a40e |
return m_viewer->getGuidedStrokePickerCursor();
|
|
manongjohn |
40a40e |
return ToolCursor::PenCursor;
|
|
manongjohn |
40a40e |
}
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
TPropertyGroup *getProperties(int targetType) override;
|
|
shun-iwasawa |
98926d |
bool onPropertyChanged(std::string propertyName) override;
|
|
shun-iwasawa |
98926d |
void resetFrameRange();
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
void initPresets();
|
|
shun-iwasawa |
98926d |
void loadPreset();
|
|
shun-iwasawa |
98926d |
void addPreset(QString name);
|
|
shun-iwasawa |
98926d |
void removePreset();
|
|
shun-iwasawa |
98926d |
|
|
manongjohn |
df5842 |
void loadLastBrush();
|
|
manongjohn |
df5842 |
|
|
shun-iwasawa |
98926d |
// return true if the pencil mode is active in the Brush / PaintBrush / Eraser
|
|
shun-iwasawa |
98926d |
// Tools.
|
|
shun-iwasawa |
98926d |
bool isPencilModeActive() override;
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
bool doFrameRangeStrokes(TFrameId firstFrameId, TStroke *firstStroke,
|
|
shun-iwasawa |
98926d |
TFrameId lastFrameId, TStroke *lastStroke,
|
|
manongjohn |
40a40e |
int interpolationType, bool breakAngles,
|
|
manongjohn |
40a40e |
bool autoGroup = false, bool autoFill = false,
|
|
manongjohn |
40a40e |
bool drawFirstStroke = true,
|
|
manongjohn |
40a40e |
bool drawLastStroke = true, bool withUndo = true);
|
|
manongjohn |
40a40e |
bool doGuidedAutoInbetween(TFrameId cFid, const TVectorImageP &cvi,
|
|
manongjohn |
40a40e |
TStroke *cStroke, bool breakAngles,
|
|
manongjohn |
40a40e |
bool autoGroup = false, bool autoFill = false,
|
|
manongjohn |
40a40e |
bool drawStroke = true);
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
protected:
|
|
|
fa009d |
typedef std::vector<strokegenerator> TrackList;</strokegenerator>
|
|
|
fa009d |
typedef std::vector<tstroke*> StrokeList;</tstroke*>
|
|
|
fa009d |
void deleteStrokes(StrokeList &strokes);
|
|
|
fa009d |
void copyStrokes(StrokeList &dst, const StrokeList &src);
|
|
|
fa009d |
|
|
|
fa009d |
void snap(const TPointD &pos, bool snapEnabled, bool withSelfSnap = false);
|
|
|
fa009d |
|
|
|
da847a |
void updateModifiers();
|
|
|
da847a |
|
|
|
fa009d |
enum MouseEventType { ME_DOWN, ME_DRAG, ME_UP, ME_MOVE };
|
|
|
fa009d |
void handleMouseEvent(MouseEventType type, const TPointD &pos,
|
|
|
fa009d |
const TMouseEvent &e);
|
|
|
fa009d |
|
|
|
fa009d |
protected:
|
|
shun-iwasawa |
98926d |
TPropertyGroup m_prop[2];
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
TDoublePairProperty m_thickness;
|
|
shun-iwasawa |
98926d |
TDoubleProperty m_accuracy;
|
|
shun-iwasawa |
98926d |
TDoubleProperty m_smooth;
|
|
shun-iwasawa |
98926d |
TEnumProperty m_preset;
|
|
shun-iwasawa |
98926d |
TBoolProperty m_breakAngles;
|
|
shun-iwasawa |
98926d |
TBoolProperty m_pressure;
|
|
shun-iwasawa |
98926d |
TBoolProperty m_snap;
|
|
shun-iwasawa |
98926d |
TEnumProperty m_frameRange;
|
|
shun-iwasawa |
98926d |
TEnumProperty m_snapSensitivity;
|
|
shun-iwasawa |
98926d |
TEnumProperty m_capStyle;
|
|
shun-iwasawa |
98926d |
TEnumProperty m_joinStyle;
|
|
shun-iwasawa |
98926d |
TIntProperty m_miterJoinLimit;
|
|
|
fa009d |
TBoolProperty m_assistants;
|
|
|
fa009d |
|
|
|
fa009d |
TInputManager m_inputmanager;
|
|
|
fa009d |
TSmartPointerT<tmodifierline> m_modifierLine;</tmodifierline>
|
|
|
fa009d |
TSmartPointerT<tmodifiertangents> m_modifierTangents;</tmodifiertangents>
|
|
|
fa009d |
TSmartPointerT<tmodifierassistants> m_modifierAssistants;</tmodifierassistants>
|
|
|
fa009d |
TSmartPointerT<tmodifiersegmentation> m_modifierSegmentation;</tmodifiersegmentation>
|
|
|
fa009d |
TSmartPointerT<tmodifiersegmentation> m_modifierSmoothSegmentation;</tmodifiersegmentation>
|
|
|
fa009d |
TSmartPointerT<tmodifiersmooth> m_modifierSmooth[3];</tmodifiersmooth>
|
|
|
fa009d |
TSmartPointerT<tmodifiersimplify> m_modifierSimplify;</tmodifiersimplify>
|
|
|
fa009d |
#ifndef NDEBUG
|
|
|
fa009d |
TSmartPointerT<tmodifiertest> m_modifierTest;</tmodifiertest>
|
|
|
fa009d |
#endif
|
|
|
da847a |
TInputModifier::List m_modifierReplicate;
|
|
|
fa009d |
|
|
|
fa009d |
TrackList m_tracks;
|
|
|
fa009d |
TrackList m_rangeTracks;
|
|
|
fa009d |
StrokeList m_firstStrokes;
|
|
shun-iwasawa |
98926d |
TFrameId m_firstFrameId, m_veryFirstFrameId;
|
|
shun-iwasawa |
98926d |
TPixel32 m_currentColor;
|
|
|
da847a |
int m_styleId;
|
|
shun-iwasawa |
98926d |
double m_minThick, m_maxThick;
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
// for snapping and framerange
|
|
|
fa009d |
int m_col, m_firstFrame, m_veryFirstFrame,
|
|
shun-iwasawa |
98926d |
m_veryFirstCol, m_targetType;
|
|
|
fa009d |
double m_pixelSize, m_minDistance2;
|
|
|
fa009d |
|
|
|
fa009d |
bool m_snapped;
|
|
|
fa009d |
bool m_snappedSelf;
|
|
|
fa009d |
TPointD m_snapPoint;
|
|
|
fa009d |
TPointD m_snapPointSelf;
|
|
|
fa009d |
|
|
|
fa009d |
TPointD m_mousePos; //!< Current mouse position, in world coordinates.
|
|
|
fa009d |
TPointD m_brushPos; //!< World position the brush will be painted at.
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
VectorBrushPresetManager
|
|
shun-iwasawa |
98926d |
m_presetsManager; //!< Manager for presets of this tool instance
|
|
shun-iwasawa |
98926d |
|
|
|
fa009d |
bool m_active, m_firstTime, m_isPath,
|
|
|
fa009d |
m_presetsLoaded, m_firstFrameRange;
|
|
manongjohn |
5a2268 |
|
|
|
fa009d |
bool m_propertyUpdating;
|
|
shun-iwasawa |
98926d |
};
|
|
shun-iwasawa |
98926d |
|
|
shun-iwasawa |
98926d |
#endif // TOONZVECTORBRUSHTOOL_H
|