diff --git a/common/basic_gal.cpp b/common/basic_gal.cpp index 16387b8e5b..ec4ff5e983 100644 --- a/common/basic_gal.cpp +++ b/common/basic_gal.cpp @@ -59,7 +59,7 @@ void BASIC_GAL::doDrawPolyline( const std::vector& aLocalPointList ) { if( m_DC ) { - if( isFillEnabled ) + if( m_isFillEnabled ) { GRPoly( m_isClipped ? &m_clipBox : NULL, m_DC, aLocalPointList.size(), &aLocalPointList[0], 0, GetLineWidth(), m_Color, m_Color ); @@ -130,7 +130,7 @@ void BASIC_GAL::DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint if( m_DC ) { - if( isFillEnabled ) + if( m_isFillEnabled ) { GRLine( m_isClipped ? &m_clipBox : NULL, m_DC, startVector.x, startVector.y, endVector.x, endVector.y, GetLineWidth(), m_Color ); diff --git a/common/gal/cairo/cairo_gal.cpp b/common/gal/cairo/cairo_gal.cpp index e7bd28c4c3..a241a17b4e 100644 --- a/common/gal/cairo/cairo_gal.cpp +++ b/common/gal/cairo/cairo_gal.cpp @@ -49,29 +49,28 @@ using namespace KIGFX; CAIRO_GAL_BASE::CAIRO_GAL_BASE( GAL_DISPLAY_OPTIONS& aDisplayOptions ) : GAL( aDisplayOptions ) { // Initialise grouping - isGrouping = false; - isElementAdded = false; - groupCounter = 0; - currentGroup = nullptr; + m_isGrouping = false; + m_isElementAdded = false; + m_groupCounter = 0; + m_currentGroup = nullptr; - lineWidth = 1.0; - linePixelWidth = 1.0; - lineWidthInPixels = 1.0; - lineWidthIsOdd = true; + m_lineWidth = 1.0; + m_lineWidthInPixels = 1.0; + m_lineWidthIsOdd = true; // Initialise Cairo state - cairo_matrix_init_identity( &cairoWorldScreenMatrix ); - currentContext = nullptr; - context = nullptr; - surface = nullptr; + cairo_matrix_init_identity( &m_cairoWorldScreenMatrix ); + m_currentContext = nullptr; + m_context = nullptr; + m_surface = nullptr; // Grid color settings are different in Cairo and OpenGL SetGridColor( COLOR4D( 0.1, 0.1, 0.1, 0.8 ) ); SetAxesColor( COLOR4D( BLUE ) ); // Avoid unitialized variables: - cairo_matrix_init_identity( ¤tXform ); - cairo_matrix_init_identity( ¤tWorld2Screen ); + cairo_matrix_init_identity( &m_currentXform ); + cairo_matrix_init_identity( &m_currentWorld2Screen ); } @@ -79,13 +78,13 @@ CAIRO_GAL_BASE::~CAIRO_GAL_BASE() { ClearCache(); - if( surface ) - cairo_surface_destroy( surface ); + if( m_surface ) + cairo_surface_destroy( m_surface ); - if( context ) - cairo_destroy( context ); + if( m_context ) + cairo_destroy( m_context ); - for( auto imageSurface : imageSurfaces ) + for( _cairo_surface* imageSurface : m_imageSurfaces ) cairo_surface_destroy( imageSurface ); } @@ -105,7 +104,7 @@ void CAIRO_GAL_BASE::endDrawing() void CAIRO_GAL_BASE::updateWorldScreenMatrix() { - cairo_matrix_multiply( ¤tWorld2Screen, ¤tXform, &cairoWorldScreenMatrix ); + cairo_matrix_multiply( &m_currentWorld2Screen, &m_currentXform, &m_cairoWorldScreenMatrix ); } @@ -113,8 +112,8 @@ const VECTOR2D CAIRO_GAL_BASE::xform( double x, double y ) { VECTOR2D rv; - rv.x = currentWorld2Screen.xx * x + currentWorld2Screen.xy * y + currentWorld2Screen.x0; - rv.y = currentWorld2Screen.yx * x + currentWorld2Screen.yy * y + currentWorld2Screen.y0; + rv.x = m_currentWorld2Screen.xx * x + m_currentWorld2Screen.xy * y + m_currentWorld2Screen.x0; + rv.y = m_currentWorld2Screen.yx * x + m_currentWorld2Screen.yy * y + m_currentWorld2Screen.y0; return rv; } @@ -129,7 +128,7 @@ const double CAIRO_GAL_BASE::angle_xform( const double aAngle ) { // calculate rotation angle due to the rotation transform // and if flipped on X axis. - double world_rotation = -std::atan2( currentWorld2Screen.xy, currentWorld2Screen.xx ); + double world_rotation = -std::atan2( m_currentWorld2Screen.xy, m_currentWorld2Screen.xx ); // When flipped on X axis, the rotation angle is M_PI - initial angle: if( IsFlippedX() ) @@ -173,8 +172,8 @@ void CAIRO_GAL_BASE::arc_angles_xform_and_normalize( double& aStartAngle, double const double CAIRO_GAL_BASE::xform( double x ) { - double dx = currentWorld2Screen.xx * x; - double dy = currentWorld2Screen.yx * x; + double dx = m_currentWorld2Screen.xx * x; + double dy = m_currentWorld2Screen.yx * x; return sqrt( dx * dx + dy * dy ); } @@ -187,7 +186,7 @@ static double roundp( double x ) const VECTOR2D CAIRO_GAL_BASE::roundp( const VECTOR2D& v ) { - if( lineWidthIsOdd && isStrokeEnabled ) + if( m_lineWidthIsOdd && m_isStrokeEnabled ) return VECTOR2D( ::roundp( v.x ), ::roundp( v.y ) ); else return VECTOR2D( floor( v.x + 0.5 ), floor( v.y + 0.5 ) ); @@ -198,54 +197,55 @@ void CAIRO_GAL_BASE::DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEnd { syncLineWidth(); - auto p0 = roundp( xform( aStartPoint ) ); - auto p1 = roundp( xform( aEndPoint ) ); + VECTOR2D p0 = roundp( xform( aStartPoint ) ); + VECTOR2D p1 = roundp( xform( aEndPoint ) ); - cairo_move_to( currentContext, p0.x, p0.y ); - cairo_line_to( currentContext, p1.x, p1.y ); + cairo_move_to( m_currentContext, p0.x, p0.y ); + cairo_line_to( m_currentContext, p1.x, p1.y ); flushPath(); - isElementAdded = true; + m_isElementAdded = true; } void CAIRO_GAL_BASE::syncLineWidth( bool aForceWidth, double aWidth ) { - auto w = floor( xform( aForceWidth ? aWidth : lineWidth ) + 0.5 ); + double w = floor( xform( aForceWidth ? aWidth : m_lineWidth ) + 0.5 ); if( w <= 1.0 ) { w = 1.0; - cairo_set_line_join( currentContext, CAIRO_LINE_JOIN_MITER ); - cairo_set_line_cap( currentContext, CAIRO_LINE_CAP_BUTT ); - cairo_set_line_width( currentContext, 1.0 ); - lineWidthIsOdd = true; + cairo_set_line_join( m_currentContext, CAIRO_LINE_JOIN_MITER ); + cairo_set_line_cap( m_currentContext, CAIRO_LINE_CAP_BUTT ); + cairo_set_line_width( m_currentContext, 1.0 ); + m_lineWidthIsOdd = true; } else { - cairo_set_line_join( currentContext, CAIRO_LINE_JOIN_ROUND ); - cairo_set_line_cap( currentContext, CAIRO_LINE_CAP_ROUND ); - cairo_set_line_width( currentContext, w ); - lineWidthIsOdd = ( (int) w % 2 ) == 1; + cairo_set_line_join( m_currentContext, CAIRO_LINE_JOIN_ROUND ); + cairo_set_line_cap( m_currentContext, CAIRO_LINE_CAP_ROUND ); + cairo_set_line_width( m_currentContext, w ); + m_lineWidthIsOdd = ( (int) w % 2 ) == 1; } - lineWidthInPixels = w; + m_lineWidthInPixels = w; } void CAIRO_GAL_BASE::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint, double aWidth ) { - if( isFillEnabled ) + if( m_isFillEnabled ) { syncLineWidth( true, aWidth ); - auto p0 = roundp( xform( aStartPoint ) ); - auto p1 = roundp( xform( aEndPoint ) ); + VECTOR2D p0 = roundp( xform( aStartPoint ) ); + VECTOR2D p1 = roundp( xform( aEndPoint ) ); - cairo_move_to( currentContext, p0.x, p0.y ); - cairo_line_to( currentContext, p1.x, p1.y ); - cairo_set_source_rgba( currentContext, fillColor.r, fillColor.g, fillColor.b, fillColor.a ); - cairo_stroke( currentContext ); + cairo_move_to( m_currentContext, p0.x, p0.y ); + cairo_line_to( m_currentContext, p1.x, p1.y ); + cairo_set_source_rgba( m_currentContext, m_fillColor.r, m_fillColor.g, m_fillColor.b, + m_fillColor.a ); + cairo_stroke( m_currentContext ); } else { @@ -268,23 +268,23 @@ void CAIRO_GAL_BASE::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& a auto pb = xform( aEndPoint ); auto rb = ( pa0 - pa ).EuclideanNorm(); - cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, - strokeColor.a ); + cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, + m_strokeColor.a ); - cairo_move_to( currentContext, pa0.x, pa0.y ); - cairo_line_to( currentContext, pb0.x, pb0.y ); + cairo_move_to( m_currentContext, pa0.x, pa0.y ); + cairo_line_to( m_currentContext, pb0.x, pb0.y ); - cairo_move_to( currentContext, pa1.x, pa1.y ); - cairo_line_to( currentContext, pb1.x, pb1.y ); + cairo_move_to( m_currentContext, pa1.x, pa1.y ); + cairo_line_to( m_currentContext, pb1.x, pb1.y ); - cairo_arc( currentContext, pb.x, pb.y, rb, lineAngle - M_PI / 2.0, lineAngle + M_PI / 2.0 ); - cairo_arc( currentContext, pa.x, pa.y, rb, lineAngle + M_PI / 2.0, + cairo_arc( m_currentContext, pb.x, pb.y, rb, lineAngle - M_PI / 2.0, lineAngle + M_PI / 2.0 ); + cairo_arc( m_currentContext, pa.x, pa.y, rb, lineAngle + M_PI / 2.0, lineAngle + 3.0 * M_PI / 2.0 ); flushPath(); } - isElementAdded = true; + m_isElementAdded = true; } @@ -292,15 +292,15 @@ void CAIRO_GAL_BASE::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ) { syncLineWidth(); - auto c = roundp( xform( aCenterPoint ) ); - auto r = ::roundp( xform( aRadius ) ); + VECTOR2D c = roundp( xform( aCenterPoint ) ); + double r = ::roundp( xform( aRadius ) ); - cairo_set_line_width( currentContext, std::min( 2.0 * r, lineWidthInPixels ) ); - cairo_new_sub_path( currentContext ); - cairo_arc( currentContext, c.x, c.y, r, 0.0, 2 * M_PI ); - cairo_close_path( currentContext ); + cairo_set_line_width( m_currentContext, std::min( 2.0 * r, m_lineWidthInPixels ) ); + cairo_new_sub_path( m_currentContext ); + cairo_arc( m_currentContext, c.x, c.y, r, 0.0, 2 * M_PI ); + cairo_close_path( m_currentContext ); flushPath(); - isElementAdded = true; + m_isElementAdded = true; } @@ -319,38 +319,38 @@ void CAIRO_GAL_BASE::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, doub // point that changes both endpoints. In the worst case, this is twice as far. // We cannot adjust radius or center based on the other because this causes the // whole arc to change position/size - lineWidthIsOdd = !( static_cast( aRadius ) % 2 ); + m_lineWidthIsOdd = !( static_cast( aRadius ) % 2 ); auto mid = roundp( xform( aCenterPoint ) ); - cairo_set_line_width( currentContext, lineWidthInPixels ); - cairo_new_sub_path( currentContext ); + cairo_set_line_width( m_currentContext, m_lineWidthInPixels ); + cairo_new_sub_path( m_currentContext ); - if( isFillEnabled ) - cairo_move_to( currentContext, mid.x, mid.y ); + if( m_isFillEnabled ) + cairo_move_to( m_currentContext, mid.x, mid.y ); - cairo_arc( currentContext, mid.x, mid.y, r, aStartAngle, aEndAngle ); + cairo_arc( m_currentContext, mid.x, mid.y, r, aStartAngle, aEndAngle ); - if( isFillEnabled ) - cairo_close_path( currentContext ); + if( m_isFillEnabled ) + cairo_close_path( m_currentContext ); flushPath(); - isElementAdded = true; + m_isElementAdded = true; } void CAIRO_GAL_BASE::DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth ) { - if( isFillEnabled ) + if( m_isFillEnabled ) { - lineWidth = aWidth; - isStrokeEnabled = true; - isFillEnabled = false; + m_lineWidth = aWidth; + m_isStrokeEnabled = true; + m_isFillEnabled = false; DrawArc( aCenterPoint, aRadius, aStartAngle, aEndAngle ); - isFillEnabled = true; - isStrokeEnabled = false; + m_isFillEnabled = true; + m_isStrokeEnabled = false; return; } @@ -368,37 +368,37 @@ void CAIRO_GAL_BASE::DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadiu // point that changes both endpoints. In the worst case, this is twice as far. // We cannot adjust radius or center based on the other because this causes the // whole arc to change position/size - lineWidthIsOdd = !( static_cast( aRadius ) % 2 ); + m_lineWidthIsOdd = !( static_cast( aRadius ) % 2 ); - auto mid = roundp( xform( aCenterPoint ) ); - double width = xform( aWidth / 2.0 ); - auto startPointS = VECTOR2D( r, 0.0 ).Rotate( startAngleS ); - auto endPointS = VECTOR2D( r, 0.0 ).Rotate( endAngleS ); + VECTOR2D mid = roundp( xform( aCenterPoint ) ); + double width = xform( aWidth / 2.0 ); + VECTOR2D startPointS = VECTOR2D( r, 0.0 ).Rotate( startAngleS ); + VECTOR2D endPointS = VECTOR2D( r, 0.0 ).Rotate( endAngleS ); - cairo_save( currentContext ); + cairo_save( m_currentContext ); - cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, - strokeColor.a ); + cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, + m_strokeColor.a ); - cairo_translate( currentContext, mid.x, mid.y ); + cairo_translate( m_currentContext, mid.x, mid.y ); - cairo_new_sub_path( currentContext ); - cairo_arc( currentContext, 0, 0, r - width, startAngleS, endAngleS ); + cairo_new_sub_path( m_currentContext ); + cairo_arc( m_currentContext, 0, 0, r - width, startAngleS, endAngleS ); - cairo_new_sub_path( currentContext ); - cairo_arc( currentContext, 0, 0, r + width, startAngleS, endAngleS ); + cairo_new_sub_path( m_currentContext ); + cairo_arc( m_currentContext, 0, 0, r + width, startAngleS, endAngleS ); - cairo_new_sub_path( currentContext ); - cairo_arc_negative( currentContext, startPointS.x, startPointS.y, width, startAngleS, + cairo_new_sub_path( m_currentContext ); + cairo_arc_negative( m_currentContext, startPointS.x, startPointS.y, width, startAngleS, startAngleS + M_PI ); - cairo_new_sub_path( currentContext ); - cairo_arc( currentContext, endPointS.x, endPointS.y, width, endAngleS, endAngleS + M_PI ); + cairo_new_sub_path( m_currentContext ); + cairo_arc( m_currentContext, endPointS.x, endPointS.y, width, endAngleS, endAngleS + M_PI ); - cairo_restore( currentContext ); + cairo_restore( m_currentContext ); flushPath(); - isElementAdded = true; + m_isElementAdded = true; } @@ -407,20 +407,20 @@ void CAIRO_GAL_BASE::DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& // Calculate the diagonal points syncLineWidth(); - const auto p0 = roundp( xform( aStartPoint ) ); - const auto p1 = roundp( xform( VECTOR2D( aEndPoint.x, aStartPoint.y ) ) ); - const auto p2 = roundp( xform( aEndPoint ) ); - const auto p3 = roundp( xform( VECTOR2D( aStartPoint.x, aEndPoint.y ) ) ); + const VECTOR2D p0 = roundp( xform( aStartPoint ) ); + const VECTOR2D p1 = roundp( xform( VECTOR2D( aEndPoint.x, aStartPoint.y ) ) ); + const VECTOR2D p2 = roundp( xform( aEndPoint ) ); + const VECTOR2D p3 = roundp( xform( VECTOR2D( aStartPoint.x, aEndPoint.y ) ) ); // The path is composed from 4 segments - cairo_move_to( currentContext, p0.x, p0.y ); - cairo_line_to( currentContext, p1.x, p1.y ); - cairo_line_to( currentContext, p2.x, p2.y ); - cairo_line_to( currentContext, p3.x, p3.y ); - cairo_close_path( currentContext ); + cairo_move_to( m_currentContext, p0.x, p0.y ); + cairo_line_to( m_currentContext, p1.x, p1.y ); + cairo_line_to( m_currentContext, p2.x, p2.y ); + cairo_line_to( m_currentContext, p3.x, p3.y ); + cairo_close_path( m_currentContext ); flushPath(); - isElementAdded = true; + m_isElementAdded = true; } @@ -445,38 +445,38 @@ void CAIRO_GAL_BASE::DrawCurve( const VECTOR2D& aStartPoint, const VECTOR2D& aCo // supported by Cairo. syncLineWidth(); - const auto sp = roundp( xform( aStartPoint ) ); - const auto cpa = roundp( xform( aControlPointA ) ); - const auto cpb = roundp( xform( aControlPointB ) ); - const auto ep = roundp( xform( aEndPoint ) ); + const VECTOR2D sp = roundp( xform( aStartPoint ) ); + const VECTOR2D cpa = roundp( xform( aControlPointA ) ); + const VECTOR2D cpb = roundp( xform( aControlPointB ) ); + const VECTOR2D ep = roundp( xform( aEndPoint ) ); - cairo_move_to( currentContext, sp.x, sp.y ); - cairo_curve_to( currentContext, cpa.x, cpa.y, cpb.x, cpb.y, ep.x, ep.y ); - cairo_line_to( currentContext, ep.x, ep.y ); + cairo_move_to( m_currentContext, sp.x, sp.y ); + cairo_curve_to( m_currentContext, cpa.x, cpa.y, cpb.x, cpb.y, ep.x, ep.y ); + cairo_line_to( m_currentContext, ep.x, ep.y ); flushPath(); - isElementAdded = true; + m_isElementAdded = true; } void CAIRO_GAL_BASE::DrawBitmap( const BITMAP_BASE& aBitmap ) { - cairo_save( currentContext ); + cairo_save( m_currentContext ); // We have to calculate the pixel size in users units to draw the image. - // worldUnitLength is a factor used for converting IU to inches - double scale = 1.0 / ( aBitmap.GetPPI() * worldUnitLength ); + // m_worldUnitLength is a factor used for converting IU to inches + double scale = 1.0 / ( aBitmap.GetPPI() * m_worldUnitLength ); // The position of the bitmap is the bitmap center. // move the draw origin to the top left bitmap corner: int w = aBitmap.GetSizePixels().x; int h = aBitmap.GetSizePixels().y; - cairo_set_matrix( currentContext, ¤tWorld2Screen ); - cairo_scale( currentContext, scale, scale ); - cairo_translate( currentContext, -w / 2.0, -h / 2.0 ); + cairo_set_matrix( m_currentContext, &m_currentWorld2Screen ); + cairo_scale( m_currentContext, scale, scale ); + cairo_translate( m_currentContext, -w / 2.0, -h / 2.0 ); - cairo_new_path( currentContext ); + cairo_new_path( m_currentContext ); cairo_surface_t* image = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, w, h ); cairo_surface_flush( image ); @@ -515,21 +515,21 @@ void CAIRO_GAL_BASE::DrawBitmap( const BITMAP_BASE& aBitmap ) } cairo_surface_mark_dirty( image ); - cairo_set_source_surface( currentContext, image, 0, 0 ); - cairo_paint( currentContext ); + cairo_set_source_surface( m_currentContext, image, 0, 0 ); + cairo_paint( m_currentContext ); // store the image handle so it can be destroyed later - imageSurfaces.push_back( image ); + m_imageSurfaces.push_back( image ); - isElementAdded = true; + m_isElementAdded = true; - cairo_restore( currentContext ); + cairo_restore( m_currentContext ); } void CAIRO_GAL_BASE::ResizeScreen( int aWidth, int aHeight ) { - screenSize = VECTOR2I( aWidth, aHeight ); + m_screenSize = VECTOR2I( aWidth, aHeight ); } @@ -541,23 +541,23 @@ void CAIRO_GAL_BASE::Flush() void CAIRO_GAL_BASE::ClearScreen() { - cairo_set_source_rgb( currentContext, m_clearColor.r, m_clearColor.g, m_clearColor.b ); - cairo_rectangle( currentContext, 0.0, 0.0, screenSize.x, screenSize.y ); - cairo_fill( currentContext ); + cairo_set_source_rgb( m_currentContext, m_clearColor.r, m_clearColor.g, m_clearColor.b ); + cairo_rectangle( m_currentContext, 0.0, 0.0, m_screenSize.x, m_screenSize.y ); + cairo_fill( m_currentContext ); } void CAIRO_GAL_BASE::SetIsFill( bool aIsFillEnabled ) { storePath(); - isFillEnabled = aIsFillEnabled; + m_isFillEnabled = aIsFillEnabled; - if( isGrouping ) + if( m_isGrouping ) { GROUP_ELEMENT groupElement; - groupElement.command = CMD_SET_FILL; - groupElement.argument.boolArg = aIsFillEnabled; - currentGroup->push_back( groupElement ); + groupElement.m_Command = CMD_SET_FILL; + groupElement.m_Argument.BoolArg = aIsFillEnabled; + m_currentGroup->push_back( groupElement ); } } @@ -565,14 +565,14 @@ void CAIRO_GAL_BASE::SetIsFill( bool aIsFillEnabled ) void CAIRO_GAL_BASE::SetIsStroke( bool aIsStrokeEnabled ) { storePath(); - isStrokeEnabled = aIsStrokeEnabled; + m_isStrokeEnabled = aIsStrokeEnabled; - if( isGrouping ) + if( m_isGrouping ) { GROUP_ELEMENT groupElement; - groupElement.command = CMD_SET_STROKE; - groupElement.argument.boolArg = aIsStrokeEnabled; - currentGroup->push_back( groupElement ); + groupElement.m_Command = CMD_SET_STROKE; + groupElement.m_Argument.BoolArg = aIsStrokeEnabled; + m_currentGroup->push_back( groupElement ); } } @@ -580,17 +580,17 @@ void CAIRO_GAL_BASE::SetIsStroke( bool aIsStrokeEnabled ) void CAIRO_GAL_BASE::SetStrokeColor( const COLOR4D& aColor ) { storePath(); - strokeColor = aColor; + m_strokeColor = aColor; - if( isGrouping ) + if( m_isGrouping ) { GROUP_ELEMENT groupElement; - groupElement.command = CMD_SET_STROKECOLOR; - groupElement.argument.dblArg[0] = strokeColor.r; - groupElement.argument.dblArg[1] = strokeColor.g; - groupElement.argument.dblArg[2] = strokeColor.b; - groupElement.argument.dblArg[3] = strokeColor.a; - currentGroup->push_back( groupElement ); + groupElement.m_Command = CMD_SET_STROKECOLOR; + groupElement.m_Argument.DblArg[0] = m_strokeColor.r; + groupElement.m_Argument.DblArg[1] = m_strokeColor.g; + groupElement.m_Argument.DblArg[2] = m_strokeColor.b; + groupElement.m_Argument.DblArg[3] = m_strokeColor.a; + m_currentGroup->push_back( groupElement ); } } @@ -598,17 +598,17 @@ void CAIRO_GAL_BASE::SetStrokeColor( const COLOR4D& aColor ) void CAIRO_GAL_BASE::SetFillColor( const COLOR4D& aColor ) { storePath(); - fillColor = aColor; + m_fillColor = aColor; - if( isGrouping ) + if( m_isGrouping ) { GROUP_ELEMENT groupElement; - groupElement.command = CMD_SET_FILLCOLOR; - groupElement.argument.dblArg[0] = fillColor.r; - groupElement.argument.dblArg[1] = fillColor.g; - groupElement.argument.dblArg[2] = fillColor.b; - groupElement.argument.dblArg[3] = fillColor.a; - currentGroup->push_back( groupElement ); + groupElement.m_Command = CMD_SET_FILLCOLOR; + groupElement.m_Argument.DblArg[0] = m_fillColor.r; + groupElement.m_Argument.DblArg[1] = m_fillColor.g; + groupElement.m_Argument.DblArg[2] = m_fillColor.b; + groupElement.m_Argument.DblArg[3] = m_fillColor.a; + m_currentGroup->push_back( groupElement ); } } @@ -618,16 +618,16 @@ void CAIRO_GAL_BASE::SetLineWidth( float aLineWidth ) storePath(); GAL::SetLineWidth( aLineWidth ); - if( isGrouping ) + if( m_isGrouping ) { GROUP_ELEMENT groupElement; - groupElement.command = CMD_SET_LINE_WIDTH; - groupElement.argument.dblArg[0] = aLineWidth; - currentGroup->push_back( groupElement ); + groupElement.m_Command = CMD_SET_LINE_WIDTH; + groupElement.m_Argument.DblArg[0] = aLineWidth; + m_currentGroup->push_back( groupElement ); } else { - lineWidth = aLineWidth; + m_lineWidth = aLineWidth; } } @@ -648,8 +648,8 @@ void CAIRO_GAL_BASE::Transform( const MATRIX3x3D& aTransformation ) aTransformation.m_data[1][1], aTransformation.m_data[0][2], aTransformation.m_data[1][2] ); - cairo_matrix_multiply( &newXform, ¤tXform, &cairoTransformation ); - currentXform = newXform; + cairo_matrix_multiply( &newXform, &m_currentXform, &cairoTransformation ); + m_currentXform = newXform; updateWorldScreenMatrix(); } @@ -658,16 +658,16 @@ void CAIRO_GAL_BASE::Rotate( double aAngle ) { storePath(); - if( isGrouping ) + if( m_isGrouping ) { GROUP_ELEMENT groupElement; - groupElement.command = CMD_ROTATE; - groupElement.argument.dblArg[0] = aAngle; - currentGroup->push_back( groupElement ); + groupElement.m_Command = CMD_ROTATE; + groupElement.m_Argument.DblArg[0] = aAngle; + m_currentGroup->push_back( groupElement ); } else { - cairo_matrix_rotate( ¤tXform, aAngle ); + cairo_matrix_rotate( &m_currentXform, aAngle ); updateWorldScreenMatrix(); } } @@ -677,17 +677,17 @@ void CAIRO_GAL_BASE::Translate( const VECTOR2D& aTranslation ) { storePath(); - if( isGrouping ) + if( m_isGrouping ) { GROUP_ELEMENT groupElement; - groupElement.command = CMD_TRANSLATE; - groupElement.argument.dblArg[0] = aTranslation.x; - groupElement.argument.dblArg[1] = aTranslation.y; - currentGroup->push_back( groupElement ); + groupElement.m_Command = CMD_TRANSLATE; + groupElement.m_Argument.DblArg[0] = aTranslation.x; + groupElement.m_Argument.DblArg[1] = aTranslation.y; + m_currentGroup->push_back( groupElement ); } else { - cairo_matrix_translate( ¤tXform, aTranslation.x, aTranslation.y ); + cairo_matrix_translate( &m_currentXform, aTranslation.x, aTranslation.y ); updateWorldScreenMatrix(); } } @@ -697,17 +697,17 @@ void CAIRO_GAL_BASE::Scale( const VECTOR2D& aScale ) { storePath(); - if( isGrouping ) + if( m_isGrouping ) { GROUP_ELEMENT groupElement; - groupElement.command = CMD_SCALE; - groupElement.argument.dblArg[0] = aScale.x; - groupElement.argument.dblArg[1] = aScale.y; - currentGroup->push_back( groupElement ); + groupElement.m_Command = CMD_SCALE; + groupElement.m_Argument.DblArg[0] = aScale.x; + groupElement.m_Argument.DblArg[1] = aScale.y; + m_currentGroup->push_back( groupElement ); } else { - cairo_matrix_scale( ¤tXform, aScale.x, aScale.y ); + cairo_matrix_scale( &m_currentXform, aScale.x, aScale.y ); updateWorldScreenMatrix(); } } @@ -717,15 +717,15 @@ void CAIRO_GAL_BASE::Save() { storePath(); - if( isGrouping ) + if( m_isGrouping ) { GROUP_ELEMENT groupElement; - groupElement.command = CMD_SAVE; - currentGroup->push_back( groupElement ); + groupElement.m_Command = CMD_SAVE; + m_currentGroup->push_back( groupElement ); } else { - xformStack.push_back( currentXform ); + m_xformStack.push_back( m_currentXform ); updateWorldScreenMatrix(); } } @@ -735,18 +735,18 @@ void CAIRO_GAL_BASE::Restore() { storePath(); - if( isGrouping ) + if( m_isGrouping ) { GROUP_ELEMENT groupElement; - groupElement.command = CMD_RESTORE; - currentGroup->push_back( groupElement ); + groupElement.m_Command = CMD_RESTORE; + m_currentGroup->push_back( groupElement ); } else { - if( !xformStack.empty() ) + if( !m_xformStack.empty() ) { - currentXform = xformStack.back(); - xformStack.pop_back(); + m_currentXform = m_xformStack.back(); + m_xformStack.pop_back(); updateWorldScreenMatrix(); } } @@ -761,9 +761,9 @@ int CAIRO_GAL_BASE::BeginGroup() GROUP group; int groupNumber = getNewGroupNumber(); - groups.insert( std::make_pair( groupNumber, group ) ); - currentGroup = &groups[groupNumber]; - isGrouping = true; + m_groups.insert( std::make_pair( groupNumber, group ) ); + m_currentGroup = &m_groups[groupNumber]; + m_isGrouping = true; return groupNumber; } @@ -772,7 +772,7 @@ int CAIRO_GAL_BASE::BeginGroup() void CAIRO_GAL_BASE::EndGroup() { storePath(); - isGrouping = false; + m_isGrouping = false; } @@ -783,84 +783,85 @@ void CAIRO_GAL_BASE::DrawGroup( int aGroupNumber ) storePath(); - for( GROUP::iterator it = groups[aGroupNumber].begin(); it != groups[aGroupNumber].end(); ++it ) + for( auto it = m_groups[aGroupNumber].begin(); it != m_groups[aGroupNumber].end(); ++it ) { - switch( it->command ) + switch( it->m_Command ) { case CMD_SET_FILL: - isFillEnabled = it->argument.boolArg; + m_isFillEnabled = it->m_Argument.BoolArg; break; case CMD_SET_STROKE: - isStrokeEnabled = it->argument.boolArg; + m_isStrokeEnabled = it->m_Argument.BoolArg; break; case CMD_SET_FILLCOLOR: - fillColor = COLOR4D( it->argument.dblArg[0], it->argument.dblArg[1], - it->argument.dblArg[2], it->argument.dblArg[3] ); + m_fillColor = COLOR4D( it->m_Argument.DblArg[0], it->m_Argument.DblArg[1], + it->m_Argument.DblArg[2], it->m_Argument.DblArg[3] ); break; case CMD_SET_STROKECOLOR: - strokeColor = COLOR4D( it->argument.dblArg[0], it->argument.dblArg[1], - it->argument.dblArg[2], it->argument.dblArg[3] ); + m_strokeColor = COLOR4D( it->m_Argument.DblArg[0], it->m_Argument.DblArg[1], + it->m_Argument.DblArg[2], it->m_Argument.DblArg[3] ); break; case CMD_SET_LINE_WIDTH: { // Make lines appear at least 1 pixel wide, no matter of zoom double x = 1.0, y = 1.0; - cairo_device_to_user_distance( currentContext, &x, &y ); + cairo_device_to_user_distance( m_currentContext, &x, &y ); double minWidth = std::min( fabs( x ), fabs( y ) ); - cairo_set_line_width( currentContext, std::max( it->argument.dblArg[0], minWidth ) ); + cairo_set_line_width( m_currentContext, std::max( it->m_Argument.DblArg[0], minWidth ) ); break; } case CMD_STROKE_PATH: - cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, - strokeColor.a ); - cairo_append_path( currentContext, it->cairoPath ); - cairo_stroke( currentContext ); + cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g, + m_strokeColor.b, m_strokeColor.a ); + cairo_append_path( m_currentContext, it->m_CairoPath ); + cairo_stroke( m_currentContext ); break; case CMD_FILL_PATH: - cairo_set_source_rgba( currentContext, fillColor.r, fillColor.g, fillColor.b, - strokeColor.a ); - cairo_append_path( currentContext, it->cairoPath ); - cairo_fill( currentContext ); + cairo_set_source_rgba( m_currentContext, m_fillColor.r, m_fillColor.g, m_fillColor.b, + m_strokeColor.a ); + cairo_append_path( m_currentContext, it->m_CairoPath ); + cairo_fill( m_currentContext ); break; /* case CMD_TRANSFORM: cairo_matrix_t matrix; - cairo_matrix_init( &matrix, it->argument.dblArg[0], it->argument.dblArg[1], it->argument.dblArg[2], - it->argument.dblArg[3], it->argument.dblArg[4], it->argument.dblArg[5] ); - cairo_transform( currentContext, &matrix ); + cairo_matrix_init( &matrix, it->argument.DblArg[0], it->argument.DblArg[1], + it->argument.DblArg[2], it->argument.DblArg[3], + it->argument.DblArg[4], it->argument.DblArg[5] ); + cairo_transform( m_currentContext, &matrix ); break; */ case CMD_ROTATE: - cairo_rotate( currentContext, it->argument.dblArg[0] ); + cairo_rotate( m_currentContext, it->m_Argument.DblArg[0] ); break; case CMD_TRANSLATE: - cairo_translate( currentContext, it->argument.dblArg[0], it->argument.dblArg[1] ); + cairo_translate( m_currentContext, it->m_Argument.DblArg[0], it->m_Argument.DblArg[1] ); break; case CMD_SCALE: - cairo_scale( currentContext, it->argument.dblArg[0], it->argument.dblArg[1] ); + cairo_scale( m_currentContext, it->m_Argument.DblArg[0], it->m_Argument.DblArg[1] ); break; case CMD_SAVE: - cairo_save( currentContext ); + cairo_save( m_currentContext ); break; case CMD_RESTORE: - cairo_restore( currentContext ); + cairo_restore( m_currentContext ); break; case CMD_CALL_GROUP: - DrawGroup( it->argument.intArg ); + DrawGroup( it->m_Argument.IntArg ); break; } } @@ -871,14 +872,14 @@ void CAIRO_GAL_BASE::ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColo { storePath(); - for( GROUP::iterator it = groups[aGroupNumber].begin(); it != groups[aGroupNumber].end(); ++it ) + for( auto it = m_groups[aGroupNumber].begin(); it != m_groups[aGroupNumber].end(); ++it ) { - if( it->command == CMD_SET_FILLCOLOR || it->command == CMD_SET_STROKECOLOR ) + if( it->m_Command == CMD_SET_FILLCOLOR || it->m_Command == CMD_SET_STROKECOLOR ) { - it->argument.dblArg[0] = aNewColor.r; - it->argument.dblArg[1] = aNewColor.g; - it->argument.dblArg[2] = aNewColor.b; - it->argument.dblArg[3] = aNewColor.a; + it->m_Argument.DblArg[0] = aNewColor.r; + it->m_Argument.DblArg[1] = aNewColor.g; + it->m_Argument.DblArg[2] = aNewColor.b; + it->m_Argument.DblArg[3] = aNewColor.a; } } } @@ -898,35 +899,33 @@ void CAIRO_GAL_BASE::DeleteGroup( int aGroupNumber ) // Delete the Cairo paths std::deque::iterator it, end; - for( it = groups[aGroupNumber].begin(), end = groups[aGroupNumber].end(); it != end; ++it ) + for( it = m_groups[aGroupNumber].begin(), end = m_groups[aGroupNumber].end(); it != end; ++it ) { - if( it->command == CMD_FILL_PATH || it->command == CMD_STROKE_PATH ) - { - cairo_path_destroy( it->cairoPath ); - } + if( it->m_Command == CMD_FILL_PATH || it->m_Command == CMD_STROKE_PATH ) + cairo_path_destroy( it->m_CairoPath ); } // Delete the group - groups.erase( aGroupNumber ); + m_groups.erase( aGroupNumber ); } void CAIRO_GAL_BASE::ClearCache() { - for( auto it = groups.begin(); it != groups.end(); ) + for( auto it = m_groups.begin(); it != m_groups.end(); ) DeleteGroup( ( it++ )->first ); } void CAIRO_GAL_BASE::SetNegativeDrawMode( bool aSetting ) { - cairo_set_operator( currentContext, aSetting ? CAIRO_OPERATOR_CLEAR : CAIRO_OPERATOR_OVER ); + cairo_set_operator( m_currentContext, aSetting ? CAIRO_OPERATOR_CLEAR : CAIRO_OPERATOR_OVER ); } void CAIRO_GAL_BASE::DrawCursor( const VECTOR2D& aCursorPosition ) { - cursorPosition = aCursorPosition; + m_cursorPosition = aCursorPosition; } @@ -937,33 +936,33 @@ void CAIRO_GAL_BASE::EnableDepthTest( bool aEnabled ) void CAIRO_GAL_BASE::resetContext() { - for( auto imageSurface : imageSurfaces ) + for( _cairo_surface* imageSurface : m_imageSurfaces ) cairo_surface_destroy( imageSurface ); - imageSurfaces.clear(); + m_imageSurfaces.clear(); ClearScreen(); // Compute the world <-> screen transformations ComputeWorldScreenMatrix(); - cairo_matrix_init( &cairoWorldScreenMatrix, worldScreenMatrix.m_data[0][0], - worldScreenMatrix.m_data[1][0], worldScreenMatrix.m_data[0][1], - worldScreenMatrix.m_data[1][1], worldScreenMatrix.m_data[0][2], - worldScreenMatrix.m_data[1][2] ); + cairo_matrix_init( &m_cairoWorldScreenMatrix, m_worldScreenMatrix.m_data[0][0], + m_worldScreenMatrix.m_data[1][0], m_worldScreenMatrix.m_data[0][1], + m_worldScreenMatrix.m_data[1][1], m_worldScreenMatrix.m_data[0][2], + m_worldScreenMatrix.m_data[1][2] ); // we work in screen-space coordinates and do the transforms outside. - cairo_identity_matrix( context ); + cairo_identity_matrix( m_context ); - cairo_matrix_init_identity( ¤tXform ); + cairo_matrix_init_identity( &m_currentXform ); // Start drawing with a new path - cairo_new_path( context ); - isElementAdded = true; + cairo_new_path( m_context ); + m_isElementAdded = true; updateWorldScreenMatrix(); - lineWidth = 0; + m_lineWidth = 0; } @@ -971,29 +970,31 @@ void CAIRO_GAL_BASE::drawAxes( const VECTOR2D& aStartPoint, const VECTOR2D& aEnd { syncLineWidth(); - auto p0 = roundp( xform( aStartPoint ) ); - auto p1 = roundp( xform( aEndPoint ) ); - auto org = roundp( xform( VECTOR2D( 0.0, 0.0 ) ) ); // Axis origin = 0,0 coord + VECTOR2D p0 = roundp( xform( aStartPoint ) ); + VECTOR2D p1 = roundp( xform( aEndPoint ) ); + VECTOR2D org = roundp( xform( VECTOR2D( 0.0, 0.0 ) ) ); // Axis origin = 0,0 coord - cairo_set_source_rgba( currentContext, axesColor.r, axesColor.g, axesColor.b, axesColor.a ); - cairo_move_to( currentContext, p0.x, org.y ); - cairo_line_to( currentContext, p1.x, org.y ); - cairo_move_to( currentContext, org.x, p0.y ); - cairo_line_to( currentContext, org.x, p1.y ); - cairo_stroke( currentContext ); + cairo_set_source_rgba( m_currentContext, m_axesColor.r, m_axesColor.g, m_axesColor.b, + m_axesColor.a ); + cairo_move_to( m_currentContext, p0.x, org.y ); + cairo_line_to( m_currentContext, p1.x, org.y ); + cairo_move_to( m_currentContext, org.x, p0.y ); + cairo_line_to( m_currentContext, org.x, p1.y ); + cairo_stroke( m_currentContext ); } void CAIRO_GAL_BASE::drawGridLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) { syncLineWidth(); - auto p0 = roundp( xform( aStartPoint ) ); - auto p1 = roundp( xform( aEndPoint ) ); + VECTOR2D p0 = roundp( xform( aStartPoint ) ); + VECTOR2D p1 = roundp( xform( aEndPoint ) ); - cairo_set_source_rgba( currentContext, gridColor.r, gridColor.g, gridColor.b, gridColor.a ); - cairo_move_to( currentContext, p0.x, p0.y ); - cairo_line_to( currentContext, p1.x, p1.y ); - cairo_stroke( currentContext ); + cairo_set_source_rgba( m_currentContext, m_gridColor.r, m_gridColor.g, m_gridColor.b, + m_gridColor.a ); + cairo_move_to( m_currentContext, p0.x, p0.y ); + cairo_line_to( m_currentContext, p1.x, p1.y ); + cairo_stroke( m_currentContext ); } @@ -1001,19 +1002,20 @@ void CAIRO_GAL_BASE::drawGridCross( const VECTOR2D& aPoint ) { syncLineWidth(); VECTOR2D offset( 0, 0 ); - double size = 2.0 * lineWidthInPixels + 0.5; + double size = 2.0 * m_lineWidthInPixels + 0.5; VECTOR2D p0 = roundp( xform( aPoint ) ) - VECTOR2D( size, 0 ) + offset; VECTOR2D p1 = roundp( xform( aPoint ) ) + VECTOR2D( size, 0 ) + offset; VECTOR2D p2 = roundp( xform( aPoint ) ) - VECTOR2D( 0, size ) + offset; VECTOR2D p3 = roundp( xform( aPoint ) ) + VECTOR2D( 0, size ) + offset; - cairo_set_source_rgba( currentContext, gridColor.r, gridColor.g, gridColor.b, gridColor.a ); - cairo_move_to( currentContext, p0.x, p0.y ); - cairo_line_to( currentContext, p1.x, p1.y ); - cairo_move_to( currentContext, p2.x, p2.y ); - cairo_line_to( currentContext, p3.x, p3.y ); - cairo_stroke( currentContext ); + cairo_set_source_rgba( m_currentContext, m_gridColor.r, m_gridColor.g, m_gridColor.b, + m_gridColor.a ); + cairo_move_to( m_currentContext, p0.x, p0.y ); + cairo_line_to( m_currentContext, p1.x, p1.y ); + cairo_move_to( m_currentContext, p2.x, p2.y ); + cairo_line_to( m_currentContext, p3.x, p3.y ); + cairo_stroke( m_currentContext ); } @@ -1024,55 +1026,57 @@ void CAIRO_GAL_BASE::drawGridPoint( const VECTOR2D& aPoint, double aWidth, doubl double sw = std::max( 1.0, aWidth ); double sh = std::max( 1.0, aHeight ); - cairo_set_source_rgba( currentContext, gridColor.r, gridColor.g, gridColor.b, gridColor.a ); - cairo_rectangle( currentContext, p.x - std::floor( sw / 2 ) - 0.5, + cairo_set_source_rgba( m_currentContext, m_gridColor.r, m_gridColor.g, m_gridColor.b, + m_gridColor.a ); + cairo_rectangle( m_currentContext, p.x - std::floor( sw / 2 ) - 0.5, p.y - std::floor( sh / 2 ) - 0.5, sw, sh ); - cairo_fill( currentContext ); + cairo_fill( m_currentContext ); } void CAIRO_GAL_BASE::flushPath() { - if( isFillEnabled ) + if( m_isFillEnabled ) { - cairo_set_source_rgba( currentContext, fillColor.r, fillColor.g, fillColor.b, fillColor.a ); + cairo_set_source_rgba( m_currentContext, m_fillColor.r, m_fillColor.g, m_fillColor.b, + m_fillColor.a ); - if( isStrokeEnabled ) - cairo_fill_preserve( currentContext ); + if( m_isStrokeEnabled ) + cairo_fill_preserve( m_currentContext ); else - cairo_fill( currentContext ); + cairo_fill( m_currentContext ); } - if( isStrokeEnabled ) + if( m_isStrokeEnabled ) { - cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, - strokeColor.a ); - cairo_stroke( currentContext ); + cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, + m_strokeColor.a ); + cairo_stroke( m_currentContext ); } } void CAIRO_GAL_BASE::storePath() { - if( isElementAdded ) + if( m_isElementAdded ) { - isElementAdded = false; + m_isElementAdded = false; - if( !isGrouping ) + if( !m_isGrouping ) { - if( isFillEnabled ) + if( m_isFillEnabled ) { - cairo_set_source_rgba( currentContext, fillColor.r, fillColor.g, fillColor.b, - fillColor.a ); - cairo_fill_preserve( currentContext ); + cairo_set_source_rgba( m_currentContext, m_fillColor.r, m_fillColor.g, m_fillColor.b, + m_fillColor.a ); + cairo_fill_preserve( m_currentContext ); } - if( isStrokeEnabled ) + if( m_isStrokeEnabled ) { - cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, - strokeColor.a ); - cairo_stroke_preserve( currentContext ); + cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g, + m_strokeColor.b, m_strokeColor.a ); + cairo_stroke_preserve( m_currentContext ); } } else @@ -1080,24 +1084,24 @@ void CAIRO_GAL_BASE::storePath() // Copy the actual path, append it to the global path list // then check, if the path needs to be stroked/filled and // add this command to the group list; - if( isStrokeEnabled ) + if( m_isStrokeEnabled ) { GROUP_ELEMENT groupElement; - groupElement.cairoPath = cairo_copy_path( currentContext ); - groupElement.command = CMD_STROKE_PATH; - currentGroup->push_back( groupElement ); + groupElement.m_CairoPath = cairo_copy_path( m_currentContext ); + groupElement.m_Command = CMD_STROKE_PATH; + m_currentGroup->push_back( groupElement ); } - if( isFillEnabled ) + if( m_isFillEnabled ) { GROUP_ELEMENT groupElement; - groupElement.cairoPath = cairo_copy_path( currentContext ); - groupElement.command = CMD_FILL_PATH; - currentGroup->push_back( groupElement ); + groupElement.m_CairoPath = cairo_copy_path( m_currentContext ); + groupElement.m_Command = CMD_FILL_PATH; + m_currentGroup->push_back( groupElement ); } } - cairo_new_path( currentContext ); + cairo_new_path( m_currentContext ); } } @@ -1107,10 +1111,9 @@ void CAIRO_GAL_BASE::blitCursor( wxMemoryDC& clientDC ) if( !IsCursorEnabled() ) return; - auto p = ToScreen( cursorPosition ); - - const auto cColor = getCursorColor(); - const int cursorSize = fullscreenCursor ? 8000 : 80; + VECTOR2D p = ToScreen( m_cursorPosition ); + const COLOR4D cColor = getCursorColor(); + const int cursorSize = m_fullscreenCursor ? 8000 : 80; wxColour color( cColor.r * cColor.a * 255, cColor.g * cColor.a * 255, cColor.b * cColor.a * 255, 255 ); @@ -1129,19 +1132,19 @@ void CAIRO_GAL_BASE::drawPoly( const std::deque& aPointList ) syncLineWidth(); - const auto p = roundp( xform( it->x, it->y ) ); + const VECTOR2D p = roundp( xform( it->x, it->y ) ); - cairo_move_to( currentContext, p.x, p.y ); + cairo_move_to( m_currentContext, p.x, p.y ); for( ++it; it != aPointList.end(); ++it ) { - const auto p2 = roundp( xform( it->x, it->y ) ); + const VECTOR2D p2 = roundp( xform( it->x, it->y ) ); - cairo_line_to( currentContext, p2.x, p2.y ); + cairo_line_to( m_currentContext, p2.x, p2.y ); } flushPath(); - isElementAdded = true; + m_isElementAdded = true; } @@ -1154,18 +1157,18 @@ void CAIRO_GAL_BASE::drawPoly( const VECTOR2D aPointList[], int aListSize ) syncLineWidth(); - const auto p = roundp( xform( ptr->x, ptr->y ) ); - cairo_move_to( currentContext, p.x, p.y ); + const VECTOR2D p = roundp( xform( ptr->x, ptr->y ) ); + cairo_move_to( m_currentContext, p.x, p.y ); for( int i = 1; i < aListSize; ++i ) { ++ptr; - const auto p2 = roundp( xform( ptr->x, ptr->y ) ); - cairo_line_to( currentContext, p2.x, p2.y ); + const VECTOR2D p2 = roundp( xform( ptr->x, ptr->y ) ); + cairo_line_to( m_currentContext, p2.x, p2.y ); } flushPath(); - isElementAdded = true; + m_isElementAdded = true; } @@ -1181,30 +1184,30 @@ void CAIRO_GAL_BASE::drawPoly( const SHAPE_LINE_CHAIN& aLineChain ) numPoints += 1; const VECTOR2I start = aLineChain.CPoint( 0 ); - const auto p = roundp( xform( start.x, start.y ) ); - cairo_move_to( currentContext, p.x, p.y ); + const VECTOR2D p = roundp( xform( start.x, start.y ) ); + cairo_move_to( m_currentContext, p.x, p.y ); for( int i = 1; i < numPoints; ++i ) { const VECTOR2I& pw = aLineChain.CPoint( i ); - const auto ps = roundp( xform( pw.x, pw.y ) ); - cairo_line_to( currentContext, ps.x, ps.y ); + const VECTOR2D ps = roundp( xform( pw.x, pw.y ) ); + cairo_line_to( m_currentContext, ps.x, ps.y ); } flushPath(); - isElementAdded = true; + m_isElementAdded = true; } unsigned int CAIRO_GAL_BASE::getNewGroupNumber() { - wxASSERT_MSG( groups.size() < std::numeric_limits::max(), + wxASSERT_MSG( m_groups.size() < std::numeric_limits::max(), wxT( "There are no free slots to store a group" ) ); - while( groups.find( groupCounter ) != groups.end() ) - groupCounter++; + while( m_groups.find( m_groupCounter ) != m_groups.end() ) + m_groupCounter++; - return groupCounter++; + return m_groupCounter++; } @@ -1215,17 +1218,17 @@ CAIRO_GAL::CAIRO_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent, wxWindow( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxEXPAND, aName ) { // Initialise compositing state - mainBuffer = 0; - overlayBuffer = 0; - validCompositor = false; + m_mainBuffer = 0; + m_overlayBuffer = 0; + m_validCompositor = false; SetTarget( TARGET_NONCACHED ); - bitmapBuffer = nullptr; - wxOutput = nullptr; + m_bitmapBuffer = nullptr; + m_wxOutput = nullptr; - parentWindow = aParent; - mouseListener = aMouseListener; - paintListener = aPaintListener; + m_parentWindow = aParent; + m_mouseListener = aMouseListener; + m_paintListener = aPaintListener; // Connecting the event handlers Connect( wxEVT_PAINT, wxPaintEventHandler( CAIRO_GAL::onPaint ) ); @@ -1247,12 +1250,12 @@ CAIRO_GAL::CAIRO_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent, #endif SetSize( aParent->GetClientSize() ); - screenSize = VECTOR2I( aParent->GetClientSize() ); + m_screenSize = VECTOR2I( aParent->GetClientSize() ); // Allocate memory for pixel storage allocateBitmaps(); - isInitialized = false; + m_isInitialized = false; } @@ -1268,11 +1271,11 @@ void CAIRO_GAL::beginDrawing() CAIRO_GAL_BASE::beginDrawing(); - if( !validCompositor ) + if( !m_validCompositor ) setCompositor(); - compositor->SetMainContext( context ); - compositor->SetBuffer( mainBuffer ); + m_compositor->SetMainContext( m_context ); + m_compositor->SetBuffer( m_mainBuffer ); } @@ -1281,8 +1284,8 @@ void CAIRO_GAL::endDrawing() CAIRO_GAL_BASE::endDrawing(); // Merge buffers on the screen - compositor->DrawBuffer( mainBuffer ); - compositor->DrawBuffer( overlayBuffer ); + m_compositor->DrawBuffer( m_mainBuffer ); + m_compositor->DrawBuffer( m_overlayBuffer ); // Now translate the raw context data from the format stored // by cairo into a format understood by wxImage. @@ -1290,26 +1293,26 @@ void CAIRO_GAL::endDrawing() pixman_image_t* dstImg = pixman_image_create_bits( wxPlatformInfo::Get().GetEndianness() == wxENDIAN_LITTLE ? PIXMAN_b8g8r8 : PIXMAN_r8g8b8, - screenSize.x, screenSize.y, (uint32_t*) wxOutput, wxBufferWidth * 3 ); + m_screenSize.x, m_screenSize.y, (uint32_t*) m_wxOutput, m_wxBufferWidth * 3 ); pixman_image_t* srcImg = - pixman_image_create_bits( PIXMAN_a8r8g8b8, screenSize.x, screenSize.y, - (uint32_t*) bitmapBuffer, wxBufferWidth * 4 ); + pixman_image_create_bits( PIXMAN_a8r8g8b8, m_screenSize.x, m_screenSize.y, + (uint32_t*) m_bitmapBuffer, m_wxBufferWidth * 4 ); - pixman_image_composite( PIXMAN_OP_SRC, srcImg, NULL, dstImg, 0, 0, 0, 0, 0, 0, screenSize.x, - screenSize.y ); + pixman_image_composite( PIXMAN_OP_SRC, srcImg, NULL, dstImg, 0, 0, 0, 0, 0, 0, m_screenSize.x, + m_screenSize.y ); // Free allocated memory pixman_image_unref( srcImg ); pixman_image_unref( dstImg ); - wxImage img( wxBufferWidth, screenSize.y, wxOutput, true ); + wxImage img( m_wxBufferWidth, m_screenSize.y, m_wxOutput, true ); wxBitmap bmp( img ); wxMemoryDC mdc( bmp ); wxClientDC clientDC( this ); // Now it is the time to blit the mouse cursor blitCursor( mdc ); - clientDC.Blit( 0, 0, screenSize.x, screenSize.y, &mdc, 0, 0, wxCOPY ); + clientDC.Blit( 0, 0, m_screenSize.x, m_screenSize.y, &mdc, 0, 0, wxCOPY ); deinitSurface(); } @@ -1318,10 +1321,8 @@ void CAIRO_GAL::endDrawing() void CAIRO_GAL::PostPaint( wxPaintEvent& aEvent ) { // posts an event to m_paint_listener to ask for redraw the canvas. - if( paintListener ) - { - wxPostEvent( paintListener, aEvent ); - } + if( m_paintListener ) + wxPostEvent( m_paintListener, aEvent ); } @@ -1333,10 +1334,10 @@ void CAIRO_GAL::ResizeScreen( int aWidth, int aHeight ) deleteBitmaps(); allocateBitmaps(); - if( validCompositor ) - compositor->Resize( aWidth, aHeight ); + if( m_validCompositor ) + m_compositor->Resize( aWidth, aHeight ); - validCompositor = false; + m_validCompositor = false; SetSize( wxSize( aWidth, aHeight ) ); } @@ -1371,129 +1372,128 @@ void CAIRO_GAL::SetTarget( RENDER_TARGET aTarget ) { // If the compositor is not set, that means that there is a recaching process going on // and we do not need the compositor now - if( !validCompositor ) + if( !m_validCompositor ) return; // Cairo grouping prevents display of overlapping items on the same layer in the lighter color - if( isInitialized ) + if( m_isInitialized ) storePath(); switch( aTarget ) { default: case TARGET_CACHED: - case TARGET_NONCACHED: compositor->SetBuffer( mainBuffer ); break; - - case TARGET_OVERLAY: compositor->SetBuffer( overlayBuffer ); break; + case TARGET_NONCACHED: m_compositor->SetBuffer( m_mainBuffer ); break; + case TARGET_OVERLAY: m_compositor->SetBuffer( m_overlayBuffer ); break; } - currentTarget = aTarget; + m_currentTarget = aTarget; } RENDER_TARGET CAIRO_GAL::GetTarget() const { - return currentTarget; + return m_currentTarget; } void CAIRO_GAL::ClearTarget( RENDER_TARGET aTarget ) { // Save the current state - unsigned int currentBuffer = compositor->GetBuffer(); + unsigned int currentBuffer = m_compositor->GetBuffer(); switch( aTarget ) { // Cached and noncached items are rendered to the same buffer default: case TARGET_CACHED: - case TARGET_NONCACHED: compositor->SetBuffer( mainBuffer ); break; - case TARGET_OVERLAY: compositor->SetBuffer( overlayBuffer ); break; + case TARGET_NONCACHED: m_compositor->SetBuffer( m_mainBuffer ); break; + case TARGET_OVERLAY: m_compositor->SetBuffer( m_overlayBuffer ); break; } - compositor->ClearBuffer( COLOR4D::BLACK ); + m_compositor->ClearBuffer( COLOR4D::BLACK ); // Restore the previous state - compositor->SetBuffer( currentBuffer ); + m_compositor->SetBuffer( currentBuffer ); } void CAIRO_GAL::initSurface() { - if( isInitialized ) + if( m_isInitialized ) return; - surface = cairo_image_surface_create_for_data( bitmapBuffer, GAL_FORMAT, wxBufferWidth, - screenSize.y, stride ); + m_surface = cairo_image_surface_create_for_data( m_bitmapBuffer, GAL_FORMAT, m_wxBufferWidth, + m_screenSize.y, m_stride ); - context = cairo_create( surface ); + m_context = cairo_create( m_surface ); #ifdef DEBUG - cairo_status_t status = cairo_status( context ); + cairo_status_t status = cairo_status( m_context ); wxASSERT_MSG( status == CAIRO_STATUS_SUCCESS, wxT( "Cairo context creation error" ) ); #endif /* DEBUG */ - currentContext = context; + m_currentContext = m_context; - isInitialized = true; + m_isInitialized = true; } void CAIRO_GAL::deinitSurface() { - if( !isInitialized ) + if( !m_isInitialized ) return; - cairo_destroy( context ); - context = nullptr; - cairo_surface_destroy( surface ); - surface = nullptr; + cairo_destroy( m_context ); + m_context = nullptr; + cairo_surface_destroy( m_surface ); + m_surface = nullptr; - isInitialized = false; + m_isInitialized = false; } void CAIRO_GAL::allocateBitmaps() { - wxBufferWidth = screenSize.x; + m_wxBufferWidth = m_screenSize.x; - while( ( ( wxBufferWidth * 3 ) % 4 ) != 0 ) - wxBufferWidth++; + while( ( ( m_wxBufferWidth * 3 ) % 4 ) != 0 ) + m_wxBufferWidth++; // Create buffer, use the system independent Cairo context backend - stride = cairo_format_stride_for_width( GAL_FORMAT, wxBufferWidth ); - bufferSize = stride * screenSize.y; + m_stride = cairo_format_stride_for_width( GAL_FORMAT, m_wxBufferWidth ); + m_bufferSize = m_stride * m_screenSize.y; - wxASSERT( bitmapBuffer == nullptr ); - bitmapBuffer = new unsigned char[bufferSize * 4]; + wxASSERT( m_bitmapBuffer == nullptr ); + m_bitmapBuffer = new unsigned char[m_bufferSize * 4]; - wxASSERT( wxOutput == nullptr ); - wxOutput = new unsigned char[wxBufferWidth * 3 * screenSize.y]; + wxASSERT( m_wxOutput == nullptr ); + m_wxOutput = new unsigned char[m_wxBufferWidth * 3 * m_screenSize.y]; } void CAIRO_GAL::deleteBitmaps() { - delete[] bitmapBuffer; - bitmapBuffer = nullptr; + delete[] m_bitmapBuffer; + m_bitmapBuffer = nullptr; - delete[] wxOutput; - wxOutput = nullptr; + delete[] m_wxOutput; + m_wxOutput = nullptr; } void CAIRO_GAL::setCompositor() { // Recreate the compositor with the new Cairo context - compositor.reset( new CAIRO_COMPOSITOR( ¤tContext ) ); - compositor->Resize( screenSize.x, screenSize.y ); - compositor->SetAntialiasingMode( options.cairo_antialiasing_mode ); + m_compositor.reset( new CAIRO_COMPOSITOR( &m_currentContext ) ); + m_compositor->Resize( m_screenSize.x, m_screenSize.y ); + m_compositor->SetAntialiasingMode( m_options.cairo_antialiasing_mode ); // Prepare buffers - mainBuffer = compositor->CreateBuffer(); - overlayBuffer = compositor->CreateBuffer(); + m_mainBuffer = m_compositor->CreateBuffer(); + m_overlayBuffer = m_compositor->CreateBuffer(); - validCompositor = true; + m_validCompositor = true; } @@ -1506,8 +1506,8 @@ void CAIRO_GAL::onPaint( wxPaintEvent& aEvent ) void CAIRO_GAL::skipMouseEvent( wxMouseEvent& aEvent ) { // Post the mouse event to the event listener registered in constructor, if any - if( mouseListener ) - wxPostEvent( mouseListener, aEvent ); + if( m_mouseListener ) + wxPostEvent( m_mouseListener, aEvent ); } @@ -1515,10 +1515,10 @@ bool CAIRO_GAL::updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions ) { bool refresh = false; - if( validCompositor && aOptions.cairo_antialiasing_mode != compositor->GetAntialiasingMode() ) + if( m_validCompositor && aOptions.cairo_antialiasing_mode != m_compositor->GetAntialiasingMode() ) { - compositor->SetAntialiasingMode( options.cairo_antialiasing_mode ); - validCompositor = false; + m_compositor->SetAntialiasingMode( m_options.cairo_antialiasing_mode ); + m_validCompositor = false; deinitSurface(); refresh = true; @@ -1541,47 +1541,47 @@ void CAIRO_GAL_BASE::DrawGrid() // Draw the grid // For the drawing the start points, end points and increments have // to be calculated in world coordinates - VECTOR2D worldStartPoint = screenWorldMatrix * VECTOR2D( 0.0, 0.0 ); - VECTOR2D worldEndPoint = screenWorldMatrix * VECTOR2D( screenSize ); + VECTOR2D worldStartPoint = m_screenWorldMatrix * VECTOR2D( 0.0, 0.0 ); + VECTOR2D worldEndPoint = m_screenWorldMatrix * VECTOR2D( m_screenSize ); // Compute the line marker or point radius of the grid // Note: generic grids can't handle sub-pixel lines without // either losing fine/course distinction or having some dots // fail to render - float marker = std::fmax( 1.0f, gridLineWidth ) / worldScale; + float marker = std::fmax( 1.0f, m_gridLineWidth ) / m_worldScale; float doubleMarker = 2.0f * marker; // Draw axes if desired - if( axesEnabled ) + if( m_axesEnabled ) { SetLineWidth( marker ); drawAxes( worldStartPoint, worldEndPoint ); } - if( !gridVisibility || gridSize.x == 0 || gridSize.y == 0 ) + if( !m_gridVisibility || m_gridSize.x == 0 || m_gridSize.y == 0 ) return; - VECTOR2D gridScreenSize( gridSize ); + VECTOR2D gridScreenSize( m_gridSize ); - double gridThreshold = KiROUND( computeMinGridSpacing() / worldScale ); + double gridThreshold = KiROUND( computeMinGridSpacing() / m_worldScale ); - if( gridStyle == GRID_STYLE::SMALL_CROSS ) + if( m_gridStyle == GRID_STYLE::SMALL_CROSS ) gridThreshold *= 2.0; // If we cannot display the grid density, scale down by a tick size and // try again. Eventually, we get some representation of the grid while( std::min( gridScreenSize.x, gridScreenSize.y ) <= gridThreshold ) { - gridScreenSize = gridScreenSize * static_cast( gridTick ); + gridScreenSize = gridScreenSize * static_cast( m_gridTick ); } // Compute grid starting and ending indexes to draw grid points on the // visible screen area - // Note: later any point coordinate will be offsetted by gridOrigin - int gridStartX = KiROUND( ( worldStartPoint.x - gridOrigin.x ) / gridScreenSize.x ); - int gridEndX = KiROUND( ( worldEndPoint.x - gridOrigin.x ) / gridScreenSize.x ); - int gridStartY = KiROUND( ( worldStartPoint.y - gridOrigin.y ) / gridScreenSize.y ); - int gridEndY = KiROUND( ( worldEndPoint.y - gridOrigin.y ) / gridScreenSize.y ); + // Note: later any point coordinate will be offsetted by m_gridOrigin + int gridStartX = KiROUND( ( worldStartPoint.x - m_gridOrigin.x ) / gridScreenSize.x ); + int gridEndX = KiROUND( ( worldEndPoint.x - m_gridOrigin.x ) / gridScreenSize.x ); + int gridStartY = KiROUND( ( worldStartPoint.y - m_gridOrigin.y ) / gridScreenSize.y ); + int gridEndY = KiROUND( ( worldEndPoint.y - m_gridOrigin.y ) / gridScreenSize.y ); // Ensure start coordinate > end coordinate @@ -1595,62 +1595,62 @@ void CAIRO_GAL_BASE::DrawGrid() ++gridEndY; // Draw the grid behind all other layers - SetLayerDepth( depthRange.y * 0.75 ); + SetLayerDepth( m_depthRange.y * 0.75 ); - if( gridStyle == GRID_STYLE::LINES ) + if( m_gridStyle == GRID_STYLE::LINES ) { // Now draw the grid, every coarse grid line gets the double width // Vertical lines for( int j = gridStartY; j <= gridEndY; j++ ) { - const double y = j * gridScreenSize.y + gridOrigin.y; + const double y = j * gridScreenSize.y + m_gridOrigin.y; - if( axesEnabled && y == 0.0 ) + if( m_axesEnabled && y == 0.0 ) continue; - SetLineWidth( ( j % gridTick ) ? marker : doubleMarker ); - drawGridLine( VECTOR2D( gridStartX * gridScreenSize.x + gridOrigin.x, y ), - VECTOR2D( gridEndX * gridScreenSize.x + gridOrigin.x, y ) ); + SetLineWidth( ( j % m_gridTick ) ? marker : doubleMarker ); + drawGridLine( VECTOR2D( gridStartX * gridScreenSize.x + m_gridOrigin.x, y ), + VECTOR2D( gridEndX * gridScreenSize.x + m_gridOrigin.x, y ) ); } // Horizontal lines for( int i = gridStartX; i <= gridEndX; i++ ) { - const double x = i * gridScreenSize.x + gridOrigin.x; + const double x = i * gridScreenSize.x + m_gridOrigin.x; - if( axesEnabled && x == 0.0 ) + if( m_axesEnabled && x == 0.0 ) continue; - SetLineWidth( ( i % gridTick ) ? marker : doubleMarker ); - drawGridLine( VECTOR2D( x, gridStartY * gridScreenSize.y + gridOrigin.y ), - VECTOR2D( x, gridEndY * gridScreenSize.y + gridOrigin.y ) ); + SetLineWidth( ( i % m_gridTick ) ? marker : doubleMarker ); + drawGridLine( VECTOR2D( x, gridStartY * gridScreenSize.y + m_gridOrigin.y ), + VECTOR2D( x, gridEndY * gridScreenSize.y + m_gridOrigin.y ) ); } } else // Dots or Crosses grid { - lineWidthIsOdd = true; - isStrokeEnabled = true; + m_lineWidthIsOdd = true; + m_isStrokeEnabled = true; for( int j = gridStartY; j <= gridEndY; j++ ) { - bool tickY = ( j % gridTick == 0 ); + bool tickY = ( j % m_gridTick == 0 ); for( int i = gridStartX; i <= gridEndX; i++ ) { - bool tickX = ( i % gridTick == 0 ); - VECTOR2D pos{ i * gridScreenSize.x + gridOrigin.x, - j * gridScreenSize.y + gridOrigin.y }; + bool tickX = ( i % m_gridTick == 0 ); + VECTOR2D pos{ i * gridScreenSize.x + m_gridOrigin.x, + j * gridScreenSize.y + m_gridOrigin.y }; - if( gridStyle == GRID_STYLE::SMALL_CROSS ) + if( m_gridStyle == GRID_STYLE::SMALL_CROSS ) { SetLineWidth( ( tickX && tickY ) ? doubleMarker : marker ); drawGridCross( pos ); } - else if( gridStyle == GRID_STYLE::DOTS ) + else if( m_gridStyle == GRID_STYLE::DOTS ) { - double doubleGridLineWidth = gridLineWidth * 2.0f; - drawGridPoint( pos, ( tickX ) ? doubleGridLineWidth : gridLineWidth, - ( tickY ) ? doubleGridLineWidth : gridLineWidth ); + double doubleGridLineWidth = m_gridLineWidth * 2.0f; + drawGridPoint( pos, ( tickX ) ? doubleGridLineWidth : m_gridLineWidth, + ( tickY ) ? doubleGridLineWidth : m_gridLineWidth ); } } } diff --git a/common/gal/cairo/cairo_print.cpp b/common/gal/cairo/cairo_print.cpp index 3b9468e3ce..76b6c569b2 100644 --- a/common/gal/cairo/cairo_print.cpp +++ b/common/gal/cairo/cairo_print.cpp @@ -136,10 +136,10 @@ CAIRO_PRINT_GAL::CAIRO_PRINT_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptio CAIRO_GAL_BASE( aDisplayOptions ) { m_printCtx = std::move( aContext ); - context = currentContext = m_printCtx->GetContext(); - surface = m_printCtx->GetSurface(); - cairo_reference( context ); - cairo_surface_reference( surface ); + m_context = m_currentContext = m_printCtx->GetContext(); + m_surface = m_printCtx->GetSurface(); + cairo_reference( m_context ); + cairo_surface_reference( m_surface ); m_clearColor = COLOR4D( 1.0, 1.0, 1.0, 1.0 ); m_hasNativeLandscapeRotation = false; resetContext(); @@ -150,10 +150,10 @@ CAIRO_PRINT_GAL::CAIRO_PRINT_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptio void CAIRO_PRINT_GAL::ComputeWorldScreenMatrix() { - worldScale = screenDPI * worldUnitLength * zoomFactor; - const auto paperSizeIU = VECTOR2D( m_nativePaperSize.y, m_nativePaperSize.x ) /* inches */ - / worldUnitLength; /* 1 inch in IU */ - const auto paperSizeIUTransposed = VECTOR2D( paperSizeIU.y, paperSizeIU.x ); + m_worldScale = m_screenDPI * m_worldUnitLength * m_zoomFactor; + const VECTOR2D paperSizeIU = VECTOR2D( m_nativePaperSize.y, m_nativePaperSize.x ) /* inches */ + / m_worldUnitLength; /* 1" in IU */ + const VECTOR2D paperSizeIUTransposed( paperSizeIU.y, paperSizeIU.x ); MATRIX3x3D scale, translation, flip, rotate, lookat; @@ -165,27 +165,27 @@ void CAIRO_PRINT_GAL::ComputeWorldScreenMatrix() if( m_hasNativeLandscapeRotation ) { - translation.SetTranslation( 0.5 / zoomFactor * paperSizeIUTransposed ); + translation.SetTranslation( 0.5 / m_zoomFactor * paperSizeIUTransposed ); } else { if( isLandscape() ) { - translation.SetTranslation( 0.5 / zoomFactor * paperSizeIU ); + translation.SetTranslation( 0.5 / m_zoomFactor * paperSizeIU ); rotate.SetRotation( 90.0 * M_PI / 180.0 ); } else { - translation.SetTranslation( 0.5 / zoomFactor * paperSizeIUTransposed ); + translation.SetTranslation( 0.5 / m_zoomFactor * paperSizeIUTransposed ); } } - scale.SetScale( VECTOR2D( worldScale, worldScale ) ); - flip.SetScale( VECTOR2D( globalFlipX ? -1.0 : 1.0, globalFlipY ? -1.0 : 1.0 ) ); - lookat.SetTranslation( -lookAtPoint ); + scale.SetScale( VECTOR2D( m_worldScale, m_worldScale ) ); + flip.SetScale( VECTOR2D( m_globalFlipX ? -1.0 : 1.0, m_globalFlipY ? -1.0 : 1.0 ) ); + lookat.SetTranslation( -m_lookAtPoint ); - worldScreenMatrix = scale * translation * flip * rotate * lookat; - screenWorldMatrix = worldScreenMatrix.Inverse(); + m_worldScreenMatrix = scale * translation * flip * rotate * lookat; + m_screenWorldMatrix = m_worldScreenMatrix.Inverse(); } @@ -199,8 +199,8 @@ void CAIRO_PRINT_GAL::SetNativePaperSize( const VECTOR2D& aSize, bool aHasNative void CAIRO_PRINT_GAL::SetSheetSize( const VECTOR2D& aSize ) { // Convert aSize (inches) to pixels - SetScreenSize( VECTOR2I( std::ceil( aSize.x * screenDPI ) * 2, - std::ceil( aSize.y * screenDPI ) * 2 ) ); + SetScreenSize( VECTOR2I( std::ceil( aSize.x * m_screenDPI ) * 2, + std::ceil( aSize.y * m_screenDPI ) * 2 ) ); } diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp index 7456541455..5faf555aee 100644 --- a/common/gal/graphics_abstraction_layer.cpp +++ b/common/gal/graphics_abstraction_layer.cpp @@ -37,8 +37,8 @@ using namespace KIGFX; GAL::GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions ) : - options( aDisplayOptions ), - strokeFont( this ) + m_options( aDisplayOptions ), + m_strokeFont( this ) { // Set the default values for the internal variables SetIsFill( false ); @@ -64,23 +64,23 @@ GAL::GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions ) : // Set grid defaults SetGridVisibility( true ); SetCoarseGrid( 10 ); - gridLineWidth = 0.5f; - gridStyle = GRID_STYLE::LINES; - gridMinSpacing = 10; + m_gridLineWidth = 0.5f; + m_gridStyle = GRID_STYLE::LINES; + m_gridMinSpacing = 10; // Initialize the cursor shape SetCursorColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) ); - fullscreenCursor = false; - forceDisplayCursor = false; + m_fullscreenCursor = false; + m_forceDisplayCursor = false; SetCursorEnabled( false ); // Initialize text properties ResetTextAttributes(); - strokeFont.LoadNewStrokeFont( newstroke_font, newstroke_font_bufsize ); + m_strokeFont.LoadNewStrokeFont( newstroke_font, newstroke_font_bufsize ); // subscribe for settings updates - observerLink = options.Subscribe( this ); + m_observerLink = m_options.Subscribe( this ); } @@ -102,39 +102,39 @@ bool GAL::updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions ) { bool refresh = false; - if( options.m_gridStyle != gridStyle ) + if( m_options.m_gridStyle != m_gridStyle ) { - gridStyle = options.m_gridStyle ; + m_gridStyle = m_options.m_gridStyle ; refresh = true; } - if( options.m_gridLineWidth != gridLineWidth ) + if( m_options.m_gridLineWidth != m_gridLineWidth ) { - gridLineWidth = std::floor( options.m_gridLineWidth + 0.5 ); + m_gridLineWidth = std::floor( m_options.m_gridLineWidth + 0.5 ); refresh = true; } - if( options.m_gridMinSpacing != gridMinSpacing ) + if( m_options.m_gridMinSpacing != m_gridMinSpacing ) { - gridMinSpacing = options.m_gridMinSpacing; + m_gridMinSpacing = m_options.m_gridMinSpacing; refresh = true; } - if( options.m_axesEnabled != axesEnabled ) + if( m_options.m_axesEnabled != m_axesEnabled ) { - axesEnabled = options.m_axesEnabled; + m_axesEnabled = m_options.m_axesEnabled; refresh = true; } - if( options.m_forceDisplayCursor != forceDisplayCursor ) + if( m_options.m_forceDisplayCursor != m_forceDisplayCursor ) { - forceDisplayCursor = options.m_forceDisplayCursor; + m_forceDisplayCursor = m_options.m_forceDisplayCursor; refresh = true; } - if( options.m_fullscreenCursor != fullscreenCursor ) + if( m_options.m_fullscreenCursor != m_fullscreenCursor ) { - fullscreenCursor = options.m_fullscreenCursor; + m_fullscreenCursor = m_options.m_fullscreenCursor; refresh = true; } @@ -176,7 +176,7 @@ VECTOR2D GAL::GetTextLineSize( const UTF8& aText ) const // Compute the X and Y size of a given text. // Because computeTextLineSize expects a one line text, // aText is expected to be only one line text. - return strokeFont.computeTextLineSize( aText ); + return m_strokeFont.computeTextLineSize( aText ); } @@ -186,26 +186,26 @@ void GAL::ComputeWorldScreenMatrix() MATRIX3x3D translation; translation.SetIdentity(); - translation.SetTranslation( 0.5 * VECTOR2D( screenSize ) ); + translation.SetTranslation( 0.5 * VECTOR2D( m_screenSize ) ); MATRIX3x3D rotate; rotate.SetIdentity(); - rotate.SetRotation( rotation ); + rotate.SetRotation( m_rotation ); MATRIX3x3D scale; scale.SetIdentity(); - scale.SetScale( VECTOR2D( worldScale, worldScale ) ); + scale.SetScale( VECTOR2D( m_worldScale, m_worldScale ) ); MATRIX3x3D flip; flip.SetIdentity(); - flip.SetScale( VECTOR2D( globalFlipX ? -1.0 : 1.0, globalFlipY ? -1.0 : 1.0 ) ); + flip.SetScale( VECTOR2D( m_globalFlipX ? -1.0 : 1.0, m_globalFlipY ? -1.0 : 1.0 ) ); MATRIX3x3D lookat; lookat.SetIdentity(); - lookat.SetTranslation( -lookAtPoint ); + lookat.SetTranslation( -m_lookAtPoint ); - worldScreenMatrix = translation * rotate * flip * scale * lookat; - screenWorldMatrix = worldScreenMatrix.Inverse(); + m_worldScreenMatrix = translation * rotate * flip * scale * lookat; + m_screenWorldMatrix = m_worldScreenMatrix.Inverse(); } @@ -213,7 +213,7 @@ double GAL::computeMinGridSpacing() const { // just return the current value. This could be cleverer and take // into account other settings in future - return gridMinSpacing; + return m_gridMinSpacing; } @@ -221,14 +221,14 @@ VECTOR2D GAL::GetGridPoint( const VECTOR2D& aPoint ) const { #if 0 // This old code expects a non zero grid size, which can be wrong here. - return VECTOR2D( KiROUND( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x, - KiROUND( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y ); + return VECTOR2D( KiROUND( ( aPoint.x - m_gridOffset.x ) / m_gridSize.x ) * m_gridSize.x + m_gridOffset.x, + KiROUND( ( aPoint.y - m_gridOffset.y ) / m_gridSize.y ) * m_gridSize.y + m_gridOffset.y ); #else // if grid size == 0.0 there is no grid, so use aPoint as grid reference position - double cx = gridSize.x > 0.0 ? KiROUND( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x - : aPoint.x; - double cy = gridSize.y > 0.0 ? KiROUND( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y - : aPoint.y; + double cx = m_gridSize.x > 0.0 ? KiROUND( ( aPoint.x - m_gridOffset.x ) / m_gridSize.x ) * m_gridSize.x + m_gridOffset.x + : aPoint.x; + double cy = m_gridSize.y > 0.0 ? KiROUND( ( aPoint.y - m_gridOffset.y ) / m_gridSize.y ) * m_gridSize.y + m_gridOffset.y + : aPoint.y; return VECTOR2D( cx, cy ); #endif @@ -241,14 +241,12 @@ const int GAL::GRID_DEPTH = MAX_DEPTH - 1; COLOR4D GAL::getCursorColor() const { - auto color = cursorColor; + COLOR4D color = m_cursorColor; // dim the cursor if it's only on because it was forced // (this helps to provide a hint for active tools) - if( !isCursorEnabled ) - { + if( !m_isCursorEnabled ) color.a = color.a * 0.5; - } return color; } diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index f833ae7769..b722f796f0 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -78,10 +78,10 @@ using namespace KIGFX::BUILTIN_FONT; static void InitTesselatorCallbacks( GLUtesselator* aTesselator ); static const int glAttributes[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 8, 0 }; -wxGLContext* OPENGL_GAL::glMainContext = NULL; -int OPENGL_GAL::instanceCounter = 0; -GLuint OPENGL_GAL::fontTexture = 0; -bool OPENGL_GAL::isBitmapFontLoaded = false; +wxGLContext* OPENGL_GAL::m_glMainContext = NULL; +int OPENGL_GAL::m_instanceCounter = 0; +GLuint OPENGL_GAL::g_fontTexture = 0; +bool OPENGL_GAL::m_isBitmapFontLoaded = false; namespace KIGFX { @@ -198,42 +198,42 @@ OPENGL_GAL::OPENGL_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent, GAL( aDisplayOptions ), HIDPI_GL_CANVAS( aParent, wxID_ANY, (int*) glAttributes, wxDefaultPosition, wxDefaultSize, wxEXPAND, aName ), - mouseListener( aMouseListener ), - paintListener( aPaintListener ), - currentManager( nullptr ), - cachedManager( nullptr ), - nonCachedManager( nullptr ), - overlayManager( nullptr ), - mainBuffer( 0 ), - overlayBuffer( 0 ), + m_mouseListener( aMouseListener ), + m_paintListener( aPaintListener ), + m_currentManager( nullptr ), + m_cachedManager( nullptr ), + m_nonCachedManager( nullptr ), + m_overlayManager( nullptr ), + m_mainBuffer( 0 ), + m_overlayBuffer( 0 ), m_isContextLocked( false ), - lockClientCookie( 0 ) + m_lockClientCookie( 0 ) { - if( glMainContext == NULL ) + if( m_glMainContext == NULL ) { - glMainContext = GL_CONTEXT_MANAGER::Get().CreateCtx( this ); + m_glMainContext = GL_CONTEXT_MANAGER::Get().CreateCtx( this ); - glPrivContext = glMainContext; + m_glPrivContext = m_glMainContext; } else { - glPrivContext = GL_CONTEXT_MANAGER::Get().CreateCtx( this, glMainContext ); + m_glPrivContext = GL_CONTEXT_MANAGER::Get().CreateCtx( this, m_glMainContext ); } - shader = new SHADER(); - ++instanceCounter; + m_shader = new SHADER(); + ++m_instanceCounter; - bitmapCache = std::make_unique(); + m_bitmapCache = std::make_unique(); - compositor = new OPENGL_COMPOSITOR; - compositor->SetAntialiasingMode( options.gl_antialiasing_mode ); + m_compositor = new OPENGL_COMPOSITOR; + m_compositor->SetAntialiasingMode( m_options.gl_antialiasing_mode ); // Initialize the flags - isFramebufferInitialized = false; - isBitmapFontInitialized = false; - isInitialized = false; - isGrouping = false; - groupCounter = 0; + m_isFramebufferInitialized = false; + m_isBitmapFontInitialized = false; + m_isInitialized = false; + m_isGrouping = false; + m_groupCounter = 0; // Connecting the event handlers Connect( wxEVT_PAINT, wxPaintEventHandler( OPENGL_GAL::onPaint ) ); @@ -258,17 +258,17 @@ OPENGL_GAL::OPENGL_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent, #endif SetSize( aParent->GetClientSize() ); - screenSize = VECTOR2I( GetNativePixelSize() ); + m_screenSize = VECTOR2I( GetNativePixelSize() ); // Grid color settings are different in Cairo and OpenGL SetGridColor( COLOR4D( 0.8, 0.8, 0.8, 0.1 ) ); SetAxesColor( COLOR4D( BLUE ) ); // Tesselator initialization - tesselator = gluNewTess(); - InitTesselatorCallbacks( tesselator ); + m_tesselator = gluNewTess(); + InitTesselatorCallbacks( m_tesselator ); - gluTessProperty( tesselator, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE ); + gluTessProperty( m_tesselator, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE ); SetTarget( TARGET_NONCACHED ); @@ -281,45 +281,45 @@ OPENGL_GAL::OPENGL_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent, OPENGL_GAL::~OPENGL_GAL() { - GL_CONTEXT_MANAGER::Get().LockCtx( glPrivContext, this ); + GL_CONTEXT_MANAGER::Get().LockCtx( m_glPrivContext, this ); - --instanceCounter; + --m_instanceCounter; glFlush(); - gluDeleteTess( tesselator ); + gluDeleteTess( m_tesselator ); ClearCache(); - delete compositor; + delete m_compositor; - if( isInitialized ) + if( m_isInitialized ) { - delete cachedManager; - delete nonCachedManager; - delete overlayManager; + delete m_cachedManager; + delete m_nonCachedManager; + delete m_overlayManager; } - GL_CONTEXT_MANAGER::Get().UnlockCtx( glPrivContext ); + GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glPrivContext ); // If it was the main context, then it will be deleted // when the last OpenGL GAL instance is destroyed (a few lines below) - if( glPrivContext != glMainContext ) - GL_CONTEXT_MANAGER::Get().DestroyCtx( glPrivContext ); + if( m_glPrivContext != m_glMainContext ) + GL_CONTEXT_MANAGER::Get().DestroyCtx( m_glPrivContext ); - delete shader; + delete m_shader; // Are we destroying the last GAL instance? - if( instanceCounter == 0 ) + if( m_instanceCounter == 0 ) { - GL_CONTEXT_MANAGER::Get().LockCtx( glMainContext, this ); + GL_CONTEXT_MANAGER::Get().LockCtx( m_glMainContext, this ); - if( isBitmapFontLoaded ) + if( m_isBitmapFontLoaded ) { - glDeleteTextures( 1, &fontTexture ); - isBitmapFontLoaded = false; + glDeleteTextures( 1, &g_fontTexture ); + m_isBitmapFontLoaded = false; } - GL_CONTEXT_MANAGER::Get().UnlockCtx( glMainContext ); - GL_CONTEXT_MANAGER::Get().DestroyCtx( glMainContext ); - glMainContext = NULL; + GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glMainContext ); + GL_CONTEXT_MANAGER::Get().DestroyCtx( m_glMainContext ); + m_glMainContext = NULL; } } @@ -359,10 +359,8 @@ wxString OPENGL_GAL::CheckFeatures( GAL_DISPLAY_OPTIONS& aOptions ) void OPENGL_GAL::PostPaint( wxPaintEvent& aEvent ) { // posts an event to m_paint_listener to ask for redraw the canvas. - if( paintListener ) - { - wxPostEvent( paintListener, aEvent ); - } + if( m_paintListener ) + wxPostEvent( m_paintListener, aEvent ); } @@ -370,16 +368,16 @@ bool OPENGL_GAL::updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions ) { bool refresh = false; - if( options.gl_antialiasing_mode != compositor->GetAntialiasingMode() ) + if( m_options.gl_antialiasing_mode != m_compositor->GetAntialiasingMode() ) { - compositor->SetAntialiasingMode( options.gl_antialiasing_mode ); - isFramebufferInitialized = false; + m_compositor->SetAntialiasingMode( m_options.gl_antialiasing_mode ); + m_isFramebufferInitialized = false; refresh = true; } - if( options.m_scaleFactor != GetScaleFactor() ) + if( m_options.m_scaleFactor != GetScaleFactor() ) { - SetScaleFactor( options.m_scaleFactor ); + SetScaleFactor( m_options.m_scaleFactor ); refresh = true; } @@ -395,15 +393,15 @@ bool OPENGL_GAL::updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions ) double OPENGL_GAL::getWorldPixelSize() const { - auto matrix = GetScreenWorldMatrix(); + MATRIX3x3D matrix = GetScreenWorldMatrix(); return std::min( std::abs( matrix.GetScale().x ), std::abs( matrix.GetScale().y ) ); } VECTOR2D OPENGL_GAL::getScreenPixelSize() const { - auto sf = GetScaleFactor(); - return VECTOR2D( 2.0 / (double) ( screenSize.x * sf ), 2.0 / (double) ( screenSize.y * sf ) ); + double sf = GetScaleFactor(); + return VECTOR2D( 2.0 / (double) ( m_screenSize.x * sf ), 2.0 / (double) ( m_screenSize.y * sf ) ); } @@ -420,7 +418,7 @@ void OPENGL_GAL::beginDrawing() "Other drawing routines will expect everything to be initialized " "which will not be the case." ); - if( !isInitialized ) + if( !m_isInitialized ) init(); // Set up the view port @@ -428,26 +426,27 @@ void OPENGL_GAL::beginDrawing() glLoadIdentity(); // Create the screen transformation (Do the RH-LH conversion here) - glOrtho( 0, (GLint) screenSize.x, (GLsizei) screenSize.y, 0, -depthRange.x, -depthRange.y ); + glOrtho( 0, (GLint) m_screenSize.x, (GLsizei) m_screenSize.y, 0, + -m_depthRange.x, -m_depthRange.y ); - if( !isFramebufferInitialized ) + if( !m_isFramebufferInitialized ) { // Prepare rendering target buffers - compositor->Initialize(); - mainBuffer = compositor->CreateBuffer(); + m_compositor->Initialize(); + m_mainBuffer = m_compositor->CreateBuffer(); try { - overlayBuffer = compositor->CreateBuffer(); + m_overlayBuffer = m_compositor->CreateBuffer(); } catch( const std::runtime_error& ) { wxLogVerbose( "Could not create a framebuffer for overlays.\n" ); - overlayBuffer = 0; + m_overlayBuffer = 0; } - isFramebufferInitialized = true; + m_isFramebufferInitialized = true; } - compositor->Begin(); + m_compositor->Begin(); // Disable 2D Textures glDisable( GL_TEXTURE_2D ); @@ -467,40 +466,40 @@ void OPENGL_GAL::beginDrawing() // Set up the world <-> screen transformation ComputeWorldScreenMatrix(); GLdouble matrixData[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; - matrixData[0] = worldScreenMatrix.m_data[0][0]; - matrixData[1] = worldScreenMatrix.m_data[1][0]; - matrixData[2] = worldScreenMatrix.m_data[2][0]; - matrixData[4] = worldScreenMatrix.m_data[0][1]; - matrixData[5] = worldScreenMatrix.m_data[1][1]; - matrixData[6] = worldScreenMatrix.m_data[2][1]; - matrixData[12] = worldScreenMatrix.m_data[0][2]; - matrixData[13] = worldScreenMatrix.m_data[1][2]; - matrixData[14] = worldScreenMatrix.m_data[2][2]; + matrixData[0] = m_worldScreenMatrix.m_data[0][0]; + matrixData[1] = m_worldScreenMatrix.m_data[1][0]; + matrixData[2] = m_worldScreenMatrix.m_data[2][0]; + matrixData[4] = m_worldScreenMatrix.m_data[0][1]; + matrixData[5] = m_worldScreenMatrix.m_data[1][1]; + matrixData[6] = m_worldScreenMatrix.m_data[2][1]; + matrixData[12] = m_worldScreenMatrix.m_data[0][2]; + matrixData[13] = m_worldScreenMatrix.m_data[1][2]; + matrixData[14] = m_worldScreenMatrix.m_data[2][2]; glLoadMatrixd( matrixData ); // Set defaults - SetFillColor( fillColor ); - SetStrokeColor( strokeColor ); + SetFillColor( m_fillColor ); + SetStrokeColor( m_strokeColor ); // Remove all previously stored items - nonCachedManager->Clear(); - overlayManager->Clear(); + m_nonCachedManager->Clear(); + m_overlayManager->Clear(); - cachedManager->BeginDrawing(); - nonCachedManager->BeginDrawing(); - overlayManager->BeginDrawing(); + m_cachedManager->BeginDrawing(); + m_nonCachedManager->BeginDrawing(); + m_overlayManager->BeginDrawing(); - if( !isBitmapFontInitialized ) + if( !m_isBitmapFontInitialized ) { // Keep bitmap font texture always bound to the second texturing unit const GLint FONT_TEXTURE_UNIT = 2; // Either load the font atlas to video memory, or simply bind it to a texture unit - if( !isBitmapFontLoaded ) + if( !m_isBitmapFontLoaded ) { glActiveTexture( GL_TEXTURE0 + FONT_TEXTURE_UNIT ); - glGenTextures( 1, &fontTexture ); - glBindTexture( GL_TEXTURE_2D, fontTexture ); + glGenTextures( 1, &g_fontTexture ); + glBindTexture( GL_TEXTURE_2D, g_fontTexture ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB8, font_image.width, font_image.height, 0, GL_RGB, GL_UNSIGNED_BYTE, font_image.pixels ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); @@ -509,44 +508,44 @@ void OPENGL_GAL::beginDrawing() glActiveTexture( GL_TEXTURE0 ); - isBitmapFontLoaded = true; + m_isBitmapFontLoaded = true; } else { glActiveTexture( GL_TEXTURE0 + FONT_TEXTURE_UNIT ); - glBindTexture( GL_TEXTURE_2D, fontTexture ); + glBindTexture( GL_TEXTURE_2D, g_fontTexture ); glActiveTexture( GL_TEXTURE0 ); } // Set shader parameter - GLint ufm_fontTexture = shader->AddParameter( "fontTexture" ); - GLint ufm_fontTextureWidth = shader->AddParameter( "fontTextureWidth" ); - ufm_worldPixelSize = shader->AddParameter( "worldPixelSize" ); - ufm_screenPixelSize = shader->AddParameter( "screenPixelSize" ); - ufm_pixelSizeMultiplier = shader->AddParameter( "pixelSizeMultiplier" ); + GLint ufm_fontTexture = m_shader->AddParameter( "fontTexture" ); + GLint ufm_fontTextureWidth = m_shader->AddParameter( "fontTextureWidth" ); + ufm_worldPixelSize = m_shader->AddParameter( "worldPixelSize" ); + ufm_screenPixelSize = m_shader->AddParameter( "screenPixelSize" ); + ufm_pixelSizeMultiplier = m_shader->AddParameter( "pixelSizeMultiplier" ); - shader->Use(); - shader->SetParameter( ufm_fontTexture, (int) FONT_TEXTURE_UNIT ); - shader->SetParameter( ufm_fontTextureWidth, (int) font_image.width ); - shader->Deactivate(); + m_shader->Use(); + m_shader->SetParameter( ufm_fontTexture, (int) FONT_TEXTURE_UNIT ); + m_shader->SetParameter( ufm_fontTextureWidth, (int) font_image.width ); + m_shader->Deactivate(); checkGlError( "setting bitmap font sampler as shader parameter" ); - isBitmapFontInitialized = true; + m_isBitmapFontInitialized = true; } - shader->Use(); - shader->SetParameter( ufm_worldPixelSize, (float) ( getWorldPixelSize() / GetScaleFactor() ) ); - shader->SetParameter( ufm_screenPixelSize, getScreenPixelSize() ); - double pixelSizeMultiplier = compositor->GetAntialiasSupersamplingFactor(); - shader->SetParameter( ufm_pixelSizeMultiplier, (float) pixelSizeMultiplier ); - shader->Deactivate(); + m_shader->Use(); + m_shader->SetParameter( ufm_worldPixelSize, (float) ( getWorldPixelSize() / GetScaleFactor() ) ); + m_shader->SetParameter( ufm_screenPixelSize, getScreenPixelSize() ); + double pixelSizeMultiplier = m_compositor->GetAntialiasSupersamplingFactor(); + m_shader->SetParameter( ufm_pixelSizeMultiplier, (float) pixelSizeMultiplier ); + m_shader->Deactivate(); // Something betreen BeginDrawing and EndDrawing seems to depend on // this texture unit being active, but it does not assure it itself. glActiveTexture( GL_TEXTURE0 ); // Unbind buffers - set compositor for direct drawing - compositor->SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING ); + m_compositor->SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING ); #ifdef __WXDEBUG__ totalRealTime.Stop(); @@ -565,25 +564,26 @@ void OPENGL_GAL::endDrawing() #endif /* __WXDEBUG__ */ // Cached & non-cached containers are rendered to the same buffer - compositor->SetBuffer( mainBuffer ); - nonCachedManager->EndDrawing(); - cachedManager->EndDrawing(); + m_compositor->SetBuffer( m_mainBuffer ); + m_nonCachedManager->EndDrawing(); + m_cachedManager->EndDrawing(); // Overlay container is rendered to a different buffer - if( overlayBuffer ) - compositor->SetBuffer( overlayBuffer ); - overlayManager->EndDrawing(); + if( m_overlayBuffer ) + m_compositor->SetBuffer( m_overlayBuffer ); + + m_overlayManager->EndDrawing(); // Be sure that the framebuffer is not colorized (happens on specific GPU&drivers combinations) glColor4d( 1.0, 1.0, 1.0, 1.0 ); // Draw the remaining contents, blit the rendering targets to the screen, swap the buffers - compositor->DrawBuffer( mainBuffer ); + m_compositor->DrawBuffer( m_mainBuffer ); - if( overlayBuffer ) - compositor->DrawBuffer( overlayBuffer ); + if( m_overlayBuffer ) + m_compositor->DrawBuffer( m_overlayBuffer ); - compositor->Present(); + m_compositor->Present(); blitCursor(); SwapBuffers(); @@ -599,9 +599,9 @@ void OPENGL_GAL::lockContext( int aClientCookie ) { wxASSERT_MSG( !m_isContextLocked, "Context already locked." ); m_isContextLocked = true; - lockClientCookie = aClientCookie; + m_lockClientCookie = aClientCookie; - GL_CONTEXT_MANAGER::Get().LockCtx( glPrivContext, this ); + GL_CONTEXT_MANAGER::Get().LockCtx( m_glPrivContext, this ); } @@ -610,12 +610,12 @@ void OPENGL_GAL::unlockContext( int aClientCookie ) wxASSERT_MSG( m_isContextLocked, "Context not locked. A GAL_CONTEXT_LOCKER RAII object must " "be stacked rather than making separate lock/unlock calls." ); - wxASSERT_MSG( lockClientCookie == aClientCookie, "Context was locked by a different client. " - "Should not be possible with RAII objects." ); + wxASSERT_MSG( m_lockClientCookie == aClientCookie, "Context was locked by a different client. " + "Should not be possible with RAII objects." ); m_isContextLocked = false; - GL_CONTEXT_MANAGER::Get().UnlockCtx( glPrivContext ); + GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glPrivContext ); } @@ -628,25 +628,25 @@ void OPENGL_GAL::beginUpdate() "Other update routines will expect everything to be initialized " "which will not be the case." ); - if( !isInitialized ) + if( !m_isInitialized ) init(); - cachedManager->Map(); + m_cachedManager->Map(); } void OPENGL_GAL::endUpdate() { - if( !isInitialized ) + if( !m_isInitialized ) return; - cachedManager->Unmap(); + m_cachedManager->Unmap(); } void OPENGL_GAL::DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) { - currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ); + m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, m_strokeColor.a ); drawLineQuad( aStartPoint, aEndPoint ); } @@ -672,9 +672,9 @@ void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndP return; } - if( isFillEnabled || aWidth == 1.0 ) + if( m_isFillEnabled || aWidth == 1.0 ) { - currentManager->Color( fillColor.r, fillColor.g, fillColor.b, fillColor.a ); + m_currentManager->Color( m_fillColor.r, m_fillColor.g, m_fillColor.b, m_fillColor.a ); SetLineWidth( aWidth ); drawLineQuad( aStartPoint, aEndPoint ); @@ -685,12 +685,13 @@ void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndP // Outlined tracks SetLineWidth( 1.0 ); - currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ); + m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, + m_strokeColor.a ); Save(); - currentManager->Translate( aStartPoint.x, aStartPoint.y, 0.0 ); - currentManager->Rotate( lineAngle, 0.0f, 0.0f, 1.0f ); + m_currentManager->Translate( aStartPoint.x, aStartPoint.y, 0.0 ); + m_currentManager->Rotate( lineAngle, 0.0f, 0.0f, 1.0f ); drawLineQuad( VECTOR2D( 0.0, aWidth / 2.0 ), VECTOR2D( lineLength, aWidth / 2.0 ) ); @@ -707,10 +708,10 @@ void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndP void OPENGL_GAL::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ) { - if( isFillEnabled ) + if( m_isFillEnabled ) { - currentManager->Reserve( 3 ); - currentManager->Color( fillColor.r, fillColor.g, fillColor.b, fillColor.a ); + m_currentManager->Reserve( 3 ); + m_currentManager->Color( m_fillColor.r, m_fillColor.g, m_fillColor.b, m_fillColor.a ); /* Draw a triangle that contains the circle, then shade it leaving only the circle. * Parameters given to Shader() are indices of the triangle's vertices @@ -722,19 +723,20 @@ void OPENGL_GAL::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ) * //\\ * v0 /_\/_\ v1 */ - currentManager->Shader( SHADER_FILLED_CIRCLE, 1.0, aRadius ); - currentManager->Vertex( aCenterPoint.x, aCenterPoint.y, layerDepth ); + m_currentManager->Shader( SHADER_FILLED_CIRCLE, 1.0, aRadius ); + m_currentManager->Vertex( aCenterPoint.x, aCenterPoint.y, m_layerDepth ); - currentManager->Shader( SHADER_FILLED_CIRCLE, 2.0, aRadius ); - currentManager->Vertex( aCenterPoint.x, aCenterPoint.y, layerDepth ); + m_currentManager->Shader( SHADER_FILLED_CIRCLE, 2.0, aRadius ); + m_currentManager->Vertex( aCenterPoint.x, aCenterPoint.y, m_layerDepth ); - currentManager->Shader( SHADER_FILLED_CIRCLE, 3.0, aRadius ); - currentManager->Vertex( aCenterPoint.x, aCenterPoint.y, layerDepth ); + m_currentManager->Shader( SHADER_FILLED_CIRCLE, 3.0, aRadius ); + m_currentManager->Vertex( aCenterPoint.x, aCenterPoint.y, m_layerDepth ); } - if( isStrokeEnabled ) + if( m_isStrokeEnabled ) { - currentManager->Reserve( 3 ); - currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ); + m_currentManager->Reserve( 3 ); + m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, + m_strokeColor.a ); /* Draw a triangle that contains the circle, then shade it leaving only the circle. * Parameters given to Shader() are indices of the triangle's vertices @@ -746,17 +748,17 @@ void OPENGL_GAL::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ) * //\\ * v0 /_\/_\ v1 */ - currentManager->Shader( SHADER_STROKED_CIRCLE, 1.0, aRadius, lineWidth ); - currentManager->Vertex( aCenterPoint.x, // v0 - aCenterPoint.y, layerDepth ); + m_currentManager->Shader( SHADER_STROKED_CIRCLE, 1.0, aRadius, m_lineWidth ); + m_currentManager->Vertex( aCenterPoint.x, // v0 + aCenterPoint.y, m_layerDepth ); - currentManager->Shader( SHADER_STROKED_CIRCLE, 2.0, aRadius, lineWidth ); - currentManager->Vertex( aCenterPoint.x, // v1 - aCenterPoint.y, layerDepth ); + m_currentManager->Shader( SHADER_STROKED_CIRCLE, 2.0, aRadius, m_lineWidth ); + m_currentManager->Vertex( aCenterPoint.x, // v1 + aCenterPoint.y, m_layerDepth ); - currentManager->Shader( SHADER_STROKED_CIRCLE, 3.0, aRadius, lineWidth ); - currentManager->Vertex( aCenterPoint.x, aCenterPoint.y, // v2 - layerDepth ); + m_currentManager->Shader( SHADER_STROKED_CIRCLE, 3.0, aRadius, m_lineWidth ); + m_currentManager->Vertex( aCenterPoint.x, aCenterPoint.y, // v2 + m_layerDepth ); } } @@ -773,36 +775,37 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a const double alphaIncrement = calcAngleStep( aRadius ); Save(); - currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0 ); + m_currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0 ); - if( isFillEnabled ) + if( m_isFillEnabled ) { double alpha; - currentManager->Color( fillColor.r, fillColor.g, fillColor.b, fillColor.a ); - currentManager->Shader( SHADER_NONE ); + m_currentManager->Color( m_fillColor.r, m_fillColor.g, m_fillColor.b, m_fillColor.a ); + m_currentManager->Shader( SHADER_NONE ); // Triangle fan for( alpha = aStartAngle; ( alpha + alphaIncrement ) < aEndAngle; ) { - currentManager->Reserve( 3 ); - currentManager->Vertex( 0.0, 0.0, layerDepth ); - currentManager->Vertex( cos( alpha ) * aRadius, sin( alpha ) * aRadius, layerDepth ); + m_currentManager->Reserve( 3 ); + m_currentManager->Vertex( 0.0, 0.0, m_layerDepth ); + m_currentManager->Vertex( cos( alpha ) * aRadius, sin( alpha ) * aRadius, m_layerDepth ); alpha += alphaIncrement; - currentManager->Vertex( cos( alpha ) * aRadius, sin( alpha ) * aRadius, layerDepth ); + m_currentManager->Vertex( cos( alpha ) * aRadius, sin( alpha ) * aRadius, m_layerDepth ); } // The last missing triangle const VECTOR2D endPoint( cos( aEndAngle ) * aRadius, sin( aEndAngle ) * aRadius ); - currentManager->Reserve( 3 ); - currentManager->Vertex( 0.0, 0.0, layerDepth ); - currentManager->Vertex( cos( alpha ) * aRadius, sin( alpha ) * aRadius, layerDepth ); - currentManager->Vertex( endPoint.x, endPoint.y, layerDepth ); + m_currentManager->Reserve( 3 ); + m_currentManager->Vertex( 0.0, 0.0, m_layerDepth ); + m_currentManager->Vertex( cos( alpha ) * aRadius, sin( alpha ) * aRadius, m_layerDepth ); + m_currentManager->Vertex( endPoint.x, endPoint.y, m_layerDepth ); } - if( isStrokeEnabled ) + if( m_isStrokeEnabled ) { - currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ); + m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, + m_strokeColor.a ); VECTOR2D p( cos( aStartAngle ) * aRadius, sin( aStartAngle ) * aRadius ); double alpha; @@ -857,11 +860,12 @@ void OPENGL_GAL::DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius, d alphaIncrement = ( aEndAngle - aStartAngle ) / seg_count; Save(); - currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0 ); + m_currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0 ); - if( isStrokeEnabled ) + if( m_isStrokeEnabled ) { - currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ); + m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, + m_strokeColor.a ); double width = aWidth / 2.0; VECTOR2D startPoint( cos( aStartAngle ) * aRadius, sin( aStartAngle ) * aRadius ); @@ -905,9 +909,9 @@ void OPENGL_GAL::DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius, d } } - if( isFillEnabled ) + if( m_isFillEnabled ) { - currentManager->Color( fillColor.r, fillColor.g, fillColor.b, fillColor.a ); + m_currentManager->Color( m_fillColor.r, m_fillColor.g, m_fillColor.b, m_fillColor.a ); SetLineWidth( aWidth ); VECTOR2D p( cos( aStartAngle ) * aRadius, sin( aStartAngle ) * aRadius ); @@ -940,25 +944,26 @@ void OPENGL_GAL::DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEn VECTOR2D diagonalPointB( aStartPoint.x, aEndPoint.y ); // Fill the rectangle - if( isFillEnabled ) + if( m_isFillEnabled ) { - currentManager->Reserve( 6 ); - currentManager->Shader( SHADER_NONE ); - currentManager->Color( fillColor.r, fillColor.g, fillColor.b, fillColor.a ); + m_currentManager->Reserve( 6 ); + m_currentManager->Shader( SHADER_NONE ); + m_currentManager->Color( m_fillColor.r, m_fillColor.g, m_fillColor.b, m_fillColor.a ); - currentManager->Vertex( aStartPoint.x, aStartPoint.y, layerDepth ); - currentManager->Vertex( diagonalPointA.x, diagonalPointA.y, layerDepth ); - currentManager->Vertex( aEndPoint.x, aEndPoint.y, layerDepth ); + m_currentManager->Vertex( aStartPoint.x, aStartPoint.y, m_layerDepth ); + m_currentManager->Vertex( diagonalPointA.x, diagonalPointA.y, m_layerDepth ); + m_currentManager->Vertex( aEndPoint.x, aEndPoint.y, m_layerDepth ); - currentManager->Vertex( aStartPoint.x, aStartPoint.y, layerDepth ); - currentManager->Vertex( aEndPoint.x, aEndPoint.y, layerDepth ); - currentManager->Vertex( diagonalPointB.x, diagonalPointB.y, layerDepth ); + m_currentManager->Vertex( aStartPoint.x, aStartPoint.y, m_layerDepth ); + m_currentManager->Vertex( aEndPoint.x, aEndPoint.y, m_layerDepth ); + m_currentManager->Vertex( diagonalPointB.x, diagonalPointB.y, m_layerDepth ); } // Stroke the outline - if( isStrokeEnabled ) + if( m_isStrokeEnabled ) { - currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ); + m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, + m_strokeColor.a ); std::deque pointList; pointList.push_back( aStartPoint ); @@ -1019,7 +1024,7 @@ void OPENGL_GAL::DrawPolygon( const std::deque& aPointList ) { *ptr++ = p.x; *ptr++ = p.y; - *ptr++ = layerDepth; + *ptr++ = m_layerDepth; } drawPolygon( points.get(), aPointList.size() ); @@ -1037,7 +1042,7 @@ void OPENGL_GAL::DrawPolygon( const VECTOR2D aPointList[], int aListSize ) { *target++ = src->x; *target++ = src->y; - *target++ = layerDepth; + *target++ = m_layerDepth; ++src; } @@ -1047,10 +1052,10 @@ void OPENGL_GAL::DrawPolygon( const VECTOR2D aPointList[], int aListSize ) void OPENGL_GAL::drawTriangulatedPolyset( const SHAPE_POLY_SET& aPolySet ) { - currentManager->Shader( SHADER_NONE ); - currentManager->Color( fillColor.r, fillColor.g, fillColor.b, fillColor.a ); + m_currentManager->Shader( SHADER_NONE ); + m_currentManager->Color( m_fillColor.r, m_fillColor.g, m_fillColor.b, m_fillColor.a ); - if( isFillEnabled ) + if( m_isFillEnabled ) { for( unsigned int j = 0; j < aPolySet.TriangulatedPolyCount(); ++j ) { @@ -1060,14 +1065,14 @@ void OPENGL_GAL::drawTriangulatedPolyset( const SHAPE_POLY_SET& aPolySet ) { VECTOR2I a, b, c; triPoly->GetTriangle( i, a, b, c ); - currentManager->Vertex( a.x, a.y, layerDepth ); - currentManager->Vertex( b.x, b.y, layerDepth ); - currentManager->Vertex( c.x, c.y, layerDepth ); + m_currentManager->Vertex( a.x, a.y, m_layerDepth ); + m_currentManager->Vertex( b.x, b.y, m_layerDepth ); + m_currentManager->Vertex( c.x, c.y, m_layerDepth ); } } } - if( isStrokeEnabled ) + if( m_isStrokeEnabled ) { for( int j = 0; j < aPolySet.OutlineCount(); ++j ) { @@ -1082,10 +1087,10 @@ void OPENGL_GAL::drawTriangulatedPolyset( const SHAPE_POLY_SET& aPolySet ) if( ADVANCED_CFG::GetCfg().m_DrawTriangulationOutlines ) { - auto oldStrokeColor = strokeColor; - double oldLayerDepth = layerDepth; + COLOR4D oldStrokeColor = m_strokeColor; + double oldLayerDepth = m_layerDepth; - SetLayerDepth( layerDepth - 1 ); + SetLayerDepth( m_layerDepth - 1 ); SetStrokeColor( COLOR4D( 0.0, 1.0, 0.2, 1.0 ) ); for( unsigned int j = 0; j < aPolySet.TriangulatedPolyCount(); ++j ) @@ -1137,7 +1142,7 @@ void OPENGL_GAL::DrawPolygon( const SHAPE_LINE_CHAIN& aPolygon ) const VECTOR2I& p = aPolygon.CPoint( i ); *ptr++ = p.x; *ptr++ = p.y; - *ptr++ = layerDepth; + *ptr++ = m_layerDepth; } drawPolygon( points.get(), pointCount ); @@ -1166,18 +1171,18 @@ void OPENGL_GAL::DrawCurve( const VECTOR2D& aStartPoint, const VECTOR2D& aContro void OPENGL_GAL::DrawBitmap( const BITMAP_BASE& aBitmap ) { // We have to calculate the pixel size in users units to draw the image. - // worldUnitLength is a factor used for converting IU to inches - double scale = 1.0 / ( aBitmap.GetPPI() * worldUnitLength ); + // m_worldUnitLength is a factor used for converting IU to inches + double scale = 1.0 / ( aBitmap.GetPPI() * m_worldUnitLength ); double w = (double) aBitmap.GetSizePixels().x * scale; double h = (double) aBitmap.GetSizePixels().y * scale; - auto xform = currentManager->GetTransformation(); + auto xform = m_currentManager->GetTransformation(); glm::vec4 v0 = xform * glm::vec4( -w / 2, -h / 2, 0.0, 0.0 ); glm::vec4 v1 = xform * glm::vec4( w / 2, h / 2, 0.0, 0.0 ); glm::vec4 trans = xform[3]; - auto texture_id = bitmapCache->RequestBitmap( &aBitmap ); + auto texture_id = m_bitmapCache->RequestBitmap( &aBitmap ); if( !glIsTexture( texture_id ) ) // ensure the bitmap texture is still valid return; @@ -1195,16 +1200,16 @@ void OPENGL_GAL::DrawBitmap( const BITMAP_BASE& aBitmap ) glBegin( GL_QUADS ); glColor4f( 1.0, 1.0, 1.0, 1.0 ); glTexCoord2f( 0.0, 0.0 ); - glVertex3f( v0.x, v0.y, layerDepth ); + glVertex3f( v0.x, v0.y, m_layerDepth ); glColor4f( 1.0, 1.0, 1.0, 1.0 ); glTexCoord2f( 1.0, 0.0 ); - glVertex3f( v1.x, v0.y, layerDepth ); + glVertex3f( v1.x, v0.y, m_layerDepth ); glColor4f( 1.0, 1.0, 1.0, 1.0 ); glTexCoord2f( 1.0, 1.0 ); - glVertex3f( v1.x, v1.y, layerDepth ); + glVertex3f( v1.x, v1.y, m_layerDepth ); glColor4f( 1.0, 1.0, 1.0, 1.0 ); glTexCoord2f( 0.0, 1.0 ); - glVertex3f( v0.x, v1.y, layerDepth ); + glVertex3f( v0.x, v1.y, m_layerDepth ); glEnd(); SetTarget( oldTarget ); @@ -1239,15 +1244,15 @@ void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2D& aPosition, Save(); - currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ); - currentManager->Translate( aPosition.x, aPosition.y, layerDepth ); - currentManager->Rotate( aRotationAngle, 0.0f, 0.0f, -1.0f ); + m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, m_strokeColor.a ); + m_currentManager->Translate( aPosition.x, aPosition.y, m_layerDepth ); + m_currentManager->Rotate( aRotationAngle, 0.0f, 0.0f, -1.0f ); - double sx = SCALE * ( globalFlipX ? -1.0 : 1.0 ); - double sy = SCALE * ( globalFlipY ? -1.0 : 1.0 ); + double sx = SCALE * ( m_globalFlipX ? -1.0 : 1.0 ); + double sy = SCALE * ( m_globalFlipY ? -1.0 : 1.0 ); - currentManager->Scale( sx, sy, 0 ); - currentManager->Translate( 0, -commonOffset, 0 ); + m_currentManager->Scale( sx, sy, 0 ); + m_currentManager->Translate( 0, -commonOffset, 0 ); switch( GetHorizontalJustify() ) { @@ -1328,7 +1333,7 @@ void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2D& aPosition, } // Handle the case when overbar is active till the end of the drawn text - currentManager->Translate( 0, commonOffset, 0 ); + m_currentManager->Translate( 0, commonOffset, 0 ); if( overbar && overbarLength > 0 ) drawBitmapOverbar( overbarLength, overbarHeight ); @@ -1340,58 +1345,58 @@ void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2D& aPosition, void OPENGL_GAL::DrawGrid() { SetTarget( TARGET_NONCACHED ); - compositor->SetBuffer( mainBuffer ); + m_compositor->SetBuffer( m_mainBuffer ); - nonCachedManager->EnableDepthTest( false ); + m_nonCachedManager->EnableDepthTest( false ); // sub-pixel lines all render the same - float minorLineWidth = - std::fmax( 1.0f, gridLineWidth ) * getWorldPixelSize() / GetScaleFactor(); + float minorLineWidth = std::fmax( 1.0f, + m_gridLineWidth ) * getWorldPixelSize() / GetScaleFactor(); float majorLineWidth = minorLineWidth * 2.0f; // Draw the axis and grid // For the drawing the start points, end points and increments have // to be calculated in world coordinates - VECTOR2D worldStartPoint = screenWorldMatrix * VECTOR2D( 0.0, 0.0 ); - VECTOR2D worldEndPoint = screenWorldMatrix * VECTOR2D( screenSize ); + VECTOR2D worldStartPoint = m_screenWorldMatrix * VECTOR2D( 0.0, 0.0 ); + VECTOR2D worldEndPoint = m_screenWorldMatrix * VECTOR2D( m_screenSize ); // Draw axes if desired - if( axesEnabled ) + if( m_axesEnabled ) { SetLineWidth( minorLineWidth ); - SetStrokeColor( axesColor ); + SetStrokeColor( m_axesColor ); DrawLine( VECTOR2D( worldStartPoint.x, 0 ), VECTOR2D( worldEndPoint.x, 0 ) ); DrawLine( VECTOR2D( 0, worldStartPoint.y ), VECTOR2D( 0, worldEndPoint.y ) ); } // force flush - nonCachedManager->EndDrawing(); + m_nonCachedManager->EndDrawing(); - if( !gridVisibility || gridSize.x == 0 || gridSize.y == 0 ) + if( !m_gridVisibility || m_gridSize.x == 0 || m_gridSize.y == 0 ) return; - VECTOR2D gridScreenSize( gridSize ); + VECTOR2D gridScreenSize( m_gridSize ); - double gridThreshold = computeMinGridSpacing() / worldScale; + double gridThreshold = computeMinGridSpacing() / m_worldScale; - if( gridStyle == GRID_STYLE::SMALL_CROSS ) + if( m_gridStyle == GRID_STYLE::SMALL_CROSS ) gridThreshold *= 2.0; // If we cannot display the grid density, scale down by a tick size and // try again. Eventually, we get some representation of the grid while( std::min( gridScreenSize.x, gridScreenSize.y ) <= gridThreshold ) { - gridScreenSize = gridScreenSize * static_cast( gridTick ); + gridScreenSize = gridScreenSize * static_cast( m_gridTick ); } // Compute grid starting and ending indexes to draw grid points on the // visible screen area - // Note: later any point coordinate will be offsetted by gridOrigin - int gridStartX = KiROUND( ( worldStartPoint.x - gridOrigin.x ) / gridScreenSize.x ); - int gridEndX = KiROUND( ( worldEndPoint.x - gridOrigin.x ) / gridScreenSize.x ); - int gridStartY = KiROUND( ( worldStartPoint.y - gridOrigin.y ) / gridScreenSize.y ); - int gridEndY = KiROUND( ( worldEndPoint.y - gridOrigin.y ) / gridScreenSize.y ); + // Note: later any point coordinate will be offsetted by m_gridOrigin + int gridStartX = KiROUND( ( worldStartPoint.x - m_gridOrigin.x ) / gridScreenSize.x ); + int gridEndX = KiROUND( ( worldEndPoint.x - m_gridOrigin.x ) / gridScreenSize.x ); + int gridStartY = KiROUND( ( worldStartPoint.y - m_gridOrigin.y ) / gridScreenSize.y ); + int gridEndY = KiROUND( ( worldEndPoint.y - m_gridOrigin.y ) / gridScreenSize.y ); // Ensure start coordinate > end coordinate SWAP( gridStartX, >, gridEndX ); @@ -1406,7 +1411,7 @@ void OPENGL_GAL::DrawGrid() glDisable( GL_DEPTH_TEST ); glDisable( GL_TEXTURE_2D ); - if( gridStyle == GRID_STYLE::DOTS ) + if( m_gridStyle == GRID_STYLE::DOTS ) { glEnable( GL_STENCIL_TEST ); glStencilFunc( GL_ALWAYS, 1, 1 ); @@ -1416,78 +1421,78 @@ void OPENGL_GAL::DrawGrid() } else { - glColor4d( gridColor.r, gridColor.g, gridColor.b, gridColor.a ); - SetStrokeColor( gridColor ); + glColor4d( m_gridColor.r, m_gridColor.g, m_gridColor.b, m_gridColor.a ); + SetStrokeColor( m_gridColor ); } - if( gridStyle == GRID_STYLE::SMALL_CROSS ) + if( m_gridStyle == GRID_STYLE::SMALL_CROSS ) { // Vertical positions for( int j = gridStartY; j <= gridEndY; j++ ) { - bool tickY = ( j % gridTick == 0 ); - const double posY = j * gridScreenSize.y + gridOrigin.y; + bool tickY = ( j % m_gridTick == 0 ); + const double posY = j * gridScreenSize.y + m_gridOrigin.y; // Horizontal positions for( int i = gridStartX; i <= gridEndX; i++ ) { - bool tickX = ( i % gridTick == 0 ); + bool tickX = ( i % m_gridTick == 0 ); SetLineWidth( ( ( tickX && tickY ) ? majorLineWidth : minorLineWidth ) ); auto lineLen = 2.0 * GetLineWidth(); - auto posX = i * gridScreenSize.x + gridOrigin.x; + auto posX = i * gridScreenSize.x + m_gridOrigin.x; DrawLine( VECTOR2D( posX - lineLen, posY ), VECTOR2D( posX + lineLen, posY ) ); DrawLine( VECTOR2D( posX, posY - lineLen ), VECTOR2D( posX, posY + lineLen ) ); } } - nonCachedManager->EndDrawing(); + m_nonCachedManager->EndDrawing(); } else { // Vertical lines for( int j = gridStartY; j <= gridEndY; j++ ) { - const double y = j * gridScreenSize.y + gridOrigin.y; + const double y = j * gridScreenSize.y + m_gridOrigin.y; // If axes are drawn, skip the lines that would cover them - if( axesEnabled && y == 0.0 ) + if( m_axesEnabled && y == 0.0 ) continue; - SetLineWidth( ( j % gridTick == 0 ) ? majorLineWidth : minorLineWidth ); - VECTOR2D a( gridStartX * gridScreenSize.x + gridOrigin.x, y ); - VECTOR2D b( gridEndX * gridScreenSize.x + gridOrigin.x, y ); + SetLineWidth( ( j % m_gridTick == 0 ) ? majorLineWidth : minorLineWidth ); + VECTOR2D a( gridStartX * gridScreenSize.x + m_gridOrigin.x, y ); + VECTOR2D b( gridEndX * gridScreenSize.x + m_gridOrigin.x, y ); DrawLine( a, b ); } - nonCachedManager->EndDrawing(); + m_nonCachedManager->EndDrawing(); - if( gridStyle == GRID_STYLE::DOTS ) + if( m_gridStyle == GRID_STYLE::DOTS ) { glStencilFunc( GL_NOTEQUAL, 0, 1 ); - glColor4d( gridColor.r, gridColor.g, gridColor.b, gridColor.a ); - SetStrokeColor( gridColor ); + glColor4d( m_gridColor.r, m_gridColor.g, m_gridColor.b, m_gridColor.a ); + SetStrokeColor( m_gridColor ); } // Horizontal lines for( int i = gridStartX; i <= gridEndX; i++ ) { - const double x = i * gridScreenSize.x + gridOrigin.x; + const double x = i * gridScreenSize.x + m_gridOrigin.x; // If axes are drawn, skip the lines that would cover them - if( axesEnabled && x == 0.0 ) + if( m_axesEnabled && x == 0.0 ) continue; - SetLineWidth( ( i % gridTick == 0 ) ? majorLineWidth : minorLineWidth ); - VECTOR2D a( x, gridStartY * gridScreenSize.y + gridOrigin.y ); - VECTOR2D b( x, gridEndY * gridScreenSize.y + gridOrigin.y ); + SetLineWidth( ( i % m_gridTick == 0 ) ? majorLineWidth : minorLineWidth ); + VECTOR2D a( x, gridStartY * gridScreenSize.y + m_gridOrigin.y ); + VECTOR2D b( x, gridEndY * gridScreenSize.y + m_gridOrigin.y ); DrawLine( a, b ); } - nonCachedManager->EndDrawing(); + m_nonCachedManager->EndDrawing(); - if( gridStyle == GRID_STYLE::DOTS ) + if( m_gridStyle == GRID_STYLE::DOTS ) glDisable( GL_STENCIL_TEST ); } @@ -1498,12 +1503,12 @@ void OPENGL_GAL::DrawGrid() void OPENGL_GAL::ResizeScreen( int aWidth, int aHeight ) { - screenSize = VECTOR2I( aWidth, aHeight ); + m_screenSize = VECTOR2I( aWidth, aHeight ); // Resize framebuffers const float scaleFactor = GetScaleFactor(); - compositor->Resize( aWidth * scaleFactor, aHeight * scaleFactor ); - isFramebufferInitialized = false; + m_compositor->Resize( aWidth * scaleFactor, aHeight * scaleFactor ); + m_isFramebufferInitialized = false; wxGLCanvas::SetSize( aWidth, aHeight ); } @@ -1529,7 +1534,7 @@ void OPENGL_GAL::Flush() void OPENGL_GAL::ClearScreen() { // Clear screen - compositor->SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING ); + m_compositor->SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING ); // NOTE: Black used here instead of m_clearColor; it will be composited later glClearColor( 0, 0, 0, 1 ); @@ -1557,41 +1562,41 @@ void OPENGL_GAL::Transform( const MATRIX3x3D& aTransformation ) void OPENGL_GAL::Rotate( double aAngle ) { - currentManager->Rotate( aAngle, 0.0f, 0.0f, 1.0f ); + m_currentManager->Rotate( aAngle, 0.0f, 0.0f, 1.0f ); } void OPENGL_GAL::Translate( const VECTOR2D& aVector ) { - currentManager->Translate( aVector.x, aVector.y, 0.0f ); + m_currentManager->Translate( aVector.x, aVector.y, 0.0f ); } void OPENGL_GAL::Scale( const VECTOR2D& aScale ) { - currentManager->Scale( aScale.x, aScale.y, 0.0f ); + m_currentManager->Scale( aScale.x, aScale.y, 0.0f ); } void OPENGL_GAL::Save() { - currentManager->PushMatrix(); + m_currentManager->PushMatrix(); } void OPENGL_GAL::Restore() { - currentManager->PopMatrix(); + m_currentManager->PopMatrix(); } int OPENGL_GAL::BeginGroup() { - isGrouping = true; + m_isGrouping = true; - std::shared_ptr newItem = std::make_shared( *cachedManager ); + std::shared_ptr newItem = std::make_shared( *m_cachedManager ); int groupNumber = getNewGroupNumber(); - groups.insert( std::make_pair( groupNumber, newItem ) ); + m_groups.insert( std::make_pair( groupNumber, newItem ) ); return groupNumber; } @@ -1599,47 +1604,47 @@ int OPENGL_GAL::BeginGroup() void OPENGL_GAL::EndGroup() { - cachedManager->FinishItem(); - isGrouping = false; + m_cachedManager->FinishItem(); + m_isGrouping = false; } void OPENGL_GAL::DrawGroup( int aGroupNumber ) { - if( groups[aGroupNumber] ) - cachedManager->DrawItem( *groups[aGroupNumber] ); + if( m_groups[aGroupNumber] ) + m_cachedManager->DrawItem( *m_groups[aGroupNumber] ); } void OPENGL_GAL::ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor ) { - if( groups[aGroupNumber] ) - cachedManager->ChangeItemColor( *groups[aGroupNumber], aNewColor ); + if( m_groups[aGroupNumber] ) + m_cachedManager->ChangeItemColor( *m_groups[aGroupNumber], aNewColor ); } void OPENGL_GAL::ChangeGroupDepth( int aGroupNumber, int aDepth ) { - if( groups[aGroupNumber] ) - cachedManager->ChangeItemDepth( *groups[aGroupNumber], aDepth ); + if( m_groups[aGroupNumber] ) + m_cachedManager->ChangeItemDepth( *m_groups[aGroupNumber], aDepth ); } void OPENGL_GAL::DeleteGroup( int aGroupNumber ) { // Frees memory in the container as well - groups.erase( aGroupNumber ); + m_groups.erase( aGroupNumber ); } void OPENGL_GAL::ClearCache() { - bitmapCache = std::make_unique(); + m_bitmapCache = std::make_unique(); - groups.clear(); + m_groups.clear(); - if( isInitialized ) - cachedManager->Clear(); + if( m_isInitialized ) + m_cachedManager->Clear(); } @@ -1648,25 +1653,25 @@ void OPENGL_GAL::SetTarget( RENDER_TARGET aTarget ) switch( aTarget ) { default: - case TARGET_CACHED: currentManager = cachedManager; break; - case TARGET_NONCACHED: currentManager = nonCachedManager; break; - case TARGET_OVERLAY: currentManager = overlayManager; break; + case TARGET_CACHED: m_currentManager = m_cachedManager; break; + case TARGET_NONCACHED: m_currentManager = m_nonCachedManager; break; + case TARGET_OVERLAY: m_currentManager = m_overlayManager; break; } - currentTarget = aTarget; + m_currentTarget = aTarget; } RENDER_TARGET OPENGL_GAL::GetTarget() const { - return currentTarget; + return m_currentTarget; } void OPENGL_GAL::ClearTarget( RENDER_TARGET aTarget ) { // Save the current state - unsigned int oldTarget = compositor->GetBuffer(); + unsigned int oldTarget = m_compositor->GetBuffer(); switch( aTarget ) { @@ -1674,23 +1679,23 @@ void OPENGL_GAL::ClearTarget( RENDER_TARGET aTarget ) default: case TARGET_CACHED: case TARGET_NONCACHED: - compositor->SetBuffer( mainBuffer ); + m_compositor->SetBuffer( m_mainBuffer ); break; case TARGET_OVERLAY: - if( overlayBuffer ) - compositor->SetBuffer( overlayBuffer ); + if( m_overlayBuffer ) + m_compositor->SetBuffer( m_overlayBuffer ); break; } if( aTarget != TARGET_OVERLAY ) - compositor->ClearBuffer( m_clearColor ); - else if( overlayBuffer ) - compositor->ClearBuffer( COLOR4D::BLACK ); + m_compositor->ClearBuffer( m_clearColor ); + else if( m_overlayBuffer ) + m_compositor->ClearBuffer( COLOR4D::BLACK ); // Restore the previous state - compositor->SetBuffer( oldTarget ); + m_compositor->SetBuffer( oldTarget ); } @@ -1701,8 +1706,7 @@ bool OPENGL_GAL::HasTarget( RENDER_TARGET aTarget ) default: case TARGET_CACHED: case TARGET_NONCACHED: return true; - - case TARGET_OVERLAY: return ( overlayBuffer != 0 ); + case TARGET_OVERLAY: return ( m_overlayBuffer != 0 ); } } @@ -1711,9 +1715,9 @@ void OPENGL_GAL::DrawCursor( const VECTOR2D& aCursorPosition ) { // Now we should only store the position of the mouse cursor // The real drawing routines are in blitCursor() - //VECTOR2D screenCursor = worldScreenMatrix * aCursorPosition; - //cursorPosition = screenWorldMatrix * VECTOR2D( screenCursor.x, screenCursor.y ); - cursorPosition = aCursorPosition; + //VECTOR2D screenCursor = m_worldScreenMatrix * aCursorPosition; + //m_cursorPosition = m_screenWorldMatrix * VECTOR2D( screenCursor.x, screenCursor.y ); + m_cursorPosition = aCursorPosition; } @@ -1734,46 +1738,47 @@ void OPENGL_GAL::drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2D& aEnd * dots mark triangles' hypotenuses */ - auto v1 = currentManager->GetTransformation() + auto v1 = m_currentManager->GetTransformation() * glm::vec4( aStartPoint.x, aStartPoint.y, 0.0, 0.0 ); - auto v2 = currentManager->GetTransformation() * glm::vec4( aEndPoint.x, aEndPoint.y, 0.0, 0.0 ); + auto v2 = m_currentManager->GetTransformation() + * glm::vec4( aEndPoint.x, aEndPoint.y, 0.0, 0.0 ); VECTOR2D vs( v2.x - v1.x, v2.y - v1.y ); - currentManager->Reserve( 6 ); + m_currentManager->Reserve( 6 ); // Line width is maintained by the vertex shader - currentManager->Shader( SHADER_LINE_A, lineWidth, vs.x, vs.y ); - currentManager->Vertex( aStartPoint, layerDepth ); + m_currentManager->Shader( SHADER_LINE_A, m_lineWidth, vs.x, vs.y ); + m_currentManager->Vertex( aStartPoint, m_layerDepth ); - currentManager->Shader( SHADER_LINE_B, lineWidth, vs.x, vs.y ); - currentManager->Vertex( aStartPoint, layerDepth ); + m_currentManager->Shader( SHADER_LINE_B, m_lineWidth, vs.x, vs.y ); + m_currentManager->Vertex( aStartPoint, m_layerDepth ); - currentManager->Shader( SHADER_LINE_C, lineWidth, vs.x, vs.y ); - currentManager->Vertex( aEndPoint, layerDepth ); + m_currentManager->Shader( SHADER_LINE_C, m_lineWidth, vs.x, vs.y ); + m_currentManager->Vertex( aEndPoint, m_layerDepth ); - currentManager->Shader( SHADER_LINE_D, lineWidth, vs.x, vs.y ); - currentManager->Vertex( aEndPoint, layerDepth ); + m_currentManager->Shader( SHADER_LINE_D, m_lineWidth, vs.x, vs.y ); + m_currentManager->Vertex( aEndPoint, m_layerDepth ); - currentManager->Shader( SHADER_LINE_E, lineWidth, vs.x, vs.y ); - currentManager->Vertex( aEndPoint, layerDepth ); + m_currentManager->Shader( SHADER_LINE_E, m_lineWidth, vs.x, vs.y ); + m_currentManager->Vertex( aEndPoint, m_layerDepth ); - currentManager->Shader( SHADER_LINE_F, lineWidth, vs.x, vs.y ); - currentManager->Vertex( aStartPoint, layerDepth ); + m_currentManager->Shader( SHADER_LINE_F, m_lineWidth, vs.x, vs.y ); + m_currentManager->Vertex( aStartPoint, m_layerDepth ); } void OPENGL_GAL::drawSemiCircle( const VECTOR2D& aCenterPoint, double aRadius, double aAngle ) { - if( isFillEnabled ) + if( m_isFillEnabled ) { - currentManager->Color( fillColor.r, fillColor.g, fillColor.b, fillColor.a ); + m_currentManager->Color( m_fillColor.r, m_fillColor.g, m_fillColor.b, m_fillColor.a ); drawFilledSemiCircle( aCenterPoint, aRadius, aAngle ); } - if( isStrokeEnabled ) + if( m_isStrokeEnabled ) { - currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ); + m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, m_strokeColor.a ); drawStrokedSemiCircle( aCenterPoint, aRadius, aAngle ); } } @@ -1783,9 +1788,9 @@ void OPENGL_GAL::drawFilledSemiCircle( const VECTOR2D& aCenterPoint, double aRad { Save(); - currentManager->Reserve( 3 ); - currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0f ); - currentManager->Rotate( aAngle, 0.0f, 0.0f, 1.0f ); + m_currentManager->Reserve( 3 ); + m_currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0f ); + m_currentManager->Rotate( aAngle, 0.0f, 0.0f, 1.0f ); /* Draw a triangle that contains the semicircle, then shade it to leave only * the semicircle. Parameters given to Shader() are indices of the triangle's vertices @@ -1796,14 +1801,14 @@ void OPENGL_GAL::drawFilledSemiCircle( const VECTOR2D& aCenterPoint, double aRad * /__\ * v0 //__\\ v1 */ - currentManager->Shader( SHADER_FILLED_CIRCLE, 4.0f ); - currentManager->Vertex( -aRadius * 3.0f / sqrt( 3.0f ), 0.0f, layerDepth ); // v0 + m_currentManager->Shader( SHADER_FILLED_CIRCLE, 4.0f ); + m_currentManager->Vertex( -aRadius * 3.0f / sqrt( 3.0f ), 0.0f, m_layerDepth ); // v0 - currentManager->Shader( SHADER_FILLED_CIRCLE, 5.0f ); - currentManager->Vertex( aRadius * 3.0f / sqrt( 3.0f ), 0.0f, layerDepth ); // v1 + m_currentManager->Shader( SHADER_FILLED_CIRCLE, 5.0f ); + m_currentManager->Vertex( aRadius * 3.0f / sqrt( 3.0f ), 0.0f, m_layerDepth ); // v1 - currentManager->Shader( SHADER_FILLED_CIRCLE, 6.0f ); - currentManager->Vertex( 0.0f, aRadius * 2.0f, layerDepth ); // v2 + m_currentManager->Shader( SHADER_FILLED_CIRCLE, 6.0f ); + m_currentManager->Vertex( 0.0f, aRadius * 2.0f, m_layerDepth ); // v2 Restore(); } @@ -1812,13 +1817,13 @@ void OPENGL_GAL::drawFilledSemiCircle( const VECTOR2D& aCenterPoint, double aRad void OPENGL_GAL::drawStrokedSemiCircle( const VECTOR2D& aCenterPoint, double aRadius, double aAngle ) { - double outerRadius = aRadius + ( lineWidth / 2 ); + double outerRadius = aRadius + ( m_lineWidth / 2 ); Save(); - currentManager->Reserve( 3 ); - currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0f ); - currentManager->Rotate( aAngle, 0.0f, 0.0f, 1.0f ); + m_currentManager->Reserve( 3 ); + m_currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0f ); + m_currentManager->Rotate( aAngle, 0.0f, 0.0f, 1.0f ); /* Draw a triangle that contains the semicircle, then shade it to leave only * the semicircle. Parameters given to Shader() are indices of the triangle's vertices @@ -1830,14 +1835,14 @@ void OPENGL_GAL::drawStrokedSemiCircle( const VECTOR2D& aCenterPoint, double aRa * /__\ * v0 //__\\ v1 */ - currentManager->Shader( SHADER_STROKED_CIRCLE, 4.0f, aRadius, lineWidth ); - currentManager->Vertex( -outerRadius * 3.0f / sqrt( 3.0f ), 0.0f, layerDepth ); // v0 + m_currentManager->Shader( SHADER_STROKED_CIRCLE, 4.0f, aRadius, m_lineWidth ); + m_currentManager->Vertex( -outerRadius * 3.0f / sqrt( 3.0f ), 0.0f, m_layerDepth ); // v0 - currentManager->Shader( SHADER_STROKED_CIRCLE, 5.0f, aRadius, lineWidth ); - currentManager->Vertex( outerRadius * 3.0f / sqrt( 3.0f ), 0.0f, layerDepth ); // v1 + m_currentManager->Shader( SHADER_STROKED_CIRCLE, 5.0f, aRadius, m_lineWidth ); + m_currentManager->Vertex( outerRadius * 3.0f / sqrt( 3.0f ), 0.0f, m_layerDepth ); // v1 - currentManager->Shader( SHADER_STROKED_CIRCLE, 6.0f, aRadius, lineWidth ); - currentManager->Vertex( 0.0f, outerRadius * 2.0f, layerDepth ); // v2 + m_currentManager->Shader( SHADER_STROKED_CIRCLE, 6.0f, aRadius, m_lineWidth ); + m_currentManager->Vertex( 0.0f, outerRadius * 2.0f, m_layerDepth ); // v2 Restore(); } @@ -1845,33 +1850,33 @@ void OPENGL_GAL::drawStrokedSemiCircle( const VECTOR2D& aCenterPoint, double aRa void OPENGL_GAL::drawPolygon( GLdouble* aPoints, int aPointCount ) { - if( isFillEnabled ) + if( m_isFillEnabled ) { - currentManager->Shader( SHADER_NONE ); - currentManager->Color( fillColor.r, fillColor.g, fillColor.b, fillColor.a ); + m_currentManager->Shader( SHADER_NONE ); + m_currentManager->Color( m_fillColor.r, m_fillColor.g, m_fillColor.b, m_fillColor.a ); // Any non convex polygon needs to be tesselated // for this purpose the GLU standard functions are used - TessParams params = { currentManager, tessIntersects }; - gluTessBeginPolygon( tesselator, ¶ms ); - gluTessBeginContour( tesselator ); + TessParams params = { m_currentManager, m_tessIntersects }; + gluTessBeginPolygon( m_tesselator, ¶ms ); + gluTessBeginContour( m_tesselator ); GLdouble* point = aPoints; for( int i = 0; i < aPointCount; ++i ) { - gluTessVertex( tesselator, point, point ); + gluTessVertex( m_tesselator, point, point ); point += 3; // 3 coordinates } - gluTessEndContour( tesselator ); - gluTessEndPolygon( tesselator ); + gluTessEndContour( m_tesselator ); + gluTessEndPolygon( m_tesselator ); // Free allocated intersecting points - tessIntersects.clear(); + m_tessIntersects.clear(); } - if( isStrokeEnabled ) + if( m_isStrokeEnabled ) { drawPolyline( [&]( int idx ) @@ -1887,7 +1892,7 @@ void OPENGL_GAL::drawPolyline( const std::function& aPointGette { wxCHECK( aPointCount >= 2, /* return */ ); - currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ); + m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, m_strokeColor.a ); int i; for( i = 1; i < aPointCount; ++i ) @@ -1941,7 +1946,7 @@ int OPENGL_GAL::drawBitmapChar( unsigned long aChar ) const float H = glyph->atlas_h - font_information.smooth_pixels * 2; const float B = 0; - currentManager->Reserve( 6 ); + m_currentManager->Reserve( 6 ); Translate( VECTOR2D( XOFF, YOFF ) ); /* Glyph: @@ -1952,24 +1957,24 @@ int OPENGL_GAL::drawBitmapChar( unsigned long aChar ) * +--+ * v2 v3 */ - currentManager->Shader( SHADER_FONT, X / TEX_X, ( Y + H ) / TEX_Y ); - currentManager->Vertex( -B, -B, 0 ); // v0 + m_currentManager->Shader( SHADER_FONT, X / TEX_X, ( Y + H ) / TEX_Y ); + m_currentManager->Vertex( -B, -B, 0 ); // v0 - currentManager->Shader( SHADER_FONT, ( X + W ) / TEX_X, ( Y + H ) / TEX_Y ); - currentManager->Vertex( W + B, -B, 0 ); // v1 + m_currentManager->Shader( SHADER_FONT, ( X + W ) / TEX_X, ( Y + H ) / TEX_Y ); + m_currentManager->Vertex( W + B, -B, 0 ); // v1 - currentManager->Shader( SHADER_FONT, X / TEX_X, Y / TEX_Y ); - currentManager->Vertex( -B, H + B, 0 ); // v2 + m_currentManager->Shader( SHADER_FONT, X / TEX_X, Y / TEX_Y ); + m_currentManager->Vertex( -B, H + B, 0 ); // v2 - currentManager->Shader( SHADER_FONT, ( X + W ) / TEX_X, ( Y + H ) / TEX_Y ); - currentManager->Vertex( W + B, -B, 0 ); // v1 + m_currentManager->Shader( SHADER_FONT, ( X + W ) / TEX_X, ( Y + H ) / TEX_Y ); + m_currentManager->Vertex( W + B, -B, 0 ); // v1 - currentManager->Shader( SHADER_FONT, X / TEX_X, Y / TEX_Y ); - currentManager->Vertex( -B, H + B, 0 ); // v2 + m_currentManager->Shader( SHADER_FONT, X / TEX_X, Y / TEX_Y ); + m_currentManager->Vertex( -B, H + B, 0 ); // v2 - currentManager->Shader( SHADER_FONT, ( X + W ) / TEX_X, Y / TEX_Y ); - currentManager->Vertex( W + B, H + B, 0 ); // v3 + m_currentManager->Shader( SHADER_FONT, ( X + W ) / TEX_X, Y / TEX_Y ); + m_currentManager->Vertex( W + B, H + B, 0 ); // v3 Translate( VECTOR2D( -XOFF + glyph->advance, -YOFF ) ); @@ -1989,18 +1994,18 @@ void OPENGL_GAL::drawBitmapOverbar( double aLength, double aHeight ) Translate( VECTOR2D( -aLength, -aHeight - 1.5 * H ) ); - currentManager->Reserve( 6 ); - currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ); + m_currentManager->Reserve( 6 ); + m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, m_strokeColor.a ); - currentManager->Shader( 0 ); + m_currentManager->Shader( 0 ); - currentManager->Vertex( 0, 0, 0 ); // v0 - currentManager->Vertex( aLength, 0, 0 ); // v1 - currentManager->Vertex( 0, H, 0 ); // v2 + m_currentManager->Vertex( 0, 0, 0 ); // v0 + m_currentManager->Vertex( aLength, 0, 0 ); // v1 + m_currentManager->Vertex( 0, H, 0 ); // v2 - currentManager->Vertex( aLength, 0, 0 ); // v1 - currentManager->Vertex( 0, H, 0 ); // v2 - currentManager->Vertex( aLength, H, 0 ); // v3 + m_currentManager->Vertex( aLength, 0, 0 ); // v1 + m_currentManager->Vertex( 0, H, 0 ); // v2 + m_currentManager->Vertex( aLength, H, 0 ); // v3 Restore(); } @@ -2079,8 +2084,8 @@ void OPENGL_GAL::onPaint( wxPaintEvent& aEvent ) void OPENGL_GAL::skipMouseEvent( wxMouseEvent& aEvent ) { // Post the mouse event to the event listener registered in constructor, if any - if( mouseListener ) - wxPostEvent( mouseListener, aEvent ); + if( m_mouseListener ) + wxPostEvent( m_mouseListener, aEvent ); } @@ -2089,12 +2094,12 @@ void OPENGL_GAL::blitCursor() if( !IsCursorEnabled() ) return; - compositor->SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING ); + m_compositor->SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING ); - const int cursorSize = fullscreenCursor ? 8000 : 80; + const int cursorSize = m_fullscreenCursor ? 8000 : 80; - VECTOR2D cursorBegin = cursorPosition - cursorSize / ( 2 * worldScale ); - VECTOR2D cursorEnd = cursorPosition + cursorSize / ( 2 * worldScale ); + VECTOR2D cursorBegin = m_cursorPosition - cursorSize / ( 2 * m_worldScale ); + VECTOR2D cursorEnd = m_cursorPosition + cursorSize / ( 2 * m_worldScale ); VECTOR2D cursorCenter = ( cursorBegin + cursorEnd ) / 2; const COLOR4D cColor = getCursorColor(); @@ -2117,15 +2122,13 @@ void OPENGL_GAL::blitCursor() unsigned int OPENGL_GAL::getNewGroupNumber() { - wxASSERT_MSG( groups.size() < std::numeric_limits::max(), + wxASSERT_MSG( m_groups.size() < std::numeric_limits::max(), wxT( "There are no free slots to store a group" ) ); - while( groups.find( groupCounter ) != groups.end() ) - { - groupCounter++; - } + while( m_groups.find( m_groupCounter ) != m_groups.end() ) + m_groupCounter++; - return groupCounter++; + return m_groupCounter++; } @@ -2145,14 +2148,14 @@ void OPENGL_GAL::init() #endif /* wxCHECK_VERSION( 3, 0, 3 ) */ // Check correct initialization from the constructor - if( !glMainContext ) + if( !m_glMainContext ) throw std::runtime_error( "Could not create the main OpenGL context" ); - if( !glPrivContext ) + if( !m_glPrivContext ) throw std::runtime_error( "Could not create a private OpenGL context" ); - if( tesselator == NULL ) - throw std::runtime_error( "Could not create the tesselator" ); + if( m_tesselator == NULL ) + throw std::runtime_error( "Could not create the m_tesselator" ); // End initialzation checks GLenum err = glewInit(); @@ -2180,17 +2183,21 @@ void OPENGL_GAL::init() throw std::runtime_error( "Vertex buffer objects are not supported!" ); // Prepare shaders - if( !shader->IsLinked() - && !shader->LoadShaderFromStrings( SHADER_TYPE_VERTEX, - BUILTIN_SHADERS::kicad_vertex_shader ) ) + if( !m_shader->IsLinked() + && !m_shader->LoadShaderFromStrings( SHADER_TYPE_VERTEX, + BUILTIN_SHADERS::kicad_vertex_shader ) ) + { throw std::runtime_error( "Cannot compile vertex shader!" ); + } - if( !shader->IsLinked() - && !shader->LoadShaderFromStrings( SHADER_TYPE_FRAGMENT, - BUILTIN_SHADERS::kicad_fragment_shader ) ) + if( !m_shader->IsLinked() + && !m_shader->LoadShaderFromStrings( SHADER_TYPE_FRAGMENT, + BUILTIN_SHADERS::kicad_fragment_shader ) ) + { throw std::runtime_error( "Cannot compile fragment shader!" ); + } - if( !shader->IsLinked() && !shader->Link() ) + if( !m_shader->IsLinked() && !m_shader->Link() ) throw std::runtime_error( "Cannot link the shaders!" ); // Check if video card supports textures big enough to fit the font atlas @@ -2206,16 +2213,16 @@ void OPENGL_GAL::init() GL_UTILS::SetSwapInterval( -1 ); - cachedManager = new VERTEX_MANAGER( true ); - nonCachedManager = new VERTEX_MANAGER( false ); - overlayManager = new VERTEX_MANAGER( false ); + m_cachedManager = new VERTEX_MANAGER( true ); + m_nonCachedManager = new VERTEX_MANAGER( false ); + m_overlayManager = new VERTEX_MANAGER( false ); // Make VBOs use shaders - cachedManager->SetShader( *shader ); - nonCachedManager->SetShader( *shader ); - overlayManager->SetShader( *shader ); + m_cachedManager->SetShader( *m_shader ); + m_nonCachedManager->SetShader( *m_shader ); + m_overlayManager->SetShader( *m_shader ); - isInitialized = true; + m_isInitialized = true; } @@ -2269,9 +2276,9 @@ static void InitTesselatorCallbacks( GLUtesselator* aTesselator ) void OPENGL_GAL::EnableDepthTest( bool aEnabled ) { - cachedManager->EnableDepthTest( aEnabled ); - nonCachedManager->EnableDepthTest( aEnabled ); - overlayManager->EnableDepthTest( aEnabled ); + m_cachedManager->EnableDepthTest( aEnabled ); + m_nonCachedManager->EnableDepthTest( aEnabled ); + m_overlayManager->EnableDepthTest( aEnabled ); } @@ -2283,10 +2290,10 @@ static double roundr( double f, double r ) void OPENGL_GAL::ComputeWorldScreenMatrix() { - auto pixelSize = worldScale; + auto pixelSize = m_worldScale; - lookAtPoint.x = roundr( lookAtPoint.x, pixelSize ); - lookAtPoint.y = roundr( lookAtPoint.y, pixelSize ); + m_lookAtPoint.x = roundr( m_lookAtPoint.x, pixelSize ); + m_lookAtPoint.y = roundr( m_lookAtPoint.y, pixelSize ); GAL::ComputeWorldScreenMatrix(); } diff --git a/include/gal/cairo/cairo_gal.h b/include/gal/cairo/cairo_gal.h index 2e3971589c..77c0f3dd7a 100644 --- a/include/gal/cairo/cairo_gal.h +++ b/include/gal/cairo/cairo_gal.h @@ -218,13 +218,13 @@ public: protected: - // Geometric transforms according to the currentWorld2Screen transform matrix: + // Geometric transforms according to the m_currentWorld2Screen transform matrix: const double xform( double x ); // scale const VECTOR2D xform( double x, double y ); // rotation, scale and offset const VECTOR2D xform( const VECTOR2D& aP ); // rotation, scale and offset /** - * Transform according to the rotation from currentWorld2Screen transform matrix. + * Transform according to the rotation from m_currentWorld2Screen transform matrix. * * @param aAngle is the angle in radians to transform. * @return the modified angle. @@ -232,7 +232,7 @@ protected: const double angle_xform( const double aAngle ); /** - * Transform according to the rotation from currentWorld2Screen transform matrix + * Transform according to the rotation from m_currentWorld2Screen transform matrix * for the start angle and the end angle of an arc. * * @param aStartAngle is the arc starting point in radians to transform @@ -312,38 +312,38 @@ protected: /// Type definition for an graphics group element typedef struct { - GRAPHICS_COMMAND command; ///< Command to execute + GRAPHICS_COMMAND m_Command; ///< Command to execute union { - double dblArg[MAX_CAIRO_ARGUMENTS]; ///< Arguments for Cairo commands - bool boolArg; ///< A bool argument - int intArg; ///< An int argument - } argument; - cairo_path_t* cairoPath; ///< Pointer to a Cairo path + double DblArg[MAX_CAIRO_ARGUMENTS]; ///< Arguments for Cairo commands + bool BoolArg; ///< A bool argument + int IntArg; ///< An int argument + } m_Argument; + cairo_path_t* m_CairoPath; ///< Pointer to a Cairo path } GROUP_ELEMENT; - // Variables for the grouping function - bool isGrouping; ///< Is grouping enabled ? - bool isElementAdded; ///< Was an graphic element added ? typedef std::deque GROUP; ///< A graphic group type definition - std::map groups; ///< List of graphic groups - unsigned int groupCounter; ///< Counter used for generating keys for groups - GROUP* currentGroup; ///< Currently used group - double linePixelWidth; - double lineWidthInPixels; - bool lineWidthIsOdd; + // Variables for the grouping function + bool m_isGrouping; ///< Is grouping enabled ? + bool m_isElementAdded; ///< Was an graphic element added ? + std::map m_groups; ///< List of graphic groups + unsigned int m_groupCounter; ///< Counter used for generating group keys + GROUP* m_currentGroup; ///< Currently used group - cairo_matrix_t cairoWorldScreenMatrix; ///< Cairo world to screen transformation matrix - cairo_matrix_t currentXform; - cairo_matrix_t currentWorld2Screen; - cairo_t* currentContext; ///< Currently used Cairo context for drawing - cairo_t* context; ///< Cairo image - cairo_surface_t* surface; ///< Cairo surface + double m_lineWidthInPixels; + bool m_lineWidthIsOdd; + + cairo_matrix_t m_cairoWorldScreenMatrix; ///< Cairo world to screen transform matrix + cairo_matrix_t m_currentXform; + cairo_matrix_t m_currentWorld2Screen; + cairo_t* m_currentContext; ///< Currently used Cairo context for drawing + cairo_t* m_context; ///< Cairo image + cairo_surface_t* m_surface; ///< Cairo surface /// List of surfaces that were created by painting images, to be cleaned up later - std::vector imageSurfaces; + std::vector m_imageSurfaces; - std::vector xformStack; + std::vector m_xformStack; /// Format used to store pixels static constexpr cairo_format_t GAL_FORMAT = CAIRO_FORMAT_ARGB32; }; @@ -399,12 +399,12 @@ public: void SetMouseListener( wxEvtHandler* aMouseListener ) { - mouseListener = aMouseListener; + m_mouseListener = aMouseListener; } void SetPaintListener( wxEvtHandler* aPaintListener ) { - paintListener = aPaintListener; + m_paintListener = aPaintListener; } /// @copydoc GAL::BeginDrawing() @@ -448,25 +448,25 @@ public: protected: // Compositor related variables - std::shared_ptr compositor; ///< Object for layers compositing - unsigned int mainBuffer; ///< Handle to the main buffer - unsigned int overlayBuffer; ///< Handle to the overlay buffer - RENDER_TARGET currentTarget; ///< Current rendering target - bool validCompositor; ///< Compositor initialization flag + std::shared_ptr m_compositor; ///< Object for layers compositing + unsigned int m_mainBuffer; ///< Handle to the main buffer + unsigned int m_overlayBuffer; ///< Handle to the overlay buffer + RENDER_TARGET m_currentTarget; ///< Current rendering target + bool m_validCompositor; ///< Compositor initialization flag // Variables related to wxWidgets - wxWindow* parentWindow; ///< Parent window - wxEvtHandler* mouseListener; ///< Mouse listener - wxEvtHandler* paintListener; ///< Paint listener - unsigned int bufferSize; ///< Size of buffers cairoOutput, bitmapBuffers - unsigned char* wxOutput; ///< wxImage compatible buffer + wxWindow* m_parentWindow; ///< Parent window + wxEvtHandler* m_mouseListener; ///< Mouse listener + wxEvtHandler* m_paintListener; ///< Paint listener + unsigned int m_bufferSize; ///< Size of buffers cairoOutput, bitmapBuffers + unsigned char* m_wxOutput; ///< wxImage compatible buffer // Variables related to Cairo <-> wxWidgets - unsigned char* bitmapBuffer; ///< Storage of the Cairo image - int stride; ///< Stride value for Cairo - int wxBufferWidth; - bool isInitialized; ///< Are Cairo image & surface ready to use - COLOR4D backgroundColor; ///< Background color + unsigned char* m_bitmapBuffer; ///< Storage of the Cairo image + int m_stride; ///< Stride value for Cairo + int m_wxBufferWidth; + bool m_isInitialized; ///< Are Cairo image & surface ready to use + COLOR4D m_backgroundColor; ///< Background color }; } // namespace KIGFX diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h index eee7247e85..3125f49db8 100644 --- a/include/gal/graphics_abstraction_layer.h +++ b/include/gal/graphics_abstraction_layer.h @@ -207,7 +207,7 @@ public: /// Return GAL canvas size in pixels const VECTOR2I& GetScreenPixelSize() const { - return screenSize; + return m_screenSize; } /// Force all remaining objects to be drawn. @@ -241,7 +241,7 @@ public: */ virtual void SetIsFill( bool aIsFillEnabled ) { - isFillEnabled = aIsFillEnabled; + m_isFillEnabled = aIsFillEnabled; } /** @@ -251,7 +251,7 @@ public: */ virtual void SetIsStroke( bool aIsStrokeEnabled ) { - isStrokeEnabled = aIsStrokeEnabled; + m_isStrokeEnabled = aIsStrokeEnabled; } /** @@ -261,7 +261,7 @@ public: */ virtual void SetFillColor( const COLOR4D& aColor ) { - fillColor = aColor; + m_fillColor = aColor; } /** @@ -271,7 +271,7 @@ public: */ inline const COLOR4D& GetFillColor() const { - return fillColor; + return m_fillColor; } /** @@ -281,7 +281,7 @@ public: */ virtual void SetStrokeColor( const COLOR4D& aColor ) { - strokeColor = aColor; + m_strokeColor = aColor; } /** @@ -291,7 +291,7 @@ public: */ inline const COLOR4D& GetStrokeColor() const { - return strokeColor; + return m_strokeColor; } /** @@ -301,7 +301,7 @@ public: */ virtual void SetLineWidth( float aLineWidth ) { - lineWidth = aLineWidth; + m_lineWidth = aLineWidth; } /** @@ -311,7 +311,7 @@ public: */ inline float GetLineWidth() const { - return lineWidth; + return m_lineWidth; } /** @@ -321,10 +321,10 @@ public: */ virtual void SetLayerDepth( double aLayerDepth ) { - assert( aLayerDepth <= depthRange.y ); - assert( aLayerDepth >= depthRange.x ); + assert( aLayerDepth <= m_depthRange.y ); + assert( aLayerDepth >= m_depthRange.x ); - layerDepth = aLayerDepth; + m_layerDepth = aLayerDepth; } // ---- @@ -333,7 +333,7 @@ public: const STROKE_FONT& GetStrokeFont() const { - return strokeFont; + return m_strokeFont; } /** @@ -346,7 +346,7 @@ public: virtual void StrokeText( const wxString& aText, const VECTOR2D& aPosition, double aRotationAngle ) { - strokeFont.Draw( aText, aPosition, aRotationAngle ); + m_strokeFont.Draw( aText, aPosition, aRotationAngle ); } /** @@ -363,23 +363,23 @@ public: // Fallback: use stroke font // Handle flipped view - if( globalFlipX ) + if( m_globalFlipX ) textProperties.m_mirrored = !textProperties.m_mirrored; // Bitmap font is slightly smaller and slightly heavier than the stroke font so we // compensate a bit before stroking - float saveLineWidth = lineWidth; + float saveLineWidth = m_lineWidth; VECTOR2D saveGlyphSize = textProperties.m_glyphSize; { - lineWidth *= 1.2f; + m_lineWidth *= 1.2f; textProperties.m_glyphSize = textProperties.m_glyphSize * 0.8; StrokeText( aText, aPosition, aRotationAngle ); } - lineWidth = saveLineWidth; + m_lineWidth = saveLineWidth; textProperties.m_glyphSize = saveGlyphSize; - if( globalFlipX ) + if( m_globalFlipX ) textProperties.m_mirrored = !textProperties.m_mirrored; } @@ -582,7 +582,7 @@ public: */ const MATRIX3x3D& GetWorldScreenMatrix() const { - return worldScreenMatrix; + return m_worldScreenMatrix; } /** @@ -592,7 +592,7 @@ public: */ const MATRIX3x3D& GetScreenWorldMatrix() const { - return screenWorldMatrix; + return m_screenWorldMatrix; } /** @@ -602,7 +602,7 @@ public: */ inline void SetWorldScreenMatrix( const MATRIX3x3D& aMatrix ) { - worldScreenMatrix = aMatrix; + m_worldScreenMatrix = aMatrix; } /** @@ -616,12 +616,12 @@ public: */ inline void SetWorldUnitLength( double aWorldUnitLength ) { - worldUnitLength = aWorldUnitLength; + m_worldUnitLength = aWorldUnitLength; } inline void SetScreenSize( const VECTOR2I& aSize ) { - screenSize = aSize; + m_screenSize = aSize; } /** @@ -634,7 +634,7 @@ public: */ inline void SetScreenDPI( double aScreenDPI ) { - screenDPI = aScreenDPI; + m_screenDPI = aScreenDPI; } /** @@ -646,7 +646,7 @@ public: */ inline void SetLookAtPoint( const VECTOR2D& aPoint ) { - lookAtPoint = aPoint; + m_lookAtPoint = aPoint; } /** @@ -656,7 +656,7 @@ public: */ inline const VECTOR2D& GetLookAtPoint() const { - return lookAtPoint; + return m_lookAtPoint; } /** @@ -666,7 +666,7 @@ public: */ inline void SetZoomFactor( double aZoomFactor ) { - zoomFactor = aZoomFactor; + m_zoomFactor = aZoomFactor; } /** @@ -676,7 +676,7 @@ public: */ inline double GetZoomFactor() const { - return zoomFactor; + return m_zoomFactor; } /** @@ -686,7 +686,7 @@ public: */ void SetRotation( double aRotation ) { - rotation = aRotation; + m_rotation = aRotation; } /** @@ -696,7 +696,7 @@ public: */ double GetRotation() const { - return rotation; + return m_rotation; } /** @@ -709,7 +709,7 @@ public: */ inline void SetDepthRange( const VECTOR2D& aDepthRange ) { - depthRange = aDepthRange; + m_depthRange = aDepthRange; } /** @@ -717,7 +717,7 @@ public: */ inline double GetMinDepth() const { - return depthRange.x; + return m_depthRange.x; } /** @@ -725,7 +725,7 @@ public: */ inline double GetMaxDepth() const { - return depthRange.y; + return m_depthRange.y; } /** @@ -735,7 +735,7 @@ public: */ inline double GetWorldScale() const { - return worldScale; + return m_worldScale; } /** @@ -746,8 +746,8 @@ public: */ inline void SetFlip( bool xAxis, bool yAxis ) { - globalFlipX = xAxis; - globalFlipY = yAxis; + m_globalFlipX = xAxis; + m_globalFlipY = yAxis; } /** @@ -755,7 +755,7 @@ public: */ bool IsFlippedX() const { - return globalFlipX; + return m_globalFlipX; } /** @@ -763,7 +763,7 @@ public: */ bool IsFlippedY() const { - return globalFlipY; + return m_globalFlipY; } // --------------------------- @@ -823,14 +823,14 @@ public: * * @param aVisibility is the new visibility setting of the grid. */ - void SetGridVisibility( bool aVisibility ) { gridVisibility = aVisibility; } + void SetGridVisibility( bool aVisibility ) { m_gridVisibility = aVisibility; } - bool GetGridVisibility() const { return gridVisibility; } + bool GetGridVisibility() const { return m_gridVisibility; } bool GetGridSnapping() const { - return ( options.m_gridSnapping == KIGFX::GRID_SNAPPING::ALWAYS || - ( gridVisibility && options.m_gridSnapping == KIGFX::GRID_SNAPPING::WITH_GRID ) ); + return m_options.m_gridSnapping == KIGFX::GRID_SNAPPING::ALWAYS || + ( m_gridVisibility && m_options.m_gridSnapping == KIGFX::GRID_SNAPPING::WITH_GRID ); } /** * Set the origin point for the grid. @@ -839,18 +839,22 @@ public: */ inline void SetGridOrigin( const VECTOR2D& aGridOrigin ) { - gridOrigin = aGridOrigin; + m_gridOrigin = aGridOrigin; - if( gridSize.x == 0.0 || gridSize.y == 0.0 ) - gridOffset = VECTOR2D(0.0, 0.0); + if( m_gridSize.x == 0.0 || m_gridSize.y == 0.0 ) + { + m_gridOffset = VECTOR2D( 0.0, 0.0); + } else - gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x, - (long) gridOrigin.y % (long) gridSize.y ); + { + m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x, + (long) m_gridOrigin.y % (long) m_gridSize.y ); + } } inline const VECTOR2D& GetGridOrigin() const { - return gridOrigin; + return m_gridOrigin; } /** @@ -860,14 +864,14 @@ public: */ inline void SetGridSize( const VECTOR2D& aGridSize ) { - gridSize = aGridSize; + m_gridSize = aGridSize; // Avoid stupid grid size values: a grid size should be >= 1 in internal units - gridSize.x = std::max( 1.0, gridSize.x ); - gridSize.y = std::max( 1.0, gridSize.y ); + m_gridSize.x = std::max( 1.0, m_gridSize.x ); + m_gridSize.y = std::max( 1.0, m_gridSize.y ); - gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x, - (long) gridOrigin.y % (long) gridSize.y ); + m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x, + (long) m_gridOrigin.y % (long) m_gridSize.y ); } /** @@ -877,7 +881,7 @@ public: */ inline const VECTOR2D& GetGridSize() const { - return gridSize; + return m_gridSize; } /** @@ -887,7 +891,7 @@ public: */ inline void SetGridColor( const COLOR4D& aGridColor ) { - gridColor = aGridColor; + m_gridColor = aGridColor; } /** @@ -897,7 +901,7 @@ public: */ inline void SetAxesColor( const COLOR4D& aAxesColor ) { - axesColor = aAxesColor; + m_axesColor = aAxesColor; } /** @@ -905,7 +909,7 @@ public: */ inline void SetAxesEnabled( bool aAxesEnabled ) { - axesEnabled = aAxesEnabled; + m_axesEnabled = aAxesEnabled; } /** @@ -915,7 +919,7 @@ public: */ inline void SetCoarseGrid( int aInterval ) { - gridTick = aInterval; + m_gridTick = aInterval; } /** @@ -925,7 +929,7 @@ public: */ inline float GetGridLineWidth() const { - return gridLineWidth; + return m_gridLineWidth; } ///< Draw the grid @@ -947,7 +951,7 @@ public: */ inline VECTOR2D ToWorld( const VECTOR2D& aPoint ) const { - return VECTOR2D( screenWorldMatrix * aPoint ); + return VECTOR2D( m_screenWorldMatrix * aPoint ); } /** @@ -958,7 +962,7 @@ public: */ inline VECTOR2D ToScreen( const VECTOR2D& aPoint ) const { - return VECTOR2D( worldScreenMatrix * aPoint ); + return VECTOR2D( m_worldScreenMatrix * aPoint ); } /** @@ -968,7 +972,7 @@ public: */ inline void SetCursorEnabled( bool aCursorEnabled ) { - isCursorEnabled = aCursorEnabled; + m_isCursorEnabled = aCursorEnabled; } /** @@ -978,7 +982,7 @@ public: */ bool IsCursorEnabled() const { - return isCursorEnabled || forceDisplayCursor; + return m_isCursorEnabled || m_forceDisplayCursor; } /** @@ -988,7 +992,7 @@ public: */ inline void SetCursorColor( const COLOR4D& aCursorColor ) { - cursorColor = aCursorColor; + m_cursorColor = aCursorColor; } /** @@ -1004,7 +1008,7 @@ public: */ inline void AdvanceDepth() { - layerDepth -= 0.05; + m_layerDepth -= 0.05; } /** @@ -1012,7 +1016,7 @@ public: */ inline void PushDepth() { - depthStack.push( layerDepth ); + m_depthStack.push( m_layerDepth ); } /** @@ -1020,8 +1024,8 @@ public: */ inline void PopDepth() { - layerDepth = depthStack.top(); - depthStack.pop(); + m_layerDepth = m_depthStack.top(); + m_depthStack.pop(); } virtual void EnableDepthTest( bool aEnabled = false ) {}; @@ -1059,7 +1063,7 @@ protected: /// Compute the scaling factor for the world->screen matrix inline void computeWorldScale() { - worldScale = screenDPI * worldUnitLength * zoomFactor; + m_worldScale = m_screenDPI * m_worldUnitLength * m_zoomFactor; } /** @@ -1099,60 +1103,60 @@ protected: */ virtual bool updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions ); - GAL_DISPLAY_OPTIONS& options; - UTIL::LINK observerLink; + GAL_DISPLAY_OPTIONS& m_options; + UTIL::LINK m_observerLink; - std::stack depthStack; ///< Stored depth values - VECTOR2I screenSize; ///< Screen size in screen coordinates + std::stack m_depthStack; ///< Stored depth values + VECTOR2I m_screenSize; ///< Screen size in screen coordinates - double worldUnitLength; ///< The unit length of the world coordinates [inch] - double screenDPI; ///< The dots per inch of the screen - VECTOR2D lookAtPoint; ///< Point to be looked at in world space + double m_worldUnitLength; ///< The unit length of the world coordinates [inch] + double m_screenDPI; ///< The dots per inch of the screen + VECTOR2D m_lookAtPoint; ///< Point to be looked at in world space - double zoomFactor; ///< The zoom factor - double rotation; ///< Rotation transformation (radians) - MATRIX3x3D worldScreenMatrix; ///< World transformation - MATRIX3x3D screenWorldMatrix; ///< Screen transformation - double worldScale; ///< The scale factor world->screen + double m_zoomFactor; ///< The zoom factor + double m_rotation; ///< Rotation transformation (radians) + MATRIX3x3D m_worldScreenMatrix; ///< World transformation + MATRIX3x3D m_screenWorldMatrix; ///< Screen transformation + double m_worldScale; ///< The scale factor world->screen - bool globalFlipX; ///< Flag for X axis flipping - bool globalFlipY; ///< Flag for Y axis flipping + bool m_globalFlipX; ///< Flag for X axis flipping + bool m_globalFlipY; ///< Flag for Y axis flipping - float lineWidth; ///< The line width + float m_lineWidth; ///< The line width - bool isFillEnabled; ///< Is filling of graphic objects enabled ? - bool isStrokeEnabled; ///< Are the outlines stroked ? + bool m_isFillEnabled; ///< Is filling of graphic objects enabled ? + bool m_isStrokeEnabled; ///< Are the outlines stroked ? - COLOR4D fillColor; ///< The fill color - COLOR4D strokeColor; ///< The color of the outlines - COLOR4D m_clearColor; + COLOR4D m_fillColor; ///< The fill color + COLOR4D m_strokeColor; ///< The color of the outlines + COLOR4D m_clearColor; - double layerDepth; ///< The actual layer depth - VECTOR2D depthRange; ///< Range of the depth + double m_layerDepth; ///< The actual layer depth + VECTOR2D m_depthRange; ///< Range of the depth // Grid settings - bool gridVisibility; ///< Should the grid be shown - GRID_STYLE gridStyle; ///< Grid display style - VECTOR2D gridSize; ///< The grid size - VECTOR2D gridOrigin; ///< The grid origin - VECTOR2D gridOffset; ///< The grid offset to compensate cursor position - COLOR4D gridColor; ///< Color of the grid - COLOR4D axesColor; ///< Color of the axes - bool axesEnabled; ///< Should the axes be drawn - int gridTick; ///< Every tick line gets the double width - float gridLineWidth; ///< Line width of the grid - int gridMinSpacing; ///< Minimum screen size of the grid (pixels) + bool m_gridVisibility; ///< Should the grid be shown + GRID_STYLE m_gridStyle; ///< Grid display style + VECTOR2D m_gridSize; ///< The grid size + VECTOR2D m_gridOrigin; ///< The grid origin + VECTOR2D m_gridOffset; ///< The grid offset to compensate cursor position + COLOR4D m_gridColor; ///< Color of the grid + COLOR4D m_axesColor; ///< Color of the axes + bool m_axesEnabled; ///< Should the axes be drawn + int m_gridTick; ///< Every tick line gets the double width + float m_gridLineWidth; ///< Line width of the grid + int m_gridMinSpacing; ///< Minimum screen size of the grid (pixels) ///< below which the grid is not drawn // Cursor settings - bool isCursorEnabled; ///< Is the cursor enabled? - bool forceDisplayCursor; ///< Always show cursor - COLOR4D cursorColor; ///< Cursor color - bool fullscreenCursor; ///< Shape of the cursor (fullscreen or small cross) - VECTOR2D cursorPosition; ///< Current cursor position (world coordinates) + bool m_isCursorEnabled; ///< Is the cursor enabled? + bool m_forceDisplayCursor; ///< Always show cursor + COLOR4D m_cursorColor; ///< Cursor color + bool m_fullscreenCursor; ///< Shape of the cursor (fullscreen or small cross) + VECTOR2D m_cursorPosition; ///< Current cursor position (world coordinates) - /// Instance of object that stores information about how to draw texts - STROKE_FONT strokeFont; + STROKE_FONT m_strokeFont; ///< Instance of object that stores information + ///< about how to draw texts private: struct TEXT_PROPERTIES diff --git a/include/gal/opengl/opengl_gal.h b/include/gal/opengl/opengl_gal.h index cbdc4a155d..03716b0350 100644 --- a/include/gal/opengl/opengl_gal.h +++ b/include/gal/opengl/opengl_gal.h @@ -259,12 +259,12 @@ public: void SetMouseListener( wxEvtHandler* aMouseListener ) { - mouseListener = aMouseListener; + m_mouseListener = aMouseListener; } void SetPaintListener( wxEvtHandler* aPaintListener ) { - paintListener = aPaintListener; + m_paintListener = aPaintListener; } void EnableDepthTest( bool aEnabled = false ) override; @@ -291,48 +291,53 @@ private: static const int CIRCLE_POINTS = 64; ///< The number of points for circle approximation static const int CURVE_POINTS = 32; ///< The number of points for curve approximation - static wxGLContext* glMainContext; ///< Parent OpenGL context - wxGLContext* glPrivContext; ///< Canvas-specific OpenGL context - static int instanceCounter; ///< GL GAL instance counter - wxEvtHandler* mouseListener; - wxEvtHandler* paintListener; + static wxGLContext* m_glMainContext; ///< Parent OpenGL context + wxGLContext* m_glPrivContext; ///< Canvas-specific OpenGL context + static int m_instanceCounter; ///< GL GAL instance counter + wxEvtHandler* m_mouseListener; + wxEvtHandler* m_paintListener; - static GLuint fontTexture; ///< Bitmap font texture handle (shared) + static GLuint g_fontTexture; ///< Bitmap font texture handle (shared) // Vertex buffer objects related fields typedef std::unordered_map< unsigned int, std::shared_ptr > GROUPS_MAP; - GROUPS_MAP groups; ///< Stores information about VBO objects (groups) - unsigned int groupCounter; ///< Counter used for generating keys for groups - VERTEX_MANAGER* currentManager; ///< Currently used VERTEX_MANAGER (for storing + + GROUPS_MAP m_groups; ///< Stores information about VBO objects (groups) + unsigned int m_groupCounter; ///< Counter used for generating keys for groups + VERTEX_MANAGER* m_currentManager; ///< Currently used VERTEX_MANAGER (for storing ///< VERTEX_ITEMs). - VERTEX_MANAGER* cachedManager; ///< Container for storing cached VERTEX_ITEMs - VERTEX_MANAGER* nonCachedManager; ///< Container for storing non-cached VERTEX_ITEMs - VERTEX_MANAGER* overlayManager; ///< Container for storing overlaid VERTEX_ITEMs + VERTEX_MANAGER* m_cachedManager; ///< Container for storing cached VERTEX_ITEMs + VERTEX_MANAGER* m_nonCachedManager; ///< Container for storing non-cached VERTEX_ITEMs + VERTEX_MANAGER* m_overlayManager; ///< Container for storing overlaid VERTEX_ITEMs // Framebuffer & compositing - OPENGL_COMPOSITOR* compositor; ///< Handles multiple rendering targets - unsigned int mainBuffer; ///< Main rendering target - unsigned int overlayBuffer; ///< Auxiliary rendering target (for menus etc.) - RENDER_TARGET currentTarget; ///< Current rendering target + OPENGL_COMPOSITOR* m_compositor; ///< Handles multiple rendering targets + unsigned int m_mainBuffer; ///< Main rendering target + unsigned int m_overlayBuffer; ///< Auxiliary rendering target (for menus etc.) + RENDER_TARGET m_currentTarget; ///< Current rendering target // Shader - SHADER* shader; ///< There is only one shader used for different + SHADER* m_shader; ///< There is only one shader used for different ///< objects. // Internal flags - bool isFramebufferInitialized; ///< Are the framebuffers initialized? - static bool isBitmapFontLoaded; ///< Is the bitmap font texture loaded? - bool isBitmapFontInitialized; ///< Is the shader set to use bitmap fonts? - bool isInitialized; ///< Basic initialization flag, has to be done - ///< when the window is visible - bool isGrouping; ///< Was a group started? - bool m_isContextLocked; ///< Used for assertion checking - int lockClientCookie; + bool m_isFramebufferInitialized; ///< Are the framebuffers initialized? + static bool m_isBitmapFontLoaded; ///< Is the bitmap font texture loaded? + bool m_isBitmapFontInitialized; ///< Is the shader set to use bitmap fonts? + bool m_isInitialized; ///< Basic initialization flag, has to be + ///< done when the window is visible + bool m_isGrouping; ///< Was a group started? + bool m_isContextLocked; ///< Used for assertion checking + int m_lockClientCookie; GLint ufm_worldPixelSize; GLint ufm_screenPixelSize; GLint ufm_pixelSizeMultiplier; - std::unique_ptr bitmapCache; + std::unique_ptr m_bitmapCache; + + // Polygon tesselation + GLUtesselator* m_tesselator; + std::deque< boost::shared_array > m_tessIntersects; void lockContext( int aClientCookie ) override; @@ -353,12 +358,6 @@ private: ///< Update handler for OpenGL settings bool updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions ) override; - // Polygon tesselation - /// The tessellator - GLUtesselator* tesselator; - /// Storage for intersecting points - std::deque< boost::shared_array > tessIntersects; - /** * @brief Draw a quad for the line. * @@ -370,7 +369,7 @@ private: /** * Draw a semicircle. * - * Depending on settings (isStrokeEnabled & isFilledEnabled) it runs the proper function + * Depending on settings (m_isStrokeEnabled & isFilledEnabled) it runs the proper function * (drawStrokedSemiCircle or drawFilledSemiCircle). * * @param aCenterPoint is the center point. diff --git a/qa/gal/gal_pixel_alignment/test_gal_pixel_alignment.cpp b/qa/gal/gal_pixel_alignment/test_gal_pixel_alignment.cpp index 3326ba4662..590ac9d5ff 100644 --- a/qa/gal/gal_pixel_alignment/test_gal_pixel_alignment.cpp +++ b/qa/gal/gal_pixel_alignment/test_gal_pixel_alignment.cpp @@ -24,16 +24,16 @@ void screenSpaceLine( KIGFX::GAL* gal, const VECTOR2D& p0, const VECTOR2D& p1, d #if 0 //shader->Deactivate(); - currentManager->Reserve( 6 ); - currentManager->Shader( SHADER_NONE ); - currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ); + m_currentManager->Reserve( 6 ); + m_currentManager->Shader( SHADER_NONE ); + m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, m_strokeColor.a ); - currentManager->Shader( SHADER_NONE ); currentManager->Vertex( pa.x, pa.y, layerDepth ); - currentManager->Shader( SHADER_NONE ); currentManager->Vertex( pb.x, pb.y, layerDepth ); - currentManager->Shader( SHADER_NONE ); currentManager->Vertex( pc.x, pc.y, layerDepth ); - currentManager->Shader( SHADER_NONE ); currentManager->Vertex( pa.x, pa.y, layerDepth ); - currentManager->Shader( SHADER_NONE ); currentManager->Vertex( pc.x, pc.y, layerDepth ); - currentManager->Shader( SHADER_NONE ); currentManager->Vertex( pd.x, pd.y, layerDepth ); + m_currentManager->Shader( SHADER_NONE ); m_currentManager->Vertex( pa.x, pa.y, m_layerDepth ); + m_currentManager->Shader( SHADER_NONE ); m_currentManager->Vertex( pb.x, pb.y, m_layerDepth ); + m_currentManager->Shader( SHADER_NONE ); m_currentManager->Vertex( pc.x, pc.y, m_layerDepth ); + m_currentManager->Shader( SHADER_NONE ); m_currentManager->Vertex( pa.x, pa.y, m_layerDepth ); + m_currentManager->Shader( SHADER_NONE ); m_currentManager->Vertex( pc.x, pc.y, m_layerDepth ); + m_currentManager->Shader( SHADER_NONE ); m_currentManager->Vertex( pd.x, pd.y, m_layerDepth ); shader->Use(); #endif