Logo Search packages:      
Sourcecode: qmk-groundstation version File versions  Download package

bool qmapcontrol::Point::Touches ( Point geom,
const MapAdapter mapadapter 
) [protected, virtual]

returns true if the given Point touches this Point

The collision detection checks for the bounding rectangulars.

Parameters:
geom the other point which should be tested on collision
mapadapter the mapadapter which is used for calculations
Returns:

Implements qmapcontrol::Geometry.

Definition at line 231 of file point.cpp.

References BottomLeft, BottomRight, coordinate(), qmapcontrol::MapAdapter::coordinateToDisplay(), qmapcontrol::MapAdapter::displayToCoordinate(), qmapcontrol::Geometry::geometryClicked(), qmapcontrol::Geometry::isVisible(), latitude(), longitude(), Middle, TopLeft, and TopRight.

    {
        if (this->isVisible() == false)
            return false;
        if (mypixmap == 0)
            return false;

        QPointF c = p->coordinate();
        // coordinate to pixel
        QPoint pxOfPoint = mapadapter->coordinateToDisplay(c);
        // size/2 Pixel toleranz aufaddieren
        QPoint p1;
        QPoint p2;

        switch (myalignment)
        {
                        case Middle:
            p1 = pxOfPoint - QPoint(displaysize.width()/2,displaysize.height()/2);
            p2 = pxOfPoint + QPoint(displaysize.width()/2,displaysize.height()/2);
            break;
                        case TopLeft:
            p1 = pxOfPoint - QPoint(displaysize.width(),displaysize.height());
            p2 = pxOfPoint;
            break;
                        case TopRight:
            p1 = pxOfPoint - QPoint(0, displaysize.height());
            p2 = pxOfPoint + QPoint(displaysize.width(),0);
            break;
                        case BottomLeft:
            p1 = pxOfPoint - QPoint(displaysize.width(), 0);
            p2 = pxOfPoint + QPoint(0, displaysize.height());
            break;
                        case BottomRight:
            p1 = pxOfPoint;
            p2 = pxOfPoint + QPoint(displaysize.width(), displaysize.height());
            break;
        }

        // calculate "Bounding Box" in coordinates
        QPointF c1 = mapadapter->displayToCoordinate(p1);
        QPointF c2 = mapadapter->displayToCoordinate(p2);


        if(this->longitude()>=c1.x() && this->longitude()<=c2.x())
        {
            if (this->latitude()<=c1.y() && this->latitude()>=c2.y())
            {
                emit(geometryClicked(this, QPoint(0,0)));
                return true;
            }
        }
        return false;
    }


Generated by  Doxygen 1.6.0   Back to index