|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/tool.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tundo.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tproperty.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/cursors.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/autoclose.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ttoonzimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzimageutils.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tenv.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/toolutils.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshsimplelevel.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/ttileset.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/levelproperties.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/stage2.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tvectorimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/strokegenerator.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstroke.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "drawutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tinbetween.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheethandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tframehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcolumnhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tpalettehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevelhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/toolhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// For Qt translation support
|
|
Toshihiro Shimizu |
890ddd |
#include <qcoreapplication></qcoreapplication>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using namespace ToolUtils;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TEnv::StringVar AutocloseVectorType("InknpaintAutocloseVectorType", "Normal");
|
|
Toshihiro Shimizu |
890ddd |
TEnv::DoubleVar AutocloseDistance("InknpaintAutocloseDistance", 10.0);
|
|
Toshihiro Shimizu |
890ddd |
TEnv::DoubleVar AutocloseAngle("InknpaintAutocloseAngle", 60.0);
|
|
Toshihiro Shimizu |
890ddd |
TEnv::IntVar AutocloseRange("InknpaintAutocloseRange", 0);
|
|
Toshihiro Shimizu |
890ddd |
TEnv::IntVar AutocloseOpacity("InknpaintAutocloseOpacity", 1);
|
|
Toshihiro Shimizu |
890ddd |
#define NORMAL_CLOSE L"Normal"
|
|
Toshihiro Shimizu |
890ddd |
#define RECT_CLOSE L"Rectangular"
|
|
Toshihiro Shimizu |
890ddd |
#define FREEHAND_CLOSE L"Freehand"
|
|
Toshihiro Shimizu |
890ddd |
#define POLYLINE_CLOSE L"Polyline"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//============================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class AutocloseParameters
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
int m_closingDistance, m_inkIndex, m_opacity;
|
|
Toshihiro Shimizu |
890ddd |
double m_spotAngle;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
AutocloseParameters()
|
|
Toshihiro Shimizu |
890ddd |
: m_closingDistance(0), m_inkIndex(0), m_spotAngle(0), m_opacity(1)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//============================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class RasterAutocloseUndo : public TRasterUndo
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
AutocloseParameters m_params;
|
|
Toshihiro Shimizu |
890ddd |
std::vector<tautocloser::segment> m_segments;</tautocloser::segment>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
RasterAutocloseUndo(
|
|
Toshihiro Shimizu |
890ddd |
TTileSetCM32 *tileSet,
|
|
Toshihiro Shimizu |
890ddd |
const AutocloseParameters ¶ms,
|
|
Toshihiro Shimizu |
890ddd |
const std::vector<tautocloser::segment> &segments,</tautocloser::segment>
|
|
Toshihiro Shimizu |
890ddd |
TXshSimpleLevel *level, const TFrameId &frameId)
|
|
Toshihiro Shimizu |
890ddd |
: TRasterUndo(tileSet, level, frameId, false, false, 0), m_segments(segments), m_params(params)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void redo() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TToonzImageP image = getImage();
|
|
Toshihiro Shimizu |
890ddd |
if (!image)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
TAutocloser ac(image->getRaster(), m_params.m_closingDistance, m_params.m_spotAngle, m_params.m_inkIndex, m_params.m_opacity);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ac.draw(m_segments);
|
|
Toshihiro Shimizu |
890ddd |
ToolUtils::updateSaveBox();
|
|
Toshihiro Shimizu |
890ddd |
/*-- Viewerを更新させるため --*/
|
|
Toshihiro Shimizu |
890ddd |
TTool::getApplication()->getCurrentXsheet()->notifyXsheetChanged();
|
|
Toshihiro Shimizu |
890ddd |
notifyImageChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
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("Autoclose Tool");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
int getHistoryType()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return HistoryType::AutocloseTool;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//============================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class RasterTapeTool : public TTool
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Q_DECLARE_TR_FUNCTIONS(RasterTapeTool)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool m_selecting;
|
|
Toshihiro Shimizu |
890ddd |
TRectD m_selectingRect;
|
|
Toshihiro Shimizu |
890ddd |
TRectD m_firstRect;
|
|
Toshihiro Shimizu |
890ddd |
TPointD m_firstPoint;
|
|
Toshihiro Shimizu |
890ddd |
bool m_firstFrameSelected;
|
|
Toshihiro Shimizu |
890ddd |
TXshSimpleLevelP m_level;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//TBoolProperty m_isRect;
|
|
Toshihiro Shimizu |
890ddd |
TEnumProperty m_closeType;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleProperty m_distance;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleProperty m_angle;
|
|
Toshihiro Shimizu |
890ddd |
TStyleIndexProperty m_inkIndex;
|
|
Toshihiro Shimizu |
890ddd |
TIntProperty m_opacity;
|
|
Toshihiro Shimizu |
890ddd |
TPropertyGroup m_prop;
|
|
Toshihiro Shimizu |
890ddd |
TBoolProperty m_multi;
|
|
Toshihiro Shimizu |
890ddd |
TFrameId m_firstFrameId, m_veryFirstFrameId;
|
|
Toshihiro Shimizu |
890ddd |
bool m_isXsheetCell;
|
|
Toshihiro Shimizu |
890ddd |
std::pair<int, int=""> m_currCell;</int,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Aggiunte per disegnare il lazzo a la polyline
|
|
Toshihiro Shimizu |
890ddd |
StrokeGenerator m_track;
|
|
Toshihiro Shimizu |
890ddd |
TPointD m_firstPos;
|
|
Toshihiro Shimizu |
890ddd |
TPointD m_mousePosition;
|
|
Toshihiro Shimizu |
890ddd |
double m_thick;
|
|
Toshihiro Shimizu |
890ddd |
TStroke *m_stroke;
|
|
Toshihiro Shimizu |
890ddd |
TStroke *m_firstStroke;
|
|
Toshihiro Shimizu |
890ddd |
vector<tpointd> m_polyline;</tpointd>
|
|
Toshihiro Shimizu |
890ddd |
bool m_firstTime;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
RasterTapeTool()
|
|
Toshihiro Shimizu |
890ddd |
: TTool("T_Tape"), m_closeType("Type:") //W_ToolOptions_CloseType
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_distance("Distance:", 1, 100, 10) //W_ToolOptions_Distance
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_angle("Angle:", 1, 180, 60) //W_ToolOptions_Angle
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_inkIndex("Style Index:", L"current") //W_ToolOptions_InkIndex
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_opacity("Opacity:", 1, 255, 255), m_multi("Frame Range", false) //W_ToolOptions_FrameRange
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_selecting(false), m_selectingRect(), m_firstRect(), m_level(0), m_firstFrameSelected(false), m_isXsheetCell(false), m_currCell(-1, -1), m_firstPos(), m_mousePosition(), m_thick(0.5), m_stroke(0), m_firstStroke(0), m_firstTime(true)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
bind(TTool::ToonzImage);
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_closeType);
|
|
Toshihiro Shimizu |
890ddd |
m_closeType.addValue(NORMAL_CLOSE);
|
|
Toshihiro Shimizu |
890ddd |
m_closeType.addValue(RECT_CLOSE);
|
|
Toshihiro Shimizu |
890ddd |
m_closeType.addValue(FREEHAND_CLOSE);
|
|
Toshihiro Shimizu |
890ddd |
m_closeType.addValue(POLYLINE_CLOSE);
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_multi);
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_distance);
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_angle);
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_inkIndex);
|
|
Toshihiro Shimizu |
890ddd |
m_prop.bind(m_opacity);
|
|
Toshihiro Shimizu |
890ddd |
m_multi.setId("FrameRange");
|
|
Toshihiro Shimizu |
890ddd |
m_closeType.setId("Type");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToolType getToolType() const { return TTool::LevelWriteTool; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void updateTranslation()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_closeType.setQStringName(tr("Type:"));
|
|
Toshihiro Shimizu |
890ddd |
m_distance.setQStringName(tr("Distance:"));
|
|
Toshihiro Shimizu |
890ddd |
m_inkIndex.setQStringName(tr("Style Index:"));
|
|
Toshihiro Shimizu |
890ddd |
m_opacity.setQStringName(tr("Opacity:"));
|
|
Toshihiro Shimizu |
890ddd |
m_multi.setQStringName(tr("Frame Range"));
|
|
Toshihiro Shimizu |
890ddd |
m_angle.setQStringName(tr("Angle:"));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_closeType.getValue() == RECT_CLOSE) {
|
|
Toshihiro Shimizu |
890ddd |
if (!m_selecting)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.x1 = pos.x;
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.y1 = pos.y;
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
} else if (m_closeType.getValue() == FREEHAND_CLOSE) {
|
|
Toshihiro Shimizu |
890ddd |
freehandDrag(pos);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*-- AutoCloseが実行されたらtrue,実行されなければfalseを返す --*/
|
|
Toshihiro Shimizu |
890ddd |
bool applyAutoclose(const TToonzImageP &ti,
|
|
Toshihiro Shimizu |
890ddd |
const TRectD &selRect = TRectD(),
|
|
Toshihiro Shimizu |
890ddd |
TStroke *stroke = 0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!ti)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
//inizializzo gli AutocloseParameters
|
|
Toshihiro Shimizu |
890ddd |
AutocloseParameters params;
|
|
Toshihiro Shimizu |
890ddd |
params.m_closingDistance = (int)(m_distance.getValue());
|
|
Toshihiro Shimizu |
890ddd |
params.m_spotAngle = (int)(m_angle.getValue());
|
|
Toshihiro Shimizu |
890ddd |
params.m_opacity = m_opacity.getValue();
|
|
Toshihiro Shimizu |
890ddd |
string inkString = toString(m_inkIndex.getValue());
|
|
Toshihiro Shimizu |
890ddd |
int inkIndex = TTool::getApplication()->getCurrentLevelStyleIndex(); //TApp::instance()->getCurrentPalette()->getStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
if (isInt(inkString))
|
|
Toshihiro Shimizu |
890ddd |
inkIndex = toInt(inkString);
|
|
Toshihiro Shimizu |
890ddd |
params.m_inkIndex = inkIndex;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPoint delta;
|
|
Toshihiro Shimizu |
890ddd |
TRasterCM32P ras, raux = ti->getRaster();
|
|
Toshihiro Shimizu |
890ddd |
if (m_closeType.getValue() == RECT_CLOSE && raux && !selRect.isEmpty()) {
|
|
Toshihiro Shimizu |
890ddd |
TRectD selArea = selRect;
|
|
Toshihiro Shimizu |
890ddd |
if (selRect.x0 > selRect.x1) {
|
|
Toshihiro Shimizu |
890ddd |
selArea.x1 = selRect.x0;
|
|
Toshihiro Shimizu |
890ddd |
selArea.x0 = selRect.x1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (selRect.y0 > selRect.y1) {
|
|
Toshihiro Shimizu |
890ddd |
selArea.y1 = selRect.y0;
|
|
Toshihiro Shimizu |
890ddd |
selArea.y0 = selRect.y1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
TRect myRect(ToonzImageUtils::convertWorldToRaster(selArea, ti));
|
|
Toshihiro Shimizu |
890ddd |
ras = raux->extract(myRect);
|
|
Toshihiro Shimizu |
890ddd |
delta = myRect.getP00();
|
|
Toshihiro Shimizu |
890ddd |
} else if ((m_closeType.getValue() == FREEHAND_CLOSE || m_closeType.getValue() == POLYLINE_CLOSE) &&
|
|
Toshihiro Shimizu |
890ddd |
stroke) {
|
|
Toshihiro Shimizu |
890ddd |
TRectD selArea = stroke->getBBox();
|
|
Toshihiro Shimizu |
890ddd |
TRect myRect(ToonzImageUtils::convertWorldToRaster(selArea, ti));
|
|
Toshihiro Shimizu |
890ddd |
ras = raux->extract(myRect);
|
|
Toshihiro Shimizu |
890ddd |
delta = myRect.getP00();
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
ras = raux;
|
|
Toshihiro Shimizu |
890ddd |
if (!ras)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TAutocloser ac(ras, params.m_closingDistance, params.m_spotAngle, params.m_inkIndex, params.m_opacity);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
vector<tautocloser::segment> segments;</tautocloser::segment>
|
|
Toshihiro Shimizu |
890ddd |
ac.compute(segments);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if ((m_closeType.getValue() == FREEHAND_CLOSE || m_closeType.getValue() == POLYLINE_CLOSE) &&
|
|
Toshihiro Shimizu |
890ddd |
stroke)
|
|
Toshihiro Shimizu |
890ddd |
checkSegments(segments, stroke, raux, delta);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
vector<tautocloser::segment> segments2(segments);</tautocloser::segment>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*-- segmentが取得できなければfalseを返す --*/
|
|
Toshihiro Shimizu |
890ddd |
if (segments2.empty())
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
if (delta != TPoint(0, 0))
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < (int)segments2.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
segments2[i].first += delta;
|
|
Toshihiro Shimizu |
890ddd |
segments2[i].second += delta;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TTileSetCM32 *tileSet = new TTileSetCM32(raux->getSize());
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < (int)segments2.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TRect bbox(segments2[i].first, segments2[i].second);
|
|
Toshihiro Shimizu |
890ddd |
bbox = bbox.enlarge(2);
|
|
Toshihiro Shimizu |
890ddd |
tileSet->add(raux, bbox);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TXshSimpleLevel *sl = TTool::getApplication()->getCurrentLevel()->getSimpleLevel();
|
|
Toshihiro Shimizu |
890ddd |
TFrameId id = getCurrentFid();
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->add(new RasterAutocloseUndo(tileSet, params, segments2, sl, id));
|
|
Toshihiro Shimizu |
890ddd |
ac.draw(segments);
|
|
Toshihiro Shimizu |
890ddd |
ToolUtils::updateSaveBox();
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline TRectD interpolateRect(const TRectD &r1, const TRectD &r2, double t)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TRectD(r1.x0 + (r2.x0 - r1.x0) * t, r1.y0 + (r2.y0 - r1.y0) * t,
|
|
Toshihiro Shimizu |
890ddd |
r1.x1 + (r2.x1 - r1.x1) * t, r1.y1 + (r2.y1 - r1.y1) * t);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//============================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void multiApplyAutoclose(TFrameId firstFid, TFrameId lastFid,
|
|
Toshihiro Shimizu |
890ddd |
TRectD firstRect, TRectD lastRect,
|
|
Toshihiro Shimizu |
890ddd |
TStroke *firstStroke = 0, TStroke *lastStroke = 0)
|
|
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);
|
|
Toshihiro Shimizu |
890ddd |
vector<tframeid> allFids;</tframeid>
|
|
Toshihiro Shimizu |
890ddd |
m_level->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);
|
|
Toshihiro Shimizu |
890ddd |
vector<tframeid> fids(i0, i1);</tframeid>
|
|
Toshihiro Shimizu |
890ddd |
int m = fids.size();
|
|
Toshihiro Shimizu |
890ddd |
assert(m > 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TVectorImageP firstImage;
|
|
Toshihiro Shimizu |
890ddd |
TVectorImageP lastImage;
|
|
Toshihiro Shimizu |
890ddd |
if ((m_closeType.getValue() == FREEHAND_CLOSE || m_closeType.getValue() == POLYLINE_CLOSE) &&
|
|
Toshihiro Shimizu |
890ddd |
firstStroke && lastStroke) {
|
|
Toshihiro Shimizu |
890ddd |
TStroke *first = new TStroke(*firstStroke);
|
|
Toshihiro Shimizu |
890ddd |
TStroke *last = new TStroke(*lastStroke);
|
|
Toshihiro Shimizu |
890ddd |
firstImage = new TVectorImage();
|
|
Toshihiro Shimizu |
890ddd |
lastImage = new TVectorImage();
|
|
Toshihiro Shimizu |
890ddd |
firstImage->addStroke(first);
|
|
Toshihiro Shimizu |
890ddd |
lastImage->addStroke(last);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
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 |
TToonzImageP img = (TToonzImageP)m_level->getFrame(fid, true);
|
|
Toshihiro Shimizu |
890ddd |
if (!img)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
double t = m > 1 ? (double)i / (double)(m - 1) : 0.5;
|
|
Toshihiro Shimizu |
890ddd |
if (m_closeType.getValue() == RECT_CLOSE)
|
|
Toshihiro Shimizu |
890ddd |
applyAutoclose(img, interpolateRect(firstRect, lastRect, t));
|
|
Toshihiro Shimizu |
890ddd |
else if ((m_closeType.getValue() == FREEHAND_CLOSE || m_closeType.getValue() == POLYLINE_CLOSE) &&
|
|
Toshihiro Shimizu |
890ddd |
firstStroke && lastStroke)
|
|
Toshihiro Shimizu |
890ddd |
doClose(t, img, firstImage, lastImage);
|
|
Toshihiro Shimizu |
890ddd |
m_level->getProperties()->setDirtyFlag(true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->endBlock();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TTool::getApplication()->getCurrentXsheet()->notifyXsheetChanged();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TNotifier::instance()->notify(TLevelChange());
|
|
Toshihiro Shimizu |
890ddd |
// TNotifier::instance()->notify(TStageChange());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void multiApplyAutoclose(TFrameId firstFrameId, TFrameId lastFrameId)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int r0 = firstFrameId.getNumber();
|
|
Toshihiro Shimizu |
890ddd |
int r1 = lastFrameId.getNumber();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (r0 > r1) {
|
|
Toshihiro Shimizu |
890ddd |
tswap(r0, r1);
|
|
Toshihiro Shimizu |
890ddd |
tswap(firstFrameId, lastFrameId);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if ((r1 - r0) < 2)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->beginBlock();
|
|
Toshihiro Shimizu |
890ddd |
for (int i = r0; i <= r1; ++i) {
|
|
Toshihiro Shimizu |
890ddd |
TFrameId fid(i);
|
|
Toshihiro Shimizu |
890ddd |
TImageP img = m_level->getFrame(fid, true);
|
|
Toshihiro Shimizu |
890ddd |
applyAutoclose(img);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->endBlock();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TTool::getApplication()->getCurrentXsheet()->notifyXsheetChanged();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TNotifier::instance()->notify(TLevelChange());
|
|
Toshihiro Shimizu |
890ddd |
// TNotifier::instance()->notify(TStageChange());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonUp(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TToonzImageP ti = TToonzImageP(getImage(true));
|
|
Toshihiro Shimizu |
890ddd |
if (!ti)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*-- Rectの座標の向きを揃える --*/
|
|
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 |
TTool::Application *app = TTool::getApplication();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_selecting = false;
|
|
Toshihiro Shimizu |
890ddd |
TRasterCM32P ras;
|
|
Toshihiro Shimizu |
890ddd |
if (m_closeType.getValue() == RECT_CLOSE) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_multi.getValue()) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_firstFrameSelected) {
|
|
Toshihiro Shimizu |
890ddd |
multiApplyAutoclose(m_firstFrameId, getFrameId(), m_firstRect, m_selectingRect);
|
|
Toshihiro Shimizu |
890ddd |
invalidate(m_selectingRect.enlarge(2));
|
|
Toshihiro Shimizu |
890ddd |
if (e.isShiftPressed()) {
|
|
Toshihiro Shimizu |
890ddd |
m_firstRect = m_selectingRect;
|
|
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 |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
m_isXsheetCell = app->getCurrentFrame()->isEditingScene();
|
|
Toshihiro Shimizu |
890ddd |
//if (m_isXsheetCell)
|
|
Toshihiro Shimizu |
890ddd |
m_currCell = std::pair<int, int="">(getColumnIndex(), this->getFrame());</int,>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*-- AutoCloseが実行されたか判定する --*/
|
|
Toshihiro Shimizu |
890ddd |
if (!applyAutoclose(ti, m_selectingRect)) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_stroke) {
|
|
Toshihiro Shimizu |
890ddd |
delete m_stroke;
|
|
Toshihiro Shimizu |
890ddd |
m_stroke = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
notifyImageChanged();
|
|
Toshihiro Shimizu |
890ddd |
} else if (m_closeType.getValue() == FREEHAND_CLOSE) {
|
|
Toshihiro Shimizu |
890ddd |
closeFreehand(pos);
|
|
Toshihiro Shimizu |
890ddd |
if (m_multi.getValue())
|
|
Toshihiro Shimizu |
890ddd |
multiAutocloseRegion(m_stroke, e);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
applyAutoclose(ti, TRectD(), m_stroke);
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_stroke) {
|
|
Toshihiro Shimizu |
890ddd |
delete m_stroke;
|
|
Toshihiro Shimizu |
890ddd |
m_stroke = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void draw()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize2 = getPixelSize() * getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
m_thick = sqrt(pixelSize2) / 2.0;
|
|
Toshihiro Shimizu |
890ddd |
if (m_closeType.getValue() == RECT_CLOSE) {
|
|
Toshihiro Shimizu |
890ddd |
TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg ? TPixel32::White : TPixel32::Black;
|
|
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, 0x3F33, true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if ((m_closeType.getValue() == FREEHAND_CLOSE || m_closeType.getValue() == POLYLINE_CLOSE) && m_multi.getValue() && m_firstStroke) {
|
|
Toshihiro Shimizu |
890ddd |
TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg ? TPixel32::White : TPixel32::Black;
|
|
Toshihiro Shimizu |
890ddd |
tglColor(color);
|
|
Toshihiro Shimizu |
890ddd |
drawStrokeCenterline(*m_firstStroke, 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_closeType.getValue() == POLYLINE_CLOSE && !m_polyline.empty()) {
|
|
Toshihiro Shimizu |
890ddd |
TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg ? TPixel32::White : TPixel32::Black;
|
|
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_mousePosition);
|
|
Toshihiro Shimizu |
890ddd |
glEnd();
|
|
Toshihiro Shimizu |
890ddd |
} else if (m_multi.getValue() && m_firstFrameSelected)
|
|
Toshihiro Shimizu |
890ddd |
drawCross(m_firstPoint, 5);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool onPropertyChanged(string propertyName)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (propertyName == m_closeType.getName()) {
|
|
Toshihiro Shimizu |
890ddd |
AutocloseVectorType = toString(m_closeType.getValue());
|
|
Toshihiro Shimizu |
890ddd |
resetMulti();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
else if (propertyName == m_distance.getName())
|
|
Toshihiro Shimizu |
890ddd |
AutocloseDistance = m_distance.getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
else if (propertyName == m_angle.getName())
|
|
Toshihiro Shimizu |
890ddd |
AutocloseAngle = m_angle.getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
else if (propertyName == m_inkIndex.getName()) {
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
else if (propertyName == m_opacity.getName())
|
|
Toshihiro Shimizu |
890ddd |
AutocloseOpacity = m_opacity.getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
else if (propertyName == m_multi.getName()) {
|
|
Toshihiro Shimizu |
890ddd |
AutocloseRange = (int)((m_multi.getValue()));
|
|
Toshihiro Shimizu |
890ddd |
resetMulti();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (ToonzCheck::instance()->getChecks() & ToonzCheck::eAutoclose)
|
|
Toshihiro Shimizu |
890ddd |
notifyImageChanged();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void resetMulti()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_firstFrameSelected = false;
|
|
Toshihiro Shimizu |
890ddd |
m_firstRect.empty();
|
|
Toshihiro Shimizu |
890ddd |
m_firstPoint = TPointD();
|
|
Toshihiro Shimizu |
890ddd |
m_selectingRect.empty();
|
|
Toshihiro Shimizu |
890ddd |
TTool::Application *app = TTool::getApplication();
|
|
Toshihiro Shimizu |
890ddd |
m_level = app->getCurrentLevel()->getLevel() ? app->getCurrentLevel()->getSimpleLevel() : 0;
|
|
Toshihiro Shimizu |
890ddd |
m_firstFrameId = m_veryFirstFrameId = getFrameId();
|
|
Toshihiro Shimizu |
890ddd |
m_firstStroke = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void 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_closeType.getValue() == RECT_CLOSE && m_selectingRect.isEmpty()) ||
|
|
Toshihiro Shimizu |
890ddd |
((m_closeType.getValue() == FREEHAND_CLOSE || m_closeType.getValue() == POLYLINE_CLOSE) && !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_closeType.getValue() == RECT_CLOSE) {
|
|
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 leftButtonDown(const TPointD &pos, const TMouseEvent &)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TToonzImageP ti = TToonzImageP(getImage(true));
|
|
Toshihiro Shimizu |
890ddd |
if (!ti)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_closeType.getValue() == RECT_CLOSE) {
|
|
Toshihiro Shimizu |
890ddd |
m_selecting = true;
|
|
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 |
return;
|
|
Toshihiro Shimizu |
890ddd |
} else if (m_closeType.getValue() == FREEHAND_CLOSE) {
|
|
Toshihiro Shimizu |
890ddd |
startFreehand(pos);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
} else if (m_closeType.getValue() == POLYLINE_CLOSE) {
|
|
Toshihiro Shimizu |
890ddd |
addPointPolyline(pos);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
} else if (m_closeType.getValue() == NORMAL_CLOSE) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_multi.getValue()) {
|
|
Toshihiro Shimizu |
890ddd |
TTool::Application *app = TTool::getApplication();
|
|
Toshihiro Shimizu |
890ddd |
if (m_firstFrameSelected) {
|
|
Toshihiro Shimizu |
890ddd |
multiApplyAutoclose(m_firstFrameId, getFrameId());
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
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 |
} else {
|
|
Toshihiro Shimizu |
890ddd |
m_isXsheetCell = app->getCurrentFrame()->isEditingScene();
|
|
Toshihiro Shimizu |
890ddd |
//if (m_isXsheetCell)
|
|
Toshihiro Shimizu |
890ddd |
m_currCell = std::pair<int, int="">(getColumnIndex(), getFrame());</int,>
|
|
Toshihiro Shimizu |
890ddd |
m_firstFrameSelected = true;
|
|
Toshihiro Shimizu |
890ddd |
m_firstPoint = pos;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_selecting = false;
|
|
Toshihiro Shimizu |
890ddd |
applyAutoclose(ti);
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
notifyImageChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDoubleClick(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TToonzImageP ti = TToonzImageP(getImage(true));
|
|
Toshihiro Shimizu |
890ddd |
if (m_closeType.getValue() == POLYLINE_CLOSE && ti) {
|
|
Toshihiro Shimizu |
890ddd |
closePolyline(pos);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
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 |
m_stroke = new TStroke(strokePoints);
|
|
Toshihiro Shimizu |
890ddd |
assert(m_stroke->getPoint(0) == m_stroke->getPoint(1));
|
|
Toshihiro Shimizu |
890ddd |
if (m_multi.getValue())
|
|
Toshihiro Shimizu |
890ddd |
multiAutocloseRegion(m_stroke, e);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
applyAutoclose(ti, TRectD(), m_stroke);
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (m_stroke) {
|
|
Toshihiro Shimizu |
890ddd |
delete m_stroke;
|
|
Toshihiro Shimizu |
890ddd |
m_stroke = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void mouseMove(const TPointD &pos, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_closeType.getValue() == POLYLINE_CLOSE) {
|
|
Toshihiro Shimizu |
890ddd |
m_mousePosition = pos;
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void onEnter()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
// getApplication()->editImage();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPropertyGroup *getProperties(int targetType)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return &m_prop;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void onActivate()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_firstTime) {
|
|
Toshihiro Shimizu |
890ddd |
m_closeType.setValue(toWideString((AutocloseVectorType.getValue())));
|
|
Toshihiro Shimizu |
890ddd |
m_distance.setValue(AutocloseDistance);
|
|
Toshihiro Shimizu |
890ddd |
m_angle.setValue(AutocloseAngle);
|
|
Toshihiro Shimizu |
890ddd |
m_opacity.setValue(AutocloseOpacity);
|
|
Toshihiro Shimizu |
890ddd |
m_multi.setValue(AutocloseRange ? 1 : 0);
|
|
Toshihiro Shimizu |
890ddd |
m_firstTime = false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
// getApplication()->editImage();
|
|
Toshihiro Shimizu |
890ddd |
resetMulti();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void onDeactivate()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getCursorId() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg)
|
|
Toshihiro Shimizu |
890ddd |
return ToolCursor::TapeCursorWhite;
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
return ToolCursor::TapeCursor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!Viene aggiunto \b pos a \b m_track e disegnato il primo pezzetto del lazzo. Viene inizializzato \b m_firstPos
|
|
Toshihiro Shimizu |
890ddd |
void startFreehand(const TPointD &pos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
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 |
#if defined(MACOSX)
|
|
Toshihiro Shimizu |
890ddd |
//getViewer()->prepareForegroundDrawing();
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
// getViewer()->makeCurrent();
|
|
Toshihiro Shimizu |
890ddd |
TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg ? TPixel32::White : TPixel32::Black;
|
|
Toshihiro Shimizu |
890ddd |
tglColor(color);
|
|
Toshihiro Shimizu |
890ddd |
m_viewer->startForegroundDrawing();
|
|
Toshihiro Shimizu |
890ddd |
glPushMatrix();
|
|
Toshihiro Shimizu |
890ddd |
glScaled(dpiScale.x, dpiScale.y, 1);
|
|
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 |
//!Viene aggiunto \b pos a \b m_track e disegnato un altro pezzetto del lazzo.
|
|
Toshihiro Shimizu |
890ddd |
void freehandDrag(const TPointD &pos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
#if defined(MACOSX)
|
|
Toshihiro Shimizu |
890ddd |
//getViewer()->enableRedraw(false);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
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 |
double pixelSize2 = getPixelSize() * getPixelSize();
|
|
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 |
//!Viene chiuso il lazzo (si aggiunge l'ultimo punto ad m_track) e viene creato lo stroke rappresentante il lazzo.
|
|
Toshihiro Shimizu |
890ddd |
void closeFreehand(const TPointD &pos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
#if defined(MACOSX)
|
|
Toshihiro Shimizu |
890ddd |
//getViewer()->enableRedraw(true);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
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 |
m_stroke = m_track.makeStroke(error);
|
|
Toshihiro Shimizu |
890ddd |
m_stroke->setStyle(1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!Viene aggiunto un punto al vettore m_polyline.
|
|
Toshihiro Shimizu |
890ddd |
void addPointPolyline(const TPointD &pos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_firstPos = pos;
|
|
Toshihiro Shimizu |
890ddd |
//m_mousePosition = pos;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPointD dpiScale = m_viewer->getDpiScale();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if defined(MACOSX)
|
|
Toshihiro Shimizu |
890ddd |
//getViewer()->prepareForegroundDrawing();
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
// getViewer()->makeCurrent();
|
|
Toshihiro Shimizu |
890ddd |
TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg ? TPixel32::White : TPixel32::Black;
|
|
Toshihiro Shimizu |
890ddd |
tglColor(color);
|
|
Toshihiro Shimizu |
890ddd |
getViewer()->startForegroundDrawing();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if defined(MACOSX)
|
|
Toshihiro Shimizu |
890ddd |
//getViewer()->enableRedraw(m_closeType.getValue() == POLYLINE_CLOSE);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
glPushMatrix();
|
|
Toshihiro Shimizu |
890ddd |
glScaled(dpiScale.x, dpiScale.y, 1);
|
|
Toshihiro Shimizu |
890ddd |
m_polyline.push_back(pos);
|
|
Toshihiro Shimizu |
890ddd |
glPopMatrix();
|
|
Toshihiro Shimizu |
890ddd |
getViewer()->endForegroundDrawing();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!Agginge l'ultimo pos a \b m_polyline e chiude la spezzata (aggiunge \b m_polyline.front() alla fine del vettore)
|
|
Toshihiro Shimizu |
890ddd |
void closePolyline(const TPointD &pos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_polyline.size() <= 1)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
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());
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Elimina i segmenti che non sono contenuti all'interno dello stroke!!!
|
|
Toshihiro Shimizu |
890ddd |
void checkSegments(vector<tautocloser::segment> &segments, TStroke *stroke,</tautocloser::segment>
|
|
Toshihiro Shimizu |
890ddd |
const TRasterCM32P &ras, const TPoint &delta)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TVectorImage vi;
|
|
Toshihiro Shimizu |
890ddd |
TStroke *app = new TStroke();
|
|
Toshihiro Shimizu |
890ddd |
*app = *stroke;
|
|
Toshihiro Shimizu |
890ddd |
app->transform(TTranslation(convert(ras->getCenter())));
|
|
Toshihiro Shimizu |
890ddd |
vi.addStroke(app);
|
|
Toshihiro Shimizu |
890ddd |
vi.findRegions();
|
|
Toshihiro Shimizu |
890ddd |
vector<tautocloser::segment>::iterator it = segments.begin();</tautocloser::segment>
|
|
Toshihiro Shimizu |
890ddd |
for (; it < segments.end(); it++) {
|
|
Toshihiro Shimizu |
890ddd |
if (it == segments.end())
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
bool isContained = false;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < (int)vi.getRegionCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TRegion *reg = vi.getRegion(i);
|
|
Toshihiro Shimizu |
890ddd |
if (reg->contains(convert(it->first + delta)) && reg->contains(convert(it->second + delta))) {
|
|
Toshihiro Shimizu |
890ddd |
isContained = true;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (!isContained) {
|
|
Toshihiro Shimizu |
890ddd |
it = segments.erase(it);
|
|
Toshihiro Shimizu |
890ddd |
if (it != segments.end() && it != segments.begin())
|
|
Toshihiro Shimizu |
890ddd |
it--;
|
|
Toshihiro Shimizu |
890ddd |
else if (it == segments.end())
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void multiAutocloseRegion(TStroke *stroke, const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TTool::Application *app = TTool::getApplication();
|
|
Toshihiro Shimizu |
890ddd |
if (m_firstStroke) {
|
|
Toshihiro Shimizu |
890ddd |
multiApplyAutoclose(m_firstFrameId, getFrameId(),
|
|
Toshihiro Shimizu |
890ddd |
TRectD(), TRectD(), m_firstStroke, stroke);
|
|
Toshihiro Shimizu |
890ddd |
invalidate();
|
|
Toshihiro Shimizu |
890ddd |
if (e.isShiftPressed()) {
|
|
Toshihiro Shimizu |
890ddd |
delete m_firstStroke;
|
|
Toshihiro Shimizu |
890ddd |
m_firstStroke = new TStroke(*stroke);
|
|
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 |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
m_isXsheetCell = app->getCurrentFrame()->isEditingScene();
|
|
Toshihiro Shimizu |
890ddd |
//if (m_isXsheetCell)
|
|
Toshihiro Shimizu |
890ddd |
m_currCell = std::pair<int, int="">(getColumnIndex(), getFrame());</int,>
|
|
Toshihiro Shimizu |
890ddd |
m_firstStroke = new TStroke(*stroke);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void doClose(double t, const TImageP &img,
|
|
Toshihiro Shimizu |
890ddd |
const TVectorImageP &firstImage,
|
|
Toshihiro Shimizu |
890ddd |
const TVectorImageP &lastImage)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (t == 0)
|
|
Toshihiro Shimizu |
890ddd |
applyAutoclose(img, TRectD(), firstImage->getStroke(0));
|
|
Toshihiro Shimizu |
890ddd |
else if (t == 1)
|
|
Toshihiro Shimizu |
890ddd |
applyAutoclose(img, TRectD(), lastImage->getStroke(0));
|
|
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 |
applyAutoclose(img, TRectD(), vi->getStroke(0));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} rasterTapeTool;
|