|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzTools includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/toolutils.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/cursors.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/tool.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/toolutils.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/toolhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "bluredbrush.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzQt includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/icongenerator.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzLib includes
|
|
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 "toonz/txsheethandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tframehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevelhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tpalettehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tobjecthandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcolumnhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzBase includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tenv.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tstroke.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tmathutil.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 "tgl.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trop.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tinbetween.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ttile.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tropcm.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "timage_io.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Qt includes
|
|
Toshihiro Shimizu |
890ddd |
#include <qcoreapplication> // For Qt translation support</qcoreapplication>
|
|
Toshihiro Shimizu |
890ddd |
#include <qpainter></qpainter>
|
|
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::DoubleVar EraseSize("InknpaintEraseSize", 10);
|
|
Toshihiro Shimizu |
890ddd |
TEnv::StringVar EraseType("InknpaintEraseType", "Normal");
|
|
Toshihiro Shimizu |
890ddd |
TEnv::IntVar EraseSelective("InknpaintEraseSelective", 0);
|
|
Toshihiro Shimizu |
890ddd |
TEnv::IntVar EraseInvert("InknpaintEraseInvert", 0);
|
|
Toshihiro Shimizu |
890ddd |
TEnv::IntVar EraseRange("InknpaintEraseRange", 0);
|
|
Toshihiro Shimizu |
890ddd |
TEnv::StringVar EraseColorType("InknpaintEraseColorType", "Lines");
|
|
Toshihiro Shimizu |
890ddd |
TEnv::DoubleVar EraseHardness("EraseHardness", 100);
|
|
Toshihiro Shimizu |
890ddd |
TEnv::IntVar ErasePencil("InknpaintErasePencil", 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// Undo dei Tools
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
Viene realizzata la funzione di "UNDO" per il cancellino nell'opzione RECTERASE
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class RectRasterUndo : public TRasterUndo
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TRectD m_modifyArea;
|
|
Toshihiro Shimizu |
890ddd |
TStroke *m_stroke;
|
|
Toshihiro Shimizu |
890ddd |
int m_styleId;
|
|
Shinya Kitaoka |
3bfa54 |
std::wstring m_colorType;
|
|
Shinya Kitaoka |
3bfa54 |
std::wstring m_eraseType;
|
|
Toshihiro Shimizu |
890ddd |
bool m_selective;
|
|
Toshihiro Shimizu |
890ddd |
bool m_invert;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
RectRasterUndo(TTileSetCM32 *tileSet, const TRectD &modifyArea, TStroke stroke,
|
|
Shinya Kitaoka |
3bfa54 |
int styleId, std::wstring eraseType, std::wstring colorType,
|
|
Toshihiro Shimizu |
890ddd |
TXshSimpleLevel *level, bool selective, bool invert,
|
|
Toshihiro Shimizu |
890ddd |
const TFrameId &frameId)
|
|
Toshihiro Shimizu |
890ddd |
: TRasterUndo(tileSet, level, frameId, false, false, 0), m_modifyArea(modifyArea), m_styleId(styleId), m_eraseType(eraseType), m_colorType(colorType), m_selective(selective), m_invert(invert)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_stroke = new TStroke(stroke);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void redo() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TToonzImageP ti = getImage();
|
|
Toshihiro Shimizu |
890ddd |
if (!ti)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
bool eraseInk = m_colorType == LINES || m_colorType == ALL;
|
|
Toshihiro Shimizu |
890ddd |
bool erasePaint = m_colorType == AREAS || m_colorType == ALL;
|
|
Toshihiro Shimizu |
890ddd |
if (m_eraseType == RECTERASE) {
|
|
Toshihiro Shimizu |
890ddd |
TRect rect = ToonzImageUtils::eraseRect(ti, m_modifyArea, m_styleId, eraseInk, erasePaint);
|
|
Toshihiro Shimizu |
890ddd |
if (!rect.isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
ToolUtils::updateSaveBox(m_level, m_frameId);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} else if (m_eraseType == FREEHANDERASE || m_eraseType == POLYLINEERASE) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_level) {
|
|
Toshihiro Shimizu |
890ddd |
TPoint pos;
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P ras = convertStrokeToImage(m_stroke, ti->getRaster()->getBounds(), pos);
|
|
Toshihiro Shimizu |
890ddd |
if (!ras)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
ToonzImageUtils::eraseImage(ti, ras, pos, m_invert, eraseInk, erasePaint, m_selective, m_styleId);
|
|
Toshihiro Shimizu |
890ddd |
ToolUtils::updateSaveBox(m_level, m_frameId);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
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 TRasterUndo::getSize() +
|
|
Toshihiro Shimizu |
890ddd |
sizeof(this) +
|
|
Toshihiro Shimizu |
890ddd |
m_stroke->getControlPointCount() * sizeof(TThickPoint) +
|
|
Toshihiro Shimizu |
890ddd |
100;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
~RectRasterUndo()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_stroke)
|
|
Toshihiro Shimizu |
890ddd |
delete m_stroke;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString getToolName()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return QString("Eraser Tool (Rect)");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
int getHistoryType()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return HistoryType::EraserTool;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=====================================================================
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
Viene realizzata la funzione di "UNDO" per il cancellino nell'opzione NORMALERAS
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
class RasterEraserUndo : 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 |
bool m_isPencil;
|
|
Toshihiro Shimizu |
890ddd |
ColorType m_colorType;
|
|
Toshihiro Shimizu |
890ddd |
int m_colorSelected;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
3bfa54 |
RasterEraserUndo(TTileSetCM32 *tileSet, const std::vector<tthickpoint> &points,</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
ColorType colorType, int styleId, bool selective,
|
|
Toshihiro Shimizu |
890ddd |
int colorSelected, TXshSimpleLevel *level,
|
|
Toshihiro Shimizu |
890ddd |
const TFrameId &frameId, bool isPencil)
|
|
Toshihiro Shimizu |
890ddd |
: TRasterUndo(tileSet, level, frameId, false, false, 0), m_points(points), m_styleId(styleId), m_selective(selective), m_colorType(colorType), m_colorSelected(colorSelected), m_isPencil(isPencil)
|
|
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, ERASE, m_colorType, 0, m_points[0], m_selective, m_colorSelected, !m_isPencil);
|
|
Toshihiro Shimizu |
890ddd |
m_rasterTrack.setPointsSequence(m_points);
|
|
Toshihiro Shimizu |
890ddd |
m_rasterTrack.generateStroke(m_isPencil);
|
|
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 |
|
|
Toshihiro Shimizu |
890ddd |
QString getToolName()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return QString("Eraser Tool");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
int getHistoryType()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return HistoryType::EraserTool;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=====================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class RasterBluredEraserUndo : 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 |
int m_size;
|
|
Toshihiro Shimizu |
890ddd |
double m_hardness;
|
|
Shinya Kitaoka |
3bfa54 |
std::wstring m_mode;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
RasterBluredEraserUndo(TTileSetCM32 *tileSet,
|
|
Shinya Kitaoka |
3bfa54 |
const std::vector<tthickpoint> &points,</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
int styleId, bool selective,
|
|
Toshihiro Shimizu |
890ddd |
TXshSimpleLevel *level, const TFrameId &frameId,
|
|
Shinya Kitaoka |
3bfa54 |
int size, double hardness, const std::wstring &mode)
|
|
Toshihiro Shimizu |
890ddd |
: TRasterUndo(tileSet, level, frameId, false, false, 0), m_points(points), m_styleId(styleId), m_selective(selective), m_size(size), m_hardness(hardness), m_mode(mode)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void redo() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_points.size() == 0)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
TToonzImageP image = getImage();
|
|
Toshihiro Shimizu |
890ddd |
TRasterCM32P ras = image->getRaster();
|
|
Toshihiro Shimizu |
890ddd |
TRasterCM32P backupRas = ras->clone();
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P workRaster(ras->getSize());
|
|
Toshihiro Shimizu |
890ddd |
QRadialGradient brushPad = ToolUtils::getBrushPad(m_size, m_hardness);
|
|
Toshihiro Shimizu |
890ddd |
workRaster->clear();
|
|
Toshihiro Shimizu |
890ddd |
BluredBrush brush(workRaster, m_size, brushPad, false);
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tthickpoint> points;</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
points.push_back(m_points[0]);
|
|
Toshihiro Shimizu |
890ddd |
TRect bbox = brush.getBoundFromPoints(points);
|
|
Toshihiro Shimizu |
890ddd |
brush.addPoint(m_points[0], 1);
|
|
Toshihiro Shimizu |
890ddd |
brush.eraseDrawing(ras, ras, bbox, m_selective, m_styleId, m_mode);
|
|
Toshihiro Shimizu |
890ddd |
if (m_points.size() > 1) {
|
|
Toshihiro Shimizu |
890ddd |
points.clear();
|
|
Toshihiro Shimizu |
890ddd |
points.push_back(m_points[0]);
|
|
Toshihiro Shimizu |
890ddd |
points.push_back(m_points[1]);
|
|
Toshihiro Shimizu |
890ddd |
bbox = brush.getBoundFromPoints(points);
|
|
Toshihiro Shimizu |
890ddd |
brush.addArc(m_points[0], (m_points[0] + m_points[1]) * 0.5, m_points[1], 1, 1);
|
|
Toshihiro Shimizu |
890ddd |
brush.eraseDrawing(ras, backupRas, bbox, m_selective, m_styleId, m_mode);
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 1; i + 2 < (int)m_points.size(); i = i + 2) {
|
|
Toshihiro Shimizu |
890ddd |
points.clear();
|
|
Toshihiro Shimizu |
890ddd |
points.push_back(m_points[i]);
|
|
Toshihiro Shimizu |
890ddd |
points.push_back(m_points[i + 1]);
|
|
Toshihiro Shimizu |
890ddd |
points.push_back(m_points[i + 2]);
|
|
Toshihiro Shimizu |
890ddd |
bbox = brush.getBoundFromPoints(points);
|
|
Toshihiro Shimizu |
890ddd |
brush.addArc(m_points[i], m_points[i + 1], m_points[i + 2], 1, 1);
|
|
Toshihiro Shimizu |
890ddd |
brush.eraseDrawing(ras, backupRas, bbox, m_selective, m_styleId, m_mode);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
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 |
|
|
Toshihiro Shimizu |
890ddd |
QString getToolName()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return QString("Eraser Tool");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
int getHistoryType()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return HistoryType::EraserTool;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
void eraseStroke(const TToonzImageP &ti, TStroke *stroke, std::wstring eraseType,
|
|
Shinya Kitaoka |
3bfa54 |
std::wstring colorType, bool invert, bool selective,
|
|
Toshihiro Shimizu |
890ddd |
int styleId, const TXshSimpleLevelP &level, const TFrameId &frameId)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(stroke);
|
|
Toshihiro Shimizu |
890ddd |
TPoint pos;
|
|
Toshihiro Shimizu |
890ddd |
TRasterCM32P ras = ti->getRaster();
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P image = convertStrokeToImage(stroke, ras->getBounds(), pos);
|
|
Toshihiro Shimizu |
890ddd |
if (!image)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRect rasterErasedArea = image->getBounds() + pos;
|
|
Toshihiro Shimizu |
890ddd |
TRect area;
|
|
Toshihiro Shimizu |
890ddd |
if (!invert)
|
|
Toshihiro Shimizu |
890ddd |
area = rasterErasedArea.enlarge(2);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
area = ras->getBounds();
|
|
Toshihiro Shimizu |
890ddd |
TTileSetCM32 *tileSet = new TTileSetCM32(ras->getSize());
|
|
Toshihiro Shimizu |
890ddd |
tileSet->add(ras, area);
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->add(new RectRasterUndo(tileSet, convert(area), *stroke,
|
|
Toshihiro Shimizu |
890ddd |
selective ? styleId : -1, eraseType, colorType, level.getPointer(),
|
|
Toshihiro Shimizu |
890ddd |
selective, invert, frameId));
|
|
Toshihiro Shimizu |
890ddd |
bool eraseInk = colorType == LINES || colorType == ALL;
|
|
Toshihiro Shimizu |
890ddd |
bool erasePaint = colorType == AREAS || colorType == ALL;
|
|
Toshihiro Shimizu |
890ddd |
ToonzImageUtils::eraseImage(ti, image, pos, invert, eraseInk, erasePaint, selective, styleId);
|
|
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)*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 |
//==================================================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// InkPaintTool class declaration
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class EraserTool : public TTool
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Q_DECLARE_TR_FUNCTIONS(EraserTool)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
3bfa54 |
EraserTool(std::string name);
|
|
Toshihiro Shimizu |
890ddd |
~EraserTool()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_firstStroke)
|
|
Toshihiro Shimizu |
890ddd |
delete m_firstStroke;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToolType getToolType() const { return TTool::LevelWriteTool; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void updateTranslation();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void draw();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void update(const TToonzImageP &ti, const TPointD &pos);
|
|
Toshihiro Shimizu |
890ddd |
void saveUndo();
|
|
Toshihiro Shimizu |
890ddd |
void update(const TToonzImageP &ti, TRectD selArea, const TXshSimpleLevelP &level, bool multi = false,
|
|
Toshihiro Shimizu |
890ddd |
const TFrameId &frameId = -1);
|
|
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 leftButtonDoubleClick(const TPointD &pos, const TMouseEvent &e);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void multiAreaEraser(const TXshSimpleLevelP &sl, TFrameId &firstFid, TFrameId &lastFid,
|
|
Toshihiro Shimizu |
890ddd |
TStroke *firstStroke, TStroke *lastStroke);
|
|
Toshihiro Shimizu |
890ddd |
void doMultiEraser(const TImageP &img, double t,
|
|
Toshihiro Shimizu |
890ddd |
const TXshSimpleLevelP &sl, const TFrameId &fid,
|
|
Toshihiro Shimizu |
890ddd |
const TVectorImageP &firstImage, const TVectorImageP &lastImage);
|
|
Toshihiro Shimizu |
890ddd |
|
|
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();
|
|
Shinya Kitaoka |
3bfa54 |
bool onPropertyChanged(std::string propertyName);
|
|
Toshihiro Shimizu |
890ddd |
void onImageChanged();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void multiUpdate(const TXshSimpleLevelP &level, TFrameId firstFrameId, TFrameId lastFrameId, TRectD firstRect, TRectD lastRect);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPropertyGroup *getProperties(int targetType) { return &m_prop; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getCursorId() const;
|
|
Toshihiro Shimizu |
890ddd |
void resetMulti();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*-- ドラッグ中にツールが切り替わった場合、処理を終了させる--*/
|
|
Toshihiro Shimizu |
890ddd |
void onDeactivate();
|
|
Toshihiro Shimizu |
890ddd |
/*-- Brush、PaintBrush、EraserToolがPencilModeのときにTrueを返す --*/
|
|
Toshihiro Shimizu |
890ddd |
bool isPencilModeActive();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
/*-- 終了処理 --*/
|
|
Toshihiro Shimizu |
890ddd |
void storeUndoAndRefresh();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
enum Type {
|
|
Toshihiro Shimizu |
890ddd |
NONE = 0,
|
|
Toshihiro Shimizu |
890ddd |
BRUSH,
|
|
Toshihiro Shimizu |
890ddd |
INKCHANGE,
|
|
Toshihiro Shimizu |
890ddd |
ERASER
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
TPropertyGroup m_prop;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TEnumProperty m_eraseType;
|
|
Toshihiro Shimizu |
890ddd |
TIntProperty m_toolSize;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleProperty m_hardness;
|
|
Toshihiro Shimizu |
890ddd |
TBoolProperty m_invertOption;
|
|
Toshihiro Shimizu |
890ddd |
TBoolProperty m_currentStyle;
|
|
Toshihiro Shimizu |
890ddd |
TBoolProperty m_multi;
|
|
Toshihiro Shimizu |
890ddd |
TBoolProperty m_pencil;
|
|
Toshihiro Shimizu |
890ddd |
TEnumProperty m_colorType;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Type m_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TXshSimpleLevelP m_level;
|
|
Toshihiro Shimizu |
890ddd |
std::pair<int, int=""> m_currCell;</int,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFrameId m_firstFrameId,
|
|
Toshihiro Shimizu |
890ddd |
m_veryFirstFrameId;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
StrokeGenerator m_track;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TStroke *m_firstStroke;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TTileSaverCM32 *m_tileSaver;
|
|
Toshihiro Shimizu |
890ddd |
TTileSetCM32 *m_tileSet;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
RasterStrokeGenerator *m_normalEraser;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRectD m_selectingRect,
|
|
Toshihiro Shimizu |
890ddd |
m_firstRect;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ColorType m_colorTypeEraser;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPointD m_mousePos,
|
|
Toshihiro Shimizu |
890ddd |
m_brushPos,
|
|
Toshihiro Shimizu |
890ddd |
m_firstPos;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tpointd> m_polyline;</tpointd>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//gestione cancellino blurato
|
|
Toshihiro Shimizu |
890ddd |
TRasterCM32P m_backupRas;
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P m_workRas;
|
|
Toshihiro Shimizu |
890ddd |
QRadialGradient m_brushPad;
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tthickpoint> m_points;</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
BluredBrush *m_bluredBrush;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double m_pointSize,
|
|
Toshihiro Shimizu |
890ddd |
m_distance2,
|
|
Toshihiro Shimizu |
890ddd |
m_cleanerSize,
|
|
Toshihiro Shimizu |
890ddd |
m_thick;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool m_isXsheetCell,
|
|
Toshihiro Shimizu |
890ddd |
m_active,
|
|
Toshihiro Shimizu |
890ddd |
m_enabled,
|
|
Toshihiro Shimizu |
890ddd |
m_selecting,
|
|
Toshihiro Shimizu |
890ddd |
m_firstFrameSelected,
|
|
Toshihiro Shimizu |
890ddd |
m_firstTime;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*--- 消しゴム開始時のFrameIdを保存し、マウスリリース時(Undoの登録時)に
|
|
Toshihiro Shimizu |
890ddd |
別のフレームに移動していた場合に備える
|
|
Toshihiro Shimizu |
890ddd |
---*/
|
|
Toshihiro Shimizu |
890ddd |
TFrameId m_workingFrameId;
|
|
Toshihiro Shimizu |
890ddd |
/*--- マウスボタンDown→プロパティ変更→マウスボタンUpのように、
|
|
Toshihiro Shimizu |
890ddd |
ボタンDownからUpまでストレートに来なかった場合は処理を行わないようにする。
|
|
Toshihiro Shimizu |
890ddd |
---*/
|
|
Toshihiro Shimizu |
890ddd |
bool m_isLeftButtonPressed;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
EraserTool inkPaintEraserTool("T_Eraser");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// InkPaintTool implemention
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
EraserTool::EraserTool(std::string name)
|
|
Toshihiro Shimizu |
890ddd |
: TTool(name), m_toolSize("Size:", 1, 100, 10, false) //W_ToolOptions_EraserToolSize
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_hardness("Hardness:", 0, 100, 100), m_eraseType("Type:") //W_ToolOptions_Erasetype
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_colorType("Mode:") //W_ToolOptions_InkOrPaint
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_currentStyle("Selective", false) //W_ToolOptions_Selective
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_invertOption("Invert", false) //W_ToolOptions_Invert
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_multi("Frame Range", false) //W_ToolOptions_FrameRange
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_pencil("Pencil Mode", false), m_currCell(-1, -1), m_tileSaver(0), m_bluredBrush(0), m_pointSize(-1), m_thick(0.5), m_firstFrameSelected(false), m_selecting(false), m_active(false), m_enabled(false), m_isXsheetCell(false), m_firstTime(true), m_workingFrameId(TFrameId()), m_isLeftButtonPressed(false)
|
|
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_hardness);
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_eraseType);
|
|
Toshihiro Shimizu |
890ddd |
m_eraseType.addValue(NORMALERASE);
|
|
Toshihiro Shimizu |
890ddd |
m_eraseType.addValue(RECTERASE);
|
|
Toshihiro Shimizu |
890ddd |
m_eraseType.addValue(FREEHANDERASE);
|
|
Toshihiro Shimizu |
890ddd |
m_eraseType.addValue(POLYLINEERASE);
|
|
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 |
m_prop.bind(m_colorType);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_currentStyle);
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_invertOption);
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_multi);
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_pencil);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_currentStyle.setId("Selective");
|
|
Toshihiro Shimizu |
890ddd |
m_invertOption.setId("Invert");
|
|
Toshihiro Shimizu |
890ddd |
m_multi.setId("FrameRange");
|
|
Toshihiro Shimizu |
890ddd |
m_pencil.setId("PencilMode");
|
|
Toshihiro Shimizu |
890ddd |
m_colorType.setId("Mode");
|
|
Toshihiro Shimizu |
890ddd |
m_eraseType.setId("Type");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void EraserTool::updateTranslation()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_toolSize.setQStringName(tr("Size:"));
|
|
Toshihiro Shimizu |
890ddd |
m_hardness.setQStringName(tr("Hardness:"));
|
|
Toshihiro Shimizu |
890ddd |
m_eraseType.setQStringName(tr("Type:"));
|
|
Toshihiro Shimizu |
890ddd |
m_colorType.setQStringName(tr("Mode:"));
|
|
Toshihiro Shimizu |
890ddd |
m_currentStyle.setQStringName(tr("Selective"));
|
|
Toshihiro Shimizu |
890ddd |
m_invertOption.setQStringName(tr("Invert"));
|
|
Toshihiro Shimizu |
890ddd |
m_multi.setQStringName(tr("Frame Range"));
|
|
Toshihiro Shimizu |
890ddd |
m_pencil.setQStringName(tr("Pencil Mode"));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void EraserTool::draw()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
/*-- MouseLeave時に赤点が描かれるのを防ぐ --*/
|
|
Toshihiro Shimizu |
890ddd |
if (m_pointSize == -1 && m_cleanerSize == 0)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize2 = getPixelSize() * getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
m_thick = sqrt(pixelSize2) / 2.0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImageP img = getImage(false);
|
|
Toshihiro Shimizu |
890ddd |
if (!img)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_eraseType.getValue() == RECTERASE) {
|
|
Toshihiro Shimizu |
890ddd |
TPixel color = TPixel32::Red;
|
|
Toshihiro Shimizu |
890ddd |
if (m_multi.getValue() && m_firstFrameSelected)
|
|
Toshihiro Shimizu |
890ddd |
drawRect(m_firstRect, color, 0x3F33, true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_selecting || (m_multi.getValue() && !m_firstFrameSelected))
|
|
Toshihiro Shimizu |
890ddd |
drawRect(m_selectingRect, color, 0xFFFF, true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_eraseType.getValue() == NORMALERASE) {
|
|
Toshihiro Shimizu |
890ddd |
TToonzImageP image(img);
|
|
Toshihiro Shimizu |
890ddd |
TRasterP ras = image->getRaster();
|
|
Toshihiro Shimizu |
890ddd |
int lx = ras->getLx();
|
|
Toshihiro Shimizu |
890ddd |
int ly = ras->getLy();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*-- InkCheck, PaintCheck, Ink#1CheckがONのときは、BrushTipの描画色を変える --*/
|
|
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 |
drawEmptyCircle(tround(m_cleanerSize), m_brushPos,
|
|
Toshihiro Shimizu |
890ddd |
(m_pencil.getValue() || m_colorType.getValue() == AREAS),
|
|
Toshihiro Shimizu |
890ddd |
lx % 2 == 0, ly % 2 == 0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if ((m_eraseType.getValue() == FREEHANDERASE || m_eraseType.getValue() == POLYLINEERASE) && m_multi.getValue()) {
|
|
Toshihiro Shimizu |
890ddd |
TPixel color = TPixel32::Red;
|
|
Toshihiro Shimizu |
890ddd |
tglColor(color);
|
|
Toshihiro Shimizu |
890ddd |
if (m_firstStroke)
|
|
Toshihiro Shimizu |
890ddd |
drawStrokeCenterline(*m_firstStroke, 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_eraseType.getValue() == POLYLINEERASE && !m_polyline.empty()) {
|
|
Toshihiro Shimizu |
890ddd |
TPixel color = TPixel32::Red;
|
|
Toshihiro Shimizu |
890ddd |
tglColor(color);
|
|
Toshihiro Shimizu |
890ddd |
tglDrawCircle(m_polyline[0], 2);
|
|
Toshihiro Shimizu |
890ddd |
glBegin(GL_LINE_STRIP);
|
|
Toshihiro Shimizu |
890ddd |
for (UINT i = 0; i < m_polyline.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
tglVertex(m_polyline[i]);
|
|
Toshihiro Shimizu |
890ddd |
tglVertex(m_mousePos);
|
|
Toshihiro Shimizu |
890ddd |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int EraserTool::getCursorId() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_eraseType.getValue() == NORMALERASE)
|
|
Toshihiro Shimizu |
890ddd |
return ToolCursor::NormalEraserCursor;
|
|
Toshihiro Shimizu |
890ddd |
else if (ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg)
|
|
Toshihiro Shimizu |
890ddd |
return ToolCursor::RectEraserCursorWhite;
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
return ToolCursor::RectEraserCursor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void EraserTool::resetMulti()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_isXsheetCell = false;
|
|
Toshihiro Shimizu |
890ddd |
m_firstFrameSelected = false;
|
|
Toshihiro Shimizu |
890ddd |
m_firstRect.empty();
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.empty();
|
|
Toshihiro Shimizu |
890ddd |
TTool::Application *app = TTool::getApplication();
|
|
Toshihiro Shimizu |
890ddd |
m_level = app->getCurrentLevel()->getLevel()
|
|
Toshihiro Shimizu |
890ddd |
? app->getCurrentLevel()->getSimpleLevel()
|
|
Toshihiro Shimizu |
890ddd |
: 0;
|
|
Toshihiro Shimizu |
890ddd |
m_firstFrameId = m_veryFirstFrameId = getFrameId();
|
|
Toshihiro Shimizu |
890ddd |
if (m_firstStroke) {
|
|
Toshihiro Shimizu |
890ddd |
delete m_firstStroke;
|
|
Toshihiro Shimizu |
890ddd |
m_firstStroke = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void EraserTool::multiUpdate(const TXshSimpleLevelP &level, TFrameId firstFid, TFrameId lastFid, TRectD firstRect, TRectD lastRect)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
bool backward = false;
|
|
Toshihiro Shimizu |
890ddd |
if (firstFid > lastFid) {
|
|
Toshihiro Shimizu |
890ddd |
tswap(firstFid, lastFid);
|
|
Toshihiro Shimizu |
890ddd |
backward = true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
assert(firstFid <= lastFid);
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tframeid> allFids;</tframeid>
|
|
Toshihiro Shimizu |
890ddd |
level->getFids(allFids);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*-- フレーム範囲に対応するFIdを取得 --*/
|
|
Toshihiro Shimizu |
890ddd |
std::vector<tframeid>::iterator i0 = allFids.begin();</tframeid>
|
|
Toshihiro Shimizu |
890ddd |
while (i0 != allFids.end() && *i0 < firstFid)
|
|
Toshihiro Shimizu |
890ddd |
i0++;
|
|
Toshihiro Shimizu |
890ddd |
if (i0 == allFids.end())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
std::vector<tframeid>::iterator i1 = i0;</tframeid>
|
|
Toshihiro Shimizu |
890ddd |
while (i1 != allFids.end() && *i1 <= lastFid)
|
|
Toshihiro Shimizu |
890ddd |
i1++;
|
|
Toshihiro Shimizu |
890ddd |
assert(i0 < i1);
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tframeid> fids(i0, i1);</tframeid>
|
|
Toshihiro Shimizu |
890ddd |
int m = fids.size();
|
|
Toshihiro Shimizu |
890ddd |
assert(m > 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
std::wstring levelName = level->getName();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*-- FrameRangeの各フレームについて --*/
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->beginBlock();
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < m; ++i) {
|
|
Toshihiro Shimizu |
890ddd |
TFrameId fid = fids[i];
|
|
Toshihiro Shimizu |
890ddd |
assert(firstFid <= fid && fid <= lastFid);
|
|
Toshihiro Shimizu |
890ddd |
TToonzImageP ti = level->getFrame(fid, true);
|
|
Toshihiro Shimizu |
890ddd |
if (!ti)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
/*--補間の係数を取得 --*/
|
|
Toshihiro Shimizu |
890ddd |
double t = m > 1 ? (double)i / (double)(m - 1) : 0.5;
|
|
Toshihiro Shimizu |
890ddd |
/*--invertがONのとき、外側領域を4つのRectに分けてupdate--*/
|
|
Toshihiro Shimizu |
890ddd |
if (m_invertOption.getValue()) {
|
|
Toshihiro Shimizu |
890ddd |
TRect rect = convert(interpolateRect(firstRect, lastRect, backward ? 1 - t : t));
|
|
Toshihiro Shimizu |
890ddd |
TRectD rect01 = TRectD(TPointD(-100000., -100000.), TPointD((double)rect.x0, 100000.));
|
|
Toshihiro Shimizu |
890ddd |
update(ti, rect01, level, true, fid);
|
|
Toshihiro Shimizu |
890ddd |
TRectD rect02 = TRectD(convert(rect.getP01()), TPointD((double)rect.x1, 100000.));
|
|
Toshihiro Shimizu |
890ddd |
update(ti, rect02, level, true, fid);
|
|
Toshihiro Shimizu |
890ddd |
TRectD rect03 = TRectD(TPointD((double)rect.x0, -100000.), convert(rect.getP10()));
|
|
Toshihiro Shimizu |
890ddd |
update(ti, rect03, level, true, fid);
|
|
Toshihiro Shimizu |
890ddd |
TRectD rect04 = TRectD(TPointD((double)rect.x1, -100000.), TPointD(100000., 100000.));
|
|
Toshihiro Shimizu |
890ddd |
update(ti, rect04, level, true, fid);
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
update(ti, interpolateRect(firstRect, lastRect, backward ? 1 - t : t), level, true, fid);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRect savebox;
|
|
Toshihiro Shimizu |
890ddd |
TRop::computeBBox(ti->getRaster(), savebox);
|
|
Toshihiro Shimizu |
890ddd |
ti->setSavebox(savebox);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
level->getProperties()->setDirtyFlag(true);
|
|
Toshihiro Shimizu |
890ddd |
notifyImageChanged(fid);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->endBlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void EraserTool::update(const TToonzImageP &ti, TRectD selArea, const TXshSimpleLevelP &level,
|
|
Toshihiro Shimizu |
890ddd |
bool multi, const TFrameId &frameId)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_selectingRect.x0 > m_selectingRect.x1) {
|
|
Toshihiro Shimizu |
890ddd |
selArea.x1 = m_selectingRect.x0;
|
|
Toshihiro Shimizu |
890ddd |
selArea.x0 = m_selectingRect.x1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_selectingRect.y0 > m_selectingRect.y1) {
|
|
Toshihiro Shimizu |
890ddd |
selArea.y1 = m_selectingRect.y0;
|
|
Toshihiro Shimizu |
890ddd |
selArea.y0 = m_selectingRect.y1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (selArea.getLx() < 1 || selArea.getLy() < 1)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
bool selective = m_currentStyle.getValue();
|
|
Toshihiro Shimizu |
890ddd |
int styleId = TTool::getApplication()->getCurrentLevelStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRasterCM32P raster = ti->getRaster();
|
|
Toshihiro Shimizu |
890ddd |
TTileSetCM32 *tileSet = new TTileSetCM32(raster->getSize());
|
|
Toshihiro Shimizu |
890ddd |
tileSet->add(raster, ToonzImageUtils::convertWorldToRaster(selArea, ti));
|
|
Toshihiro Shimizu |
890ddd |
TUndo *undo;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
std::wstring inkPaint = m_colorType.getValue();
|
|
Toshihiro Shimizu |
890ddd |
undo = new RectRasterUndo(tileSet, selArea, TStroke(), selective ? styleId : -1, m_eraseType.getValue(), inkPaint,
|
|
Toshihiro Shimizu |
890ddd |
level.getPointer(), selective, m_invertOption.getValue(), frameId);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToonzImageUtils::eraseRect(ti, selArea, selective ? styleId : -1,
|
|
Toshihiro Shimizu |
890ddd |
inkPaint == LINES || inkPaint == ALL,
|
|
Toshihiro Shimizu |
890ddd |
inkPaint == AREAS || inkPaint == ALL);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->add(undo);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void EraserTool::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 |
|
|
Toshihiro Shimizu |
890ddd |
TRectD invalidateRect;
|
|
Toshihiro Shimizu |
890ddd |
if (TToonzImageP ti = image) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_eraseType.getValue() == RECTERASE) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_multi.getValue() && m_firstRect.isEmpty()) {
|
|
Toshihiro Shimizu |
890ddd |
invalidateRect = m_selectingRect;
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.empty();
|
|
Toshihiro Shimizu |
890ddd |
invalidate(invalidateRect.enlarge(2));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.x0 = pos.x;
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.y0 = pos.y;
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.x1 = pos.x + 1;
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.y1 = pos.y + 1;
|
|
Toshihiro Shimizu |
890ddd |
invalidateRect = m_selectingRect.enlarge(2);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_eraseType.getValue() == NORMALERASE) {
|
|
Toshihiro Shimizu |
890ddd |
TRasterCM32P raster = ti->getRaster();
|
|
Toshihiro Shimizu |
890ddd |
TThickPoint intPos;
|
|
Toshihiro Shimizu |
890ddd |
/*--Areasタイプの時は常にPencilと同じ消し方にする--*/
|
|
Toshihiro Shimizu |
890ddd |
if (m_pencil.getValue() || m_colorType.getValue() == AREAS)
|
|
Toshihiro Shimizu |
890ddd |
intPos = TThickPoint(pos + convert(raster->getCenter()), m_toolSize.getValue());
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
intPos = TThickPoint(pos + convert(raster->getCenter()), m_toolSize.getValue() - 1);
|
|
Toshihiro Shimizu |
890ddd |
int currentStyle = 0;
|
|
Toshihiro Shimizu |
890ddd |
if (m_currentStyle.getValue())
|
|
Toshihiro Shimizu |
890ddd |
currentStyle = TTool::getApplication()->getCurrentLevelStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
m_tileSet = new TTileSetCM32(raster->getSize());
|
|
Toshihiro Shimizu |
890ddd |
m_tileSaver = new TTileSaverCM32(raster, m_tileSet);
|
|
Toshihiro Shimizu |
890ddd |
TPointD halfThick(m_toolSize.getValue() * 0.5, m_toolSize.getValue() * 0.5);
|
|
Toshihiro Shimizu |
890ddd |
invalidateRect = TRectD(pos - halfThick, pos + halfThick);
|
|
Toshihiro Shimizu |
890ddd |
if (m_hardness.getValue() == 100 || m_pencil.getValue() || m_colorType.getValue() == AREAS) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_colorType.getValue() == LINES) {
|
|
Toshihiro Shimizu |
890ddd |
m_colorTypeEraser = INK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_colorType.getValue() == AREAS)
|
|
Toshihiro Shimizu |
890ddd |
m_colorTypeEraser = PAINT;
|
|
Toshihiro Shimizu |
890ddd |
if (m_colorType.getValue() == ALL)
|
|
Toshihiro Shimizu |
890ddd |
m_colorTypeEraser = INKNPAINT;
|
|
Toshihiro Shimizu |
890ddd |
m_normalEraser = new RasterStrokeGenerator(raster, ERASE, m_colorTypeEraser, 0, intPos,
|
|
Toshihiro Shimizu |
890ddd |
m_currentStyle.getValue(), currentStyle,
|
|
Toshihiro Shimizu |
890ddd |
!(m_pencil.getValue() || m_colorType.getValue() == AREAS));
|
|
Toshihiro Shimizu |
890ddd |
m_tileSaver->save(m_normalEraser->getLastRect());
|
|
Toshihiro Shimizu |
890ddd |
m_normalEraser->generateLastPieceOfStroke(m_pencil.getValue() || m_colorType.getValue() == AREAS);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
m_points.clear();
|
|
Toshihiro Shimizu |
890ddd |
m_backupRas = raster->clone();
|
|
Toshihiro Shimizu |
890ddd |
m_workRas = TRaster32P(raster->getSize());
|
|
Toshihiro Shimizu |
890ddd |
m_workRas->clear();
|
|
Toshihiro Shimizu |
890ddd |
TPointD center = raster->getCenterD();
|
|
Toshihiro Shimizu |
890ddd |
TThickPoint point(pos + center, m_toolSize.getValue());
|
|
Toshihiro Shimizu |
890ddd |
m_points.push_back(point);
|
|
Toshihiro Shimizu |
890ddd |
m_bluredBrush = new BluredBrush(m_workRas, m_toolSize.getValue(), m_brushPad, false);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRect bbox = m_bluredBrush->getBoundFromPoints(m_points);
|
|
Toshihiro Shimizu |
890ddd |
m_tileSaver->save(bbox);
|
|
Toshihiro Shimizu |
890ddd |
m_bluredBrush->addPoint(point, 1);
|
|
Toshihiro Shimizu |
890ddd |
m_bluredBrush->eraseDrawing(raster, m_backupRas, bbox, m_currentStyle.getValue(),
|
|
Toshihiro Shimizu |
890ddd |
currentStyle, m_colorType.getValue());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
/*--- 現在のFidを記憶する ---*/
|
|
Toshihiro Shimizu |
890ddd |
m_workingFrameId = getFrameId();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_eraseType.getValue() == FREEHANDERASE || m_eraseType.getValue() == POLYLINEERASE) {
|
|
Toshihiro Shimizu |
890ddd |
int col = getColumnIndex();
|
|
Toshihiro Shimizu |
890ddd |
m_enabled = col >= 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!m_enabled)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_multi.getValue() && m_firstStroke && !m_firstFrameSelected) {
|
|
Toshihiro Shimizu |
890ddd |
invalidateRect = m_firstStroke->getBBox();
|
|
Toshihiro Shimizu |
890ddd |
delete m_firstStroke;
|
|
Toshihiro Shimizu |
890ddd |
m_firstStroke = 0;
|
|
Toshihiro Shimizu |
890ddd |
invalidate(invalidateRect.enlarge(2));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_active = true;
|
|
Toshihiro Shimizu |
890ddd |
m_track.clear();
|
|
Toshihiro Shimizu |
890ddd |
m_firstPos = pos;
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize2 = getPixelSize() * getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
m_track.add(TThickPoint(pos, m_thick), pixelSize2);
|
|
Toshihiro Shimizu |
890ddd |
TPointD dpiScale = m_viewer->getDpiScale();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg ? TPixel32::White : TPixel32::Black;
|
|
Toshihiro Shimizu |
890ddd |
tglColor(color);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
getViewer()->startForegroundDrawing();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glPushMatrix();
|
|
Toshihiro Shimizu |
890ddd |
glScaled(dpiScale.x, dpiScale.y, 1);
|
|
Toshihiro Shimizu |
890ddd |
if (m_eraseType.getValue() == POLYLINEERASE) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_polyline.empty() || m_polyline.back() != pos)
|
|
Toshihiro Shimizu |
890ddd |
m_polyline.push_back(pos);
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
m_track.drawLastFragments();
|
|
Toshihiro Shimizu |
890ddd |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
getViewer()->endForegroundDrawing();
|
|
Toshihiro Shimizu |
890ddd |
int maxThick = 2 * m_thick;
|
|
Toshihiro Shimizu |
890ddd |
TPointD halfThick(maxThick * 0.5, maxThick * 0.5);
|
|
Toshihiro Shimizu |
890ddd |
invalidateRect = TRectD(pos - halfThick, pos + halfThick);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
invalidate(invalidateRect.enlarge(2));
|
|
Toshihiro Shimizu |
890ddd |
m_isLeftButtonPressed = true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void EraserTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
/*-- 先にLeftButtonDownに入っていなければreturn --*/
|
|
Toshihiro Shimizu |
890ddd |
if (!m_isLeftButtonPressed)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize2 = getPixelSize() * getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_brushPos = m_mousePos = pos;
|
|
Toshihiro Shimizu |
890ddd |
if (!m_selecting)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImageP image(getImage(true));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (TToonzImageP ti = image) {
|
|
Toshihiro Shimizu |
890ddd |
TRectD invalidateRect;
|
|
Toshihiro Shimizu |
890ddd |
TPointD rasCenter = ti->getRaster()->getCenterD();
|
|
Toshihiro Shimizu |
890ddd |
if (m_eraseType.getValue() == RECTERASE) {
|
|
Toshihiro Shimizu |
890ddd |
TRectD oldRect = m_selectingRect;
|
|
Toshihiro Shimizu |
890ddd |
if (oldRect.x0 > oldRect.x1)
|
|
Toshihiro Shimizu |
890ddd |
tswap(oldRect.x1, oldRect.x0);
|
|
Toshihiro Shimizu |
890ddd |
if (oldRect.y0 > oldRect.y1)
|
|
Toshihiro Shimizu |
890ddd |
tswap(oldRect.y1, oldRect.y0);
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.x1 = pos.x;
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.y1 = pos.y;
|
|
Toshihiro Shimizu |
890ddd |
invalidateRect = m_selectingRect;
|
|
Toshihiro Shimizu |
890ddd |
if (invalidateRect.x0 > invalidateRect.x1)
|
|
Toshihiro Shimizu |
890ddd |
tswap(invalidateRect.x1, invalidateRect.x0);
|
|
Toshihiro Shimizu |
890ddd |
if (invalidateRect.y0 > invalidateRect.y1)
|
|
Toshihiro Shimizu |
890ddd |
tswap(invalidateRect.y1, invalidateRect.y0);
|
|
Toshihiro Shimizu |
890ddd |
invalidateRect += oldRect;
|
|
Toshihiro Shimizu |
890ddd |
invalidate(invalidateRect.enlarge(2));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_eraseType.getValue() == NORMALERASE) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_normalEraser && (m_hardness.getValue() == 100 || m_pencil.getValue() || m_colorType.getValue() == AREAS)) {
|
|
Toshihiro Shimizu |
890ddd |
TPointD pp(pos.x, pos.y);
|
|
Toshihiro Shimizu |
890ddd |
TThickPoint intPos;
|
|
Toshihiro Shimizu |
890ddd |
if (m_pencil.getValue() || m_colorType.getValue() == AREAS)
|
|
Toshihiro Shimizu |
890ddd |
intPos = TThickPoint(pp + convert(ti->getRaster()->getCenter()), m_toolSize.getValue());
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
intPos = TThickPoint(pp + convert(ti->getRaster()->getCenter()), m_toolSize.getValue() - 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool isAdded = m_normalEraser->add(intPos);
|
|
Toshihiro Shimizu |
890ddd |
if (ti && isAdded) {
|
|
Toshihiro Shimizu |
890ddd |
m_tileSaver->save(m_normalEraser->getLastRect());
|
|
Toshihiro Shimizu |
890ddd |
m_normalEraser->generateLastPieceOfStroke(m_pencil.getValue() || m_colorType.getValue() == AREAS);
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tthickpoint> brushPoints = m_normalEraser->getPointsSequence();</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
int m = (int)brushPoints.size();
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tthickpoint> points;</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
if (m == 3) {
|
|
Toshihiro Shimizu |
890ddd |
points.push_back(brushPoints[0]);
|
|
Toshihiro Shimizu |
890ddd |
points.push_back(brushPoints[1]);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
points.push_back(brushPoints[m - 4]);
|
|
Toshihiro Shimizu |
890ddd |
points.push_back(brushPoints[m - 3]);
|
|
Toshihiro Shimizu |
890ddd |
points.push_back(brushPoints[m - 2]);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
invalidateRect = ToolUtils::getBounds(points, m_toolSize.getValue());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
assert(m_workRas.getPointer() && m_backupRas.getPointer());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TThickPoint old = m_points.back();
|
|
Toshihiro Shimizu |
890ddd |
if (norm2(pos - old) < 4)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int thickness = m_toolSize.getValue();
|
|
Toshihiro Shimizu |
890ddd |
TThickPoint point(pos + rasCenter, thickness);
|
|
Toshihiro Shimizu |
890ddd |
TThickPoint mid((old + point) * 0.5, (point.thick + old.thick) * 0.5);
|
|
Toshihiro Shimizu |
890ddd |
m_points.push_back(mid);
|
|
Toshihiro Shimizu |
890ddd |
m_points.push_back(point);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int currentStyle = 0;
|
|
Toshihiro Shimizu |
890ddd |
if (m_currentStyle.getValue())
|
|
Toshihiro Shimizu |
890ddd |
currentStyle = TTool::getApplication()->getCurrentLevelStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRect bbox;
|
|
Toshihiro Shimizu |
890ddd |
int m = (int)m_points.size();
|
|
Toshihiro Shimizu |
890ddd |
if (m == 3) {
|
|
Toshihiro Shimizu |
890ddd |
// ho appena cominciato. devo disegnare un segmento
|
|
Toshihiro Shimizu |
890ddd |
TThickPoint pa = m_points.front();
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tthickpoint> points;</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
points.push_back(pa);
|
|
Toshihiro Shimizu |
890ddd |
points.push_back(mid);
|
|
Toshihiro Shimizu |
890ddd |
invalidateRect = ToolUtils::getBounds(points, thickness);
|
|
Toshihiro Shimizu |
890ddd |
bbox = m_bluredBrush->getBoundFromPoints(points);
|
|
Toshihiro Shimizu |
890ddd |
m_bluredBrush->addArc(pa, (mid + pa) * 0.5, mid, 1, 1);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tthickpoint> points;</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
points.push_back(m_points[m - 4]);
|
|
Toshihiro Shimizu |
890ddd |
points.push_back(old);
|
|
Toshihiro Shimizu |
890ddd |
points.push_back(mid);
|
|
Toshihiro Shimizu |
890ddd |
invalidateRect = ToolUtils::getBounds(points, thickness);
|
|
Toshihiro Shimizu |
890ddd |
bbox = m_bluredBrush->getBoundFromPoints(points);
|
|
Toshihiro Shimizu |
890ddd |
m_bluredBrush->addArc(m_points[m - 4], old, mid, 1, 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_tileSaver->save(bbox);
|
|
Toshihiro Shimizu |
890ddd |
m_bluredBrush->eraseDrawing(ti->getRaster(), m_backupRas, bbox, m_currentStyle.getValue(),
|
|
Toshihiro Shimizu |
890ddd |
currentStyle, m_colorType.getValue());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
invalidate(invalidateRect.enlarge(2) - rasCenter);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_eraseType.getValue() == FREEHANDERASE) {
|
|
Toshihiro Shimizu |
890ddd |
if (!m_enabled || !m_active)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
getViewer()->startForegroundDrawing();
|
|
Toshihiro Shimizu |
890ddd |
TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg ? TPixel32::White : TPixel32::Black;
|
|
Toshihiro Shimizu |
890ddd |
tglColor(color);
|
|
Toshihiro Shimizu |
890ddd |
glPushMatrix();
|
|
Toshihiro Shimizu |
890ddd |
tglMultMatrix(getMatrix());
|
|
Toshihiro Shimizu |
890ddd |
TPointD dpiScale = m_viewer->getDpiScale();
|
|
Toshihiro Shimizu |
890ddd |
glScaled(dpiScale.x, dpiScale.y, 1);
|
|
Toshihiro Shimizu |
890ddd |
m_track.add(TThickPoint(pos, m_thick), pixelSize2);
|
|
Toshihiro Shimizu |
890ddd |
m_track.drawLastFragments();
|
|
Toshihiro Shimizu |
890ddd |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
getViewer()->endForegroundDrawing();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void EraserTool::onImageChanged()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_multi.getValue())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
TTool::Application *app = TTool::getApplication();
|
|
Toshihiro Shimizu |
890ddd |
TXshSimpleLevel *xshl = 0;
|
|
Toshihiro Shimizu |
890ddd |
if (app->getCurrentLevel()->getLevel())
|
|
Toshihiro Shimizu |
890ddd |
xshl = app->getCurrentLevel()->getSimpleLevel();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!xshl || m_level.getPointer() != xshl || (m_selectingRect.isEmpty() && !m_firstStroke))
|
|
Toshihiro Shimizu |
890ddd |
resetMulti();
|
|
Toshihiro Shimizu |
890ddd |
else if (m_firstFrameId == getFrameId())
|
|
Toshihiro Shimizu |
890ddd |
m_firstFrameSelected = false; //nel caso sono passato allo stato 1 e torno all'immagine iniziale, torno allo stato iniziale
|
|
Toshihiro Shimizu |
890ddd |
else { //cambio stato.
|
|
Toshihiro Shimizu |
890ddd |
m_firstFrameSelected = true;
|
|
Toshihiro Shimizu |
890ddd |
if (m_eraseType.getValue() != FREEHANDERASE && m_eraseType.getValue() != POLYLINEERASE) {
|
|
Toshihiro Shimizu |
890ddd |
assert(!m_selectingRect.isEmpty());
|
|
Toshihiro Shimizu |
890ddd |
m_firstRect = m_selectingRect;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void EraserTool::leftButtonUp(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
/*--先にLeftButtonDownに入っていなければ処理をしない--*/
|
|
Toshihiro Shimizu |
890ddd |
if (!m_isLeftButtonPressed)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
m_isLeftButtonPressed = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!m_selecting)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
TImageP image(getImage(true));
|
|
Toshihiro Shimizu |
890ddd |
if (TToonzImageP ti = image) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_eraseType.getValue() == RECTERASE) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_selectingRect.x0 > m_selectingRect.x1)
|
|
Toshihiro Shimizu |
890ddd |
tswap(m_selectingRect.x1, m_selectingRect.x0);
|
|
Toshihiro Shimizu |
890ddd |
if (m_selectingRect.y0 > m_selectingRect.y1)
|
|
Toshihiro Shimizu |
890ddd |
tswap(m_selectingRect.y1, m_selectingRect.y0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_multi.getValue()) {
|
|
Toshihiro Shimizu |
890ddd |
TTool::Application *app = TTool::getApplication();
|
|
Toshihiro Shimizu |
890ddd |
if (m_firstFrameSelected) {
|
|
Toshihiro Shimizu |
890ddd |
multiUpdate(m_level, m_firstFrameId, getFrameId(), m_firstRect, m_selectingRect);
|
|
Toshihiro Shimizu |
890ddd |
if (e.isShiftPressed()) {
|
|
Toshihiro Shimizu |
890ddd |
m_firstRect = m_selectingRect;
|
|
Toshihiro Shimizu |
890ddd |
m_firstFrameId = getFrameId();
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
if (m_isXsheetCell) {
|
|
Toshihiro Shimizu |
890ddd |
app->getCurrentColumn()->setColumnIndex(m_currCell.first);
|
|
Toshihiro Shimizu |
890ddd |
app->getCurrentFrame()->setFrame(m_currCell.second);
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
app->getCurrentFrame()->setFid(m_veryFirstFrameId);
|
|
Toshihiro Shimizu |
890ddd |
resetMulti();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
m_isXsheetCell = app->getCurrentFrame()->isEditingScene();
|
|
Toshihiro Shimizu |
890ddd |
m_currCell = std::pair<int, int="">(getColumnIndex(), getFrame());</int,>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
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 |
TFrameId frameId = getFrameId();
|
|
Toshihiro Shimizu |
890ddd |
if (m_invertOption.getValue()) {
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->beginBlock();
|
|
Toshihiro Shimizu |
890ddd |
TRectD rect = m_selectingRect;
|
|
Toshihiro Shimizu |
890ddd |
TRectD worldBBox = ToonzImageUtils::convertRasterToWorld(ti->getRaster()->getBounds(), ti);
|
|
Toshihiro Shimizu |
890ddd |
rect *= ToonzImageUtils::convertRasterToWorld(ti->getSavebox(), ti);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRectD rect01 = TRectD(worldBBox.getP00(), TPointD(rect.x0, worldBBox.y1));
|
|
Toshihiro Shimizu |
890ddd |
if (rect01.getLx() > 0 && rect01.getLy() > 0)
|
|
Toshihiro Shimizu |
890ddd |
update(ti, rect01, simLevel, false, frameId);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRectD rect02 = TRectD(rect.getP01(), TPointD(rect.x1, worldBBox.y1));
|
|
Toshihiro Shimizu |
890ddd |
if (rect02.getLx() > 0 && rect02.getLy() > 0)
|
|
Toshihiro Shimizu |
890ddd |
update(ti, rect02, simLevel, false, frameId);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRectD rect03 = TRectD(TPointD(rect.x0, worldBBox.y0), rect.getP10());
|
|
Toshihiro Shimizu |
890ddd |
if (rect03.getLx() > 0 && rect03.getLy() > 0)
|
|
Toshihiro Shimizu |
890ddd |
update(ti, rect03, simLevel, false, frameId);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRectD rect04 = TRectD(TPointD(rect.x1, worldBBox.y0), TPointD(worldBBox.x1, worldBBox.y1));
|
|
Toshihiro Shimizu |
890ddd |
if (rect04.getLx() > 0 && rect04.getLy() > 0)
|
|
Toshihiro Shimizu |
890ddd |
update(ti, rect04, simLevel, false, frameId);
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->endBlock();
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
update(ti, m_selectingRect, simLevel, false, frameId);
|
|
Toshihiro Shimizu |
890ddd |
invalidate(m_selectingRect.enlarge(2));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.empty();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TTool::getApplication()->getCurrentXsheet()->notifyXsheetChanged();
|
|
Toshihiro Shimizu |
890ddd |
notifyImageChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_eraseType.getValue() == NORMALERASE) {
|
|
Toshihiro Shimizu |
890ddd |
TTool::Application *app = TTool::getApplication();
|
|
Toshihiro Shimizu |
890ddd |
int currentStyle = app->getCurrentLevelStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
TXshLevel *level = app->getCurrentLevel()->getLevel();
|
|
Toshihiro Shimizu |
890ddd |
TXshSimpleLevelP simLevel = level->getSimpleLevel();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*--Erase中にフレームが動いても、クリック時のFidに対してUndoを記録する--*/
|
|
Toshihiro Shimizu |
890ddd |
TFrameId frameId = m_workingFrameId.isEmptyFrame() ? getCurrentFid() : m_workingFrameId;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_normalEraser && (m_hardness.getValue() == 100 || m_pencil.getValue() || m_colorType.getValue() == AREAS)) {
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->add(new RasterEraserUndo(m_tileSet, m_normalEraser->getPointsSequence(),
|
|
Toshihiro Shimizu |
890ddd |
m_colorTypeEraser, 0, m_normalEraser->isSelective(), currentStyle,
|
|
Toshihiro Shimizu |
890ddd |
simLevel.getPointer(), frameId,
|
|
Toshihiro Shimizu |
890ddd |
(m_pencil.getValue() || m_colorType.getValue() == AREAS)));
|
|
Toshihiro Shimizu |
890ddd |
app->getCurrentTool()->getTool()->notifyImageChanged(frameId);
|
|
Toshihiro Shimizu |
890ddd |
app->getCurrentXsheet()->notifyXsheetChanged();
|
|
Toshihiro Shimizu |
890ddd |
delete m_normalEraser;
|
|
Toshihiro Shimizu |
890ddd |
m_normalEraser = 0;
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
if (m_points.size() != 1) {
|
|
Toshihiro Shimizu |
890ddd |
TPointD rasCenter = ti->getRaster()->getCenterD();
|
|
Toshihiro Shimizu |
890ddd |
TThickPoint point(pos + rasCenter, m_toolSize.getValue());
|
|
Toshihiro Shimizu |
890ddd |
m_points.push_back(point);
|
|
Toshihiro Shimizu |
890ddd |
int m = m_points.size();
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tthickpoint> points;</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
points.push_back(m_points[m - 3]);
|
|
Toshihiro Shimizu |
890ddd |
points.push_back(m_points[m - 2]);
|
|
Toshihiro Shimizu |
890ddd |
points.push_back(m_points[m - 1]);
|
|
Toshihiro Shimizu |
890ddd |
TRect bbox = m_bluredBrush->getBoundFromPoints(points);
|
|
Toshihiro Shimizu |
890ddd |
m_tileSaver->save(bbox);
|
|
Toshihiro Shimizu |
890ddd |
m_bluredBrush->addArc(points[0], points[1], points[2], 1, 1);
|
|
Toshihiro Shimizu |
890ddd |
m_bluredBrush->eraseDrawing(ti->getRaster(), m_backupRas, bbox, m_currentStyle.getValue(),
|
|
Toshihiro Shimizu |
890ddd |
currentStyle, m_colorType.getValue());
|
|
Toshihiro Shimizu |
890ddd |
TRectD invalidateRect = ToolUtils::getBounds(points, m_toolSize.getValue());
|
|
Toshihiro Shimizu |
890ddd |
invalidate(invalidateRect.enlarge(2) - rasCenter);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_backupRas = TRasterCM32P();
|
|
Toshihiro Shimizu |
890ddd |
m_workRas = TRaster32P();
|
|
Toshihiro Shimizu |
890ddd |
delete m_bluredBrush;
|
|
Toshihiro Shimizu |
890ddd |
m_bluredBrush = 0;
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->add(new RasterBluredEraserUndo(m_tileSet, m_points,
|
|
Toshihiro Shimizu |
890ddd |
currentStyle, m_currentStyle.getValue(), simLevel.getPointer(),
|
|
Toshihiro Shimizu |
890ddd |
frameId, m_toolSize.getValue(), m_hardness.getValue() * 0.01, m_colorType.getValue()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
delete m_tileSaver;
|
|
Toshihiro Shimizu |
890ddd |
m_tileSaver = 0;
|
|
Toshihiro Shimizu |
890ddd |
/*-- 作業したフレームをシグナルで知らせる --*/
|
|
Toshihiro Shimizu |
890ddd |
notifyImageChanged(frameId);
|
|
Toshihiro Shimizu |
890ddd |
/*-- 作業フレームをリセット --*/
|
|
Toshihiro Shimizu |
890ddd |
m_workingFrameId = TFrameId();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_eraseType.getValue() == FREEHANDERASE) {
|
|
Toshihiro Shimizu |
890ddd |
bool isValid = m_enabled && m_active;
|
|
Toshihiro Shimizu |
890ddd |
m_enabled = m_active = false;
|
|
Toshihiro Shimizu |
890ddd |
if (!isValid)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
if (m_track.isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize2 = getPixelSize() * getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
m_track.add(TThickPoint(m_firstPos, m_thick), pixelSize2);
|
|
Toshihiro Shimizu |
890ddd |
m_track.filterPoints();
|
|
Toshihiro Shimizu |
890ddd |
double error = (30.0 / 11) * sqrt(pixelSize2);
|
|
Toshihiro Shimizu |
890ddd |
TStroke *stroke = m_track.makeStroke(error);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
stroke->setStyle(1);
|
|
Toshihiro Shimizu |
890ddd |
m_track.clear();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TTool::Application *app = TTool::getApplication();
|
|
Toshihiro Shimizu |
890ddd |
int styleId = app->getCurrentLevelStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
if (m_multi.getValue()) //stroke multi
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_firstFrameSelected) {
|
|
Toshihiro Shimizu |
890ddd |
TFrameId tmp = getFrameId();
|
|
Toshihiro Shimizu |
890ddd |
if (m_firstStroke && stroke)
|
|
Toshihiro Shimizu |
890ddd |
multiAreaEraser(m_level, m_firstFrameId, tmp, m_firstStroke, stroke);
|
|
Toshihiro Shimizu |
890ddd |
notifyImageChanged();
|
|
Toshihiro Shimizu |
890ddd |
if (e.isShiftPressed()) {
|
|
Toshihiro Shimizu |
890ddd |
TRectD invalidateRect = m_firstStroke->getBBox();
|
|
Toshihiro Shimizu |
890ddd |
delete m_firstStroke;
|
|
Toshihiro Shimizu |
890ddd |
m_firstStroke = 0;
|
|
Toshihiro Shimizu |
890ddd |
invalidate(invalidateRect.enlarge(2));
|
|
Toshihiro Shimizu |
890ddd |
m_firstStroke = stroke;
|
|
Toshihiro Shimizu |
890ddd |
invalidateRect = m_firstStroke->getBBox();
|
|
Toshihiro Shimizu |
890ddd |
invalidate(invalidateRect.enlarge(2));
|
|
Toshihiro Shimizu |
890ddd |
m_firstFrameId = getFrameId();
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
if (m_isXsheetCell) {
|
|
Toshihiro Shimizu |
890ddd |
app->getCurrentColumn()->setColumnIndex(m_currCell.first);
|
|
Toshihiro Shimizu |
890ddd |
app->getCurrentFrame()->setFrame(m_currCell.second);
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
app->getCurrentFrame()->setFid(m_veryFirstFrameId);
|
|
Toshihiro Shimizu |
890ddd |
resetMulti();
|
|
Toshihiro Shimizu |
890ddd |
delete stroke;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else //primo frame
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_firstStroke = stroke;
|
|
Toshihiro Shimizu |
890ddd |
m_isXsheetCell = app->getCurrentFrame()->isEditingScene();
|
|
Toshihiro Shimizu |
890ddd |
m_currCell = std::pair<int, int="">(getColumnIndex(), getFrame());</int,>
|
|
Toshihiro Shimizu |
890ddd |
invalidate(m_firstStroke->getBBox().enlarge(2));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else //stroke non multi
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!getImage(true))
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
TXshLevel *level = app->getCurrentLevel()->getLevel();
|
|
Toshihiro Shimizu |
890ddd |
TXshSimpleLevelP simLevel = level->getSimpleLevel();
|
|
Toshihiro Shimizu |
890ddd |
TFrameId frameId = getFrameId();
|
|
Toshihiro Shimizu |
890ddd |
eraseStroke(image, stroke, m_eraseType.getValue(), m_colorType.getValue(),
|
|
Toshihiro Shimizu |
890ddd |
m_invertOption.getValue(), m_currentStyle.getValue(), styleId, simLevel,
|
|
Toshihiro Shimizu |
890ddd |
frameId);
|
|
Toshihiro Shimizu |
890ddd |
notifyImageChanged();
|
|
Toshihiro Shimizu |
890ddd |
if (m_invertOption.getValue())
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
invalidate(stroke->getBBox().enlarge(2));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
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 |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void EraserTool::leftButtonDoubleClick(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TStroke *stroke;
|
|
Toshihiro Shimizu |
890ddd |
TTool::Application *app = TTool::getApplication();
|
|
Toshihiro Shimizu |
890ddd |
if (m_polyline.size() <= 1) {
|
|
Toshihiro Shimizu |
890ddd |
resetMulti();
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_polyline.back() != pos)
|
|
Toshihiro Shimizu |
890ddd |
m_polyline.push_back(pos);
|
|
Toshihiro Shimizu |
890ddd |
if (m_polyline.back() != m_polyline.front())
|
|
Toshihiro Shimizu |
890ddd |
m_polyline.push_back(m_polyline.front());
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tthickpoint> strokePoints;</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
for (UINT i = 0; i < m_polyline.size() - 1; i++) {
|
|
Toshihiro Shimizu |
890ddd |
strokePoints.push_back(TThickPoint(m_polyline[i], 1));
|
|
Toshihiro Shimizu |
890ddd |
strokePoints.push_back(TThickPoint(0.5 * (m_polyline[i] + m_polyline[i + 1]), 1));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
strokePoints.push_back(TThickPoint(m_polyline.back(), 1));
|
|
Toshihiro Shimizu |
890ddd |
m_polyline.clear();
|
|
Toshihiro Shimizu |
890ddd |
stroke = new TStroke(strokePoints);
|
|
Toshihiro Shimizu |
890ddd |
assert(stroke->getPoint(0) == stroke->getPoint(1));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int styleId = app->getCurrentLevelStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
if (m_multi.getValue()) //stroke multi
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_firstFrameSelected) {
|
|
Toshihiro Shimizu |
890ddd |
TFrameId tmp = getFrameId();
|
|
Toshihiro Shimizu |
890ddd |
if (m_firstStroke && stroke)
|
|
Toshihiro Shimizu |
890ddd |
multiAreaEraser(m_level, m_firstFrameId, tmp, m_firstStroke, stroke);
|
|
Toshihiro Shimizu |
890ddd |
if (e.isShiftPressed()) {
|
|
Toshihiro Shimizu |
890ddd |
TRectD invalidateRect = m_firstStroke->getBBox();
|
|
Toshihiro Shimizu |
890ddd |
delete m_firstStroke;
|
|
Toshihiro Shimizu |
890ddd |
m_firstStroke = 0;
|
|
Toshihiro Shimizu |
890ddd |
invalidate(invalidateRect.enlarge(2));
|
|
Toshihiro Shimizu |
890ddd |
m_firstStroke = stroke;
|
|
Toshihiro Shimizu |
890ddd |
invalidateRect = m_firstStroke->getBBox();
|
|
Toshihiro Shimizu |
890ddd |
invalidate(invalidateRect.enlarge(2));
|
|
Toshihiro Shimizu |
890ddd |
m_firstFrameId = getFrameId();
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
if (m_isXsheetCell) {
|
|
Toshihiro Shimizu |
890ddd |
app->getCurrentColumn()->setColumnIndex(m_currCell.first);
|
|
Toshihiro Shimizu |
890ddd |
app->getCurrentFrame()->setFrame(m_currCell.second);
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
app->getCurrentFrame()->setFid(m_veryFirstFrameId);
|
|
Toshihiro Shimizu |
890ddd |
resetMulti();
|
|
Toshihiro Shimizu |
890ddd |
delete stroke;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else //primo frame
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_firstStroke = stroke;
|
|
Toshihiro Shimizu |
890ddd |
m_isXsheetCell = app->getCurrentFrame()->isEditingScene();
|
|
Toshihiro Shimizu |
890ddd |
m_currCell = std::pair<int, int="">(getColumnIndex(), getFrame());</int,>
|
|
Toshihiro Shimizu |
890ddd |
invalidate(m_firstStroke->getBBox().enlarge(2));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
if (!getImage(true))
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
TXshLevel *level = app->getCurrentLevel()->getLevel();
|
|
Toshihiro Shimizu |
890ddd |
TXshSimpleLevelP simLevel = level->getSimpleLevel();
|
|
Toshihiro Shimizu |
890ddd |
TFrameId frameId = getFrameId();
|
|
Toshihiro Shimizu |
890ddd |
TToonzImageP ti = (TToonzImageP)getImage(true);
|
|
Toshihiro Shimizu |
890ddd |
eraseStroke(ti, stroke, m_eraseType.getValue(), m_colorType.getValue(),
|
|
Toshihiro Shimizu |
890ddd |
m_invertOption.getValue(), m_currentStyle.getValue(), styleId, simLevel, frameId);
|
|
Toshihiro Shimizu |
890ddd |
notifyImageChanged();
|
|
Toshihiro Shimizu |
890ddd |
if (m_invertOption.getValue())
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
invalidate(stroke->getBBox().enlarge(2));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
bool EraserTool::onPropertyChanged(std::string propertyName)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
/*--- 変更されたPropertyに合わせて処理を分ける ---*/
|
|
Toshihiro Shimizu |
890ddd |
if (propertyName == m_eraseType.getName()) {
|
|
Toshihiro Shimizu |
890ddd |
/*--- polylineにした時、前回のpolyline選択をクリアする ---*/
|
|
Toshihiro Shimizu |
890ddd |
if (m_eraseType.getValue() == POLYLINEERASE && !m_polyline.empty())
|
|
Toshihiro Shimizu |
890ddd |
m_polyline.clear();
|
|
Toshihiro Shimizu |
890ddd |
EraseType = toString(m_eraseType.getValue());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
else if (propertyName == m_toolSize.getName()) {
|
|
Toshihiro Shimizu |
890ddd |
EraseSize = m_toolSize.getValue();
|
|
Toshihiro Shimizu |
890ddd |
m_cleanerSize = m_toolSize.getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_brushPad = ToolUtils::getBrushPad(m_toolSize.getValue(), m_hardness.getValue() * 0.01);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
else if (propertyName == m_invertOption.getName())
|
|
Toshihiro Shimizu |
890ddd |
EraseInvert = m_invertOption.getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
else if (propertyName == m_currentStyle.getName())
|
|
Toshihiro Shimizu |
890ddd |
EraseSelective = m_currentStyle.getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
else if (propertyName == m_multi.getName()) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_multi.getValue())
|
|
Toshihiro Shimizu |
890ddd |
resetMulti();
|
|
Toshihiro Shimizu |
890ddd |
EraseRange = m_multi.getValue();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
else if (propertyName == m_pencil.getName()) {
|
|
Toshihiro Shimizu |
890ddd |
ErasePencil = m_pencil.getValue();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
else if (propertyName == m_colorType.getName()) {
|
|
Toshihiro Shimizu |
890ddd |
EraseColorType = 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 |
else if (propertyName == m_hardness.getName()) {
|
|
Toshihiro Shimizu |
890ddd |
EraseHardness = m_hardness.getValue();
|
|
Toshihiro Shimizu |
890ddd |
m_brushPad = ToolUtils::getBrushPad(m_toolSize.getValue(), m_hardness.getValue() * 0.01);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (propertyName == m_hardness.getName() || propertyName == m_toolSize.getName()) {
|
|
Toshihiro Shimizu |
890ddd |
m_brushPad = ToolUtils::getBrushPad(m_toolSize.getValue(), m_hardness.getValue() * 0.01);
|
|
Toshihiro Shimizu |
890ddd |
TRectD rect(m_brushPos - TPointD(EraseSize + 2, EraseSize + 2),
|
|
Toshihiro Shimizu |
890ddd |
m_brushPos + TPointD(EraseSize + 2, EraseSize + 2));
|
|
Toshihiro Shimizu |
890ddd |
invalidate(rect);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*--- Erase動作中にプロパティが変わったら、終了処理を行う ---*/
|
|
Toshihiro Shimizu |
890ddd |
if (m_isLeftButtonPressed) {
|
|
Toshihiro Shimizu |
890ddd |
storeUndoAndRefresh();
|
|
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 EraserTool::mouseMove(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
struct Locals {
|
|
Toshihiro Shimizu |
890ddd |
EraserTool *m_this;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void setValue(TIntProperty &prop, int value)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
prop.setValue(value);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_this->onPropertyChanged(prop.getName());
|
|
Toshihiro Shimizu |
890ddd |
TTool::getApplication()->getCurrentTool()->notifyToolChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void addValue(TIntProperty &prop, double add)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
const TIntProperty::Range &range = prop.getRange();
|
|
Toshihiro Shimizu |
890ddd |
setValue(prop, tcrop<double>(prop.getValue() + add, range.first, range.second));</double>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} locals = {this};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
switch (e.getModifiersMask()) {
|
|
Toshihiro Shimizu |
890ddd |
case TMouseEvent::ALT_KEY: {
|
|
Toshihiro Shimizu |
890ddd |
// User wants to alter the maximum brush size
|
|
Toshihiro Shimizu |
890ddd |
const TPointD &diff = pos - m_mousePos;
|
|
Toshihiro Shimizu |
890ddd |
double add = (fabs(diff.x) > fabs(diff.y)) ? diff.x : diff.y;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
locals.addValue(m_toolSize, add);
|
|
Shinya Kitaoka |
d4642c |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d4642c |
default:
|
|
Toshihiro Shimizu |
890ddd |
m_brushPos = pos;
|
|
Shinya Kitaoka |
d4642c |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_mousePos = pos;
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void EraserTool::onEnter()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TToonzImageP ti(getImage(false));
|
|
Toshihiro Shimizu |
890ddd |
if (!ti)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
if (m_firstTime) {
|
|
Toshihiro Shimizu |
890ddd |
m_toolSize.setValue(EraseSize);
|
|
Toshihiro Shimizu |
890ddd |
m_eraseType.setValue(toWideString(EraseType.getValue()));
|
|
Toshihiro Shimizu |
890ddd |
m_currentStyle.setValue(EraseSelective ? 1 : 0);
|
|
Toshihiro Shimizu |
890ddd |
m_invertOption.setValue(EraseInvert ? 1 : 0);
|
|
Toshihiro Shimizu |
890ddd |
m_colorType.setValue(toWideString(EraseColorType.getValue()));
|
|
Toshihiro Shimizu |
890ddd |
m_multi.setValue(EraseRange ? 1 : 0);
|
|
Toshihiro Shimizu |
890ddd |
m_hardness.setValue(EraseHardness);
|
|
Toshihiro Shimizu |
890ddd |
m_pencil.setValue(ErasePencil);
|
|
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.1;
|
|
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 |
// getApplication()->editImage();
|
|
Toshihiro Shimizu |
890ddd |
m_cleanerSize = m_toolSize.getValue();
|
|
Toshihiro Shimizu |
890ddd |
TTool::Application *app = TTool::getApplication();
|
|
Toshihiro Shimizu |
890ddd |
m_level = app->getCurrentLevel()->getLevel()
|
|
Toshihiro Shimizu |
890ddd |
? app->getCurrentLevel()->getSimpleLevel()
|
|
Toshihiro Shimizu |
890ddd |
: 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void EraserTool::onLeave()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_pointSize = -1;
|
|
Toshihiro Shimizu |
890ddd |
m_cleanerSize = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void EraserTool::onActivate()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_multi.getValue())
|
|
Toshihiro Shimizu |
890ddd |
resetMulti();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*-- 他のツールからpolylineに入った時、前回のpolyline選択をクリアする --*/
|
|
Toshihiro Shimizu |
890ddd |
if (m_eraseType.getValue() == POLYLINEERASE && !m_polyline.empty())
|
|
Toshihiro Shimizu |
890ddd |
m_polyline.clear();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
onEnter();
|
|
Toshihiro Shimizu |
890ddd |
m_brushPad = ToolUtils::getBrushPad(m_toolSize.getValue(), m_hardness.getValue() * 0.01);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void EraserTool::multiAreaEraser(const TXshSimpleLevelP &sl, TFrameId &firstFid, TFrameId &lastFid,
|
|
Toshihiro Shimizu |
890ddd |
TStroke *firstStroke, TStroke *lastStroke)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TStroke *first = new TStroke();
|
|
Toshihiro Shimizu |
890ddd |
TStroke *last = new TStroke();
|
|
Toshihiro Shimizu |
890ddd |
*first = *firstStroke;
|
|
Toshihiro Shimizu |
890ddd |
*last = *lastStroke;
|
|
Toshihiro Shimizu |
890ddd |
TVectorImageP firstImage = new TVectorImage();
|
|
Toshihiro Shimizu |
890ddd |
TVectorImageP lastImage = new TVectorImage();
|
|
Toshihiro Shimizu |
890ddd |
firstImage->addStroke(first);
|
|
Toshihiro Shimizu |
890ddd |
lastImage->addStroke(last);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool backward = false;
|
|
Toshihiro Shimizu |
890ddd |
if (firstFid > lastFid) {
|
|
Toshihiro Shimizu |
890ddd |
tswap(firstFid, lastFid);
|
|
Toshihiro Shimizu |
890ddd |
backward = true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
assert(firstFid <= lastFid);
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tframeid> allFids;</tframeid>
|
|
Toshihiro Shimizu |
890ddd |
sl->getFids(allFids);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::vector<tframeid>::iterator i0 = allFids.begin();</tframeid>
|
|
Toshihiro Shimizu |
890ddd |
while (i0 != allFids.end() && *i0 < firstFid)
|
|
Toshihiro Shimizu |
890ddd |
i0++;
|
|
Toshihiro Shimizu |
890ddd |
if (i0 == allFids.end())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
std::vector<tframeid>::iterator i1 = i0;</tframeid>
|
|
Toshihiro Shimizu |
890ddd |
while (i1 != allFids.end() && *i1 <= lastFid)
|
|
Toshihiro Shimizu |
890ddd |
i1++;
|
|
Toshihiro Shimizu |
890ddd |
assert(i0 < i1);
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tframeid> fids(i0, i1);</tframeid>
|
|
Toshihiro Shimizu |
890ddd |
int m = fids.size();
|
|
Toshihiro Shimizu |
890ddd |
assert(m > 0);
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->beginBlock();
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < m; ++i) {
|
|
Toshihiro Shimizu |
890ddd |
TFrameId fid = fids[i];
|
|
Toshihiro Shimizu |
890ddd |
assert(firstFid <= fid && fid <= lastFid);
|
|
Toshihiro Shimizu |
890ddd |
TImageP img = sl->getFrame(fid, true);
|
|
Toshihiro Shimizu |
890ddd |
double t = m > 1 ? (double)i / (double)(m - 1) : 0.5;
|
|
Toshihiro Shimizu |
890ddd |
doMultiEraser(img, backward ? 1 - t : t, sl, fid, firstImage, lastImage);
|
|
Toshihiro Shimizu |
890ddd |
sl->getProperties()->setDirtyFlag(true);
|
|
Toshihiro Shimizu |
890ddd |
notifyImageChanged(fid);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->endBlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void EraserTool::doMultiEraser(const TImageP &img, double t,
|
|
Toshihiro Shimizu |
890ddd |
const TXshSimpleLevelP &sl, const TFrameId &fid,
|
|
Toshihiro Shimizu |
890ddd |
const TVectorImageP &firstImage, const TVectorImageP &lastImage)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
// ColorController::instance()->switchToLevelPalette();
|
|
Toshihiro Shimizu |
890ddd |
int styleId = TTool::getApplication()->getCurrentLevelStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
if (t == 0)
|
|
Toshihiro Shimizu |
890ddd |
eraseStroke(img, firstImage->getStroke(0), m_eraseType.getValue(), m_colorType.getValue(),
|
|
Toshihiro Shimizu |
890ddd |
m_invertOption.getValue(), m_currentStyle.getValue(), styleId, sl, fid);
|
|
Toshihiro Shimizu |
890ddd |
else if (t == 1)
|
|
Toshihiro Shimizu |
890ddd |
eraseStroke(img, lastImage->getStroke(0), m_eraseType.getValue(), m_colorType.getValue(),
|
|
Toshihiro Shimizu |
890ddd |
m_invertOption.getValue(), m_currentStyle.getValue(), styleId, sl, fid);
|
|
Toshihiro Shimizu |
890ddd |
else {
|
|
Toshihiro Shimizu |
890ddd |
assert(firstImage->getStrokeCount() == 1);
|
|
Toshihiro Shimizu |
890ddd |
assert(lastImage->getStrokeCount() == 1);
|
|
Toshihiro Shimizu |
890ddd |
TVectorImageP vi = TInbetween(firstImage, lastImage).tween(t);
|
|
Toshihiro Shimizu |
890ddd |
assert(vi->getStrokeCount() == 1);
|
|
Toshihiro Shimizu |
890ddd |
eraseStroke(img, vi->getStroke(0), m_eraseType.getValue(), m_colorType.getValue(),
|
|
Toshihiro Shimizu |
890ddd |
m_invertOption.getValue(), m_currentStyle.getValue(), styleId, sl, fid);
|
|
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 EraserTool::onDeactivate()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_isLeftButtonPressed || !m_selecting)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
storeUndoAndRefresh();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*-- Erase終了処理 --*/
|
|
Toshihiro Shimizu |
890ddd |
void EraserTool::storeUndoAndRefresh()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_isLeftButtonPressed = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*-- 各データのリフレッシュ --*/
|
|
Toshihiro Shimizu |
890ddd |
if (m_firstStroke) {
|
|
Toshihiro Shimizu |
890ddd |
delete m_firstStroke;
|
|
Toshihiro Shimizu |
890ddd |
m_firstStroke = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_normalEraser) {
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->add(new RasterEraserUndo(m_tileSet,
|
|
Toshihiro Shimizu |
890ddd |
m_normalEraser->getPointsSequence(),
|
|
Toshihiro Shimizu |
890ddd |
m_colorTypeEraser,
|
|
Toshihiro Shimizu |
890ddd |
0,
|
|
Toshihiro Shimizu |
890ddd |
m_normalEraser->isSelective(),
|
|
Toshihiro Shimizu |
890ddd |
TTool::getApplication()->getCurrentLevelStyleIndex(),
|
|
Toshihiro Shimizu |
890ddd |
TTool::getApplication()->getCurrentLevel()->getLevel()->getSimpleLevel(),
|
|
Toshihiro Shimizu |
890ddd |
m_workingFrameId.isEmptyFrame() ? getCurrentFid() : m_workingFrameId,
|
|
Toshihiro Shimizu |
890ddd |
(m_pencil.getValue() || m_colorType.getValue() == AREAS)));
|
|
Toshihiro Shimizu |
890ddd |
delete m_normalEraser;
|
|
Toshihiro Shimizu |
890ddd |
m_normalEraser = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_bluredBrush) {
|
|
Toshihiro Shimizu |
890ddd |
m_backupRas = TRasterCM32P();
|
|
Toshihiro Shimizu |
890ddd |
m_workRas = TRaster32P();
|
|
Toshihiro Shimizu |
890ddd |
delete m_bluredBrush;
|
|
Toshihiro Shimizu |
890ddd |
m_bluredBrush = 0;
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->add(new RasterBluredEraserUndo(m_tileSet, m_points,
|
|
Toshihiro Shimizu |
890ddd |
TTool::getApplication()->getCurrentLevelStyleIndex(),
|
|
Toshihiro Shimizu |
890ddd |
m_currentStyle.getValue(),
|
|
Toshihiro Shimizu |
890ddd |
TTool::getApplication()->getCurrentLevel()->getLevel()->getSimpleLevel(),
|
|
Toshihiro Shimizu |
890ddd |
m_workingFrameId.isEmptyFrame() ? getCurrentFid() : m_workingFrameId,
|
|
Toshihiro Shimizu |
890ddd |
m_toolSize.getValue(),
|
|
Toshihiro Shimizu |
890ddd |
m_hardness.getValue() * 0.01,
|
|
Toshihiro Shimizu |
890ddd |
m_colorType.getValue()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_tileSaver) {
|
|
Toshihiro Shimizu |
890ddd |
delete m_tileSaver;
|
|
Toshihiro Shimizu |
890ddd |
m_tileSaver = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRectD invalidateRect;
|
|
Toshihiro Shimizu |
890ddd |
if (m_firstRect != TRectD()) {
|
|
Toshihiro Shimizu |
890ddd |
invalidateRect += m_firstRect;
|
|
Toshihiro Shimizu |
890ddd |
m_firstRect.empty();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_selectingRect != TRectD()) {
|
|
Toshihiro Shimizu |
890ddd |
invalidateRect += m_selectingRect;
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.empty();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (!m_track.isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
m_track.clear();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!invalidateRect.isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
invalidate(invalidateRect.enlarge(2));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Brush、PaintBrush、EraserToolがPencilModeのときにTrueを返す
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
bool EraserTool::isPencilModeActive()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_eraseType.getValue() == NORMALERASE && m_pencil.getValue();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} //namespace
|