Exemplo n.º 1
0
vector< vector< double > > allocateMatrix(int rows, int cols)
{
    vector< vector< double > > toRet(rows);
    for(int i = 0; i < rows; i++)
        for(int j = 0; j < cols; j++)
            toRet[i].push_back(0);
    return toRet;

}
//pure-virtual from QGraphicsItem
QRectF PrivateQGraphicsObject::boundingRect() const
{
    QRectF toRet(-1.0,-1.0,2.0,2.0);
    if (_mgObj.isNull())
    {
        qWarning() << "Warning:" << this << "could not get bounding rect as MapGraphicsObject is null";
        return toRet;
    }

    //If the object's size is zoom invariant (e.g., labels or markers) then assume the rect's units are pixels
    if (_mgObj->sizeIsZoomInvariant())
        return _mgObj->boundingRect();

    //Otherwise, assume they're meters and do some conversions!
    QRectF enuRect = _mgObj->boundingRect();

    //Convert from ENU to lat/lon
    QPointF latLonCenter = _mgObj->pos();
    Position latLonCenterPos(latLonCenter, 0.0);
    QPointF leftLatLon = Conversions::enu2lla(enuRect.left(),
                                              0.0,
                                              0.0,
                                              latLonCenterPos).lonLat();
    QPointF upLatLon = Conversions::enu2lla(0.0,
                                            enuRect.top(),
                                            0.0,
                                            latLonCenterPos).lonLat();

    qreal lonWidth = 2.0*(latLonCenter.x() - leftLatLon.x());
    qreal latHeight = 2.0*(upLatLon.y() - latLonCenter.y());

    //Once we've got the rect in lat/lon, we should convert it to scene pixels
    QRectF latLonRect(leftLatLon.x(),upLatLon.y(),lonWidth,latHeight);

    //We need our tile source to do the conversion
    QSharedPointer<MapTileSource> tileSource = _infoSource->tileSource();
    if (tileSource.isNull())
    {
        qWarning() << this << "can't do bounding box conversion, null tile source.";
        return toRet;
    }

    int zoomLevel = _infoSource->zoomLevel();
    QPointF topLeft = tileSource->ll2qgs(latLonRect.topLeft(),zoomLevel);
    QPointF bottomRight = tileSource->ll2qgs(latLonRect.bottomRight(),zoomLevel);

    toRet = QRectF(topLeft,bottomRight);
    toRet.moveCenter(QPointF(0,0));
    return toRet;
}
Exemplo n.º 3
0
GameObjectPtr NetworkManager::RegisterAndReturn( GameObject* inGameObject )
{
	GameObjectPtr toRet( inGameObject );
	RegisterGameObject( toRet );
	return toRet;
}