On Thursday, February 10, 2022 at 7:00:05 PM UTC-5 johnfi...@gmail.com 
wrote:

>  A slight rearrangement of conditions inside my code would directly fix 
> the problem you described.
>
> Since you have seen symptoms of the basic issue I described, does that 
> mean you would like it corrected in hugin, and if so, is the basic approach 
> I selected (corrected for the case you mentioned) acceptable?
>
> I made that change, new version below.  I only tested a tiny amount, but 
including the case you mentioned that I hadn't tested before, which now 
works the way I assume most people would consider correct.

 // Inserts qualifying points int UIntSet &points, returns true if any found
// 1) Any number of points inside the rectangle m_dragStartPos to 
m_currentPos might qualify
// 2) If no points are in the rectangle, the single point nearest the 
rectangle, if near enough, might qualify
//     (unspecified which one in case of ties, but only one)
// 3) If considerSelectedOnly, only selected points actually qualify.
// Even if considerSelectedOnly is true, an unselected point may disqualify 
some selected point that is further
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++)
    {
        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);
            else
                pending = UINT_MAX;
            if( !considerSelectedOnly || set_contains(m_selectedPoints,i) )
                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 hugin-ptx+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/hugin-ptx/1246738c-1415-4ed2-b2ab-468428b3423an%40googlegroups.com.

Reply via email to