|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tstroke.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/toolutils.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/tool.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tmathutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/cursors.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "drawutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tcolorstyles.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tundo.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tvectorimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ttoonzimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tproperty.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/strokegenerator.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/ttilesaver.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshsimplelevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/observer.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzimageutils.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/levelproperties.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/stage2.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/ttileset.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/rasterstrokegenerator.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tgl.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tenv.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "trop.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tinbetween.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ttile.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tpalettehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheethandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevelhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tframehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/toolhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/toolutils.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// For Qt translation support
|
|
Toshihiro Shimizu |
890ddd |
#include <qcoreapplication></qcoreapplication>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using namespace ToolUtils;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#define LINES L"Lines"
|
|
Toshihiro Shimizu |
890ddd |
#define AREAS L"Areas"
|
|
Toshihiro Shimizu |
890ddd |
#define ALL L"Lines & Areas"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#define NORMALERASE L"Normal"
|
|
Toshihiro Shimizu |
890ddd |
#define RECTERASE L"Rectangular"
|
|
Toshihiro Shimizu |
890ddd |
#define FREEHANDERASE L"Freehand"
|
|
Toshihiro Shimizu |
890ddd |
#define POLYLINEERASE L"Polyline"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TEnv::StringVar PaintBrushColorType("InknpaintPaintBrushColorType", "Areas");
|
|
Toshihiro Shimizu |
890ddd |
TEnv::IntVar PaintBrushSelective("InknpaintPaintBrushSelective", 0);
|
|
Toshihiro Shimizu |
890ddd |
TEnv::DoubleVar PaintBrushSize("InknpaintPaintBrushSize", 10);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const int BackgroundStyle = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class BrushUndo : public TRasterUndo
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tthickpoint> m_points;</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
int m_styleId;
|
|
Toshihiro Shimizu |
890ddd |
bool m_selective;
|
|
Toshihiro Shimizu |
890ddd |
ColorType m_colorType;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
3bfa54 |
BrushUndo(TTileSetCM32 *tileSet, const std::vector<tthickpoint> &points,</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
ColorType colorType, int styleId, bool selective,
|
|
Toshihiro Shimizu |
890ddd |
TXshSimpleLevel *level,
|
|
Toshihiro Shimizu |
890ddd |
const TFrameId &frameId)
|
|
Toshihiro Shimizu |
890ddd |
: TRasterUndo(tileSet, level, frameId, false, false, 0), m_points(points), m_styleId(styleId), m_selective(selective), m_colorType(colorType)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void redo() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TToonzImageP image = m_level->getFrame(m_frameId, true);
|
|
Toshihiro Shimizu |
890ddd |
TRasterCM32P ras = image->getRaster();
|
|
Toshihiro Shimizu |
890ddd |
RasterStrokeGenerator m_rasterTrack(ras, PAINTBRUSH, m_colorType, m_styleId, m_points[0], m_selective, 0, false);
|
|
Toshihiro Shimizu |
890ddd |
m_rasterTrack.setPointsSequence(m_points);
|
|
Toshihiro Shimizu |
890ddd |
m_rasterTrack.generateStroke(true);
|
|
Toshihiro Shimizu |
890ddd |
image->setSavebox(image->getSavebox() + m_rasterTrack.getBBox(m_rasterTrack.getPointsSequence()));
|
|
Toshihiro Shimizu |
890ddd |
ToolUtils::updateSaveBox();
|
|
Toshihiro Shimizu |
890ddd |
TTool::getApplication()->getCurrentXsheet()->notifyXsheetChanged();
|
|
Toshihiro Shimizu |
890ddd |
notifyImageChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getSize() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return sizeof(*this) + TRasterUndo::getSize();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
virtual QString getToolName()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return QString("Paint Brush Tool");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
int getHistoryType()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return HistoryType::PaintBrushTool;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void drawLine(const TPointD &point, const TPointD ¢re, bool horizontal, bool isDecimal)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!isDecimal) {
|
|
Toshihiro Shimizu |
890ddd |
if (horizontal) {
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.x - 1.5, point.y + 0.5) + centre, TPointD(point.x - 0.5, point.y + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.y - 0.5, -point.x + 1.5) + centre, TPointD(point.y - 0.5, -point.x + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.x + 0.5, -point.y + 0.5) + centre, TPointD(-point.x - 0.5, -point.y + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.y - 0.5, point.x - 0.5) + centre, TPointD(-point.y - 0.5, point.x + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.y - 0.5, point.x + 0.5) + centre, TPointD(point.y - 0.5, point.x - 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.x - 0.5, -point.y + 0.5) + centre, TPointD(point.x - 1.5, -point.y + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.y - 0.5, -point.x + 0.5) + centre, TPointD(-point.y - 0.5, -point.x + 1.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.x - 0.5, point.y + 0.5) + centre, TPointD(-point.x + 0.5, point.y + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.x - 1.5, point.y + 1.5) + centre, TPointD(point.x - 1.5, point.y + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.x - 1.5, point.y + 0.5) + centre, TPointD(point.x - 0.5, point.y + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.y + 0.5, -point.x + 1.5) + centre, TPointD(point.y - 0.5, -point.x + 1.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.y - 0.5, -point.x + 1.5) + centre, TPointD(point.y - 0.5, -point.x + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.x + 0.5, -point.y - 0.5) + centre, TPointD(-point.x + 0.5, -point.y + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.x + 0.5, -point.y + 0.5) + centre, TPointD(-point.x - 0.5, -point.y + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.y - 1.5, point.x - 0.5) + centre, TPointD(-point.y - 0.5, point.x - 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.y - 0.5, point.x - 0.5) + centre, TPointD(-point.y - 0.5, point.x + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.y + 0.5, point.x - 0.5) + centre, TPointD(point.y - 0.5, point.x - 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.y - 0.5, point.x - 0.5) + centre, TPointD(point.y - 0.5, point.x + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.x - 1.5, -point.y - 0.5) + centre, TPointD(point.x - 1.5, -point.y + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.x - 1.5, -point.y + 0.5) + centre, TPointD(point.x - 0.5, -point.y + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.y - 1.5, -point.x + 1.5) + centre, TPointD(-point.y - 0.5, -point.x + 1.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.y - 0.5, -point.x + 1.5) + centre, TPointD(-point.y - 0.5, -point.x + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.x + 0.5, point.y + 1.5) + centre, TPointD(-point.x + 0.5, point.y + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.x + 0.5, point.y + 0.5) + centre, TPointD(-point.x - 0.5, point.y + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
if (horizontal) {
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.x - 0.5, point.y + 0.5) + centre, TPointD(point.x + 0.5, point.y + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.y + 0.5, point.x - 0.5) + centre, TPointD(point.y + 0.5, point.x + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.y + 0.5, -point.x + 0.5) + centre, TPointD(point.y + 0.5, -point.x - 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.x + 0.5, -point.y - 0.5) + centre, TPointD(point.x - 0.5, -point.y - 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.x - 0.5, -point.y - 0.5) + centre, TPointD(-point.x + 0.5, -point.y - 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.y - 0.5, -point.x + 0.5) + centre, TPointD(-point.y - 0.5, -point.x - 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.y - 0.5, point.x - 0.5) + centre, TPointD(-point.y - 0.5, point.x + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.x + 0.5, point.y + 0.5) + centre, TPointD(-point.x - 0.5, point.y + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.x - 0.5, point.y + 1.5) + centre, TPointD(point.x - 0.5, point.y + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.x - 0.5, point.y + 0.5) + centre, TPointD(point.x + 0.5, point.y + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.y + 1.5, point.x - 0.5) + centre, TPointD(point.y + 0.5, point.x - 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.y + 0.5, point.x - 0.5) + centre, TPointD(point.y + 0.5, point.x + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.y + 1.5, -point.x + 0.5) + centre, TPointD(point.y + 0.5, -point.x + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.y + 0.5, -point.x + 0.5) + centre, TPointD(point.y + 0.5, -point.x - 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.x - 0.5, -point.y - 1.5) + centre, TPointD(point.x - 0.5, -point.y - 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(point.x - 0.5, -point.y - 0.5) + centre, TPointD(point.x + 0.5, -point.y - 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.x + 0.5, -point.y - 1.5) + centre, TPointD(-point.x + 0.5, -point.y - 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.x + 0.5, -point.y - 0.5) + centre, TPointD(-point.x - 0.5, -point.y - 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.y - 1.5, -point.x + 0.5) + centre, TPointD(-point.y - 0.5, -point.x + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.y - 0.5, -point.x + 0.5) + centre, TPointD(-point.y - 0.5, -point.x - 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.y - 1.5, point.x - 0.5) + centre, TPointD(-point.y - 0.5, point.x - 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.y - 0.5, point.x - 0.5) + centre, TPointD(-point.y - 0.5, point.x + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.x + 0.5, point.y + 1.5) + centre, TPointD(-point.x + 0.5, point.y + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(-point.x + 0.5, point.y + 0.5) + centre, TPointD(-point.x - 0.5, point.y + 0.5) + centre);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void drawEmptyCircle(int thick, const TPointD &mousePos, bool isPencil, bool isLxEven, bool isLyEven)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPointD pos = mousePos;
|
|
Toshihiro Shimizu |
890ddd |
if (isLxEven)
|
|
Toshihiro Shimizu |
890ddd |
pos.x += 0.5;
|
|
Toshihiro Shimizu |
890ddd |
if (isLyEven)
|
|
Toshihiro Shimizu |
890ddd |
pos.y += 0.5;
|
|
Toshihiro Shimizu |
890ddd |
if (!isPencil)
|
|
Toshihiro Shimizu |
890ddd |
tglDrawCircle(pos, (thick + 1) * 0.5);
|
|
Toshihiro Shimizu |
890ddd |
else {
|
|
Toshihiro Shimizu |
890ddd |
int x = 0, y = tround((thick * 0.5) - 0.5);
|
|
Toshihiro Shimizu |
890ddd |
int d = 3 - 2 * (int)(thick * 0.5);
|
|
Toshihiro Shimizu |
890ddd |
bool horizontal = true, isDecimal = thick % 2 != 0;
|
|
Toshihiro Shimizu |
890ddd |
drawLine(TPointD(x, y), pos, horizontal, isDecimal);
|
|
Toshihiro Shimizu |
890ddd |
while (y > x) {
|
|
Toshihiro Shimizu |
890ddd |
if (d < 0) {
|
|
Toshihiro Shimizu |
890ddd |
d = d + 4 * x + 6;
|
|
Toshihiro Shimizu |
890ddd |
horizontal = true;
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
d = d + 4 * (x - y) + 10;
|
|
Toshihiro Shimizu |
890ddd |
horizontal = false;
|
|
Toshihiro Shimizu |
890ddd |
y--;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
x++;
|
|
Toshihiro Shimizu |
890ddd |
drawLine(TPointD(x, y), pos, horizontal, isDecimal);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} //namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class PaintBrushTool : public TTool
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Q_DECLARE_TR_FUNCTIONS(PaintBrushTool)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
RasterStrokeGenerator *m_rasterTrack;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool m_firstTime;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double m_pointSize, m_distance2;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool m_selecting;
|
|
Toshihiro Shimizu |
890ddd |
TTileSaverCM32 *m_tileSaver;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPointD m_mousePos;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TIntProperty m_toolSize;
|
|
Toshihiro Shimizu |
890ddd |
TBoolProperty m_onlyEmptyAreas;
|
|
Toshihiro Shimizu |
890ddd |
TEnumProperty m_colorType;
|
|
Toshihiro Shimizu |
890ddd |
TPropertyGroup m_prop;
|
|
Toshihiro Shimizu |
890ddd |
int m_cursor;
|
|
Toshihiro Shimizu |
890ddd |
ColorType m_colorTypeBrush;
|
|
Toshihiro Shimizu |
890ddd |
/*-- 描画開始時のFrameIdを保存し、マウスリリース時(Undoの登録時)に別のフレームに
|
|
Toshihiro Shimizu |
890ddd |
移動している場合に備える --*/
|
|
Toshihiro Shimizu |
890ddd |
TFrameId m_workingFrameId;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
PaintBrushTool();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToolType getToolType() const { return TTool::LevelWriteTool; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void draw();
|
|
Toshihiro Shimizu |
890ddd |
void update(TToonzImageP ti, TRectD area);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void updateTranslation();
|
|
Toshihiro Shimizu |
890ddd |
|
|
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 &);
|
|
Toshihiro Shimizu |
890ddd |
void mouseMove(const TPointD &pos, const TMouseEvent &e);
|
|
Toshihiro Shimizu |
890ddd |
void onEnter();
|
|
Toshihiro Shimizu |
890ddd |
void onLeave();
|
|
Toshihiro Shimizu |
890ddd |
void onActivate();
|
|
Toshihiro Shimizu |
890ddd |
void onDeactivate();
|
|
Shinya Kitaoka |
3bfa54 |
bool onPropertyChanged(std::string propertyName);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPropertyGroup *getProperties(int targetType) { return &m_prop; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getCursorId() const { return m_cursor; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getColorClass() const { return 2; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*--- 描画中にツールが切り替わった場合に備え、onDeactivateにもMouseReleaseと同じ終了処理を行う ---*/
|
|
Toshihiro Shimizu |
890ddd |
void finishBrush();
|
|
Toshihiro Shimizu |
890ddd |
/*--- Brush、PaintBrush、EraserToolがPencilModeのときにTrueを返す。
|
|
Toshihiro Shimizu |
890ddd |
PaintBrushはピクセルのStyleIndexを入れ替えるツールのため、
|
|
Toshihiro Shimizu |
890ddd |
アンチエイリアスは存在しない、いわば常にPencilMode ---*/
|
|
Toshihiro Shimizu |
890ddd |
bool isPencilModeActive() { return true; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PaintBrushTool paintBrushTool;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// InkPaintTool implemention
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PaintBrushTool::PaintBrushTool()
|
|
Toshihiro Shimizu |
890ddd |
: TTool("T_PaintBrush"), m_rasterTrack(0), m_pointSize(-1), m_selecting(false), m_tileSaver(0), m_cursor(ToolCursor::EraserCursor)
|
|
Toshihiro Shimizu |
890ddd |
//sostituire i nomi con quelli del current, tipo W_ToolOptions...
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_toolSize("Size:", 1, 100, 10, false) //W_ToolOptions_BrushToolSize
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_colorType("Mode:") //W_ToolOptions_InkOrPaint
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_onlyEmptyAreas("Selective", false) //W_ToolOptions_Selective
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_firstTime(true), m_workingFrameId(TFrameId())
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_colorType.addValue(LINES);
|
|
Toshihiro Shimizu |
890ddd |
m_colorType.addValue(AREAS);
|
|
Toshihiro Shimizu |
890ddd |
m_colorType.addValue(ALL);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bind(TTool::ToonzImage);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_toolSize);
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_colorType);
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_onlyEmptyAreas);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_onlyEmptyAreas.setId("Selective");
|
|
Toshihiro Shimizu |
890ddd |
m_colorType.setId("Mode");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaintBrushTool::updateTranslation()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_toolSize.setQStringName(tr("Size:"));
|
|
Toshihiro Shimizu |
890ddd |
m_colorType.setQStringName(tr("Mode:"));
|
|
Toshihiro Shimizu |
890ddd |
m_onlyEmptyAreas.setQStringName(tr("Selective", NULL));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaintBrushTool::draw()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
/*-- MouseLeave時にBrushTipが描かれるのを防止する --*/
|
|
Toshihiro Shimizu |
890ddd |
if (m_pointSize == -1)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TToonzImageP ti = (TToonzImageP)getImage(false);
|
|
Toshihiro Shimizu |
890ddd |
if (!ti)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
TRasterP ras = ti->getRaster();
|
|
Toshihiro Shimizu |
890ddd |
int lx = ras->getLx();
|
|
Toshihiro Shimizu |
890ddd |
int ly = ras->getLy();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if ((ToonzCheck::instance()->getChecks() & ToonzCheck::eInk) || (ToonzCheck::instance()->getChecks() & ToonzCheck::ePaint) || (ToonzCheck::instance()->getChecks() & ToonzCheck::eInk1))
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(0.5, 0.8, 0.8);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
glColor3d(1.0, 0.0, 0.0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
drawEmptyCircle(m_toolSize.getValue(), m_mousePos, true, lx % 2 == 0, ly % 2 == 0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const UINT pointCount = 20;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
bool PaintBrushTool::onPropertyChanged(std::string propertyName)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
/*-- Size ---*/
|
|
Toshihiro Shimizu |
890ddd |
if (propertyName == m_toolSize.getName()) {
|
|
Toshihiro Shimizu |
890ddd |
PaintBrushSize = m_toolSize.getValue();
|
|
Toshihiro Shimizu |
890ddd |
double x = m_toolSize.getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double minRange = 1;
|
|
Toshihiro Shimizu |
890ddd |
double maxRange = 100;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double minSize = 0.01;
|
|
Toshihiro Shimizu |
890ddd |
double maxSize = 100;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_pointSize = (x - minRange) / (maxRange - minRange) * (maxSize - minSize) + minSize;
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Selective
|
|
Toshihiro Shimizu |
890ddd |
else if (propertyName == m_onlyEmptyAreas.getName()) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_onlyEmptyAreas.getValue() && m_colorType.getValue() == LINES) {
|
|
Toshihiro Shimizu |
890ddd |
m_colorType.setValue(AREAS);
|
|
Toshihiro Shimizu |
890ddd |
PaintBrushColorType = toString(m_colorType.getValue());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
PaintBrushSelective = (int)(m_onlyEmptyAreas.getValue());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Areas, Lines etc.
|
|
Toshihiro Shimizu |
890ddd |
else if (propertyName == m_colorType.getName()) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_colorType.getValue() == LINES) {
|
|
Toshihiro Shimizu |
890ddd |
PaintBrushSelective = (int)(m_onlyEmptyAreas.getValue());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
PaintBrushColorType = toString(m_colorType.getValue());
|
|
Toshihiro Shimizu |
890ddd |
/*--- ColorModelのCursor更新のためにSIGNALを出す ---*/
|
|
Toshihiro Shimizu |
890ddd |
TTool::getApplication()->getCurrentTool()->notifyToolChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaintBrushTool::leftButtonDown(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_selecting = true;
|
|
Toshihiro Shimizu |
890ddd |
TImageP image(getImage(true));
|
|
Toshihiro Shimizu |
890ddd |
if (m_colorType.getValue() == LINES)
|
|
Toshihiro Shimizu |
890ddd |
m_colorTypeBrush = INK;
|
|
Toshihiro Shimizu |
890ddd |
if (m_colorType.getValue() == AREAS)
|
|
Toshihiro Shimizu |
890ddd |
m_colorTypeBrush = PAINT;
|
|
Toshihiro Shimizu |
890ddd |
if (m_colorType.getValue() == ALL)
|
|
Toshihiro Shimizu |
890ddd |
m_colorTypeBrush = INKNPAINT;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (TToonzImageP ti = image) {
|
|
Toshihiro Shimizu |
890ddd |
TRasterCM32P ras = ti->getRaster();
|
|
Toshihiro Shimizu |
890ddd |
if (ras) {
|
|
Toshihiro Shimizu |
890ddd |
int thickness = m_toolSize.getValue();
|
|
Toshihiro Shimizu |
890ddd |
int styleId = TTool::getApplication()->getCurrentLevelStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
TTileSetCM32 *tileSet = new TTileSetCM32(ras->getSize());
|
|
Toshihiro Shimizu |
890ddd |
m_tileSaver = new TTileSaverCM32(ras, tileSet);
|
|
Toshihiro Shimizu |
890ddd |
m_rasterTrack = new RasterStrokeGenerator(ras, PAINTBRUSH, m_colorTypeBrush, styleId,
|
|
Toshihiro Shimizu |
890ddd |
TThickPoint(pos + convert(ras->getCenter()), thickness),
|
|
Toshihiro Shimizu |
890ddd |
m_onlyEmptyAreas.getValue(), 0, false);
|
|
Toshihiro Shimizu |
890ddd |
/*-- 現在のFidを記憶 --*/
|
|
Toshihiro Shimizu |
890ddd |
m_workingFrameId = getFrameId();
|
|
Toshihiro Shimizu |
890ddd |
m_tileSaver->save(m_rasterTrack->getLastRect());
|
|
Toshihiro Shimizu |
890ddd |
m_rasterTrack->generateLastPieceOfStroke(true);
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaintBrushTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_selecting)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_mousePos = pos;
|
|
Toshihiro Shimizu |
890ddd |
if (TToonzImageP ri = TImageP(getImage(true))) {
|
|
Toshihiro Shimizu |
890ddd |
/*--- マウスを動かしながらショートカットでこのツールに切り替わった場合、
|
|
Toshihiro Shimizu |
890ddd |
いきなりleftButtonDragから呼ばれることがあり、m_rasterTrackが無い可能性がある
|
|
Toshihiro Shimizu |
890ddd |
---*/
|
|
Toshihiro Shimizu |
890ddd |
if (m_rasterTrack) {
|
|
Toshihiro Shimizu |
890ddd |
int thickness = m_toolSize.getValue();
|
|
Toshihiro Shimizu |
890ddd |
bool isAdded = m_rasterTrack->add(TThickPoint(pos + convert(ri->getRaster()->getCenter()), thickness));
|
|
Toshihiro Shimizu |
890ddd |
if (isAdded) {
|
|
Toshihiro Shimizu |
890ddd |
m_tileSaver->save(m_rasterTrack->getLastRect());
|
|
Toshihiro Shimizu |
890ddd |
TRect modifiedBbox = m_rasterTrack->generateLastPieceOfStroke(true);
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaintBrushTool::leftButtonUp(const TPointD &pos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_selecting)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_mousePos = pos;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
finishBrush();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaintBrushTool::mouseMove(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_mousePos = pos;
|
|
Toshihiro Shimizu |
890ddd |
TPointD pp(tround(pos.x), tround(pos.y));
|
|
Toshihiro Shimizu |
890ddd |
m_mousePos = pp;
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaintBrushTool::onEnter()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_firstTime) {
|
|
Toshihiro Shimizu |
890ddd |
m_onlyEmptyAreas.setValue(PaintBrushSelective ? 1 : 0);
|
|
Toshihiro Shimizu |
890ddd |
m_colorType.setValue(toWideString((PaintBrushColorType.getValue())));
|
|
Toshihiro Shimizu |
890ddd |
m_toolSize.setValue(PaintBrushSize);
|
|
Toshihiro Shimizu |
890ddd |
m_firstTime = false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
double x = m_toolSize.getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double minRange = 1;
|
|
Toshihiro Shimizu |
890ddd |
double maxRange = 100;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double minSize = 0.01;
|
|
Toshihiro Shimizu |
890ddd |
double maxSize = 100;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_pointSize = (x - minRange) / (maxRange - minRange) * (maxSize - minSize) + minSize;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if ((TToonzImageP)getImage(false))
|
|
Toshihiro Shimizu |
890ddd |
m_cursor = ToolCursor::PenCursor;
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
m_cursor = ToolCursor::CURSOR_NO;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaintBrushTool::onLeave()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_pointSize = -1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaintBrushTool::onActivate()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
onEnter();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaintBrushTool::onDeactivate()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
/*--マウスドラッグ中(m_selecting=true)にツールが切り替わったときに描画の終了処理を行う---*/
|
|
Toshihiro Shimizu |
890ddd |
if (m_selecting)
|
|
Toshihiro Shimizu |
890ddd |
finishBrush();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! 描画中にツールが切り替わった場合に備え、onDeactivateでもMouseReleaseと同じ終了処理を行う
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void PaintBrushTool::finishBrush()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (TToonzImageP ti = (TToonzImageP)getImage(true)) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_rasterTrack) {
|
|
Toshihiro Shimizu |
890ddd |
int thickness = m_toolSize.getValue();
|
|
Toshihiro Shimizu |
890ddd |
bool isAdded = m_rasterTrack->add(TThickPoint(m_mousePos + convert(ti->getRaster()->getCenter()), thickness));
|
|
Toshihiro Shimizu |
890ddd |
if (isAdded) {
|
|
Toshihiro Shimizu |
890ddd |
m_tileSaver->save(m_rasterTrack->getLastRect());
|
|
Toshihiro Shimizu |
890ddd |
m_rasterTrack->generateLastPieceOfStroke(true, true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TTool::Application *app = TTool::getApplication();
|
|
Toshihiro Shimizu |
890ddd |
TXshLevel *level = app->getCurrentLevel()->getLevel();
|
|
Toshihiro Shimizu |
890ddd |
TXshSimpleLevelP simLevel = level->getSimpleLevel();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*-- 描画中にフレームが動いても、描画開始時のFidに対してUndoを記録する --*/
|
|
Toshihiro Shimizu |
890ddd |
TFrameId frameId = m_workingFrameId.isEmptyFrame() ? getCurrentFid() : m_workingFrameId;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->add(new BrushUndo(m_tileSaver->getTileSet(),
|
|
Toshihiro Shimizu |
890ddd |
m_rasterTrack->getPointsSequence(),
|
|
Toshihiro Shimizu |
890ddd |
m_colorTypeBrush,
|
|
Toshihiro Shimizu |
890ddd |
m_rasterTrack->getStyleId(),
|
|
Toshihiro Shimizu |
890ddd |
m_rasterTrack->isSelective(),
|
|
Toshihiro Shimizu |
890ddd |
simLevel.getPointer(),
|
|
Toshihiro Shimizu |
890ddd |
frameId));
|
|
Toshihiro Shimizu |
890ddd |
ToolUtils::updateSaveBox();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*--- FIdを指定して、描画中にフレームが変わっても、
|
|
Toshihiro Shimizu |
890ddd |
クリック時のFidのサムネイルが更新されるようにする。---*/
|
|
Toshihiro Shimizu |
890ddd |
notifyImageChanged(frameId);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
delete m_rasterTrack;
|
|
Toshihiro Shimizu |
890ddd |
m_rasterTrack = 0;
|
|
Toshihiro Shimizu |
890ddd |
delete m_tileSaver;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*--- 作業中のフレームをリセット ---*/
|
|
Toshihiro Shimizu |
890ddd |
m_workingFrameId = TFrameId();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToolUtils::updateSaveBox();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_selecting = false;
|
|
Toshihiro Shimizu |
890ddd |
}
|