Commit 4360860b authored by unknown's avatar unknown Committed by Maciej Suminski

Removed different styles of line caps and line joins, leaving only round caps & joins.

Fixed drawing stroked semicircles using OpenGL backend.
parent 8a44751b
...@@ -72,15 +72,6 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener, ...@@ -72,15 +72,6 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) ); Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
#endif #endif
// Initialize line attributes map
lineCapMap[LINE_CAP_BUTT] = CAIRO_LINE_CAP_BUTT;
lineCapMap[LINE_CAP_ROUND] = CAIRO_LINE_CAP_ROUND;
lineCapMap[LINE_CAP_SQUARED] = CAIRO_LINE_CAP_SQUARE;
lineJoinMap[LINE_JOIN_BEVEL] = CAIRO_LINE_JOIN_BEVEL;
lineJoinMap[LINE_JOIN_ROUND] = CAIRO_LINE_JOIN_ROUND;
lineJoinMap[LINE_JOIN_MITER] = CAIRO_LINE_JOIN_MITER;
// Initialize the cursor shape // Initialize the cursor shape
SetCursorColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) ); SetCursorColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
initCursor( 21 ); initCursor( 21 );
...@@ -179,8 +170,8 @@ void CAIRO_GAL::initSurface() ...@@ -179,8 +170,8 @@ void CAIRO_GAL::initSurface()
cairo_new_path( cairoImage ); cairo_new_path( cairoImage );
isElementAdded = true; isElementAdded = true;
cairo_set_line_join( cairoImage, lineJoinMap[lineJoin] ); cairo_set_line_join( cairoImage, CAIRO_LINE_JOIN_ROUND );
cairo_set_line_cap( cairoImage, lineCapMap[lineCap] ); cairo_set_line_cap( cairoImage, CAIRO_LINE_CAP_ROUND );
lineWidth = 0; lineWidth = 0;
...@@ -298,9 +289,6 @@ void CAIRO_GAL::DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ...@@ -298,9 +289,6 @@ void CAIRO_GAL::DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint
void CAIRO_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint, double aWidth ) void CAIRO_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint, double aWidth )
{ {
cairo_set_line_cap( cairoImage, CAIRO_LINE_CAP_ROUND );
cairo_set_line_join( cairoImage, CAIRO_LINE_JOIN_ROUND );
if( isFillEnabled ) if( isFillEnabled )
{ {
SetLineWidth( aWidth ); SetLineWidth( aWidth );
...@@ -520,42 +508,6 @@ void CAIRO_GAL::SetLineWidth( double aLineWidth ) ...@@ -520,42 +508,6 @@ void CAIRO_GAL::SetLineWidth( double aLineWidth )
} }
void CAIRO_GAL::SetLineCap( LineCap aLineCap )
{
storePath();
lineCap = aLineCap;
cairo_set_line_cap( cairoImage, lineCapMap[aLineCap] );
if( isGrouping )
{
GroupElement groupElement;
groupElement.command = CMD_SET_LINE_CAP;
groupElement.intArgument = (int) aLineCap;
currentGroup->push_back( groupElement );
}
}
void CAIRO_GAL::SetLineJoin( LineJoin aLineJoin )
{
storePath();
lineJoin = aLineJoin;
cairo_set_line_join( cairoImage, lineJoinMap[aLineJoin] );
if( isGrouping )
{
GroupElement groupElement;
groupElement.command = CMD_SET_LINE_JOIN;
groupElement.intArgument = (int) aLineJoin;
currentGroup->push_back( groupElement );
}
}
void CAIRO_GAL::ClearScreen() void CAIRO_GAL::ClearScreen()
{ {
// Clear screen // Clear screen
...@@ -767,14 +719,6 @@ void CAIRO_GAL::DrawGroup( int aGroupNumber ) ...@@ -767,14 +719,6 @@ void CAIRO_GAL::DrawGroup( int aGroupNumber )
cairo_set_line_width( cairoImage, it->arguments[0] ); cairo_set_line_width( cairoImage, it->arguments[0] );
break; break;
case CMD_SET_LINE_JOIN:
cairo_set_line_join( cairoImage, lineJoinMap[(LineJoin) ( it->intArgument )] );
break;
case CMD_SET_LINE_CAP:
cairo_set_line_cap( cairoImage, lineCapMap[(LineCap) ( it->intArgument )] );
break;
case CMD_STROKE_PATH: case CMD_STROKE_PATH:
cairo_set_source_rgb( cairoImage, strokeColor.r, strokeColor.g, strokeColor.b ); cairo_set_source_rgb( cairoImage, strokeColor.r, strokeColor.g, strokeColor.b );
cairo_append_path( cairoImage, it->cairoPath ); cairo_append_path( cairoImage, it->cairoPath );
......
...@@ -38,8 +38,6 @@ GAL::GAL() ...@@ -38,8 +38,6 @@ GAL::GAL()
// Set the default values for the internal variables // Set the default values for the internal variables
SetIsFill( false ); SetIsFill( false );
SetIsStroke( true ); SetIsStroke( true );
SetLineJoin( LINE_JOIN_ROUND );
SetLineCap( LINE_CAP_ROUND );
SetIsCursorEnabled( false ); SetIsCursorEnabled( false );
SetZoomFactor( 1.0 ); SetZoomFactor( 1.0 );
SetFillColor( COLOR4D( 0.0, 0.0, 0.0, 0.0 ) ); SetFillColor( COLOR4D( 0.0, 0.0, 0.0, 0.0 ) );
......
This diff is collapsed.
...@@ -233,8 +233,6 @@ void STROKE_FONT::Draw( std::string aText, const VECTOR2D& aPosition, double aRo ...@@ -233,8 +233,6 @@ void STROKE_FONT::Draw( std::string aText, const VECTOR2D& aPosition, double aRo
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
m_gal->SetIsFill( false ); m_gal->SetIsFill( false );
m_gal->SetLineCap( LINE_CAP_ROUND );
m_gal->SetLineJoin( LINE_JOIN_ROUND );
if( m_bold ) if( m_bold )
{ {
......
...@@ -159,12 +159,6 @@ public: ...@@ -159,12 +159,6 @@ public:
/// @copydoc GAL::SetBackgroundColor() /// @copydoc GAL::SetBackgroundColor()
virtual void SetBackgroundColor( const COLOR4D& aColor ); virtual void SetBackgroundColor( const COLOR4D& aColor );
/// @copydoc GAL::SetLineCap()
virtual void SetLineCap( LineCap aLineCap );
/// @copydoc GAL::SetLineJoin()
virtual void SetLineJoin( LineJoin aLineJoin );
/// @copydoc GAL::SetLineWidth() /// @copydoc GAL::SetLineWidth()
virtual void SetLineWidth( double aLineWidth ); virtual void SetLineWidth( double aLineWidth );
...@@ -334,8 +328,6 @@ private: ...@@ -334,8 +328,6 @@ private:
CMD_SET_FILLCOLOR, ///< Set the fill color CMD_SET_FILLCOLOR, ///< Set the fill color
CMD_SET_STROKECOLOR, ///< Set the stroke color CMD_SET_STROKECOLOR, ///< Set the stroke color
CMD_SET_LINE_WIDTH, ///< Set the line width CMD_SET_LINE_WIDTH, ///< Set the line width
CMD_SET_LINE_CAP, ///< Set the line cap style
CMD_SET_LINE_JOIN, ///< Set the line join style
CMD_STROKE_PATH, ///< Set the stroke path CMD_STROKE_PATH, ///< Set the stroke path
CMD_FILL_PATH, ///< Set the fill path CMD_FILL_PATH, ///< Set the fill path
CMD_TRANSFORM, ///< Transform the actual context CMD_TRANSFORM, ///< Transform the actual context
...@@ -371,10 +363,6 @@ private: ...@@ -371,10 +363,6 @@ private:
int stride; ///< Stride value for Cairo int stride; ///< Stride value for Cairo
bool isInitialized; ///< Are Cairo image & surface ready to use bool isInitialized; ///< Are Cairo image & surface ready to use
// Mapping between Cairo and GAL line attributes
std::map<LineCap, cairo_line_cap_t> lineCapMap; ///< Line cap style mapping
std::map<LineJoin, cairo_line_join_t> lineJoinMap; ///< Line join style mapping
// Methods // Methods
void storePath(); ///< Store the actual path void storePath(); ///< Store the actual path
......
...@@ -38,27 +38,6 @@ ...@@ -38,27 +38,6 @@
namespace KiGfx namespace KiGfx
{ {
/**
* LineCap: Type definition of the line end point style
*/
enum LineCap
{
LINE_CAP_BUTT, ///< Stop line at the end point
LINE_CAP_ROUND, ///< Draw a circle at the end point
LINE_CAP_SQUARED ///< Draw a square at the end point
};
/**
* LineJoin: Type definition of the line joint style
*/
enum LineJoin
{
LINE_JOIN_MITER, ///< Use sharp corners
LINE_JOIN_ROUND, ///< Insert a circle at the joints
LINE_JOIN_BEVEL ///< Diagonal corner
};
/** /**
* GridStyle: Type definition of the grid style * GridStyle: Type definition of the grid style
*/ */
...@@ -251,26 +230,6 @@ public: ...@@ -251,26 +230,6 @@ public:
*/ */
virtual void SetBackgroundColor( const COLOR4D& aColor ) = 0; virtual void SetBackgroundColor( const COLOR4D& aColor ) = 0;
/**
* @brief Set the style of the line caps.
*
* @param aLineCap is the line cap style.
*/
inline virtual void SetLineCap( LineCap aLineCap )
{
lineCap = aLineCap;
}
/**
* @brief Set the line join style.
*
* @param aLineJoin is the line join style.
*/
inline virtual void SetLineJoin( LineJoin aLineJoin )
{
lineJoin = aLineJoin;
}
/** /**
* @brief Set the line width. * @brief Set the line width.
* *
...@@ -710,8 +669,6 @@ protected: ...@@ -710,8 +669,6 @@ protected:
double worldScale; ///< The scale factor world->screen double worldScale; ///< The scale factor world->screen
double lineWidth; ///< The line width double lineWidth; ///< The line width
LineCap lineCap; ///< Line end style
LineJoin lineJoin; ///< Style of the line joints
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 ?
......
...@@ -176,18 +176,6 @@ public: ...@@ -176,18 +176,6 @@ public:
/// @copydoc GAL::SetBackgroundColor() /// @copydoc GAL::SetBackgroundColor()
virtual void SetBackgroundColor( const COLOR4D& aColor ); virtual void SetBackgroundColor( const COLOR4D& aColor );
/// @copydoc GAL::SetLineCap()
virtual void SetLineCap( LineCap aLineCap )
{
lineCap = aLineCap;
}
/// @copydoc GAL::SetLineJoin()
virtual void SetLineJoin( LineJoin aLineJoin )
{
lineJoin = aLineJoin;
}
/// @copydoc GAL::SetLineWidth() /// @copydoc GAL::SetLineWidth()
virtual void SetLineWidth( double aLineWidth ); virtual void SetLineWidth( double aLineWidth );
...@@ -421,6 +409,9 @@ private: ...@@ -421,6 +409,9 @@ private:
*/ */
void drawSemiCircle( const VECTOR2D& aCenterPoint, double aRadius, double aAngle ); void drawSemiCircle( const VECTOR2D& aCenterPoint, double aRadius, double aAngle );
void drawFilledSemiCircle( const VECTOR2D& aCenterPoint, double aRadius, double aAngle );
void drawStrokedSemiCircle( const VECTOR2D& aCenterPoint, double aRadius, double aAngle );
/// Compute the points of a unit circle. /// Compute the points of a unit circle.
void computeUnitCircle(); void computeUnitCircle();
...@@ -514,15 +505,6 @@ private: ...@@ -514,15 +505,6 @@ private:
*/ */
inline void drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ); inline void drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint );
/**
* @brief Draw the line cap
*
* @param aStartPoint is the start point of the line.
* @param aEndPoint is the end point of the line.
* @param aDepthOffset is the relative depth of the line cap.
*/
inline void drawLineCap( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint );
/** /**
* @brief Returns a valid key that can be used as a group number. * @brief Returns a valid key that can be used as a group number.
* *
......
...@@ -314,8 +314,6 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) ...@@ -314,8 +314,6 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
// Outline mode // Outline mode
m_gal->SetIsFill( false ); m_gal->SetIsFill( false );
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
m_gal->SetLineCap( LINE_CAP_ROUND );
m_gal->SetLineJoin( LINE_JOIN_MITER );
m_gal->SetLineWidth( m_pcbSettings->m_outlineWidth ); m_gal->SetLineWidth( m_pcbSettings->m_outlineWidth );
m_gal->SetStrokeColor( color ); m_gal->SetStrokeColor( color );
} }
...@@ -420,8 +418,6 @@ void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment ) ...@@ -420,8 +418,6 @@ void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment )
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
m_gal->SetStrokeColor( strokeColor ); m_gal->SetStrokeColor( strokeColor );
m_gal->SetLineWidth( aSegment->GetWidth() ); m_gal->SetLineWidth( aSegment->GetWidth() );
m_gal->SetLineCap( LINE_CAP_ROUND );
m_gal->SetLineJoin( LINE_JOIN_ROUND );
switch( aSegment->GetShape() ) switch( aSegment->GetShape() )
{ {
...@@ -430,9 +426,8 @@ void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment ) ...@@ -430,9 +426,8 @@ void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment )
break; break;
case S_RECT: case S_RECT:
m_gal->SetLineCap( LINE_CAP_SQUARED ); wxASSERT_MSG( false, wxT( "Not tested yet" ) );
m_gal->SetLineJoin( LINE_JOIN_BEVEL ); m_gal->DrawRectangle( VECTOR2D( aSegment->GetStart() ), VECTOR2D( aSegment->GetEnd() ) );
m_gal->DrawLine( VECTOR2D( aSegment->GetStart() ), VECTOR2D( aSegment->GetEnd() ) );
break; break;
case S_ARC: case S_ARC:
...@@ -506,8 +501,6 @@ void PCB_PAINTER::draw( const ZONE_CONTAINER* aContainer ) ...@@ -506,8 +501,6 @@ void PCB_PAINTER::draw( const ZONE_CONTAINER* aContainer )
m_gal->SetIsFill( !fillMode ); m_gal->SetIsFill( !fillMode );
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
m_gal->SetLineWidth( aContainer->GetThermalReliefCopperBridge() / 2.0 ); m_gal->SetLineWidth( aContainer->GetThermalReliefCopperBridge() / 2.0 );
m_gal->SetLineCap( LINE_CAP_ROUND );
m_gal->SetLineJoin( LINE_JOIN_ROUND );
// FIXME implement hatch mode // FIXME implement hatch mode
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment