Fix several bugs in SCH color printing and plotting.

Fixes https://gitlab.com/kicad/code/kicad/issues/6723
This commit is contained in:
Jeff Young 2020-12-13 22:42:29 +00:00
parent 9720fc80fe
commit 9dae57ae9d
5 changed files with 78 additions and 71 deletions

View File

@ -289,10 +289,10 @@ void DIALOG_PLOT_SCHEMATIC::getPlotOptions( RENDER_SETTINGS* aSettings )
aSettings->LoadColors( colors );
aSettings->SetDefaultPenWidth( (int) m_defaultLineWidth.GetValue() );
if( m_plotBackgroundColor->GetValue() )
aSettings->SetBackgroundColor( colors->GetColor( LAYER_SCHEMATIC_BACKGROUND ) );
else
aSettings->SetBackgroundColor( COLOR4D::UNSPECIFIED );
if( m_plotBackgroundColor->GetValue() )
aSettings->SetBackgroundColor( colors->GetColor( LAYER_SCHEMATIC_BACKGROUND ) );
else
aSettings->SetBackgroundColor( COLOR4D::UNSPECIFIED );
// Plot directory
wxString path = m_outputDirectoryName->GetValue();

View File

@ -95,7 +95,7 @@ private:
// PDF
void createPDFFile( bool aPlotAll, bool aPlotFrameRef, RENDER_SETTINGS* aRenderSettings );
void plotOneSheetPDF( PLOTTER* aPlotter, SCH_SCREEN* aScreen, bool aPlotFrameRef);
void plotOneSheetPDF( PLOTTER* aPlotter, SCH_SCREEN* aScreen, bool aPlotWorksheet);
void setupPlotPagePDF( PLOTTER* aPlotter, SCH_SCREEN* aScreen );
/**

View File

@ -155,9 +155,8 @@ void DIALOG_PLOT_SCHEMATIC::restoreEnvironment( PDF_PLOTTER* aPlotter,
}
void DIALOG_PLOT_SCHEMATIC::plotOneSheetPDF( PLOTTER* aPlotter,
SCH_SCREEN* aScreen,
bool aPlotFrameRef )
void DIALOG_PLOT_SCHEMATIC::plotOneSheetPDF( PLOTTER* aPlotter, SCH_SCREEN* aScreen,
bool aPlotWorksheet )
{
if( m_plotBackgroundColor->GetValue() )
{
@ -167,15 +166,17 @@ void DIALOG_PLOT_SCHEMATIC::plotOneSheetPDF( PLOTTER* aPlotter,
aPlotter->Rect( wxPoint( 0, 0 ), end, FILL_TYPE::FILLED_SHAPE, 1.0 );
}
if( aPlotFrameRef )
if( aPlotWorksheet )
{
COLOR4D color = COLOR4D::BLACK;
if( aPlotter->GetColorMode() )
color = aPlotter->RenderSettings()->GetLayerColor( LAYER_SCHEMATIC_WORKSHEET );
PlotWorkSheet( aPlotter, &aScreen->Schematic()->Prj(), m_parent->GetTitleBlock(),
m_parent->GetPageSettings(), aScreen->GetPageNumber(),
aScreen->GetPageCount(), m_parent->GetScreenDesc(),
aScreen->GetFileName(),
aPlotter->GetColorMode() ?
aPlotter->RenderSettings()->GetLayerColor( LAYER_SCHEMATIC_WORKSHEET ) :
COLOR4D::BLACK, aScreen->GetVirtualPageNumber() == 1 );
aScreen->GetPageCount(), m_parent->GetScreenDesc(), aScreen->GetFileName(),
color, aScreen->GetVirtualPageNumber() == 1 );
}
aScreen->Plot( aPlotter );

View File

@ -549,34 +549,6 @@ void SCH_SHEET::ViewGetLayers( int aLayers[], int& aCount ) const
}
void SCH_SHEET::Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
{
wxDC* DC = aSettings->GetPrintDC();
wxPoint pos = m_pos + aOffset;
int lineWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
COLOR4D background = GetBackgroundColor();
COLOR4D border = GetBorderColor();
if( background == COLOR4D::UNSPECIFIED )
background = aSettings->GetLayerColor( LAYER_SHEET_BACKGROUND );
if( border == COLOR4D::UNSPECIFIED )
border = aSettings->GetLayerColor( LAYER_SHEET );
if( background != COLOR4D::UNSPECIFIED && background != COLOR4D::WHITE )
GRRect( nullptr, DC, pos.x, pos.y, pos.x + m_size.x, pos.y + m_size.y, background );
GRRect( nullptr, DC, pos.x, pos.y, pos.x + m_size.x, pos.y + m_size.y, lineWidth, border );
for( SCH_FIELD& field : m_fields )
field.Print( aSettings, aOffset );
/* Draw text : SheetLabel */
for( SCH_SHEET_PIN* sheetPin : m_pins )
sheetPin->Print( aSettings, aOffset );
}
const EDA_RECT SCH_SHEET::GetBodyBoundingBox() const
{
wxPoint end;
@ -959,17 +931,12 @@ bool SCH_SHEET::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
void SCH_SHEET::Plot( PLOTTER* aPlotter )
{
wxString Text;
wxPoint pos;
bool override = false;
if( KIGFX::SCH_RENDER_SETTINGS* settings =
dynamic_cast<KIGFX::SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() ) )
override = settings->m_OverrideItemColors;
COLOR4D borderColor = GetBorderColor();
COLOR4D backgroundColor = GetBackgroundColor();
wxString msg;
wxPoint pos;
auto* settings = dynamic_cast<KIGFX::SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
bool override = settings ? settings->m_OverrideItemColors : false;
COLOR4D borderColor = GetBorderColor();
COLOR4D backgroundColor = GetBackgroundColor();
if( override || borderColor == COLOR4D::UNSPECIFIED )
borderColor = aPlotter->RenderSettings()->GetLayerColor( LAYER_SHEET );
@ -980,7 +947,9 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter )
aPlotter->SetColor( backgroundColor );
// Do not fill shape in B&W mode, otherwise texts are unreadable
bool fill = aPlotter->GetColorMode();
aPlotter->Rect( m_pos, m_pos + m_size, fill ? FILL_TYPE::FILLED_SHAPE : FILL_TYPE::NO_FILL, 1.0 );
aPlotter->Rect( m_pos, m_pos + m_size, fill ? FILL_TYPE::FILLED_SHAPE : FILL_TYPE::NO_FILL,
1.0 );
aPlotter->SetColor( borderColor );
@ -1010,6 +979,39 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter )
}
void SCH_SHEET::Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
{
wxDC* DC = aSettings->GetPrintDC();
wxPoint pos = m_pos + aOffset;
int lineWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
auto* settings = dynamic_cast<KIGFX::SCH_RENDER_SETTINGS*>( aSettings );
bool override = settings ? settings->m_OverrideItemColors : false;
COLOR4D border = GetBorderColor();
COLOR4D background = GetBackgroundColor();
if( override || border == COLOR4D::UNSPECIFIED )
border = aSettings->GetLayerColor( LAYER_SHEET );
if( override || background == COLOR4D::UNSPECIFIED )
background = aSettings->GetLayerColor( LAYER_SHEET_BACKGROUND );
if( background != COLOR4D::UNSPECIFIED )
{
GRFilledRect( nullptr, DC, pos.x, pos.y, pos.x + m_size.x, pos.y + m_size.y, 0,
background, background );
}
GRRect( nullptr, DC, pos.x, pos.y, pos.x + m_size.x, pos.y + m_size.y, lineWidth, border );
for( SCH_FIELD& field : m_fields )
field.Print( aSettings, aOffset );
/* Draw text : SheetLabel */
for( SCH_SHEET_PIN* sheetPin : m_pins )
sheetPin->Print( aSettings, aOffset );
}
SCH_SHEET& SCH_SHEET::operator=( const SCH_ITEM& aItem )
{
wxCHECK_MSG( Type() == aItem.Type(), *this,

View File

@ -602,11 +602,15 @@ bool SCH_TEXT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
void SCH_TEXT::Plot( PLOTTER* aPlotter )
{
static std::vector<wxPoint> Poly;
COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( GetLayer() );
int penWidth = GetEffectiveTextPenWidth( aPlotter->RenderSettings()->GetDefaultPenWidth() );
static std::vector<wxPoint> s_poly;
penWidth = std::max( penWidth, aPlotter->RenderSettings()->GetMinPenWidth() );
RENDER_SETTINGS* settings = aPlotter->RenderSettings();
SCH_CONNECTION* connection = Connection();
int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer;
COLOR4D color = settings->GetLayerColor( layer );
int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() );
penWidth = std::max( penWidth, settings->GetMinPenWidth() );
aPlotter->SetCurrentLineWidth( penWidth );
if( IsMultilineAllowed() )
@ -635,10 +639,10 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter )
}
// Draw graphic symbol for global or hierarchical labels
CreateGraphicShape( aPlotter->RenderSettings(), Poly, GetTextPos() );
CreateGraphicShape( aPlotter->RenderSettings(), s_poly, GetTextPos() );
if( Poly.size() )
aPlotter->PlotPoly( Poly, FILL_TYPE::NO_FILL, penWidth );
if( s_poly.size() )
aPlotter->PlotPoly( s_poly, FILL_TYPE::NO_FILL, penWidth );
}
@ -1152,21 +1156,21 @@ bool SCH_GLOBALLABEL::ResolveTextVar( wxString* token, int aDepth ) const
void SCH_GLOBALLABEL::Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
{
static std::vector <wxPoint> Poly;
static std::vector<wxPoint> s_poly;
wxDC* DC = aSettings->GetPrintDC();
COLOR4D color = aSettings->GetLayerColor( m_layer );
int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
wxPoint text_offset = aOffset + GetSchematicTextOffset( aSettings );
SCH_CONNECTION* connection = Connection();
int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer;
wxDC* DC = aSettings->GetPrintDC();
COLOR4D color = aSettings->GetLayerColor( layer );
int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
wxPoint text_offset = aOffset + GetSchematicTextOffset( aSettings );
EDA_TEXT::Print( aSettings, text_offset, color );
CreateGraphicShape( aSettings, Poly, GetTextPos() + aOffset );
GRPoly( nullptr, DC, Poly.size(), &Poly[0], false, penWidth, color, color );
CreateGraphicShape( aSettings, s_poly, GetTextPos() + aOffset );
GRPoly( nullptr, DC, s_poly.size(), &s_poly[0], false, penWidth, color, color );
bool show = Schematic()->Settings().m_IntersheetRefsShow;
if ( show )
if( Schematic()->Settings().m_IntersheetRefsShow )
m_intersheetRefsField.Print( aSettings, aOffset );
}