Skip to content

Commit 90fb9de

Browse files
committed
fix snapping behavior
1 parent dae67e6 commit 90fb9de

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

plugins/SkyCultureMaker/src/ScmDraw.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ bool scm::ScmDraw::handleMouseMoves(int x, int y, Qt::MouseButtons b)
273273

274274
if (activeTool == DrawTools::Pen)
275275
{
276+
Vec3d position = Vec3d(0, 0, 0);
277+
276278
if (drawingMode == DrawingMode::StarsAndDSO)
277279
{
278280
// this wouldve been easier with cleverFind but that is private
@@ -291,15 +293,23 @@ bool scm::ScmDraw::handleMouseMoves(int x, int y, Qt::MouseButtons b)
291293
{
292294
objectMgr.unSelect();
293295
}
296+
// snap to the star and update the line position
297+
else
298+
{
299+
position = stelObj->getJ2000EquatorialPos(core);
300+
}
294301
}
295302
}
296303

297-
// draw a floating line in any mode
298304
if (hasFlag(drawState, (Drawing::hasStart | Drawing::hasFloatingEnd)))
299305
{
300-
StelProjectorP prj = core->getProjection(drawFrame);
301-
Vec3d position;
302-
prj->unProject(x, y, position);
306+
// no selection, compute the position from the mouse cursor
307+
if (position == Vec3d(0, 0, 0))
308+
{
309+
std::get<CoordinateLine>(currentLine).end = position;
310+
StelProjectorP prj = core->getProjection(drawFrame);
311+
prj->unProject(x, y, position);
312+
}
303313
std::get<CoordinateLine>(currentLine).end = position;
304314
drawState = Drawing::hasFloatingEnd;
305315
}

0 commit comments

Comments
 (0)