Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SlicerT: improve mouse pointer logic with related visual enhancement #7711

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions plugins/SlicerT/SlicerTWaveform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static QColor s_playHighlightColor = QColor(255, 255, 255, 70); // now playing n
// slice markers
static QColor s_sliceColor = QColor(218, 193, 255); // color of slice marker
static QColor s_sliceShadowColor = QColor(136, 120, 158); // color of dark side of slice marker
static QColor s_sliceHighlightColor = QColor(255, 255, 255); // color of highlighted slice marker
static QColor s_sliceHighlightColor = QColor(255, 0, 0); // color of highlighted slice marker

// seeker rect colors
static QColor s_seekerColor = QColor(178, 115, 255); // outline of seeker
Expand Down Expand Up @@ -321,15 +321,27 @@ void SlicerTWaveform::updateClosest(QMouseEvent* me)
m_closestSlice = -1;
float startFrame = m_seekerStart;
float endFrame = m_seekerEnd;
float nearestSoFar = s_distanceForClick;

for (auto i = std::size_t{0}; i < m_slicerTParent->m_slicePoints.size(); i++)
{
float sliceIndex = m_slicerTParent->m_slicePoints.at(i);
float xPos = (sliceIndex - startFrame) / (endFrame - startFrame);

if (std::abs(xPos - normalizedClickEditor) < s_distanceForClick)
float currentDistance = std::abs(xPos - normalizedClickEditor);

if (currentDistance < s_distanceForClick)
{
m_closestObject = UIObjects::SlicePoint;
m_closestSlice = i;
if( currentDistance < nearestSoFar)
{
m_closestObject = UIObjects::SlicePoint;
m_closestSlice = i;
nearestSoFar = currentDistance;
}
else
{
// Done, this can't get any better
break;
}
}
}
}
Expand Down