mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-20 00:21:31 +00:00
Remove a bunch of globals.
This commit is contained in:
parent
99c1d7cf96
commit
9c8941e040
3d-viewer/3d_canvas
common
CMakeLists.txt
dialogs
eda_draw_frame.cppeda_text.cppgr_text.cppmarker_base.cpppage_layout
painter.cppplotters
DXF_plotter.cppGERBER_plotter.cppHPGL_plotter.cppPDF_plotter.cppPS_plotter.cppSVG_plotter.cppcommon_plot_functions.cppplotter.cpp
render_settings.cppeeschema
class_libentry.cppclass_libentry.h
dialogs
dialog_edit_component_in_schematic.cppdialog_edit_label.cppdialog_edit_line_style.cppdialog_fields_editor_global.cppdialog_lib_edit_pin.cppdialog_plot_schematic.cppdialog_plot_schematic.hdialog_print_using_printer.cppdialog_sch_sheet_props.cppdialog_update_fields.cpppanel_eeschema_color_settings.cpppanel_setup_formatting.cpp
edit_label.cppeeschema.cppeeschema_config.cppfiles-io.cppgeneral.hlib_arc.cpplib_arc.hlib_bezier.cpplib_bezier.hlib_circle.cpplib_circle.hlib_field.cpplib_field.hlib_item.cpplib_item.hlib_pin.cpplib_pin.hlib_polyline.cpplib_polyline.hlib_rectangle.cpplib_rectangle.hlib_text.cpplib_text.hlibedit
plot_schematic_DXF.cppplot_schematic_HPGL.cppplot_schematic_PDF.cppplot_schematic_PS.cppplot_schematic_SVG.cppproject_rescue.cppsch_base_frame.cppsch_base_frame.hsch_bitmap.cppsch_bitmap.hsch_bus_entry.cppsch_bus_entry.hsch_component.cppsch_component.hsch_eagle_plugin.cppsch_edit_frame.cppsch_edit_frame.hsch_field.cppsch_field.hsch_item.hsch_junction.cppsch_junction.hsch_legacy_plugin.cppsch_line.cppsch_line.hsch_marker.cppsch_marker.hsch_no_connect.cppsch_no_connect.hsch_painter.cppsch_painter.hsch_pin.hsch_preview_panel.cppsch_screen.cppsch_screen.hsch_sexpr_parser.cppsch_sheet.cppsch_sheet.hsch_sheet_pin.cppsch_text.cppsch_text.hsheet.cpptools
include
eda_draw_frame.heda_text.hgr_text.hmarker_base.hpainter.hplotter.hrender_settings.hws_draw_item.hws_painter.h
pagelayout_editor
pcbnew
altium2kicadpcb_plugin
board_items_to_polygon_shape_transform.cppclass_dimension.cppclass_marker_pcb.cppclass_marker_pcb.hclass_pcb_text.cppclass_pcb_text.hclass_text_mod.cppclass_text_mod.hclass_track.cppdialogs
dialog_edit_footprint_for_BoardEditor.cppdialog_edit_footprint_for_fp_editor.cppdialog_global_edit_text_and_graphics.cppdialog_text_properties.cpp
drc
eagle_plugin.cppexporters
footprint_libraries_utils.cppgpcb_plugin.cppimport_gfx
legacy_plugin.cppmicrowave
pad_print_functions.cpppcad2kicadpcb_plugin
pcb_painter.cpppcb_parser.cpppcbplot.cppplot_board_layers.cppplot_brditems_plotter.cpprouter
text_mod_grid_table.cpptools
@ -93,7 +93,7 @@ void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const TEXTE_PCB* aText,
|
||||
|
||||
s_boardItem = (const BOARD_ITEM *) &aText;
|
||||
s_dstcontainer = aDstContainer;
|
||||
s_textWidth = aText->GetEffectiveTextPenWidth( nullptr ) + ( 2 * aClearanceValue );
|
||||
s_textWidth = aText->GetEffectiveTextPenWidth() + ( 2 * aClearanceValue );
|
||||
s_biuTo3Dunits = m_biuTo3Dunits;
|
||||
|
||||
// not actually used, but needed by GRText
|
||||
@ -107,22 +107,22 @@ void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const TEXTE_PCB* aText,
|
||||
wxStringSplit( aText->GetShownText(), strings_list, '\n' );
|
||||
std::vector<wxPoint> positions;
|
||||
positions.reserve( strings_list.Count() );
|
||||
aText->GetPositionsOfLinesOfMultilineText( positions, strings_list.Count() );
|
||||
aText->GetLinePositions( positions, strings_list.Count());
|
||||
|
||||
for( unsigned ii = 0; ii < strings_list.Count(); ++ii )
|
||||
{
|
||||
wxString txt = strings_list.Item( ii );
|
||||
|
||||
GRText( nullptr, positions[ii], dummy_color, txt, aText->GetTextAngle(), size,
|
||||
aText->GetHorizJustify(), aText->GetVertJustify(), penWidth, aText->IsItalic(),
|
||||
penWidth, addTextSegmToContainer );
|
||||
aText->GetHorizJustify(), aText->GetVertJustify(), penWidth,
|
||||
aText->IsItalic(), forceBold, 0, addTextSegmToContainer );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GRText( nullptr, aText->GetTextPos(), dummy_color, aText->GetShownText(),
|
||||
aText->GetTextAngle(), size, aText->GetHorizJustify(), aText->GetVertJustify(),
|
||||
penWidth, aText->IsItalic(), penWidth, addTextSegmToContainer );
|
||||
penWidth, aText->IsItalic(), forceBold, 0, addTextSegmToContainer );
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@ void BOARD_ADAPTER::AddGraphicsShapesWithClearanceToContainer( const MODULE* aMo
|
||||
|
||||
for( TEXTE_MODULE* text : texts )
|
||||
{
|
||||
s_textWidth = text->GetEffectiveTextPenWidth( nullptr ) + ( 2 * aInflateValue );
|
||||
s_textWidth = text->GetEffectiveTextPenWidth() + ( 2 * aInflateValue );
|
||||
wxSize size = text->GetTextSize();
|
||||
bool forceBold = true;
|
||||
int penWidth = 0; // force max width for bold
|
||||
@ -227,7 +227,7 @@ void BOARD_ADAPTER::AddGraphicsShapesWithClearanceToContainer( const MODULE* aMo
|
||||
|
||||
GRText( NULL, text->GetTextPos(), BLACK, text->GetShownText(), text->GetDrawRotation(),
|
||||
size, text->GetHorizJustify(), text->GetVertJustify(), penWidth, text->IsItalic(),
|
||||
forceBold, addTextSegmToContainer );
|
||||
forceBold, 0, addTextSegmToContainer );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,6 +330,7 @@ set( COMMON_SRCS
|
||||
ptree.cpp
|
||||
rc_item.cpp
|
||||
refdes_utils.cpp
|
||||
render_settings.cpp
|
||||
reporter.cpp
|
||||
richio.cpp
|
||||
search_stack.cpp
|
||||
|
@ -756,10 +756,15 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample()
|
||||
GRResetPenAndBrush( &memDC );
|
||||
|
||||
WS_DATA_MODEL::SetAltInstance( m_pagelayout );
|
||||
KIGFX::WS_RENDER_SETTINGS renderSettings;
|
||||
renderSettings.SetDefaultPenWidth( 1 );
|
||||
renderSettings.SetLayerColor( LAYER_WORKSHEET, COLOR4D( RED ) );
|
||||
renderSettings.SetPrintDC( &memDC );
|
||||
|
||||
GRFilledRect( NULL, &memDC, 0, 0, m_layout_size.x, m_layout_size.y, WHITE, WHITE );
|
||||
PrintPageLayout( &memDC, pageDUMMY, emptyString, emptyString, m_tb,
|
||||
m_screen->m_NumberOfScreens, m_screen->m_ScreenNumber, 1, 1, RED,
|
||||
&Prj() );
|
||||
|
||||
PrintPageLayout( &renderSettings, pageDUMMY, emptyString, emptyString, m_tb,
|
||||
m_screen->m_NumberOfScreens, m_screen->m_ScreenNumber, 1, &Prj() );
|
||||
|
||||
memDC.SelectObject( wxNullBitmap );
|
||||
m_PageLayoutExampleBitmap->SetBitmap( *m_page_bitmap );
|
||||
|
@ -243,7 +243,7 @@ void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
|
||||
}
|
||||
|
||||
|
||||
void EDA_DRAW_FRAME::PrintPage( wxDC* aDC )
|
||||
void EDA_DRAW_FRAME::PrintPage( RENDER_SETTINGS* aSettings )
|
||||
{
|
||||
wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") );
|
||||
}
|
||||
@ -728,14 +728,14 @@ void EDA_DRAW_FRAME::FocusOnLocation( const wxPoint& aPos )
|
||||
|
||||
static const wxString productName = wxT( "KiCad E.D.A. " );
|
||||
|
||||
void PrintPageLayout( wxDC* aDC, const PAGE_INFO& aPageInfo, const wxString& aFullSheetName,
|
||||
const wxString& aFileName, const TITLE_BLOCK& aTitleBlock, int aSheetCount,
|
||||
int aSheetNumber, int aPenWidth, double aScalar, COLOR4D aColor,
|
||||
const PROJECT* aProject, const wxString& aSheetLayer )
|
||||
void PrintPageLayout( RENDER_SETTINGS* aSettings, const PAGE_INFO& aPageInfo,
|
||||
const wxString& aFullSheetName, const wxString& aFileName,
|
||||
const TITLE_BLOCK& aTitleBlock, int aSheetCount, int aSheetNumber,
|
||||
double aScalar, const PROJECT* aProject, const wxString& aSheetLayer )
|
||||
{
|
||||
WS_DRAW_ITEM_LIST drawList;
|
||||
|
||||
drawList.SetDefaultPenSize( aPenWidth );
|
||||
drawList.SetDefaultPenSize( aSettings->GetDefaultPenWidth() );
|
||||
drawList.SetMilsToIUfactor( aScalar );
|
||||
drawList.SetSheetNumber( aSheetNumber );
|
||||
drawList.SetSheetCount( aSheetCount );
|
||||
@ -747,35 +747,34 @@ void PrintPageLayout( wxDC* aDC, const PAGE_INFO& aPageInfo, const wxString& aFu
|
||||
drawList.BuildWorkSheetGraphicList( aPageInfo, aTitleBlock );
|
||||
|
||||
// Draw item list
|
||||
drawList.Print( aDC, aColor );
|
||||
drawList.Print( aSettings );
|
||||
}
|
||||
|
||||
|
||||
void EDA_DRAW_FRAME::PrintWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth,
|
||||
void EDA_DRAW_FRAME::PrintWorkSheet( RENDER_SETTINGS* aSettings, BASE_SCREEN* aScreen,
|
||||
double aScalar, const wxString &aFilename,
|
||||
const wxString &aSheetLayer, COLOR4D aColor )
|
||||
const wxString &aSheetLayer )
|
||||
{
|
||||
if( !m_showBorderAndTitleBlock )
|
||||
return;
|
||||
|
||||
COLOR4D color = ( aColor != COLOR4D::UNSPECIFIED ) ? aColor : COLOR4D( RED );
|
||||
|
||||
wxPoint origin = aDC->GetDeviceOrigin();
|
||||
wxDC* DC = aSettings->GetPrintDC();
|
||||
wxPoint origin = DC->GetDeviceOrigin();
|
||||
|
||||
if( origin.y > 0 )
|
||||
{
|
||||
aDC->SetDeviceOrigin( 0, 0 );
|
||||
aDC->SetAxisOrientation( true, false );
|
||||
DC->SetDeviceOrigin( 0, 0 );
|
||||
DC->SetAxisOrientation( true, false );
|
||||
}
|
||||
|
||||
PrintPageLayout( aDC, GetPageSettings(), GetScreenDesc(), aFilename, GetTitleBlock(),
|
||||
aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber, aLineWidth, aScalar,
|
||||
color, &Prj(), aSheetLayer );
|
||||
PrintPageLayout( aSettings, GetPageSettings(), GetScreenDesc(), aFilename, GetTitleBlock(),
|
||||
aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber, aScalar, &Prj(),
|
||||
aSheetLayer );
|
||||
|
||||
if( origin.y > 0 )
|
||||
{
|
||||
aDC->SetDeviceOrigin( origin.x, origin.y );
|
||||
aDC->SetAxisOrientation( true, true );
|
||||
DC->SetDeviceOrigin( origin.x, origin.y );
|
||||
DC->SetAxisOrientation( true, true );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,8 @@ EDA_TEXT_VJUSTIFY_T EDA_TEXT::MapVertJustify( int aVertJustify )
|
||||
}
|
||||
|
||||
|
||||
EDA_TEXT::EDA_TEXT( const wxString& text ) :
|
||||
EDA_TEXT::EDA_TEXT( const wxString& text, int aTextMarkupFlags ) :
|
||||
m_textMarkupFlags( aTextMarkupFlags ),
|
||||
m_text( text ),
|
||||
m_e( 1<<TE_VISIBLE )
|
||||
{
|
||||
@ -96,6 +97,7 @@ EDA_TEXT::EDA_TEXT( const wxString& text ) :
|
||||
|
||||
|
||||
EDA_TEXT::EDA_TEXT( const EDA_TEXT& aText ) :
|
||||
m_textMarkupFlags( aText.m_textMarkupFlags ),
|
||||
m_text( aText.m_text ),
|
||||
m_e( aText.m_e )
|
||||
{
|
||||
@ -141,15 +143,17 @@ void EDA_TEXT::SwapEffects( EDA_TEXT& aTradingPartner )
|
||||
}
|
||||
|
||||
|
||||
int EDA_TEXT::GetEffectiveTextPenWidth( RENDER_SETTINGS* aSettings ) const
|
||||
int EDA_TEXT::GetEffectiveTextPenWidth() const
|
||||
{
|
||||
int width = GetTextPenWidth();
|
||||
int width = GetTextThickness();
|
||||
|
||||
if( width == 0 && IsBold() )
|
||||
width = GetPenSizeForBold( GetTextWidth() );
|
||||
|
||||
if( width <= 0 && aSettings )
|
||||
width = aSettings->GetDefaultTextThickness();
|
||||
if( width <= 0 )
|
||||
{
|
||||
if( IsBold() )
|
||||
width = GetPenSizeForBold( GetTextWidth() );
|
||||
else
|
||||
width = 1;
|
||||
}
|
||||
|
||||
// Clip pen size for small texts:
|
||||
width = Clamp_Text_PenSize( width, GetTextSize(), IsBold() );
|
||||
@ -198,15 +202,14 @@ int EDA_TEXT::GetInterline() const
|
||||
}
|
||||
|
||||
|
||||
EDA_RECT EDA_TEXT::GetTextBox( RENDER_SETTINGS* aSettings, int aLine, bool aInvertY ) const
|
||||
EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
|
||||
{
|
||||
EDA_RECT rect;
|
||||
wxArrayString strings;
|
||||
wxString text = GetShownText();
|
||||
int thickness = GetEffectiveTextPenWidth( aSettings );
|
||||
int thickness = GetEffectiveTextPenWidth();
|
||||
int linecount = 1;
|
||||
bool hasOverBar = false; // true if the first line of text as an overbar
|
||||
int markupFlags = aSettings ? aSettings->GetTextMarkupFlags() : 0;
|
||||
|
||||
if( IsMultilineAllowed() )
|
||||
{
|
||||
@ -236,14 +239,14 @@ EDA_RECT EDA_TEXT::GetTextBox( RENDER_SETTINGS* aSettings, int aLine, bool aInve
|
||||
|
||||
// calculate the H and V size
|
||||
const auto& font = basic_gal.GetStrokeFont();
|
||||
VECTOR2D size( GetTextSize() );
|
||||
VECTOR2D fontSize( GetTextSize() );
|
||||
double penWidth( thickness );
|
||||
int dx = KiROUND( font.ComputeStringBoundaryLimits( text, size, penWidth, markupFlags ).x );
|
||||
int dy = GetInterline();
|
||||
int dx = KiROUND( font.ComputeStringBoundaryLimits( text, fontSize, penWidth,
|
||||
m_textMarkupFlags ).x );
|
||||
int dy = GetInterline();
|
||||
|
||||
// Creates bounding box (rectangle) for an horizontal
|
||||
// and left and top justified text. the bounding box will be moved later
|
||||
// according to the actual text options
|
||||
// Creates bounding box (rectangle) for horizontal, left and top justified text. The
|
||||
// bounding box will be moved later according to the actual text options
|
||||
wxSize textsize = wxSize( dx, dy );
|
||||
wxPoint pos = GetTextPos();
|
||||
|
||||
@ -263,7 +266,9 @@ EDA_RECT EDA_TEXT::GetTextBox( RENDER_SETTINGS* aSettings, int aLine, bool aInve
|
||||
{ // A overbar adds an extra size to the text
|
||||
// Height from the base line text of chars like [ or {
|
||||
double curr_height = GetTextHeight() * 1.15;
|
||||
int extra_height = KiROUND( font.ComputeOverbarVerticalPosition( size.y, penWidth ) - curr_height );
|
||||
double overbarPosition = font.ComputeOverbarVerticalPosition( fontSize.y, penWidth );
|
||||
int extra_height = KiROUND( overbarPosition - curr_height );
|
||||
|
||||
extra_height += thickness / 2;
|
||||
textsize.y += extra_height;
|
||||
rect.Move( wxPoint( 0, -extra_height ) );
|
||||
@ -276,7 +281,8 @@ EDA_RECT EDA_TEXT::GetTextBox( RENDER_SETTINGS* aSettings, int aLine, bool aInve
|
||||
for( unsigned ii = 1; ii < strings.GetCount(); ii++ )
|
||||
{
|
||||
text = strings.Item( ii );
|
||||
dx = KiROUND( font.ComputeStringBoundaryLimits( text, size, penWidth, markupFlags ).x );
|
||||
dx = KiROUND( font.ComputeStringBoundaryLimits( text, fontSize, penWidth,
|
||||
m_textMarkupFlags ).x );
|
||||
textsize.x = std::max( textsize.x, dx );
|
||||
textsize.y += dy;
|
||||
}
|
||||
@ -353,7 +359,7 @@ EDA_RECT EDA_TEXT::GetTextBox( RENDER_SETTINGS* aSettings, int aLine, bool aInve
|
||||
|
||||
bool EDA_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
|
||||
{
|
||||
EDA_RECT rect = GetTextBox( nullptr ); // JEY TODO: requires RENDER_SETTINGS
|
||||
EDA_RECT rect = GetTextBox();
|
||||
wxPoint location = aPoint;
|
||||
|
||||
rect.Inflate( aAccuracy );
|
||||
@ -370,13 +376,14 @@ bool EDA_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy
|
||||
rect.Inflate( aAccuracy );
|
||||
|
||||
if( aContains )
|
||||
return rect.Contains( GetTextBox( nullptr ) ); // JEY TODO: requires RENDER_SETTINGS
|
||||
return rect.Contains( GetTextBox() );
|
||||
|
||||
return rect.Intersects( GetTextBox( nullptr ), GetTextAngle() ); // JEY TODO: requires RENDER_SETTINGS
|
||||
return rect.Intersects( GetTextBox(), GetTextAngle() );
|
||||
}
|
||||
|
||||
|
||||
void EDA_TEXT::Print( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor, EDA_DRAW_MODE_T aFillMode )
|
||||
void EDA_TEXT::Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset, COLOR4D aColor,
|
||||
EDA_DRAW_MODE_T aFillMode )
|
||||
{
|
||||
if( IsMultilineAllowed() )
|
||||
{
|
||||
@ -386,21 +393,19 @@ void EDA_TEXT::Print( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor, EDA_DRA
|
||||
|
||||
positions.reserve( strings.Count() );
|
||||
|
||||
GetPositionsOfLinesOfMultilineText( positions, strings.Count() );
|
||||
GetLinePositions( positions, strings.Count());
|
||||
|
||||
for( unsigned ii = 0; ii < strings.Count(); ii++ )
|
||||
{
|
||||
wxString& txt = strings.Item( ii );
|
||||
printOneLineOfText( aDC, aOffset, aColor, aFillMode, txt, positions[ii] );
|
||||
}
|
||||
printOneLineOfText( aSettings, aOffset, aColor, aFillMode, strings[ii], positions[ii] );
|
||||
}
|
||||
else
|
||||
printOneLineOfText( aDC, aOffset, aColor, aFillMode, GetShownText(), GetTextPos() );
|
||||
{
|
||||
printOneLineOfText( aSettings, aOffset, aColor, aFillMode, GetShownText(), GetTextPos() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EDA_TEXT::GetPositionsOfLinesOfMultilineText(
|
||||
std::vector<wxPoint>& aPositions, int aLineCount ) const
|
||||
void EDA_TEXT::GetLinePositions( std::vector<wxPoint>& aPositions, int aLineCount ) const
|
||||
{
|
||||
wxPoint pos = GetTextPos(); // Position of first line of the
|
||||
// multiline text according to
|
||||
@ -441,22 +446,23 @@ void EDA_TEXT::GetPositionsOfLinesOfMultilineText(
|
||||
}
|
||||
}
|
||||
|
||||
void EDA_TEXT::printOneLineOfText( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor,
|
||||
EDA_DRAW_MODE_T aFillMode, const wxString& aText,
|
||||
const wxPoint &aPos )
|
||||
void EDA_TEXT::printOneLineOfText( RENDER_SETTINGS* aSettings, const wxPoint& aOffset,
|
||||
COLOR4D aColor, EDA_DRAW_MODE_T aFillMode,
|
||||
const wxString& aText, const wxPoint &aPos )
|
||||
{
|
||||
int width = GetEffectiveTextPenWidth( nullptr );
|
||||
wxDC* DC = aSettings->GetPrintDC();
|
||||
int penWidth = std::max( GetEffectiveTextPenWidth(), aSettings->GetDefaultPenWidth() );
|
||||
|
||||
if( aFillMode == SKETCH )
|
||||
width = -width;
|
||||
penWidth = -penWidth;
|
||||
|
||||
wxSize size = GetTextSize();
|
||||
|
||||
if( IsMirrored() )
|
||||
size.x = -size.x;
|
||||
|
||||
GRText( aDC, aOffset + aPos, aColor, aText, GetTextAngle(), size, GetHorizJustify(),
|
||||
GetVertJustify(), width, IsItalic(), IsBold() );
|
||||
GRText( DC, aOffset + aPos, aColor, aText, GetTextAngle(), size, GetHorizJustify(),
|
||||
GetVertJustify(), penWidth, IsItalic(), IsBold(), m_textMarkupFlags );
|
||||
}
|
||||
|
||||
|
||||
@ -483,11 +489,11 @@ wxString EDA_TEXT::GetTextStyleName()
|
||||
|
||||
bool EDA_TEXT::IsDefaultFormatting() const
|
||||
{
|
||||
return ( IsVisible()
|
||||
&& !IsMirrored()
|
||||
&& GetHorizJustify() == GR_TEXT_HJUSTIFY_CENTER
|
||||
&& GetVertJustify() == GR_TEXT_VJUSTIFY_CENTER
|
||||
&& GetTextPenWidth() == 0
|
||||
return ( IsVisible()
|
||||
&& !IsMirrored()
|
||||
&& GetHorizJustify() == GR_TEXT_HJUSTIFY_CENTER
|
||||
&& GetVertJustify() == GR_TEXT_VJUSTIFY_CENTER
|
||||
&& GetTextThickness() == 0
|
||||
&& !IsItalic()
|
||||
&& !IsBold()
|
||||
&& !IsMultilineAllowed()
|
||||
@ -510,8 +516,8 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
|
||||
FormatInternalUnits( GetTextHeight() ).c_str(),
|
||||
FormatInternalUnits( GetTextWidth() ).c_str() );
|
||||
|
||||
if( GetTextPenWidth() )
|
||||
aFormatter->Print( 0, " (thickness %s)", FormatInternalUnits( GetTextPenWidth() ).c_str() );
|
||||
if( GetTextThickness() )
|
||||
aFormatter->Print( 0, " (thickness %s)", FormatInternalUnits( GetTextThickness() ).c_str() );
|
||||
|
||||
if( IsBold() )
|
||||
aFormatter->Print( 0, " bold" );
|
||||
@ -577,20 +583,20 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuf
|
||||
wxStringSplit( GetShownText(), strings_list, wxChar('\n') );
|
||||
std::vector<wxPoint> positions;
|
||||
positions.reserve( strings_list.Count() );
|
||||
GetPositionsOfLinesOfMultilineText( positions,strings_list.Count() );
|
||||
GetLinePositions( positions, strings_list.Count());
|
||||
|
||||
for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
|
||||
{
|
||||
wxString txt = strings_list.Item( ii );
|
||||
GRText( NULL, positions[ii], color, txt, GetTextAngle(), size, GetHorizJustify(),
|
||||
GetVertJustify(), penWidth, IsItalic(), forceBold, addTextSegmToBuffer,
|
||||
GetVertJustify(), penWidth, IsItalic(), forceBold, 0, addTextSegmToBuffer,
|
||||
&aCornerBuffer );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GRText( NULL, GetTextPos(), color, GetText(), GetTextAngle(), size, GetHorizJustify(),
|
||||
GetVertJustify(), penWidth, IsItalic(), forceBold, addTextSegmToBuffer,
|
||||
GetVertJustify(), penWidth, IsItalic(), forceBold, 0, addTextSegmToBuffer,
|
||||
&aCornerBuffer );
|
||||
}
|
||||
}
|
||||
|
@ -43,21 +43,6 @@
|
||||
#include <basic_gal.h>
|
||||
|
||||
|
||||
static int s_textMarkupFlags = 0;
|
||||
|
||||
|
||||
void SetTextMarkupFlags( int aMarkupFlags )
|
||||
{
|
||||
s_textMarkupFlags = aMarkupFlags;
|
||||
}
|
||||
|
||||
|
||||
int GetTextMarkupFlags()
|
||||
{
|
||||
return s_textMarkupFlags;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function GetPensizeForBold
|
||||
* @return the "best" value for a pen size to draw/plot a bold text
|
||||
@ -143,7 +128,7 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool aItalic,
|
||||
void GRText( wxDC* aDC, const wxPoint& aPos, COLOR4D aColor, const wxString& aText,
|
||||
double aOrient, const wxSize& aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
||||
enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold,
|
||||
void (* aCallback)( int x0, int y0, int xf, int yf, void* aData ),
|
||||
int aMarkupFlags, void (* aCallback)( int x0, int y0, int xf, int yf, void* aData ),
|
||||
void* aCallbackData, PLOTTER* aPlotter )
|
||||
{
|
||||
bool fill_mode = true;
|
||||
@ -181,14 +166,14 @@ void GRText( wxDC* aDC, const wxPoint& aPos, COLOR4D aColor, const wxString& aTe
|
||||
basic_gal.m_Color = aColor;
|
||||
basic_gal.SetClipBox( nullptr );
|
||||
|
||||
basic_gal.StrokeText( aText, VECTOR2D( aPos ), aOrient * M_PI/1800, GetTextMarkupFlags() );
|
||||
basic_gal.StrokeText( aText, VECTOR2D( aPos ), aOrient * M_PI/1800, aMarkupFlags );
|
||||
}
|
||||
|
||||
|
||||
void GRHaloText( wxDC * aDC, const wxPoint &aPos, const COLOR4D aBgColor, COLOR4D aColor1,
|
||||
void GRHaloText( wxDC * aDC, const wxPoint &aPos, COLOR4D aBgColor, COLOR4D aColor1,
|
||||
COLOR4D aColor2, const wxString &aText, double aOrient, const wxSize &aSize,
|
||||
enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
||||
int aWidth, bool aItalic, bool aBold,
|
||||
int aWidth, bool aItalic, bool aBold, int aMarkupFlags,
|
||||
void (*aCallback)( int x0, int y0, int xf, int yf, void* aData ),
|
||||
void* aCallbackData, PLOTTER * aPlotter )
|
||||
{
|
||||
@ -203,13 +188,14 @@ void GRHaloText( wxDC * aDC, const wxPoint &aPos, const COLOR4D aBgColor, COLOR4
|
||||
|
||||
// Draw the background
|
||||
GRText( aDC, aPos, aColor1, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic,
|
||||
aBold, aCallback, aCallbackData, aPlotter );
|
||||
aBold, aMarkupFlags, aCallback, aCallbackData, aPlotter );
|
||||
|
||||
// Draw the text
|
||||
GRText( aDC, aPos, aColor2, aText, aOrient, aSize, aH_justify, aV_justify, aWidth/4, aItalic,
|
||||
aBold, aCallback, aCallbackData, aPlotter );
|
||||
aBold, aMarkupFlags, aCallback, aCallbackData, aPlotter );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function PLOTTER::Text
|
||||
* same as GRText, but plot graphic text insteed of draw it
|
||||
@ -237,11 +223,12 @@ void PLOTTER::Text( const wxPoint& aPos,
|
||||
int aPenWidth,
|
||||
bool aItalic,
|
||||
bool aBold,
|
||||
int aTextMarkupFlags,
|
||||
bool aMultilineAllowed,
|
||||
void* aData )
|
||||
{
|
||||
SetColor( aColor );
|
||||
|
||||
GRText( NULL, aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aPenWidth,
|
||||
aItalic, aBold, nullptr, nullptr, this );
|
||||
aItalic, aBold, aTextMarkupFlags, nullptr, nullptr, this );
|
||||
}
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "macros.h"
|
||||
#include "marker_base.h"
|
||||
#include <geometry/shape_line_chain.h>
|
||||
#include <render_settings.h>
|
||||
#include "dialog_display_info_HTML_base.h"
|
||||
|
||||
|
||||
@ -182,8 +183,10 @@ EDA_RECT MARKER_BASE::GetBoundingBoxMarker() const
|
||||
}
|
||||
|
||||
|
||||
void MARKER_BASE::PrintMarker( wxDC* aDC, const wxPoint& aOffset )
|
||||
void MARKER_BASE::PrintMarker( RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
|
||||
{
|
||||
wxDC* DC = aSettings->GetPrintDC();
|
||||
|
||||
// Build the marker shape polygon in internal units:
|
||||
std::vector<wxPoint> shape;
|
||||
shape.reserve( CORNERS_COUNT );
|
||||
@ -191,5 +194,5 @@ void MARKER_BASE::PrintMarker( wxDC* aDC, const wxPoint& aOffset )
|
||||
for( const VECTOR2I& corner : MarkerShapeCorners )
|
||||
shape.emplace_back( corner * MarkerScale() + m_Pos + aOffset );
|
||||
|
||||
GRClosedPoly( nullptr, aDC, CORNERS_COUNT, &shape[0], true, 0, getColor(), getColor() );
|
||||
GRClosedPoly( nullptr, DC, CORNERS_COUNT, &shape[0], true, 0, getColor(), getColor() );
|
||||
}
|
||||
|
@ -714,7 +714,7 @@ void WS_DATA_ITEM_TEXT::SetConstrainedTextSize()
|
||||
dummy.SetVertJustify( m_Vjustify );
|
||||
dummy.SetTextAngle( m_Orient * 10 );
|
||||
|
||||
EDA_RECT rect = dummy.GetTextBox( nullptr ); // JEY TODO: requires RENDER_SETTINGS
|
||||
EDA_RECT rect = dummy.GetTextBox();
|
||||
DSIZE size;
|
||||
size.x = rect.GetWidth() / FSCALE;
|
||||
size.y = rect.GetHeight() / FSCALE;
|
||||
|
@ -155,15 +155,15 @@ void WS_DRAW_ITEM_BASE::GetMsgPanelInfo( EDA_UNITS aUnits, MSG_PANEL_ITEMS& aLis
|
||||
|
||||
// ============================ TEXT ==============================
|
||||
|
||||
void WS_DRAW_ITEM_TEXT::PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor )
|
||||
void WS_DRAW_ITEM_TEXT::PrintWsItem( RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
|
||||
{
|
||||
Print( aDC, aOffset, aColor, FILLED );
|
||||
Print( aSettings, aOffset, aSettings->GetLayerColor( LAYER_WORKSHEET ), FILLED );
|
||||
}
|
||||
|
||||
|
||||
const EDA_RECT WS_DRAW_ITEM_TEXT::GetBoundingBox() const
|
||||
{
|
||||
return EDA_TEXT::GetTextBox( nullptr ); // JEY TODO: requires RENDER_SETTINGS
|
||||
return EDA_TEXT::GetTextBox();
|
||||
}
|
||||
|
||||
|
||||
@ -190,8 +190,12 @@ wxString WS_DRAW_ITEM_TEXT::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
|
||||
// ============================ POLYGON =================================
|
||||
|
||||
void WS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor )
|
||||
void WS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem( RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
|
||||
{
|
||||
wxDC* DC = aSettings->GetPrintDC();
|
||||
COLOR4D color = aSettings->GetLayerColor( LAYER_WORKSHEET );
|
||||
int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
|
||||
|
||||
std::vector<wxPoint> points_moved;
|
||||
|
||||
for( int idx = 0; idx < m_Polygons.OutlineCount(); ++idx )
|
||||
@ -200,11 +204,13 @@ void WS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem( wxDC* aDC, const wxPoint& aOffset,
|
||||
SHAPE_LINE_CHAIN& outline = m_Polygons.Outline( idx );
|
||||
|
||||
for( int ii = 0; ii < outline.PointCount(); ii++ )
|
||||
points_moved.emplace_back(
|
||||
outline.CPoint( ii ).x + aOffset.x, outline.CPoint( ii ).y + aOffset.y );
|
||||
{
|
||||
points_moved.emplace_back( outline.CPoint( ii ).x + aOffset.x,
|
||||
outline.CPoint( ii ).y + aOffset.y );
|
||||
}
|
||||
|
||||
GRPoly( nullptr, aDC, points_moved.size(), &points_moved[0], FILLED_SHAPE,
|
||||
GetPenWidth(), aColor, aColor );
|
||||
GRPoly( nullptr, DC, points_moved.size(), &points_moved[0], FILLED_SHAPE, penWidth,
|
||||
color, color );
|
||||
}
|
||||
}
|
||||
|
||||
@ -289,10 +295,14 @@ wxString WS_DRAW_ITEM_POLYPOLYGONS::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
|
||||
// ============================ RECT ==============================
|
||||
|
||||
void WS_DRAW_ITEM_RECT::PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor )
|
||||
void WS_DRAW_ITEM_RECT::PrintWsItem( RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
|
||||
{
|
||||
GRRect( nullptr, aDC, GetStart().x + aOffset.x, GetStart().y + aOffset.y,
|
||||
GetEnd().x + aOffset.x, GetEnd().y + aOffset.y, GetPenWidth(), aColor );
|
||||
wxDC* DC = aSettings->GetPrintDC();
|
||||
COLOR4D color = aSettings->GetLayerColor( LAYER_WORKSHEET );
|
||||
int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
|
||||
|
||||
GRRect( nullptr, DC, GetStart().x + aOffset.x, GetStart().y + aOffset.y,
|
||||
GetEnd().x + aOffset.x, GetEnd().y + aOffset.y, penWidth, color );
|
||||
}
|
||||
|
||||
|
||||
@ -348,9 +358,13 @@ wxString WS_DRAW_ITEM_RECT::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
|
||||
// ============================ LINE ==============================
|
||||
|
||||
void WS_DRAW_ITEM_LINE::PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor )
|
||||
void WS_DRAW_ITEM_LINE::PrintWsItem( RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
|
||||
{
|
||||
GRLine( nullptr, aDC, GetStart() + aOffset, GetEnd() + aOffset, GetPenWidth(), aColor );
|
||||
wxDC* DC = aSettings->GetPrintDC();
|
||||
COLOR4D color = aSettings->GetLayerColor( LAYER_WORKSHEET );
|
||||
int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
|
||||
|
||||
GRLine( nullptr, DC, GetStart() + aOffset, GetEnd() + aOffset, penWidth, color );
|
||||
}
|
||||
|
||||
|
||||
@ -362,7 +376,7 @@ const EDA_RECT WS_DRAW_ITEM_LINE::GetBoundingBox() const
|
||||
|
||||
bool WS_DRAW_ITEM_LINE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||
{
|
||||
int mindist = aAccuracy + ( GetPenWidth() / 2 );
|
||||
int mindist = aAccuracy + ( GetPenWidth() / 2 ) + 1;
|
||||
return TestSegmentHit( aPosition, GetStart(), GetEnd(), mindist );
|
||||
}
|
||||
|
||||
@ -379,12 +393,12 @@ wxString WS_DRAW_ITEM_LINE::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
|
||||
// ============== BITMAP ================
|
||||
|
||||
void WS_DRAW_ITEM_BITMAP::PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor )
|
||||
void WS_DRAW_ITEM_BITMAP::PrintWsItem( RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
|
||||
{
|
||||
WS_DATA_ITEM_BITMAP* bitmap = (WS_DATA_ITEM_BITMAP*) GetPeer();
|
||||
|
||||
if( bitmap->m_ImageBitmap )
|
||||
bitmap->m_ImageBitmap->DrawBitmap( aDC, m_pos + aOffset );
|
||||
if( bitmap->m_ImageBitmap )
|
||||
bitmap->m_ImageBitmap->DrawBitmap( aSettings->GetPrintDC(), m_pos + aOffset );
|
||||
}
|
||||
|
||||
|
||||
@ -480,20 +494,20 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( const PAGE_INFO& aPageInfo,
|
||||
* The selected items are drawn after (usually 0 or 1)
|
||||
* to be sure they are seen, even for overlapping items
|
||||
*/
|
||||
void WS_DRAW_ITEM_LIST::Print( wxDC* aDC, COLOR4D aColor )
|
||||
void WS_DRAW_ITEM_LIST::Print( RENDER_SETTINGS* aSettings )
|
||||
{
|
||||
std::vector<WS_DRAW_ITEM_BASE*> second_items;
|
||||
|
||||
for( WS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() )
|
||||
{
|
||||
if( item->Type() == WSG_BITMAP_T )
|
||||
item->PrintWsItem( aDC, aColor );
|
||||
item->PrintWsItem( aSettings );
|
||||
else
|
||||
second_items.push_back( item );
|
||||
}
|
||||
|
||||
for( auto item : second_items )
|
||||
item->PrintWsItem( aDC, aColor );
|
||||
item->PrintWsItem( aSettings );
|
||||
}
|
||||
|
||||
|
||||
|
@ -250,7 +250,7 @@ void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_LINE* aItem, int aLayer ) const
|
||||
m_gal->SetIsStroke( true );
|
||||
m_gal->SetIsFill( false );
|
||||
m_gal->SetStrokeColor( m_renderSettings.GetColor( aItem, aLayer ) );
|
||||
m_gal->SetLineWidth( aItem->GetPenWidth() );
|
||||
m_gal->SetLineWidth( std::max( aItem->GetPenWidth(), m_renderSettings.GetDefaultPenWidth() ) );
|
||||
m_gal->DrawLine( VECTOR2D( aItem->GetStart() ), VECTOR2D( aItem->GetEnd() ) );
|
||||
}
|
||||
|
||||
@ -260,7 +260,7 @@ void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_RECT* aItem, int aLayer ) const
|
||||
m_gal->SetIsStroke( true );
|
||||
m_gal->SetIsFill( false );
|
||||
m_gal->SetStrokeColor( m_renderSettings.GetColor( aItem, aLayer ) );
|
||||
m_gal->SetLineWidth( aItem->GetPenWidth() );
|
||||
m_gal->SetLineWidth( std::max( aItem->GetPenWidth(), m_renderSettings.GetDefaultPenWidth() ) );
|
||||
m_gal->DrawRectangle( VECTOR2D( aItem->GetStart() ), VECTOR2D( aItem->GetEnd() ) );
|
||||
}
|
||||
|
||||
@ -284,12 +284,14 @@ void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_POLYPOLYGONS* aItem, int aLayer
|
||||
void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_TEXT* aItem, int aLayer ) const
|
||||
{
|
||||
VECTOR2D position( aItem->GetTextPos().x, aItem->GetTextPos().y );
|
||||
int penWidth = std::max( aItem->GetEffectiveTextPenWidth(),
|
||||
m_renderSettings.GetDefaultPenWidth() );
|
||||
|
||||
m_gal->Save();
|
||||
m_gal->Translate( position );
|
||||
m_gal->Rotate( -aItem->GetTextAngle() * M_PI / 1800.0 );
|
||||
m_gal->SetStrokeColor( m_renderSettings.GetColor( aItem, aLayer ) );
|
||||
m_gal->SetLineWidth( aItem->GetEffectiveTextPenWidth( nullptr ) ); // JEY TODO: requires RENDER_SETTINGS
|
||||
m_gal->SetLineWidth( penWidth );
|
||||
m_gal->SetTextAttributes( aItem );
|
||||
m_gal->SetIsFill( false );
|
||||
m_gal->SetIsStroke( true );
|
||||
|
@ -29,43 +29,6 @@
|
||||
|
||||
using namespace KIGFX;
|
||||
|
||||
RENDER_SETTINGS::RENDER_SETTINGS()
|
||||
{
|
||||
// Set the default initial values
|
||||
m_highlightFactor = 0.5f;
|
||||
m_selectFactor = 0.5f;
|
||||
m_highlightItems = false;
|
||||
m_highlightEnabled = false;
|
||||
m_hiContrastEnabled = false;
|
||||
m_hiContrastFactor = 0.2f; //TODO: Make this user-configurable
|
||||
m_highlightNetcode = -1;
|
||||
m_outlineWidth = 1;
|
||||
m_worksheetLineWidth = 100000;
|
||||
m_defaultPenWidth = 0;
|
||||
m_textMarkupFlags = 0;
|
||||
m_showPageLimits = false;
|
||||
}
|
||||
|
||||
|
||||
RENDER_SETTINGS::~RENDER_SETTINGS()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void RENDER_SETTINGS::update()
|
||||
{
|
||||
// Calculate darkened/highlighted variants of layer colors
|
||||
for( int i = 0; i < LAYER_ID_COUNT; i++ )
|
||||
{
|
||||
m_hiContrastColor[i] = m_layerColors[i].Mix( m_layerColors[LAYER_PCB_BACKGROUND],
|
||||
m_hiContrastFactor );
|
||||
m_layerColorsHi[i] = m_layerColors[i].Brightened( m_highlightFactor );
|
||||
m_layerColorsDark[i] = m_layerColors[i].Darkened( 1.0 - m_highlightFactor );
|
||||
m_layerColorsSel[i] = m_layerColors[i].Brightened( m_selectFactor );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PAINTER::PAINTER( GAL* aGal ) :
|
||||
m_gal( aGal ),
|
||||
m_brightenedColor( 0.0, 1.0, 0.0, 0.9 )
|
||||
|
@ -169,7 +169,6 @@ void DXF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
||||
iuPerDeviceUnit = 1.0 / aIusPerDecimil; // Gives a DXF in decimils
|
||||
iuPerDeviceUnit *= GetUnitScaling(); // Get the scaling factor for the current units
|
||||
|
||||
SetDefaultLineWidth( 0 ); // No line width on DXF
|
||||
m_plotMirror = false; // No mirroring on DXF
|
||||
m_currentColor = COLOR4D::BLACK;
|
||||
}
|
||||
@ -871,6 +870,7 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
|
||||
int aWidth,
|
||||
bool aItalic,
|
||||
bool aBold,
|
||||
int aTextMarkupFlags,
|
||||
bool aMultilineAllowed,
|
||||
void* aData )
|
||||
{
|
||||
@ -880,10 +880,10 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
|
||||
|
||||
bool processSuperSub = false;
|
||||
|
||||
if( ( GetTextMarkupFlags() & ENABLE_SUBSCRIPT_MARKUP ) && aText.Contains( wxT( "#" ) ) )
|
||||
if( ( aTextMarkupFlags & ENABLE_SUBSCRIPT_MARKUP ) && aText.Contains( wxT( "#" ) ) )
|
||||
processSuperSub = true;
|
||||
|
||||
if( ( GetTextMarkupFlags() & ENABLE_SUPERSCRIPT_MARKUP ) && aText.Contains( wxT( "^" ) ) )
|
||||
if( ( aTextMarkupFlags & ENABLE_SUPERSCRIPT_MARKUP ) && aText.Contains( wxT( "^" ) ) )
|
||||
processSuperSub = true;
|
||||
|
||||
if( m_textAsLines || containsNonAsciiChars( aText ) || aMultilineAllowed || processSuperSub )
|
||||
@ -892,7 +892,7 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
|
||||
// Perhaps multiline texts could be handled as DXF text entity
|
||||
// but I do not want spend time about this (JPC)
|
||||
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
|
||||
aWidth, aItalic, aBold, aMultilineAllowed );
|
||||
aWidth, aItalic, aBold, aTextMarkupFlags, aMultilineAllowed );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -83,7 +83,6 @@ void GERBER_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
||||
// origin at the origin
|
||||
paperSize.x = 0;
|
||||
paperSize.y = 0;
|
||||
SetDefaultLineWidth( 100 * aIusPerDecimil ); // Arbitrary default
|
||||
}
|
||||
|
||||
|
||||
@ -283,30 +282,13 @@ bool GERBER_PLOTTER::EndPlot()
|
||||
}
|
||||
|
||||
|
||||
void GERBER_PLOTTER::SetDefaultLineWidth( int width )
|
||||
void GERBER_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData )
|
||||
{
|
||||
defaultPenWidth = width;
|
||||
m_currentApertureIdx = -1;
|
||||
}
|
||||
|
||||
|
||||
void GERBER_PLOTTER::SetCurrentLineWidth( int width, void* aData )
|
||||
{
|
||||
if( width == DO_NOT_SET_LINE_WIDTH )
|
||||
return;
|
||||
|
||||
int pen_width;
|
||||
|
||||
if( width > 0 )
|
||||
pen_width = width;
|
||||
else
|
||||
pen_width = defaultPenWidth;
|
||||
|
||||
GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
|
||||
int aperture_attribute = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
|
||||
|
||||
selectAperture( wxSize( pen_width, pen_width ), APERTURE::AT_PLOTTING, aperture_attribute );
|
||||
currentPenWidth = pen_width;
|
||||
selectAperture( wxSize( aWidth, aWidth ), APERTURE::AT_PLOTTING, aperture_attribute );
|
||||
currentPenWidth = aWidth;
|
||||
}
|
||||
|
||||
|
||||
@ -1183,16 +1165,16 @@ void GERBER_PLOTTER::FlashRegularPolygon( const wxPoint& aShapePos,
|
||||
void GERBER_PLOTTER::Text( const wxPoint& aPos, const COLOR4D aColor,
|
||||
const wxString& aText, double aOrient, const wxSize& aSize,
|
||||
enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
||||
int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed,
|
||||
void* aData )
|
||||
int aWidth, bool aItalic, bool aBold, int aTextMarkupFlags,
|
||||
bool aMultilineAllowed, void* aData )
|
||||
{
|
||||
GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
|
||||
|
||||
if( gbr_metadata )
|
||||
formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
|
||||
|
||||
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize,
|
||||
aH_justify, aV_justify, aWidth, aItalic, aBold, aMultilineAllowed, aData );
|
||||
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic,
|
||||
aBold, aTextMarkupFlags, aMultilineAllowed, aData );
|
||||
}
|
||||
|
||||
|
||||
|
@ -234,7 +234,6 @@ void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
||||
paperSize = pageInfo.GetSizeMils();
|
||||
paperSize.x *= 10.0 * aIusPerDecimil;
|
||||
paperSize.y *= 10.0 * aIusPerDecimil;
|
||||
SetDefaultLineWidth( 0 ); // HPGL has pen sizes instead
|
||||
m_plotMirror = aMirror;
|
||||
}
|
||||
|
||||
|
@ -74,8 +74,6 @@ void PDF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
||||
// The CTM is set to 1 user unit per decimil
|
||||
iuPerDeviceUnit = 1.0 / aIusPerDecimil;
|
||||
|
||||
SetDefaultLineWidth( 100 / iuPerDeviceUnit ); // arbitrary default
|
||||
|
||||
/* The paper size in this engined is handled page by page
|
||||
Look in the StartPage function */
|
||||
}
|
||||
@ -89,23 +87,17 @@ void PDF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
||||
* no outline thickness
|
||||
* use in this case pen width = 1 does not actally change the polygon
|
||||
*/
|
||||
void PDF_PLOTTER::SetCurrentLineWidth( int width, void* aData )
|
||||
void PDF_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData )
|
||||
{
|
||||
wxASSERT( workFile );
|
||||
int pen_width;
|
||||
|
||||
if( width > 0 )
|
||||
pen_width = width;
|
||||
else if( width == 0 )
|
||||
pen_width = 1;
|
||||
else
|
||||
pen_width = defaultPenWidth;
|
||||
if( aWidth == 0 )
|
||||
aWidth = 1;
|
||||
|
||||
if( pen_width != currentPenWidth )
|
||||
fprintf( workFile, "%g w\n",
|
||||
userToDeviceSize( pen_width ) );
|
||||
if( aWidth != currentPenWidth )
|
||||
fprintf( workFile, "%g w\n", userToDeviceSize( aWidth ) );
|
||||
|
||||
currentPenWidth = pen_width;
|
||||
currentPenWidth = aWidth;
|
||||
}
|
||||
|
||||
|
||||
@ -585,7 +577,7 @@ void PDF_PLOTTER::StartPage()
|
||||
fprintf( workFile,
|
||||
"%g 0 0 %g 0 0 cm 1 J 1 j 0 0 0 rg 0 0 0 RG %g w\n",
|
||||
0.0072 * plotScaleAdjX, 0.0072 * plotScaleAdjY,
|
||||
userToDeviceSize( defaultPenWidth ) );
|
||||
userToDeviceSize( m_renderSettings->GetDefaultPenWidth() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -812,6 +804,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
|
||||
int aWidth,
|
||||
bool aItalic,
|
||||
bool aBold,
|
||||
int aTextMarkupFlags,
|
||||
bool aMultilineAllowed,
|
||||
void* aData )
|
||||
{
|
||||
@ -840,9 +833,9 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
|
||||
double wideningFactor, heightFactor;
|
||||
|
||||
computeTextParameters( aPos, aText, aOrient, aSize, m_plotMirror, aH_justify,
|
||||
aV_justify, aWidth, aItalic, aBold,
|
||||
&wideningFactor, &ctm_a, &ctm_b, &ctm_c,
|
||||
&ctm_d, &ctm_e, &ctm_f, &heightFactor );
|
||||
aV_justify, aWidth, aItalic, aBold,
|
||||
&wideningFactor, &ctm_a, &ctm_b, &ctm_c,
|
||||
&ctm_d, &ctm_e, &ctm_f, &heightFactor );
|
||||
|
||||
SetColor( aColor );
|
||||
SetCurrentLineWidth( aWidth, aData );
|
||||
@ -886,8 +879,8 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
|
||||
// Plot the stroked text (if requested)
|
||||
if( !use_native_font )
|
||||
{
|
||||
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
|
||||
aWidth, aItalic, aBold, aMultilineAllowed );
|
||||
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth,
|
||||
aItalic, aBold, aTextMarkupFlags, aMultilineAllowed );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,13 +50,6 @@ const double PSLIKE_PLOTTER::postscriptTextAscent = 0.718;
|
||||
|
||||
// Common routines for Postscript-like plotting engines
|
||||
|
||||
void PSLIKE_PLOTTER::SetDefaultLineWidth( int width )
|
||||
{
|
||||
defaultPenWidth = width;
|
||||
currentPenWidth = -1;
|
||||
}
|
||||
|
||||
|
||||
void PSLIKE_PLOTTER::SetColor( COLOR4D color )
|
||||
{
|
||||
if( colorMode )
|
||||
@ -422,7 +415,6 @@ void PS_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
||||
paperSize = pageInfo.GetSizeMils();
|
||||
paperSize.x *= 10.0 * aIusPerDecimil;
|
||||
paperSize.y *= 10.0 * aIusPerDecimil;
|
||||
SetDefaultLineWidth( 100 * aIusPerDecimil ); // arbitrary default
|
||||
}
|
||||
|
||||
|
||||
@ -525,20 +517,14 @@ void PSLIKE_PLOTTER::computeTextParameters( const wxPoint& aPos,
|
||||
|
||||
/* Set the current line width (in IUs) for the next plot
|
||||
*/
|
||||
void PS_PLOTTER::SetCurrentLineWidth( int width, void* aData )
|
||||
void PS_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData )
|
||||
{
|
||||
wxASSERT( outputFile );
|
||||
int pen_width;
|
||||
|
||||
if( width >= 0 )
|
||||
pen_width = width;
|
||||
else
|
||||
pen_width = defaultPenWidth;
|
||||
if( aWidth != GetCurrentLineWidth() )
|
||||
fprintf( outputFile, "%g setlinewidth\n", userToDeviceSize( aWidth ) );
|
||||
|
||||
if( pen_width != GetCurrentLineWidth() )
|
||||
fprintf( outputFile, "%g setlinewidth\n", userToDeviceSize( pen_width ) );
|
||||
|
||||
currentPenWidth = pen_width;
|
||||
currentPenWidth = aWidth;
|
||||
}
|
||||
|
||||
|
||||
@ -942,9 +928,9 @@ bool PS_PLOTTER::StartPlot()
|
||||
// within the Document Structuring Convention.
|
||||
fputs( "%%Page: 1 1\n"
|
||||
"%%BeginPageSetup\n"
|
||||
"gsave\n"
|
||||
"0.0072 0.0072 scale\n" // Configure postscript for decimils coordinates
|
||||
"linemode1\n", outputFile );
|
||||
"gsave\n"
|
||||
"0.0072 0.0072 scale\n" // Configure postscript for decimils coordinates
|
||||
"linemode1\n", outputFile );
|
||||
|
||||
|
||||
// Rototranslate the coordinate to achieve the landscape layout
|
||||
@ -953,11 +939,11 @@ bool PS_PLOTTER::StartPlot()
|
||||
|
||||
// Apply the user fine scale adjustments
|
||||
if( plotScaleAdjX != 1.0 || plotScaleAdjY != 1.0 )
|
||||
fprintf( outputFile, "%g %g scale\n",
|
||||
plotScaleAdjX, plotScaleAdjY );
|
||||
fprintf( outputFile, "%g %g scale\n", plotScaleAdjX, plotScaleAdjY );
|
||||
|
||||
// Set default line width
|
||||
fprintf( outputFile, "%g setlinewidth\n", userToDeviceSize( defaultPenWidth ) );
|
||||
fprintf( outputFile, "%g setlinewidth\n",
|
||||
userToDeviceSize( m_renderSettings->GetDefaultPenWidth() ) );
|
||||
fputs( "%%EndPageSetup\n", outputFile );
|
||||
|
||||
return true;
|
||||
@ -988,6 +974,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos,
|
||||
int aWidth,
|
||||
bool aItalic,
|
||||
bool aBold,
|
||||
int aTextMarkupFlags,
|
||||
bool aMultilineAllowed,
|
||||
void* aData )
|
||||
{
|
||||
@ -1000,10 +987,10 @@ void PS_PLOTTER::Text( const wxPoint& aPos,
|
||||
|
||||
bool processSuperSub = false;
|
||||
|
||||
if( ( GetTextMarkupFlags() & ENABLE_SUBSCRIPT_MARKUP ) && aText.Contains( wxT( "#" ) ) )
|
||||
if( ( aTextMarkupFlags & ENABLE_SUBSCRIPT_MARKUP ) && aText.Contains( wxT( "#" ) ) )
|
||||
processSuperSub = true;
|
||||
|
||||
if( ( GetTextMarkupFlags() & ENABLE_SUPERSCRIPT_MARKUP ) && aText.Contains( wxT( "^" ) ) )
|
||||
if( ( aTextMarkupFlags & ENABLE_SUPERSCRIPT_MARKUP ) && aText.Contains( wxT( "^" ) ) )
|
||||
processSuperSub = true;
|
||||
|
||||
// Draw the native postscript text (if requested)
|
||||
@ -1067,7 +1054,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos,
|
||||
if( !use_native )
|
||||
{
|
||||
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
|
||||
aWidth, aItalic, aBold, aMultilineAllowed );
|
||||
aWidth, aItalic, aBold, aTextMarkupFlags, aMultilineAllowed );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,6 @@ void SVG_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
||||
paperSize = pageInfo.GetSizeMils();
|
||||
paperSize.x *= 10.0 * aIusPerDecimil;
|
||||
paperSize.y *= 10.0 * aIusPerDecimil;
|
||||
SetDefaultLineWidth( 100 * aIusPerDecimil ); // arbitrary default
|
||||
}
|
||||
|
||||
|
||||
@ -276,19 +275,12 @@ void SVG_PLOTTER::setSVGPlotStyle( bool aIsGroup, const std::string& aExtraStyle
|
||||
|
||||
/* Set the current line width (in IUs) for the next plot
|
||||
*/
|
||||
void SVG_PLOTTER::SetCurrentLineWidth( int width, void* aData )
|
||||
void SVG_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData )
|
||||
{
|
||||
int pen_width;
|
||||
|
||||
if( width >= 0 )
|
||||
pen_width = width;
|
||||
else
|
||||
pen_width = defaultPenWidth;
|
||||
|
||||
if( pen_width != currentPenWidth )
|
||||
if( aWidth != currentPenWidth )
|
||||
{
|
||||
m_graphics_changed = true;
|
||||
currentPenWidth = pen_width;
|
||||
currentPenWidth = aWidth;
|
||||
}
|
||||
|
||||
if( m_graphics_changed )
|
||||
@ -756,6 +748,7 @@ void SVG_PLOTTER::Text( const wxPoint& aPos,
|
||||
int aWidth,
|
||||
bool aItalic,
|
||||
bool aBold,
|
||||
int aTextMarkupFlags,
|
||||
bool aMultilineAllowed,
|
||||
void* aData )
|
||||
{
|
||||
@ -763,14 +756,6 @@ void SVG_PLOTTER::Text( const wxPoint& aPos,
|
||||
SetColor( aColor );
|
||||
SetCurrentLineWidth( aWidth );
|
||||
|
||||
int width = currentPenWidth;
|
||||
|
||||
if( aWidth <= 0 && aBold )
|
||||
width = GetPenSizeForBold( std::min( aSize.x, aSize.y ) );
|
||||
|
||||
if( aWidth <= 0 )
|
||||
width = currentPenWidth;
|
||||
|
||||
wxPoint text_pos = aPos;
|
||||
const char *hjust = "start";
|
||||
|
||||
@ -806,7 +791,7 @@ void SVG_PLOTTER::Text( const wxPoint& aPos,
|
||||
wxSize text_size;
|
||||
// aSize.x or aSize.y is < 0 for mirrored texts.
|
||||
// The actual text size value is the absolue value
|
||||
text_size.x = std::abs( GraphicTextWidth( aText, aSize, aItalic, width ) );
|
||||
text_size.x = std::abs( GraphicTextWidth( aText, aSize, aItalic, aWidth ) );
|
||||
text_size.y = std::abs( aSize.x * 4/3 ); // Hershey font height to em size conversion
|
||||
DPOINT anchor_pos_dev = userToDeviceCoordinates( aPos );
|
||||
DPOINT text_pos_dev = userToDeviceCoordinates( text_pos );
|
||||
@ -833,6 +818,6 @@ void SVG_PLOTTER::Text( const wxPoint& aPos,
|
||||
"<g class=\"stroked-text\"><desc>%s</desc>\n",
|
||||
TO_UTF8( XmlEsc( aText ) ) );
|
||||
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
|
||||
aWidth, aItalic, aBold, aMultilineAllowed );
|
||||
aWidth, aItalic, aBold, aTextMarkupFlags, aMultilineAllowed );
|
||||
fputs( "</g>", outputFile );
|
||||
}
|
||||
|
@ -64,8 +64,8 @@ void PlotWorkSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BLOCK
|
||||
/* Note: Page sizes values are given in mils
|
||||
*/
|
||||
double iusPerMil = plotter->GetIUsPerDecimil() * 10.0;
|
||||
|
||||
COLOR4D plotColor = plotter->GetColorMode() ? aColor : COLOR4D::BLACK;
|
||||
COLOR4D plotColor = plotter->GetColorMode() ? aColor : COLOR4D::BLACK;
|
||||
int defaultPenWidth = plotter->RenderSettings()->GetDefaultPenWidth();
|
||||
|
||||
if( plotColor == COLOR4D::UNSPECIFIED )
|
||||
plotColor = COLOR4D( RED );
|
||||
@ -97,7 +97,7 @@ void PlotWorkSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BLOCK
|
||||
case WSG_LINE_T:
|
||||
{
|
||||
WS_DRAW_ITEM_LINE* line = (WS_DRAW_ITEM_LINE*) item;
|
||||
plotter->SetCurrentLineWidth( line->GetPenWidth() );
|
||||
plotter->SetCurrentLineWidth( std::max( line->GetPenWidth(), defaultPenWidth ) );
|
||||
plotter->MoveTo( line->GetStart() );
|
||||
plotter->FinishTo( line->GetEnd() );
|
||||
}
|
||||
@ -106,24 +106,26 @@ void PlotWorkSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BLOCK
|
||||
case WSG_RECT_T:
|
||||
{
|
||||
WS_DRAW_ITEM_RECT* rect = (WS_DRAW_ITEM_RECT*) item;
|
||||
plotter->Rect( rect->GetStart(), rect->GetEnd(), NO_FILL, rect->GetPenWidth() );
|
||||
int penWidth = std::max( rect->GetPenWidth(), defaultPenWidth );
|
||||
plotter->Rect( rect->GetStart(), rect->GetEnd(), NO_FILL, penWidth );
|
||||
}
|
||||
break;
|
||||
|
||||
case WSG_TEXT_T:
|
||||
{
|
||||
WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item;
|
||||
int penWidth = std::max( text->GetEffectiveTextPenWidth(), defaultPenWidth );
|
||||
plotter->Text( text->GetTextPos(), plotColor, text->GetShownText(),
|
||||
text->GetTextAngle(), text->GetTextSize(),
|
||||
text->GetHorizJustify(), text->GetVertJustify(),
|
||||
text->GetEffectiveTextPenWidth( nullptr ),
|
||||
text->IsItalic(), text->IsBold(), text->IsMultilineAllowed() );
|
||||
text->GetTextAngle(), text->GetTextSize(), text->GetHorizJustify(),
|
||||
text->GetVertJustify(), penWidth, text->IsItalic(), text->IsBold(),
|
||||
text->GetTextMarkupFlags(), text->IsMultilineAllowed() );
|
||||
}
|
||||
break;
|
||||
|
||||
case WSG_POLY_T:
|
||||
{
|
||||
WS_DRAW_ITEM_POLYPOLYGONS* poly = (WS_DRAW_ITEM_POLYPOLYGONS*) item;
|
||||
int penWidth = std::max( poly->GetPenWidth(), defaultPenWidth );
|
||||
std::vector<wxPoint> points;
|
||||
|
||||
for( int idx = 0; idx < poly->GetPolygons().OutlineCount(); ++idx )
|
||||
@ -134,7 +136,7 @@ void PlotWorkSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BLOCK
|
||||
for( int ii = 0; ii < outline.PointCount(); ii++ )
|
||||
points.emplace_back( outline.CPoint( ii ).x, outline.CPoint( ii ).y );
|
||||
|
||||
plotter->PlotPoly( points, FILLED_SHAPE, poly->GetPenWidth() );
|
||||
plotter->PlotPoly( points, FILLED_SHAPE, penWidth );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -39,14 +39,9 @@
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <vector>
|
||||
|
||||
#include <trigo.h>
|
||||
#include <eda_base_frame.h>
|
||||
#include <base_struct.h>
|
||||
#include <common.h>
|
||||
#include <plotter.h>
|
||||
#include <macros.h>
|
||||
#include <base_screen.h>
|
||||
#include <gr_text.h>
|
||||
#include <geometry/shape_line_chain.h>
|
||||
#include <geometry/geometry_utils.h>
|
||||
@ -56,19 +51,18 @@
|
||||
PLOTTER::PLOTTER( )
|
||||
{
|
||||
plotScale = 1;
|
||||
defaultPenWidth = 0;
|
||||
currentPenWidth = -1; // To-be-set marker
|
||||
penState = 'Z'; // End-of-path idle
|
||||
m_plotMirror = false; // Plot mirror option flag
|
||||
m_mirrorIsHorizontal = true;
|
||||
m_yaxisReversed = false;
|
||||
outputFile = 0;
|
||||
m_colors = nullptr;
|
||||
colorMode = false; // Starts as a BW plot
|
||||
negativeMode = false;
|
||||
// Temporary init to avoid not initialized vars, will be set later
|
||||
m_IUsPerDecimil = 1; // will be set later to the actual value
|
||||
iuPerDeviceUnit = 1; // will be set later to the actual value
|
||||
m_renderSettings = nullptr;
|
||||
}
|
||||
|
||||
PLOTTER::~PLOTTER()
|
||||
|
64
common/render_settings.cpp
Normal file
64
common/render_settings.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <render_settings.h>
|
||||
|
||||
using namespace KIGFX;
|
||||
|
||||
|
||||
RENDER_SETTINGS::RENDER_SETTINGS() :
|
||||
m_printDC( nullptr )
|
||||
{
|
||||
// Set the default initial values
|
||||
m_highlightFactor = 0.5f;
|
||||
m_selectFactor = 0.5f;
|
||||
m_highlightItems = false;
|
||||
m_highlightEnabled = false;
|
||||
m_hiContrastEnabled = false;
|
||||
m_hiContrastFactor = 0.2f; //TODO: Make this user-configurable
|
||||
m_highlightNetcode = -1;
|
||||
m_outlineWidth = 1;
|
||||
m_worksheetLineWidth = 100000;
|
||||
m_defaultPenWidth = 0;
|
||||
m_showPageLimits = false;
|
||||
}
|
||||
|
||||
|
||||
RENDER_SETTINGS::~RENDER_SETTINGS()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void RENDER_SETTINGS::update()
|
||||
{
|
||||
// Calculate darkened/highlighted variants of layer colors
|
||||
for( int i = 0; i < LAYER_ID_COUNT; i++ )
|
||||
{
|
||||
m_hiContrastColor[i] = m_layerColors[i].Mix( m_layerColors[LAYER_PCB_BACKGROUND],
|
||||
m_hiContrastFactor );
|
||||
m_layerColorsHi[i] = m_layerColors[i].Brightened( m_highlightFactor );
|
||||
m_layerColorsDark[i] = m_layerColors[i].Darkened( 1.0 - m_highlightFactor );
|
||||
m_layerColorsSel[i] = m_layerColors[i].Brightened( m_selectFactor );
|
||||
}
|
||||
}
|
||||
|
@ -426,8 +426,8 @@ wxString LIB_PART::SubReference( int aUnit, bool aAddSeparator )
|
||||
}
|
||||
|
||||
|
||||
void LIB_PART::Print( wxDC* aDc, const wxPoint& aOffset, int aMulti, int aConvert,
|
||||
const PART_DRAW_OPTIONS& aOpts )
|
||||
void LIB_PART::Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset, int aMulti,
|
||||
int aConvert, const PART_DRAW_OPTIONS& aOpts )
|
||||
{
|
||||
/* draw background for filled items using background option
|
||||
* Solid lines will be drawn after the background
|
||||
@ -452,7 +452,7 @@ void LIB_PART::Print( wxDC* aDc, const wxPoint& aOffset, int aMulti, int aConver
|
||||
|
||||
// Now, draw only the background for items with
|
||||
// m_Fill == FILLED_WITH_BG_BODYCOLOR:
|
||||
drawItem.Print( aDc, aOffset, (void*) false, aOpts.transform );
|
||||
drawItem.Print( aSettings, aOffset, (void*) false, aOpts.transform );
|
||||
}
|
||||
}
|
||||
|
||||
@ -478,16 +478,16 @@ void LIB_PART::Print( wxDC* aDc, const wxPoint& aOffset, int aMulti, int aConver
|
||||
|
||||
if( drawItem.Type() == LIB_PIN_T )
|
||||
{
|
||||
drawItem.Print( aDc, aOffset, (void*) &aOpts, aOpts.transform );
|
||||
drawItem.Print( aSettings, aOffset, (void*) &aOpts, aOpts.transform );
|
||||
}
|
||||
else if( drawItem.Type() == LIB_FIELD_T )
|
||||
{
|
||||
drawItem.Print( aDc, aOffset, (void*) NULL, aOpts.transform );
|
||||
drawItem.Print( aSettings, aOffset, (void*) NULL, aOpts.transform );
|
||||
}
|
||||
else
|
||||
{
|
||||
bool forceNoFill = drawItem.m_Fill == FILLED_WITH_BG_BODYCOLOR;
|
||||
drawItem.Print( aDc, aOffset, (void*) forceNoFill, aOpts.transform );
|
||||
drawItem.Print( aSettings, aOffset, (void*) forceNoFill, aOpts.transform );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -498,7 +498,7 @@ void LIB_PART::Plot( PLOTTER* aPlotter, int aUnit, int aConvert,
|
||||
{
|
||||
wxASSERT( aPlotter != NULL );
|
||||
|
||||
aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( LAYER_DEVICE ) );
|
||||
aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE ) );
|
||||
bool fill = aPlotter->GetColorMode();
|
||||
|
||||
// draw background for filled items using background option
|
||||
@ -544,7 +544,7 @@ void LIB_PART::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert,
|
||||
{
|
||||
wxASSERT( aPlotter != NULL );
|
||||
|
||||
aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( LAYER_FIELDS ) );
|
||||
aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_FIELDS ) );
|
||||
bool fill = aPlotter->GetColorMode();
|
||||
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
|
@ -65,19 +65,19 @@ extern bool operator<( const LIB_PART& aItem1, const LIB_PART& aItem2 );
|
||||
|
||||
struct PART_DRAW_OPTIONS
|
||||
{
|
||||
TRANSFORM transform; ///< Coordinate adjustment settings
|
||||
bool draw_visible_fields; ///< Whether to draw "visible" fields
|
||||
bool draw_hidden_fields; ///< Whether to draw "hidden" fields
|
||||
bool show_elec_type; ///< Whether to show the pin electrical type
|
||||
TRANSFORM transform; // Coordinate adjustment settings
|
||||
bool draw_visible_fields; // Whether to draw "visible" fields
|
||||
bool draw_hidden_fields; // Whether to draw "hidden" fields
|
||||
bool show_elec_type; // Whether to show the pin electrical type
|
||||
int text_markup_flags; // Whether to process various text markups
|
||||
|
||||
static PART_DRAW_OPTIONS Default()
|
||||
PART_DRAW_OPTIONS()
|
||||
{
|
||||
PART_DRAW_OPTIONS def;
|
||||
def.transform = DefaultTransform;
|
||||
def.draw_visible_fields = true;
|
||||
def.draw_hidden_fields = true;
|
||||
def.show_elec_type = false;
|
||||
return def;
|
||||
transform = DefaultTransform;
|
||||
draw_visible_fields = true;
|
||||
draw_hidden_fields = true;
|
||||
show_elec_type = false;
|
||||
text_markup_flags = 0;
|
||||
}
|
||||
};
|
||||
|
||||
@ -294,13 +294,12 @@ public:
|
||||
/**
|
||||
* Print part.
|
||||
*
|
||||
* @param aDc - Device context to draw on.
|
||||
* @param aOffset - Position of part.
|
||||
* @param aMulti - unit if multiple units per part.
|
||||
* @param aConvert - Component conversion (DeMorgan) if available.
|
||||
* @param aOpts - Drawing options
|
||||
*/
|
||||
void Print( wxDC* aDc, const wxPoint& aOffset, int aMulti, int aConvert,
|
||||
void Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset, int aMulti, int aConvert,
|
||||
const PART_DRAW_OPTIONS& aOpts );
|
||||
|
||||
/**
|
||||
|
@ -160,7 +160,8 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow()
|
||||
{
|
||||
if( defined.count( templateFieldname.m_Name ) <= 0 )
|
||||
{
|
||||
SCH_FIELD field( wxPoint( 0, 0 ), -1, m_cmp, templateFieldname.m_Name );
|
||||
SCH_FIELD field( wxPoint( 0, 0 ), -1, m_cmp, templateFieldname.m_Name,
|
||||
GetParent()->GetTextMarkupFlags() );
|
||||
field.SetVisible( templateFieldname.m_Visible );
|
||||
m_fields->push_back( field );
|
||||
}
|
||||
@ -530,9 +531,10 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnAddField( wxCommandEvent& event )
|
||||
return;
|
||||
|
||||
int fieldID = m_fields->size();
|
||||
SCH_FIELD newField( wxPoint( 0, 0 ), fieldID, m_cmp );
|
||||
SCH_FIELD newField( wxPoint( 0, 0 ), fieldID, m_cmp,
|
||||
TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldID ),
|
||||
GetParent()->GetTextMarkupFlags() );
|
||||
|
||||
newField.SetName( TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldID ) );
|
||||
newField.SetTextAngle( m_fields->at( REFERENCE ).GetTextAngle() );
|
||||
|
||||
newField.SetTextSize( wxSize( GetParent()->GetDefaultTextSize(),
|
||||
@ -662,7 +664,8 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::UpdateFieldsFromLibrary( wxCommandEvent
|
||||
{
|
||||
if( defined.count( templateFieldname.m_Name ) <= 0 )
|
||||
{
|
||||
SCH_FIELD field( wxPoint( 0, 0 ), -1, m_cmp, templateFieldname.m_Name );
|
||||
SCH_FIELD field( wxPoint( 0, 0 ), -1, m_cmp, templateFieldname.m_Name,
|
||||
GetParent()->GetTextMarkupFlags() );
|
||||
field.SetVisible( templateFieldname.m_Visible );
|
||||
m_fields->push_back( field );
|
||||
}
|
||||
|
@ -460,12 +460,12 @@ bool DIALOG_LABEL_EDITOR::TransferDataFromWindow()
|
||||
if( ( style & 2 ) )
|
||||
{
|
||||
m_CurrentText->SetBold( true );
|
||||
m_CurrentText->SetTextPenWidth( GetPenSizeForBold( m_CurrentText->GetTextWidth() ) );
|
||||
m_CurrentText->SetTextThickness( GetPenSizeForBold( m_CurrentText->GetTextWidth() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CurrentText->SetBold( false );
|
||||
m_CurrentText->SetTextPenWidth( 0 ); // Use default pen width
|
||||
m_CurrentText->SetTextThickness( 0 ); // Use default pen width
|
||||
}
|
||||
|
||||
m_Parent->RefreshItem( m_CurrentText );
|
||||
|
@ -82,10 +82,10 @@ bool DIALOG_EDIT_LINE_STYLE::TransferDataToWindow()
|
||||
if( std::all_of( m_lines.begin() + 1, m_lines.end(),
|
||||
[&]( const SCH_LINE* r )
|
||||
{
|
||||
return r->GetPenSize() == first_line->GetPenSize();
|
||||
return r->GetPenWidth() == first_line->GetPenWidth();
|
||||
} ) )
|
||||
{
|
||||
m_width.SetValue( first_line->GetPenSize() );
|
||||
m_width.SetValue( first_line->GetPenWidth() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user