Example #1
0
void
DrawCross(const Graphics& g, const Point& pt, const Size& s, Color c)
{
	if(YB_LIKELY(s.Width > 8 && s.Height > 8))
	{
		const Rect r(pt, s);
		const SPos xmin(pt.X + 4), xmax(xmin + s.Width - 8),
			ymin(pt.Y + 4), ymax(ymin + s.Height - 8);

		DrawLineSeg(g, r, xmin, ymin, xmax, ymax, c),
		DrawLineSeg(g, r, xmax - 1, ymin, xmin - 1, ymax, c);
	}
}
Example #2
0
/* plot to dc, or opengl is dc is NULL */
void IsoBarMap::Plot(wxDC *dc, PlugIn_ViewPort &vp)
{
    if(dc) {
        dc->SetPen(wxPen(m_Color, 3));
    } else {
        glLineWidth(3.0);
        glColor4ub(m_Color.Red(), m_Color.Green(), m_Color.Blue(), m_Color.Alpha());
    }

    int startlatind = floor((vp.lat_min+MAX_LAT)/ZONE_SIZE);
    if(startlatind < 0) startlatind = 0;

    int endlatind = floor((vp.lat_max+MAX_LAT)/ZONE_SIZE);
    if(endlatind > LATITUDE_ZONES-1) endlatind = LATITUDE_ZONES-1;

    double lon_min = vp.lon_min; /* expected +- 360 convert to +- 180 */
    if(lon_min<-180) lon_min+=360;
    else if(lon_min>=180) lon_min-=360;
    int startlonind = floor((lon_min+180)/ZONE_SIZE);
    if(startlonind < 0) startlonind = LONGITUDE_ZONES-1;
    if(startlonind > LONGITUDE_ZONES-1) startlonind = 0;

    double lon_max = vp.lon_max; /* expected +- 360 convert to +- 180 */
    if(lon_max<-180) lon_max+=360;
    else if(lon_max>=180) lon_max-=360;
    int endlonind = floor((lon_max+180)/ZONE_SIZE);
    if(endlonind < 0) endlonind = LONGITUDE_ZONES-1;
    if(endlonind > LONGITUDE_ZONES-1) endlonind = 0;

    for(int latind = startlatind; latind <= endlatind; latind++)
        for(int lonind = startlonind;; lonind++) {
            if(lonind > LONGITUDE_ZONES-1)
                lonind = 0;
            for(std::list<PlotLineSeg*>::iterator it = m_map[latind][lonind].begin();
                    it!=m_map[latind][lonind].end(); it++) {
                DrawLineSeg(dc, vp, (*it)->lat1, (*it)->lon1, (*it)->lat2, (*it)->lon2);
                wxString msg;
                DrawContour(dc, vp, (*it)->contour,
                            ((*it)->lat1 + (*it)->lat2)/2,
                            ((*it)->lon1 + (*it)->lon2)/2);
            }
            if(lonind == endlonind)
                break;
        }
}