Merge pull request #2809 from manongjohn/improve_vector_stroke_selection
Improve vector stroke selection
This commit is contained in:
commit
db6b5f45a9
1 changed files with 19 additions and 9 deletions
|
@ -94,13 +94,21 @@ FourPoints getFourPointsFromVectorImage(const TVectorImageP &img,
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool getStrokeIndexFromPos(UINT &index, const TVectorImageP &vi,
|
bool getStrokeIndexFromPos(UINT &index, const TVectorImageP &vi,
|
||||||
const TPointD &pos, double pixelSize) {
|
const TPointD &pos, double pixelSize, TAffine aff) {
|
||||||
if (!vi) return false;
|
if (!vi) return false;
|
||||||
double t, dist2 = 0;
|
double t, dist2 = 0;
|
||||||
double maxDist = 5 * pixelSize;
|
double maxDist = 5 * pixelSize;
|
||||||
double maxDist2 = maxDist * maxDist;
|
double maxDist2 = maxDist * maxDist;
|
||||||
vi->getNearestStroke(pos, t, index, dist2);
|
double checkDist = maxDist2 * 4;
|
||||||
return (dist2 < maxDist2 * 4);
|
|
||||||
|
if (vi->getNearestStroke(pos, t, index, dist2)) {
|
||||||
|
TStroke *strokeRef = vi->getStroke(index);
|
||||||
|
TThickPoint cursor = strokeRef->getThickPoint(t);
|
||||||
|
double len = cursor.thick * pixelSize * sqrt(aff.det());
|
||||||
|
checkDist = std::max(checkDist, (len * len));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (dist2 < checkDist);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -1448,7 +1456,8 @@ void VectorSelectionTool::modifySelectionOnClick(TImageP image,
|
||||||
|
|
||||||
UINT index = 0;
|
UINT index = 0;
|
||||||
bool modifiableSel = isModifiableSelectionType(),
|
bool modifiableSel = isModifiableSelectionType(),
|
||||||
strokeAtPos = getStrokeIndexFromPos(index, vi, pos, getPixelSize()),
|
strokeAtPos = getStrokeIndexFromPos(index, vi, pos, getPixelSize(),
|
||||||
|
getViewer()->getViewMatrix()),
|
||||||
addStroke = strokeAtPos && !m_strokeSelection.isSelected(index),
|
addStroke = strokeAtPos && !m_strokeSelection.isSelected(index),
|
||||||
toggleStroke = strokeAtPos && e.isShiftPressed();
|
toggleStroke = strokeAtPos && e.isShiftPressed();
|
||||||
|
|
||||||
|
@ -2155,7 +2164,8 @@ void VectorSelectionTool::updateAction(TPointD pos, const TMouseEvent &e) {
|
||||||
|
|
||||||
if ((isLevelType() &&
|
if ((isLevelType() &&
|
||||||
bbox.contains(pos)) // What about isSelectedFramesType()??
|
bbox.contains(pos)) // What about isSelectedFramesType()??
|
||||||
|| (getStrokeIndexFromPos(index, vi, pos, getPixelSize()) &&
|
|| (getStrokeIndexFromPos(index, vi, pos, getPixelSize(),
|
||||||
|
getViewer()->getViewMatrix()) &&
|
||||||
m_strokeSelection.isSelected(index))) {
|
m_strokeSelection.isSelected(index))) {
|
||||||
m_what = Inside;
|
m_what = Inside;
|
||||||
m_cursorId =
|
m_cursorId =
|
||||||
|
|
Loading…
Reference in a new issue