Merge pull request #1744 from shun-iwasawa/precise_pen_position
Use Precise Pen Position
This commit is contained in:
commit
9115786ea5
15 changed files with 100 additions and 98 deletions
|
@ -86,7 +86,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TPoint m_pos; //!< Mouse position in window coordinates, bottom-left origin.
|
TPointD m_pos; //!< Mouse position in window coordinates, bottom-left origin.
|
||||||
int m_pressure; //!< Pressure of the tablet pen, or 255 for pure mouse
|
int m_pressure; //!< Pressure of the tablet pen, or 255 for pure mouse
|
||||||
//! events.
|
//! events.
|
||||||
ModifierMask m_modifiersMask; //!< Bitmask specifying key modifiers applying
|
ModifierMask m_modifiersMask; //!< Bitmask specifying key modifiers applying
|
||||||
|
@ -94,7 +94,7 @@ public:
|
||||||
|
|
||||||
Qt::MouseButtons m_buttons;
|
Qt::MouseButtons m_buttons;
|
||||||
Qt::MouseButton m_button;
|
Qt::MouseButton m_button;
|
||||||
QPoint m_mousePos; // mouse position obtained with QMouseEvent::pos() or
|
QPointF m_mousePos; // mouse position obtained with QMouseEvent::pos() or
|
||||||
// QTabletEvent::pos()
|
// QTabletEvent::pos()
|
||||||
bool m_isTablet;
|
bool m_isTablet;
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public:
|
||||||
bool isLeftButtonPressed() const { return (m_buttons & Qt::LeftButton) != 0; }
|
bool isLeftButtonPressed() const { return (m_buttons & Qt::LeftButton) != 0; }
|
||||||
Qt::MouseButtons buttons() const { return m_buttons; }
|
Qt::MouseButtons buttons() const { return m_buttons; }
|
||||||
Qt::MouseButton button() const { return m_button; }
|
Qt::MouseButton button() const { return m_button; }
|
||||||
QPoint mousePos() const { return m_mousePos; }
|
QPointF mousePos() const { return m_mousePos; }
|
||||||
bool isTablet() const { return m_isTablet; }
|
bool isTablet() const { return m_isTablet; }
|
||||||
|
|
||||||
void setModifiers(bool shiftPressed, bool altPressed, bool ctrlPressed) {
|
void setModifiers(bool shiftPressed, bool altPressed, bool ctrlPressed) {
|
||||||
|
@ -368,7 +368,7 @@ public:
|
||||||
restrict drawing to a small regionaround \p p of the viewport.
|
restrict drawing to a small regionaround \p p of the viewport.
|
||||||
Retuns -1 if no object's view has been changed.
|
Retuns -1 if no object's view has been changed.
|
||||||
*/
|
*/
|
||||||
int pick(const TPoint &p);
|
int pick(const TPointD &p);
|
||||||
bool isPicking() const { return m_picking; }
|
bool isPicking() const { return m_picking; }
|
||||||
|
|
||||||
virtual void updateTranslation(){};
|
virtual void updateTranslation(){};
|
||||||
|
@ -603,32 +603,32 @@ public:
|
||||||
|
|
||||||
//! return the column index of the drawing intersecting point \b p
|
//! return the column index of the drawing intersecting point \b p
|
||||||
//! (window coordinate, pixels, bottom-left origin)
|
//! (window coordinate, pixels, bottom-left origin)
|
||||||
virtual int posToColumnIndex(const TPoint &p, double distance,
|
virtual int posToColumnIndex(const TPointD &p, double distance,
|
||||||
bool includeInvisible = true) const = 0;
|
bool includeInvisible = true) const = 0;
|
||||||
virtual void posToColumnIndexes(const TPoint &p, std::vector<int> &indexes,
|
virtual void posToColumnIndexes(const TPointD &p, std::vector<int> &indexes,
|
||||||
double distance,
|
double distance,
|
||||||
bool includeInvisible = true) const = 0;
|
bool includeInvisible = true) const = 0;
|
||||||
|
|
||||||
//! return the row of the drawing intersecting point \b p (used with
|
//! return the row of the drawing intersecting point \b p (used with
|
||||||
//! onionskins)
|
//! onionskins)
|
||||||
//! (window coordinate, pixels, bottom-left origin)
|
//! (window coordinate, pixels, bottom-left origin)
|
||||||
virtual int posToRow(const TPoint &p, double distance,
|
virtual int posToRow(const TPointD &p, double distance,
|
||||||
bool includeInvisible = true) const = 0;
|
bool includeInvisible = true) const = 0;
|
||||||
|
|
||||||
//! return pos in pixel, bottom-left origin
|
//! return pos in pixel, bottom-left origin
|
||||||
virtual TPoint worldToPos(const TPointD &worldPos) const = 0;
|
virtual TPointD worldToPos(const TPointD &worldPos) const = 0;
|
||||||
|
|
||||||
//! return the OpenGL nameId of the object intersecting point \b p
|
//! return the OpenGL nameId of the object intersecting point \b p
|
||||||
//! (window coordinate, pixels, bottom-left origin)
|
//! (window coordinate, pixels, bottom-left origin)
|
||||||
virtual int pick(const TPoint &point) = 0;
|
virtual int pick(const TPointD &point) = 0;
|
||||||
|
|
||||||
// note: winPos in pixel, top-left origin;
|
// note: winPos in pixel, top-left origin;
|
||||||
// when no camera movements have been defined then worldPos = 0 at camera
|
// when no camera movements have been defined then worldPos = 0 at camera
|
||||||
// center
|
// center
|
||||||
virtual TPointD winToWorld(const TPoint &winPos) const = 0;
|
virtual TPointD winToWorld(const TPointD &winPos) const = 0;
|
||||||
|
|
||||||
// delta.x: right panning, pixels; delta.y: down panning, pixels
|
// delta.x: right panning, pixels; delta.y: down panning, pixels
|
||||||
virtual void pan(const TPoint &delta) = 0;
|
virtual void pan(const TPointD &delta) = 0;
|
||||||
|
|
||||||
// center: window coordinates, pixels, bottomleft origin
|
// center: window coordinates, pixels, bottomleft origin
|
||||||
virtual void zoom(const TPointD ¢er, double scaleFactor) = 0;
|
virtual void zoom(const TPointD ¢er, double scaleFactor) = 0;
|
||||||
|
@ -639,7 +639,7 @@ public:
|
||||||
virtual bool getIsFlippedX() const = 0;
|
virtual bool getIsFlippedX() const = 0;
|
||||||
virtual bool getIsFlippedY() const = 0;
|
virtual bool getIsFlippedY() const = 0;
|
||||||
|
|
||||||
virtual double projectToZ(const TPoint &delta) = 0;
|
virtual double projectToZ(const TPointD &delta) = 0;
|
||||||
|
|
||||||
virtual TPointD getDpiScale() const = 0;
|
virtual TPointD getDpiScale() const = 0;
|
||||||
virtual int getVGuideCount() = 0;
|
virtual int getVGuideCount() = 0;
|
||||||
|
|
|
@ -568,7 +568,7 @@ public:
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
class DragZTool final : public DragChannelTool {
|
class DragZTool final : public DragChannelTool {
|
||||||
TPoint m_lastPos;
|
TPointD m_lastPos;
|
||||||
TTool::Viewer *m_viewer;
|
TTool::Viewer *m_viewer;
|
||||||
double m_dz;
|
double m_dz;
|
||||||
|
|
||||||
|
|
|
@ -378,7 +378,7 @@ void PinchTool::onImageChanged() {
|
||||||
m_deformation->reset();
|
m_deformation->reset();
|
||||||
|
|
||||||
double w = 0;
|
double w = 0;
|
||||||
TStroke *stroke = getClosestStroke(convert(m_lastMouseEvent.m_pos), w);
|
TStroke *stroke = getClosestStroke(m_lastMouseEvent.m_pos, w);
|
||||||
if (stroke) {
|
if (stroke) {
|
||||||
// set parameters from sliders
|
// set parameters from sliders
|
||||||
updateInterfaceStatus(m_lastMouseEvent);
|
updateInterfaceStatus(m_lastMouseEvent);
|
||||||
|
|
|
@ -330,10 +330,10 @@ void RGBPickerTool::leftButtonDown(const TPointD &pos, const TMouseEvent &e) {
|
||||||
invalidate();
|
invalidate();
|
||||||
return;
|
return;
|
||||||
} else if (m_pickType.getValue() == FREEHAND_PICK) {
|
} else if (m_pickType.getValue() == FREEHAND_PICK) {
|
||||||
startFreehand(pos, convert(e.m_pos));
|
startFreehand(pos, e.m_pos);
|
||||||
return;
|
return;
|
||||||
} else if (m_pickType.getValue() == POLYLINE_PICK) {
|
} else if (m_pickType.getValue() == POLYLINE_PICK) {
|
||||||
addPointPolyline(pos, convert(e.m_pos));
|
addPointPolyline(pos, e.m_pos);
|
||||||
return;
|
return;
|
||||||
} else { // NORMAL_PICK
|
} else { // NORMAL_PICK
|
||||||
m_mousePixelPosition = e.m_pos;
|
m_mousePixelPosition = e.m_pos;
|
||||||
|
@ -354,7 +354,7 @@ void RGBPickerTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &e) {
|
||||||
invalidate();
|
invalidate();
|
||||||
return;
|
return;
|
||||||
} else if (m_pickType.getValue() == FREEHAND_PICK) {
|
} else if (m_pickType.getValue() == FREEHAND_PICK) {
|
||||||
freehandDrag(pos, convert(e.m_pos));
|
freehandDrag(pos, e.m_pos);
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -380,7 +380,7 @@ void RGBPickerTool::leftButtonDoubleClick(const TPointD &pos,
|
||||||
const TMouseEvent &e) {
|
const TMouseEvent &e) {
|
||||||
if (m_currentStyleId == 0) return;
|
if (m_currentStyleId == 0) return;
|
||||||
if (m_pickType.getValue() == POLYLINE_PICK) {
|
if (m_pickType.getValue() == POLYLINE_PICK) {
|
||||||
closePolyline(pos, convert(e.m_pos));
|
closePolyline(pos, e.m_pos);
|
||||||
std::vector<TThickPoint> strokePoints;
|
std::vector<TThickPoint> strokePoints;
|
||||||
for (UINT i = 0; i < m_workingPolyline.size() - 1; i++) {
|
for (UINT i = 0; i < m_workingPolyline.size() - 1; i++) {
|
||||||
strokePoints.push_back(TThickPoint(m_workingPolyline[i], 1));
|
strokePoints.push_back(TThickPoint(m_workingPolyline[i], 1));
|
||||||
|
|
|
@ -37,7 +37,7 @@ class RGBPickerTool final : public TTool {
|
||||||
std::vector<TPointD> m_workingPolyline;
|
std::vector<TPointD> m_workingPolyline;
|
||||||
bool m_makePick;
|
bool m_makePick;
|
||||||
|
|
||||||
TPoint m_mousePixelPosition;
|
TPointD m_mousePixelPosition;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RGBPickerTool();
|
RGBPickerTool();
|
||||||
|
|
|
@ -112,7 +112,7 @@ public:
|
||||||
|
|
||||||
class ParentChangeTool final : public DragTool {
|
class ParentChangeTool final : public DragTool {
|
||||||
TTool::Viewer *m_viewer;
|
TTool::Viewer *m_viewer;
|
||||||
TPoint m_firstWinPos;
|
TPointD m_firstWinPos;
|
||||||
TPointD m_lastPos, m_lastPos2;
|
TPointD m_lastPos, m_lastPos2;
|
||||||
TPointD m_center;
|
TPointD m_center;
|
||||||
int m_index;
|
int m_index;
|
||||||
|
|
|
@ -1037,7 +1037,7 @@ void SkeletonTool::drawHooks() {
|
||||||
currentColumnHooks.push_back(HookData(xsh, col, hookId, m_parentProbe));
|
currentColumnHooks.push_back(HookData(xsh, col, hookId, m_parentProbe));
|
||||||
|
|
||||||
// otherColumn = "picked" column not connected
|
// otherColumn = "picked" column not connected
|
||||||
TPoint parentProbePos = getViewer()->worldToPos(m_parentProbe);
|
TPointD parentProbePos = getViewer()->worldToPos(m_parentProbe);
|
||||||
std::vector<int> indexes;
|
std::vector<int> indexes;
|
||||||
getViewer()->posToColumnIndexes(parentProbePos, indexes,
|
getViewer()->posToColumnIndexes(parentProbePos, indexes,
|
||||||
getPixelSize() * 10, false);
|
getPixelSize() * 10, false);
|
||||||
|
|
|
@ -498,7 +498,7 @@ void TTool::invalidate(const TRectD &rect) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
int TTool::pick(const TPoint &p) {
|
int TTool::pick(const TPointD &p) {
|
||||||
if (!m_viewer) return 0;
|
if (!m_viewer) return 0;
|
||||||
|
|
||||||
m_picking = true;
|
m_picking = true;
|
||||||
|
|
|
@ -1531,7 +1531,7 @@ void ToolUtils::drawBalloon(const TPointD &pos, std::string text,
|
||||||
double d = pixelSize * 5;
|
double d = pixelSize * 5;
|
||||||
glRectd(x0 - d, y0 - d, x1 + d, y1 + d);
|
glRectd(x0 - d, y0 - d, x1 + d, y1 + d);
|
||||||
} else {
|
} else {
|
||||||
TPoint posBalloon = viewer->worldToPos(pos);
|
TPointD posBalloon = viewer->worldToPos(pos);
|
||||||
|
|
||||||
double d = 5;
|
double d = 5;
|
||||||
double x0 = posBalloon.x + textRect.left() - d;
|
double x0 = posBalloon.x + textRect.left() - d;
|
||||||
|
@ -1539,10 +1539,10 @@ void ToolUtils::drawBalloon(const TPointD &pos, std::string text,
|
||||||
double x1 = x0 + textRect.width() + d;
|
double x1 = x0 + textRect.width() + d;
|
||||||
double y1 = y0 + textRect.height() + d;
|
double y1 = y0 + textRect.height() + d;
|
||||||
|
|
||||||
TPoint p1(x0, y0);
|
TPointD p1(x0, y0);
|
||||||
TPoint p2(x1, y0);
|
TPointD p2(x1, y0);
|
||||||
TPoint p3(x0, y1);
|
TPointD p3(x0, y1);
|
||||||
TPoint p4(x1, y1);
|
TPointD p4(x1, y1);
|
||||||
|
|
||||||
TPointD w1(viewer->winToWorld(p1));
|
TPointD w1(viewer->winToWorld(p1));
|
||||||
TPointD w2(viewer->winToWorld(p2));
|
TPointD w2(viewer->winToWorld(p2));
|
||||||
|
|
|
@ -62,7 +62,7 @@ public:
|
||||||
void draw() override {
|
void draw() override {
|
||||||
if (!m_dragging) return;
|
if (!m_dragging) return;
|
||||||
|
|
||||||
TPointD center = m_viewer->winToWorld(TPoint(m_center.x, m_center.y));
|
TPointD center = m_viewer->winToWorld(m_center);
|
||||||
double pixelSize = getPixelSize();
|
double pixelSize = getPixelSize();
|
||||||
double unit = pixelSize;
|
double unit = pixelSize;
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
@ -91,7 +91,7 @@ public:
|
||||||
|
|
||||||
class HandTool final : public TTool {
|
class HandTool final : public TTool {
|
||||||
TStopWatch m_sw;
|
TStopWatch m_sw;
|
||||||
TPoint m_oldPos;
|
TPointD m_oldPos;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HandTool() : TTool("T_Hand") { bind(TTool::AllTargets); }
|
HandTool() : TTool("T_Hand") { bind(TTool::AllTargets); }
|
||||||
|
@ -111,7 +111,7 @@ public:
|
||||||
if (m_sw.getTotalTime() < 10) return;
|
if (m_sw.getTotalTime() < 10) return;
|
||||||
m_sw.stop();
|
m_sw.stop();
|
||||||
m_sw.start(true);
|
m_sw.start(true);
|
||||||
TPoint delta = e.m_pos - m_oldPos;
|
TPointD delta = e.m_pos - m_oldPos;
|
||||||
delta.y = -delta.y;
|
delta.y = -delta.y;
|
||||||
m_viewer->pan(delta);
|
m_viewer->pan(delta);
|
||||||
m_oldPos = e.m_pos;
|
m_oldPos = e.m_pos;
|
||||||
|
@ -136,7 +136,7 @@ class RotateTool final : public TTool {
|
||||||
TPointD m_center;
|
TPointD m_center;
|
||||||
bool m_dragging;
|
bool m_dragging;
|
||||||
double m_angle;
|
double m_angle;
|
||||||
TPoint m_oldMousePos;
|
TPointD m_oldMousePos;
|
||||||
TBoolProperty m_cameraCentered;
|
TBoolProperty m_cameraCentered;
|
||||||
TPropertyGroup m_prop;
|
TPropertyGroup m_prop;
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ public:
|
||||||
m_sw.start(true);
|
m_sw.start(true);
|
||||||
TPointD p = pos;
|
TPointD p = pos;
|
||||||
if (m_viewer->is3DView()) {
|
if (m_viewer->is3DView()) {
|
||||||
TPoint d = e.m_pos - m_oldMousePos;
|
TPointD d = e.m_pos - m_oldMousePos;
|
||||||
m_oldMousePos = e.m_pos;
|
m_oldMousePos = e.m_pos;
|
||||||
double factor = 0.5;
|
double factor = 0.5;
|
||||||
m_viewer->rotate3D(factor * d.x, -factor * d.y);
|
m_viewer->rotate3D(factor * d.x, -factor * d.y);
|
||||||
|
|
|
@ -645,10 +645,11 @@ void SceneViewer::enablePreview(int previewMode) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
TPointD SceneViewer::winToWorld(const QPoint &pos) const {
|
TPointD SceneViewer::winToWorld(const QPointF &pos) const {
|
||||||
// coordinate window (origine in alto a sinistra) -> coordinate colonna
|
// coordinate window (origine in alto a sinistra) -> coordinate colonna
|
||||||
// (origine al centro dell'immagine)
|
// (origine al centro dell'immagine)
|
||||||
TPointD pp(pos.x() - width() / 2, -pos.y() + height() / 2);
|
TPointD pp(pos.x() - (double)width() / 2.0,
|
||||||
|
-pos.y() + (double)height() / 2.0);
|
||||||
if (is3DView()) {
|
if (is3DView()) {
|
||||||
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
|
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
|
||||||
TStageObjectId cameraId = xsh->getStageObjectTree()->getCurrentCameraId();
|
TStageObjectId cameraId = xsh->getStageObjectTree()->getCurrentCameraId();
|
||||||
|
@ -684,15 +685,15 @@ TPointD SceneViewer::winToWorld(const QPoint &pos) const {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
TPointD SceneViewer::winToWorld(const TPoint &winPos) const {
|
TPointD SceneViewer::winToWorld(const TPointD &winPos) const {
|
||||||
return winToWorld(QPoint(winPos.x, height() - winPos.y));
|
return winToWorld(QPointF(winPos.x, height() - winPos.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
TPoint SceneViewer::worldToPos(const TPointD &worldPos) const {
|
TPointD SceneViewer::worldToPos(const TPointD &worldPos) const {
|
||||||
TPointD p = getViewMatrix() * worldPos;
|
TPointD p = getViewMatrix() * worldPos;
|
||||||
return TPoint(width() / 2 + p.x, height() / 2 + p.y);
|
return TPointD(width() / 2 + p.x, height() / 2 + p.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -1605,7 +1606,7 @@ void SceneViewer::mult3DMatrix() {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
double SceneViewer::projectToZ(const TPoint &delta) {
|
double SceneViewer::projectToZ(const TPointD &delta) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
mult3DMatrix();
|
mult3DMatrix();
|
||||||
GLint viewport[4];
|
GLint viewport[4];
|
||||||
|
@ -1623,7 +1624,7 @@ double SceneViewer::projectToZ(const TPoint &delta) {
|
||||||
TPointD zdir(bx - ax, by - ay);
|
TPointD zdir(bx - ax, by - ay);
|
||||||
double zdirLength2 = norm2(zdir);
|
double zdirLength2 = norm2(zdir);
|
||||||
if (zdirLength2 > 0.0) {
|
if (zdirLength2 > 0.0) {
|
||||||
double dz = (TPointD(delta.x, delta.y) * zdir) / zdirLength2;
|
double dz = (delta * zdir) / zdirLength2;
|
||||||
return dz;
|
return dz;
|
||||||
} else
|
} else
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
@ -1632,25 +1633,25 @@ double SceneViewer::projectToZ(const TPoint &delta) {
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
TRect SceneViewer::getActualClipRect(const TAffine &aff) {
|
TRect SceneViewer::getActualClipRect(const TAffine &aff) {
|
||||||
TDimension viewerSize(width(), height());
|
TDimensionD viewerSize(width(), height());
|
||||||
TRect clipRect(viewerSize);
|
TRectD clipRect(viewerSize);
|
||||||
|
|
||||||
if (is3DView()) {
|
if (is3DView()) {
|
||||||
TPointD p00 = winToWorld(clipRect.getP00());
|
TPointD p00 = winToWorld(clipRect.getP00());
|
||||||
TPointD p01 = winToWorld(clipRect.getP01());
|
TPointD p01 = winToWorld(clipRect.getP01());
|
||||||
TPointD p10 = winToWorld(clipRect.getP10());
|
TPointD p10 = winToWorld(clipRect.getP10());
|
||||||
TPointD p11 = winToWorld(clipRect.getP11());
|
TPointD p11 = winToWorld(clipRect.getP11());
|
||||||
clipRect = TRect(TPoint(std::min(p00.x, p01.x), std::min(p00.y, p10.y)),
|
clipRect = TRectD(TPointD(std::min(p00.x, p01.x), std::min(p00.y, p10.y)),
|
||||||
TPoint(std::max(p11.x, p10.x), std::max(p11.y, p01.y)));
|
TPointD(std::max(p11.x, p10.x), std::max(p11.y, p01.y)));
|
||||||
} else if (m_clipRect.isEmpty())
|
} else if (m_clipRect.isEmpty())
|
||||||
clipRect -= TPoint(viewerSize.lx / 2, viewerSize.ly / 2);
|
clipRect -= TPointD(viewerSize.lx / 2, viewerSize.ly / 2);
|
||||||
else {
|
else {
|
||||||
TRectD app = aff * (m_clipRect.enlarge(3));
|
TRectD app = aff * (m_clipRect.enlarge(3));
|
||||||
clipRect =
|
clipRect =
|
||||||
TRect(tceil(app.x0), tceil(app.y0), tfloor(app.x1), tfloor(app.y1));
|
TRectD(tceil(app.x0), tceil(app.y0), tfloor(app.x1), tfloor(app.y1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return clipRect;
|
return convert(clipRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -1734,8 +1735,8 @@ void SceneViewer::GLInvalidateRect(const TRectD &rect) {
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// delta.x: right panning, pixel; delta.y: down panning, pixel
|
// delta.x: right panning, pixel; delta.y: down panning, pixel
|
||||||
void SceneViewer::panQt(const QPoint &delta) {
|
void SceneViewer::panQt(const QPointF &delta) {
|
||||||
if (delta == QPoint()) return;
|
if (delta == QPointF()) return;
|
||||||
if (is3DView())
|
if (is3DView())
|
||||||
m_pan3D += TPointD(delta.x(), -delta.y());
|
m_pan3D += TPointD(delta.x(), -delta.y());
|
||||||
else {
|
else {
|
||||||
|
@ -2208,7 +2209,7 @@ void SceneViewer::onToolChanged() {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
int SceneViewer::pick(const TPoint &point) {
|
int SceneViewer::pick(const TPointD &point) {
|
||||||
// pick is typically called in a mouse event handler.
|
// pick is typically called in a mouse event handler.
|
||||||
// QGLWidget::makeCurrent() is not automatically called in these events.
|
// QGLWidget::makeCurrent() is not automatically called in these events.
|
||||||
// (to exploit the bug: open the FxEditor preview and then select the edit
|
// (to exploit the bug: open the FxEditor preview and then select the edit
|
||||||
|
@ -2296,7 +2297,7 @@ int SceneViewer::pick(const TPoint &point) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
int SceneViewer::posToColumnIndex(const TPoint &p, double distance,
|
int SceneViewer::posToColumnIndex(const TPointD &p, double distance,
|
||||||
bool includeInvisible) const {
|
bool includeInvisible) const {
|
||||||
std::vector<int> ret;
|
std::vector<int> ret;
|
||||||
posToColumnIndexes(p, ret, distance, includeInvisible);
|
posToColumnIndexes(p, ret, distance, includeInvisible);
|
||||||
|
@ -2305,8 +2306,8 @@ int SceneViewer::posToColumnIndex(const TPoint &p, double distance,
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void SceneViewer::posToColumnIndexes(const TPoint &p, std::vector<int> &indexes,
|
void SceneViewer::posToColumnIndexes(const TPointD &p,
|
||||||
double distance,
|
std::vector<int> &indexes, double distance,
|
||||||
bool includeInvisible) const {
|
bool includeInvisible) const {
|
||||||
int oldRasterizePli = TXshSimpleLevel::m_rasterizePli;
|
int oldRasterizePli = TXshSimpleLevel::m_rasterizePli;
|
||||||
TApp *app = TApp::instance();
|
TApp *app = TApp::instance();
|
||||||
|
@ -2349,7 +2350,7 @@ includeInvisible);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
int SceneViewer::posToRow(const TPoint &p, double distance,
|
int SceneViewer::posToRow(const TPointD &p, double distance,
|
||||||
bool includeInvisible) const {
|
bool includeInvisible) const {
|
||||||
int oldRasterizePli = TXshSimpleLevel::m_rasterizePli;
|
int oldRasterizePli = TXshSimpleLevel::m_rasterizePli;
|
||||||
TApp *app = TApp::instance();
|
TApp *app = TApp::instance();
|
||||||
|
|
|
@ -65,8 +65,8 @@ class SceneViewer final : public GLWidgetForHighDpi,
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
qreal m_pressure;
|
qreal m_pressure;
|
||||||
QPoint m_lastMousePos;
|
QPointF m_lastMousePos;
|
||||||
QPoint m_pos;
|
QPointF m_pos;
|
||||||
Qt::MouseButton m_mouseButton;
|
Qt::MouseButton m_mouseButton;
|
||||||
bool m_foregroundDrawing;
|
bool m_foregroundDrawing;
|
||||||
bool m_tabletEvent, m_tabletMove;
|
bool m_tabletEvent, m_tabletMove;
|
||||||
|
@ -226,7 +226,7 @@ public:
|
||||||
TPointD getPan3D() const { return m_pan3D; }
|
TPointD getPan3D() const { return m_pan3D; }
|
||||||
double getZoomScale3D() const { return m_zoomScale3D; }
|
double getZoomScale3D() const { return m_zoomScale3D; }
|
||||||
|
|
||||||
double projectToZ(const TPoint &delta) override;
|
double projectToZ(const TPointD &delta) override;
|
||||||
|
|
||||||
TPointD getDpiScale() const override { return m_dpiScale; }
|
TPointD getDpiScale() const override { return m_dpiScale; }
|
||||||
void zoomQt(bool forward, bool reset);
|
void zoomQt(bool forward, bool reset);
|
||||||
|
@ -264,10 +264,10 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// SceneViewer's gadget public functions
|
// SceneViewer's gadget public functions
|
||||||
TPointD winToWorld(const QPoint &pos) const;
|
TPointD winToWorld(const QPointF &pos) const;
|
||||||
TPointD winToWorld(const TPoint &winPos) const override;
|
TPointD winToWorld(const TPointD &winPos) const override;
|
||||||
|
|
||||||
TPoint worldToPos(const TPointD &worldPos) const override;
|
TPointD worldToPos(const TPointD &worldPos) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Paint vars
|
// Paint vars
|
||||||
|
@ -328,13 +328,13 @@ protected:
|
||||||
bool event(QEvent *event) override;
|
bool event(QEvent *event) override;
|
||||||
|
|
||||||
// delta.x: right panning, pixel; delta.y: down panning, pixel
|
// delta.x: right panning, pixel; delta.y: down panning, pixel
|
||||||
void panQt(const QPoint &delta);
|
void panQt(const QPointF &delta);
|
||||||
|
|
||||||
// center: window coordinate, pixels, topleft origin
|
// center: window coordinate, pixels, topleft origin
|
||||||
void zoomQt(const QPoint ¢er, double scaleFactor);
|
void zoomQt(const QPoint ¢er, double scaleFactor);
|
||||||
|
|
||||||
// overriden from TTool::Viewer
|
// overriden from TTool::Viewer
|
||||||
void pan(const TPoint &delta) override { panQt(QPoint(delta.x, delta.y)); }
|
void pan(const TPointD &delta) override { panQt(QPointF(delta.x, delta.y)); }
|
||||||
|
|
||||||
// overriden from TTool::Viewer
|
// overriden from TTool::Viewer
|
||||||
void zoom(const TPointD ¢er, double factor) override;
|
void zoom(const TPointD ¢er, double factor) override;
|
||||||
|
@ -345,20 +345,20 @@ protected:
|
||||||
|
|
||||||
//! return the column index of the drawing intersecting point \b p
|
//! return the column index of the drawing intersecting point \b p
|
||||||
//! (window coordinate, pixels, bottom-left origin)
|
//! (window coordinate, pixels, bottom-left origin)
|
||||||
int pick(const TPoint &point) override;
|
int pick(const TPointD &point) override;
|
||||||
|
|
||||||
//! return the column indexes of the drawings intersecting point \b p
|
//! return the column indexes of the drawings intersecting point \b p
|
||||||
//! (window coordinate, pixels, bottom-left origin)
|
//! (window coordinate, pixels, bottom-left origin)
|
||||||
int posToColumnIndex(const TPoint &p, double distance,
|
int posToColumnIndex(const TPointD &p, double distance,
|
||||||
bool includeInvisible = true) const override;
|
bool includeInvisible = true) const override;
|
||||||
void posToColumnIndexes(const TPoint &p, std::vector<int> &indexes,
|
void posToColumnIndexes(const TPointD &p, std::vector<int> &indexes,
|
||||||
double distance,
|
double distance,
|
||||||
bool includeInvisible = true) const override;
|
bool includeInvisible = true) const override;
|
||||||
|
|
||||||
//! return the row of the drawings intersecting point \b p (used with onion
|
//! return the row of the drawings intersecting point \b p (used with onion
|
||||||
//! skins)
|
//! skins)
|
||||||
//! (window coordinate, pixels, bottom-left origin)
|
//! (window coordinate, pixels, bottom-left origin)
|
||||||
int posToRow(const TPoint &p, double distance,
|
int posToRow(const TPointD &p, double distance,
|
||||||
bool includeInvisible = true) const override;
|
bool includeInvisible = true) const override;
|
||||||
|
|
||||||
void dragEnterEvent(QDragEnterEvent *event) override;
|
void dragEnterEvent(QDragEnterEvent *event) override;
|
||||||
|
|
|
@ -77,7 +77,7 @@ int modifiers = 0;
|
||||||
|
|
||||||
void initToonzEvent(TMouseEvent &toonzEvent, QMouseEvent *event,
|
void initToonzEvent(TMouseEvent &toonzEvent, QMouseEvent *event,
|
||||||
int widgetHeight, double pressure, int devPixRatio) {
|
int widgetHeight, double pressure, int devPixRatio) {
|
||||||
toonzEvent.m_pos = TPoint(event->pos().x() * devPixRatio,
|
toonzEvent.m_pos = TPointD(event->pos().x() * devPixRatio,
|
||||||
widgetHeight - 1 - event->pos().y() * devPixRatio);
|
widgetHeight - 1 - event->pos().y() * devPixRatio);
|
||||||
toonzEvent.m_mousePos = event->pos();
|
toonzEvent.m_mousePos = event->pos();
|
||||||
toonzEvent.m_pressure = 255;
|
toonzEvent.m_pressure = 255;
|
||||||
|
@ -95,9 +95,10 @@ void initToonzEvent(TMouseEvent &toonzEvent, QMouseEvent *event,
|
||||||
|
|
||||||
void initToonzEvent(TMouseEvent &toonzEvent, QTabletEvent *event,
|
void initToonzEvent(TMouseEvent &toonzEvent, QTabletEvent *event,
|
||||||
int widgetHeight, double pressure, int devPixRatio) {
|
int widgetHeight, double pressure, int devPixRatio) {
|
||||||
toonzEvent.m_pos = TPoint(event->pos().x() * devPixRatio,
|
toonzEvent.m_pos = TPointD(
|
||||||
widgetHeight - 1 - event->pos().y() * devPixRatio);
|
event->posF().x() * (float)devPixRatio,
|
||||||
toonzEvent.m_mousePos = event->pos();
|
(float)widgetHeight - 1.0f - event->posF().y() * (float)devPixRatio);
|
||||||
|
toonzEvent.m_mousePos = event->posF();
|
||||||
toonzEvent.m_pressure = int(255 * pressure);
|
toonzEvent.m_pressure = int(255 * pressure);
|
||||||
|
|
||||||
toonzEvent.setModifiers(event->modifiers() & Qt::ShiftModifier,
|
toonzEvent.setModifiers(event->modifiers() & Qt::ShiftModifier,
|
||||||
|
@ -112,8 +113,8 @@ void initToonzEvent(TMouseEvent &toonzEvent, QTabletEvent *event,
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void initToonzEvent(TMouseEvent &toonzEvent, QKeyEvent *event) {
|
void initToonzEvent(TMouseEvent &toonzEvent, QKeyEvent *event) {
|
||||||
toonzEvent.m_pos = TPoint();
|
toonzEvent.m_pos = TPointD();
|
||||||
toonzEvent.m_mousePos = QPoint();
|
toonzEvent.m_mousePos = QPointF();
|
||||||
toonzEvent.m_pressure = 0;
|
toonzEvent.m_pressure = 0;
|
||||||
|
|
||||||
toonzEvent.setModifiers(event->modifiers() & Qt::ShiftModifier,
|
toonzEvent.setModifiers(event->modifiers() & Qt::ShiftModifier,
|
||||||
|
@ -427,7 +428,7 @@ void SceneViewer::onMove(const TMouseEvent &event) {
|
||||||
if (m_freezedStatus != NO_FREEZED) return;
|
if (m_freezedStatus != NO_FREEZED) return;
|
||||||
|
|
||||||
int devPixRatio = getDevPixRatio();
|
int devPixRatio = getDevPixRatio();
|
||||||
QPoint curPos = event.mousePos() * devPixRatio;
|
QPointF curPos = event.mousePos() * devPixRatio;
|
||||||
bool cursorSet = false;
|
bool cursorSet = false;
|
||||||
m_lastMousePos = curPos;
|
m_lastMousePos = curPos;
|
||||||
|
|
||||||
|
@ -495,8 +496,8 @@ void SceneViewer::onMove(const TMouseEvent &event) {
|
||||||
// if the middle mouse button is pressed while dragging, then do panning
|
// if the middle mouse button is pressed while dragging, then do panning
|
||||||
if (event.buttons() & Qt::MidButton) {
|
if (event.buttons() & Qt::MidButton) {
|
||||||
// panning
|
// panning
|
||||||
QPoint p = curPos - m_pos;
|
QPointF p = curPos - m_pos;
|
||||||
if (m_pos == QPoint(0, 0) && p.manhattanLength() > 300) return;
|
if (m_pos == QPointF() && p.manhattanLength() > 300) return;
|
||||||
panQt(curPos - m_pos);
|
panQt(curPos - m_pos);
|
||||||
m_pos = curPos;
|
m_pos = curPos;
|
||||||
return;
|
return;
|
||||||
|
@ -731,7 +732,7 @@ void SceneViewer::onRelease(const TMouseEvent &event) {
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pos = QPoint(0, 0);
|
m_pos = QPointF();
|
||||||
if (!tool || !tool->isEnabled()) goto quit;
|
if (!tool || !tool->isEnabled()) goto quit;
|
||||||
|
|
||||||
tool->setViewer(this);
|
tool->setViewer(this);
|
||||||
|
@ -1195,8 +1196,8 @@ void SceneViewer::keyPressEvent(QKeyEvent *event) {
|
||||||
// cambiare subito la forma del cursore, senza aspettare il prossimo move
|
// cambiare subito la forma del cursore, senza aspettare il prossimo move
|
||||||
TMouseEvent toonzEvent;
|
TMouseEvent toonzEvent;
|
||||||
initToonzEvent(toonzEvent, event);
|
initToonzEvent(toonzEvent, event);
|
||||||
toonzEvent.m_pos =
|
toonzEvent.m_pos = TPointD(m_lastMousePos.x(),
|
||||||
TPoint(m_lastMousePos.x(), height() - 1 - m_lastMousePos.y());
|
(double)(height() - 1) - m_lastMousePos.y());
|
||||||
|
|
||||||
TPointD pos = tool->getMatrix().inv() * winToWorld(m_lastMousePos);
|
TPointD pos = tool->getMatrix().inv() * winToWorld(m_lastMousePos);
|
||||||
|
|
||||||
|
@ -1352,8 +1353,8 @@ void SceneViewer::keyReleaseEvent(QKeyEvent *event) {
|
||||||
// cambiare subito la forma del cursore, senza aspettare il prossimo move
|
// cambiare subito la forma del cursore, senza aspettare il prossimo move
|
||||||
TMouseEvent toonzEvent;
|
TMouseEvent toonzEvent;
|
||||||
initToonzEvent(toonzEvent, event);
|
initToonzEvent(toonzEvent, event);
|
||||||
toonzEvent.m_pos =
|
toonzEvent.m_pos = TPointD(m_lastMousePos.x(),
|
||||||
TPoint(m_lastMousePos.x(), height() - 1 - m_lastMousePos.y());
|
(double)(height() - 1) - m_lastMousePos.y());
|
||||||
|
|
||||||
TPointD pos = tool->getMatrix().inv() * winToWorld(m_lastMousePos);
|
TPointD pos = tool->getMatrix().inv() * winToWorld(m_lastMousePos);
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ TRectD PreviewSubCameraManager::getEditingCameraInterestStageRect() const {
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
TPointD PreviewSubCameraManager::winToCamera(SceneViewer *viewer,
|
TPointD PreviewSubCameraManager::winToCamera(SceneViewer *viewer,
|
||||||
const QPoint &pos) const {
|
const QPointF &pos) const {
|
||||||
TPointD worldPos(viewer->winToWorld(pos));
|
TPointD worldPos(viewer->winToWorld(pos));
|
||||||
|
|
||||||
TApp *app = TApp::instance();
|
TApp *app = TApp::instance();
|
||||||
|
@ -100,7 +100,7 @@ TPointD PreviewSubCameraManager::winToCamera(SceneViewer *viewer,
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
TPoint PreviewSubCameraManager::cameraToWin(SceneViewer *viewer,
|
TPointD PreviewSubCameraManager::cameraToWin(SceneViewer *viewer,
|
||||||
const TPointD &cameraPos) const {
|
const TPointD &cameraPos) const {
|
||||||
TApp *app = TApp::instance();
|
TApp *app = TApp::instance();
|
||||||
TAffine stageToWorldRef(app->getCurrentXsheet()->getXsheet()->getCameraAff(
|
TAffine stageToWorldRef(app->getCurrentXsheet()->getXsheet()->getCameraAff(
|
||||||
|
@ -133,7 +133,7 @@ bool PreviewSubCameraManager::mousePressEvent(SceneViewer *viewer,
|
||||||
bool PreviewSubCameraManager::mouseMoveEvent(SceneViewer *viewer,
|
bool PreviewSubCameraManager::mouseMoveEvent(SceneViewer *viewer,
|
||||||
const TMouseEvent &event) {
|
const TMouseEvent &event) {
|
||||||
if (viewer->is3DView()) return true;
|
if (viewer->is3DView()) return true;
|
||||||
QPoint curPos(event.mousePos() * getDevPixRatio());
|
QPointF curPos(event.mousePos() * getDevPixRatio());
|
||||||
if (event.buttons() == Qt::LeftButton) {
|
if (event.buttons() == Qt::LeftButton) {
|
||||||
if (!bitwiseContains(m_dragType, INNER)) {
|
if (!bitwiseContains(m_dragType, INNER)) {
|
||||||
if (abs(curPos.x() - m_mousePressPos.x()) > 10 ||
|
if (abs(curPos.x() - m_mousePressPos.x()) > 10 ||
|
||||||
|
@ -261,17 +261,17 @@ bool PreviewSubCameraManager::mouseReleaseEvent(SceneViewer *viewer) {
|
||||||
|
|
||||||
//! Builds the drag enum and camera distance for subcamera refinement drags.
|
//! Builds the drag enum and camera distance for subcamera refinement drags.
|
||||||
UCHAR PreviewSubCameraManager::getSubCameraDragEnum(SceneViewer *viewer,
|
UCHAR PreviewSubCameraManager::getSubCameraDragEnum(SceneViewer *viewer,
|
||||||
const QPoint &mousePos) {
|
const QPointF &mousePos) {
|
||||||
TCamera *camera =
|
TCamera *camera =
|
||||||
TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera();
|
TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera();
|
||||||
TRect subCamera = camera->getInterestRect();
|
TRect subCamera = camera->getInterestRect();
|
||||||
|
|
||||||
if (subCamera.getLx() <= 0 || subCamera.getLy() <= 0) return NODRAG;
|
if (subCamera.getLx() <= 0 || subCamera.getLy() <= 0) return NODRAG;
|
||||||
|
|
||||||
TPointD cameraPosL(winToCamera(viewer, mousePos - QPoint(10, 0)));
|
TPointD cameraPosL(winToCamera(viewer, mousePos - QPointF(10, 0)));
|
||||||
TPointD cameraPosR(winToCamera(viewer, mousePos + QPoint(10, 0)));
|
TPointD cameraPosR(winToCamera(viewer, mousePos + QPointF(10, 0)));
|
||||||
TPointD cameraPosT(winToCamera(viewer, mousePos - QPoint(0, 10)));
|
TPointD cameraPosT(winToCamera(viewer, mousePos - QPointF(0, 10)));
|
||||||
TPointD cameraPosB(winToCamera(viewer, mousePos + QPoint(0, 10)));
|
TPointD cameraPosB(winToCamera(viewer, mousePos + QPointF(0, 10)));
|
||||||
|
|
||||||
TRectD cameraPosBox(
|
TRectD cameraPosBox(
|
||||||
std::min({cameraPosL.x, cameraPosR.x, cameraPosT.x, cameraPosB.x}),
|
std::min({cameraPosL.x, cameraPosR.x, cameraPosT.x, cameraPosB.x}),
|
||||||
|
@ -302,7 +302,7 @@ UCHAR PreviewSubCameraManager::getSubCameraDragEnum(SceneViewer *viewer,
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
TPoint PreviewSubCameraManager::getSubCameraDragDistance(
|
TPoint PreviewSubCameraManager::getSubCameraDragDistance(
|
||||||
SceneViewer *viewer, const QPoint &mousePos) {
|
SceneViewer *viewer, const QPointF &mousePos) {
|
||||||
// Build the camera drag distance
|
// Build the camera drag distance
|
||||||
if (m_clickAndDrag) return TPoint();
|
if (m_clickAndDrag) return TPoint();
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ class PreviewSubCameraManager final : public SceneViewerInteractiveGadget {
|
||||||
UCHAR m_dragType;
|
UCHAR m_dragType;
|
||||||
bool m_clickAndDrag;
|
bool m_clickAndDrag;
|
||||||
|
|
||||||
QPoint m_mousePressPos;
|
QPointF m_mousePressPos;
|
||||||
TPointD m_cameraMousePressPos;
|
TPointD m_cameraMousePressPos;
|
||||||
bool m_mousePressed;
|
bool m_mousePressed;
|
||||||
|
|
||||||
|
@ -106,11 +106,11 @@ public:
|
||||||
void deleteSubCamera(SceneViewer *viewer);
|
void deleteSubCamera(SceneViewer *viewer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TPointD winToCamera(SceneViewer *viewer, const QPoint &pos) const;
|
TPointD winToCamera(SceneViewer *viewer, const QPointF &pos) const;
|
||||||
TPoint cameraToWin(SceneViewer *viewer, const TPointD &cameraPos) const;
|
TPointD cameraToWin(SceneViewer *viewer, const TPointD &cameraPos) const;
|
||||||
|
|
||||||
UCHAR getSubCameraDragEnum(SceneViewer *viewer, const QPoint &mousePos);
|
UCHAR getSubCameraDragEnum(SceneViewer *viewer, const QPointF &mousePos);
|
||||||
TPoint getSubCameraDragDistance(SceneViewer *viewer, const QPoint &mousePos);
|
TPoint getSubCameraDragDistance(SceneViewer *viewer, const QPointF &mousePos);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SUBCAMERAMANAGER_INCLUDED
|
#endif // SUBCAMERAMANAGER_INCLUDED
|
||||||
|
|
Loading…
Reference in a new issue