After playing with it a bit, I understand how it might have been the way it
was due to not caring about the behavior of points close together (rather
than explicitly wanting them to act that way) while wanting an interface
that supported the explicit method of supporting multiple points (dragging).
I expect the project admins won't want this change (won't see any value in
better support of points very near each other within a mask). So
committing this to sourceforge would just confuse the other things I want
to commit later.
But, if anyone cares, the code below is what I'm using myself replacing
that function. So far, I'm much happier about the way it behaves vs.
struggling with the original.
I hope the code below formats OK in google groups. The online instructions
for doing that "correctly" tell me to click on something that isn't there.
Unlike other forums, I can't preview and I can't edit after posting. So
apologies if the following comes out unreadable (and if so, can someone
tell me how to do it right):
// Inserts into UIntSet &points either all (selected) points inside
rectangle m_dragStartPos
// to m_currentPos, or (if there were none) the single nearest and near
enough point outside
bool MaskImageCtrl::SelectPointsInsideMouseRect(HuginBase::UIntSet
&points,const bool considerSelectedOnly)
{
// compute one dimension distance outside range (zero if inside range)
auto distanceHelper = [](double vmin, double vmax, double v)->double
{
return (v<vmin) ? (vmin-v) : (v<vmax) ? 0 : (v-vmax);
};
double selectionLimit = maxSelectionDistance*maxSelectionDistance;
unsigned pending = UINT_MAX;
hugin_utils::FDiff2D p1=applyRotInv(invtransform(m_dragStartPos));
hugin_utils::FDiff2D p2=applyRotInv(invtransform(m_currentPos));
double xmin=std::min(p1.x,p2.x);
double xmax=std::max(p1.x,p2.x);
double ymin=std::min(p1.y,p2.y);
double ymax=std::max(p1.y,p2.y);
const HuginBase::VectorPolygon poly=m_editingMask.getMaskPolygon();
for(unsigned int i=0;i<poly.size();i++)
{
if( !considerSelectedOnly || set_contains(m_selectedPoints,i) )
{
double xDistance = distanceHelper(xmin, xmax, poly[i].x);
double yDistance = distanceHelper(ymin, ymax, poly[i].y);
double d2 = xDistance*xDistance + yDistance*yDistance;
if(d2 <= selectionLimit)
{
if(selectionLimit==0 && pending!=UINT_MAX)
points.insert(pending);
pending = i;
selectionLimit = d2;
}
}
}
if(pending!=UINT_MAX)
{
points.insert(pending);
return true;
}
return false;
};
--
A list of frequently asked questions is available at:
http://wiki.panotools.org/Hugin_FAQ
---
You received this message because you are subscribed to the Google Groups
"hugin and other free panoramic software" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/hugin-ptx/c29e6427-2a1e-4842-8d50-a8b1f9ebeebfn%40googlegroups.com.