void ocpnDC::DrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, bool b_hiqual ) { if( dc ) dc->DrawLines( n, points, xoffset, yoffset ); #ifdef ocpnUSE_GL else if( ConfigurePen() ) { SetGLAttrs( b_hiqual ); bool b_draw_thick = false; glDisable( GL_LINE_STIPPLE ); SetGLStipple(); // Enable anti-aliased lines, at best quality if( b_hiqual ) { glEnable( GL_BLEND ); if( m_pen.GetWidth() > 1 ) { GLint parms[2]; glGetIntegerv( GL_SMOOTH_LINE_WIDTH_RANGE, &parms[0] ); if( m_pen.GetWidth() > parms[1] ) b_draw_thick = true; else glLineWidth( wxMax(g_GLMinSymbolLineWidth, m_pen.GetWidth()) ); } else glLineWidth( wxMax(g_GLMinSymbolLineWidth, 1) ); } else { if( m_pen.GetWidth() > 1 ) { GLint parms[2]; glGetIntegerv( GL_ALIASED_LINE_WIDTH_RANGE, &parms[0] ); if( m_pen.GetWidth() > parms[1] ) b_draw_thick = true; else glLineWidth( wxMax(g_GLMinSymbolLineWidth, m_pen.GetWidth()) ); } else glLineWidth( wxMax(g_GLMinSymbolLineWidth, 1) ); } if( b_draw_thick) { DrawGLThickLines( n, points, xoffset, yoffset, m_pen, b_hiqual ); } else { if( b_hiqual ) { glEnable( GL_LINE_SMOOTH ); ;// SetGLStipple(m_pen.GetStyle()); } glBegin( GL_LINE_STRIP ); for( int i = 0; i < n; i++ ) glVertex2i( points[i].x + xoffset, points[i].y + yoffset ); glEnd(); } if( b_hiqual ) { glDisable( GL_LINE_STIPPLE ); glDisable( GL_POLYGON_SMOOTH ); glDisable( GL_BLEND ); } } #endif }
void ocpnDC::DrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, bool b_hiqual ) { if( dc ) dc->DrawLines( n, points, xoffset, yoffset ); else if( ConfigurePen() ) { glPushAttrib( GL_COLOR_BUFFER_BIT | GL_LINE_BIT | GL_HINT_BIT ); //Save state SetGLAttrs( b_hiqual ); bool b_draw_thick = false; SetGLStipple(); // Enable anti-aliased lines, at best quality if( b_hiqual ) { if( m_pen.GetWidth() > 1 ) { GLint parms[2]; glGetIntegerv( GL_SMOOTH_LINE_WIDTH_RANGE, &parms[0] ); if( m_pen.GetWidth() > parms[1] ) b_draw_thick = true; else glLineWidth( wxMax(g_GLMinLineWidth, m_pen.GetWidth()) ); } else glLineWidth( wxMax(g_GLMinLineWidth, 1) ); } else { if( m_pen.GetWidth() > 1 ) { GLint parms[2]; glGetIntegerv( GL_ALIASED_LINE_WIDTH_RANGE, &parms[0] ); if( m_pen.GetWidth() > parms[1] ) b_draw_thick = true; else glLineWidth( wxMax(g_GLMinLineWidth, m_pen.GetWidth()) ); } else glLineWidth( wxMax(g_GLMinLineWidth, 1) ); } if( b_draw_thick/*m_pen.GetWidth() > 1*/) { wxPoint p0 = points[0]; for( int i = 1; i < n; i++ ) { DrawThickLine( p0.x + xoffset, p0.y + yoffset, points[i].x + xoffset, points[i].y + yoffset, m_pen, b_hiqual ); p0 = points[i]; } } else { glBegin( GL_LINE_STRIP ); for( int i = 0; i < n; i++ ) glVertex2i( points[i].x + xoffset, points[i].y + yoffset ); glEnd(); } glPopAttrib(); // restore state } }
void ocpnDC::DrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, bool b_hiqual ) { if( dc ) dc->DrawLine( x1, y1, x2, y2 ); else { glPushAttrib( GL_COLOR_BUFFER_BIT | GL_LINE_BIT | GL_ENABLE_BIT | GL_HINT_BIT ); //Save state if( ConfigurePen() ) { glDisable( GL_MULTISAMPLE ); bool b_draw_thick = false; float pen_width = wxMax(g_GLMinLineWidth, m_pen.GetWidth()); // Enable anti-aliased lines, at best quality if( b_hiqual ) { SetGLStipple(); glEnable( GL_LINE_SMOOTH ); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glHint( GL_LINE_SMOOTH_HINT, GL_NICEST ); if( pen_width > 1.0 ) { GLint parms[2]; glGetIntegerv( GL_SMOOTH_LINE_WIDTH_RANGE, &parms[0] ); if( pen_width > parms[1] ) b_draw_thick = true; else glLineWidth( pen_width ); } else glLineWidth( pen_width ); } else { glDisable( GL_LINE_SMOOTH ); glDisable( GL_BLEND ); if( pen_width > 1 ) { GLint parms[2]; glGetIntegerv( GL_ALIASED_LINE_WIDTH_RANGE, &parms[0] ); if( pen_width > parms[1] ) b_draw_thick = true; else glLineWidth( pen_width ); } else glLineWidth( pen_width ); } if( b_draw_thick ) DrawThickLine( x1, y1, x2, y2, m_pen, b_hiqual ); else { wxDash *dashes; int n_dashes = m_pen.GetDashes( &dashes ); if( n_dashes ) { double angle = atan2( (double) ( y2 - y1 ), (double) ( x2 - x1 ) ); double cosa = cos( angle ); double sina = sin( angle ); double t1 = m_pen.GetWidth(); double lpix = sqrt( (double) ( x1 - x2 ) * ( x1 - x2 ) + (double) ( y1 - y2 ) * ( y1 - y2 ) ); double lrun = 0.; double xa = x1; double ya = y1; double ldraw = t1 * dashes[0]; double lspace = t1 * dashes[1]; while( lrun < lpix ) { // Dash double xb = xa + ldraw * cosa; double yb = ya + ldraw * sina; if( ( lrun + ldraw ) >= lpix ) // last segment is partial draw { xb = x2; yb = y2; } glBegin( GL_LINES ); glVertex2f( xa, ya ); glVertex2f( xb, yb ); glEnd(); xa = xa + ( lspace + ldraw ) * cosa; ya = ya + ( lspace + ldraw ) * sina; lrun += lspace + ldraw; } } else // not dashed { glBegin( GL_LINES ); glVertex2i( x1, y1 ); glVertex2i( x2, y2 ); glEnd(); } } } glPopAttrib(); } }
void ocpnDC::DrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, bool b_hiqual ) { if( dc ) dc->DrawLine( x1, y1, x2, y2 ); #ifdef ocpnUSE_GL else if( ConfigurePen() ) { bool b_draw_thick = false; float pen_width = wxMax(g_GLMinSymbolLineWidth, m_pen.GetWidth()); // Enable anti-aliased lines, at best quality if( b_hiqual ) { SetGLStipple(); #ifndef __WXQT__ glEnable( GL_BLEND ); glEnable( GL_LINE_SMOOTH ); #endif if( pen_width > 1.0 ) { GLint parms[2]; glGetIntegerv( GL_SMOOTH_LINE_WIDTH_RANGE, &parms[0] ); if( pen_width > parms[1] ) b_draw_thick = true; else glLineWidth( pen_width ); } else glLineWidth( pen_width ); } else { if( pen_width > 1 ) { GLint parms[2]; glGetIntegerv( GL_ALIASED_LINE_WIDTH_RANGE, &parms[0] ); if( pen_width > parms[1] ) b_draw_thick = true; else glLineWidth( pen_width ); } else glLineWidth( pen_width ); } if( b_draw_thick ) DrawGLThickLine( x1, y1, x2, y2, m_pen, b_hiqual ); else { wxDash *dashes; int n_dashes = m_pen.GetDashes( &dashes ); if( n_dashes ) { float angle = atan2f( (float) ( y2 - y1 ), (float) ( x2 - x1 ) ); float cosa = cosf( angle ); float sina = sinf( angle ); float t1 = m_pen.GetWidth(); float lpix = sqrtf( powf(x1 - x2, 2) + powf(y1 - y2, 2) ); float lrun = 0.; float xa = x1; float ya = y1; float ldraw = t1 * dashes[0]; float lspace = t1 * dashes[1]; ldraw = wxMax(ldraw, 4.0); lspace = wxMax(lspace, 4.0); lpix = wxMin(lpix, 2000.0); glBegin( GL_LINES ); while( lrun < lpix ) { // Dash float xb = xa + ldraw * cosa; float yb = ya + ldraw * sina; if( ( lrun + ldraw ) >= lpix ) // last segment is partial draw { xb = x2; yb = y2; } glVertex2f( xa, ya ); glVertex2f( xb, yb ); xa = xa + ( lspace + ldraw ) * cosa; ya = ya + ( lspace + ldraw ) * sina; lrun += lspace + ldraw; } glEnd(); } else // not dashed { glBegin( GL_LINES ); glVertex2i( x1, y1 ); glVertex2i( x2, y2 ); glEnd(); } } glDisable( GL_LINE_STIPPLE ); if( b_hiqual ) { glDisable( GL_LINE_SMOOTH ); glDisable( GL_BLEND ); } } #endif }