Fix issues in print mirror. (include some changes coming from Cirilo Berdarno's patch)
gr_basic.cpp: rewrite the function which draws the outlines of a thick segment.
This commit is contained in:
parent
f214a57629
commit
29a1bdb32a
|
@ -623,18 +623,10 @@ void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC, std::vector<wxPoint>& aLines,
|
||||||
aClipBox->Inflate(-aWidth/2);
|
aClipBox->Inflate(-aWidth/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw the outline of a thick segment wih rounded ends
|
||||||
void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||||
int width, int aPenSize, EDA_COLOR_T Color )
|
int width, int aPenSize, EDA_COLOR_T Color )
|
||||||
{
|
{
|
||||||
long radius;
|
|
||||||
int dwx, dwy;
|
|
||||||
long dx, dy, dwx2, dwy2;
|
|
||||||
long sx1, sy1, ex1, ey1;
|
|
||||||
long sx2, sy2, ex2, ey2;
|
|
||||||
bool swap_ends = false;
|
|
||||||
|
|
||||||
|
|
||||||
GRLastMoveToX = x2;
|
GRLastMoveToX = x2;
|
||||||
GRLastMoveToY = y2;
|
GRLastMoveToY = y2;
|
||||||
|
|
||||||
|
@ -658,114 +650,63 @@ void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||||
GRSetColorPen( DC, Color, aPenSize );
|
GRSetColorPen( DC, Color, aPenSize );
|
||||||
GRSetBrush( DC, Color, false );
|
GRSetBrush( DC, Color, false );
|
||||||
|
|
||||||
radius = (width + 1) >> 1;
|
int radius = (width + 1) >> 1;
|
||||||
|
int dx = x2 - x1;
|
||||||
|
int dy = y2 - y1;
|
||||||
|
double angle = -ArcTangente( dy, dx );
|
||||||
|
wxPoint start;
|
||||||
|
wxPoint end;
|
||||||
|
wxPoint org( x1, y1);
|
||||||
|
int len = (int) hypot( dx, dy );
|
||||||
|
|
||||||
dx = x2 - x1;
|
// We know if the DC is mirrored, to draw arcs
|
||||||
dy = y2 - y1;
|
int slx = DC->DeviceToLogicalX( 1 ) - DC->DeviceToLogicalX( 0 );
|
||||||
|
int sly = DC->DeviceToLogicalY( 1 ) - DC->DeviceToLogicalY( 0 );
|
||||||
|
bool mirrored = (slx > 0 && sly < 0) || (slx < 0 && sly > 0);
|
||||||
|
|
||||||
if( dx == 0 ) /* segment vertical */
|
// first edge
|
||||||
{
|
start.x = 0;
|
||||||
dwx = radius;
|
start.y = radius;
|
||||||
if( dy >= 0 )
|
end.x = len;
|
||||||
dwx = -dwx;
|
end.y = radius;
|
||||||
|
RotatePoint( &start, angle);
|
||||||
|
RotatePoint( &end, angle);
|
||||||
|
|
||||||
sx1 = x1 - dwx;
|
start += org;
|
||||||
sy1 = y1;
|
end += org;
|
||||||
|
|
||||||
ex1 = x2 - dwx;
|
DC->DrawLine( start, end );
|
||||||
ey1 = y2;
|
|
||||||
|
|
||||||
DC->DrawLine( sx1, sy1, ex1, ey1 );
|
// first rounded end
|
||||||
|
end.x = 0;
|
||||||
|
end.y = -radius;
|
||||||
|
RotatePoint( &end, angle);
|
||||||
|
end += org;
|
||||||
|
|
||||||
sx2 = x1 + dwx;
|
if( !mirrored )
|
||||||
sy2 = y1;
|
DC->DrawArc( end, start, org );
|
||||||
|
|
||||||
ex2 = x2 + dwx;
|
|
||||||
ey2 = y2;
|
|
||||||
|
|
||||||
DC->DrawLine( sx2, sy2, ex2, ey2 );
|
|
||||||
}
|
|
||||||
else if( dy == 0 ) /* segment horizontal */
|
|
||||||
{
|
|
||||||
dwy = radius;
|
|
||||||
if( dx < 0 )
|
|
||||||
dwy = -dwy;
|
|
||||||
|
|
||||||
sx1 = x1;
|
|
||||||
sy1 = y1 - dwy;
|
|
||||||
|
|
||||||
ex1 = x2;
|
|
||||||
ey1 = y2 - dwy;
|
|
||||||
|
|
||||||
DC->DrawLine( sx1, sy1, ex1, ey1 );
|
|
||||||
|
|
||||||
sx2 = x1;
|
|
||||||
sy2 = y1 + dwy;
|
|
||||||
|
|
||||||
ex2 = x2;
|
|
||||||
ey2 = y2 + dwy;
|
|
||||||
|
|
||||||
DC->DrawLine( sx2, sy2, ex2, ey2 );
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
DC->DrawArc( start, end, org );
|
||||||
if( std::abs( dx ) == std::abs( dy ) ) // segment 45 degrees
|
|
||||||
{
|
|
||||||
dwx = dwy = ( (width * 5) + 4 ) / 7; // = width / 2 * 0.707
|
// second edge
|
||||||
if( dy < 0 )
|
start.x = len;
|
||||||
{
|
start.y = -radius;
|
||||||
if( dx <= 0 )
|
RotatePoint( &start, angle);
|
||||||
{
|
start += org;
|
||||||
dwx = -dwx; swap_ends = true;
|
|
||||||
}
|
DC->DrawLine( start, end );
|
||||||
}
|
|
||||||
else // dy >= 0
|
// second rounded end
|
||||||
{
|
end.x = len;
|
||||||
if( dx > 0 )
|
end.y = radius;
|
||||||
{
|
RotatePoint( &end, angle);
|
||||||
dwy = -dwy; swap_ends = true;
|
end += org;
|
||||||
}
|
|
||||||
|
if( !mirrored )
|
||||||
|
DC->DrawArc( end.x, end.y, start.x, start.y, x2, y2 );
|
||||||
else
|
else
|
||||||
swap_ends = true;
|
DC->DrawArc( start.x, start.y, end.x, end.y, x2, y2 );
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
double delta_angle = ArcTangente( dy, dx );
|
|
||||||
dwx = 0;
|
|
||||||
dwy = width;
|
|
||||||
RotatePoint( &dwx, &dwy, -delta_angle );
|
|
||||||
}
|
|
||||||
dwx2 = dwx >> 1;
|
|
||||||
dwy2 = dwy >> 1;
|
|
||||||
|
|
||||||
sx1 = x1 - dwx2;
|
|
||||||
sy1 = y1 - dwy2;
|
|
||||||
|
|
||||||
ex1 = x2 - dwx2;
|
|
||||||
ey1 = y2 - dwy2;
|
|
||||||
|
|
||||||
DC->DrawLine( sx1, sy1, ex1, ey1 );
|
|
||||||
|
|
||||||
sx2 = x1 + dwx2;
|
|
||||||
sy2 = y1 + dwy2;
|
|
||||||
|
|
||||||
ex2 = x2 + dwx2;
|
|
||||||
ey2 = y2 + dwy2;
|
|
||||||
|
|
||||||
DC->DrawLine( sx2, sy2, ex2, ey2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( swap_ends )
|
|
||||||
{
|
|
||||||
DC->DrawArc( sx2, sy2, sx1, sy1, x1, y1 );
|
|
||||||
DC->DrawArc( ex1, ey1, ex2, ey2, x2, y2 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DC->DrawArc( sx1, sy1, sx2, sy2, x1, y1 );
|
|
||||||
DC->DrawArc( ex2, ey2, ex1, ey1, x2, y2 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -200,8 +200,16 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
StAngle = ArcTangente( dy - uy0, dx - ux0 );
|
StAngle = ArcTangente( dy - uy0, dx - ux0 );
|
||||||
EndAngle = StAngle + m_Angle;
|
EndAngle = StAngle + m_Angle;
|
||||||
|
|
||||||
|
if( !panel->GetPrintMirrored() )
|
||||||
|
{
|
||||||
if( StAngle > EndAngle )
|
if( StAngle > EndAngle )
|
||||||
EXCHG( StAngle, EndAngle );
|
EXCHG( StAngle, EndAngle );
|
||||||
|
}
|
||||||
|
else // Mirrored mode: arc orientation is reversed
|
||||||
|
{
|
||||||
|
if( StAngle < EndAngle )
|
||||||
|
EXCHG( StAngle, EndAngle );
|
||||||
|
}
|
||||||
|
|
||||||
if( typeaff == LINE )
|
if( typeaff == LINE )
|
||||||
{
|
{
|
||||||
|
|
|
@ -282,7 +282,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
|
||||||
if( printMirror )
|
if( printMirror )
|
||||||
{
|
{
|
||||||
// Calculate the mirrored center of the board.
|
// Calculate the mirrored center of the board.
|
||||||
center.y = m_Parent->GetPageSizeIU().y - boardBoundingBox.Centre().y;
|
center.x = m_Parent->GetPageSizeIU().x - boardBoundingBox.Centre().x;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset += center;
|
offset += center;
|
||||||
|
@ -301,21 +301,29 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
|
||||||
screen->m_IsPrinting = true;
|
screen->m_IsPrinting = true;
|
||||||
EDA_COLOR_T bg_color = g_DrawBgColor;
|
EDA_COLOR_T bg_color = g_DrawBgColor;
|
||||||
|
|
||||||
|
// Print frame reference, if reqquested, before
|
||||||
|
if( m_PrintParams.m_Print_Black_and_White )
|
||||||
|
GRForceBlackPen( true );
|
||||||
|
|
||||||
|
if( m_PrintParams.PrintBorderAndTitleBlock() )
|
||||||
|
m_Parent->DrawWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize,
|
||||||
|
IU_PER_MILS, titleblockFilename );
|
||||||
|
|
||||||
if( printMirror )
|
if( printMirror )
|
||||||
{
|
{
|
||||||
// To plot mirror, we reverse the y axis, and modify the plot y origin
|
// To plot mirror, we reverse the x axis, and modify the plot x origin
|
||||||
dc->SetAxisOrientation( true, true );
|
dc->SetAxisOrientation( false, false);
|
||||||
|
|
||||||
/* Plot offset y is moved by the y plot area size in order to have
|
/* Plot offset x is moved by the x plot area size in order to have
|
||||||
* the old draw area in the new draw area, because the draw origin has not moved
|
* the old draw area in the new draw area, because the draw origin has not moved
|
||||||
* (this is the upper left corner) but the Y axis is reversed, therefore the plotting area
|
* (this is the upper left corner) but the X axis is reversed, therefore the plotting area
|
||||||
* is the y coordinate values from - PlotAreaSize.y to 0 */
|
* is the x coordinate values from - PlotAreaSize.x to 0 */
|
||||||
int y_dc_offset = PlotAreaSizeInPixels.y;
|
int x_dc_offset = PlotAreaSizeInPixels.x;
|
||||||
y_dc_offset = KiROUND( y_dc_offset * userscale );
|
x_dc_offset = KiROUND( x_dc_offset * userscale );
|
||||||
dc->SetDeviceOrigin( 0, y_dc_offset );
|
dc->SetDeviceOrigin( x_dc_offset, 0 );
|
||||||
|
|
||||||
wxLogTrace( tracePrinting, wxT( "Device origin: x=%d, y=%d" ),
|
wxLogTrace( tracePrinting, wxT( "Device origin: x=%d, y=%d" ),
|
||||||
0, y_dc_offset );
|
x_dc_offset, 0 );
|
||||||
|
|
||||||
panel->SetClipBox( EDA_RECT( wxPoint( -MAX_VALUE/2, -MAX_VALUE/2 ),
|
panel->SetClipBox( EDA_RECT( wxPoint( -MAX_VALUE/2, -MAX_VALUE/2 ),
|
||||||
panel->GetClipBox()->GetSize() ) );
|
panel->GetClipBox()->GetSize() ) );
|
||||||
|
@ -359,13 +367,9 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
|
||||||
printMirror, &m_PrintParams );
|
printMirror, &m_PrintParams );
|
||||||
GRForceBlackPen( false );
|
GRForceBlackPen( false );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if( m_PrintParams.m_Print_Black_and_White )
|
|
||||||
GRForceBlackPen( true );
|
GRForceBlackPen( true );
|
||||||
|
|
||||||
if( m_PrintParams.PrintBorderAndTitleBlock() )
|
|
||||||
m_Parent->DrawWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize,
|
|
||||||
IU_PER_MILS, titleblockFilename );
|
|
||||||
|
|
||||||
#if defined (GERBVIEW)
|
#if defined (GERBVIEW)
|
||||||
// In B&W mode, do not force black pen for Gerbview
|
// In B&W mode, do not force black pen for Gerbview
|
||||||
|
|
Loading…
Reference in New Issue