Browse Source

GAL: changed line width setting to float type

pull/13/head
Maciej Suminski 7 years ago
parent
commit
47d0eaa2c6
  1. 9
      common/gal/cairo/cairo_gal.cpp
  2. 8
      common/gal/graphics_abstraction_layer.cpp
  3. 4
      common/gal/opengl/opengl_gal.cpp
  4. 2
      include/gal/cairo/cairo_gal.h
  5. 10
      include/gal/graphics_abstraction_layer.h

9
common/gal/cairo/cairo_gal.cpp

@ -417,11 +417,10 @@ void CAIRO_GAL_BASE::SetFillColor( const COLOR4D& aColor )
} }
void CAIRO_GAL_BASE::SetLineWidth( double aLineWidth )
void CAIRO_GAL_BASE::SetLineWidth( float aLineWidth )
{ {
storePath(); storePath();
lineWidth = aLineWidth;
GAL::SetLineWidth( aLineWidth );
if( isGrouping ) if( isGrouping )
{ {
@ -435,8 +434,8 @@ void CAIRO_GAL_BASE::SetLineWidth( double aLineWidth )
// Make lines appear at least 1 pixel wide, no matter of zoom // Make lines appear at least 1 pixel wide, no matter of zoom
double x = 1.0, y = 1.0; double x = 1.0, y = 1.0;
cairo_device_to_user_distance( currentContext, &x, &y ); cairo_device_to_user_distance( currentContext, &x, &y );
double minWidth = std::min( fabs( x ), fabs( y ) );
cairo_set_line_width( currentContext, std::max( aLineWidth, minWidth ) );
float minWidth = std::min( fabs( x ), fabs( y ) );
cairo_set_line_width( currentContext, std::fmax( aLineWidth, minWidth ) );
} }
} }

8
common/gal/graphics_abstraction_layer.cpp

@ -54,14 +54,14 @@ GAL::GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions ) :
SetDepthRange( VECTOR2D( GAL::MIN_DEPTH, GAL::MAX_DEPTH ) ); SetDepthRange( VECTOR2D( GAL::MIN_DEPTH, GAL::MAX_DEPTH ) );
SetLayerDepth( 0.0 ); SetLayerDepth( 0.0 );
SetFlip( false, false ); SetFlip( false, false );
SetLineWidth( 1.0 );
SetLineWidth( 1.0f );
computeWorldScale(); computeWorldScale();
SetAxesEnabled( false ); SetAxesEnabled( false );
// Set grid defaults // Set grid defaults
SetGridVisibility( true ); SetGridVisibility( true );
SetCoarseGrid( 10 ); SetCoarseGrid( 10 );
gridLineWidth = 0.5;
gridLineWidth = 0.5f;
gridStyle = GRID_STYLE::LINES; gridStyle = GRID_STYLE::LINES;
gridMinSpacing = 10; gridMinSpacing = 10;
@ -231,8 +231,8 @@ void GAL::DrawGrid()
// Note: generic grids can't handle sub-pixel lines without // Note: generic grids can't handle sub-pixel lines without
// either losing fine/course distinction or having some dots // either losing fine/course distinction or having some dots
// fail to render // fail to render
double marker = std::max( 1.0, gridLineWidth ) / worldScale;
double doubleMarker = 2.0 * marker;
float marker = std::fmax( 1.0f, gridLineWidth ) / worldScale;
float doubleMarker = 2.0f * marker;
// Draw axes if desired // Draw axes if desired
if( axesEnabled ) if( axesEnabled )

4
common/gal/opengl/opengl_gal.cpp

@ -1182,8 +1182,8 @@ void OPENGL_GAL::DrawGrid()
nonCachedManager->EnableDepthTest( false ); nonCachedManager->EnableDepthTest( false );
// sub-pixel lines all render the same // sub-pixel lines all render the same
double minorLineWidth = std::max( 1.0, gridLineWidth ) * getWorldPixelSize();
double majorLineWidth = minorLineWidth * 2.0;
float minorLineWidth = std::fmax( 1.0f, gridLineWidth ) * getWorldPixelSize();
float majorLineWidth = minorLineWidth * 2.0f;
// Draw the axis and grid // Draw the axis and grid
// For the drawing the start points, end points and increments have // For the drawing the start points, end points and increments have

2
include/gal/cairo/cairo_gal.h

@ -143,7 +143,7 @@ public:
virtual void SetFillColor( const COLOR4D& aColor ) override; virtual void SetFillColor( const COLOR4D& aColor ) override;
/// @copydoc GAL::SetLineWidth() /// @copydoc GAL::SetLineWidth()
virtual void SetLineWidth( double aLineWidth ) override;
virtual void SetLineWidth( float aLineWidth ) override;
/// @copydoc GAL::SetLayerDepth() /// @copydoc GAL::SetLayerDepth()
virtual void SetLayerDepth( double aLayerDepth ) override; virtual void SetLayerDepth( double aLayerDepth ) override;

10
include/gal/graphics_abstraction_layer.h

@ -283,7 +283,7 @@ public:
* *
* @param aLineWidth is the line width. * @param aLineWidth is the line width.
*/ */
virtual void SetLineWidth( double aLineWidth )
virtual void SetLineWidth( float aLineWidth )
{ {
lineWidth = aLineWidth; lineWidth = aLineWidth;
} }
@ -293,7 +293,7 @@ public:
* *
* @return the actual line width. * @return the actual line width.
*/ */
inline double GetLineWidth() const
inline float GetLineWidth() const
{ {
return lineWidth; return lineWidth;
} }
@ -916,7 +916,7 @@ public:
* *
* @return the grid line width * @return the grid line width
*/ */
inline double GetGridLineWidth() const
inline float GetGridLineWidth() const
{ {
return gridLineWidth; return gridLineWidth;
} }
@ -1042,7 +1042,7 @@ protected:
bool globalFlipX; ///< Flag for X axis flipping bool globalFlipX; ///< Flag for X axis flipping
bool globalFlipY; ///< Flag for Y axis flipping bool globalFlipY; ///< Flag for Y axis flipping
double lineWidth; ///< The line width
float lineWidth; ///< The line width
bool isFillEnabled; ///< Is filling of graphic objects enabled ? bool isFillEnabled; ///< Is filling of graphic objects enabled ?
bool isStrokeEnabled; ///< Are the outlines stroked ? bool isStrokeEnabled; ///< Are the outlines stroked ?
@ -1064,7 +1064,7 @@ protected:
COLOR4D axesColor; ///< Color of the axes COLOR4D axesColor; ///< Color of the axes
bool axesEnabled; ///< Should the axes be drawn bool axesEnabled; ///< Should the axes be drawn
int gridTick; ///< Every tick line gets the double width int gridTick; ///< Every tick line gets the double width
double gridLineWidth; ///< Line width of the grid
float gridLineWidth; ///< Line width of the grid
int gridMinSpacing; ///< Minimum screen size of the grid (pixels) int gridMinSpacing; ///< Minimum screen size of the grid (pixels)
///< below which the grid is not drawn ///< below which the grid is not drawn

Loading…
Cancel
Save