Example #1
0
void GPSView::AddGPSPoints(GPSPoints &p){

	int width;
	int height;
	GetClientSize(&width, &height);

	Point minXY(-1, -1);
	Point maxXY(-1, -1);

	for (size_t i = 0; i < p.Count(); i++){
		Point point = ProjectPoint(p[i]);
		minXY.x = ((minXY.x == -1) ? point.x : std::min(minXY.x, point.x));
		minXY.y = ((minXY.y == -1) ? point.y : std::min(minXY.y, point.y));
		m_trackPoints.Add(point);
	}

	for (size_t i = 0; i < m_trackPoints.size(); i++){
		Point point = m_trackPoints[i];
		point.x = point.x - minXY.x;
        point.y = point.y - minXY.y;
        // now, we need to keep track the max X and Y values
        maxXY.x = (maxXY.x == -1) ? point.x : std::max(maxXY.x, point.x);
        maxXY.y = (maxXY.y == -1) ? point.y : std::max(maxXY.y, point.y);
	}

	int paddingBothSides = MIN_PADDING * 2;

	// the actual drawing space for the map on the image
    int mapWidth = width - paddingBothSides;
    int mapHeight = height - paddingBothSides;

    // determine the width and height ratio because we need to magnify the map to fit into the given image dimension
    double mapWidthRatio = mapWidth / maxXY.x;
    double mapHeightRatio = mapHeight / maxXY.y;

    // using different ratios for width and height will cause the map to be stretched. So, we have to determine
    // the global ratio that will perfectly fit into the given image dimension
    m_globalRatio = std::min(mapWidthRatio, mapHeightRatio);

    // now we need to readjust the padding to ensure the map is always drawn on the center of the given image dimension
    m_heightPadding = (height - (m_globalRatio * maxXY.y)) / 2;
    m_widthPadding = (width - (m_globalRatio * maxXY.x)) / 2;
    m_offsetPoint = minXY;
    UpdateMinMax(m_trackPoints);
    RefreshBackground();
}
Example #2
0
void Barrier::initOutConstraint (int pathCount, const Point *)
{
    if (pathCount)
        throw new StringError ("Barriers may not have out constraints");
	UpdateMinMax();
}
Example #3
0
void Barrier::scale (double sx, double sy, double sz )
{
	m_barrier.scale( sx, sy, sz );
	UpdateMinMax();
}