Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

fix freehand line (#1545)

shun-iwasawac189d1a1bc83
diff --git a/toonz/sources/include/tools/tool.h b/toonz/sources/include/tools/tool.h
index a2f66efae..02fa5d9c3 100644
--- a/toonz/sources/include/tools/tool.h
+++ b/toonz/sources/include/tools/tool.h
@@ -580,9 +580,6 @@ public:
virtual double getPixelSize()
const = 0; //!< Returns the length of a pixel in current OpenGL
//!< coordinates
- virtual void startForegroundDrawing() = 0; //!< Marks the beginning of an
- //! OpenGL drawing block
- virtual void endForegroundDrawing() = 0; //!< Closes an OpenGL drawing block
virtual void invalidateAll() = 0; //!< Redraws the entire viewer, passing
//! through Qt's event system
diff --git a/toonz/sources/tnztools/filltool.cpp b/toonz/sources/tnztools/filltool.cpp
index 584dfb056..0fb431e99 100644
--- a/toonz/sources/tnztools/filltool.cpp
+++ b/toonz/sources/tnztools/filltool.cpp
@@ -1172,6 +1172,11 @@ public:
tglVertex(m_mousePosition);
glEnd();
glPopMatrix();
+ } else if (m_type == FREEHAND && !m_track.isEmpty()) {
+ tglColor(TPixel::Red);
+ glPushMatrix();
+ m_track.drawAllFragments();
+ glPopMatrix();
}
}
@@ -1225,31 +1230,10 @@ public:
} else
m_track.add(TThickPoint(pos, m_thick), pixelSize2);
- TPointD dpiScale = m_parent->getViewer()->getDpiScale();
-
-#if defined(MACOSX)
-// m_parent->m_viewer->prepareForegroundDrawing();
-#endif
-
- // m_parent->m_viewer->makeCurrent();
- tglColor(TPixel::Red);
-
- m_parent->getViewer()->startForegroundDrawing();
-
-#if defined(MACOSX)
-// m_parent->m_viewer->enableRedraw(m_type == POLYLINE);
-#endif
- glPushMatrix();
- tglMultMatrix(m_parent->getMatrix());
- glScaled(dpiScale.x, dpiScale.y, 1);
if (m_type == POLYLINE) {
if (m_polyline.empty() || m_polyline.back() != pos)
m_polyline.push_back(pos);
- // drawPolyline(m_polyline);
- } else
- m_track.drawLastFragments();
- glPopMatrix();
- m_parent->getViewer()->endForegroundDrawing();
+ }
}
m_isLeftButtonPressed = true;
}
@@ -1337,18 +1321,9 @@ public:
#if defined(MACOSX)
// m_parent->m_viewer->enableRedraw(false);
#endif
-
- m_parent->getViewer()->startForegroundDrawing();
- tglColor(TPixel::Red);
- glPushMatrix();
- tglMultMatrix(m_parent->getMatrix());
- TPointD dpiScale = m_parent->getViewer()->getDpiScale();
- glScaled(dpiScale.x, dpiScale.y, 1);
double pixelSize2 = m_parent->getPixelSize() * m_parent->getPixelSize();
m_track.add(TThickPoint(pos, m_thick), pixelSize2);
- m_track.drawLastFragments();
- glPopMatrix();
- m_parent->getViewer()->endForegroundDrawing();
+ m_parent->invalidate();
}
}
diff --git a/toonz/sources/tnztools/fullcolorerasertool.cpp b/toonz/sources/tnztools/fullcolorerasertool.cpp
index 793da8563..0920cf22a 100644
--- a/toonz/sources/tnztools/fullcolorerasertool.cpp
+++ b/toonz/sources/tnztools/fullcolorerasertool.cpp
@@ -497,24 +497,11 @@ void FullColorEraserTool::leftButtonDown(const TPointD &pos,
m_firstPos = pos;
double pixelSize2 = getPixelSize() * getPixelSize();
m_track.add(TThickPoint(pos, m_thick), pixelSize2);
- TPointD dpiScale = m_viewer->getDpiScale();
- TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg
- ? TPixel32::White
- : TPixel32::Black;
- tglColor(color);
-
- getViewer()->startForegroundDrawing();
-
- glPushMatrix();
- glScaled(dpiScale.x, dpiScale.y, 1);
if (m_eraseType.getValue() == POLYLINEERASE) {
if (m_polyline.empty() || m_polyline.back() != pos)
m_polyline.push_back(pos);
- } else
- m_track.drawLastFragments();
- glPopMatrix();
- getViewer()->endForegroundDrawing();
+ }
int maxThick = 2 * m_thick;
TPointD halfThick(maxThick * 0.5, maxThick * 0.5);
@@ -593,19 +580,8 @@ void FullColorEraserTool::leftButtonDrag(const TPointD &pos,
invalidate(invalidateRect.enlarge(2));
}
if (m_eraseType.getValue() == FREEHANDERASE) {
- getViewer()->startForegroundDrawing();
- TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg
- ? TPixel32::White
- : TPixel32::Black;
- tglColor(color);
- glPushMatrix();
- tglMultMatrix(getMatrix());
- TPointD dpiScale = m_viewer->getDpiScale();
- glScaled(dpiScale.x, dpiScale.y, 1);
m_track.add(TThickPoint(pos, m_thick), pixelSize2);
- m_track.drawLastFragments();
- glPopMatrix();
- getViewer()->endForegroundDrawing();
+ invalidate(m_track.getModifiedRegion());
}
}
@@ -734,9 +710,6 @@ void FullColorEraserTool::leftButtonUp(const TPointD &pos,
double pixelSize2 = getPixelSize() * getPixelSize();
m_track.add(TThickPoint(pos, m_thick), pixelSize2);
m_track.add(TThickPoint(m_firstPos, m_thick), pixelSize2);
- getViewer()->startForegroundDrawing();
- m_track.drawLastFragments();
- getViewer()->endForegroundDrawing();
m_track.filterPoints();
double error = (30.0 / 11) * sqrt(pixelSize2);
TStroke *stroke = m_track.makeStroke(error);
@@ -944,6 +917,12 @@ void FullColorEraserTool::draw() {
for (UINT i = 0; i < m_polyline.size(); i++) tglVertex(m_polyline[i]);
tglVertex(m_mousePos);
glEnd();
+ } else if (m_eraseType.getValue() == FREEHANDERASE && !m_track.isEmpty()) {
+ TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg
+ ? TPixel32::White
+ : TPixel32::Black;
+ tglColor(color);
+ m_track.drawAllFragments();
}
}
diff --git a/toonz/sources/tnztools/rastererasertool.cpp b/toonz/sources/tnztools/rastererasertool.cpp
index 264a89636..d7da98949 100644
--- a/toonz/sources/tnztools/rastererasertool.cpp
+++ b/toonz/sources/tnztools/rastererasertool.cpp
@@ -684,6 +684,14 @@ void EraserTool::draw() {
for (UINT i = 0; i < m_polyline.size(); i++) tglVertex(m_polyline[i]);
tglVertex(m_mousePos);
glEnd();
+ } else if (m_eraseType.getValue() == FREEHANDERASE && !m_track.isEmpty()) {
+ TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg
+ ? TPixel32::White
+ : TPixel32::Black;
+ tglColor(color);
+ glPushMatrix();
+ m_track.drawAllFragments();
+ glPopMatrix();
}
}
@@ -925,24 +933,12 @@ void EraserTool::leftButtonDown(const TPointD &pos, const TMouseEvent &e) {
m_firstPos = pos;
double pixelSize2 = getPixelSize() * getPixelSize();
m_track.add(TThickPoint(pos, m_thick), pixelSize2);
- TPointD dpiScale = m_viewer->getDpiScale();
-
- TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg
- ? TPixel32::White
- : TPixel32::Black;
- tglColor(color);
-
- getViewer()->startForegroundDrawing();
- glPushMatrix();
- glScaled(dpiScale.x, dpiScale.y, 1);
if (m_eraseType.getValue() == POLYLINEERASE) {
if (m_polyline.empty() || m_polyline.back() != pos)
m_polyline.push_back(pos);
- } else
- m_track.drawLastFragments();
- glPopMatrix();
- getViewer()->endForegroundDrawing();
+ }
+
int maxThick = 2 * m_thick;
TPointD halfThick(maxThick * 0.5, maxThick * 0.5);
invalidateRect = TRectD(pos - halfThick, pos + halfThick);
@@ -1059,20 +1055,8 @@ void EraserTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &e) {
}
if (m_eraseType.getValue() == FREEHANDERASE) {
if (!m_enabled || !m_active) return;
-
- getViewer()->startForegroundDrawing();
- TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg
- ? TPixel32::White
- : TPixel32::Black;
- tglColor(color);
- glPushMatrix();
- tglMultMatrix(getMatrix());
- TPointD dpiScale = m_viewer->getDpiScale();
- glScaled(dpiScale.x, dpiScale.y, 1);
m_track.add(TThickPoint(pos, m_thick), pixelSize2);
- m_track.drawLastFragments();
- glPopMatrix();
- getViewer()->endForegroundDrawing();
+ invalidate(m_track.getModifiedRegion());
}
}
}
diff --git a/toonz/sources/tnztools/rasterselectiontool.cpp b/toonz/sources/tnztools/rasterselectiontool.cpp
index 62b4cfcfe..cb1ccf27b 100644
--- a/toonz/sources/tnztools/rasterselectiontool.cpp
+++ b/toonz/sources/tnztools/rasterselectiontool.cpp
@@ -624,8 +624,10 @@ void RasterSelectionTool::leftButtonDrag(const TPointD &pos,
m_selectingRect = rectD;
m_bboxs.clear();
invalidate();
- } else if (m_strokeSelectionType.getValue() == FREEHAND_SELECTION)
+ } else if (m_strokeSelectionType.getValue() == FREEHAND_SELECTION) {
freehandDrag(pos);
+ invalidate();
+ }
return;
}
@@ -637,9 +639,10 @@ void RasterSelectionTool::leftButtonDrag(const TPointD &pos,
m_curPos = pos;
- if (m_strokeSelectionType.getValue() == FREEHAND_SELECTION)
+ if (m_strokeSelectionType.getValue() == FREEHAND_SELECTION) {
freehandDrag(pos);
- else if (m_strokeSelectionType.getValue() == RECT_SELECTION) {
+ invalidate();
+ } else if (m_strokeSelectionType.getValue() == RECT_SELECTION) {
bool selectOverlappingStroke = (m_firstPos.x > pos.x);
TRectD rect(m_firstPos, pos);
m_selectingRect = rect;
@@ -689,6 +692,7 @@ void RasterSelectionTool::leftButtonUp(const TPointD &pos,
m_rasterSelection.setFrameId(getCurrentFid());
m_rasterSelection.makeCurrent();
}
+ m_track.clear();
}
}
m_selecting = false;
@@ -782,6 +786,9 @@ void RasterSelectionTool::draw() {
if (m_strokeSelectionType.getValue() == POLYLINE_SELECTION &&
!m_rasterSelection.isFloating())
drawPolylineSelection();
+ else if (m_strokeSelectionType.getValue() == FREEHAND_SELECTION &&
+ !m_rasterSelection.isFloating())
+ drawFreehandSelection();
if (m_rasterSelection.isEmpty()) m_bboxs.clear();
/*-- 選択範囲の変形ハンドルの描画 --*/
diff --git a/toonz/sources/tnztools/rastertapetool.cpp b/toonz/sources/tnztools/rastertapetool.cpp
index e39992bd5..d8c473fd0 100644
--- a/toonz/sources/tnztools/rastertapetool.cpp
+++ b/toonz/sources/tnztools/rastertapetool.cpp
@@ -194,6 +194,7 @@ public:
invalidate();
} else if (m_closeType.getValue() == FREEHAND_CLOSE) {
freehandDrag(pos);
+ invalidate();
}
}
@@ -431,6 +432,7 @@ public:
multiAutocloseRegion(m_stroke, e);
else
applyAutoclose(ti, TRectD(), m_stroke);
+ m_track.clear();
invalidate();
}
if (m_stroke) {
@@ -473,6 +475,12 @@ public:
for (UINT i = 0; i < m_polyline.size(); i++) tglVertex(m_polyline[i]);
tglVertex(m_mousePosition);
glEnd();
+ } else if (m_closeType.getValue() == FREEHAND_CLOSE && !m_track.isEmpty()) {
+ TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg
+ ? TPixel32::White
+ : TPixel32::Black;
+ tglColor(color);
+ m_track.drawAllFragments();
} else if (m_multi.getValue() && m_firstFrameSelected)
drawCross(m_firstPoint, 5);
}
@@ -695,21 +703,6 @@ public:
m_firstPos = pos;
double pixelSize2 = getPixelSize() * getPixelSize();
m_track.add(TThickPoint(pos, m_thick), pixelSize2);
- TPointD dpiScale = m_viewer->getDpiScale();
-#if defined(MACOSX)
-// getViewer()->prepareForegroundDrawing();
-#endif
- // getViewer()->makeCurrent();
- TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg
- ? TPixel32::White
- : TPixel32::Black;
- tglColor(color);
- m_viewer->startForegroundDrawing();
- glPushMatrix();
- glScaled(dpiScale.x, dpiScale.y, 1);
- m_track.drawLastFragments();
- glPopMatrix();
- getViewer()->endForegroundDrawing();
}
//------------------------------------------------------------------
@@ -717,24 +710,8 @@ public:
//! Viene aggiunto \b pos a \b m_track e disegnato un altro pezzetto del
//! lazzo.
void freehandDrag(const TPointD &pos) {
-#if defined(MACOSX)
-// getViewer()->enableRedraw(false);
-#endif
-
- getViewer()->startForegroundDrawing();
- TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg
- ? TPixel32::White
- : TPixel32::Black;
- tglColor(color);
- glPushMatrix();
- tglMultMatrix(getMatrix());
- TPointD dpiScale = m_viewer->getDpiScale();
- glScaled(dpiScale.x, dpiScale.y, 1);
double pixelSize2 = getPixelSize() * getPixelSize();
m_track.add(TThickPoint(pos, m_thick), pixelSize2);
- m_track.drawLastFragments();
- glPopMatrix();
- getViewer()->endForegroundDrawing();
}
//------------------------------------------------------------------
@@ -742,9 +719,6 @@ public:
//! Viene chiuso il lazzo (si aggiunge l'ultimo punto ad m_track) e viene
//! creato lo stroke rappresentante il lazzo.
void closeFreehand(const TPointD &pos) {
-#if defined(MACOSX)
-// getViewer()->enableRedraw(true);
-#endif
if (m_track.isEmpty()) return;
double pixelSize2 = getPixelSize() * getPixelSize();
m_track.add(TThickPoint(m_firstPos, m_thick), pixelSize2);
@@ -759,29 +733,7 @@ public:
//! Viene aggiunto un punto al vettore m_polyline.
void addPointPolyline(const TPointD &pos) {
m_firstPos = pos;
- // m_mousePosition = pos;
-
- TPointD dpiScale = m_viewer->getDpiScale();
-
-#if defined(MACOSX)
-// getViewer()->prepareForegroundDrawing();
-#endif
- // getViewer()->makeCurrent();
- TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg
- ? TPixel32::White
- : TPixel32::Black;
- tglColor(color);
- getViewer()->startForegroundDrawing();
-
-#if defined(MACOSX)
-// getViewer()->enableRedraw(m_closeType.getValue() == POLYLINE_CLOSE);
-#endif
-
- glPushMatrix();
- glScaled(dpiScale.x, dpiScale.y, 1);
m_polyline.push_back(pos);
- glPopMatrix();
- getViewer()->endForegroundDrawing();
}
//------------------------------------------------------------------
diff --git a/toonz/sources/tnztools/selectiontool.cpp b/toonz/sources/tnztools/selectiontool.cpp
index 406e8cab5..164ca68c2 100644
--- a/toonz/sources/tnztools/selectiontool.cpp
+++ b/toonz/sources/tnztools/selectiontool.cpp
@@ -1180,6 +1180,17 @@ void SelectionTool::drawPolylineSelection() {
//-----------------------------------------------------------------------------
+void SelectionTool::drawFreehandSelection() {
+ if (m_track.isEmpty()) return;
+ TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg
+ ? TPixel32::White
+ : TPixel32::Black;
+ tglColor(color);
+ m_track.drawAllFragments();
+}
+
+//-----------------------------------------------------------------------------
+
void SelectionTool::drawRectSelection(const TImage *image) {
const TVectorImage *vi = dynamic_cast<const TVectorImage *>(image);
unsigned short stipple = 0x3F33;
@@ -1269,45 +1280,14 @@ void SelectionTool::startFreehand(const TPointD &pos) {
m_firstPos = pos;
double pixelSize = getPixelSize();
m_track.add(TThickPoint(pos, 0), pixelSize * pixelSize);
- TPointD dpiScale = m_viewer->getDpiScale();
-#if defined(MACOSX)
-// m_viewer->prepareForegroundDrawing();
-#endif
- TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg
- ? TPixel32::White
- : TPixel32::Black;
- tglColor(color);
- m_viewer->startForegroundDrawing();
- glPushMatrix();
- tglMultMatrix(getMatrix());
- glScaled(dpiScale.x, dpiScale.y, 1);
- m_track.drawLastFragments();
- glPopMatrix();
- m_viewer->endForegroundDrawing();
}
//-----------------------------------------------------------------------------
//! Viene aggiunto \b pos a \b m_track e disegnato un altro pezzetto del lazzo.
void SelectionTool::freehandDrag(const TPointD &pos) {
-#if defined(MACOSX)
-// m_viewer->enableRedraw(false);
-#endif
-
double pixelSize = getPixelSize();
- m_viewer->startForegroundDrawing();
- TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg
- ? TPixel32::White
- : TPixel32::Black;
- tglColor(color);
- glPushMatrix();
- tglMultMatrix(getMatrix());
- TPointD dpiScale = m_viewer->getDpiScale();
- glScaled(dpiScale.x, dpiScale.y, 1);
m_track.add(TThickPoint(pos, 0), pixelSize * pixelSize);
- m_track.drawLastFragments();
- glPopMatrix();
- m_viewer->endForegroundDrawing();
}
//-----------------------------------------------------------------------------
@@ -1315,9 +1295,6 @@ void SelectionTool::freehandDrag(const TPointD &pos) {
//! Viene chiuso il lazzo (si aggiunge l'ultimo punto ad m_track) e viene creato
//! lo stroke rappresentante il lazzo.
void SelectionTool::closeFreehand(const TPointD &pos) {
-#if defined(MACOSX)
-// m_viewer->enableRedraw(true);
-#endif
if (m_track.isEmpty()) return;
double pixelSize = getPixelSize();
m_track.add(TThickPoint(m_firstPos, 0), pixelSize * pixelSize);
@@ -1333,28 +1310,7 @@ void SelectionTool::closeFreehand(const TPointD &pos) {
void SelectionTool::addPointPolyline(const TPointD &pos) {
m_firstPos = pos;
m_mousePosition = pos;
-
- TPointD dpiScale = m_viewer->getDpiScale();
-
-#if defined(MACOSX)
-// m_viewer->prepareForegroundDrawing();
-#endif
- TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg
- ? TPixel32::White
- : TPixel32::Black;
- tglColor(color);
- m_viewer->startForegroundDrawing();
-
-#if defined(MACOSX)
-// m_viewer->enableRedraw(m_strokeSelectionType.getValue() ==
-// POLYLINE_SELECTION);
-#endif
-
- glPushMatrix();
- glScaled(dpiScale.x, dpiScale.y, 1);
m_polyline.push_back(pos);
- glPopMatrix();
- m_viewer->endForegroundDrawing();
}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/tnztools/selectiontool.h b/toonz/sources/tnztools/selectiontool.h
index 077553347..0a14e5b9a 100644
--- a/toonz/sources/tnztools/selectiontool.h
+++ b/toonz/sources/tnztools/selectiontool.h
@@ -393,6 +393,7 @@ protected:
void drawPolylineSelection();
void drawRectSelection(const TImage *image);
+ void drawFreehandSelection();
void drawCommandHandle(const TImage *image);
public:
diff --git a/toonz/sources/tnztools/vectorerasertool.cpp b/toonz/sources/tnztools/vectorerasertool.cpp
index dd33bc635..1ea2bc588 100644
--- a/toonz/sources/tnztools/vectorerasertool.cpp
+++ b/toonz/sources/tnztools/vectorerasertool.cpp
@@ -443,6 +443,12 @@ void EraserTool::draw() {
for (UINT i = 0; i < m_polyline.size(); i++) tglVertex(m_polyline[i]);
tglVertex(m_mousePos);
glEnd();
+ } else if (m_eraseType.getValue() == FREEHAND_ERASE && !m_track.isEmpty()) {
+ TPixel color = blackBg ? TPixel32::White : TPixel32::Black;
+ tglColor(color);
+ glPushMatrix();
+ m_track.drawAllFragments();
+ glPopMatrix();
}
}
}
@@ -962,6 +968,7 @@ void EraserTool::leftButtonUp(const TPointD &pos, const TMouseEvent &e) {
invalidate();
notifyImageChanged();
}
+ m_track.clear();
}
m_active = false;
}
@@ -1112,22 +1119,6 @@ void EraserTool::startFreehand(const TPointD &pos) {
m_track.clear();
m_firstPos = pos;
m_track.add(TThickPoint(pos, m_thick), getPixelSize() * getPixelSize());
- TPointD dpiScale = m_viewer->getDpiScale();
-#if defined(MACOSX)
-// m_viewer->prepareForegroundDrawing();
-#endif
- // m_viewer->makeCurrent();
- TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg
- ? TPixel32::White
- : TPixel32::Black;
- tglColor(color);
- m_viewer->startForegroundDrawing();
- glPushMatrix();
- tglMultMatrix(getMatrix());
- glScaled(dpiScale.x, dpiScale.y, 1);
- m_track.drawLastFragments();
- glPopMatrix();
- m_viewer->endForegroundDrawing();
}
//-----------------------------------------------------------------------------
@@ -1137,20 +1128,8 @@ void EraserTool::freehandDrag(const TPointD &pos) {
#if defined(MACOSX)
// m_viewer->enableRedraw(false);
#endif
-
- m_viewer->startForegroundDrawing();
- TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg
- ? TPixel32::White
- : TPixel32::Black;
- tglColor(color);
- glPushMatrix();
- tglMultMatrix(getMatrix());
- TPointD dpiScale = m_viewer->getDpiScale();
- glScaled(dpiScale.x, dpiScale.y, 1);
m_track.add(TThickPoint(pos, m_thick), getPixelSize() * getPixelSize());
- m_track.drawLastFragments();
- glPopMatrix();
- m_viewer->endForegroundDrawing();
+ invalidate(m_track.getModifiedRegion());
}
//-----------------------------------------------------------------------------
@@ -1175,29 +1154,7 @@ void EraserTool::closeFreehand(const TPointD &pos) {
//! Viene aggiunto un punto al vettore m_polyline.
void EraserTool::addPointPolyline(const TPointD &pos) {
m_firstPos = pos;
-
- TPointD dpiScale = m_viewer->getDpiScale();
-
-#if defined(MACOSX)
-// m_viewer->prepareForegroundDrawing();
-#endif
- // m_viewer->makeCurrent();
- TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg
- ? TPixel32::White
- : TPixel32::Black;
- tglColor(color);
-// m_viewer->startForegroundDrawing();
-
-#if defined(MACOSX)
-// m_viewer->enableRedraw(m_eraseType.getValue() ==
-// POLYLINE_ERASE);
-#endif
-
- glPushMatrix();
- glScaled(dpiScale.x, dpiScale.y, 1);
m_polyline.push_back(pos);
- glPopMatrix();
- // m_viewer->endForegroundDrawing();
}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/tnztools/vectorselectiontool.cpp b/toonz/sources/tnztools/vectorselectiontool.cpp
index 6e64af6bb..83f30c9af 100644
--- a/toonz/sources/tnztools/vectorselectiontool.cpp
+++ b/toonz/sources/tnztools/vectorselectiontool.cpp
@@ -1515,9 +1515,10 @@ void VectorSelectionTool::leftButtonDrag(const TPointD &pos,
m_curPos = pos;
- if (m_strokeSelectionType.getIndex() == FREEHAND_SELECTION_IDX)
+ if (m_strokeSelectionType.getIndex() == FREEHAND_SELECTION_IDX) {
freehandDrag(pos);
- else if (m_strokeSelectionType.getIndex() == RECT_SELECTION_IDX) {
+ invalidate();
+ } else if (m_strokeSelectionType.getIndex() == RECT_SELECTION_IDX) {
bool selectOverlappingStroke = (m_firstPos.x > pos.x);
TRectD rect(m_firstPos, pos);
@@ -1588,6 +1589,7 @@ void VectorSelectionTool::leftButtonUp(const TPointD &pos,
delete m_stroke; // >:(
m_stroke = 0;
+ m_track.clear();
}
}
@@ -1700,6 +1702,8 @@ void VectorSelectionTool::draw() {
if (m_strokeSelectionType.getIndex() == POLYLINE_SELECTION_IDX)
drawPolylineSelection();
+ else if (m_strokeSelectionType.getIndex() == FREEHAND_SELECTION_IDX)
+ drawFreehandSelection();
if (m_levelSelection.isEmpty()) drawGroup(*vi);
diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cpp
index 84c7b1800..6056baa1c 100644
--- a/toonz/sources/toonz/sceneviewer.cpp
+++ b/toonz/sources/toonz/sceneviewer.cpp
@@ -577,48 +577,6 @@ void SceneViewer::onPreviewUpdate() {
//-----------------------------------------------------------------------------
-void SceneViewer::startForegroundDrawing() {
- makeCurrent();
- // setAutoBufferSwap(false);
- update(); // needed?
- glPushMatrix();
- tglMultMatrix(getViewMatrix());
-
- if (is3DView()) {
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_ALWAYS);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glPushMatrix();
- mult3DMatrix();
- }
-
- glDrawBuffer(GL_FRONT);
-
- assert(glGetError() == GL_NO_ERROR);
- m_foregroundDrawing = true;
-}
-
-//-----------------------------------------------------------------------------
-
-void SceneViewer::endForegroundDrawing() {
- makeCurrent();
- glFlush();
- glDrawBuffer(GL_BACK);
- glPopMatrix();
-
- if (is3DView()) {
- glDisable(GL_DEPTH_TEST);
- glPopMatrix();
- assert(glGetError() == GL_NO_ERROR);
- }
-
- // setAutoBufferSwap(true);
- update(); // needed?
- m_foregroundDrawing = false;
-}
-
-//-----------------------------------------------------------------------------
-
void SceneViewer::setReferenceMode(int referenceMode) {
if (m_referenceMode == referenceMode) return;
diff --git a/toonz/sources/toonz/sceneviewer.h b/toonz/sources/toonz/sceneviewer.h
index d199263d6..b2c810bb7 100644
--- a/toonz/sources/toonz/sceneviewer.h
+++ b/toonz/sources/toonz/sceneviewer.h
@@ -173,8 +173,6 @@ public:
void onRenderCompleted(int frame) override;
void onPreviewUpdate() override;
- void startForegroundDrawing() override;
- void endForegroundDrawing() override;
bool isPreviewEnabled() const { return m_previewMode != NO_PREVIEW; }
int getPreviewMode() const { return m_previewMode; }