From d6e9bdf07bf8387d008821b4f8fbd8e451146f0b Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 31 May 2019 13:15:25 +0100 Subject: [PATCH] Convert remaining legacy drawing code to print code. --- .../3d_canvas/create_3Dgraphic_brd_items.cpp | 56 ++-- common/CMakeLists.txt | 6 +- common/dialogs/dialog_page_settings.cpp | 6 +- common/eda_text.cpp | 60 ++-- common/{draw_graphic_text.cpp => gr_text.cpp} | 67 ++-- common/legacy_gal/eda_draw_frame.cpp | 54 +-- common/legacy_gal/other.cpp | 10 - common/legacy_wx/eda_draw_frame.cpp | 60 +--- common/legacy_wx/eda_draw_panel.cpp | 112 ------- common/legacy_wx/other.cpp | 35 -- common/marker_base.cpp | 20 ++ common/page_layout/ws_data_item.cpp | 2 +- common/page_layout/ws_data_model.cpp | 2 +- common/page_layout/ws_draw_item.cpp | 40 +-- common/plotters/common_plot_functions.cpp | 2 +- common/plotters/plotter.cpp | 2 +- cvpcb/display_footprints_frame.cpp | 12 +- eeschema/class_libentry.cpp | 16 +- eeschema/class_libentry.h | 28 +- eeschema/dialogs/dialog_edit_label.cpp | 2 +- eeschema/dialogs/dialog_lib_edit_pin.cpp | 2 +- .../dialogs/dialog_print_using_printer.cpp | 31 +- eeschema/edit_label.cpp | 3 +- eeschema/getpart.cpp | 1 - eeschema/lib_arc.cpp | 15 +- eeschema/lib_arc.h | 7 +- eeschema/lib_bezier.cpp | 12 +- eeschema/lib_bezier.h | 4 +- eeschema/lib_circle.cpp | 12 +- eeschema/lib_circle.h | 4 +- eeschema/lib_draw_item.cpp | 5 +- eeschema/lib_draw_item.h | 13 +- eeschema/lib_field.cpp | 12 +- eeschema/lib_field.h | 6 +- eeschema/lib_pin.cpp | 161 ++++----- eeschema/lib_pin.h | 19 +- eeschema/lib_polyline.cpp | 11 +- eeschema/lib_polyline.h | 4 +- eeschema/lib_rectangle.cpp | 11 +- eeschema/lib_rectangle.h | 4 +- eeschema/lib_text.cpp | 19 +- eeschema/lib_text.h | 7 +- eeschema/libedit/lib_edit_frame.cpp | 1 - eeschema/libedit/lib_edit_frame.h | 11 - eeschema/libedit/libedit.cpp | 22 -- eeschema/libedit/libedit_plot_component.cpp | 2 +- eeschema/project_rescue.cpp | 1 - eeschema/sch_base_frame.cpp | 2 - eeschema/sch_bitmap.cpp | 2 +- eeschema/sch_bitmap.h | 2 +- eeschema/sch_bus_entry.cpp | 20 +- eeschema/sch_bus_entry.h | 2 +- eeschema/sch_component.cpp | 15 +- eeschema/sch_component.h | 5 +- eeschema/sch_draw_panel.cpp | 18 - eeschema/sch_draw_panel.h | 3 - eeschema/sch_eagle_plugin.cpp | 2 +- eeschema/sch_edit_frame.cpp | 4 +- eeschema/sch_field.cpp | 21 +- eeschema/sch_field.h | 2 +- eeschema/sch_item.h | 9 +- eeschema/sch_junction.cpp | 4 +- eeschema/sch_junction.h | 2 +- eeschema/sch_legacy_plugin.cpp | 2 +- eeschema/sch_line.cpp | 4 +- eeschema/sch_line.h | 2 +- eeschema/sch_marker.cpp | 4 +- eeschema/sch_marker.h | 2 +- eeschema/sch_no_connect.cpp | 12 +- eeschema/sch_no_connect.h | 2 +- eeschema/sch_painter.cpp | 2 +- eeschema/sch_pin.h | 2 +- eeschema/sch_screen.cpp | 31 +- eeschema/sch_screen.h | 5 +- eeschema/sch_sheet.cpp | 19 +- eeschema/sch_sheet.h | 4 +- eeschema/sch_sheet_pin.cpp | 9 +- eeschema/sch_text.cpp | 60 ++-- eeschema/sch_text.h | 6 +- eeschema/sheet.cpp | 4 - gerbview/events_called_functions.cpp | 1 - gerbview/gbr_layout.cpp | 313 +----------------- gerbview/gbr_layout.h | 55 +-- gerbview/gerber_draw_item.cpp | 67 ++-- gerbview/gerber_draw_item.h | 32 +- include/class_board_item.h | 8 +- include/draw_frame.h | 14 +- include/eda_base_frame.h | 1 - include/eda_text.h | 25 +- include/gr_basic.h | 1 - include/{draw_graphic_text.h => gr_text.h} | 48 +-- include/kicad_device_context.h | 203 ------------ include/legacy_gal/class_drawpanel.h | 94 +----- include/legacy_wx/class_drawpanel.h | 111 +------ include/marker_base.h | 6 +- include/origin_viewitem.h | 7 +- include/plotter.h | 2 +- include/ws_draw_item.h | 30 +- include/ws_painter.h | 24 +- .../dialogs/dialogs_for_printing.cpp | 14 +- pagelayout_editor/hotkeys.cpp | 1 - pagelayout_editor/pl_editor_frame.cpp | 10 +- pagelayout_editor/pl_editor_layout.h | 2 - pcbnew/autorouter/spread_footprints.cpp | 2 +- pcbnew/board_connected_item.h | 3 +- ...board_items_to_polygon_shape_transform.cpp | 38 +-- pcbnew/class_board.cpp | 2 +- pcbnew/class_board.h | 9 +- pcbnew/class_dimension.cpp | 58 ++-- pcbnew/class_dimension.h | 6 +- pcbnew/class_drawsegment.cpp | 71 +--- pcbnew/class_drawsegment.h | 3 +- pcbnew/class_edge_mod.cpp | 67 ++-- pcbnew/class_edge_mod.h | 4 +- pcbnew/class_marker_pcb.h | 5 +- pcbnew/class_module.cpp | 71 +--- pcbnew/class_module.h | 54 +-- pcbnew/class_pad.h | 18 +- pcbnew/class_pcb_target.cpp | 30 +- pcbnew/class_pcb_target.h | 4 +- pcbnew/class_pcb_text.cpp | 43 +-- pcbnew/class_pcb_text.h | 4 +- pcbnew/class_text_mod.cpp | 71 +--- pcbnew/class_text_mod.h | 28 +- pcbnew/class_track.cpp | 247 +++----------- pcbnew/class_track.h | 13 +- pcbnew/class_zone.cpp | 166 ++-------- pcbnew/class_zone.h | 33 +- .../dialog_cleanup_tracks_and_vias.cpp | 8 +- pcbnew/dialogs/dialog_drc.cpp | 6 +- pcbnew/dialogs/dialog_exchange_footprints.cpp | 2 +- pcbnew/dialogs/dialog_global_deletion.cpp | 2 +- .../dialog_global_edit_text_and_graphics.cpp | 2 +- pcbnew/dialogs/dialog_pad_properties.cpp | 6 +- .../dialogs/dialog_select_net_from_list.cpp | 1 - pcbnew/dialogs/dialog_swap_layers.cpp | 2 +- pcbnew/dialogs/dialog_text_properties.cpp | 2 +- .../dialogs/panel_modedit_display_options.cpp | 2 +- .../dialogs/panel_pcbnew_display_options.cpp | 3 +- pcbnew/drc.h | 1 - pcbnew/edit.cpp | 108 +----- pcbnew/exporters/export_vrml.cpp | 43 +-- pcbnew/exporters/gen_drill_report_files.cpp | 2 +- pcbnew/footprint_edit_frame.cpp | 6 +- pcbnew/footprint_editor_utils.cpp | 27 +- pcbnew/footprint_libraries_utils.cpp | 2 +- pcbnew/footprint_viewer_frame.cpp | 12 +- pcbnew/footprint_wizard_frame.cpp | 10 +- pcbnew/footprint_wizard_frame_functions.cpp | 2 +- pcbnew/load_select_footprint.cpp | 2 +- pcbnew/netinfo.h | 7 +- pcbnew/netinfo_item.cpp | 7 +- pcbnew/netlist.cpp | 2 +- pcbnew/pad_edit_functions.cpp | 6 +- ..._functions.cpp => pad_print_functions.cpp} | 286 ++++------------ pcbnew/pcb_base_frame.cpp | 15 +- pcbnew/pcb_edit_frame.cpp | 40 +-- pcbnew/pcb_edit_frame.h | 1 - pcbnew/pcb_layer_widget.cpp | 10 +- pcbnew/pcb_legacy_draw_utils.cpp | 31 +- pcbnew/plot_board_layers.cpp | 2 +- pcbnew/plot_brditems_plotter.cpp | 2 +- pcbnew/swig/pcbnew_action_plugins.cpp | 1 - pcbnew/tracks_cleaner.cpp | 2 +- pcbnew/undo_redo.cpp | 6 +- pcbnew/zones_by_polygon_fill_functions.cpp | 2 - qa/qa_utils/mocks.cpp | 11 +- 167 files changed, 896 insertions(+), 3180 deletions(-) rename common/{draw_graphic_text.cpp => gr_text.cpp} (77%) delete mode 100644 common/legacy_gal/other.cpp delete mode 100644 common/legacy_wx/other.cpp rename include/{draw_graphic_text.h => gr_text.h} (73%) delete mode 100644 include/kicad_device_context.h rename pcbnew/{pad_draw_functions.cpp => pad_print_functions.cpp} (69%) diff --git a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp index 03571ef94c..9a5724dd96 100644 --- a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp +++ b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include #include @@ -65,7 +65,7 @@ static float s_biuTo3Dunits; static const CBBOX2D *s_boardBBox3DU = NULL; static const BOARD_ITEM *s_boardItem = NULL; -// This is a call back function, used by DrawGraphicText to draw the 3D text shape: +// This is a call back function, used by GRText to draw the 3D text shape: void addTextSegmToContainer( int x0, int y0, int xf, int yf, void* aData ) { wxASSERT( s_boardBBox3DU != NULL ); @@ -89,52 +89,47 @@ void addTextSegmToContainer( int x0, int y0, int xf, int yf, void* aData ) // Based on // void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet // board_items_to_polygon_shape_transform.cpp -void CINFO3D_VISU::AddShapeWithClearanceToContainer( const TEXTE_PCB* aTextPCB, +void CINFO3D_VISU::AddShapeWithClearanceToContainer( const TEXTE_PCB* aText, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue ) { - wxSize size = aTextPCB->GetTextSize(); + wxSize size = aText->GetTextSize(); - if( aTextPCB->IsMirrored() ) + if( aText->IsMirrored() ) size.x = -size.x; - s_boardItem = (const BOARD_ITEM *)&aTextPCB; + s_boardItem = (const BOARD_ITEM *) &aText; s_dstcontainer = aDstContainer; - s_textWidth = aTextPCB->GetThickness() + ( 2 * aClearanceValue ); + s_textWidth = aText->GetThickness() + ( 2 * aClearanceValue ); s_biuTo3Dunits = m_biuTo3Dunits; s_boardBBox3DU = &m_board2dBBox3DU; - // not actually used, but needed by DrawGraphicText + // not actually used, but needed by GRText const COLOR4D dummy_color = COLOR4D::BLACK; - if( aTextPCB->IsMultilineAllowed() ) + if( aText->IsMultilineAllowed() ) { wxArrayString strings_list; - wxStringSplit( aTextPCB->GetShownText(), strings_list, '\n' ); + wxStringSplit( aText->GetShownText(), strings_list, '\n' ); std::vector positions; positions.reserve( strings_list.Count() ); - aTextPCB->GetPositionsOfLinesOfMultilineText( positions, - strings_list.Count() ); + aText->GetPositionsOfLinesOfMultilineText( positions, strings_list.Count() ); for( unsigned ii = 0; ii < strings_list.Count(); ++ii ) { wxString txt = strings_list.Item( ii ); - DrawGraphicText( NULL, NULL, positions[ii], dummy_color, - txt, aTextPCB->GetTextAngle(), size, - aTextPCB->GetHorizJustify(), aTextPCB->GetVertJustify(), - aTextPCB->GetThickness(), aTextPCB->IsItalic(), - true, addTextSegmToContainer ); + GRText( NULL, positions[ii], dummy_color, txt, aText->GetTextAngle(), size, + aText->GetHorizJustify(), aText->GetVertJustify(), aText->GetThickness(), + aText->IsItalic(), true, addTextSegmToContainer ); } } else { - DrawGraphicText( NULL, NULL, aTextPCB->GetTextPos(), dummy_color, - aTextPCB->GetShownText(), aTextPCB->GetTextAngle(), size, - aTextPCB->GetHorizJustify(), aTextPCB->GetVertJustify(), - aTextPCB->GetThickness(), aTextPCB->IsItalic(), - true, addTextSegmToContainer ); + GRText( NULL, aText->GetTextPos(), dummy_color, aText->GetShownText(), + aText->GetTextAngle(), size, aText->GetHorizJustify(), aText->GetVertJustify(), + aText->GetThickness(), aText->IsItalic(), true, addTextSegmToContainer ); } } @@ -230,20 +225,17 @@ void CINFO3D_VISU::AddGraphicsShapesWithClearanceToContainer( const MODULE* aMod s_biuTo3Dunits = m_biuTo3Dunits; s_boardBBox3DU = &m_board2dBBox3DU; - for( unsigned ii = 0; ii < texts.size(); ++ii ) + for( TEXTE_MODULE* text : texts ) { - TEXTE_MODULE *textmod = texts[ii]; - s_textWidth = textmod->GetThickness() + ( 2 * aInflateValue ); - wxSize size = textmod->GetTextSize(); + s_textWidth = text->GetThickness() + ( 2 * aInflateValue ); + wxSize size = text->GetTextSize(); - if( textmod->IsMirrored() ) + if( text->IsMirrored() ) size.x = -size.x; - DrawGraphicText( NULL, NULL, textmod->GetTextPos(), BLACK, - textmod->GetShownText(), textmod->GetDrawRotation(), size, - textmod->GetHorizJustify(), textmod->GetVertJustify(), - textmod->GetThickness(), textmod->IsItalic(), - true, addTextSegmToContainer ); + GRText( NULL, text->GetTextPos(), BLACK, text->GetShownText(), text->GetDrawRotation(), + size, text->GetHorizJustify(), text->GetVertJustify(), text->GetThickness(), + text->IsItalic(), true, addTextSegmToContainer ); } } diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 3b367054cd..f179c6069b 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -72,13 +72,11 @@ set( GAL_SRCS set( LEGACY_GAL_SRCS legacy_gal/eda_draw_frame.cpp - legacy_gal/other.cpp ) set( LEGACY_WX_SRCS legacy_wx/eda_draw_frame.cpp legacy_wx/eda_draw_panel.cpp - legacy_wx/other.cpp ) add_library( gal STATIC ${GAL_SRCS} ) @@ -298,7 +296,7 @@ set( COMMON_SRCS dialog_shim.cpp displlst.cpp dpi_scaling.cpp - draw_graphic_text.cpp + gr_text.cpp dsnlexer.cpp eagle_parser.cpp eda_base_frame.cpp @@ -483,7 +481,7 @@ set( PCB_COMMON_SRCS ../pcbnew/legacy_plugin.cpp ../pcbnew/netlist_reader.cpp ../pcbnew/pad_custom_shape_functions.cpp - ../pcbnew/pad_draw_functions.cpp + ../pcbnew/pad_print_functions.cpp ../pcbnew/pcb_display_options.cpp ../pcbnew/pcb_draw_panel_gal.cpp ../pcbnew/pcb_general_settings.cpp diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp index be364c5b5f..90d6e24ba9 100644 --- a/common/dialogs/dialog_page_settings.cpp +++ b/common/dialogs/dialog_page_settings.cpp @@ -624,10 +624,8 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample() WS_DATA_MODEL::SetAltInstance( m_pagelayout ); GRFilledRect( NULL, &memDC, 0, 0, m_layout_size.x, m_layout_size.y, WHITE, WHITE ); - DrawPageLayout( &memDC, NULL, pageDUMMY, - emptyString, emptyString, - m_tb, m_screen->m_NumberOfScreens, - m_screen->m_ScreenNumber, 1, 1, DARKGRAY ); + PrintPageLayout( &memDC, pageDUMMY, emptyString, emptyString, m_tb, + m_screen->m_NumberOfScreens, m_screen->m_ScreenNumber, 1, 1, DARKGRAY ); memDC.SelectObject( wxNullBitmap ); m_PageLayoutExampleBitmap->SetBitmap( *m_page_bitmap ); diff --git a/common/eda_text.cpp b/common/eda_text.cpp index aa5544560b..72a13b9a20 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -28,11 +28,10 @@ */ #include -#include +#include #include #include #include // RotatePoint -#include // EDA_DRAW_PANEL #include #include @@ -293,9 +292,7 @@ bool EDA_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy } -void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, - COLOR4D aColor, GR_DRAWMODE aDrawMode, - EDA_DRAW_MODE_T aFillMode, COLOR4D aAnchor_color ) +void EDA_TEXT::Print( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor, EDA_DRAW_MODE_T aFillMode ) { if( IsMultilineAllowed() ) { @@ -310,21 +307,11 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, for( unsigned ii = 0; ii < strings.Count(); ii++ ) { wxString& txt = strings.Item( ii ); - drawOneLineOfText( aClipBox, aDC, aOffset, aColor, - aDrawMode, aFillMode, txt, positions[ii] ); + printOneLineOfText( aDC, aOffset, aColor, aFillMode, txt, positions[ii] ); } } else - drawOneLineOfText( aClipBox, aDC, aOffset, aColor, - aDrawMode, aFillMode, GetShownText(), GetTextPos() ); - - // Draw text anchor, if requested - if( aAnchor_color != COLOR4D::UNSPECIFIED ) - { - GRDrawAnchor( aClipBox, aDC, - GetTextPos().x + aOffset.x, GetTextPos().y + aOffset.y, - DIM_ANCRE_TEXTE, aAnchor_color ); - } + printOneLineOfText( aDC, aOffset, aColor, aFillMode, GetShownText(), GetTextPos() ); } @@ -370,16 +357,12 @@ void EDA_TEXT::GetPositionsOfLinesOfMultilineText( } } -void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC, - const wxPoint& aOffset, COLOR4D aColor, - GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode, - const wxString& aText, const wxPoint &aPos ) +void EDA_TEXT::printOneLineOfText( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor, + EDA_DRAW_MODE_T aFillMode, const wxString& aText, + const wxPoint &aPos ) { int width = GetThickness(); - if( aDrawMode != UNSPECIFIED_DRAWMODE ) - GRSetDrawMode( aDC, aDrawMode ); - if( aFillMode == SKETCH ) width = -width; @@ -388,9 +371,8 @@ void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC, if( IsMirrored() ) size.x = -size.x; - DrawGraphicText( aClipBox, aDC, aOffset + aPos, aColor, aText, GetTextAngle(), size, - GetHorizJustify(), GetVertJustify(), - width, IsItalic(), IsBold() ); + GRText( aDC, aOffset + aPos, aColor, aText, GetTextAngle(), size, GetHorizJustify(), + GetVertJustify(), width, IsItalic(), IsBold() ); } @@ -482,10 +464,9 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl // Convert the text shape to a list of segment // each segment is stored as 2 wxPoints: its starting point and its ending point -// we are using DrawGraphicText to create the segments. -// and therefore a call-back function is needed +// we are using GRText to create the segments and therefore a call-back function is needed -// This is a call back function, used by DrawGraphicText to put each segment in buffer +// This is a call back function, used by GRText to put each segment in buffer static void addTextSegmToBuffer( int x0, int y0, int xf, int yf, void* aData ) { std::vector* cornerBuffer = static_cast*>( aData ); @@ -493,6 +474,7 @@ static void addTextSegmToBuffer( int x0, int y0, int xf, int yf, void* aData ) cornerBuffer->push_back( wxPoint( xf, yf ) ); } + void EDA_TEXT::TransformTextShapeToSegmentList( std::vector& aCornerBuffer ) const { wxSize size = GetTextSize(); @@ -500,7 +482,7 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector& aCornerBuf if( IsMirrored() ) size.x = -size.x; - COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by DrawGraphicText + COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by GRText if( IsMultilineAllowed() ) { @@ -513,19 +495,15 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector& aCornerBuf for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) { wxString txt = strings_list.Item( ii ); - DrawGraphicText( NULL, NULL, positions[ii], color, - txt, GetTextAngle(), size, - GetHorizJustify(), GetVertJustify(), - GetThickness(), IsItalic(), - true, addTextSegmToBuffer, &aCornerBuffer ); + GRText( NULL, positions[ii], color, txt, GetTextAngle(), size, GetHorizJustify(), + GetVertJustify(), GetThickness(), IsItalic(), true, addTextSegmToBuffer, + &aCornerBuffer ); } } else { - DrawGraphicText( NULL, NULL, GetTextPos(), color, - GetText(), GetTextAngle(), size, - GetHorizJustify(), GetVertJustify(), - GetThickness(), IsItalic(), - true, addTextSegmToBuffer, &aCornerBuffer ); + GRText( NULL, GetTextPos(), color, GetText(), GetTextAngle(), size, GetHorizJustify(), + GetVertJustify(), GetThickness(), IsItalic(), true, addTextSegmToBuffer, + &aCornerBuffer ); } } diff --git a/common/draw_graphic_text.cpp b/common/gr_text.cpp similarity index 77% rename from common/draw_graphic_text.cpp rename to common/gr_text.cpp index 320075ca15..617d3f1769 100644 --- a/common/draw_graphic_text.cpp +++ b/common/gr_text.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include @@ -98,9 +98,8 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool aItalic, /** - * Function DrawGraphicText + * Function GRText * Draw a graphic text (like module texts) - * @param aClipBox = the clipping rect, or NULL if no clipping * @param aDC = the current Device Context. NULL if draw within a 3D GL Canvas * @param aPos = text position (according to h_justify, v_justify) * @param aColor (COLOR4D) = text color @@ -122,23 +121,13 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool aItalic, * @param aPlotter = a pointer to a PLOTTER instance, when this function is used to plot * the text. NULL to draw this text. */ -void DrawGraphicText( EDA_RECT* aClipBox, - 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 ), - void* aCallbackData, - PLOTTER* aPlotter ) +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 ), + void* aCallbackData, PLOTTER* aPlotter ) { - bool fill_mode = true; + bool fill_mode = true; if( aWidth == 0 && aBold ) // Use default values if aWidth == 0 aWidth = GetPenSizeForBold( std::min( aSize.x, aSize.y ) ); @@ -171,26 +160,18 @@ void DrawGraphicText( EDA_RECT* aClipBox, basic_gal.SetCallback( aCallback, aCallbackData ); basic_gal.m_DC = aDC; basic_gal.m_Color = aColor; - basic_gal.SetClipBox( aClipBox ); + basic_gal.SetClipBox( nullptr ); basic_gal.StrokeText( aText, VECTOR2D( aPos ), aOrient * M_PI/1800 ); } -void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC, - const wxPoint &aPos, - const 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, - void (*aCallback)( int x0, int y0, int xf, int yf, void* aData ), - void* aCallbackData, - PLOTTER * aPlotter ) +void GRHaloText( wxDC * aDC, const wxPoint &aPos, const 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, + void (*aCallback)( int x0, int y0, int xf, int yf, void* aData ), + void* aCallbackData, PLOTTER * aPlotter ) { // Swap color if contrast would be better // TODO: Maybe calculate contrast some way other than brightness @@ -202,19 +183,17 @@ void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC, } // Draw the background - DrawGraphicText( aClipBox, aDC, aPos, aColor1, aText, aOrient, aSize, - aH_justify, aV_justify, aWidth, aItalic, aBold, - aCallback, aCallbackData, aPlotter ); + GRText( aDC, aPos, aColor1, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic, + aBold, aCallback, aCallbackData, aPlotter ); // Draw the text - DrawGraphicText( aClipBox, aDC, aPos, aColor2, aText, aOrient, aSize, - aH_justify, aV_justify, aWidth/4, aItalic, aBold, - aCallback, aCallbackData, aPlotter ); + GRText( aDC, aPos, aColor2, aText, aOrient, aSize, aH_justify, aV_justify, aWidth/4, aItalic, + aBold, aCallback, aCallbackData, aPlotter ); } /** * Function PLOTTER::Text - * same as DrawGraphicText, but plot graphic text insteed of draw it + * same as GRText, but plot graphic text insteed of draw it * @param aPos = text position (according to aH_justify, aV_justify) * @param aColor (COLOR4D) = text color * @param aText = text to draw @@ -258,10 +237,8 @@ void PLOTTER::Text( const wxPoint& aPos, SetColor( aColor ); - DrawGraphicText( NULL, NULL, aPos, aColor, aText, - aOrient, aSize, - aH_justify, aV_justify, - textPensize, aItalic, aBold, nullptr, nullptr, this ); + GRText( NULL, aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, textPensize, + aItalic, aBold, nullptr, nullptr, this ); if( aWidth != textPensize ) SetCurrentLineWidth( aWidth, aData ); diff --git a/common/legacy_gal/eda_draw_frame.cpp b/common/legacy_gal/eda_draw_frame.cpp index 7bbd114fc0..b6a1f4ada1 100644 --- a/common/legacy_gal/eda_draw_frame.cpp +++ b/common/legacy_gal/eda_draw_frame.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -86,14 +85,11 @@ BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER ) END_EVENT_TABLE() -EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, - FRAME_T aFrameType, - const wxString& aTitle, - const wxPoint& aPos, const wxSize& aSize, +EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, + const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, long aStyle, const wxString & aFrameName ) : KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ) { - m_useSingleCanvasPane = false; m_socketServer = nullptr; m_mainToolBar = NULL; m_drawToolBar = NULL; @@ -123,7 +119,6 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, m_showPageLimits = false; m_drawBgColor = COLOR4D( BLACK ); // the background color of the draw canvas: // BLACK for Pcbnew, BLACK or WHITE for eeschema - m_snapToGrid = true; m_MsgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight(); m_movingCursorWithKeyboard = false; m_zoomLevelCoeff = 1.0; @@ -158,8 +153,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, // units display, Inches is bigger than mm GetTextSize( _( "Inches" ), stsbar ).x + 10, - // Size for the panel used as "Current tool in play": will take longest string from - // void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) in pcbnew/edit.cpp + // Size for the "Current Tool" panel; longest string from SetToolID() GetTextSize( wxT( "Add layer alignment target" ), stsbar ).x + 10, }; @@ -823,18 +817,10 @@ void EDA_DRAW_FRAME::FocusOnLocation( const wxPoint& aPos, bool aWarpCursor, boo static const wxString productName = wxT( "KiCad E.D.A. " ); -void DrawPageLayout( wxDC* aDC, - EDA_RECT* aClipBox, - const PAGE_INFO& aPageInfo, - const wxString& aFullSheetName, - const wxString& aFileName, - TITLE_BLOCK& aTitleBlock, - int aSheetCount, - int aSheetNumber, - int aPenWidth, - double aScalar, - COLOR4D aColor, - const wxString& aSheetLayer ) +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 wxString& aSheetLayer ) { WS_DRAW_ITEM_LIST drawList; @@ -849,44 +835,32 @@ void DrawPageLayout( wxDC* aDC, drawList.BuildWorkSheetGraphicList( aPageInfo, aTitleBlock ); // Draw item list - drawList.Draw( aClipBox, aDC, aColor ); + drawList.Print( aDC, aColor ); } -void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth, +void EDA_DRAW_FRAME::PrintWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth, double aScalar, const wxString &aFilename, const wxString &aSheetLayer, COLOR4D aColor ) { if( !m_showBorderAndTitleBlock ) return; - const PAGE_INFO& pageInfo = GetPageSettings(); - wxSize pageSize = pageInfo.GetSizeMils(); - - // if not printing, draw the page limits: - if( !aScreen->m_IsPrinting && m_showPageLimits ) - { - GRSetDrawMode( aDC, GR_COPY ); - GRRect( m_canvas->GetClipBox(), aDC, 0, 0, pageSize.x * aScalar, pageSize.y * aScalar, - aLineWidth, m_drawBgColor == WHITE ? LIGHTGRAY : DARKDARKGRAY ); - } - - TITLE_BLOCK t_block = GetTitleBlock(); COLOR4D color = ( aColor != COLOR4D::UNSPECIFIED ) ? aColor : COLOR4D( RED ); wxPoint origin = aDC->GetDeviceOrigin(); - if( aScreen->m_IsPrinting && origin.y > 0 ) + if( origin.y > 0 ) { aDC->SetDeviceOrigin( 0, 0 ); aDC->SetAxisOrientation( true, false ); } - DrawPageLayout( aDC, m_canvas->GetClipBox(), pageInfo, GetScreenDesc(), aFilename, t_block, - aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber, aLineWidth, aScalar, - color, aSheetLayer ); + PrintPageLayout( aDC, GetPageSettings(), GetScreenDesc(), aFilename, GetTitleBlock(), + aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber, aLineWidth, aScalar, + color, aSheetLayer ); - if( aScreen->m_IsPrinting && origin.y > 0 ) + if( origin.y > 0 ) { aDC->SetDeviceOrigin( origin.x, origin.y ); aDC->SetAxisOrientation( true, true ); diff --git a/common/legacy_gal/other.cpp b/common/legacy_gal/other.cpp deleted file mode 100644 index da80ccda9a..0000000000 --- a/common/legacy_gal/other.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "fctsys.h" -#include "gr_basic.h" -#include "class_drawpanel.h" -#include "marker_base.h" - - - -void MARKER_BASE::DrawMarker( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) -{ -} diff --git a/common/legacy_wx/eda_draw_frame.cpp b/common/legacy_wx/eda_draw_frame.cpp index 0899ce77a8..89fd03e97d 100644 --- a/common/legacy_wx/eda_draw_frame.cpp +++ b/common/legacy_wx/eda_draw_frame.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -141,7 +140,6 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, m_showPageLimits = false; m_drawBgColor = COLOR4D( BLACK ); // the background color of the draw canvas: // BLACK for Pcbnew, BLACK or WHITE for eeschema - m_snapToGrid = true; m_MsgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight(); m_movingCursorWithKeyboard = false; m_zoomLevelCoeff = 1.0; @@ -174,8 +172,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, // units display, Inches is bigger than mm GetTextSize( _( "Inches" ), stsbar ).x + 10, - // Size for the panel used as "Current tool in play": will take longest string from - // void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) in pcbnew/edit.cpp + // Size for the "Current Tool" panel; longest string from SetToolID() GetTextSize( wxT( "Add layer alignment target" ), stsbar ).x + 10, }; @@ -471,10 +468,6 @@ void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg ) // Keep default cursor in toolbars SetCursor( wxNullCursor ); - // Change m_canvas cursor if requested. - if( m_canvas && aCursor >= 0 ) - m_canvas->SetCurrentCursor( aCursor ); - // Change GAL canvas cursor if requested. if( aCursor >= 0 ) GetGalCanvas()->SetCurrentCursor( aCursor ); @@ -915,18 +908,10 @@ void EDA_DRAW_FRAME::FocusOnLocation( const wxPoint& aPos, bool aWarpCursor, boo } -void DrawPageLayout( wxDC* aDC, - EDA_RECT* aClipBox, - const PAGE_INFO& aPageInfo, - const wxString& aFullSheetName, - const wxString& aFileName, - TITLE_BLOCK& aTitleBlock, - int aSheetCount, - int aSheetNumber, - int aPenWidth, - double aScalar, - COLOR4D aColor, - const wxString& aSheetLayer ) +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 wxString& aSheetLayer ) { WS_DRAW_ITEM_LIST drawList; @@ -941,46 +926,32 @@ void DrawPageLayout( wxDC* aDC, drawList.BuildWorkSheetGraphicList( aPageInfo, aTitleBlock ); // Draw item list - drawList.Draw( aClipBox, aDC, aColor ); + drawList.Print( aDC, aColor ); } -void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth, - double aScalar, const wxString &aFilename, - const wxString &aSheetLayer, COLOR4D aColor ) +void EDA_DRAW_FRAME::PrintWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth, + double aScalar, const wxString &aFilename, + const wxString &aSheetLayer, COLOR4D aColor ) { if( !m_showBorderAndTitleBlock ) return; - const PAGE_INFO& pageInfo = GetPageSettings(); - wxSize pageSize = pageInfo.GetSizeMils(); - - // if not printing, draw the page limits: - if( !aScreen->m_IsPrinting && m_showPageLimits ) - { - GRSetDrawMode( aDC, GR_COPY ); - GRRect( m_canvas->GetClipBox(), aDC, 0, 0, - pageSize.x * aScalar, pageSize.y * aScalar, aLineWidth, - m_drawBgColor == WHITE ? LIGHTGRAY : DARKDARKGRAY ); - } - - TITLE_BLOCK t_block = GetTitleBlock(); COLOR4D color = ( aColor != COLOR4D::UNSPECIFIED ) ? aColor : COLOR4D( RED ); wxPoint origin = aDC->GetDeviceOrigin(); - if( aScreen->m_IsPrinting && origin.y > 0 ) + if( origin.y > 0 ) { aDC->SetDeviceOrigin( 0, 0 ); aDC->SetAxisOrientation( true, false ); } - DrawPageLayout( aDC, m_canvas->GetClipBox(), pageInfo, - GetScreenDesc(), aFilename, t_block, - aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber, - aLineWidth, aScalar, color, aSheetLayer ); + PrintPageLayout( aDC, GetPageSettings(), GetScreenDesc(), aFilename, GetTitleBlock(), + aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber, aLineWidth, aScalar, + color, aSheetLayer ); - if( aScreen->m_IsPrinting && origin.y > 0 ) + if( origin.y > 0 ) { aDC->SetDeviceOrigin( origin.x, origin.y ); aDC->SetAxisOrientation( true, true ); @@ -990,8 +961,7 @@ void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWi wxString EDA_DRAW_FRAME::GetScreenDesc() const { - // Virtual function. In basic class, returns - // an empty string. + // Virtual function. In basic class, returns an empty string. return wxEmptyString; } diff --git a/common/legacy_wx/eda_draw_panel.cpp b/common/legacy_wx/eda_draw_panel.cpp index b057ef69e7..43e4ee7485 100644 --- a/common/legacy_wx/eda_draw_panel.cpp +++ b/common/legacy_wx/eda_draw_panel.cpp @@ -32,9 +32,6 @@ #include #include #include -#include - -#define CLIP_BOX_PADDING 2 #ifdef __WXMAC__ @@ -52,31 +49,9 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id, const wxPoint& p ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS ); DisableKeyboardScrolling(); - m_scrollIncrementX = std::min( size.x / 8, 10 ); - m_scrollIncrementY = std::min( size.y / 8, 10 ); - SetLayoutDirection( wxLayout_LeftToRight ); SetBackgroundColour( parent->GetDrawBgColor().ToColour() ); - -#if KICAD_USE_BUFFERED_DC || KICAD_USE_BUFFERED_PAINTDC - SetBackgroundStyle( wxBG_STYLE_CUSTOM ); -#endif - - m_ClipBox.SetSize( size ); - m_ClipBox.SetX( 0 ); - m_ClipBox.SetY( 0 ); - -#ifdef __WXMAC__ - m_defaultCursor = m_currentCursor = wxCURSOR_CROSS; - m_showCrossHair = false; -#else - m_defaultCursor = m_currentCursor = wxCURSOR_ARROW; - m_showCrossHair = true; -#endif - - m_cursorLevel = 0; - m_PrintIsMirrored = false; } @@ -92,12 +67,6 @@ EDA_DRAW_FRAME* EDA_DRAW_PANEL::GetParent() const } -void* EDA_DRAW_PANEL::GetDisplayOptions() -{ - return GetParent()->GetDisplayOptions(); -} - - BASE_SCREEN* EDA_DRAW_PANEL::GetScreen() { EDA_DRAW_FRAME* parentFrame = GetParent(); @@ -111,84 +80,3 @@ void EDA_DRAW_PANEL::Refresh( bool eraseBackground, const wxRect* rect ) GetParent()->GetGalCanvas()->Refresh(); } - -wxPoint EDA_DRAW_PANEL::GetScreenCenterLogicalPosition() -{ - wxSize size = GetClientSize() / 2; - INSTALL_UNBUFFERED_DC( dc, this ); - - return wxPoint( dc.DeviceToLogicalX( size.x ), dc.DeviceToLogicalY( size.y ) ); -} - - -void EDA_DRAW_PANEL::SetClipBox( wxDC& aDC, const wxRect* aRect ) -{ - wxRect clipBox; - - // Use the entire visible device area if no clip area was defined. - if( aRect == NULL ) - { - BASE_SCREEN* Screen = GetScreen(); - - if( !Screen ) - return; - - Screen->m_StartVisu = CalcUnscrolledPosition( wxPoint( 0, 0 ) ); - clipBox.SetSize( GetClientSize() ); - - int scrollX, scrollY; - - double scalar = Screen->GetScalingFactor(); - scrollX = KiROUND( Screen->GetGridSize().x * scalar ); - scrollY = KiROUND( Screen->GetGridSize().y * scalar ); - - m_scrollIncrementX = std::max( GetClientSize().x / 8, scrollX ); - m_scrollIncrementY = std::max( GetClientSize().y / 8, scrollY ); - Screen->m_ScrollbarPos.x = GetScrollPos( wxHORIZONTAL ); - Screen->m_ScrollbarPos.y = GetScrollPos( wxVERTICAL ); - } - else - { - clipBox = *aRect; - } - - // Pad clip box in device units. - clipBox.Inflate( CLIP_BOX_PADDING ); - - // Convert from device units to drawing units. - m_ClipBox.SetOrigin( wxPoint( aDC.DeviceToLogicalX( clipBox.x ), - aDC.DeviceToLogicalY( clipBox.y ) ) ); - m_ClipBox.SetSize( wxSize( aDC.DeviceToLogicalXRel( clipBox.width ), - aDC.DeviceToLogicalYRel( clipBox.height ) ) ); - - wxLogTrace( kicadTraceCoords, - wxT( "Device clip box=(%d, %d, %d, %d), Logical clip box=(%d, %d, %d, %d)" ), - clipBox.x, clipBox.y, clipBox.width, clipBox.height, - m_ClipBox.GetX(), m_ClipBox.GetY(), m_ClipBox.GetWidth(), m_ClipBox.GetHeight() ); -} - - -void EDA_DRAW_PANEL::DoPrepareDC( wxDC& dc ) -{ - wxScrolledWindow::DoPrepareDC( dc ); - - if( GetScreen() != NULL ) - { - double scale = GetScreen()->GetScalingFactor(); - dc.SetUserScale( scale, scale ); - - wxPoint pt = GetScreen()->m_DrawOrg; - dc.SetLogicalOrigin( pt.x, pt.y ); - } - - SetClipBox( dc ); // Reset the clip box to the entire screen. - GRResetPenAndBrush( &dc ); - dc.SetBackgroundMode( wxTRANSPARENT ); -} - - -void EDA_DRAW_PANEL::OnCharHook( wxKeyEvent& event ) -{ - wxLogTrace( kicadTraceKeyEvent, "EDA_DRAW_PANEL::OnCharHook %s", dump( event ) ); - event.Skip(); -} diff --git a/common/legacy_wx/other.cpp b/common/legacy_wx/other.cpp deleted file mode 100644 index a68f128ff9..0000000000 --- a/common/legacy_wx/other.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "fctsys.h" -#include "gr_basic.h" -#include "base_screen.h" -#include "common.h" -#include "macros.h" -#include "class_drawpanel.h" -#include "marker_base.h" -#include "dialog_display_info_HTML_base.h" - - -void MARKER_BASE::DrawMarker( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) -{ - // Build the marker shape polygon in internal units: - const int ccount = GetShapePolygonCornerCount(); - std::vector shape; - shape.reserve( ccount ); - - for( int ii = 0; ii < ccount; ii++ ) - { - shape.push_back( wxPoint( GetShapePolygonCorner( ii ).x * MarkerScale(), - GetShapePolygonCorner( ii ).y * MarkerScale() ) ); - } - - for( int ii = 0; ii < ccount; ii++ ) - { - shape[ii] += m_Pos + aOffset; - } - - GRClosedPoly( aPanel->GetClipBox(), aDC, ccount, &shape[0], - true, // = Filled - 0, // outline width - m_Color, // outline color - m_Color // fill collor - ); -} diff --git a/common/marker_base.cpp b/common/marker_base.cpp index 56dc01bd49..97149a6588 100644 --- a/common/marker_base.cpp +++ b/common/marker_base.cpp @@ -235,3 +235,23 @@ void MARKER_BASE::DisplayMarkerInfo( EDA_DRAW_FRAME* aFrame ) infodisplay.m_htmlWindow->SetPage( msg ); infodisplay.ShowModal(); } + + +void MARKER_BASE::PrintMarker( wxDC* aDC, const wxPoint& aOffset ) +{ + // Build the marker shape polygon in internal units: + const int ccount = GetShapePolygonCornerCount(); + std::vector shape; + shape.reserve( ccount ); + + for( int ii = 0; ii < ccount; ii++ ) + { + shape.push_back( wxPoint( GetShapePolygonCorner( ii ).x * MarkerScale(), + GetShapePolygonCorner( ii ).y * MarkerScale() ) ); + } + + for( int ii = 0; ii < ccount; ii++ ) + shape[ii] += m_Pos + aOffset; + + GRClosedPoly( nullptr, aDC, ccount, &shape[0], true, 0, m_Color, m_Color ); +} diff --git a/common/page_layout/ws_data_item.cpp b/common/page_layout/ws_data_item.cpp index efddf307b0..1f064b61fe 100644 --- a/common/page_layout/ws_data_item.cpp +++ b/common/page_layout/ws_data_item.cpp @@ -50,7 +50,7 @@ */ #include -#include +#include #include #include #include diff --git a/common/page_layout/ws_data_model.cpp b/common/page_layout/ws_data_model.cpp index 7864a5d67a..25d39f8952 100644 --- a/common/page_layout/ws_data_model.cpp +++ b/common/page_layout/ws_data_model.cpp @@ -46,7 +46,7 @@ #include #include -#include +#include #include #include #include diff --git a/common/page_layout/ws_draw_item.cpp b/common/page_layout/ws_draw_item.cpp index c7cd015deb..a898101829 100644 --- a/common/page_layout/ws_draw_item.cpp +++ b/common/page_layout/ws_draw_item.cpp @@ -50,7 +50,7 @@ #include #include -#include +#include #include #include #include @@ -145,10 +145,9 @@ void WS_DRAW_ITEM_BASE::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aL // ============================ TEXT ============================== -void WS_DRAW_ITEM_TEXT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor ) +void WS_DRAW_ITEM_TEXT::PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor ) { - Draw( aClipBox, aDC, aOffset, aColor, GR_COPY, FILLED, COLOR4D::UNSPECIFIED ); + Print( aDC, aOffset, aColor, FILLED ); } @@ -181,8 +180,7 @@ wxString WS_DRAW_ITEM_TEXT::GetSelectMenuText( EDA_UNITS_T aUnits ) const // ============================ POLYGON ============================== -void WS_DRAW_ITEM_POLYGON::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor ) +void WS_DRAW_ITEM_POLYGON::PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor ) { std::vector points_moved; wxPoint *points; @@ -199,7 +197,7 @@ void WS_DRAW_ITEM_POLYGON::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPo points = &m_Corners[0]; } - GRPoly( aClipBox, aDC, m_Corners.size(), points, IsFilled() ? FILLED_SHAPE : NO_FILL, + GRPoly( nullptr, aDC, m_Corners.size(), points, IsFilled() ? FILLED_SHAPE : NO_FILL, GetPenWidth(), aColor, aColor ); } @@ -268,13 +266,10 @@ wxString WS_DRAW_ITEM_POLYGON::GetSelectMenuText( EDA_UNITS_T aUnits ) const // ============================ RECT ============================== -void WS_DRAW_ITEM_RECT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor ) +void WS_DRAW_ITEM_RECT::PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor ) { - GRRect( aClipBox, aDC, - GetStart().x + aOffset.x, GetStart().y + aOffset.y, - GetEnd().x + aOffset.x, GetEnd().y + aOffset.y, - GetPenWidth(), aColor ); + GRRect( nullptr, aDC, GetStart().x + aOffset.x, GetStart().y + aOffset.y, + GetEnd().x + aOffset.x, GetEnd().y + aOffset.y, GetPenWidth(), aColor ); } @@ -330,10 +325,9 @@ wxString WS_DRAW_ITEM_RECT::GetSelectMenuText( EDA_UNITS_T aUnits ) const // ============================ LINE ============================== -void WS_DRAW_ITEM_LINE::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor ) +void WS_DRAW_ITEM_LINE::PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor ) { - GRLine( aClipBox, aDC, GetStart() + aOffset, GetEnd() + aOffset, GetPenWidth(), aColor ); + GRLine( nullptr, aDC, GetStart() + aOffset, GetEnd() + aOffset, GetPenWidth(), aColor ); } @@ -362,17 +356,12 @@ wxString WS_DRAW_ITEM_LINE::GetSelectMenuText( EDA_UNITS_T aUnits ) const // ============== BITMAP ================ -void WS_DRAW_ITEM_BITMAP::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor ) +void WS_DRAW_ITEM_BITMAP::PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor ) { WS_DATA_ITEM_BITMAP* bitmap = (WS_DATA_ITEM_BITMAP*) GetPeer(); if( bitmap->m_ImageBitmap ) - { - GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ) ? GR_COPY : aDrawMode ); bitmap->m_ImageBitmap->DrawBitmap( aDC, m_pos + aOffset ); - GRSetDrawMode( aDC, GR_COPY ); - } } @@ -423,17 +412,16 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( const PAGE_INFO& aPageInfo, } -/* Draws the item list created by BuildWorkSheetGraphicList - * aClipBox = the clipping rect, or NULL if no clipping +/* Print the item list created by BuildWorkSheetGraphicList * aDC = the current Device Context * The not selected items are drawn first (most of items) * 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::Draw( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor ) +void WS_DRAW_ITEM_LIST::Print( wxDC* aDC, COLOR4D aColor ) { for( WS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() ) - item->DrawWsItem( aClipBox, aDC, aColor ); + item->PrintWsItem( aDC, aColor ); } diff --git a/common/plotters/common_plot_functions.cpp b/common/plotters/common_plot_functions.cpp index 35080d621c..6b480e40a8 100644 --- a/common/plotters/common_plot_functions.cpp +++ b/common/plotters/common_plot_functions.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include "ws_draw_item.h" #include "ws_data_item.h" diff --git a/common/plotters/plotter.cpp b/common/plotters/plotter.cpp index d692e67e71..b7a21db48b 100644 --- a/common/plotters/plotter.cpp +++ b/common/plotters/plotter.cpp @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index e0fd96b288..7767311ac3 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -167,10 +167,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa auto& galOpts = GetGalDisplayOptions(); galOpts.m_axesEnabled = true; - // Set up viewport - KIGFX::VIEW* view = GetGalCanvas()->GetView(); - view->SetScale( GetZoomLevelCoeff() / m_canvas->GetScreen()->GetZoom() ); - view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); + GetGalCanvas()->GetView()->SetScale( GetZoomLevelCoeff() / m_canvas->GetScreen()->GetZoom() ); ActivateGalCanvas(); @@ -517,12 +514,9 @@ void DISPLAY_FOOTPRINTS_FRAME::SyncMenusAndToolbars() /* * Redraw the BOARD items but not cursors, axis or grid. */ -void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - GR_DRAWMODE aDrawMode, const wxPoint& aOffset ) +void BOARD::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset ) { if( m_Modules ) - { - m_Modules->Draw( aPanel, aDC, GR_COPY ); - } + m_Modules->Print( aFrame, aDC ); } diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index 92090b1723..865db6ef47 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -367,14 +367,14 @@ void LIB_PART::SetName( const wxString& aName ) } -void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset, - int aMulti, int aConvert, const PART_DRAW_OPTIONS& aOpts ) +void LIB_PART::Print( wxDC* aDc, 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 * Note also, background is not drawn when printing in black and white */ - if( ! GetGRForceBlackPenState() ) + if( !GetGRForceBlackPenState() ) { for( LIB_ITEM& drawItem : m_drawings ) { @@ -393,7 +393,7 @@ void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset, // Now, draw only the background for items with // m_Fill == FILLED_WITH_BG_BODYCOLOR: - drawItem.Draw( aPanel, aDc, aOffset, (void*) false, aOpts.transform ); + drawItem.Print( aDc, aOffset, (void*) false, aOpts.transform ); } } @@ -419,16 +419,16 @@ void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset, if( drawItem.Type() == LIB_PIN_T ) { - drawItem.Draw( aPanel, aDc, aOffset, (void*) aOpts.show_elec_type, aOpts.transform ); + drawItem.Print( aDc, aOffset, (void*) aOpts.show_elec_type, aOpts.transform ); } else if( drawItem.Type() == LIB_FIELD_T ) { - drawItem.Draw( aPanel, aDc, aOffset, (void*) NULL, aOpts.transform ); + drawItem.Print( aDc, aOffset, (void*) NULL, aOpts.transform ); } else { bool forceNoFill = drawItem.m_Fill == FILLED_WITH_BG_BODYCOLOR; - drawItem.Draw( aPanel, aDc, aOffset, (void*) forceNoFill, aOpts.transform ); + drawItem.Print( aDc, aOffset, (void*) forceNoFill, aOpts.transform ); } } } @@ -514,7 +514,7 @@ void LIB_PART::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert, } -void LIB_PART::RemoveDrawItem( LIB_ITEM* aItem, EDA_DRAW_PANEL* aPanel, wxDC* aDc ) +void LIB_PART::RemoveDrawItem( LIB_ITEM* aItem ) { wxASSERT( aItem != NULL ); diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h index f670181066..c02bb87a07 100644 --- a/eeschema/class_libentry.h +++ b/eeschema/class_libentry.h @@ -436,17 +436,16 @@ public: LIB_FIELD& GetFootprintField(); /** - * Draw part. + * Print part. * - * @param aPanel - Window to draw on. Can be NULL if not available. * @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 Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset, - int aMulti, int aConvert, const PART_DRAW_OPTIONS& aOpts ); + void Print( wxDC* aDc, const wxPoint& aOffset, int aMulti, int aConvert, + const PART_DRAW_OPTIONS& aOpts ); /** * Plot lib part to plotter. @@ -460,7 +459,7 @@ public: * @param aTransform - Component plot transform matrix. */ void Plot( PLOTTER* aPlotter, int aUnit, int aConvert, const wxPoint& aOffset, - const TRANSFORM& aTransform ); + const TRANSFORM& aTransform ); /** * Plot Lib Fields only of the part to plotter. @@ -472,8 +471,8 @@ public: * @param aOffset - Distance to shift the plot coordinates. * @param aTransform - Component plot transform matrix. */ - void PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert, - const wxPoint& aOffset, const TRANSFORM& aTransform ); + void PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert, const wxPoint& aOffset, + const TRANSFORM& aTransform ); /** * Add a new draw \a aItem to the draw object list. @@ -486,10 +485,8 @@ public: * Remove draw \a aItem from list. * * @param aItem - Draw item to remove from list. - * @param aPanel - Panel to remove part from. - * @param aDc - Device context to remove part from. */ - void RemoveDrawItem( LIB_ITEM* aItem, EDA_DRAW_PANEL* aPanel = NULL, wxDC* aDc = NULL ); + void RemoveDrawItem( LIB_ITEM* aItem ); /** * Return the next draw object pointer. @@ -557,7 +554,7 @@ public: * @param aTestLength - Whether two pins at the same point must have the same length. */ bool PinsConflictWith( LIB_PART& aOtherPart, bool aTestNums, bool aTestNames, - bool aTestType, bool aTestOrientation, bool aTestLength ); + bool aTestType, bool aTestOrientation, bool aTestLength ); /** * Move the part \a aOffset. @@ -604,8 +601,8 @@ public: * @param aTransform = the transform matrix * @return The draw object if found. Otherwise NULL. */ - LIB_ITEM* LocateDrawItem( int aUnit, int aConvert, KICAD_T aType, - const wxPoint& aPoint, const TRANSFORM& aTransform ); + LIB_ITEM* LocateDrawItem( int aUnit, int aConvert, KICAD_T aType, const wxPoint& aPoint, + const TRANSFORM& aTransform ); /** * Return a reference to the draw item list. @@ -630,7 +627,6 @@ public: * @param count - Number of units per package. */ void SetUnitCount( int count ); - int GetUnitCount() const { return m_unitCount; } /** @@ -656,7 +652,6 @@ public: * only for read/save setting functions */ static int* SubpartIdSeparatorPtr() { return &m_subpartIdSeparator; } - static int GetSubpartFirstId() { return m_subpartFirstId; } /** return a reference to m_subpartFirstId, only for read/save setting functions @@ -696,7 +691,6 @@ public: * @param aOffset - The offset in mils. */ void SetPinNameOffset( int aOffset ) { m_pinNameOffset = aOffset; } - int GetPinNameOffset() { return m_pinNameOffset; } /** @@ -705,7 +699,6 @@ public: * @param aShow - True to make the part pin names visible. */ void SetShowPinNames( bool aShow ) { m_showPinNames = aShow; } - bool ShowPinNames() { return m_showPinNames; } /** @@ -714,7 +707,6 @@ public: * @param aShow - True to make the part pin numbers visible. */ void SetShowPinNumbers( bool aShow ) { m_showPinNumbers = aShow; } - bool ShowPinNumbers() { return m_showPinNumbers; } bool operator==( const LIB_PART* aPart ) const { return this == aPart; } diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index 3ebe488199..c2d199998e 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include #include diff --git a/eeschema/dialogs/dialog_lib_edit_pin.cpp b/eeschema/dialogs/dialog_lib_edit_pin.cpp index fb3374e03a..08855a38dd 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin.cpp @@ -169,7 +169,7 @@ void DIALOG_LIB_EDIT_PIN::OnPaintShowPanel( wxPaintEvent& event ) dc.SetUserScale( scale, scale ); GRResetPenAndBrush( &dc ); - m_dummyPin->Draw( nullptr, &dc, -bBox.Centre(), (void*)0, DefaultTransform ); + m_dummyPin->Print( &dc, -bBox.Centre(), (void*)0, DefaultTransform ); m_dummyPin->SetParent( nullptr ); diff --git a/eeschema/dialogs/dialog_print_using_printer.cpp b/eeschema/dialogs/dialog_print_using_printer.cpp index 7d945faf33..c16bd682a7 100644 --- a/eeschema/dialogs/dialog_print_using_printer.cpp +++ b/eeschema/dialogs/dialog_print_using_printer.cpp @@ -88,7 +88,7 @@ public: bool HasPage( int page ) override; bool OnBeginDocument( int startPage, int endPage ) override; void GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo ) override; - void DrawPage( SCH_SCREEN* aScreen ); + void PrintPage( SCH_SCREEN* aScreen ); }; @@ -321,7 +321,7 @@ bool SCH_PRINTOUT::OnPrintPage( int page ) m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->SetSheetNumberAndCount(); screen = m_parent->GetCurrentSheet().LastScreen(); - DrawPage( screen ); + PrintPage( screen ); m_parent->SetCurrentSheet( oldsheetpath ); m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->SetSheetNumberAndCount(); @@ -369,16 +369,14 @@ bool SCH_PRINTOUT::OnBeginDocument( int startPage, int endPage ) /* * This is the real print function: print the active screen */ -void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen ) +void SCH_PRINTOUT::PrintPage( SCH_SCREEN* aScreen ) { int oldZoom; wxPoint tmp_startvisu; wxSize pageSizeIU; // Page size in internal units wxPoint old_org; - EDA_RECT oldClipBox; wxRect fitRect; wxDC* dc = GetDC(); - auto panel = m_parent->GetCanvas(); wxBusyCursor dummy; @@ -387,13 +385,6 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen ) oldZoom = aScreen->GetZoom(); old_org = aScreen->m_DrawOrg; - oldClipBox = *panel->GetClipBox(); - - // Change clip box to print the whole page. - #define MAX_VALUE (INT_MAX/2) // MAX_VALUE is the max we can use in an integer - // and that allows calculations without overflow - panel->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( MAX_VALUE, MAX_VALUE ) ) ); - // Change scale factor and offset to print the whole page. bool printReference = m_parent->GetPrintSheetReference(); @@ -437,23 +428,23 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen ) m_parent->SetDrawBgColor( COLOR4D::WHITE ); GRSetDrawMode( dc, GR_COPY ); - GRSFilledRect( nullptr, dc, fitRect.GetX(), fitRect.GetY(), - fitRect.GetRight(), fitRect.GetBottom(), - 0, COLOR4D::WHITE, COLOR4D::WHITE ); + GRSFilledRect( nullptr, dc, fitRect.GetX(), fitRect.GetY(), fitRect.GetRight(), + fitRect.GetBottom(), 0, COLOR4D::WHITE, COLOR4D::WHITE ); if( m_parent->GetPrintMonochrome() ) GRForceBlackPen( true ); - aScreen->Draw( panel, dc ); + aScreen->Print( dc ); if( printReference ) - m_parent->DrawWorkSheet( dc, aScreen, GetDefaultLineThickness(), - IU_PER_MILS, aScreen->GetFileName(), wxEmptyString, - GetLayerColor( ( SCH_LAYER_ID )LAYER_WORKSHEET ) ); + { + m_parent->PrintWorkSheet( dc, aScreen, GetDefaultLineThickness(), IU_PER_MILS, + aScreen->GetFileName(), wxEmptyString, + GetLayerColor( ( SCH_LAYER_ID )LAYER_WORKSHEET ) ); + } m_parent->SetDrawBgColor( bgColor ); aScreen->m_IsPrinting = false; - panel->SetClipBox( oldClipBox ); GRForceBlackPen( false ); diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 47d4be3d34..74ae78f3df 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -25,11 +25,10 @@ #include #include #include -#include +#include #include #include #include -#include #include #include #include diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index e40ad41d8c..dd13e9287f 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index 014d35de9a..d65311144d 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -295,14 +295,8 @@ int LIB_ARC::GetPenSize() const } -void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, - const TRANSFORM& aTransform ) +void LIB_ARC::print( wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform ) { - // Don't draw the arc until the end point is selected. Only the edit indicators - // get drawn at this time. - if( IsNew() && m_lastEditState == 1 ) - return; - wxPoint pos1, pos2, posc; COLOR4D color = GetLayerColor( LAYER_DEVICE ); COLOR4D bgColor = GetLayerColor( LAYER_DEVICE_BACKGROUND ); @@ -322,15 +316,14 @@ void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf FILL_T fill = aData ? NO_FILL : m_Fill; - EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL; int penSize = GetPenSize(); if( fill == FILLED_WITH_BG_BODYCOLOR ) - GRFilledArc( clipbox, aDC, posc.x, posc.y, pt1, pt2, m_Radius, penSize, bgColor, bgColor ); + GRFilledArc( nullptr, aDC, posc.x, posc.y, pt1, pt2, m_Radius, penSize, bgColor, bgColor ); else if( fill == FILLED_SHAPE && !aData ) - GRFilledArc( clipbox, aDC, posc.x, posc.y, pt1, pt2, m_Radius, color, color ); + GRFilledArc( nullptr, aDC, posc.x, posc.y, pt1, pt2, m_Radius, color, color ); else - GRArc1( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, posc.x, posc.y, penSize, color ); + GRArc1( nullptr, aDC, pos1.x, pos1.y, pos2.x, pos2.y, posc.x, posc.y, penSize, color ); } diff --git a/eeschema/lib_arc.h b/eeschema/lib_arc.h index adbb3b6eb8..3ec4aa34d1 100644 --- a/eeschema/lib_arc.h +++ b/eeschema/lib_arc.h @@ -53,11 +53,8 @@ class LIB_ARC : public LIB_ITEM int m_editDirection; int m_lastEditState; - /** - * Draws the arc. - */ - void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, - const TRANSFORM& aTransform ) override; + void print( wxDC* aDC, const wxPoint& aOffset, void* aData, + const TRANSFORM& aTransform ) override; public: LIB_ARC( LIB_PART * aParent ); diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index a67d71ec06..ec1460db53 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -211,8 +211,8 @@ int LIB_BEZIER::GetPenSize() const } -void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - void* aData, const TRANSFORM& aTransform ) +void LIB_BEZIER::print( wxDC* aDC, const wxPoint& aOffset, void* aData, + const TRANSFORM& aTransform ) { std::vector PolyPointsTraslated; @@ -228,21 +228,19 @@ void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& FILL_T fill = aData ? NO_FILL : m_Fill; - EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL; - if( fill == FILLED_WITH_BG_BODYCOLOR ) { - GRPoly( clipbox, aDC, m_PolyPoints.size(), &PolyPointsTraslated[0], true, GetPenSize(), + GRPoly( nullptr, aDC, m_PolyPoints.size(), &PolyPointsTraslated[0], true, GetPenSize(), bgColor, bgColor ); } else if( fill == FILLED_SHAPE ) { - GRPoly( clipbox, aDC, m_PolyPoints.size(), &PolyPointsTraslated[0], true, GetPenSize(), + GRPoly( nullptr, aDC, m_PolyPoints.size(), &PolyPointsTraslated[0], true, GetPenSize(), color, color ); } else { - GRPoly( clipbox, aDC, m_PolyPoints.size(), &PolyPointsTraslated[0], false, GetPenSize(), + GRPoly( nullptr, aDC, m_PolyPoints.size(), &PolyPointsTraslated[0], false, GetPenSize(), color, color ); } } diff --git a/eeschema/lib_bezier.h b/eeschema/lib_bezier.h index 5271a768f4..3012157a06 100644 --- a/eeschema/lib_bezier.h +++ b/eeschema/lib_bezier.h @@ -38,8 +38,8 @@ class LIB_BEZIER : public LIB_ITEM std::vector m_BezierPoints; // list of parameter (3|4) std::vector m_PolyPoints; // list of points (>= 2) - void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, - const TRANSFORM& aTransform ) override; + void print( wxDC* aDC, const wxPoint& aOffset, void* aData, + const TRANSFORM& aTransform ) override; public: LIB_BEZIER( LIB_PART * aParent ); diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index 8a5bb4ecf7..7b9346ecfd 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -196,22 +196,20 @@ int LIB_CIRCLE::GetPenSize() const } -void LIB_CIRCLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - void* aData, const TRANSFORM& aTransform ) +void LIB_CIRCLE::print( wxDC* aDC, const wxPoint& aOffset, void* aData, + const TRANSFORM& aTransform ) { wxPoint pos1 = aTransform.TransformCoordinate( m_Pos ) + aOffset; COLOR4D color = GetLayerColor( LAYER_DEVICE ); COLOR4D bgColor = GetLayerColor( LAYER_DEVICE_BACKGROUND ); FILL_T fill = aData ? NO_FILL : m_Fill; - EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL; - if( fill == FILLED_WITH_BG_BODYCOLOR ) - GRFilledCircle( clipbox, aDC, pos1.x, pos1.y, GetRadius(), GetPenSize(), bgColor, bgColor ); + GRFilledCircle( nullptr, aDC, pos1.x, pos1.y, GetRadius(), GetPenSize(), bgColor, bgColor ); else if( fill == FILLED_SHAPE ) - GRFilledCircle( clipbox, aDC, pos1.x, pos1.y, GetRadius(), 0, color, color ); + GRFilledCircle( nullptr, aDC, pos1.x, pos1.y, GetRadius(), 0, color, color ); else - GRCircle( clipbox, aDC, pos1.x, pos1.y, GetRadius(), GetPenSize(), color ); + GRCircle( nullptr, aDC, pos1.x, pos1.y, GetRadius(), GetPenSize(), color ); } diff --git a/eeschema/lib_circle.h b/eeschema/lib_circle.h index c5b858e62f..3738428bfe 100644 --- a/eeschema/lib_circle.h +++ b/eeschema/lib_circle.h @@ -34,8 +34,8 @@ class LIB_CIRCLE : public LIB_ITEM wxPoint m_EndPos; // A point on the circumference of the circle. int m_Width; // Line width. - void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, - const TRANSFORM& aTransform ) override; + void print( wxDC* aDC, const wxPoint& aOffset, void* aData, + const TRANSFORM& aTransform ) override; public: LIB_CIRCLE( LIB_PART * aParent ); diff --git a/eeschema/lib_draw_item.cpp b/eeschema/lib_draw_item.cpp index 9cb2dfe68d..298a7e07a2 100644 --- a/eeschema/lib_draw_item.cpp +++ b/eeschema/lib_draw_item.cpp @@ -124,10 +124,9 @@ bool LIB_ITEM::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) } -void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, - const TRANSFORM& aTransform ) +void LIB_ITEM::Print( wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform ) { - drawGraphic( aPanel, aDC, aOffset, aData, aTransform ); + print( aDC, aOffset, aData, aTransform ); } diff --git a/eeschema/lib_draw_item.h b/eeschema/lib_draw_item.h index 992fa4531b..964eff5de2 100644 --- a/eeschema/lib_draw_item.h +++ b/eeschema/lib_draw_item.h @@ -44,7 +44,6 @@ class PLOTTER; class LIB_ITEM; class LIB_PIN; class MSG_PANEL_ITEM; -class EDA_DRAW_PANEL; extern const int fill_tab[]; @@ -67,17 +66,16 @@ typedef std::vector< LIB_PIN* > LIB_PINS; class LIB_ITEM : public EDA_ITEM { /** - * Draw the item on \a aPanel. + * Print the item to \a aDC. * - * @param aPanel A pointer to the panel to draw the object upon. * @param aDC A pointer to the device context used to draw the object. * @param aOffset A reference to a wxPoint object containing the offset where to draw * from the object's current position. * @param aData A pointer to any object specific data required to perform the draw. * @param aTransform A reference to a #TRANSFORM object containing drawing transform. */ - virtual void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - void* aData, const TRANSFORM& aTransform ) = 0; + virtual void print( wxDC* aDC, const wxPoint& aOffset, void* aData, + const TRANSFORM& aTransform ) = 0; friend class LIB_PART; @@ -174,7 +172,6 @@ public: /** * Draw an item * - * @param aPanel DrawPanel to use (can be null) mainly used for clipping purposes. * @param aDC Device Context (can be null) * @param aOffset Offset to draw * @param aData Value or pointer used to pass others parameters, depending on body items. @@ -183,8 +180,8 @@ public: * pass reference to the lib component for pins. * @param aTransform Transform Matrix (rotation, mirror ..) */ - virtual void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint &aOffset, void* aData, - const TRANSFORM& aTransform ); + virtual void Print( wxDC* aDC, const wxPoint &aOffset, void* aData, + const TRANSFORM& aTransform ); /** * @return the size of the "pen" that be used to draw or plot this item diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 5efef785c2..3513e57c49 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include @@ -128,8 +128,8 @@ int LIB_FIELD::GetPenSize() const } -void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - void* aData, const TRANSFORM& aTransform ) +void LIB_FIELD::print( wxDC* aDC, const wxPoint& aOffset, void* aData, + const TRANSFORM& aTransform ) { wxPoint text_pos; COLOR4D color = IsVisible() ? GetDefaultColor() : GetInvisibleItemColor(); @@ -144,10 +144,8 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a else text = m_Text; - EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL; - - DrawGraphicText( clipbox, aDC, text_pos, color, text, GetTextAngle(), GetTextSize(), - GetHorizJustify(), GetVertJustify(), linewidth, IsItalic(), IsBold() ); + GRText( aDC, text_pos, color, text, GetTextAngle(), GetTextSize(), GetHorizJustify(), + GetVertJustify(), linewidth, IsItalic(), IsBold() ); } diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index 0f7d468876..03e8dc7474 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -62,14 +62,14 @@ class LIB_FIELD : public LIB_ITEM, public EDA_TEXT wxString m_name; ///< Name (not the field text value itself, that is .m_Text) /** - * Draw the field. + * Print the field. *

* If \a aData not NULL, \a aData must point a wxString which is used instead of * the m_Text *

*/ - void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, - const TRANSFORM& aTransform ) override; + void print( wxDC* aDC, const wxPoint& aOffset, void* aData, + const TRANSFORM& aTransform ) override; /** * Calculate the new circle at \a aPosition when editing. diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index f7c73d5c5c..9eca5bbd6b 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include @@ -558,8 +558,7 @@ int LIB_PIN::GetPenSize() const } -void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, - const TRANSFORM& aTransform ) +void LIB_PIN::print( wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform ) { // aData is used here as a boolean. bool drawElectricalTypeName = (bool) aData; @@ -572,42 +571,26 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf /* Calculate the pin position */ wxPoint pos1 = aTransform.TransformCoordinate( m_position ) + aOffset; - // Invisible pins are only drawn on request. if( !IsVisible() ) - { - bool drawHidden = true; + return; - if( aPanel && aPanel->GetParent() ) - { - EDA_DRAW_FRAME* frame = aPanel->GetParent(); + PrintPinSymbol( aDC, pos1, orient ); - if( frame->IsType( FRAME_SCH ) ) - drawHidden = static_cast( frame )->GetShowAllPins(); - } - - if( !drawHidden ) - return; - } - - DrawPinSymbol( aPanel, aDC, pos1, orient ); - - DrawPinTexts( aPanel, aDC, pos1, orient, Entry->GetPinNameOffset(), Entry->ShowPinNumbers(), + PrintPinTexts( aDC, pos1, orient, Entry->GetPinNameOffset(), Entry->ShowPinNumbers(), Entry->ShowPinNames() ); if( drawElectricalTypeName ) - DrawPinElectricalTypeName( aPanel, aDC, pos1, orient ); + PrintPinElectricalTypeName( aDC, pos1, orient ); } -void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPos, int aOrient ) +void LIB_PIN::PrintPinSymbol( wxDC* aDC, const wxPoint& aPos, int aOrient ) { int MapX1, MapY1, x1, y1; int width = GetPenSize(); int posX = aPos.x, posY = aPos.y, len = m_length; COLOR4D color = IsVisible() ? GetLayerColor( LAYER_PIN ) : GetInvisibleItemColor(); - EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL; - MapX1 = MapY1 = 0; x1 = posX; y1 = posY; @@ -623,10 +606,10 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a if( m_shape == PINSHAPE_INVERTED || m_shape == PINSHAPE_INVERTED_CLOCK ) { const int radius = ExternalPinDecoSize( *this ); - GRCircle( clipbox, aDC, MapX1 * radius + x1, MapY1 * radius + y1, radius, width, color ); + GRCircle( nullptr, aDC, MapX1 * radius + x1, MapY1 * radius + y1, radius, width, color ); GRMoveTo( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 ); - GRLineTo( clipbox, aDC, posX, posY, width, color ); + GRLineTo( nullptr, aDC, posX, posY, width, color ); } else if( m_shape == PINSHAPE_FALLING_EDGE_CLOCK ) /* an alternative for Inverted Clock */ { @@ -634,22 +617,22 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a if( MapY1 == 0 ) /* MapX1 = +- 1 */ { GRMoveTo( x1, y1 + deco_size ); - GRLineTo( clipbox, aDC, x1 + MapX1 * deco_size * 2, y1, width, color ); - GRLineTo( clipbox, aDC, x1, y1 - deco_size, width, color ); + GRLineTo( nullptr, aDC, x1 + MapX1 * deco_size * 2, y1, width, color ); + GRLineTo( nullptr, aDC, x1, y1 - deco_size, width, color ); } else /* MapX1 = 0 */ { GRMoveTo( x1 + deco_size, y1 ); - GRLineTo( clipbox, aDC, x1, y1 + MapY1 * deco_size * 2, width, color ); - GRLineTo( clipbox, aDC, x1 - deco_size, y1, width, color ); + GRLineTo( nullptr, aDC, x1, y1 + MapY1 * deco_size * 2, width, color ); + GRLineTo( nullptr, aDC, x1 - deco_size, y1, width, color ); } GRMoveTo( MapX1 * deco_size * 2 + x1, MapY1 * deco_size * 2 + y1 ); - GRLineTo( clipbox, aDC, posX, posY, width, color ); + GRLineTo( nullptr, aDC, posX, posY, width, color ); } else { GRMoveTo( x1, y1 ); - GRLineTo( clipbox, aDC, posX, posY, width, color ); + GRLineTo( nullptr, aDC, posX, posY, width, color ); } if( m_shape == PINSHAPE_CLOCK || m_shape == PINSHAPE_INVERTED_CLOCK || m_shape == PINSHAPE_CLOCK_LOW ) @@ -658,14 +641,14 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a if( MapY1 == 0 ) /* MapX1 = +- 1 */ { GRMoveTo( x1, y1 + clock_size ); - GRLineTo( clipbox, aDC, x1 - MapX1 * clock_size * 2, y1, width, color ); - GRLineTo( clipbox, aDC, x1, y1 - clock_size, width, color ); + GRLineTo( nullptr, aDC, x1 - MapX1 * clock_size * 2, y1, width, color ); + GRLineTo( nullptr, aDC, x1, y1 - clock_size, width, color ); } else /* MapX1 = 0 */ { GRMoveTo( x1 + clock_size, y1 ); - GRLineTo( clipbox, aDC, x1, y1 - MapY1 * clock_size * 2, width, color ); - GRLineTo( clipbox, aDC, x1 - clock_size, y1, width, color ); + GRLineTo( nullptr, aDC, x1, y1 - MapY1 * clock_size * 2, width, color ); + GRLineTo( nullptr, aDC, x1 - clock_size, y1, width, color ); } } @@ -675,14 +658,14 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a if( MapY1 == 0 ) /* MapX1 = +- 1 */ { GRMoveTo( x1 + MapX1 * deco_size * 2, y1 ); - GRLineTo( clipbox, aDC, x1 + MapX1 * deco_size * 2, y1 - deco_size * 2, width, color ); - GRLineTo( clipbox, aDC, x1, y1, width, color ); + GRLineTo( nullptr, aDC, x1 + MapX1 * deco_size * 2, y1 - deco_size * 2, width, color ); + GRLineTo( nullptr, aDC, x1, y1, width, color ); } else /* MapX1 = 0 */ { GRMoveTo( x1, y1 + MapY1 * deco_size * 2 ); - GRLineTo( clipbox, aDC, x1 - deco_size * 2, y1 + MapY1 * deco_size * 2, width, color ); - GRLineTo( clipbox, aDC, x1, y1, width, color ); + GRLineTo( nullptr, aDC, x1 - deco_size * 2, y1 + MapY1 * deco_size * 2, width, color ); + GRLineTo( nullptr, aDC, x1, y1, width, color ); } } @@ -693,36 +676,36 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a if( MapY1 == 0 ) /* MapX1 = +- 1 */ { GRMoveTo( x1, y1 - deco_size * 2 ); - GRLineTo( clipbox, aDC, x1 + MapX1 * deco_size * 2, y1, width, color ); + GRLineTo( nullptr, aDC, x1 + MapX1 * deco_size * 2, y1, width, color ); } else /* MapX1 = 0 */ { GRMoveTo( x1 - deco_size * 2, y1 ); - GRLineTo( clipbox, aDC, x1, y1 + MapY1 * deco_size * 2, width, color ); + GRLineTo( nullptr, aDC, x1, y1 + MapY1 * deco_size * 2, width, color ); } } else if( m_shape == PINSHAPE_NONLOGIC ) /* NonLogic pin symbol */ { const int deco_size = ExternalPinDecoSize( *this ); GRMoveTo( x1 - (MapX1 + MapY1) * deco_size, y1 - (MapY1 - MapX1) * deco_size ); - GRLineTo( clipbox, aDC, x1 + (MapX1 + MapY1) * deco_size, y1 + (MapY1 - MapX1) * deco_size, width, + GRLineTo( nullptr, aDC, x1 + (MapX1 + MapY1) * deco_size, y1 + (MapY1 - MapX1) * deco_size, width, color ); GRMoveTo( x1 - (MapX1 - MapY1) * deco_size, y1 - (MapY1 + MapX1) * deco_size ); - GRLineTo( clipbox, aDC, x1 + (MapX1 - MapY1) * deco_size, y1 + (MapY1 + MapX1) * deco_size, width, + GRLineTo( nullptr, aDC, x1 + (MapX1 - MapY1) * deco_size, y1 + (MapY1 + MapX1) * deco_size, width, color ); } if( m_type == PIN_NC ) // Draw a N.C. symbol { const int deco_size = TARGET_PIN_RADIUS; - GRLine( clipbox, aDC, posX - deco_size, posY - deco_size, posX + deco_size, posY + deco_size, width, color ); - GRLine( clipbox, aDC, posX + deco_size, posY - deco_size, posX - deco_size, posY + deco_size, width, color ); + GRLine( nullptr, aDC, posX - deco_size, posY - deco_size, posX + deco_size, posY + deco_size, width, color ); + GRLine( nullptr, aDC, posX + deco_size, posY - deco_size, posX - deco_size, posY + deco_size, width, color ); } } -void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, wxDC* DC, wxPoint& pin_pos, int orient, - int TextInside, bool DrawPinNum, bool DrawPinName ) +void LIB_PIN::PrintPinTexts( wxDC* DC, wxPoint& pin_pos, int orient, int TextInside, + bool DrawPinNum, bool DrawPinName ) { if( !DrawPinName && !DrawPinNum ) return; @@ -736,8 +719,6 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, wxDC* DC, wxPoint& pin_pos, i int name_offset = PIN_TEXT_MARGIN + ( nameLineWidth + GetDefaultLineThickness() ) / 2; int num_offset = PIN_TEXT_MARGIN + ( numLineWidth + GetDefaultLineThickness() ) / 2; - EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; - /* Get the num and name colors */ COLOR4D NameColor = IsVisible() ? GetLayerColor( LAYER_PINNAM ) : GetInvisibleItemColor(); COLOR4D NumColor = IsVisible() ? GetLayerColor( LAYER_PINNUM ) : GetInvisibleItemColor(); @@ -766,26 +747,24 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, wxDC* DC, wxPoint& pin_pos, i if( orient == PIN_RIGHT ) { x = x1 + TextInside; - DrawGraphicText( clipbox, DC, wxPoint( x, y1 ), NameColor, - m_name, TEXT_ANGLE_HORIZ, PinNameSize, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, - nameLineWidth, false, false ); + GRText( DC, wxPoint( x, y1 ), NameColor, m_name, TEXT_ANGLE_HORIZ, + PinNameSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, + nameLineWidth, false, false ); } else // Orient == PIN_LEFT { x = x1 - TextInside; - DrawGraphicText( clipbox, DC, wxPoint( x, y1 ), NameColor, m_name, - TEXT_ANGLE_HORIZ, PinNameSize, GR_TEXT_HJUSTIFY_RIGHT, - GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, false, false ); + GRText( DC, wxPoint( x, y1 ), NameColor, m_name, TEXT_ANGLE_HORIZ, + PinNameSize, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, + nameLineWidth, false, false ); } } if( DrawPinNum ) { - DrawGraphicText( clipbox, DC, wxPoint( (x1 + pin_pos.x) / 2, y1 - num_offset ), - NumColor, m_number, TEXT_ANGLE_HORIZ, PinNumSize, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, - false, false ); + GRText( DC, wxPoint( (x1 + pin_pos.x) / 2, y1 - num_offset ), NumColor, m_number, + TEXT_ANGLE_HORIZ, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, + GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, false, false ); } } else /* Its a vertical line. */ @@ -796,30 +775,28 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, wxDC* DC, wxPoint& pin_pos, i y = y1 + TextInside; if( DrawPinName ) - DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor, m_name, - TEXT_ANGLE_VERT, PinNameSize, GR_TEXT_HJUSTIFY_RIGHT, - GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, false, false ); + GRText( DC, wxPoint( x1, y ), NameColor, m_name, TEXT_ANGLE_VERT, PinNameSize, + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, false, + false ); if( DrawPinNum ) - DrawGraphicText( clipbox, DC, wxPoint( x1 - num_offset, (y1 + pin_pos.y) / 2 ), - NumColor, m_number, TEXT_ANGLE_VERT, PinNumSize, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, - numLineWidth, false, false ); + GRText( DC, wxPoint( x1 - num_offset, (y1 + pin_pos.y) / 2 ), NumColor, + m_number, TEXT_ANGLE_VERT, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, + GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, false, false ); } else /* PIN_UP */ { y = y1 - TextInside; if( DrawPinName ) - DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor, m_name, - TEXT_ANGLE_VERT, PinNameSize, GR_TEXT_HJUSTIFY_LEFT, - GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, false, false ); + GRText( DC, wxPoint( x1, y ), NameColor, m_name, TEXT_ANGLE_VERT, PinNameSize, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, false, + false ); if( DrawPinNum ) - DrawGraphicText( clipbox, DC, wxPoint( x1 - num_offset, (y1 + pin_pos.y) / 2 ), - NumColor, m_number, TEXT_ANGLE_VERT, PinNumSize, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, - numLineWidth, false, false ); + GRText( DC, wxPoint( x1 - num_offset, (y1 + pin_pos.y) / 2 ), NumColor, + m_number, TEXT_ANGLE_VERT, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, + GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, false, false ); } } } @@ -831,16 +808,16 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, wxDC* DC, wxPoint& pin_pos, i if( DrawPinName ) { x = (x1 + pin_pos.x) / 2; - DrawGraphicText( clipbox, DC, wxPoint( x, y1 - name_offset ), NameColor, m_name, - TEXT_ANGLE_HORIZ, PinNameSize, GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth, false, false ); + GRText( DC, wxPoint( x, y1 - name_offset ), NameColor, m_name, TEXT_ANGLE_HORIZ, + PinNameSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, + nameLineWidth, false, false ); } if( DrawPinNum ) { x = (x1 + pin_pos.x) / 2; - DrawGraphicText( clipbox, DC, wxPoint( x, y1 + num_offset ), NumColor, m_number, - TEXT_ANGLE_HORIZ, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_TOP, numLineWidth, false, false ); + GRText( DC, wxPoint( x, y1 + num_offset ), NumColor, m_number, TEXT_ANGLE_HORIZ, + PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, numLineWidth, + false, false ); } } else /* Its a vertical line. */ @@ -848,17 +825,16 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, wxDC* DC, wxPoint& pin_pos, i if( DrawPinName ) { y = (y1 + pin_pos.y) / 2; - DrawGraphicText( clipbox, DC, wxPoint( x1 - name_offset, y ), NameColor, m_name, - TEXT_ANGLE_VERT, PinNameSize, GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth, false, false ); + GRText( DC, wxPoint( x1 - name_offset, y ), NameColor, m_name, TEXT_ANGLE_VERT, + PinNameSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, + nameLineWidth, false, false ); } if( DrawPinNum ) { - DrawGraphicText( clipbox, DC, wxPoint( x1 + num_offset, (y1 + pin_pos.y) / 2 ), - NumColor, m_number, TEXT_ANGLE_VERT, PinNumSize, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, numLineWidth, - false, false ); + GRText( DC, wxPoint( x1 + num_offset, (y1 + pin_pos.y) / 2 ), NumColor, m_number, + TEXT_ANGLE_VERT, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, + numLineWidth, false, false ); } } } @@ -866,8 +842,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, wxDC* DC, wxPoint& pin_pos, i -void LIB_PIN::DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint& aPosition, - int aOrientation ) +void LIB_PIN::PrintPinElectricalTypeName( wxDC* aDC, wxPoint& aPosition, int aOrientation ) { wxString typeName = GetElectricalTypeName(); @@ -912,10 +887,8 @@ void LIB_PIN::DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPo break; } - EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL; - - DrawGraphicText( clipbox, aDC, txtpos, color, typeName, orient, wxSize( textSize, textSize ), - hjustify, GR_TEXT_VJUSTIFY_CENTER, pensize, false, false ); + GRText( aDC, txtpos, color, typeName, orient, wxSize( textSize, textSize ), hjustify, + GR_TEXT_VJUSTIFY_CENTER, pensize, false, false ); } diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index a7b141c37b..8a84af66f5 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -77,17 +77,16 @@ class LIB_PIN : public LIB_ITEM int m_nameTextSize; ///< Pin num and Pin name sizes /** - * Draw a pin, with or without the pin texts + * Print a pin, with or without the pin texts * - * @param aPanel DrawPanel to use (can be null) mainly used for clipping purposes. * @param aDC Device Context (can be null) * @param aOffset Offset to draw * @param aData = used here as a boolean indicating whether or not to draw the pin * electrical types * @param aTransform Transform Matrix (rotation, mirror ..) */ - void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, - const TRANSFORM& aTransform ) override; + void print( wxDC* aDC, const wxPoint& aOffset, void* aData, + const TRANSFORM& aTransform ) override; public: LIB_PIN( LIB_PART* aParent ); @@ -356,11 +355,10 @@ public: int GetPenSize() const override; /** - * Draw the pin symbol without text. + * Print the pin symbol without text. * If \a aColor != 0, draw with \a aColor, else with the normal pin color. */ - void DrawPinSymbol( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPos, - int aOrientation ); + void PrintPinSymbol( wxDC* aDC, const wxPoint& aPos, int aOrientation ); /** * Put the pin number and pin text info, given the pin line coordinates. @@ -370,14 +368,13 @@ public: * If TextInside then the text is been put inside,otherwise all is drawn outside. * Pin Name: substring between '~' is negated */ - void DrawPinTexts( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint& aPosition, - int aOrientation, int TextInside, bool DrawPinNum, bool DrawPinName ); + void PrintPinTexts( wxDC* aDC, wxPoint& aPosition, int aOrientation, int TextInside, + bool DrawPinNum, bool DrawPinName ); /** * Draw the electrical type text of the pin (only for the footprint editor) */ - void DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint& aPosition, - int aOrientation ); + void PrintPinElectricalTypeName( wxDC* aDC, wxPoint& aPosition, int aOrientation ); /** * Plot the pin number and pin text info, given the pin line coordinates. diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index 3e8e1cc340..e9b1ebd961 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -202,8 +202,8 @@ int LIB_POLYLINE::GetPenSize() const } -void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - void* aData, const TRANSFORM& aTransform ) +void LIB_POLYLINE::print( wxDC* aDC, const wxPoint& aOffset, void* aData, + const TRANSFORM& aTransform ) { COLOR4D color = GetLayerColor( LAYER_DEVICE ); COLOR4D bgColor = GetLayerColor( LAYER_DEVICE_BACKGROUND ); @@ -215,13 +215,12 @@ void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint FILL_T fill = aData ? NO_FILL : m_Fill; - EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL; if( fill == FILLED_WITH_BG_BODYCOLOR ) - GRPoly( clipbox, aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(), bgColor, bgColor ); + GRPoly( nullptr, aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(), bgColor, bgColor ); else if( fill == FILLED_SHAPE ) - GRPoly( clipbox, aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(), color, color ); + GRPoly( nullptr, aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(), color, color ); else - GRPoly( clipbox, aDC, m_PolyPoints.size(), buffer, 0, GetPenSize(), color, color ); + GRPoly( nullptr, aDC, m_PolyPoints.size(), buffer, 0, GetPenSize(), color, color ); delete[] buffer; } diff --git a/eeschema/lib_polyline.h b/eeschema/lib_polyline.h index c083cdc1f7..8df9310ef2 100644 --- a/eeschema/lib_polyline.h +++ b/eeschema/lib_polyline.h @@ -33,8 +33,8 @@ class LIB_POLYLINE : public LIB_ITEM int m_Width; // Line width std::vector m_PolyPoints; // list of points (>= 2) - void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, - const TRANSFORM& aTransform ) override; + void print( wxDC* aDC, const wxPoint& aOffset, void* aData, + const TRANSFORM& aTransform ) override; public: LIB_POLYLINE( LIB_PART * aParent ); diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index 3370fc009c..00dd21af25 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -163,8 +163,8 @@ int LIB_RECTANGLE::GetPenSize() const } -void LIB_RECTANGLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - void* aData, const TRANSFORM& aTransform ) +void LIB_RECTANGLE::print( wxDC* aDC, const wxPoint& aOffset, void* aData, + const TRANSFORM& aTransform ) { COLOR4D color = GetLayerColor( LAYER_DEVICE ); COLOR4D bgColor = GetLayerColor( LAYER_DEVICE_BACKGROUND ); @@ -173,13 +173,12 @@ void LIB_RECTANGLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoin FILL_T fill = aData ? NO_FILL : m_Fill; - EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL; if( fill == FILLED_WITH_BG_BODYCOLOR && !aData ) - GRFilledRect( clipbox, aDC, pt1.x, pt1.y, pt2.x, pt2.y, GetPenSize( ), bgColor, bgColor ); + GRFilledRect( nullptr, aDC, pt1.x, pt1.y, pt2.x, pt2.y, GetPenSize( ), bgColor, bgColor ); else if( m_Fill == FILLED_SHAPE && !aData ) - GRFilledRect( clipbox, aDC, pt1.x, pt1.y, pt2.x, pt2.y, GetPenSize(), color, color ); + GRFilledRect( nullptr, aDC, pt1.x, pt1.y, pt2.x, pt2.y, GetPenSize(), color, color ); else - GRRect( clipbox, aDC, pt1.x, pt1.y, pt2.x, pt2.y, GetPenSize(), color ); + GRRect( nullptr, aDC, pt1.x, pt1.y, pt2.x, pt2.y, GetPenSize(), color ); } diff --git a/eeschema/lib_rectangle.h b/eeschema/lib_rectangle.h index a317ccbd33..db7c8c123b 100644 --- a/eeschema/lib_rectangle.h +++ b/eeschema/lib_rectangle.h @@ -34,8 +34,8 @@ class LIB_RECTANGLE : public LIB_ITEM wxPoint m_Pos; // Rectangle start point. int m_Width; // Line width - void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, - const TRANSFORM& aTransform ) override; + void print( wxDC* aDC, const wxPoint& aOffset, void* aData, + const TRANSFORM& aTransform ) override; public: LIB_RECTANGLE( LIB_PART * aParent ); diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index be8f4844a1..0fbd36ae58 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -192,8 +192,7 @@ void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill, else color = COLOR4D::BLACK; - plotter->Text( pos, color, GetShownText(), - t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT, + plotter->Text( pos, color, GetShownText(), t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GetPenSize(), IsItalic(), IsBold() ); } @@ -217,8 +216,7 @@ int LIB_TEXT::GetPenSize() const } -void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - void* aData, const TRANSFORM& aTransform ) +void LIB_TEXT::print( wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform ) { COLOR4D color = GetDefaultColor(); @@ -255,21 +253,16 @@ void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aO // Calculate pos according to mirror/rotation. txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset; - EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL; - DrawGraphicText( clipbox, aDC, txtpos, color, GetShownText(), orient, GetTextSize(), - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GetPenSize(), - IsItalic(), IsBold() ); + GRText( aDC, txtpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, + GR_TEXT_VJUSTIFY_CENTER, GetPenSize(), IsItalic(), IsBold() ); } void LIB_TEXT::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) { - wxString msg; - LIB_ITEM::GetMsgPanelInfo( aUnits, aList ); - msg = MessageTextFromValue( aUnits, GetThickness(), true ); - + wxString msg = MessageTextFromValue( aUnits, GetThickness(), true ); aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) ); } diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h index f19bbfd7cf..0a0ba4b829 100644 --- a/eeschema/lib_text.h +++ b/eeschema/lib_text.h @@ -39,8 +39,8 @@ */ class LIB_TEXT : public LIB_ITEM, public EDA_TEXT { - void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, - const TRANSFORM& aTransform ) override; + void print( wxDC* aDC, const wxPoint& aOffset, void* aData, + const TRANSFORM& aTransform ) override; public: LIB_TEXT( LIB_PART * aParent ); @@ -101,16 +101,13 @@ public: wxPoint GetPosition() const override { return EDA_TEXT::GetTextPos(); } void MirrorHorizontal( const wxPoint& aCenter ) override; - void MirrorVertical( const wxPoint& aCenter ) override; - void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override; void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ) override; int GetWidth() const override { return GetThickness(); } - void SetWidth( int aWidth ) override { SetThickness( aWidth ); } wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index 6dbb26e33c..527479c8e5 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include diff --git a/eeschema/libedit/lib_edit_frame.h b/eeschema/libedit/lib_edit_frame.h index 1f21a22fef..c4bc69c38f 100644 --- a/eeschema/libedit/lib_edit_frame.h +++ b/eeschema/libedit/lib_edit_frame.h @@ -301,17 +301,6 @@ public: void UpdateAfterSymbolProperties( wxString* aOldName, wxArrayString* aOldAliases ); void RebuildSymbolUnitsList(); - /** - * Redraw the current component loaded in library editor - * Display reference like in schematic (a reference U is shown U? or U?A) - * accordint to the current selected unit and De Morgan selection - * although it is stored without ? and part id. - * @param aDC = the current device context - * @param aOffset = a draw offset. usually 0,0 to draw on the screen, but - * can be set to page size / 2 to draw or print in SVG format. - */ - void RedrawComponent( wxDC* aDC, wxPoint aOffset ); - void OnCloseWindow( wxCloseEvent& Event ); void ReCreateHToolbar() override; void ReCreateVToolbar() override; diff --git a/eeschema/libedit/libedit.cpp b/eeschema/libedit/libedit.cpp index dfa54b1730..b983565bef 100644 --- a/eeschema/libedit/libedit.cpp +++ b/eeschema/libedit/libedit.cpp @@ -267,28 +267,6 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, const wxString& a } -void LIB_EDIT_FRAME::RedrawComponent( wxDC* aDC, wxPoint aOffset ) -{ - LIB_PART* part = GetCurPart(); - - if( part ) - { - // display reference like in schematic (a reference U is shown U? or U?A) - // although it is stored without ? and part id. - // So temporary change the reference by a schematic like reference - LIB_FIELD* field = part->GetField( REFERENCE ); - wxString fieldText = field->GetText(); - wxString fieldfullText = field->GetFullText( m_unit ); - - field->EDA_TEXT::SetText( fieldfullText ); // change the field text string only - auto opts = PART_DRAW_OPTIONS::Default(); - opts.show_elec_type = GetShowElectricalType(); - part->Draw( m_canvas, aDC, aOffset, m_unit, m_convert, opts ); - field->EDA_TEXT::SetText( fieldText ); // restore the field text string - } -} - - void LIB_EDIT_FRAME::OnSaveAll() { saveAllLibraries( false ); diff --git a/eeschema/libedit/libedit_plot_component.cpp b/eeschema/libedit/libedit_plot_component.cpp index 449f194e25..5afc7b562c 100644 --- a/eeschema/libedit/libedit_plot_component.cpp +++ b/eeschema/libedit/libedit_plot_component.cpp @@ -192,5 +192,5 @@ void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMod plot_offset.x = pagesize.x / 2; plot_offset.y = pagesize.y / 2; - part->Draw( m_canvas, aDC, plot_offset, m_unit, m_convert, PART_DRAW_OPTIONS::Default() ); + part->Print( aDC, plot_offset, m_unit, m_convert, PART_DRAW_OPTIONS::Default() ); } diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp index d35bd108d2..c0d24b3f09 100644 --- a/eeschema/project_rescue.cpp +++ b/eeschema/project_rescue.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index c1fd4c1a17..13c02ee395 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -397,8 +397,6 @@ void SCH_BASE_FRAME::createCanvas() m_canvas = new SCH_DRAW_PANEL( this, wxID_ANY, wxPoint( 0, 0 ), m_FrameSize, GetGalDisplayOptions(), m_canvasType ); - m_useSingleCanvasPane = true; - SetGalCanvas( static_cast( m_canvas ) ); ActivateGalCanvas(); } diff --git a/eeschema/sch_bitmap.cpp b/eeschema/sch_bitmap.cpp index aaeeeacc6c..80b78af4c3 100644 --- a/eeschema/sch_bitmap.cpp +++ b/eeschema/sch_bitmap.cpp @@ -111,7 +111,7 @@ const EDA_RECT SCH_BITMAP::GetBoundingBox() const } -void SCH_BITMAP::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) +void SCH_BITMAP::Print( wxDC* aDC, const wxPoint& aOffset ) { wxPoint pos = m_pos + aOffset; diff --git a/eeschema/sch_bitmap.h b/eeschema/sch_bitmap.h index edf93fdf90..23359725b5 100644 --- a/eeschema/sch_bitmap.h +++ b/eeschema/sch_bitmap.h @@ -111,7 +111,7 @@ public: void SwapData( SCH_ITEM* aItem ) override; - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; + void Print( wxDC* aDC, const wxPoint& aOffset ) override; /// @copydoc VIEW_ITEM::ViewGetLayers() virtual void ViewGetLayers( int aLayers[], int& aCount ) const override; diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index 64aebf7e9a..dca263d510 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -22,11 +22,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file sch_bus_entry.cpp - * - */ - #include #include #include @@ -36,7 +31,6 @@ #include #include #include - #include #include #include @@ -57,6 +51,7 @@ SCH_BUS_ENTRY_BASE::SCH_BUS_ENTRY_BASE( KICAD_T aType, const wxPoint& pos, char m_isDanglingStart = m_isDanglingEnd = true; } + SCH_BUS_WIRE_ENTRY::SCH_BUS_WIRE_ENTRY( const wxPoint& pos, char shape ) : SCH_BUS_ENTRY_BASE( SCH_BUS_WIRE_ENTRY_T, pos, shape ) { @@ -64,6 +59,7 @@ SCH_BUS_WIRE_ENTRY::SCH_BUS_WIRE_ENTRY( const wxPoint& pos, char shape ) : m_connected_bus_item = nullptr; } + SCH_BUS_BUS_ENTRY::SCH_BUS_BUS_ENTRY( const wxPoint& pos, char shape ) : SCH_BUS_ENTRY_BASE( SCH_BUS_BUS_ENTRY_T, pos, shape ) { @@ -72,11 +68,13 @@ SCH_BUS_BUS_ENTRY::SCH_BUS_BUS_ENTRY( const wxPoint& pos, char shape ) : m_connected_bus_items[1] = nullptr; } + EDA_ITEM* SCH_BUS_WIRE_ENTRY::Clone() const { return new SCH_BUS_WIRE_ENTRY( *this ); } + EDA_ITEM* SCH_BUS_BUS_ENTRY::Clone() const { return new SCH_BUS_BUS_ENTRY( *this ); @@ -108,7 +106,6 @@ void SCH_BUS_ENTRY_BASE::SwapData( SCH_ITEM* aItem ) void SCH_BUS_ENTRY_BASE::ViewGetLayers( int aLayers[], int& aCount ) const { aCount = 1; - aLayers[0] = Type() == SCH_BUS_BUS_ENTRY_T ? LAYER_BUS : LAYER_WIRE; } @@ -159,13 +156,12 @@ void SCH_BUS_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemLis } -void SCH_BUS_ENTRY_BASE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) +void SCH_BUS_ENTRY_BASE::Print( wxDC* aDC, const wxPoint& aOffset ) { - COLOR4D color = GetLayerColor( m_Layer ); - EDA_RECT* clipbox = aPanel->GetClipBox(); + COLOR4D color = GetLayerColor( m_Layer ); - GRLine( clipbox, aDC, m_pos.x + aOffset.x, m_pos.y + aOffset.y, - m_End().x + aOffset.x, m_End().y + aOffset.y, GetPenSize(), color ); + GRLine( nullptr, aDC, m_pos.x + aOffset.x, m_pos.y + aOffset.y, m_End().x + aOffset.x, + m_End().y + aOffset.y, GetPenSize(), color ); } diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index 5a4bd7d1c1..93b6a09bc4 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -85,7 +85,7 @@ public: void ViewGetLayers( int aLayers[], int& aCount ) const override; - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; + void Print( wxDC* aDC, const wxPoint& aOffset ) override; const EDA_RECT GetBoundingBox() const override; diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 3610184908..d86bcad04c 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -541,7 +541,7 @@ int SCH_COMPONENT::GetUnitCount() const } -void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) +void SCH_COMPONENT::Print( wxDC* aDC, const wxPoint& aOffset ) { auto opts = PART_DRAW_OPTIONS::Default(); opts.transform = m_transform; @@ -550,29 +550,28 @@ void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOff if( PART_SPTR part = m_part.lock() ) { - part->Draw( aPanel, aDC, m_Pos + aOffset, m_unit, m_convert, opts ); + part->Print( aDC, m_Pos + aOffset, m_unit, m_convert, opts ); } else // Use dummy() part if the actual cannot be found. { - dummy()->Draw( aPanel, aDC, m_Pos + aOffset, 0, 0, opts ); + dummy()->Print( aDC, m_Pos + aOffset, 0, 0, opts ); } SCH_FIELD* field = GetField( REFERENCE ); if( field->IsVisible() ) - field->Draw( aPanel, aDC, aOffset ); + field->Print(aDC, aOffset ); for( int ii = VALUE; ii < GetFieldCount(); ii++ ) { field = GetField( ii ); - field->Draw( aPanel, aDC, aOffset ); + field->Print( aDC, aOffset ); } } -void SCH_COMPONENT::AddHierarchicalReference( const wxString& aPath, - const wxString& aRef, - int aMulti ) +void SCH_COMPONENT::AddHierarchicalReference( const wxString& aPath, const wxString& aRef, + int aMulti ) { wxString h_path, h_ref; wxStringTokenizer tokenizer; diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index 971b6beb01..1c0eea1b50 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -466,14 +466,13 @@ public: SCH_PINS& GetPins() { return m_pins; } /** - * Draw a component + * Print a component * - * @param aPanel is the panel to use (can be null) mainly used for clipping purposes. * @param aDC is the device context (can be null) * @param aOffset is the drawing offset (usually wxPoint(0,0), * but can be different when moving an object) */ - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; + void Print( wxDC* aDC, const wxPoint& aOffset ) override; void SwapData( SCH_ITEM* aItem ) override; diff --git a/eeschema/sch_draw_panel.cpp b/eeschema/sch_draw_panel.cpp index f38d6b42d3..5175d264d3 100644 --- a/eeschema/sch_draw_panel.cpp +++ b/eeschema/sch_draw_panel.cpp @@ -44,12 +44,6 @@ using namespace std::placeholders; -// Events used by EDA_DRAW_PANEL -BEGIN_EVENT_TABLE( SCH_DRAW_PANEL, wxScrolledCanvas ) - EVT_CHAR_HOOK( SCH_DRAW_PANEL::OnCharHook ) - EVT_PAINT( SCH_DRAW_PANEL::onPaint ) -END_EVENT_TABLE() - SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId, const wxPoint& aPosition, const wxSize& aSize, KIGFX::GAL_DISPLAY_OPTIONS& aOptions, GAL_TYPE aGalType ) : @@ -57,7 +51,6 @@ SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId, m_parent( aParentWindow ) { m_defaultCursor = m_currentCursor = wxCURSOR_ARROW; - m_showCrossHair = true; m_view = new KIGFX::SCH_VIEW( true, dynamic_cast( aParentWindow ) ); m_view->SetGAL( m_gal ); @@ -83,11 +76,6 @@ SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId, // on updated viewport data. m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this ); - Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( SCH_DRAW_PANEL::OnCharHook ), NULL, this ); - - m_cursorLevel = 0; - m_PrintIsMirrored = false; - m_viewControls->SetSnapping( true ); SetEvtHandlerEnabled( true ); @@ -197,12 +185,6 @@ void SCH_DRAW_PANEL::Refresh( bool aEraseBackground, const wxRect* aRect ) } -void SCH_DRAW_PANEL::OnCharHook( wxKeyEvent& event ) -{ - event.Skip(); -} - - void SCH_DRAW_PANEL::onPaint( wxPaintEvent& aEvent ) { if( !m_gal->IsInitialized() || !m_gal->IsVisible() ) diff --git a/eeschema/sch_draw_panel.h b/eeschema/sch_draw_panel.h index 41036fd624..b127841283 100644 --- a/eeschema/sch_draw_panel.h +++ b/eeschema/sch_draw_panel.h @@ -41,7 +41,6 @@ public: void DisplaySheet( const SCH_SCREEN *aScreen ); bool SwitchBackend( GAL_TYPE aGalType ) override; - void OnCharHook( wxKeyEvent& event ); BASE_SCREEN* GetScreen() override; virtual EDA_DRAW_FRAME* GetParent() const override; @@ -60,8 +59,6 @@ protected: void setDefaultLayerOrder(); ///> Reassigns layer order to the initial settings. void setDefaultLayerDeps(); ///> Sets rendering targets & dependencies for layers. - - DECLARE_EVENT_TABLE() }; #endif diff --git a/eeschema/sch_eagle_plugin.cpp b/eeschema/sch_eagle_plugin.cpp index 7e5f533de4..de8eb2a432 100644 --- a/eeschema/sch_eagle_plugin.cpp +++ b/eeschema/sch_eagle_plugin.cpp @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 60e446a8a8..b628ed4304 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1083,8 +1083,8 @@ void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMod wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() ); GRSetDrawMode( aDC, GR_DEFAULT_DRAWMODE ); - GetScreen()->Draw( m_canvas, aDC ); - DrawWorkSheet( aDC, GetScreen(), GetDefaultLineThickness(), IU_PER_MILS, fileName ); + GetScreen()->Print( aDC ); + PrintWorkSheet( aDC, GetScreen(), GetDefaultLineThickness(), IU_PER_MILS, fileName ); } diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 436a888f52..e955088940 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -22,11 +22,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file sch_field.cpp - * @brief Implementation of the SCH_FIELD class. - */ - /* Fields are texts attached to a component, having a special meaning * Fields 0 and 1 are very important: reference and value * Field 2 is used as default footprint name. @@ -39,7 +34,7 @@ #include #include #include -#include +#include #include #include #include @@ -150,7 +145,7 @@ int SCH_FIELD::GetPenSize() const } -void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) +void SCH_FIELD::Print( wxDC* aDC, const wxPoint& aOffset ) { int orient; COLOR4D color; @@ -206,10 +201,8 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset else color = GetLayerColor( LAYER_FIELDS ); - EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL; - DrawGraphicText( clipbox, aDC, textpos, color, GetFullyQualifiedText(), orient, GetTextSize(), - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, lineWidth, IsItalic(), - IsBold() ); + GRText( aDC, textpos, color, GetFullyQualifiedText(), orient, GetTextSize(), + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, lineWidth, IsItalic(), IsBold() ); } @@ -378,8 +371,7 @@ bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData ) SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent; - wxCHECK_MSG( component != NULL, false, - wxT( "No symbol associated with field" ) + text ); + wxCHECK_MSG( component != NULL, false, wxT( "No symbol associated with field" ) + text ); text = component->GetRef( (SCH_SHEET_PATH*) aAuxData ); @@ -540,8 +532,7 @@ void SCH_FIELD::SetPosition( const wxPoint& aPosition ) wxPoint SCH_FIELD::GetPosition() const { SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent(); - - wxPoint pos = GetTextPos() - component->GetPosition(); + wxPoint pos = GetTextPos() - component->GetPosition(); return component->GetTransform().TransformCoordinate( pos ) + component->GetPosition(); } diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h index e43d39aa75..08c4456272 100644 --- a/eeschema/sch_field.h +++ b/eeschema/sch_field.h @@ -149,7 +149,7 @@ public: int GetPenSize() const override; - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; + void Print( wxDC* aDC, const wxPoint& aOffset ) override; void Move( const wxPoint& aMoveVector ) override { diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index 1627e3393e..1810f83953 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -41,7 +41,7 @@ class wxFindReplaceData; class PLOTTER; class NETLIST_OBJECT; class NETLIST_OBJECT_LIST; -class EDA_DRAW_PANEL; + enum DANGLING_END_T { UNKNOWN = 0, @@ -212,14 +212,13 @@ public: virtual int GetPenSize() const { return 0; } /** - * Function Draw - * Draw a schematic item. Each schematic item should have its own method - * @param aPanel DrawPanel to use (can be null) mainly used for clipping purposes. + * Function Print + * Print a schematic item. Each schematic item should have its own method * @param aDC Device Context (can be null) * @param aOffset drawing Offset (usually wxPoint(0,0), * but can be different when moving an object) */ - virtual void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) = 0; + virtual void Print( wxDC* aDC, const wxPoint& aOffset ) = 0; /** * Function Move diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index bbc9d99a6c..b2e4e58a35 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -92,12 +92,12 @@ const EDA_RECT SCH_JUNCTION::GetBoundingBox() const } -void SCH_JUNCTION::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) +void SCH_JUNCTION::Print( wxDC* aDC, const wxPoint& aOffset ) { auto conn = Connection( *g_CurrentSheet ); COLOR4D color = GetLayerColor( ( conn && conn->IsBus() ) ? LAYER_BUS : m_Layer ); - GRFilledCircle( aPanel->GetClipBox(), aDC, m_pos.x + aOffset.x, m_pos.y + aOffset.y, + GRFilledCircle( nullptr, aDC, m_pos.x + aOffset.x, m_pos.y + aOffset.y, ( GetEffectiveSymbolSize() / 2 ), 0, color, color ); } diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index 4d0f9af3d4..70a6f86fc6 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -59,7 +59,7 @@ public: const EDA_RECT GetBoundingBox() const override; - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; + void Print( wxDC* aDC, const wxPoint& aOffset ) override; void Move( const wxPoint& aMoveVector ) override { diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index 81ee24a54d..c92fd3f8c8 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 8aa792df9b..ef59e719c2 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -319,14 +319,14 @@ int SCH_LINE::GetPenSize() const } -void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset ) +void SCH_LINE::Print( wxDC* DC, const wxPoint& offset ) { COLOR4D color = ( m_color != COLOR4D::UNSPECIFIED ) ? m_color : GetLayerColor( m_Layer ); int width = GetPenSize(); wxPoint start = m_start; wxPoint end = m_end; - GRLine( panel->GetClipBox(), DC, start.x, start.y, end.x, end.y, width, color, + GRLine( nullptr, DC, start.x, start.y, end.x, end.y, width, color, getwxPenStyle( (PlotDashType) GetLineStyle() ) ); } diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index 44a3c6796d..c6eec2d981 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -128,7 +128,7 @@ public: */ double GetLength() const; - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; + void Print( wxDC* aDC, const wxPoint& aOffset ) override; int GetPenSize() const override; diff --git a/eeschema/sch_marker.cpp b/eeschema/sch_marker.cpp index dbb59eb3d7..62532c93e8 100644 --- a/eeschema/sch_marker.cpp +++ b/eeschema/sch_marker.cpp @@ -72,7 +72,7 @@ void SCH_MARKER::Show( int nestLevel, std::ostream& os ) const #endif -void SCH_MARKER::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) +void SCH_MARKER::Print( wxDC* aDC, const wxPoint& aOffset ) { COLOR4D tmp = m_Color; @@ -82,7 +82,7 @@ void SCH_MARKER::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset GetLayerColor( LAYER_ERC_ERR ) : GetLayerColor( LAYER_ERC_WARN ); } - DrawMarker( aPanel, aDC, aOffset ); + PrintMarker( aDC, aOffset ); m_Color = tmp; } diff --git a/eeschema/sch_marker.h b/eeschema/sch_marker.h index 5be5f27569..7cf993ee03 100644 --- a/eeschema/sch_marker.h +++ b/eeschema/sch_marker.h @@ -47,7 +47,7 @@ public: void ViewGetLayers( int aLayers[], int& aCount ) const override; - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; + void Print( wxDC* aDC, const wxPoint& aOffset ) override; void Plot( PLOTTER* aPlotter ) override { diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp index d4eab5573b..6709a3e48e 100644 --- a/eeschema/sch_no_connect.cpp +++ b/eeschema/sch_no_connect.cpp @@ -99,19 +99,17 @@ int SCH_NO_CONNECT::GetPenSize() const } -void SCH_NO_CONNECT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) +void SCH_NO_CONNECT::Print( wxDC* aDC, const wxPoint& aOffset ) { - int pX, pY; int half = GetSize() / 2; int width = GetDefaultLineThickness(); - - pX = m_pos.x + aOffset.x; - pY = m_pos.y + aOffset.y; + int pX = m_pos.x + aOffset.x; + int pY = m_pos.y + aOffset.y; COLOR4D color = GetLayerColor( LAYER_NOCONNECT ); - GRLine( aPanel->GetClipBox(), aDC, pX - half, pY - half, pX + half, pY + half, width, color ); - GRLine( aPanel->GetClipBox(), aDC, pX + half, pY - half, pX - half, pY + half, width, color ); + GRLine( nullptr, aDC, pX - half, pY - half, pX + half, pY + half, width, color ); + GRLine( nullptr, aDC, pX + half, pY - half, pX - half, pY + half, width, color ); } diff --git a/eeschema/sch_no_connect.h b/eeschema/sch_no_connect.h index 996a130c10..d2a8cddca4 100644 --- a/eeschema/sch_no_connect.h +++ b/eeschema/sch_no_connect.h @@ -62,7 +62,7 @@ public: void ViewGetLayers( int aLayers[], int& aCount ) const override; - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; + void Print( wxDC* aDC, const wxPoint& aOffset ) override; void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override; diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 65a7ca1151..0c64239419 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/eeschema/sch_pin.h b/eeschema/sch_pin.h index 2e8edc5301..33faf048f1 100644 --- a/eeschema/sch_pin.h +++ b/eeschema/sch_pin.h @@ -63,7 +63,7 @@ public: wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; void GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) override; - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override {} + void Print( wxDC* aDC, const wxPoint& aOffset ) override {} void Move( const wxPoint& aMoveVector ) override {} diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 45e8342709..dd6844b1d1 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include @@ -524,12 +524,8 @@ void SCH_SCREEN::UpdateSymbolLinks( bool aForce ) } -void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ) +void SCH_SCREEN::Print( wxDC* aDC ) { - /* note: SCH_SCREEN::Draw is useful only for schematic. - * library editor and library viewer do not use m_drawList, and therefore - * their SCH_SCREEN::Draw() draws nothing - */ std::vector< SCH_ITEM* > junctions; // Ensure links are up to date, even if a library was reloaded for some reason: @@ -543,30 +539,11 @@ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ) if( item->Type() == SCH_JUNCTION_T ) junctions.push_back( item ); else - // uncomment line below when there is a virtual EDA_ITEM::GetBoundingBox() - // if( panel->GetClipBox().Intersects( item->GetBoundingBox() ) ) - item->Draw( aCanvas, aDC, wxPoint( 0, 0 ) ); - - // TODO(JE) Remove debugging code -#ifdef DEBUG - - auto conn = item->Connection( *g_CurrentSheet ); - - if( conn ) - { - auto pos = item->GetBoundingBox().Centre(); - int sz = Mils2iu( 15 ); - auto label = conn->Name( true ); - - auto text = SCH_TEXT( pos, label, SCH_TEXT_T ); - text.SetTextSize( wxSize( sz, sz ) ); - text.Draw( aCanvas, aDC, wxPoint( 10, 10 ) ); - } -#endif + item->Print( aDC, wxPoint( 0, 0 ) ); } for( auto item : junctions ) - item->Draw( aCanvas, aDC, wxPoint( 0, 0 ) ); + item->Print( aDC, wxPoint( 0, 0 ) ); } diff --git a/eeschema/sch_screen.h b/eeschema/sch_screen.h index 20dd87a799..582448d4aa 100644 --- a/eeschema/sch_screen.h +++ b/eeschema/sch_screen.h @@ -222,15 +222,14 @@ public: void UpdateSymbolLinks( bool aForce = false ); /** - * Draw all the items in the screen to \a aCanvas. + * Print all the items in the screen to \a aDC. * * @note This function is useful only for schematic. The library editor and library viewer * do not use a draw list and therefore draws nothing. * - * @param aCanvas The canvas item to draw on. * @param aDC The device context to draw on. */ - void Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ); + void Print( wxDC* aDC ); /** * Plot all the schematic objects to \a aPlotter. diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 7c3027bf52..e1704b6527 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include #include @@ -433,7 +433,7 @@ void SCH_SHEET::ViewGetLayers( int aLayers[], int& aCount ) const } -void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) +void SCH_SHEET::Print( wxDC* aDC, const wxPoint& aOffset ) { wxString Text; int name_orientation; @@ -442,10 +442,9 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset int lineWidth = GetPenSize(); int textWidth; wxSize textSize; - EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL; COLOR4D color = GetLayerColor( m_Layer ); - GRRect( clipbox, aDC, pos.x, pos.y, pos.x + m_size.x, pos.y + m_size.y, lineWidth, color ); + GRRect( nullptr, aDC, pos.x, pos.y, pos.x + m_size.x, pos.y + m_size.y, lineWidth, color ); pos_sheetname = GetSheetNamePosition() + aOffset; pos_filename = GetFileNamePosition() + aOffset; @@ -459,21 +458,19 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset Text = wxT( "Sheet: " ) + m_name; textSize = wxSize( m_sheetNameSize, m_sheetNameSize ); textWidth = Clamp_Text_PenSize( lineWidth, textSize, false ); - DrawGraphicText( clipbox, aDC, pos_sheetname, GetLayerColor( LAYER_SHEETNAME ), Text, - name_orientation, textSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, - textWidth, false, false ); + GRText( aDC, pos_sheetname, GetLayerColor( LAYER_SHEETNAME ), Text, name_orientation, + textSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, textWidth, false, false ); /* Draw text : FileName */ Text = wxT( "File: " ) + m_fileName; textSize = wxSize( m_fileNameSize, m_fileNameSize ); textWidth = Clamp_Text_PenSize( lineWidth, textSize, false ); - DrawGraphicText( clipbox, aDC, pos_filename, GetLayerColor( LAYER_SHEETFILENAME ), Text, - name_orientation, textSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, - textWidth, false, false ); + GRText( aDC, pos_filename, GetLayerColor( LAYER_SHEETFILENAME ), Text, name_orientation, + textSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, textWidth, false, false ); /* Draw text : SheetLabel */ for( SCH_SHEET_PIN& sheetPin : m_pins ) - sheetPin.Draw( aPanel, aDC, aOffset ); + sheetPin.Print( aDC, aOffset ); } diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 145277ae76..7a5635f0aa 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -106,7 +106,7 @@ public: */ bool IsMovableFromAnchorPoint() override { return true; } - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; + void Print( wxDC* aDC, const wxPoint& aOffset ) override; /** * Calculate the graphic shape (a polygon) associated to the text. @@ -395,7 +395,7 @@ public: int GetPenSize() const override; - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; + void Print( wxDC* aDC, const wxPoint& aOffset ) override; EDA_RECT const GetBoundingBox() const override; diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp index e8f681e2b9..5b34fa149f 100644 --- a/eeschema/sch_sheet_pin.cpp +++ b/eeschema/sch_sheet_pin.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -65,11 +65,10 @@ EDA_ITEM* SCH_SHEET_PIN::Clone() const } -void SCH_SHEET_PIN::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) +void SCH_SHEET_PIN::Print( wxDC* aDC, const wxPoint& aOffset ) { - // The icon selection is handle by the virtual method CreateGraphicShape - // called by ::Draw - SCH_HIERLABEL::Draw( aPanel, aDC, aOffset ); + // The icon selection is handle by the virtual method CreateGraphicShape called by ::Print + SCH_HIERLABEL::Print( aDC, aOffset ); } diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 55dc2a6821..c25205a443 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -302,11 +302,10 @@ int SCH_TEXT::GetPenSize() const } -void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset ) +void SCH_TEXT::Print( wxDC* DC, const wxPoint& aOffset ) { COLOR4D color = GetLayerColor( m_Layer ); int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); - EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() ); @@ -315,7 +314,7 @@ void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset ) int savedWidth = GetThickness(); SetThickness( linewidth ); // Set the minimum width - EDA_TEXT::Draw( clipbox, DC, text_offset, color, GR_DEFAULT_DRAWMODE ); + EDA_TEXT::Print( DC, text_offset, color ); SetThickness( savedWidth ); } @@ -484,9 +483,7 @@ void SCH_TEXT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, // If a bus connects to label if( Connection( *aSheetPath )->IsBusLabel( m_Text ) ) - { item->ConvertBusToNetListItems( aNetListItems ); - } } @@ -512,7 +509,7 @@ bool SCH_TEXT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) void SCH_TEXT::Plot( PLOTTER* aPlotter ) { - static std::vector Poly; + static std::vector Poly; COLOR4D color = GetLayerColor( GetLayer() ); int tmp = GetThickness(); int thickness = GetPenSize(); @@ -536,9 +533,8 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter ) { wxPoint textpos = positions[ii] + GetSchematicTextOffset(); wxString& txt = strings_list.Item( ii ); - aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(), - GetHorizJustify(), GetVertJustify(), - thickness, IsItalic(), IsBold() ); + aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(), GetHorizJustify(), + GetVertJustify(), thickness, IsItalic(), IsBold() ); } } else @@ -546,8 +542,7 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter ) wxPoint textpos = GetTextPos() + GetSchematicTextOffset(); aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(), - GetHorizJustify(), GetVertJustify(), - thickness, IsItalic(), IsBold() ); + GetHorizJustify(), GetVertJustify(), thickness, IsItalic(), IsBold() ); } // Draw graphic symbol for global or hierarchical labels @@ -568,11 +563,11 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) switch( Type() ) { - case SCH_TEXT_T: msg = _( "Graphic Text" ); break; - case SCH_LABEL_T: msg = _( "Label" ); break; - case SCH_GLOBAL_LABEL_T: msg = _( "Global Label" ); break; - case SCH_HIER_LABEL_T: msg = _( "Hierarchical Label" ); break; - case SCH_SHEET_PIN_T: msg = _( "Hierarchical Sheet Pin" ); break; + case SCH_TEXT_T: msg = _( "Graphic Text" ); break; + case SCH_LABEL_T: msg = _( "Label" ); break; + case SCH_GLOBAL_LABEL_T: msg = _( "Global Label" ); break; + case SCH_HIER_LABEL_T: msg = _( "Hierarchical Label" ); break; + case SCH_SHEET_PIN_T: msg = _( "Hierarchical Sheet Pin" ); break; default: return; } @@ -600,11 +595,8 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Style" ), textStyle[style], BROWN ) ); - - // Display electricat type if it is relevant - if( (Type() == SCH_GLOBAL_LABEL_T) || - (Type() == SCH_HIER_LABEL_T ) || - (Type() == SCH_SHEET_PIN_T ) ) + // Display electrical type if it is relevant + if( Type() == SCH_GLOBAL_LABEL_T || Type() == SCH_HIER_LABEL_T || Type() == SCH_SHEET_PIN_T ) { switch( GetShape() ) { @@ -624,11 +616,8 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Size" ), msg, RED ) ); #if defined(DEBUG) - if( auto conn = Connection( *g_CurrentSheet ) ) - { conn->AppendDebugInfoToMsgPanel( aList ); - } msg.Printf( "%p", this ); aList.push_back( MSG_PANEL_ITEM( "Object Address", msg, RED ) ); @@ -796,7 +785,7 @@ void SCH_GLOBALLABEL::SetLabelSpinStyle( int aSpinStyle ) } -void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset ) +void SCH_GLOBALLABEL::Print( wxDC* DC, const wxPoint& aOffset ) { static std::vector Poly; COLOR4D color = GetLayerColor( m_Layer ); @@ -809,13 +798,12 @@ void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOff int save_width = GetThickness(); SetThickness( linewidth ); - EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; - EDA_TEXT::Draw( clipbox, DC, text_offset, color, GR_DEFAULT_DRAWMODE ); + EDA_TEXT::Print( DC, text_offset, color ); SetThickness( save_width ); // restore initial value CreateGraphicShape( Poly, GetTextPos() + aOffset ); - GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color ); + GRPoly( nullptr, DC, Poly.size(), &Poly[0], 0, linewidth, color, color ); } @@ -1036,13 +1024,13 @@ void SCH_HIERLABEL::SetLabelSpinStyle( int aSpinStyle ) } -void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset ) +void SCH_HIERLABEL::Print( wxDC* DC, const wxPoint& offset ) { static std::vector Poly; - auto conn = Connection( *g_CurrentSheet ); - COLOR4D color = GetLayerColor( ( conn && conn->IsBus() ) ? LAYER_BUS : m_Layer ); - int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); - EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; + + auto conn = Connection( *g_CurrentSheet ); + COLOR4D color = GetLayerColor( ( conn && conn->IsBus() ) ? LAYER_BUS : m_Layer ); + int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() ); @@ -1050,12 +1038,12 @@ void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset SetThickness( linewidth ); wxPoint text_offset = offset + GetSchematicTextOffset(); - EDA_TEXT::Draw( clipbox, DC, text_offset, color, GR_DEFAULT_DRAWMODE ); + EDA_TEXT::Print( DC, text_offset, color ); SetThickness( save_width ); // restore initial value CreateGraphicShape( Poly, GetTextPos() + offset ); - GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color ); + GRPoly( nullptr, DC, Poly.size(), &Poly[0], 0, linewidth, color, color ); } diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index c804416f07..6d049fac7a 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -130,7 +130,7 @@ public: */ virtual wxPoint GetSchematicTextOffset() const; - void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset ) override; + void Print( wxDC* DC, const wxPoint& offset ) override; /** * Calculate the graphic shape (a polygon) associated to the text. @@ -251,7 +251,7 @@ public: ~SCH_GLOBALLABEL() { } - void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset ) override; + void Print( wxDC* DC, const wxPoint& offset ) override; wxString GetClass() const override { @@ -296,7 +296,7 @@ public: ~SCH_HIERLABEL() { } - void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset ) override; + void Print( wxDC* DC, const wxPoint& offset ) override; wxString GetClass() const override { diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 755953e461..8e4a846a0c 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -448,19 +448,15 @@ void SCH_EDIT_FRAME::DrawCurrentSheetToClipboard( wxCommandEvent& aEvt ) wxBitmap image( dcsize ); dc.SelectObject( image ); - EDA_RECT tmp = *GetCanvas()->GetClipBox(); GRResetPenAndBrush( &dc ); GRForceBlackPen( false ); screen->m_IsPrinting = true; dc.SetUserScale( scale, scale ); - GetCanvas()->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ) ); - dc.Clear(); const LSET allLayersMask = LSET().set(); PrintPage( &dc, allLayersMask, false ); screen->m_IsPrinting = false; - GetCanvas()->SetClipBox( tmp ); if( wxTheClipboard->Open() ) { diff --git a/gerbview/events_called_functions.cpp b/gerbview/events_called_functions.cpp index ddcb8209e8..b933533f2e 100644 --- a/gerbview/events_called_functions.cpp +++ b/gerbview/events_called_functions.cpp @@ -34,7 +34,6 @@ #include #include -#include #include #include #include diff --git a/gerbview/gbr_layout.cpp b/gerbview/gbr_layout.cpp index ccb4d176e2..03dbbc373c 100644 --- a/gerbview/gbr_layout.cpp +++ b/gerbview/gbr_layout.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include #include @@ -84,317 +84,6 @@ EDA_RECT GBR_LAYOUT::ComputeBoundingBox() const } -// Redraw All GerbView layers, using a buffered mode or not -void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, - const wxPoint& aOffset, GBR_DISPLAY_OPTIONS* aDisplayOptions ) -{ - GERBVIEW_FRAME* gerbFrame = (GERBVIEW_FRAME*) aPanel->GetParent(); - - // Collect the highlight selections - wxString cmpHighlight; - - if( gerbFrame->m_SelComponentBox->GetSelection() > 0 ) - cmpHighlight = gerbFrame->m_SelComponentBox->GetStringSelection(); - - wxString netHighlight; - - if( gerbFrame->m_SelNetnameBox->GetSelection() > 0 ) - netHighlight = gerbFrame->m_SelNetnameBox->GetStringSelection(); - - wxString aperAttrHighlight = gerbFrame->m_SelAperAttributesBox->GetStringSelection(); - - if( gerbFrame->m_SelAperAttributesBox->GetSelection() > 0 ) - aperAttrHighlight = gerbFrame->m_SelAperAttributesBox->GetStringSelection(); - - - // Because Images can be negative (i.e with background filled in color) items are drawn - // graphic layer per graphic layer, after the background is filled - // to a temporary bitmap - // at least when aDrawMode = GR_COPY or aDrawMode = GR_OR - // If aDrawMode = UNSPECIFIED_DRAWMODE, items are drawn to the main screen, and therefore - // artifacts can happen with negative items or negative images - - int bitmapWidth, bitmapHeight; - wxDC* plotDC = aDC; - - aPanel->GetClientSize( &bitmapWidth, &bitmapHeight ); - - wxBitmap* layerBitmap = NULL; - wxBitmap* screenBitmap = NULL; - wxMemoryDC layerDC; // used sequentially for each gerber layer - wxMemoryDC screenDC; - - // When each image must be drawn using GR_OR (transparency mode) - // or GR_COPY (stacked mode) we must use a temporary bitmap - // to draw gerber images. - // this is due to negative objects (drawn using background color) that create artifacts - // on other images when drawn on screen - bool useBufferBitmap = false; - -#ifndef __WXMAC__ - // Can't work with MAC - // Don't try this with retina display - if( (aDrawMode == GR_COPY) || ( aDrawMode == GR_OR ) ) - useBufferBitmap = true; -#endif - - // these parameters are saved here, because they are modified - // and restored later - EDA_RECT drawBox = *aPanel->GetClipBox(); - double scale; - aDC->GetUserScale(&scale, &scale); - wxPoint dev_org = aDC->GetDeviceOrigin(); - wxPoint logical_org = aDC->GetLogicalOrigin( ); - - COLOR4D bgColor = aDisplayOptions->m_BgDrawColor; - wxBrush bgBrush( bgColor.ToColour(), wxBRUSHSTYLE_SOLID ); - - if( useBufferBitmap ) - { - layerBitmap = new wxBitmap( bitmapWidth, bitmapHeight ); - screenBitmap = new wxBitmap( bitmapWidth, bitmapHeight ); - layerDC.SelectObject( *layerBitmap ); - aPanel->DoPrepareDC( layerDC ); - aPanel->SetClipBox( drawBox ); - layerDC.SetBackground( bgBrush ); - layerDC.SetBackgroundMode( wxSOLID ); - layerDC.Clear(); - - screenDC.SelectObject( *screenBitmap ); - screenDC.SetBackground( bgBrush ); - screenDC.SetBackgroundMode( wxSOLID ); - screenDC.Clear(); - - plotDC = &layerDC; - } - - bool doBlit = false; // this flag requests an image transfer to actual screen when true. - - bool end = false; - - // Draw graphic layers from bottom to top, and the active layer is on the top of others. - // In non transparent modes, the last layer drawn masks others layers - for( int layer = GERBER_DRAWLAYERS_COUNT-1; !end; --layer ) - { - int active_layer = gerbFrame->GetActiveLayer(); - - if( layer == active_layer ) // active layer will be drawn after other layers - continue; - - if( layer < 0 ) // last loop: draw active layer - { - end = true; - layer = active_layer; - } - - GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer ); - - if( gerber == NULL ) // Graphic layer not yet used - continue; - - if( !gerbFrame->IsLayerVisible( layer ) ) - continue; - - gerber->m_PositiveDrawColor = gerbFrame->GetLayerColor( GERBER_DRAW_LAYER( layer ) ); - - // Force black and white draw mode on request: - if( aDisplayOptions->m_ForceBlackAndWhite ) - gerber->m_PositiveDrawColor = ( aDisplayOptions->m_BgDrawColor == BLACK ) ? WHITE : BLACK; - - if( useBufferBitmap ) - { - // Draw each layer into a bitmap first. Negative Gerber - // layers are drawn in background color. - if( gerber->HasNegativeItems() && doBlit ) - { - // Set Device origin, logical origin and scale to default values - // This is needed by Blit function when using a mask. - // Beside, for Blit call, both layerDC and screenDc must have the same settings - layerDC.SetDeviceOrigin(0,0); - layerDC.SetLogicalOrigin( 0, 0 ); - layerDC.SetUserScale( 1, 1 ); - - if( aDrawMode == GR_COPY ) - { - // Use the layer bitmap itself as a mask when blitting. The bitmap - // cannot be referenced by a device context when setting the mask. - layerDC.SelectObject( wxNullBitmap ); - layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor.ToColour() ) ); - layerDC.SelectObject( *layerBitmap ); - screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxCOPY, true ); - } - else if( aDrawMode == GR_OR ) - { - // On Linux with a large screen, this version is much faster and without - // flicker, but gives a Pcbnew look where layer colors blend together. - // Plus it works only because the background color is black. But it may - // be more usable for some. The difference is due in part because of - // the cpu cycles needed to create the monochromatic bitmap above, and - // the extra time needed to do bit indexing into the monochromatic bitmap - // on the blit above. - screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxOR ); - } - // Restore actual values and clear bitmap for next drawing - layerDC.SetDeviceOrigin( dev_org.x, dev_org.y ); - layerDC.SetLogicalOrigin( logical_org.x, logical_org.y ); - layerDC.SetUserScale( scale, scale ); - layerDC.SetBackground( bgBrush ); - layerDC.SetBackgroundMode( wxSOLID ); - layerDC.Clear(); - - doBlit = false; - } - - } - - if( gerber->m_ImageNegative ) - { - // Draw background negative (i.e. in graphic layer color) for negative images. - COLOR4D neg_color = gerber->GetPositiveDrawColor(); - - GRSetDrawMode( &layerDC, GR_COPY ); - GRFilledRect( &drawBox, plotDC, drawBox.GetX(), drawBox.GetY(), - drawBox.GetRight(), drawBox.GetBottom(), - 0, neg_color, neg_color ); - - GRSetDrawMode( plotDC, GR_COPY ); - doBlit = true; - } - - int dcode_highlight = 0; - - if( layer == gerbFrame->GetActiveLayer() ) - dcode_highlight = gerber->m_Selected_Tool; - - GR_DRAWMODE layerdrawMode = GR_COPY; - - if( aDrawMode == GR_OR && !gerber->HasNegativeItems() ) - layerdrawMode = GR_OR; - - // Now we can draw the current layer to the bitmap buffer - // When needed, the previous bitmap is already copied to the screen buffer. - for( GERBER_DRAW_ITEM* item = gerber->GetItemsList(); item; item = item->Next() ) - { - if( item->GetLayer() != layer ) - continue; - - GR_DRAWMODE drawMode = layerdrawMode; - - if( dcode_highlight && dcode_highlight == item->m_DCode ) - DrawModeAddHighlight( &drawMode); - - if( !aperAttrHighlight.IsEmpty() && item->GetDcodeDescr() && - item->GetDcodeDescr()->m_AperFunction == aperAttrHighlight ) - DrawModeAddHighlight( &drawMode); - - if( !cmpHighlight.IsEmpty() && - cmpHighlight == item->GetNetAttributes().m_Cmpref ) - DrawModeAddHighlight( &drawMode); - - if( !netHighlight.IsEmpty() && - netHighlight == item->GetNetAttributes().m_Netname ) - DrawModeAddHighlight( &drawMode); - - item->Draw( aPanel, plotDC, drawMode, wxPoint(0,0), aDisplayOptions ); - doBlit = true; - } - } - - if( doBlit && useBufferBitmap ) // Blit is used only if aDrawMode >= 0 - { - // For this Blit call, layerDC and screenDC must have the same settings - // So we set device origin, logical origin and scale to default values - // in layerDC - layerDC.SetDeviceOrigin(0,0); - layerDC.SetLogicalOrigin( 0, 0 ); - layerDC.SetUserScale( 1, 1 ); - - // this is the last transfer to screenDC. If there are no negative items, this is - // the only one - if( aDrawMode == GR_COPY ) - { - layerDC.SelectObject( wxNullBitmap ); - layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor.ToColour() ) ); - layerDC.SelectObject( *layerBitmap ); - screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxCOPY, true ); - - } - else if( aDrawMode == GR_OR ) - { - screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxOR ); - } - } - - if( useBufferBitmap ) - { - // For this Blit call, aDC and screenDC must have the same settings - // So we set device origin, logical origin and scale to default values - // in aDC - aDC->SetDeviceOrigin( 0, 0); - aDC->SetLogicalOrigin( 0, 0 ); - aDC->SetUserScale( 1, 1 ); - - aDC->Blit( 0, 0, bitmapWidth, bitmapHeight, &screenDC, 0, 0, wxCOPY ); - - // Restore aDC values - aDC->SetDeviceOrigin(dev_org.x, dev_org.y); - aDC->SetLogicalOrigin( logical_org.x, logical_org.y ); - aDC->SetUserScale( scale, scale ); - - layerDC.SelectObject( wxNullBitmap ); - screenDC.SelectObject( wxNullBitmap ); - delete layerBitmap; - delete screenBitmap; - } -} - - -void GBR_LAYOUT::DrawItemsDCodeID( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - GR_DRAWMODE aDrawMode, COLOR4D aDrawColor ) -{ - wxString Line; - - GRSetDrawMode( aDC, aDrawMode ); - GERBVIEW_FRAME* gerbFrame = static_cast( aPanel->GetParent() ); - - for( unsigned layer = 0; layer < GetImagesList()->ImagesMaxCount(); ++layer ) - { - GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer ); - - if( gerber == NULL ) // Graphic layer not yet used - continue; - - if( !gerbFrame->IsLayerVisible( layer ) ) - continue; - - for( GERBER_DRAW_ITEM* item = gerber->GetItemsList(); item != NULL; item = item->Next() ) - { - wxPoint pos; - int size; - double orient; - - if( ! item->GetTextD_CodePrms( size, pos, orient ) ) - continue; - - Line.Printf( wxT( "D%d" ), item->m_DCode ); - - // Avoid to draw text, if it is too small (size in pixel < 5 pixels) - // to be readable: - int size_pixel = aDC->LogicalToDeviceXRel( size ); - const int threshold = 5; - - if( size_pixel >= threshold ) - { - DrawGraphicText( aPanel->GetClipBox(), aDC, pos, aDrawColor, Line, - orient, wxSize( size, size ), - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, - 0, false, false ); - } - } - } -} - - SEARCH_RESULT GBR_LAYOUT::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) { KICAD_T stype; diff --git a/gerbview/gbr_layout.h b/gerbview/gbr_layout.h index 5bfc8eaf45..dfdb80e6a4 100644 --- a/gerbview/gbr_layout.h +++ b/gerbview/gbr_layout.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012-2014 Jean-Pierre Charras jp.charras at wanadoo.fr - * Copyright (C) 1992-2014 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2019 KiCad Developers, see change_log.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 @@ -58,7 +58,6 @@ private: wxPoint m_originAxisPosition; public: - GBR_LAYOUT(); ~GBR_LAYOUT(); @@ -71,25 +70,11 @@ public: // which handles the list of gerber files (and drill files) images loaded GERBER_FILE_IMAGE_LIST* GetImagesList() const; - const wxPoint& GetAuxOrigin() const - { - return m_originAxisPosition; - } + const wxPoint& GetAuxOrigin() const { return m_originAxisPosition; } + void SetAuxOrigin( const wxPoint& aPosition ) { m_originAxisPosition = aPosition; } - void SetAuxOrigin( const wxPoint& aPosition ) - { - m_originAxisPosition = aPosition; - } - - TITLE_BLOCK& GetTitleBlock() - { - return m_titles; - } - - void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) - { - m_titles = aTitleBlock; - } + TITLE_BLOCK& GetTitleBlock() { return m_titles; } + void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; } /** * Function ComputeBoundingBox @@ -108,39 +93,11 @@ public: void SetBoundingBox( const EDA_RECT& aBox ) { m_BoundingBox = aBox; } - /** - * Function Draw. - * Redraw the CLASS_GBR_LAYOUT items but not cursors, axis or grid. - * @param aPanel = the draw canvas - * @param aDC = the current device context - * @param aDrawMode = GR_COPY, GR_OR ... (not always used) - * @param aOffset = an draw offset value - * @param aDisplayOptions = a GBR_DISPLAY_OPTIONS for draw display opts - */ - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - GR_DRAWMODE aDrawMode, const wxPoint& aOffset, - GBR_DISPLAY_OPTIONS* aDisplayOptions ); - - /** - * Function DrawItemsDCodeID - * Draw the DCode value (if exists) corresponding to gerber item - * (polygons do not have a DCode) - * @param aPanel = the draw canvas - * @param aDC = the current device context - * @param aDrawMode = GR_COPY, GR_OR ... - * @param aDrawColor = the color of dcode texts - */ - void DrawItemsDCodeID( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - GR_DRAWMODE aDrawMode, COLOR4D aDrawColor ); - ///> @copydoc EDA_ITEM::Visit() SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override; - #if defined(DEBUG) - - void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } - + void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } #endif }; diff --git a/gerbview/gerber_draw_item.cpp b/gerbview/gerber_draw_item.cpp index 258fc89e33..bd6671438e 100644 --- a/gerbview/gerber_draw_item.cpp +++ b/gerbview/gerber_draw_item.cpp @@ -450,8 +450,7 @@ bool GERBER_DRAW_ITEM::HasNegativeItems() } -void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, - const wxPoint& aOffset, GBR_DISPLAY_OPTIONS* aDrawOptions ) +void GERBER_DRAW_ITEM::Print( wxDC* aDC, const wxPoint& aOffset, GBR_DISPLAY_OPTIONS* aOptions ) { // used when a D_CODE is not found. default D_CODE to draw a flashed item static D_CODE dummyD_CODE( 0 ); @@ -466,9 +465,6 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDra COLOR4D color = m_GerberImageFile->GetPositiveDrawColor(); - if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) ) - color.SetToLegacyHighlightColor(); - /* isDark is true if flash is positive and should use a drawing * color other than the background color, else use the background color * when drawing so that an erasure happens. @@ -478,22 +474,20 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDra if( !isDark ) { // draw in background color ("negative" color) - color = aDrawOptions->m_NegativeDrawColor; + color = aOptions->m_NegativeDrawColor; } - GRSetDrawMode( aDC, aDrawMode ); - - isFilled = aDrawOptions->m_DisplayLinesFill; + isFilled = aOptions->m_DisplayLinesFill; switch( m_Shape ) { case GBR_POLYGON: - isFilled = aDrawOptions->m_DisplayPolygonsFill; + isFilled = aOptions->m_DisplayPolygonsFill; if( !isDark ) isFilled = true; - DrawGbrPoly( aPanel->GetClipBox(), aDC, color, aOffset, isFilled ); + PrintGerberPoly( aDC, color, aOffset, isFilled ); break; case GBR_CIRCLE: @@ -504,40 +498,27 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDra if( !isFilled ) { // draw the border of the pen's path using two circles, each as narrow as possible - GRCircle( aPanel->GetClipBox(), aDC, GetABPosition( m_Start ), - radius - halfPenWidth, 0, color ); - GRCircle( aPanel->GetClipBox(), aDC, GetABPosition( m_Start ), - radius + halfPenWidth, 0, color ); + GRCircle( nullptr, aDC, GetABPosition( m_Start ), radius - halfPenWidth, 0, color ); + GRCircle( nullptr, aDC, GetABPosition( m_Start ), radius + halfPenWidth, 0, color ); } else // Filled mode { - GRCircle( aPanel->GetClipBox(), aDC, GetABPosition( m_Start ), - radius, m_Size.x, color ); + GRCircle( nullptr, aDC, GetABPosition( m_Start ), radius, m_Size.x, color ); } break; case GBR_ARC: // Currently, arcs plotted with a rectangular aperture are not supported. // a round pen only is expected. - -#if 0 // for arc debug only - GRLine( aPanel->GetClipBox(), aDC, GetABPosition( m_Start ), - GetABPosition( m_ArcCentre ), 0, color ); - GRLine( aPanel->GetClipBox(), aDC, GetABPosition( m_End ), - GetABPosition( m_ArcCentre ), 0, color ); -#endif - if( !isFilled ) { - GRArc1( aPanel->GetClipBox(), aDC, GetABPosition( m_Start ), - GetABPosition( m_End ), GetABPosition( m_ArcCentre ), - 0, color ); + GRArc1( nullptr, aDC, GetABPosition( m_Start ), GetABPosition( m_End ), + GetABPosition( m_ArcCentre ), 0, color ); } else { - GRArc1( aPanel->GetClipBox(), aDC, GetABPosition( m_Start ), - GetABPosition( m_End ), GetABPosition( m_ArcCentre ), - m_Size.x, color ); + GRArc1( nullptr, aDC, GetABPosition( m_Start ), GetABPosition( m_End ), + GetABPosition( m_ArcCentre ), m_Size.x, color ); } break; @@ -547,9 +528,8 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDra case GBR_SPOT_OVAL: case GBR_SPOT_POLY: case GBR_SPOT_MACRO: - isFilled = aDrawOptions->m_DisplayFlashedItemsFill; - d_codeDescr->DrawFlashedShape( this, aPanel->GetClipBox(), aDC, color, - m_Start, isFilled ); + isFilled = aOptions->m_DisplayFlashedItemsFill; + d_codeDescr->DrawFlashedShape( this, nullptr, aDC, color, m_Start, isFilled ); break; case GBR_SEGMENT: @@ -563,19 +543,19 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDra if( m_Polygon.OutlineCount() == 0 ) ConvertSegmentToPolygon(); - DrawGbrPoly( aPanel->GetClipBox(), aDC, color, aOffset, isFilled ); + PrintGerberPoly( aDC, color, aOffset, isFilled ); } else { if( !isFilled ) { - GRCSegm( aPanel->GetClipBox(), aDC, GetABPosition( m_Start ), - GetABPosition( m_End ), m_Size.x, color ); + GRCSegm( nullptr, aDC, GetABPosition( m_Start ), GetABPosition( m_End ), + m_Size.x, color ); } else { - GRFilledSegment( aPanel->GetClipBox(), aDC, GetABPosition( m_Start ), - GetABPosition( m_End ), m_Size.x, color ); + GRFilledSegment( nullptr, aDC, GetABPosition( m_Start ), GetABPosition( m_End ), + m_Size.x, color ); } } @@ -660,11 +640,8 @@ void GERBER_DRAW_ITEM::ConvertSegmentToPolygon() } -void GERBER_DRAW_ITEM::DrawGbrPoly( EDA_RECT* aClipBox, - wxDC* aDC, - COLOR4D aColor, - const wxPoint& aOffset, - bool aFilledShape ) +void GERBER_DRAW_ITEM::PrintGerberPoly( wxDC* aDC, COLOR4D aColor, const wxPoint& aOffset, + bool aFilledShape ) { std::vector points; SHAPE_LINE_CHAIN& poly = m_Polygon.Outline( 0 ); @@ -679,7 +656,7 @@ void GERBER_DRAW_ITEM::DrawGbrPoly( EDA_RECT* aClipBox, points[ii] = GetABPosition( points[ii] ); } - GRClosedPoly( aClipBox, aDC, pointCount, &points[0], aFilledShape, aColor, aColor ); + GRClosedPoly( nullptr, aDC, pointCount, &points[0], aFilledShape, aColor, aColor ); } diff --git a/gerbview/gerber_draw_item.h b/gerbview/gerber_draw_item.h index 0b69d83bb1..dbb4f64080 100644 --- a/gerbview/gerber_draw_item.h +++ b/gerbview/gerber_draw_item.h @@ -42,6 +42,7 @@ class GBR_LAYOUT; class D_CODE; class MSG_PANEL_ITEM; class GBR_DISPLAY_OPTIONS; +class PCB_BASE_FRAME; namespace KIGFX { @@ -75,19 +76,19 @@ private: public: - bool m_UnitsMetric; /* store here the gerber units (inch/mm). Used - * only to calculate aperture macros shapes sizes */ - int m_Shape; // Shape and type of this gerber item - wxPoint m_Start; // Line or arc start point or position of the shape + bool m_UnitsMetric; // store here the gerber units (inch/mm). Used + // only to calculate aperture macros shapes sizes + int m_Shape; // Shape and type of this gerber item + wxPoint m_Start; // Line or arc start point or position of the shape // for flashed items - wxPoint m_End; // Line or arc end point - wxPoint m_ArcCentre; // for arcs only: Centre of arc - SHAPE_POLY_SET m_Polygon; // Polygon shape data (G36 to G37 coordinates) + wxPoint m_End; // Line or arc end point + wxPoint m_ArcCentre; // for arcs only: Centre of arc + SHAPE_POLY_SET m_Polygon; // Polygon shape data (G36 to G37 coordinates) // or for complex shapes which are converted to polygon - wxSize m_Size; // Flashed shapes: size of the shape + wxSize m_Size; // Flashed shapes: size of the shape // Lines : m_Size.x = m_Size.y = line width - bool m_Flashed; // True for flashed items - int m_DCode; // DCode used to draw this item. + bool m_Flashed; // True for flashed items + int m_DCode; // DCode used to draw this item. // 0 for items that do not use DCodes (polygons) // or when unknown and normal values are 10 to 999 // values 0 to 9 can be used for special purposes @@ -231,9 +232,7 @@ public: const EDA_RECT GetBoundingBox() const override; - /* Display on screen: */ - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - GR_DRAWMODE aDrawMode, const wxPoint&aOffset, GBR_DISPLAY_OPTIONS* aDrawOptions ); + void Print( wxDC* aDC, const wxPoint& aOffset, GBR_DISPLAY_OPTIONS* aOptions ); /** * Function ConvertSegmentToPolygon @@ -244,11 +243,10 @@ public: void ConvertSegmentToPolygon(); /** - * Function DrawGbrPoly - * a helper function used to draw the polygon stored in m_PolyCorners + * Function PrintGerberPoly + * a helper function used to print the polygon stored in m_PolyCorners */ - void DrawGbrPoly( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor, - const wxPoint& aOffset, bool aFilledShape ); + void PrintGerberPoly( wxDC* aDC, COLOR4D aColor, const wxPoint& aOffset, bool aFilledShape ); /* divers */ int Shape() const { return m_Shape; } diff --git a/include/class_board_item.h b/include/class_board_item.h index 1970192444..53faa61e4c 100644 --- a/include/class_board_item.h +++ b/include/class_board_item.h @@ -39,8 +39,9 @@ class BOARD; class BOARD_ITEM_CONTAINER; -class EDA_DRAW_PANEL; class SHAPE_POLY_SET; +class PCB_BASE_FRAME; + /** * Enum STROKE_T @@ -146,11 +147,10 @@ public: } /** - * Function Draw + * Function Print * BOARD_ITEMs have their own color information. */ - virtual void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, - GR_DRAWMODE aDrawMode, const wxPoint& offset = ZeroOffset ) = 0; + virtual void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset = ZeroOffset ) = 0; /** * Swap data between aItem and aImage. diff --git a/include/draw_frame.h b/include/draw_frame.h index 2bc948107a..100e7d3e36 100644 --- a/include/draw_frame.h +++ b/include/draw_frame.h @@ -3,7 +3,7 @@ * * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2011 Wayne Stambaugh - * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.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 @@ -37,6 +37,7 @@ class wxSingleInstanceChecker; class EDA_HOTKEY; class ACTION_TOOLBAR; +class EDA_DRAW_PANEL; using KIGFX::COLOR4D; @@ -91,16 +92,12 @@ class EDA_DRAW_FRAME : public KIWAY_PLAYER BASE_SCREEN* m_currentScreen; ///< current used SCREEN - bool m_snapToGrid; ///< Indicates if cursor should be snapped to grid. - EDA_DRAW_PANEL_GAL* m_galCanvas; ///< GAL display options - this is the frame's interface to setting GAL display options KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions; protected: - bool m_useSingleCanvasPane; - wxSocketServer* m_socketServer; std::vector m_sockets; ///< interprocess communication @@ -601,7 +598,7 @@ public: double GetZoom(); /** - * Draws on screen the page layout with the frame and the basic inscriptions. + * Prints the page layout with the frame and the basic inscriptions. * * @param aDC The device context. * @param aScreen screen to draw @@ -610,9 +607,8 @@ public: * @param aFilename The filename to display in basic inscriptions. * @param aSheetLayer The layer displayed from pcbnew. */ - void DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth, - double aScale, const wxString &aFilename, - const wxString &aSheetLayer = wxEmptyString, + void PrintWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth, double aScale, + const wxString &aFilename, const wxString &aSheetLayer = wxEmptyString, COLOR4D aColor = COLOR4D::UNSPECIFIED ); void DisplayToolMsg( const wxString& msg ); diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index b31331f624..1c5c23a36e 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -63,7 +63,6 @@ class EDA_ITEM; class EDA_RECT; -class EDA_DRAW_PANEL; class EDA_DRAW_PANEL_GAL; class EDA_MSG_PANEL; class BASE_SCREEN; diff --git a/include/eda_text.h b/include/eda_text.h index 955cfb8f0d..149a6cfa95 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -248,19 +248,14 @@ public: void Empty() { m_Text.Empty(); } /** - * Function Draw - * @param aClipBox = the clipping rect, or NULL if no clipping + * Function Print * @param aDC = the current Device Context * @param aOffset = draw offset (usually (0,0)) * @param aColor = text color - * @param aDrawMode = GR_OR, GR_XOR.., -1 to use the current mode. * @param aDisplay_mode = FILLED or SKETCH - * @param aAnchor_color = anchor color ( COLOR4D::UNSPECIFIED = do not draw anchor ). */ - void Draw( EDA_RECT* aClipBox, wxDC* aDC, - const wxPoint& aOffset, COLOR4D aColor, - GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aDisplay_mode = FILLED, - COLOR4D aAnchor_color = COLOR4D::UNSPECIFIED ); + void Print( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor, + EDA_DRAW_MODE_T aDisplay_mode = FILLED ); /** * Convert the text shape to a list of segment @@ -385,22 +380,18 @@ protected: private: /** - * Function drawOneLineOfText - * draws a single text line. - * Used to draw each line of this EDA_TEXT, that can be multiline - * @param aClipBox = the clipping rect, or NULL if no clipping + * Function printOneLineOfText + * Used to print each line of this EDA_TEXT, that can be multiline * @param aDC = the current Device Context * @param aOffset = draw offset (usually (0,0)) * @param aColor = text color - * @param aDrawMode = GR_OR, GR_XOR.., -1 to use the current mode. * @param aFillMode = FILLED or SKETCH * @param aText = the single line of text to draw. * @param aPos = the position of this line ). */ - void drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC, - const wxPoint& aOffset, COLOR4D aColor, - GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode, - const wxString& aText, const wxPoint& aPos ); + void printOneLineOfText( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor, + EDA_DRAW_MODE_T aFillMode, const wxString& aText, + const wxPoint& aPos ); // Private text effects data. API above provides accessor funcs. TEXT_EFFECTS m_e; diff --git a/include/gr_basic.h b/include/gr_basic.h index 06c3173ee4..e490a3d0ed 100644 --- a/include/gr_basic.h +++ b/include/gr_basic.h @@ -87,7 +87,6 @@ typedef enum { } GRLineStypeType; -class EDA_DRAW_PANEL; void GRSetDrawMode( wxDC* DC, GR_DRAWMODE mode ); GR_DRAWMODE GRGetDrawMode( wxDC* DC ); diff --git a/include/draw_graphic_text.h b/include/gr_text.h similarity index 73% rename from include/draw_graphic_text.h rename to include/gr_text.h index f1b7d65918..83a1865601 100644 --- a/include/draw_graphic_text.h +++ b/include/gr_text.h @@ -48,7 +48,6 @@ */ #define MIN_DRAWABLE_TEXT_SIZE 3 -class EDA_DRAW_PANEL; class PLOTTER; /** @@ -81,7 +80,7 @@ int GetPenSizeForBold( int aTextSize ); int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool italic, bool bold ); /** - * Function DrawGraphicText + * Function GRText * Draw a graphic text (like module texts) * @param aClipBox = the clipping rect, or NULL if no clipping * @param aDC = the current Device Context. NULL if draw within a 3D GL Canvas @@ -105,45 +104,24 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool italic, b * @param aPlotter = a pointer to a PLOTTER instance, when this function is used to plot * the text. NULL to draw this text. */ -void DrawGraphicText( EDA_RECT* aClipBox, - wxDC * aDC, - 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, - void (*aCallback)( int x0, int y0, int xf, int yf, void* aData ) = nullptr, - void* aCallbackData = nullptr, - PLOTTER * aPlotter = nullptr ); +void GRText( wxDC * aDC, 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, + void (*aCallback)( int x0, int y0, int xf, int yf, void* aData ) = nullptr, + void* aCallbackData = nullptr, PLOTTER * aPlotter = nullptr ); /** * Draw graphic text with a border, so that it can be read on different - * backgrounds. See DrawGraphicText for most of the parameters. + * backgrounds. See GRText for most of the parameters. * If aBgColor is a dark color text is drawn in aColor2 with aColor1 * border; otherwise colors are swapped. */ -void DrawGraphicHaloText( EDA_RECT* aClipBox, - wxDC * aDC, - const wxPoint &aPos, - const 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, - void (*aCallback)( int x0, int y0, int xf, int yf, void* aData ) = nullptr, - void* aCallbackData = nullptr, - PLOTTER * aPlotter = nullptr ); +void GRHaloText( wxDC * aDC, const wxPoint &aPos, const 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, + void (*aCallback)( int x0, int y0, int xf, int yf, void* aData ) = nullptr, + void* aCallbackData = nullptr, PLOTTER * aPlotter = nullptr ); #endif /* __INCLUDE__DRAWTXT_H__ */ diff --git a/include/kicad_device_context.h b/include/kicad_device_context.h deleted file mode 100644 index 784a7cd771..0000000000 --- a/include/kicad_device_context.h +++ /dev/null @@ -1,203 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2009 jean-pierre.charras@gipsa-lab.inpg.fr - * Copyright (C) 2011 Wayne Stambaugh - * Copyright (C) 2007 KiCad Developers, see change_log.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 - */ - -/** - * a helper to handle the real device context used in KiCad - * @file kicad_device_context.h - */ - -#ifndef __KICAD_DEVICE_CONTEXT_H__ -#define __KICAD_DEVICE_CONTEXT_H__ - -#include - -#if defined(KICAD_USE_BUFFERED_PAINTDC) -#undef KICAD_USE_BUFFERED_PAINTDC -#endif - -#if defined(KICAD_USE_BUFFERED_DC) -#undef KICAD_USE_BUFFERED_DC -#endif - -// wxWidgets defines the platforms where device context buffering is well behaved. These -// definitions take advantage of their experience in this area. See for -// more information. -#if wxALWAYS_NATIVE_DOUBLE_BUFFER -#define KICAD_USE_BUFFERED_PAINTDC 1 -#define KICAD_USE_BUFFERED_DC_HELPER 0 -#define KICAD_USE_BUFFERED_DC 0 -#else -#define KICAD_USE_BUFFERED_PAINTDC 1 -#define KICAD_USE_BUFFERED_DC_HELPER 1 -#define KICAD_USE_BUFFERED_DC 1 -#endif - - -/** - * Class BUFFERED_DC_HELPER - * fixes a bug on Windows when using buffered device context. - * - *

- * When using buffered device context drawing in Windows, the user scaling must be set to 1 - * and the logical offset must be set to zero before the bitmap blit operation occurs in - * the destructor of wxBufferdDC but after the normal drawing takes place. - *

- */ -class BUFFERED_DC_HELPER -{ -public: - BUFFERED_DC_HELPER( wxBufferedDC* aDC ) - : m_dc( aDC ) {} - - virtual ~BUFFERED_DC_HELPER() - { - if( m_dc ) - { - m_dc->SetLogicalOrigin( 0, 0 ); - m_dc->SetUserScale( 1.0, 1.0 ); - } - } - -private: - wxBufferedDC* m_dc; -}; - - -/** - * Class EDA_BLIT_NORMALIZER - * is a helper class for clearing a device context scale and offset parameters before - * performing a Blit operation. - *

- * This class keeps a temporary copy of the scale and offset parameters of a device - * context and then restores them when it goes out of scope. - *

- */ -class EDA_BLIT_NORMALIZER -{ -public: - EDA_BLIT_NORMALIZER( wxDC* aDC ) - : m_dc( aDC ) - { - if( aDC ) - { - aDC->GetUserScale( &m_userScaleX, &m_userScaleY ); - aDC->GetLogicalOrigin( &m_logicalOriginX, &m_logicalOriginY ); - aDC->GetDeviceOrigin( &m_deviceOriginX, &m_deviceOriginY ); - aDC->SetUserScale( 1.0, 1.0 ); - aDC->SetLogicalOrigin( 0, 0 ); - aDC->SetDeviceOrigin( 0, 0 ); - } - } - - ~EDA_BLIT_NORMALIZER() - { - if( m_dc ) - { - m_dc->SetUserScale( m_userScaleX, m_userScaleY ); - m_dc->SetLogicalOrigin( m_logicalOriginX, m_logicalOriginY ); - m_dc->SetDeviceOrigin( m_deviceOriginX, m_deviceOriginY ); - } - } - -private: - wxDC* m_dc; - double m_userScaleX; - double m_userScaleY; - int m_logicalOriginX; - int m_logicalOriginY; - int m_deviceOriginX; - int m_deviceOriginY; - - DECLARE_NO_COPY_CLASS( EDA_BLIT_NORMALIZER ) -}; - - -#if USE_WX_GRAPHICS_CONTEXT - #include -#endif - -// Macro used to declare a device context in KiCad: -#if USE_WX_GRAPHICS_CONTEXT -//#pragma message( "INSTALL_DC is wxClientDC with wxGCDC" ) -#define INSTALL_DC( name, parent ) \ - wxClientDC _cDC( parent ); \ - wxGCDC name( _cDC ); \ - parent->DoPrepareDC( name ); \ - name.GetGraphicsContext()->Translate( 0.5, 0.5 ); -#else -#if KICAD_USE_BUFFERED_DC && !KICAD_USE_BUFFERED_DC_HELPER -//#pragma message( "INSTALL_DC is wxClientDC with wxBufferedDC" ) -#define INSTALL_DC( name, parent ) \ - wxClientDC _cDC( parent ); \ - wxBufferedDC name(&_cDC, _cDC.GetSize() ); \ - parent->DoPrepareDC( name ); -#elif KICAD_USE_BUFFERED_DC && KICAD_USE_BUFFERED_DC_HELPER -//#pragma message( "INSTALL_DC is wxBufferedDC with BUFFERED_DC_HELPER" ) -#define INSTALL_DC( name, parent ) \ - wxClientDC _cDC( parent ); \ - wxBufferedDC name(&_cDC, _cDC.GetSize() ); \ - parent->DoPrepareDC( name ); \ - BUFFERED_DC_HELPER helper( &name ); -#else -//#pragma message( "INSTALL_DC is wxClientDC" ) -#define INSTALL_DC( name, parent ) \ - wxClientDC name( parent ); \ - parent->DoPrepareDC( name ); -#endif -#endif - -#if USE_WX_GRAPHICS_CONTEXT -//#pragma message( "INSTALL_PAINTDC is wxPaintDC with wxGCDC" ) -#define INSTALL_PAINTDC( name, parent) \ - wxPaintDC _pDC( parent ); \ - wxGCDC name( _pDC ); \ - parent->DoPrepareDC( name ); \ - name.GetGraphicsContext()->Translate( 0.5, 0.5 ); -#elif KICAD_USE_BUFFERED_PAINTDC && !KICAD_USE_BUFFERED_DC_HELPER -//#pragma message( "INSTALL_PAINTDC is wxAutoBufferedPaintDC" ) -#define INSTALL_PAINTDC( name, parent ) \ - wxAutoBufferedPaintDC name( parent ); \ - parent->DoPrepareDC( name ); -#elif KICAD_USE_BUFFERED_PAINTDC && KICAD_USE_BUFFERED_DC_HELPER -//#pragma message( "INSTALL_PAINTDC is wxBufferedPaintDC with BUFFERED_DC_HELPER" ) -#define INSTALL_PAINTDC( name, parent ) \ - wxBufferedPaintDC name( parent ); \ - parent->DoPrepareDC( name ); \ - BUFFERED_DC_HELPER help( &name ); -#else -//#pragma message( "INSTALL_PAINTDC is wxPaintDC" ) -#define INSTALL_PAINTDC(name,parent) \ - wxPaintDC name( parent ); \ - parent->DoPrepareDC( name ); -#endif - - -// This macro should be used when drawing objects directly without drawing the background. -#define INSTALL_UNBUFFERED_DC( name, parent ) \ - wxClientDC name( parent ); \ - parent->DoPrepareDC( name ); - - -#endif // __KICAD_DEVICE_CONTEXT_H__ diff --git a/include/legacy_gal/class_drawpanel.h b/include/legacy_gal/class_drawpanel.h index 73d6291fff..e8f26fbdda 100644 --- a/include/legacy_gal/class_drawpanel.h +++ b/include/legacy_gal/class_drawpanel.h @@ -11,106 +11,18 @@ class BASE_SCREEN; class EDA_DRAW_PANEL { -protected: - bool m_showCrossHair; ///< Indicate if cross hair is to be shown. - int m_cursorLevel; ///< Index for cursor redraw in XOR mode. - int m_scrollIncrementX; ///< X axis scroll increment in pixels per unit. - int m_scrollIncrementY; ///< Y axis scroll increment in pixels per unit. - - /// The drawing area used to redraw the screen which is usually the visible area - /// of the drawing in internal units. - EDA_RECT m_ClipBox; - - /// True when drawing in mirror mode. Used by the draw arc function, because arcs - /// are oriented, and in mirror mode, orientations are reversed. - bool m_PrintIsMirrored; - public: - - EDA_DRAW_PANEL() : - m_showCrossHair( true ), - m_cursorLevel( 0 ), - m_scrollIncrementX( 1 ), - m_scrollIncrementY( 1 ), - m_PrintIsMirrored( false ) + EDA_DRAW_PANEL() {}; virtual ~EDA_DRAW_PANEL(){}; - /** - * Function GetDisplayOptions - * A way to pass info to draw functions. - * this is just an accessor to the GetDisplayOptions() parent frame function. - */ - virtual void* GetDisplayOptions() { printf("EDA_DRAW_PANEL:Unimplemented\n"); wxASSERT(false); return nullptr; }; - virtual BASE_SCREEN* GetScreen() = 0; virtual EDA_DRAW_FRAME* GetParent() const = 0; - //virtual void OnPaint( wxPaintEvent& event ); - - virtual EDA_RECT* GetClipBox() { return &m_ClipBox; } - - void SetClipBox( const EDA_RECT& aRect ) { m_ClipBox = aRect; } - - bool GetPrintMirrored() const { return m_PrintIsMirrored; } - void SetPrintMirrored( bool aMirror ) { m_PrintIsMirrored = aMirror; } - - /* Mouse and keys events */ - - /** - * Function OnMouseWheel - * handles mouse wheel events. - *

- * The mouse wheel is used to provide support for zooming and panning. This - * is accomplished by converting mouse wheel events in pseudo menu command - * events and sending them to the appropriate parent window event handler. - *

- */ - - virtual void SetZoom( double mode ) { printf("EDA_DRAW_PANEL:Unimplemented7\n"); };; - virtual double GetZoom() { return 1.0; };; - - //virtual void SetGrid( const wxRealPoint& size ) { printf("EDA_DRAW_PANEL:Unimplemented\n"); };; - //virtual wxRealPoint GetGrid() { printf("EDA_DRAW_PANEL:Unimplemented\n"); return wxRealPoint(1.0, 1.0); };; - - - /** - * Function SetClipBox - * sets the clip box in drawing (logical) units from \a aRect in device units. - *

- * If \a aRect is NULL, then the entire visible area of the screen is used as the clip - * area. The clip box is used when drawing to determine which objects are not visible - * and do not need to be drawn. Note that this is not the same as setting the device - * context clipping with wxDC::SetClippingRegion(). This is the rectangle used by the - * drawing functions in gr_basic.cpp used to determine if the item to draw is off screen - * and therefore not drawn. - *

- * @param aDC The device context use for drawing with the correct scale and - * offsets already configured. See DoPrepareDC(). - * @param aRect The clip rectangle in device units or NULL for the entire visible area - * of the screen. - */ - virtual void SetClipBox( wxDC& aDC, const wxRect* aRect = NULL ) { printf("EDA_DRAW_PANEL:Unimplemented10\n"); };; - - /** - * Function RefreshDrawingRect - * redraws the contents of \a aRect in drawing units. \a aRect is converted to - * screen coordinates and wxWindow::RefreshRect() is called to repaint the region. - * @param aRect The rectangle to repaint. - * @param aEraseBackground Erases the background if true. - */ - virtual void RefreshDrawingRect( const EDA_RECT& aRect, bool aEraseBackground = true ) { printf("EDA_DRAW_PANEL:Unimplemented12\n"); };; - - /// @copydoc wxWindow::Refresh() - //virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL ); - - /** - * Function GetScreenCenterLogicalPosition - * @return The current screen center position in logical (drawing) units. - */ - virtual wxPoint GetScreenCenterLogicalPosition() { return wxPoint(0, 0); };; + // Only used for printing, so no clipping + virtual EDA_RECT* GetClipBox() { return nullptr; } virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL ) {} diff --git a/include/legacy_wx/class_drawpanel.h b/include/legacy_wx/class_drawpanel.h index c6fbaaa2af..3d998c3d49 100644 --- a/include/legacy_wx/class_drawpanel.h +++ b/include/legacy_wx/class_drawpanel.h @@ -37,124 +37,19 @@ class PCB_SCREEN; class EDA_DRAW_PANEL : public wxScrolledWindow { -private: - int m_currentCursor; ///< Current mouse cursor shape id. - int m_defaultCursor; ///< The default mouse cursor shape id. - bool m_showCrossHair; ///< Indicate if cross hair is to be shown. - int m_cursorLevel; ///< Index for cursor redraw in XOR mode. - int m_scrollIncrementX; ///< X axis scroll increment in pixels per unit. - int m_scrollIncrementY; ///< Y axis scroll increment in pixels per unit. - - wxPoint m_CursorStartPos; ///< Used for testing the cursor movement. - wxPoint m_PanStartCenter; ///< Initial scroll center position when pan started - wxPoint m_PanStartEventPosition; ///< Initial position of mouse event when pan started - - wxPoint m_CursorClickPos; ///< Used for maintaining click position - - /// The drawing area used to redraw the screen which is usually the visible area - /// of the drawing in internal units. - EDA_RECT m_ClipBox; - - /* Used to inhibit a response to a mouse left button release, after a double click - * (when releasing the left button at the end of the second click. Used in Eeschema - * to inhibit a mouse left release command when switching between hierarchical sheets - * on a double click. - */ - bool m_ignoreNextLeftButtonRelease; ///< Ignore the next mouse left button release when true. - - /// True when drawing in mirror mode. Used by the draw arc function, because arcs - /// are oriented, and in mirror mode, orientations are reversed. - bool m_PrintIsMirrored; - public: - EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id, const wxPoint& pos, const wxSize& size ); ~EDA_DRAW_PANEL(); - /** - * Function GetDisplayOptions - * A way to pass info to draw functions. - * this is just an accessor to the GetDisplayOptions() parent frame function. - */ - void* GetDisplayOptions(); - BASE_SCREEN* GetScreen(); EDA_DRAW_FRAME* GetParent() const; - EDA_RECT* GetClipBox() { return &m_ClipBox; } - - void SetClipBox( const EDA_RECT& aRect ) { m_ClipBox = aRect; } - - bool GetPrintMirrored() const { return m_PrintIsMirrored; } - void SetPrintMirrored( bool aMirror ) { m_PrintIsMirrored = aMirror; } - - void OnEraseBackground( wxEraseEvent& event ) { } - - /** - * Function DoPrepareDC - * sets up the device context \a aDC for drawing. - *

- * This overrides wxScrolledWindow::DoPrepareDC() for setting up the the device context - * used for drawing. The scale factor and drawing logical offset are set and the base - * method is called to set the DC device origin (scroll bar position). This connects - * everything together to achieve the appropriate coordinate manipulation using wxDC - * LogicalToDeviceXXX and DeviceToLogixalXXX methods. This gets called automatically - * for a paint event. If you do any drawing outside the paint event, you must call - * DoPrepareDC manually. - *

- * @param aDC The device context to prepare. - */ - virtual void DoPrepareDC( wxDC& aDC ) override; - - /* Mouse and keys events */ - - void OnCharHook( wxKeyEvent& event ); - - /** - * Function SetClipBox - * sets the clip box in drawing (logical) units from \a aRect in device units. - *

- * If \a aRect is NULL, then the entire visible area of the screen is used as the clip - * area. The clip box is used when drawing to determine which objects are not visible - * and do not need to be drawn. Note that this is not the same as setting the device - * context clipping with wxDC::SetClippingRegion(). This is the rectangle used by the - * drawing functions in gr_basic.cpp used to determine if the item to draw is off screen - * and therefore not drawn. - *

- * @param aDC The device context use for drawing with the correct scale and - * offsets already configured. See DoPrepareDC(). - * @param aRect The clip rectangle in device units or NULL for the entire visible area - * of the screen. - */ - void SetClipBox( wxDC& aDC, const wxRect* aRect = NULL ); + // Only used for printing, so no clipping + virtual EDA_RECT* GetClipBox() { return nullptr; } /// @copydoc wxWindow::Refresh() - virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL ) override; - - /** - * Function GetScreenCenterLogicalPosition - * @return The current screen center position in logical (drawing) units. - */ - wxPoint GetScreenCenterLogicalPosition(); - - /* Cursor functions */ - - /** - * Function SetCurrentCursor - * Set the current cursor shape for drawpanel - */ - void SetCurrentCursor( int aCursor ) - { - m_currentCursor = aCursor; - SetCursor( (wxStockCursor) m_currentCursor ); - } - - /** - * Function GetDefaultCursor - * @return the default cursor shape - */ - int GetDefaultCursor() const { return m_defaultCursor; } + void Refresh( bool eraseBackground = true, const wxRect* rect = NULL ) override; }; diff --git a/include/marker_base.h b/include/marker_base.h index a3a4839dee..a1ff9e3eca 100644 --- a/include/marker_base.h +++ b/include/marker_base.h @@ -141,10 +141,10 @@ public: int GetShapePolygonCornerCount() const; /** - * Function DrawMarker - * draws the shape is the polygon defined in m_Corners (array of wxPoints). + * Function PrintMarker + * Prints the shape is the polygon defined in m_Corners (array of wxPoints). */ - void DrawMarker( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ); + void PrintMarker( wxDC* aDC, const wxPoint& aOffset ); /** * Function GetPos diff --git a/include/origin_viewitem.h b/include/origin_viewitem.h index 2b610f7afc..2ca84acf8a 100644 --- a/include/origin_viewitem.h +++ b/include/origin_viewitem.h @@ -31,6 +31,8 @@ #include #include +class PCB_BASE_FRAME; + /** * Class ORIGIN_VIEWITEM * @@ -56,10 +58,9 @@ public: void ViewDraw( int aLayer, VIEW* aView ) const override; - void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, - GR_DRAWMODE aDrawMode, const wxPoint& offset = ZeroOffset ) override + void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset = ZeroOffset ) override { - wxASSERT( 0 ); // ORIGIN_VIEWITEM never added to BOARD; drawn directly through ViewDraw(). + wxASSERT( 0 ); // ORIGIN_VIEWITEM never added to BOARD } void ViewGetLayers( int aLayers[], int& aCount ) const override diff --git a/include/plotter.h b/include/plotter.h index dfd521a84b..e74c9f2d02 100644 --- a/include/plotter.h +++ b/include/plotter.h @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include // FILL_T diff --git a/include/ws_draw_item.h b/include/ws_draw_item.h index 46d65e648a..6bce7e21a8 100644 --- a/include/ws_draw_item.h +++ b/include/ws_draw_item.h @@ -71,16 +71,14 @@ public: virtual void SetPosition( wxPoint aPos ) = 0; virtual void SetEnd( wxPoint aPos ) { /* not all types will need this */ } - // The function to draw a WS_DRAW_ITEM - virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor ) + // The function to print a WS_DRAW_ITEM + virtual void PrintWsItem( wxDC* aDC, COLOR4D aColor ) { - wxPoint offset( 0, 0 ); - DrawWsItem( aClipBox, aDC, offset, UNSPECIFIED_DRAWMODE, aColor ); + PrintWsItem( aDC, wxPoint( 0, 0 ), aColor ); } // More advanced version of DrawWsItem. This is what must be defined in the derived type. - virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor ) = 0; + virtual void PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor ) = 0; // Derived types must define GetBoundingBox() as a minimum, and can then override the // two HitTest() functions if they need something more specific. @@ -131,8 +129,7 @@ public: const EDA_RECT GetBoundingBox() const override; bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override; - void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode, - COLOR4D aColor ) override; + void PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor ) override; wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; @@ -175,8 +172,7 @@ public: bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode, - COLOR4D aColor ) override; + void PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor ) override; wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; @@ -214,8 +210,7 @@ public: const wxPoint GetPosition() const override { return GetStart(); } void SetPosition( wxPoint aPos ) override { SetStart( aPos ); } - void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode, - COLOR4D aColor ) override; + void PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor ) override; const EDA_RECT GetBoundingBox() const override; bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override; @@ -247,10 +242,7 @@ public: virtual wxString GetClass() const override { return wxT( "WS_DRAW_ITEM_TEXT" ); } - /** The function to draw a WS_DRAW_ITEM_TEXT - */ - void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode, - COLOR4D aColor ) override; + void PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor ) override; // Accessors: int GetPenWidth() { return GetThickness(); } @@ -293,8 +285,7 @@ public: const wxPoint GetPosition() const override { return m_pos; } void SetPosition( wxPoint aPos ) override { m_pos = aPos; } - void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode, - COLOR4D aColor ) override; + void PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor ) override; const EDA_RECT GetBoundingBox() const override; @@ -442,10 +433,9 @@ public: /** * Draws the item list created by BuildWorkSheetGraphicList - * @param aClipBox = the clipping rect, or NULL if no clipping * @param aDC = the current Device Context */ - void Draw( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor ); + void Print( wxDC* aDC, COLOR4D aColor ); /** * Function BuildWorkSheetGraphicList is a core function for drawing or plotting the diff --git a/include/ws_painter.h b/include/ws_painter.h index cecd41979e..919311d3b0 100644 --- a/include/ws_painter.h +++ b/include/ws_painter.h @@ -31,7 +31,6 @@ #include // Forward declarations: -class EDA_DRAW_PANEL; class EDA_RECT; class TITLE_BLOCK; @@ -129,10 +128,9 @@ private: /** - * Function DrawPageLayout is a core function to draw the page layout with - * the frame and the basic inscriptions. + * Function PrintPageLayout is a core function to print the page layout with the frame and the + * basic inscriptions. * @param aDC The device context. - * @param aClipBox = the clipping rect, or NULL if no clipping. * @param aPageInfo for margins and page size (in mils). * @param aFullSheetName The sheetpath (full sheet name), for basic inscriptions. * @param aFileName The file name, for basic inscriptions. @@ -142,7 +140,6 @@ private: * @param aPenWidth the pen size The line width for drawing. * @param aScalar the scale factor to convert from mils to internal units. * @param aColor The color for drawing. - * @param aAltColor The color for items which need to be "hightlighted". * @param aSheetLayer The layer from pcbnew. * * Parameters used in aPageInfo @@ -150,18 +147,9 @@ private: * - the LTmargin The left top margin of the page layout. * - the RBmargin The right bottom margin of the page layout. */ -void DrawPageLayout( wxDC* aDC, - EDA_RECT* aClipBox, - const PAGE_INFO& aPageInfo, - const wxString& aFullSheetName, - const wxString& aFileName, - TITLE_BLOCK& aTitleBlock, - int aSheetCount, - int aSheetNumber, - int aPenWidth, - double aScalar, - COLOR4D aColor, - const wxString& aSheetLayer = wxEmptyString ); - +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 wxString& aSheetLayer = wxEmptyString ); #endif // WS_PAINTER_H diff --git a/pagelayout_editor/dialogs/dialogs_for_printing.cpp b/pagelayout_editor/dialogs/dialogs_for_printing.cpp index c2a9699453..a5d6e895c5 100644 --- a/pagelayout_editor/dialogs/dialogs_for_printing.cpp +++ b/pagelayout_editor/dialogs/dialogs_for_printing.cpp @@ -147,16 +147,14 @@ void PLEDITOR_PRINTOUT::GetPageInfo( int* minPage, int* maxPage, /* * This is the real print function: print the active screen */ -void PLEDITOR_PRINTOUT::DrawPage( int aPageNum ) +void PLEDITOR_PRINTOUT::PrintPage( int aPageNum ) { int oldZoom; wxPoint tmp_startvisu; wxSize pageSizeIU; // Page size in internal units wxPoint old_org; - EDA_RECT oldClipBox; wxRect fitRect; wxDC* dc = GetDC(); - EDA_DRAW_PANEL* panel = m_parent->GetCanvas(); PL_EDITOR_SCREEN* screen = m_parent->GetScreen(); // Save current scale factor, offsets, and clip box. @@ -164,13 +162,6 @@ void PLEDITOR_PRINTOUT::DrawPage( int aPageNum ) oldZoom = screen->GetZoom(); old_org = screen->m_DrawOrg; - oldClipBox = *panel->GetClipBox(); - - // Change clip box to print the whole page. - #define MAX_VALUE (INT_MAX/2) // MAX_VALUE is the max we can use in an integer - // and that allows calculations without overflow - panel->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( MAX_VALUE, MAX_VALUE ) ) ); - // Change scale factor and offset to print the whole page. pageSizeIU = m_parent->GetPageSettings().GetSizeIU(); @@ -190,11 +181,10 @@ void PLEDITOR_PRINTOUT::DrawPage( int aPageNum ) m_parent->SetDrawBgColor( MakeColour( WHITE ) ); screen->m_ScreenNumber = aPageNum; - m_parent->DrawWorkSheet( dc, screen, 0, IU_PER_MILS, wxEmptyString ); + m_parent->PrintWorkSheet( dc, screen, 0, IU_PER_MILS, wxEmptyString ); m_parent->SetDrawBgColor( bg_color ); screen->m_IsPrinting = false; - panel->SetClipBox( oldClipBox ); GRForceBlackPen( false ); diff --git a/pagelayout_editor/hotkeys.cpp b/pagelayout_editor/hotkeys.cpp index f4869eee0a..b5d00c5a97 100644 --- a/pagelayout_editor/hotkeys.cpp +++ b/pagelayout_editor/hotkeys.cpp @@ -25,7 +25,6 @@ #include #include -#include #include #include diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index f262208c7f..df24d5a4ce 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -174,11 +174,7 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.AddPane( GetGalCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() ); - // Set up viewport - KIGFX::VIEW* view = GetGalCanvas()->GetView(); - view->SetScale( GetZoomLevelCoeff() / m_canvas->GetScreen()->GetZoom() ); - view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); - + GetGalCanvas()->GetView()->SetScale( GetZoomLevelCoeff() / m_canvas->GetScreen()->GetZoom() ); ActivateGalCanvas(); m_auimgr.Update(); @@ -584,8 +580,8 @@ void PL_EDITOR_FRAME::UpdateStatusBar() void PL_EDITOR_FRAME::PrintPage( wxDC* aDC, LSET , bool , void * ) { - GetScreen()-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2; - DrawWorkSheet( aDC, GetScreen(), 0, IU_PER_MILS, wxEmptyString ); + GetScreen()->m_ScreenNumber = GetPageNumberOption() ? 1 : 2; + PrintWorkSheet( aDC, GetScreen(), 0, IU_PER_MILS, wxEmptyString ); } diff --git a/pagelayout_editor/pl_editor_layout.h b/pagelayout_editor/pl_editor_layout.h index a3fcc4f421..c98468b0ab 100644 --- a/pagelayout_editor/pl_editor_layout.h +++ b/pagelayout_editor/pl_editor_layout.h @@ -33,8 +33,6 @@ #include #include -class EDA_DRAW_PANEL; - /** * Class PL_EDITOR_LAYOUT diff --git a/pcbnew/autorouter/spread_footprints.cpp b/pcbnew/autorouter/spread_footprints.cpp index 950c09fe43..d7d12e3e65 100644 --- a/pcbnew/autorouter/spread_footprints.cpp +++ b/pcbnew/autorouter/spread_footprints.cpp @@ -364,7 +364,7 @@ void PCB_EDIT_FRAME::SpreadFootprints( std::vector* aFootprints, OnModify(); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } diff --git a/pcbnew/board_connected_item.h b/pcbnew/board_connected_item.h index fc013d2f39..3a025827e2 100644 --- a/pcbnew/board_connected_item.h +++ b/pcbnew/board_connected_item.h @@ -230,8 +230,7 @@ public: return wxPoint(0, 0); // dummy } - void Draw( EDA_DRAW_PANEL* DrawPanel, wxDC* DC, - GR_DRAWMODE aDrawMode, const wxPoint& offset = ZeroOffset ) + void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& aOffset = ZeroOffset ) { } diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index 45026d1261..6158ff00e3 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -35,7 +35,7 @@ #include #include #include // for IU_PER_MM -#include +#include #include #include #include @@ -61,7 +61,7 @@ struct TSEGM_2_POLY_PRMS { }; TSEGM_2_POLY_PRMS prms; -// This is a call back function, used by DrawGraphicText to draw the 3D text shape: +// This is a call back function, used by GRText to draw the 3D text shape: static void addTextSegmToPoly( int x0, int y0, int xf, int yf, void* aData ) { TSEGM_2_POLY_PRMS* prm = static_cast( aData ); @@ -250,11 +250,10 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet( PCB_LAYER_ID aLaye if( textmod->IsMirrored() ) size.x = -size.x; - DrawGraphicText( NULL, NULL, textmod->GetTextPos(), BLACK, - textmod->GetShownText(), textmod->GetDrawRotation(), size, - textmod->GetHorizJustify(), textmod->GetVertJustify(), - textmod->GetThickness(), textmod->IsItalic(), - true, addTextSegmToPoly, &prms ); + GRText( NULL, textmod->GetTextPos(), BLACK, textmod->GetShownText(), + textmod->GetDrawRotation(), size, textmod->GetHorizJustify(), + textmod->GetVertJustify(), textmod->GetThickness(), textmod->IsItalic(), + true, addTextSegmToPoly, &prms ); } } @@ -309,11 +308,10 @@ void MODULE::TransformGraphicTextWithClearanceToPolygonSet( if( textmod->IsMirrored() ) size.x = -size.x; - DrawGraphicText( NULL, NULL, textmod->GetTextPos(), BLACK, - textmod->GetShownText(), textmod->GetDrawRotation(), size, - textmod->GetHorizJustify(), textmod->GetVertJustify(), - textmod->GetThickness(), textmod->IsItalic(), - true, addTextSegmToPoly, &prms ); + GRText( NULL, textmod->GetTextPos(), BLACK, textmod->GetShownText(), + textmod->GetDrawRotation(), size, textmod->GetHorizJustify(), + textmod->GetVertJustify(), textmod->GetThickness(), textmod->IsItalic(), + true, addTextSegmToPoly, &prms ); } } @@ -407,7 +405,7 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet( prms.m_cornerBuffer = &aCornerBuffer; prms.m_textWidth = GetThickness() + ( 2 * aClearanceValue ); prms.m_error = aError; - COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by DrawGraphicText + COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by GRText if( IsMultilineAllowed() ) { @@ -420,20 +418,14 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet( for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) { wxString txt = strings_list.Item( ii ); - DrawGraphicText( NULL, NULL, positions[ii], color, - txt, GetTextAngle(), size, - GetHorizJustify(), GetVertJustify(), - GetThickness(), IsItalic(), - true, addTextSegmToPoly, &prms ); + GRText( NULL, positions[ii], color, txt, GetTextAngle(), size, GetHorizJustify(), + GetVertJustify(), GetThickness(), IsItalic(), true, addTextSegmToPoly, &prms ); } } else { - DrawGraphicText( NULL, NULL, GetTextPos(), color, - GetShownText(), GetTextAngle(), size, - GetHorizJustify(), GetVertJustify(), - GetThickness(), IsItalic(), - true, addTextSegmToPoly, &prms ); + GRText( NULL, GetTextPos(), color, GetShownText(), GetTextAngle(), size, GetHorizJustify(), + GetVertJustify(), GetThickness(), IsItalic(), true, addTextSegmToPoly, &prms ); } } diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index a12f080259..1b753ff920 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -85,7 +85,7 @@ public: // pure virtuals: const wxPoint GetPosition() const override { return wxPoint(); } void SetPosition( const wxPoint& ) override {} - void Draw( EDA_DRAW_PANEL* , wxDC* , GR_DRAWMODE , const wxPoint& ) override {} + void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& aOffset ) override {} #if defined(DEBUG) void Show( int , std::ostream& ) const override {} diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index d5bbc2680e..985bc8cf12 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -807,15 +807,14 @@ public: void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; /** - * Function Draw. - * Redraw the BOARD items but not cursors, axis or grid. - * @param aPanel = the panel relative to the board + * Function Print. + * Print the BOARD items. + * @param aFrame = the current Frame * @param aDC = the current device context * @param aDrawMode = GR_COPY, GR_OR ... (not always used) * @param aOffset = an draw offset value (default = 0,0) */ - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - GR_DRAWMODE aDrawMode, const wxPoint& aOffset = ZeroOffset ) override; + void Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset = ZeroOffset ) override; /** * Function Visit diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index eb11d1f911..af5bfb94de 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -323,57 +323,39 @@ void DIMENSION::AdjustDimensionDetails() } -void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, - const wxPoint& offset ) +void DIMENSION::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset ) { - BOARD* brd = GetBoard(); + BOARD* brd = GetBoard(); if( brd->IsLayerVisible( m_Layer ) == false ) return; - m_Text.Draw( panel, DC, mode_color, offset ); + m_Text.Print( aFrame, DC, offset ); - auto frame = static_cast ( panel->GetParent() ); - auto gcolor = frame->Settings().Colors().GetLayerColor( m_Layer ); - - GRSetDrawMode( DC, mode_color ); - auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() ); + auto gcolor = aFrame->Settings().Colors().GetLayerColor( m_Layer ); + auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aFrame->GetDisplayOptions() ); bool filled = displ_opts ? displ_opts->m_DisplayDrawItemsFill : FILLED; - int width = m_Width; + int width = m_Width; if( filled ) { - GRLine( panel->GetClipBox(), DC, m_crossBarO + offset, - m_crossBarF + offset, width, gcolor ); - GRLine( panel->GetClipBox(), DC, m_featureLineGO + offset, - m_featureLineGF + offset, width, gcolor ); - GRLine( panel->GetClipBox(), DC, m_featureLineDO + offset, - m_featureLineDF + offset, width, gcolor ); - GRLine( panel->GetClipBox(), DC, m_crossBarF + offset, - m_arrowD1F + offset, width, gcolor ); - GRLine( panel->GetClipBox(), DC, m_crossBarF + offset, - m_arrowD2F + offset, width, gcolor ); - GRLine( panel->GetClipBox(), DC, m_crossBarO + offset, - m_arrowG1F + offset, width, gcolor ); - GRLine( panel->GetClipBox(), DC, m_crossBarO + offset, - m_arrowG2F + offset, width, gcolor ); + GRLine( nullptr, DC, m_crossBarO + offset, m_crossBarF + offset, width, gcolor ); + GRLine( nullptr, DC, m_featureLineGO + offset, m_featureLineGF + offset, width, gcolor ); + GRLine( nullptr, DC, m_featureLineDO + offset, m_featureLineDF + offset, width, gcolor ); + GRLine( nullptr, DC, m_crossBarF + offset, m_arrowD1F + offset, width, gcolor ); + GRLine( nullptr, DC, m_crossBarF + offset, m_arrowD2F + offset, width, gcolor ); + GRLine( nullptr, DC, m_crossBarO + offset, m_arrowG1F + offset, width, gcolor ); + GRLine( nullptr, DC, m_crossBarO + offset, m_arrowG2F + offset, width, gcolor ); } else { - GRCSegm( panel->GetClipBox(), DC, m_crossBarO + offset, - m_crossBarF + offset, width, gcolor ); - GRCSegm( panel->GetClipBox(), DC, m_featureLineGO + offset, - m_featureLineGF + offset, width, gcolor ); - GRCSegm( panel->GetClipBox(), DC, m_featureLineDO + offset, - m_featureLineDF + offset, width, gcolor ); - GRCSegm( panel->GetClipBox(), DC, m_crossBarF + offset, - m_arrowD1F + offset, width, gcolor ); - GRCSegm( panel->GetClipBox(), DC, m_crossBarF + offset, - m_arrowD2F + offset, width, gcolor ); - GRCSegm( panel->GetClipBox(), DC, m_crossBarO + offset, - m_arrowG1F + offset, width, gcolor ); - GRCSegm( panel->GetClipBox(), DC, m_crossBarO + offset, - m_arrowG2F + offset, width, gcolor ); + GRCSegm( nullptr, DC, m_crossBarO + offset, m_crossBarF + offset, width, gcolor ); + GRCSegm( nullptr, DC, m_featureLineGO + offset, m_featureLineGF + offset, width, gcolor ); + GRCSegm( nullptr, DC, m_featureLineDO + offset, m_featureLineDF + offset, width, gcolor ); + GRCSegm( nullptr, DC, m_crossBarF + offset, m_arrowD1F + offset, width, gcolor ); + GRCSegm( nullptr, DC, m_crossBarF + offset, m_arrowD2F + offset, width, gcolor ); + GRCSegm( nullptr, DC, m_crossBarO + offset, m_arrowG1F + offset, width, gcolor ); + GRCSegm( nullptr, DC, m_crossBarO + offset, m_arrowG2F + offset, width, gcolor ); } } diff --git a/pcbnew/class_dimension.h b/pcbnew/class_dimension.h index 4121cccd48..51215ec1de 100644 --- a/pcbnew/class_dimension.h +++ b/pcbnew/class_dimension.h @@ -36,7 +36,6 @@ class LINE_READER; -class EDA_DRAW_PANEL; class TEXTE_PCB; class MSG_PANEL_ITEM; @@ -200,17 +199,14 @@ public: TEXTE_PCB& Text() { return m_Text; } TEXTE_PCB& Text() const { return *(const_cast (&m_Text)); } - void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, - GR_DRAWMODE aColorMode, const wxPoint& offset = ZeroOffset ) override; + void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset = ZeroOffset ) override; /** * Function Move * @param offset : moving vector */ void Move( const wxPoint& offset ) override; - void Rotate( const wxPoint& aRotCentre, double aAngle ) override; - void Flip( const wxPoint& aCentre ) override; /** diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index ee68895a29..14e5ff89e6 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -335,32 +335,20 @@ MODULE* DRAWSEGMENT::GetParentModule() const } -void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, - const wxPoint& aOffset ) +void DRAWSEGMENT::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& aOffset ) { int ux0, uy0, dx, dy; int l_trace; int radius; - PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; - - BOARD * brd = GetBoard( ); + BOARD* brd = GetBoard( ); if( brd->IsLayerVisible( GetLayer() ) == false ) return; - auto frame = static_cast ( panel->GetParent() ); - auto color = frame->Settings().Colors().GetLayerColor( GetLayer() ); + auto color = aFrame->Settings().Colors().GetLayerColor( GetLayer() ); + auto displ_opts = (PCB_DISPLAY_OPTIONS*) aFrame->GetDisplayOptions(); - auto displ_opts = (PCB_DISPLAY_OPTIONS*) panel->GetDisplayOptions(); - - if( ( draw_mode & GR_ALLOW_HIGHCONTRAST ) && displ_opts && displ_opts->m_ContrastModeDisplay ) - { - if( !IsOnLayer( curr_layer ) && !IsOnLayer( Edge_Cuts ) ) - color = COLOR4D( DARKDARKGRAY ); - } - - GRSetDrawMode( DC, draw_mode ); l_trace = m_Width >> 1; // half trace width // Line start point or Circle and Arc center @@ -383,12 +371,12 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, if( filled ) { - GRCircle( panel->GetClipBox(), DC, ux0, uy0, radius, m_Width, color ); + GRCircle( nullptr, DC, ux0, uy0, radius, m_Width, color ); } else { - GRCircle( panel->GetClipBox(), DC, ux0, uy0, radius - l_trace, color ); - GRCircle( panel->GetClipBox(), DC, ux0, uy0, radius + l_trace, color ); + GRCircle( nullptr, DC, ux0, uy0, radius - l_trace, color ); + GRCircle( nullptr, DC, ux0, uy0, radius + l_trace, color ); } break; @@ -399,33 +387,17 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, StAngle = ArcTangente( dy - uy0, dx - ux0 ); EndAngle = StAngle + m_Angle; - if( !panel->GetPrintMirrored() ) - { - if( StAngle > EndAngle ) - std::swap( StAngle, EndAngle ); - } - else // Mirrored mode: arc orientation is reversed - { -#ifdef __WXMAC__ // wxWidgets OSX print driver handles arc mirroring for us - if( StAngle > EndAngle ) - std::swap( StAngle, EndAngle ); -#else - if( StAngle < EndAngle ) - std::swap( StAngle, EndAngle ); -#endif - } + if( StAngle > EndAngle ) + std::swap( StAngle, EndAngle ); if( filled ) { - GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle, - radius, m_Width, color ); + GRArc( nullptr, DC, ux0, uy0, StAngle, EndAngle, radius, m_Width, color ); } else { - GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle, - radius - l_trace, color ); - GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle, - radius + l_trace, color ); + GRArc( nullptr, DC, ux0, uy0, StAngle, EndAngle, radius - l_trace, color ); + GRArc( nullptr, DC, ux0, uy0, StAngle, EndAngle, radius + l_trace, color ); } break; @@ -441,11 +413,9 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, wxPoint& endp = m_BezierPoints[i]; if( filled ) - GRFilledSegment( panel->GetClipBox(), DC, - startp+aOffset, endp+aOffset, m_Width, color ); + GRFilledSegment( nullptr, DC, startp+aOffset, endp+aOffset, m_Width, color ); else - GRCSegm( panel->GetClipBox(), DC, - startp+aOffset, endp+aOffset, m_Width, color ); + GRCSegm( nullptr, DC, startp+aOffset, endp+aOffset, m_Width, color ); startp = m_BezierPoints[i]; } @@ -461,22 +431,17 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, for( int jj = 0; jj < outline.OutlineCount(); ++jj ) { SHAPE_LINE_CHAIN& poly = outline.Outline( jj ); - GRClosedPoly( panel->GetClipBox(), DC, poly.PointCount(), - (wxPoint*)&poly.Point( 0 ), IsPolygonFilled(), GetWidth(), - color, color ); + GRClosedPoly( nullptr, DC, poly.PointCount(), (wxPoint*)&poly.Point( 0 ), + IsPolygonFilled(), GetWidth(), color, color ); } } break; default: if( filled ) - { - GRFillCSegm( panel->GetClipBox(), DC, ux0, uy0, dx, dy, m_Width, color ); - } + GRFillCSegm( nullptr, DC, ux0, uy0, dx, dy, m_Width, color ); else - { - GRCSegm( panel->GetClipBox(), DC, ux0, uy0, dx, dy, m_Width, color ); - } + GRCSegm( nullptr, DC, ux0, uy0, dx, dy, m_Width, color ); break; } diff --git a/pcbnew/class_drawsegment.h b/pcbnew/class_drawsegment.h index dbea975d65..ef5a307055 100644 --- a/pcbnew/class_drawsegment.h +++ b/pcbnew/class_drawsegment.h @@ -212,8 +212,7 @@ public: void SetPolyPoints( const std::vector& aPoints ); - void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMode, - const wxPoint& aOffset = ZeroOffset ) override; + void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& aOffset = ZeroOffset ) override; void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector& aList ) override; diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index e5a1edab6b..de5643d03c 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -118,33 +118,17 @@ void EDGE_MODULE::SetDrawCoord() } -void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, - const wxPoint& offset ) +void EDGE_MODULE::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset ) { - int ux0, uy0, dx, dy, radius, StAngle, EndAngle; - PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; - + int ux0, uy0, dx, dy, radius, StAngle, EndAngle; MODULE* module = (MODULE*) m_Parent; + BOARD* brd = GetBoard( ); - if( !module ) + if( !module || !brd->IsLayerVisible( m_Layer ) ) return; - BOARD* brd = GetBoard( ); - - if( brd->IsLayerVisible( m_Layer ) == false ) - return; - - - auto frame = static_cast ( panel->GetParent() ); - auto color = frame->Settings().Colors().GetLayerColor( m_Layer ); - - auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() ); - - if(( draw_mode & GR_ALLOW_HIGHCONTRAST ) && displ_opts && displ_opts->m_ContrastModeDisplay ) - { - if( !IsOnLayer( curr_layer ) ) - color = COLOR4D( DARKDARKGRAY ); - } + auto color = aFrame->Settings().Colors().GetLayerColor( m_Layer ); + auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aFrame->GetDisplayOptions() ); ux0 = m_Start.x - offset.x; uy0 = m_Start.y - offset.y; @@ -152,7 +136,6 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, dx = m_End.x - offset.x; dy = m_End.y - offset.y; - GRSetDrawMode( DC, draw_mode ); bool filled = displ_opts ? displ_opts->m_DisplayModEdgeFill : FILLED; if( IsCopperLayer( m_Layer ) ) @@ -162,10 +145,10 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, { case S_SEGMENT: if( filled ) - GRLine( panel->GetClipBox(), DC, ux0, uy0, dx, dy, m_Width, color ); + GRLine( nullptr, DC, ux0, uy0, dx, dy, m_Width, color ); else // SKETCH Mode - GRCSegm( panel->GetClipBox(), DC, ux0, uy0, dx, dy, m_Width, color ); + GRCSegm( nullptr, DC, ux0, uy0, dx, dy, m_Width, color ); break; @@ -174,12 +157,12 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, if( filled ) { - GRCircle( panel->GetClipBox(), DC, ux0, uy0, radius, m_Width, color ); + GRCircle( nullptr, DC, ux0, uy0, radius, m_Width, color ); } else // SKETCH Mode { - GRCircle( panel->GetClipBox(), DC, ux0, uy0, radius + (m_Width / 2), color ); - GRCircle( panel->GetClipBox(), DC, ux0, uy0, radius - (m_Width / 2), color ); + GRCircle( nullptr, DC, ux0, uy0, radius + (m_Width / 2), color ); + GRCircle( nullptr, DC, ux0, uy0, radius - (m_Width / 2), color ); } break; @@ -189,27 +172,17 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, StAngle = ArcTangente( dy - uy0, dx - ux0 ); EndAngle = StAngle + m_Angle; - if( !panel->GetPrintMirrored() ) - { - if( StAngle > EndAngle ) - std::swap( StAngle, EndAngle ); - } - else // Mirrored mode: arc orientation is reversed - { - if( StAngle < EndAngle ) - std::swap( StAngle, EndAngle ); - } + if( StAngle > EndAngle ) + std::swap( StAngle, EndAngle ); if( filled ) { - GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle, radius, m_Width, color ); + GRArc( nullptr, DC, ux0, uy0, StAngle, EndAngle, radius, m_Width, color ); } else // SKETCH Mode { - GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle, - radius + (m_Width / 2), color ); - GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle, - radius - (m_Width / 2), color ); + GRArc( nullptr, DC, ux0, uy0, StAngle, EndAngle, radius + (m_Width / 2), color ); + GRArc( nullptr, DC, ux0, uy0, StAngle, EndAngle, radius - (m_Width / 2), color ); } break; @@ -235,7 +208,7 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, pt += module->GetPosition() - offset; } - GRPoly( panel->GetClipBox(), DC, points.size(), &points[0], true, m_Width, color, color ); + GRPoly( nullptr, DC, points.size(), &points[0], true, m_Width, color, color ); } break; @@ -250,11 +223,9 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, wxPoint& endp = m_BezierPoints[i]; if( filled ) - GRFilledSegment( panel->GetClipBox(), DC, - startp-offset, endp-offset, m_Width, color ); + GRFilledSegment( nullptr, DC, startp-offset, endp-offset, m_Width, color ); else - GRCSegm( panel->GetClipBox(), DC, - startp-offset, endp-offset, m_Width, color ); + GRCSegm( nullptr, DC, startp-offset, endp-offset, m_Width, color ); startp = m_BezierPoints[i]; } diff --git a/pcbnew/class_edge_mod.h b/pcbnew/class_edge_mod.h index 437ffd38ff..b4db28a8f3 100644 --- a/pcbnew/class_edge_mod.h +++ b/pcbnew/class_edge_mod.h @@ -117,9 +117,7 @@ public: */ void SetDrawCoord(); - /* drawing functions */ - void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, - GR_DRAWMODE aDrawMode, const wxPoint& offset = ZeroOffset ) override; + void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset = ZeroOffset ) override; void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; diff --git a/pcbnew/class_marker_pcb.h b/pcbnew/class_marker_pcb.h index 428db22fd5..ac03bd58ed 100644 --- a/pcbnew/class_marker_pcb.h +++ b/pcbnew/class_marker_pcb.h @@ -88,10 +88,9 @@ public: void Flip( const wxPoint& aCentre ) override; - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - GR_DRAWMODE aDrawMode, const wxPoint& aOffset = ZeroOffset ) override + void Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset = ZeroOffset ) override { - DrawMarker( aPanel, aDC, aOffset ); + PrintMarker( aDC, aOffset ); } const wxPoint GetPosition() const override { return m_Pos; } diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index eb44ddf232..96d667f0ff 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -234,22 +234,6 @@ void MODULE::ClearAllNets() } -void MODULE::DrawAncre( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, - int dim_ancre, GR_DRAWMODE draw_mode ) -{ - auto frame = (PCB_EDIT_FRAME*) panel->GetParent(); - - GRSetDrawMode( DC, draw_mode ); - - if( GetBoard()->IsElementVisible( LAYER_ANCHOR ) ) - { - GRDrawAnchor( panel->GetClipBox(), DC, m_Pos.x, m_Pos.y, - dim_ancre, - frame->Settings().Colors().GetItemColor( LAYER_ANCHOR ) ); - } -} - - void MODULE::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode ) { switch( aBoardItem->Type() ) @@ -365,72 +349,27 @@ void MODULE::CopyNetlistSettings( MODULE* aModule, bool aCopyLocalSettings ) } -void MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, - const wxPoint& aOffset ) +void MODULE::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset ) { - if( (m_Flags & DO_NOT_DRAW) || (IsMoving()) ) - return; - for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) - { - if( pad->IsMoving() ) - continue; - - pad->Draw( aPanel, aDC, aDrawMode, aOffset ); - } + pad->Print( aFrame, aDC, aOffset ); BOARD* brd = GetBoard(); - // Draws footprint anchor - DrawAncre( aPanel, aDC, aOffset, DIM_ANCRE_MODULE, aDrawMode ); - // Draw graphic items if( brd->IsElementVisible( LAYER_MOD_REFERENCES ) ) - { - if( !(m_Reference->IsMoving()) ) - m_Reference->Draw( aPanel, aDC, aDrawMode, aOffset ); - } + m_Reference->Print( aFrame, aDC, aOffset ); if( brd->IsElementVisible( LAYER_MOD_VALUES ) ) - { - if( !(m_Value->IsMoving()) ) - m_Value->Draw( aPanel, aDC, aDrawMode, aOffset ); - } + m_Value->Print( aFrame, aDC, aOffset ); for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() ) { - if( item->IsMoving() ) - continue; - switch( item->Type() ) { case PCB_MODULE_TEXT_T: case PCB_MODULE_EDGE_T: - item->Draw( aPanel, aDC, aDrawMode, aOffset ); - break; - - default: - break; - } - } - - // Enable these line to draw m_BoundaryBox (debug tests purposes only) -#if 0 - GRRect( aPanel->GetClipBox(), aDC, m_BoundaryBox, 0, BROWN ); -#endif - -} - - -void MODULE::DrawEdgesOnly( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, - GR_DRAWMODE draw_mode ) -{ - for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() ) - { - switch( item->Type() ) - { - case PCB_MODULE_EDGE_T: - item->Draw( panel, DC, draw_mode, offset ); + item->Print( aFrame, aDC, aOffset ); break; default: diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index db96200eae..599b7ee014 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -50,7 +50,6 @@ class LINE_READER; class EDA_3D_CANVAS; -class EDA_DRAW_PANEL; class D_PAD; class BOARD; class MSG_PANEL_ITEM; @@ -318,17 +317,13 @@ public: /* drawing functions */ /** - * Function Draw - * draws the footprint to the \a aDC. - * @param aPanel = draw panel, Used to know the clip box + * Function Print + * Prints the footprint to the \a aDC. + * @param aFrame = the current Frame * @param aDC = Current Device Context - * @param aDrawMode = GR_OR, GR_XOR.. * @param aOffset = draw offset (usually wxPoint(0,0) */ - void Draw( EDA_DRAW_PANEL* aPanel, - wxDC* aDC, - GR_DRAWMODE aDrawMode, - const wxPoint& aOffset = ZeroOffset ) override; + void Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset = ZeroOffset ) override; /** * function TransformPadsShapesWithClearanceToPolygon @@ -382,26 +377,6 @@ public: void TransformGraphicTextWithClearanceToPolygonSet( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aCornerBuffer, int aInflateValue, int aError = ARC_HIGH_DEF ) const; - /** - * Function DrawEdgesOnly - * Draws the footprint edges only to the current Device Context - * @param panel = The active Draw Panel (used to know the clip box) - * @param DC = current Device Context - * @param offset = draw offset (usually wxPoint(0,0) - * @param draw_mode = GR_OR, GR_XOR, GR_AND - */ - void DrawEdgesOnly( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, - GR_DRAWMODE draw_mode ); - - /** - * Function DrawAncre - * Draw the anchor cross (vertical) - * Must be done after the pads, because drawing the hole will erase overwrite - * every thing already drawn. - */ - void DrawAncre( EDA_DRAW_PANEL* panel, wxDC* DC, - const wxPoint& offset, int dim_ancre, GR_DRAWMODE draw_mode ); - ///> @copydoc EDA_ITEM::GetMsgPanelInfo void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector& aList ) override; @@ -476,8 +451,7 @@ public: * returns a D_PAD* with a matching name. Note that names may not be * unique, depending on how the foot print was created. * @param aPadName the pad name to find - * @return D_PAD* - The first matching name is returned, or NULL if not - * found. + * @return D_PAD* - The first matching name is returned, or NULL if not found. */ D_PAD* FindPadByName( const wxString& aPadName ) const; @@ -521,8 +495,8 @@ public: * Function GetNextPadName * returns the next available pad name in the module * - * @param aFillSequenceGaps true if the numbering should "fill in" gaps in - * the sequence, else return the highest value + 1 + * @param aFillSequenceGaps true if the numbering should "fill in" gaps in the sequence, + * else return the highest value + 1 * @return the next available pad name */ wxString GetNextPadName( bool aFillSequenceGaps ) const; @@ -606,7 +580,6 @@ public: * * @param aModule is the #MODULE to copy the settings to. * @param aCopyLocalSettings = false to copy only module placement - * true to also copy local prms */ void CopyNetlistSettings( MODULE* aModule, bool aCopyLocalSettings ); @@ -632,17 +605,16 @@ public: /** * Function SetInitialComments * takes ownership of caller's heap allocated aInitialComments block. The comments - * are single line strings already containing the s-expression comments with - * optional leading whitespace and then a '#' character followed by optional - * single line text (text with no line endings, not even one). + * are single line strings already containing the s-expression comments with optional + * leading whitespace and then a '#' character followed by optional single line text + * (text with no line endings, not even one). * This block of single line comments will be output upfront of any generated * s-expression text in the PCBIO::Format() function. *

- * Note that a block of single line comments constitutes a multiline block of - * single line comments. That is, the block is made of consecutive single line - * comments. + * Note that a block of single line comments constitutes a multiline block of single + * line comments. That is, the block is made of consecutive single line comments. * @param aInitialComments is a heap allocated wxArrayString or NULL, which the caller - * gives up ownership of over to this MODULE. + * gives up ownership of over to this MODULE. */ void SetInitialComments( wxArrayString* aInitialComments ) { diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 210972a4be..16c57a7e58 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -64,8 +64,6 @@ namespace KIGFX class PAD_DRAWINFO { public: - EDA_DRAW_PANEL* m_DrawPanel; // the EDA_DRAW_PANEL used to draw a PAD ; can be null - GR_DRAWMODE m_DrawMode; // the draw mode COLOR4D m_Color; // color used to draw the pad shape , from pad layers and // visible layers COLOR4D m_HoleColor; // color used to draw the pad hole @@ -501,21 +499,17 @@ public: void SetThermalGap( int aGap ) { m_ThermalGap = aGap; } int GetThermalGap() const; - /* drawing functions */ - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - GR_DRAWMODE aDrawMode, const wxPoint& aOffset = ZeroOffset ) override; + void Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset = ZeroOffset ) override; /** - * Function DrawShape - * basic function to draw a pad. + * Function PrintShape + * basic function to print a pad. *

- * This function is used by Draw after calculation of parameters (color, ) final - * orientation transforms are set. It can also be called to draw a pad on any panel - * even if this panel is not a EDA_DRAW_PANEL for instance on a wxPanel inside the - * pad editor. + * This function is used by Print after calculation of parameters (color, ) final + * orientation transforms are set. *

*/ - void DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ); + void PrintShape( wxDC* aDC, PAD_DRAWINFO& aDrawInfo ); /** * Function BuildPadPolygon diff --git a/pcbnew/class_pcb_target.cpp b/pcbnew/class_pcb_target.cpp index fea5c2e273..17e0e7dec7 100644 --- a/pcbnew/class_pcb_target.cpp +++ b/pcbnew/class_pcb_target.cpp @@ -71,12 +71,11 @@ PCB_TARGET::~PCB_TARGET() } -/* Draw PCB_TARGET object: 2 segments + 1 circle +/* Print PCB_TARGET object: 2 segments + 1 circle * The circle radius is half the radius of the target * 2 lines have length the diameter of the target */ -void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, - const wxPoint& offset ) +void PCB_TARGET::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset ) { int radius, ox, oy, width; int dx1, dx2, dy1, dy2; @@ -84,18 +83,15 @@ void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, ox = m_Pos.x + offset.x; oy = m_Pos.y + offset.y; - BOARD * brd = GetBoard( ); + BOARD* brd = GetBoard( ); if( brd->IsLayerVisible( m_Layer ) == false ) return; - auto frame = static_cast ( panel->GetParent() ); - auto gcolor = frame->Settings().Colors().GetLayerColor( m_Layer ); - - GRSetDrawMode( DC, mode_color ); - auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() ); + auto gcolor = aFrame->Settings().Colors().GetLayerColor( m_Layer ); + auto displ_opts = (PCB_DISPLAY_OPTIONS*) aFrame->GetDisplayOptions(); bool filled = displ_opts ? displ_opts->m_DisplayDrawItemsFill : FILLED; - width = m_Width; + width = m_Width; radius = m_Size / 3; @@ -103,11 +99,11 @@ void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, radius = m_Size / 2; if( filled ) - GRCircle( panel->GetClipBox(), DC, ox, oy, radius, width, gcolor ); + GRCircle( nullptr, DC, ox, oy, radius, width, gcolor ); else { - GRCircle( panel->GetClipBox(), DC, ox, oy, radius + (width / 2), gcolor ); - GRCircle( panel->GetClipBox(), DC, ox, oy, radius - (width / 2), gcolor ); + GRCircle( nullptr, DC, ox, oy, radius + (width / 2), gcolor ); + GRCircle( nullptr, DC, ox, oy, radius - (width / 2), gcolor ); } @@ -126,13 +122,13 @@ void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, if( filled ) { - GRLine( panel->GetClipBox(), DC, ox - dx1, oy - dy1, ox + dx1, oy + dy1, width, gcolor ); - GRLine( panel->GetClipBox(), DC, ox - dx2, oy - dy2, ox + dx2, oy + dy2, width, gcolor ); + GRLine( nullptr, DC, ox - dx1, oy - dy1, ox + dx1, oy + dy1, width, gcolor ); + GRLine( nullptr, DC, ox - dx2, oy - dy2, ox + dx2, oy + dy2, width, gcolor ); } else { - GRCSegm( panel->GetClipBox(), DC, ox - dx1, oy - dy1, ox + dx1, oy + dy1, width, gcolor ); - GRCSegm( panel->GetClipBox(), DC, ox - dx2, oy - dy2, ox + dx2, oy + dy2, width, gcolor ); + GRCSegm( nullptr, DC, ox - dx1, oy - dy1, ox + dx1, oy + dy1, width, gcolor ); + GRCSegm( nullptr, DC, ox - dx2, oy - dy2, ox + dx2, oy + dy2, width, gcolor ); } } diff --git a/pcbnew/class_pcb_target.h b/pcbnew/class_pcb_target.h index 80cda78ca5..bd4d7780f5 100644 --- a/pcbnew/class_pcb_target.h +++ b/pcbnew/class_pcb_target.h @@ -35,7 +35,6 @@ class EDA_RECT; class LINE_READER; -class EDA_DRAW_PANEL; class PCB_TARGET : public BOARD_ITEM @@ -84,8 +83,7 @@ public: void Flip( const wxPoint& aCentre ) override; - void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, - GR_DRAWMODE aDrawMode, const wxPoint& offset = ZeroOffset ) override; + void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset = ZeroOffset ) override; wxString GetClass() const override { diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index 9158b58b3a..bc0f26464d 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include @@ -65,52 +65,21 @@ void TEXTE_PCB::SetTextAngle( double aAngle ) } -void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, - GR_DRAWMODE DrawMode, const wxPoint& offset ) +void TEXTE_PCB::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset ) { - wxASSERT( panel ); - - if( !panel ) - return; - BOARD* brd = GetBoard(); if( brd->IsLayerVisible( m_Layer ) == false ) return; - auto frame = static_cast( panel->GetParent() ); - auto color = frame->Settings().Colors().GetLayerColor( m_Layer ); - - EDA_DRAW_MODE_T fillmode = FILLED; - PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() ); + auto color = aFrame->Settings().Colors().GetLayerColor( m_Layer ); + EDA_DRAW_MODE_T fillmode = FILLED; + PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*)( aFrame->GetDisplayOptions() ); if( displ_opts && displ_opts->m_DisplayDrawItemsFill == SKETCH ) fillmode = SKETCH; - // shade text if high contrast mode is active - if( ( DrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts && displ_opts->m_ContrastModeDisplay ) - { - PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; - - if( !IsOnLayer( curr_layer ) ) - color = COLOR4D( DARKDARKGRAY ); - } - - COLOR4D anchor_color = COLOR4D::UNSPECIFIED; - - if( brd->IsElementVisible( LAYER_ANCHOR ) ) - anchor_color = frame->Settings().Colors().GetItemColor( LAYER_ANCHOR ); - - EDA_TEXT::Draw( panel->GetClipBox(), DC, offset, color, - DrawMode, fillmode, anchor_color ); - - // Enable these line to draw the bounding box (debug tests purposes only) -#if 0 - { - EDA_RECT BoundaryBox = GetBoundingBox(); - GRRect( clipbox, DC, BoundaryBox, 0, BROWN ); - } -#endif + EDA_TEXT::Print( DC, offset, color, fillmode ); } diff --git a/pcbnew/class_pcb_text.h b/pcbnew/class_pcb_text.h index 423d3017bf..5a257fe2be 100644 --- a/pcbnew/class_pcb_text.h +++ b/pcbnew/class_pcb_text.h @@ -35,7 +35,6 @@ class LINE_READER; -class EDA_DRAW_PANEL; class MSG_PANEL_ITEM; @@ -75,8 +74,7 @@ public: void Flip( const wxPoint& aCentre ) override; - void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, - GR_DRAWMODE aDrawMode, const wxPoint& offset = ZeroOffset ) override; + void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset = ZeroOffset ) override; void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index e209be8b75..0bcdc6a7e5 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include @@ -263,22 +263,14 @@ const EDA_RECT TEXTE_MODULE::GetBoundingBox() const } -void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, - const wxPoint& aOffset ) +void TEXTE_MODULE::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset ) { - if( aPanel == NULL ) - return; - - /* parent must *not* be NULL (a footprint text without a footprint - parent has no sense) */ + /* parent must *not* be NULL (a footprint text without a footprint parent has no sense) */ wxASSERT( m_Parent ); - BOARD* brd = GetBoard( ); - - auto frame = static_cast ( aPanel->GetParent() ); - auto color = frame->Settings().Colors().GetLayerColor( GetLayer() ); - - PCB_LAYER_ID text_layer = GetLayer(); + BOARD* brd = GetBoard( ); + KIGFX::COLOR4D color = aFrame->Settings().Colors().GetLayerColor( GetLayer() ); + PCB_LAYER_ID text_layer = GetLayer(); if( !brd->IsLayerVisible( m_Layer ) || ( IsFrontLayer( text_layer ) && !brd->IsElementVisible( LAYER_MOD_TEXT_FR ) ) @@ -298,19 +290,10 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMod if( !brd->IsElementVisible( LAYER_MOD_TEXT_INVISIBLE ) ) return; - color = frame->Settings().Colors().GetItemColor( LAYER_MOD_TEXT_INVISIBLE ); + color = aFrame->Settings().Colors().GetItemColor( LAYER_MOD_TEXT_INVISIBLE ); } - auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aPanel->GetDisplayOptions() ); - - // shade text if high contrast mode is active - if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts && displ_opts->m_ContrastModeDisplay ) - { - PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) aPanel->GetScreen() )->m_Active_Layer; - - if( !IsOnLayer( curr_layer ) ) - color = COLOR4D( DARKDARKGRAY ); - } + auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aFrame->GetDisplayOptions() ); // Draw mode compensation for the width int width = GetThickness(); @@ -318,16 +301,8 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMod if( displ_opts && displ_opts->m_DisplayModTextFill == SKETCH ) width = -width; - GRSetDrawMode( aDC, aDrawMode ); wxPoint pos = GetTextPos() - aOffset; - // Draw the text anchor point - if( brd->IsElementVisible( LAYER_ANCHOR ) ) - { - COLOR4D anchor_color = frame->Settings().Colors().GetItemColor( LAYER_ANCHOR ); - GRDrawAnchor( aPanel->GetClipBox(), aDC, pos.x, pos.y, DIM_ANCRE_TEXTE, anchor_color ); - } - // Draw the text proper, with the right attributes wxSize size = GetTextSize(); double orient = GetDrawRotation(); @@ -336,34 +311,8 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMod if( IsMirrored() ) size.x = -size.x; - DrawGraphicText( aPanel->GetClipBox(), aDC, pos, color, GetShownText(), orient, - size, GetHorizJustify(), GetVertJustify(), - width, IsItalic(), IsBold() ); - - // Enable these line to draw the bounding box (debug test purpose only) -#if 0 - { - EDA_RECT BoundaryBox = GetBoundingBox(); - GRRect( aPanel->GetClipBox(), aDC, BoundaryBox, 0, BROWN ); - } -#endif -} - - -void TEXTE_MODULE::DrawUmbilical( EDA_DRAW_PANEL* aPanel, - wxDC* aDC, - GR_DRAWMODE aDrawMode, - const wxPoint& aOffset ) -{ - MODULE* parent = static_cast( GetParent() ); - - if( !parent ) - return; - - GRSetDrawMode( aDC, GR_XOR ); - GRLine( aPanel->GetClipBox(), aDC, - parent->GetPosition(), GetTextPos() + aOffset, - 0, UMBILICAL_COLOR); + GRText( aDC, pos, color, GetShownText(), orient, size, GetHorizJustify(), GetVertJustify(), + width, IsItalic(), IsBold() ); } diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index 53ec61975e..fa994be25f 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -38,9 +38,9 @@ class LINE_READER; class EDA_RECT; -class EDA_DRAW_PANEL; class MODULE; class MSG_PANEL_ITEM; +class PCB_BASE_FRAME; #define UMBILICAL_COLOR LIGHTBLUE @@ -177,31 +177,13 @@ public: /* drawing functions */ /** - * Function Draw - * Draw the text according to the footprint pos and orient - * @param aPanel = draw panel, Used to know the clip box + * Function Print + * Print the text according to the footprint pos and orient + * @param aFrame = the current Frame * @param aDC = Current Device Context * @param aOffset = draw offset (usually wxPoint(0,0) - * @param aDrawMode = GR_OR, GR_XOR.. */ - void Draw( EDA_DRAW_PANEL* aPanel, - wxDC* aDC, - GR_DRAWMODE aDrawMode, - const wxPoint& aOffset = ZeroOffset ) override; - - /** - * Function DrawUmbilical - * draws a line from the TEXTE_MODULE origin - * to parent MODULE origin. - * @param aPanel = the current DrawPanel - * @param aDC = the current device context - * @param aDrawMode = drawing mode, typically GR_XOR - * @param aOffset = offset for TEXTE_MODULE - */ - void DrawUmbilical( EDA_DRAW_PANEL* aPanel, - wxDC* aDC, - GR_DRAWMODE aDrawMode, - const wxPoint& aOffset = ZeroOffset ); + void Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset = ZeroOffset ) override; void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index a780e3be10..9fc790d176 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include @@ -503,158 +503,34 @@ TRACK* TRACK::GetEndNetCode( int NetCode ) return NULL; } -void TRACK::DrawShortNetname( EDA_DRAW_PANEL* panel, - wxDC* aDC, GR_DRAWMODE aDrawMode, COLOR4D aBgColor ) -{ - if( ! panel ) - return; - - /* we must filter tracks, to avoid a lot of texts. - * - only tracks with a length > 10 * thickness are eligible - * and, of course, if we are not printing the board - */ - auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() ); - - if( displ_opts->m_DisplayNetNamesMode == 0 || displ_opts->m_DisplayNetNamesMode == 1 ) - return; - - #define THRESHOLD 10 - - int len = KiROUND( GetLineLength( m_Start, m_End ) ); - - if( len < THRESHOLD * m_Width ) - return; - - // no room to display a text inside track - if( aDC->LogicalToDeviceXRel( m_Width ) < MIN_TEXT_SIZE ) - return; - - if( GetNetCode() == NETINFO_LIST::UNCONNECTED ) - return; - - NETINFO_ITEM* net = GetNet(); - - if( net == NULL ) - return; - - wxString text = UnescapeString( net->GetShortNetname() ); - int textlen = text.Len(); - - if( textlen > 0 ) - { - // calculate a good size for the text - int tsize = std::min( m_Width, len / textlen ); - int dx = m_End.x - m_Start.x ; - int dy = m_End.y - m_Start.y ; - wxPoint tpos = m_Start + m_End; - tpos.x /= 2; - tpos.y /= 2; - - // Calculate angle: if the track segment is vertical, angle = 90 degrees - // If horizontal 0 degrees, otherwise compute it - double angle; // angle is in 0.1 degree - - if( dy == 0 ) // Horizontal segment - { - angle = 0; - } - else - { - if( dx == 0 ) // Vertical segment - { - angle = 900; - } - else - { - /* atan2 is *not* the solution here, since it can give upside - down text. We want to work only in the first and fourth quadrant */ - angle = RAD2DECIDEG( -atan( double( dy ) / double( dx ) ) ); - } - } - - PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; - - if( ( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE ) - && ( !(!IsOnLayer( curr_layer )&& displ_opts->m_ContrastModeDisplay) ) ) - { - if( (aDrawMode & GR_XOR) == 0 ) - GRSetDrawMode( aDC, GR_COPY ); - - tsize = (tsize * 7) / 10; // small reduction to give a better look - DrawGraphicHaloText( panel->GetClipBox(), aDC, tpos, - aBgColor, BLACK, WHITE, - text, angle, wxSize( tsize, tsize ), - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, - tsize / 7, false, false ); - } - } -} - - -void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, - const wxPoint& aOffset ) +void TRACK::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset ) { BOARD* brd = GetBoard(); + auto color = aFrame->Settings().Colors().GetLayerColor( m_Layer ); - auto frame = static_cast ( panel->GetParent() ); - auto color = frame->Settings().Colors().GetLayerColor( m_Layer ); - - if( ( !brd->IsLayerVisible( m_Layer ) || !brd->IsElementVisible( LAYER_TRACKS ) ) - && !( aDrawMode & GR_HIGHLIGHT ) ) + if( !brd->IsLayerVisible( m_Layer ) || !brd->IsElementVisible( LAYER_TRACKS ) ) return; -#ifdef USE_WX_OVERLAY - // If dragged not draw in OnPaint otherwise remains impressed in wxOverlay - if( (m_Flags & IS_DRAGGED) && aDC->IsKindOf(wxCLASSINFO(wxPaintDC))) - return; -#endif - - auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() ); - - if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts->m_ContrastModeDisplay ) - { - PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; - - if( !IsOnLayer( curr_layer ) ) - color = COLOR4D( DARKDARKGRAY ); - } - - if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) ) - color.SetToLegacyHighlightColor(); + auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aFrame->GetDisplayOptions() ); color.a = 0.588; - GRSetDrawMode( aDC, aDrawMode ); - // Draw track as line if width <= 1pixel: if( aDC->LogicalToDeviceXRel( m_Width ) <= 1 ) { - GRLine( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color ); + GRLine( nullptr, aDC, m_Start + aOffset, m_End + aOffset, m_Width, color ); return; } if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) ) { - GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color ); + GRCSegm( nullptr, aDC, m_Start + aOffset, m_End + aOffset, m_Width, color ); } else { - GRFillCSegm( panel->GetClipBox(), aDC, m_Start.x + aOffset.x, - m_Start.y + aOffset.y, + GRFillCSegm( nullptr, aDC, m_Start.x + aOffset.x, m_Start.y + aOffset.y, m_End.x + aOffset.x, m_End.y + aOffset.y, m_Width, color ); } - - if( panel->GetScreen()->m_IsPrinting ) - return; - - // Show clearance for tracks, not for zone segments - if( ShowClearance( displ_opts, this ) ) - { - GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, - m_Width + (GetClearance() * 2), color ); - } - - DrawShortNetname( panel, aDC, aDrawMode, color ); } @@ -693,57 +569,36 @@ const BOX2I TRACK::ViewBBox() const } -void VIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aOffset ) +void VIA::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset ) { - wxCHECK_RET( panel != NULL, wxT( "VIA::Draw panel cannot be NULL." ) ); - - int radius; - PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; - - int fillvia = 0; - PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent(); - PCB_SCREEN* screen = frame->GetScreen(); - auto displ_opts = (PCB_DISPLAY_OPTIONS*)( frame->GetDisplayOptions() ); + int radius; + int fillvia = 0; + PCB_SCREEN* screen = aFrame->GetScreen(); + PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) aFrame->GetDisplayOptions(); + BOARD* brd = GetBoard(); + COLOR4D color = aFrame->Settings().Colors().GetItemColor( LAYER_VIAS + GetViaType() ); if( displ_opts->m_DisplayViaFill == FILLED ) fillvia = 1; - GRSetDrawMode( aDC, aDrawMode ); - - BOARD * brd = GetBoard(); - COLOR4D color = frame->Settings().Colors().GetItemColor( LAYER_VIAS + GetViaType() ); - - if( brd->IsElementVisible( LAYER_VIAS + GetViaType() ) == false - && !( aDrawMode & GR_HIGHLIGHT ) ) + if( !brd->IsElementVisible( LAYER_VIAS + GetViaType() ) ) return; // Only draw the via if at least one of the layers it crosses is being displayed if( !( brd->GetVisibleLayers() & GetLayerSet() ).any() ) return; - if( displ_opts->m_ContrastModeDisplay ) - { - if( !IsOnLayer( curr_layer ) ) - color = COLOR4D( DARKDARKGRAY ); - } - - if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) ) - color.SetToLegacyHighlightColor(); - color.a = 0.588; - radius = m_Width >> 1; // for small via size on screen (radius < 4 pixels) draw a simplified shape - int radius_in_pixels = aDC->LogicalToDeviceXRel( radius ); - + int radius_in_pixels = aDC->LogicalToDeviceXRel( radius ); bool fast_draw = false; // Vias are drawn as a filled circle or a double circle. The hole will be drawn later - int drill_radius = GetDrillValue() / 2; - - int inner_radius = radius - aDC->DeviceToLogicalXRel( 2 ); + int drill_radius = GetDrillValue() / 2; + int inner_radius = radius - aDC->DeviceToLogicalXRel( 2 ); if( radius_in_pixels < MIN_VIA_DRAW_SIZE ) { @@ -753,16 +608,16 @@ void VIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, const w if( fillvia ) { - GRFilledCircle( panel->GetClipBox(), aDC, m_Start + aOffset, radius, color ); + GRFilledCircle( nullptr, aDC, m_Start + aOffset, radius, color ); } else { - GRCircle( panel->GetClipBox(), aDC, m_Start + aOffset, radius, 0, color ); + GRCircle( nullptr, aDC, m_Start + aOffset, radius, 0, color ); if ( fast_draw ) return; - GRCircle( panel->GetClipBox(), aDC, m_Start + aOffset, inner_radius, 0, color ); + GRCircle( nullptr, aDC, m_Start + aOffset, inner_radius, 0, color ); } if( fillvia ) @@ -780,13 +635,10 @@ void VIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, const w color = BLACK; // or DARKGRAY; } - if( (aDrawMode & GR_XOR) == 0) - GRSetDrawMode( aDC, GR_COPY ); - // Draw hole if the radius is > 1pixel. if( aDC->LogicalToDeviceXRel( drill_radius ) > 1 ) - GRFilledCircle( panel->GetClipBox(), aDC, m_Start.x + aOffset.x, - m_Start.y + aOffset.y, drill_radius, 0, color, color ); + GRFilledCircle( nullptr, aDC, m_Start.x + aOffset.x, m_Start.y + aOffset.y, + drill_radius, 0, color, color ); if( screen->m_IsPrinting ) GRForceBlackPen( blackpenstate ); @@ -794,12 +646,12 @@ void VIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, const w else { if( drill_radius < inner_radius ) // We can show the via hole - GRCircle( panel->GetClipBox(), aDC, m_Start + aOffset, drill_radius, 0, color ); + GRCircle( nullptr, aDC, m_Start + aOffset, drill_radius, 0, color ); } if( ShowClearance( displ_opts, this ) ) { - GRCircle( panel->GetClipBox(), aDC, m_Start + aOffset, radius + GetClearance(), 0, color ); + GRCircle( nullptr, aDC, m_Start + aOffset, radius + GetClearance(), 0, color ); } // for Micro Vias, draw a partial cross : X on component layer, or + on copper layer @@ -820,24 +672,16 @@ void VIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, const w } // lines '|' or '\' - GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x - ax, - m_Start.y + aOffset.y - ay, - m_Start.x + aOffset.x - bx, - m_Start.y + aOffset.y - by, 0, color ); - GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x + bx, - m_Start.y + aOffset.y + by, - m_Start.x + aOffset.x + ax, - m_Start.y + aOffset.y + ay, 0, color ); + GRLine( nullptr, aDC, m_Start.x + aOffset.x - ax, m_Start.y + aOffset.y - ay, + m_Start.x + aOffset.x - bx, m_Start.y + aOffset.y - by, 0, color ); + GRLine( nullptr, aDC, m_Start.x + aOffset.x + bx, m_Start.y + aOffset.y + by, + m_Start.x + aOffset.x + ax, m_Start.y + aOffset.y + ay, 0, color ); // lines - or '/' - GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x + ay, - m_Start.y + aOffset.y - ax, - m_Start.x + aOffset.x + by, - m_Start.y + aOffset.y - bx, 0, color ); - GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x - by, - m_Start.y + aOffset.y + bx, - m_Start.x + aOffset.x - ay, - m_Start.y + aOffset.y + ax, 0, color ); + GRLine( nullptr, aDC, m_Start.x + aOffset.x + ay, m_Start.y + aOffset.y - ax, + m_Start.x + aOffset.x + by, m_Start.y + aOffset.y - bx, 0, color ); + GRLine( nullptr, aDC, m_Start.x + aOffset.x - by, m_Start.y + aOffset.y + bx, + m_Start.x + aOffset.x - ay, m_Start.y + aOffset.y + ax, 0, color ); } // for Buried Vias, draw a partial line : orient depending on layer pair @@ -852,19 +696,15 @@ void VIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, const w // lines for the top layer RotatePoint( &ax, &ay, layer_top * 3600.0 / brd->GetCopperLayerCount( ) ); RotatePoint( &bx, &by, layer_top * 3600.0 / brd->GetCopperLayerCount( ) ); - GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x - ax, - m_Start.y + aOffset.y - ay, - m_Start.x + aOffset.x - bx, - m_Start.y + aOffset.y - by, 0, color ); + GRLine( nullptr, aDC, m_Start.x + aOffset.x - ax, m_Start.y + aOffset.y - ay, + m_Start.x + aOffset.x - bx, m_Start.y + aOffset.y - by, 0, color ); // lines for the bottom layer ax = 0; ay = radius; bx = 0; by = drill_radius; RotatePoint( &ax, &ay, layer_bottom * 3600.0 / brd->GetCopperLayerCount( ) ); RotatePoint( &bx, &by, layer_bottom * 3600.0 / brd->GetCopperLayerCount( ) ); - GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x - ax, - m_Start.y + aOffset.y - ay, - m_Start.x + aOffset.x - bx, - m_Start.y + aOffset.y - by, 0, color ); + GRLine( nullptr, aDC, m_Start.x + aOffset.x - ax, m_Start.y + aOffset.y - ay, + m_Start.x + aOffset.x - bx, m_Start.y + aOffset.y - by, 0, color ); } // Display the short netname: @@ -891,15 +731,8 @@ void VIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, const w { tsize = (tsize * 7) / 10; // small reduction to give a better look, inside via - if( (aDrawMode & GR_XOR) == 0 ) - GRSetDrawMode( aDC, GR_COPY ); - - EDA_RECT* clipbox = panel->GetClipBox(); - DrawGraphicHaloText( clipbox, aDC, m_Start, - color, WHITE, BLACK, - text, 0, wxSize( tsize, tsize ), - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, - tsize / 7, false, false ); + GRHaloText( aDC, m_Start, color, WHITE, BLACK, text, 0, wxSize( tsize, tsize ), + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize/7, false, false ); } } } diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index ee43987a7c..60efb8c8c2 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -189,9 +189,7 @@ public: return GetLineLength( m_Start, m_End ); } - /* Display on screen: */ - void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, - GR_DRAWMODE aDrawMode, const wxPoint& aOffset = ZeroOffset ) override; + void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& aOffset = ZeroOffset ) override; /** * Function TransformShapeWithClearanceToPolygon @@ -331,14 +329,8 @@ protected: virtual void GetMsgPanelInfoBase( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ); - /** - * Helper function for the common panel info */ void GetMsgPanelInfoBase_Common( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ); - /** - * Helper for drawing the short netname in tracks */ - void DrawShortNetname( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, - COLOR4D aBgColor ); int m_Width; ///< Thickness of track, or via diameter wxPoint m_Start; ///< Line start point @@ -364,8 +356,7 @@ public: // Do not create a copy constructor. The one generated by the compiler is adequate. - void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, - GR_DRAWMODE aDrawMode, const wxPoint& aOffset = ZeroOffset ) override; + void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& aOffset = ZeroOffset ) override; bool IsOnLayer( PCB_LAYER_ID aLayer ) const override; diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index d0743fa392..e72be58c54 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -278,27 +278,21 @@ bool ZONE_CONTAINER::IsOnLayer( PCB_LAYER_ID aLayer ) const } -void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMode, - const wxPoint& offset ) +void ZONE_CONTAINER::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset ) { if( !DC ) return; - wxPoint seg_start, seg_end; - PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; - BOARD* brd = GetBoard(); - - auto frame = static_cast ( panel->GetParent() ); - + wxPoint seg_start, seg_end; + PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) aFrame->GetScreen() )->m_Active_Layer; + BOARD* brd = GetBoard(); PCB_LAYER_ID draw_layer = UNDEFINED_LAYER; LSET layers = GetLayerSet() & brd->GetVisibleLayers(); - // If there are no visible layers and the zone is not highlighted, return - if( layers.count() == 0 && !( aDrawMode & GR_HIGHLIGHT ) ) - { + // If there are no visible layers, return + if( layers.count() == 0 ) return; - } /* Keepout zones can exist on multiple layers * Thus, determining which color to use to render them is a bit tricky. @@ -318,10 +312,8 @@ void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMod assert( GetLayerSet().count() > 0 ); // Not on any visible layer? - if( layers.count() == 0 && !( aDrawMode & GR_HIGHLIGHT ) ) - { + if( layers.count() == 0 ) return; - } // Is keepout zone present on the selected layer? if( layers.test( curr_layer ) ) @@ -346,32 +338,22 @@ void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMod */ else { - if( brd->IsLayerVisible( GetLayer() ) == false && !( aDrawMode & GR_HIGHLIGHT ) ) - { + if( brd->IsLayerVisible( GetLayer() ) == false ) return; - } draw_layer = GetLayer(); } assert( draw_layer != UNDEFINED_LAYER ); - auto color = frame->Settings().Colors().GetLayerColor( draw_layer ); + auto color = aFrame->Settings().Colors().GetLayerColor( draw_layer ); - GRSetDrawMode( DC, aDrawMode ); - auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() ); + auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aFrame->GetDisplayOptions() ); if( displ_opts->m_ContrastModeDisplay ) { if( !IsOnLayer( curr_layer ) ) - { color = COLOR4D( DARKDARKGRAY ); - } - } - - if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) ) - { - color.SetToLegacyHighlightColor(); } color.a = 0.588; @@ -390,7 +372,7 @@ void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMod lines.push_back( static_cast( segment.B ) + offset ); } - GRLineArray( panel->GetClipBox(), DC, lines, 0, color ); + GRLineArray( nullptr, DC, lines, 0, color ); // draw hatches lines.clear(); @@ -404,20 +386,18 @@ void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMod lines.push_back( seg_end ); } - GRLineArray( panel->GetClipBox(), DC, lines, 0, color ); + GRLineArray( nullptr, DC, lines, 0, color ); } -void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, - wxDC* DC, GR_DRAWMODE aDrawMode, const wxPoint& offset ) +void ZONE_CONTAINER::PrintFilledArea( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset ) { - static std::vector CornersBuffer; - auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() ); - // outline_mode is false to show filled polys, - // and true to show polygons outlines only (test and debug purposes) - bool outline_mode = displ_opts->m_DisplayZonesMode == 2 ? true : false; + BOARD* brd = GetBoard(); + KIGFX::COLOR4D color = aFrame->Settings().Colors().GetLayerColor( GetLayer() ); + PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) aFrame->GetDisplayOptions(); + bool outline_mode = displ_opts->m_DisplayZonesMode == 2; if( DC == NULL ) return; @@ -428,29 +408,11 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, if( m_FilledPolysList.IsEmpty() ) // Nothing to draw return; - BOARD* brd = GetBoard(); - PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; - - auto frame = static_cast ( panel->GetParent() ); - auto color = frame->Settings().Colors().GetLayerColor( GetLayer() ); - - if( brd->IsLayerVisible( GetLayer() ) == false && !( aDrawMode & GR_HIGHLIGHT ) ) + if( brd->IsLayerVisible( GetLayer() ) == false ) return; - GRSetDrawMode( DC, aDrawMode ); - - if( displ_opts->m_ContrastModeDisplay ) - { - if( !IsOnLayer( curr_layer ) ) - color = COLOR4D( DARKDARKGRAY ); - } - - if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) ) - color.SetToLegacyHighlightColor(); - color.a = 0.588; - for( int ic = 0; ic < m_FilledPolysList.OutlineCount(); ic++ ) { const SHAPE_LINE_CHAIN& path = m_FilledPolysList.COutline( ic ); @@ -484,12 +446,12 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, // Draw only basic outlines, not extra segments. if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) ) { - GRCSegm( panel->GetClipBox(), DC, CornersBuffer[is], CornersBuffer[ie], + GRCSegm( nullptr, DC, CornersBuffer[is], CornersBuffer[ie], line_thickness, color ); } else { - GRFilledSegment( panel->GetClipBox(), DC, CornersBuffer[is], CornersBuffer[ie], + GRFilledSegment( nullptr, DC, CornersBuffer[is], CornersBuffer[ie], line_thickness, color ); } } @@ -497,10 +459,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, // Draw fill: if( !outline_mode ) - { - GRPoly( panel->GetClipBox(), DC, CornersBuffer.size(), &CornersBuffer[0], true, 0, - color, color ); - } + GRPoly( nullptr, DC, CornersBuffer.size(), &CornersBuffer[0], true, 0, color, color ); } } @@ -532,89 +491,6 @@ const EDA_RECT ZONE_CONTAINER::GetBoundingBox() const } -void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC, - GR_DRAWMODE draw_mode ) -{ - GR_DRAWMODE current_gr_mode = draw_mode; - bool is_close_segment = false; - - if( !DC ) - return; - - PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; - - auto frame = static_cast ( panel->GetParent() ); - auto color = frame->Settings().Colors().GetLayerColor( GetLayer() ); - - auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() ); - - if( displ_opts->m_ContrastModeDisplay ) - { - if( !IsOnLayer( curr_layer ) ) - color = COLOR4D( DARKDARKGRAY ); - } - - // Object to iterate through the corners of the outlines - SHAPE_POLY_SET::ITERATOR iterator = m_Poly->Iterate(); - - // Segment start and end - VECTOR2I seg_start, seg_end; - - // Remember the first point of this contour - VECTOR2I contour_first_point = *iterator; - - // Iterate through all the corners of the outlines and build the segments to draw - while( iterator ) - { - // Get the first point of the current segment - seg_start = *iterator; - - // Get the last point of the current segment, handling the case where the end of the - // contour is reached, when the last point of the segment is the first point of the - // contour - if( !iterator.IsEndContour() ) - { - // Set GR mode to default - current_gr_mode = draw_mode; - - SHAPE_POLY_SET::ITERATOR iterator_copy = iterator; - iterator_copy++; - if( iterator_copy.IsEndContour() ) - current_gr_mode = GR_XOR; - - is_close_segment = false; - - iterator++; - seg_end = *iterator; - } - else - { - is_close_segment = true; - - seg_end = contour_first_point; - - // Reassign first point of the contour to the next contour start - iterator++; - - if( iterator ) - contour_first_point = *iterator; - - // Set GR mode to XOR - current_gr_mode = GR_XOR; - } - - GRSetDrawMode( DC, current_gr_mode ); - - if( is_close_segment ) - GRLine( panel->GetClipBox(), DC, seg_start.x, seg_start.y, seg_end.x, seg_end.y, 0, - WHITE ); - else - GRLine( panel->GetClipBox(), DC, seg_start.x, seg_start.y, seg_end.x, seg_end.y, 0, - color ); - } -} - - int ZONE_CONTAINER::GetThermalReliefGap( D_PAD* aPad ) const { if( aPad == NULL || aPad->GetThermalGap() == 0 ) diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index 5e93e50972..f69c234022 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -42,7 +42,6 @@ class EDA_RECT; class LINE_READER; -class EDA_DRAW_PANEL; class PCB_EDIT_FRAME; class BOARD; class ZONE_CONTAINER; @@ -102,42 +101,24 @@ public: virtual LSET GetLayerSet() const override; /** - * Function Draw - * Draws the zone outline. - * @param panel = current Draw Panel + * Function Print + * Prints the zone outline. + * @param aFrame = current Frame * @param DC = current Device Context * @param aDrawMode = GR_OR, GR_XOR, GR_COPY .. * @param offset = Draw offset (usually wxPoint(0,0)) */ - void Draw( EDA_DRAW_PANEL* panel, - wxDC* DC, - GR_DRAWMODE aDrawMode, - const wxPoint& offset = ZeroOffset ) override; + void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset = ZeroOffset ) override; /** - * Function DrawDrawFilledArea + * Function PrintFilledArea * Draws the filled area for this zone (polygon list .m_FilledPolysList) - * @param panel = current Draw Panel + * @param aFrame = current Frame * @param DC = current Device Context * @param offset = Draw offset (usually wxPoint(0,0)) * @param aDrawMode = GR_OR, GR_XOR, GR_COPY .. */ - void DrawFilledArea( EDA_DRAW_PANEL* panel, - wxDC* DC, - GR_DRAWMODE aDrawMode, - const wxPoint& offset = ZeroOffset ); - - /** - * Function DrawWhileCreateOutline - * Draws the zone outline when it is created. - * The moving edges are in XOR graphic mode, old segment in draw_mode graphic mode - * (usually GR_OR). The closing edge has its own shape. - * @param panel = current Draw Panel - * @param DC = current Device Context - * @param draw_mode = draw mode: OR, XOR .. - */ - void DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC, - GR_DRAWMODE draw_mode = GR_OR ); + void PrintFilledArea( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset = ZeroOffset ); /** Function GetBoundingBox (virtual) * @return an EDA_RECT that is the bounding box of the zone outline diff --git a/pcbnew/dialogs/dialog_cleanup_tracks_and_vias.cpp b/pcbnew/dialogs/dialog_cleanup_tracks_and_vias.cpp index 458f3b0f59..6e91185f98 100644 --- a/pcbnew/dialogs/dialog_cleanup_tracks_and_vias.cpp +++ b/pcbnew/dialogs/dialog_cleanup_tracks_and_vias.cpp @@ -132,8 +132,7 @@ void DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup( bool aDryRun ) { // Clear undo and redo lists to avoid inconsistencies between lists commit.Push( _( "Board cleanup" ) ); - - m_parentFrame->GetCanvas()->Refresh( true ); + m_parentFrame->GetGalCanvas()->Refresh( true ); } } @@ -150,9 +149,8 @@ void DIALOG_CLEANUP_TRACKS_AND_VIAS::OnSelectItem( wxCommandEvent& event ) if( item ) { m_parentFrame->FocusOnLocation( item->GetPointA(), false, true ); - WINDOW_THAWER thawer( m_parentFrame ); - m_parentFrame->GetCanvas()->Refresh(); + m_parentFrame->GetGalCanvas()->Refresh(); } } @@ -201,7 +199,7 @@ void DIALOG_CLEANUP_TRACKS_AND_VIAS::OnRightUpItem( wxMouseEvent& event ) WINDOW_THAWER thawer( m_parentFrame ); m_parentFrame->GetToolManager()->RunAction( PCB_ACTIONS::selectionMenu, true, &items ); - m_parentFrame->GetCanvas()->Refresh(); + m_parentFrame->GetGalCanvas()->Refresh(); } } diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index 01e604a7ea..7567194e5e 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -387,7 +387,7 @@ bool DIALOG_DRC_CONTROL::focusOnItem( const DRC_ITEM* aItem ) } toolmgr->GetView()->SetCenter( pos ); - m_brdEditor->GetCanvas()->Refresh(); + m_brdEditor->GetGalCanvas()->Refresh(); return true; } @@ -452,7 +452,7 @@ void DIALOG_DRC_CONTROL::doSelectionMenu( const DRC_ITEM* aItem ) if( selection && ( selection == first || selection == second ) ) m_brdEditor->GetToolManager()->GetView()->SetCenter( selection->GetPosition() ); - m_brdEditor->GetCanvas()->Refresh(); + m_brdEditor->GetGalCanvas()->Refresh(); } @@ -570,7 +570,7 @@ void DIALOG_DRC_CONTROL::RedrawDrawPanel() { WINDOW_THAWER thawer( m_brdEditor ); - m_brdEditor->GetCanvas()->Refresh(); + m_brdEditor->GetGalCanvas()->Refresh(); } diff --git a/pcbnew/dialogs/dialog_exchange_footprints.cpp b/pcbnew/dialogs/dialog_exchange_footprints.cpp index ea48e22d27..a2bd589ef5 100644 --- a/pcbnew/dialogs/dialog_exchange_footprints.cpp +++ b/pcbnew/dialogs/dialog_exchange_footprints.cpp @@ -277,7 +277,7 @@ void DIALOG_EXCHANGE_FOOTPRINTS::OnApplyClicked( wxCommandEvent& event ) if( m_parent->GetBoard()->IsElementVisible( LAYER_RATSNEST ) ) m_parent->Compile_Ratsnest( true ); - m_parent->GetCanvas()->Refresh(); + m_parent->GetGalCanvas()->Refresh(); } m_commit.Push( wxT( "Changed footprint" ) ); diff --git a/pcbnew/dialogs/dialog_global_deletion.cpp b/pcbnew/dialogs/dialog_global_deletion.cpp index cf72d43a94..a02920629f 100644 --- a/pcbnew/dialogs/dialog_global_deletion.cpp +++ b/pcbnew/dialogs/dialog_global_deletion.cpp @@ -237,5 +237,5 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete() m_Parent->Compile_Ratsnest( true ); // There is a chance that some of tracks have changed their nets, so rebuild ratsnest from scratch - m_Parent->GetCanvas()->Refresh(); + m_Parent->GetGalCanvas()->Refresh(); } diff --git a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp index fdc22d5955..bcdf6e6890 100644 --- a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp +++ b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp @@ -403,7 +403,7 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow() } commit.Push( "Edit text and graphics properties" ); - m_parent->GetCanvas()->Refresh(); + m_parent->GetGalCanvas()->Refresh(); return true; } diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 34303e5dd3..128d128e27 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -357,7 +357,7 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event ) dc.SetUserScale( scale, scale ); GRResetPenAndBrush( &dc ); - m_dummyPad->DrawShape( NULL, &dc, drawInfo ); + m_dummyPad->PrintShape( &dc, drawInfo ); // draw selected primitives: long select = m_listCtrlPrimitives->GetFirstSelected(); @@ -1453,7 +1453,7 @@ bool DIALOG_PAD_PROPERTIES::TransferDataFromWindow() // redraw the area where the pad was, without pad (delete pad on screen) m_currentPad->SetFlags( DO_NOT_DRAW ); - m_parent->GetCanvas()->Refresh(); + m_parent->GetGalCanvas()->Refresh(); m_currentPad->ClearFlags( DO_NOT_DRAW ); // Update values @@ -1573,7 +1573,7 @@ bool DIALOG_PAD_PROPERTIES::TransferDataFromWindow() m_parent->SetMsgPanel( m_currentPad ); // redraw the area where the pad was - m_parent->GetCanvas()->Refresh(); + m_parent->GetGalCanvas()->Refresh(); commit.Push( _( "Modify pad" ) ); diff --git a/pcbnew/dialogs/dialog_select_net_from_list.cpp b/pcbnew/dialogs/dialog_select_net_from_list.cpp index cd8beb525f..dd0e3a387c 100644 --- a/pcbnew/dialogs/dialog_select_net_from_list.cpp +++ b/pcbnew/dialogs/dialog_select_net_from_list.cpp @@ -24,7 +24,6 @@ #include #include -#include #include #include #include diff --git a/pcbnew/dialogs/dialog_swap_layers.cpp b/pcbnew/dialogs/dialog_swap_layers.cpp index 36462f7b0d..f7eb2e0bb6 100644 --- a/pcbnew/dialogs/dialog_swap_layers.cpp +++ b/pcbnew/dialogs/dialog_swap_layers.cpp @@ -254,6 +254,6 @@ void PCB_EDIT_FRAME::Swap_Layers( wxCommandEvent& event ) { OnModify(); commit.Push( "Layers moved" ); - GetCanvas()->Refresh(); + GetGalCanvas()->Refresh(); } } diff --git a/pcbnew/dialogs/dialog_text_properties.cpp b/pcbnew/dialogs/dialog_text_properties.cpp index b2da98b898..6496b0a357 100644 --- a/pcbnew/dialogs/dialog_text_properties.cpp +++ b/pcbnew/dialogs/dialog_text_properties.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include diff --git a/pcbnew/dialogs/panel_modedit_display_options.cpp b/pcbnew/dialogs/panel_modedit_display_options.cpp index fbbf58dc5f..2bf670cb96 100644 --- a/pcbnew/dialogs/panel_modedit_display_options.cpp +++ b/pcbnew/dialogs/panel_modedit_display_options.cpp @@ -61,7 +61,7 @@ bool PANEL_MODEDIT_DISPLAY_OPTIONS::TransferDataFromWindow() KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView(); view->RecacheAllItems(); view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); - m_frame->GetCanvas()->Refresh(); + m_frame->GetGalCanvas()->Refresh(); return true; } diff --git a/pcbnew/dialogs/panel_pcbnew_display_options.cpp b/pcbnew/dialogs/panel_pcbnew_display_options.cpp index 0e0a086abc..c19281a75f 100644 --- a/pcbnew/dialogs/panel_pcbnew_display_options.cpp +++ b/pcbnew/dialogs/panel_pcbnew_display_options.cpp @@ -91,7 +91,6 @@ bool PANEL_PCBNEW_DISPLAY_OPTIONS::TransferDataFromWindow() m_frame->SetElementVisibility( LAYER_NO_CONNECTS, m_OptDisplayPadNoConn->GetValue() ); displ_opts->m_DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection(); - displ_opts->m_DisplayRatsnestLinesCurved = m_OptDisplayCurvedRatsnestLines->GetValue(); m_galOptsPanel->TransferDataFromWindow(); @@ -104,7 +103,7 @@ bool PANEL_PCBNEW_DISPLAY_OPTIONS::TransferDataFromWindow() view->RecacheAllItems(); view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); - m_frame->GetCanvas()->Refresh(); + m_frame->GetGalCanvas()->Refresh(); return true; } diff --git a/pcbnew/drc.h b/pcbnew/drc.h index 2fe6d22855..e7a7a8d96a 100644 --- a/pcbnew/drc.h +++ b/pcbnew/drc.h @@ -112,7 +112,6 @@ #define DRCE_ZERO_LENGTH_TRACK 64 -class EDA_DRAW_PANEL; class PCB_EDIT_FRAME; class DIALOG_DRC_CONTROL; class BOARD_ITEM; diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 008f4c98c2..d77514267b 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -163,7 +162,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) SetActiveLayer( ToLAYER_ID( m_SelLayerBox->GetLayerSelection() ) ); if( displ_opts->m_ContrastModeDisplay ) - m_canvas->Refresh( true ); + GetGalCanvas()->Refresh(); break; case ID_MENU_PCB_CLEAN: @@ -192,7 +191,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_GEN_IMPORT_GRAPHICS_FILE: InvokeDialogImportGfxBoard( this ); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); break; @@ -243,108 +242,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, PCB_LAYER_ID layer ) SetActiveLayer( layer ); if( displ_opts->m_ContrastModeDisplay ) - m_canvas->Refresh(); -} - - -void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) -{ - // JEY TODO: obsolete? - int id = aEvent.GetId(); - int lastToolID = GetToolId(); - auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions(); - - switch( id ) - { - case ID_NO_TOOL_SELECTED: - SetNoToolSelected(); - break; - - case ID_ZOOM_SELECTION: - // This tool is located on the main toolbar: switch it on or off on click on it - if( lastToolID != ID_ZOOM_SELECTION ) - SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) ); - else - SetNoToolSelected(); - break; - - case ID_TRACK_BUTT: - if( Settings().m_legacyDrcOn ) - SetToolID( id, wxCURSOR_PENCIL, _( "Add tracks" ) ); - else - SetToolID( id, wxCURSOR_QUESTION_ARROW, _( "Add tracks" ) ); - - Compile_Ratsnest( true ); - break; - - case ID_PCB_ZONES_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _( "Add zones" ) ); - - if( displ_opts->m_DisplayZonesMode != 0 ) - DisplayInfoMessage( this, _( "Warning: zone display is OFF!!!" ) ); - break; - - case ID_PCB_KEEPOUT_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _( "Add keepout" ) ); - break; - - case ID_PCB_TARGET_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _( "Add layer alignment target" ) ); - break; - - case ID_PCB_PLACE_OFFSET_COORD_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _( "Adjust zero" ) ); - break; - - case ID_PCB_PLACE_GRID_COORD_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _( "Adjust grid origin" ) ); - break; - - case ID_PCB_ADD_LINE_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic line" ) ); - break; - - case ID_PCB_ARC_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic arc" ) ); - break; - - case ID_PCB_CIRCLE_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic circle" ) ); - break; - - case ID_PCB_ADD_TEXT_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) ); - break; - - case ID_COMPONENT_BUTT: - SetToolID( id, wxCURSOR_HAND, _( "Add footprint" ) ); - break; - - case ID_PCB_DIMENSION_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _( "Add dimension" ) ); - break; - - case ID_PCB_DELETE_ITEM_BUTT: - SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) ); - break; - - case ID_PCB_HIGHLIGHT_BUTT: - SetToolID( id, wxCURSOR_HAND, _( "Highlight net" ) ); - break; - - case ID_LOCAL_RATSNEST_BUTT: - SetToolID( id, wxCURSOR_HAND, _( "Select rats nest" ) ); - - Compile_Ratsnest( true ); - - break; - - // collect GAL-only tools here - case ID_PCB_DRAW_VIA_BUTT: - case ID_PCB_MEASUREMENT_TOOL: - SetToolID( id, wxCURSOR_DEFAULT, _( "Unsupported tool in this canvas" ) ); - break; - } + GetGalCanvas()->Refresh(); } diff --git a/pcbnew/exporters/export_vrml.cpp b/pcbnew/exporters/export_vrml.cpp index 5705924304..df0609977d 100644 --- a/pcbnew/exporters/export_vrml.cpp +++ b/pcbnew/exporters/export_vrml.cpp @@ -40,7 +40,7 @@ #include "class_track.h" #include "class_zone.h" #include "convert_to_biu.h" -#include "draw_graphic_text.h" +#include "gr_text.h" #include "macros.h" #include "pgm_base.h" #include "plugins/3dapi/ifsg_all.h" @@ -781,7 +781,7 @@ static void export_vrml_pcbtext( MODEL_VRML& aModel, TEXTE_PCB* text ) if( text->IsMirrored() ) size.x = -size.x; - COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by DrawGraphicText + COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by GRText if( text->IsMultilineAllowed() ) { @@ -794,22 +794,16 @@ static void export_vrml_pcbtext( MODEL_VRML& aModel, TEXTE_PCB* text ) for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) { wxString& txt = strings_list.Item( ii ); - DrawGraphicText( NULL, NULL, positions[ii], color, - txt, text->GetTextAngle(), size, - text->GetHorizJustify(), text->GetVertJustify(), - text->GetThickness(), text->IsItalic(), - true, - vrml_text_callback ); + GRText( NULL, positions[ii], color, txt, text->GetTextAngle(), size, + text->GetHorizJustify(), text->GetVertJustify(), text->GetThickness(), + text->IsItalic(), true, vrml_text_callback ); } } else { - DrawGraphicText( NULL, NULL, text->GetTextPos(), color, - text->GetShownText(), text->GetTextAngle(), size, - text->GetHorizJustify(), text->GetVertJustify(), - text->GetThickness(), text->IsItalic(), - true, - vrml_text_callback ); + GRText( NULL, text->GetTextPos(), color, text->GetShownText(), text->GetTextAngle(), + size, text->GetHorizJustify(), text->GetVertJustify(), text->GetThickness(), + text->IsItalic(), true, vrml_text_callback ); } } @@ -1028,24 +1022,21 @@ static void export_vrml_zones( MODEL_VRML& aModel, BOARD* aPcb ) } -static void export_vrml_text_module( TEXTE_MODULE* module ) +static void export_vrml_text_module( TEXTE_MODULE* item ) { - if( module->IsVisible() ) + if( item->IsVisible() ) { - wxSize size = module->GetTextSize(); + wxSize size = item->GetTextSize(); - if( module->IsMirrored() ) + if( item->IsMirrored() ) size.x = -size.x; // Text is mirrored - model_vrml->m_text_layer = module->GetLayer(); - model_vrml->m_text_width = module->GetThickness(); + model_vrml->m_text_layer = item->GetLayer(); + model_vrml->m_text_width = item->GetThickness(); - DrawGraphicText( NULL, NULL, module->GetTextPos(), BLACK, - module->GetShownText(), module->GetDrawRotation(), size, - module->GetHorizJustify(), module->GetVertJustify(), - module->GetThickness(), module->IsItalic(), - true, - vrml_text_callback ); + GRText( NULL, item->GetTextPos(), BLACK, item->GetShownText(), item->GetDrawRotation(), + size, item->GetHorizJustify(), item->GetVertJustify(), item->GetThickness(), + item->IsItalic(), true, vrml_text_callback ); } } diff --git a/pcbnew/exporters/gen_drill_report_files.cpp b/pcbnew/exporters/gen_drill_report_files.cpp index 76a245d90f..41711d0906 100644 --- a/pcbnew/exporters/gen_drill_report_files.cpp +++ b/pcbnew/exporters/gen_drill_report_files.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index e9c26cae53..158048d1e2 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -274,11 +274,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, GetGalCanvas()->GetGAL()->SetAxesEnabled( true ); - // Set up viewport // JEY TODO: do these directly rather than off of m_canvas.... - KIGFX::VIEW* view = GetGalCanvas()->GetView(); - view->SetScale( GetZoomLevelCoeff() / m_canvas->GetScreen()->GetZoom() ); - view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); - + GetGalCanvas()->GetView()->SetScale( GetZoomLevelCoeff() / m_canvas->GetScreen()->GetZoom() ); ActivateGalCanvas(); m_auimgr.Update(); diff --git a/pcbnew/footprint_editor_utils.cpp b/pcbnew/footprint_editor_utils.cpp index 6a9b90eab1..a0b44b297c 100644 --- a/pcbnew/footprint_editor_utils.cpp +++ b/pcbnew/footprint_editor_utils.cpp @@ -36,7 +36,6 @@ #include #include #include <3d_viewer/eda_3d_viewer.h> -#include #include #include #include @@ -121,7 +120,7 @@ void FOOTPRINT_EDIT_FRAME::LoadModuleFromLibrary( LIB_ID aFPID) GetScreen()->ClrModify(); updateView(); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); // Update the bitmap of the ID_MODEDIT_SAVE tool if needed. if( is_last_fp_from_brd ) @@ -229,7 +228,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) } updateView(); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); Update3DView(); SyncLibraryTree( false ); @@ -288,7 +287,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) } updateView(); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); Update3DView(); SyncLibraryTree( false ); @@ -305,11 +304,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) { m_toolManager->GetView()->Update( GetBoard()->m_Modules ); - if( GetGalCanvas() ) - GetGalCanvas()->ForceRefresh(); - else - GetCanvas()->Refresh(); - + GetGalCanvas()->ForceRefresh(); GetScreen()->ClrModify(); } } @@ -338,11 +333,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) m_toolManager->GetView()->Update( GetBoard()->m_Modules ); GetScreen()->ClrModify(); - if( GetGalCanvas() ) - GetGalCanvas()->ForceRefresh(); - else - GetCanvas()->Refresh(); - + GetGalCanvas()->ForceRefresh(); SyncLibraryTree( true ); } } @@ -419,7 +410,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) GetScreen()->SetModify(); Zoom_Automatique( false ); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); Update3DView(); break; @@ -466,7 +457,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( GetBoard()->m_Modules ) { editFootprintProperties( GetBoard()->m_Modules ); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } break; @@ -474,7 +465,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( GetBoard()->m_Modules ) { InvokeDialogImportGfxModule( this, GetBoard()->m_Modules ); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } break; @@ -627,7 +618,7 @@ bool FOOTPRINT_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileS GetScreen()->ClrModify(); Zoom_Automatique( false ); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); return true; } diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp index 2d9623bf87..e2200abb73 100644 --- a/pcbnew/footprint_libraries_utils.cpp +++ b/pcbnew/footprint_libraries_utils.cpp @@ -1014,7 +1014,7 @@ bool FOOTPRINT_EDIT_FRAME::RevertFootprint() GetScreen()->ClrModify(); updateView(); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); return true; } diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 15190a3911..24e09eaff2 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -233,11 +233,7 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent GetGalCanvas()->GetGAL()->SetAxesEnabled( true ); - // Set up viewport - KIGFX::VIEW* view = GetGalCanvas()->GetView(); - view->SetScale( GetZoomLevelCoeff() / m_canvas->GetScreen()->GetZoom() ); - view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); - + GetGalCanvas()->GetView()->SetScale( GetZoomLevelCoeff() / m_canvas->GetScreen()->GetZoom() ); ActivateGalCanvas(); // Restore last zoom. (If auto-zooming we'll adjust when we load the footprint.) @@ -327,7 +323,7 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList() ReCreateFootprintList(); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } @@ -436,7 +432,7 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event ) updateView(); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); Update3D_Frame(); } } @@ -785,7 +781,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode ) UpdateTitle(); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index d2041ffc9c..f98240ede4 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -228,11 +228,7 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent galOpts.m_forceDisplayCursor = true; galOpts.m_axesEnabled = true; - // Set up viewport - KIGFX::VIEW* view = GetGalCanvas()->GetView(); - view->SetScale( GetZoomLevelCoeff() / m_canvas->GetScreen()->GetZoom() ); - view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); - + GetGalCanvas()->GetView()->SetScale( GetZoomLevelCoeff() / m_canvas->GetScreen()->GetZoom() ); ActivateGalCanvas(); updateView(); @@ -399,7 +395,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList() ReCreateParameterList(); ReCreateHToolbar(); DisplayWizardInfos(); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } @@ -528,7 +524,7 @@ void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event ) if( m_pageList->GetSelection() > 0 ) { ReCreateParameterList(); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); DisplayWizardInfos(); } } diff --git a/pcbnew/footprint_wizard_frame_functions.cpp b/pcbnew/footprint_wizard_frame_functions.cpp index 90c0755bf1..5f32fd47e8 100644 --- a/pcbnew/footprint_wizard_frame_functions.cpp +++ b/pcbnew/footprint_wizard_frame_functions.cpp @@ -124,7 +124,7 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint() } updateView(); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } diff --git a/pcbnew/load_select_footprint.cpp b/pcbnew/load_select_footprint.cpp index 2fdf53ab92..2577cb886b 100644 --- a/pcbnew/load_select_footprint.cpp +++ b/pcbnew/load_select_footprint.cpp @@ -154,7 +154,7 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule ) Update3DView(); updateView(); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); m_treePane->GetLibTree()->Refresh(); // update any previously-highlighted items return true; diff --git a/pcbnew/netinfo.h b/pcbnew/netinfo.h index 3c80c85515..171f56ed71 100644 --- a/pcbnew/netinfo.h +++ b/pcbnew/netinfo.h @@ -39,12 +39,12 @@ class wxDC; class wxPoint; class LINE_READER; -class EDA_DRAW_PANEL; class EDA_DRAW_FRAME; class D_PAD; class BOARD; class BOARD_ITEM; class MSG_PANEL_ITEM; +class PCB_BASE_FRAME; /*****************************/ @@ -213,12 +213,11 @@ public: #endif /** - * Function Draw + * Function Peinr * @todo we actually could show a NET, simply show all the tracks and * a pads or net name on pad and vias */ - void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMode, - const wxPoint& offset ) override; + void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset ) override; /** * Function GetNet diff --git a/pcbnew/netinfo_item.cpp b/pcbnew/netinfo_item.cpp index db8e27efd2..616fa2e9aa 100644 --- a/pcbnew/netinfo_item.cpp +++ b/pcbnew/netinfo_item.cpp @@ -71,12 +71,9 @@ NETINFO_ITEM::~NETINFO_ITEM() /** - * Function Draw (TODO) + * Function Print (TODO) */ -void NETINFO_ITEM::Draw( EDA_DRAW_PANEL* panel, - wxDC* DC, - GR_DRAWMODE aDrawMode, - const wxPoint& aOffset ) +void NETINFO_ITEM::Print( PCB_BASE_FRAME* frame, wxDC* DC, const wxPoint& aOffset ) { } diff --git a/pcbnew/netlist.cpp b/pcbnew/netlist.cpp index e89789d157..7f7b7be152 100644 --- a/pcbnew/netlist.cpp +++ b/pcbnew/netlist.cpp @@ -132,7 +132,7 @@ void PCB_EDIT_FRAME::OnNetlistChanged( BOARD_NETLIST_UPDATER& aUpdater, selection.SetReferencePoint( newFootprints[0]->GetPosition() ); } - GetCanvas()->Refresh(); + GetGalCanvas()->Refresh(); } diff --git a/pcbnew/pad_edit_functions.cpp b/pcbnew/pad_edit_functions.cpp index d62418259f..b28b15a843 100644 --- a/pcbnew/pad_edit_functions.cpp +++ b/pcbnew/pad_edit_functions.cpp @@ -65,7 +65,7 @@ void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw ) if( aDraw ) { aPad->SetFlags( DO_NOT_DRAW ); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); aPad->ClearFlags( DO_NOT_DRAW ); } @@ -74,7 +74,7 @@ void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw ) aPad->ImportSettingsFromMaster( mp ); if( aDraw ) - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); aPad->GetParent()->SetLastEditTime(); @@ -146,7 +146,7 @@ void PCB_BASE_FRAME::AddPad( MODULE* aModule, bool draw ) SetMsgPanel( pad ); if( draw ) - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } diff --git a/pcbnew/pad_draw_functions.cpp b/pcbnew/pad_print_functions.cpp similarity index 69% rename from pcbnew/pad_draw_functions.cpp rename to pcbnew/pad_print_functions.cpp index 30a713fb2e..b7d43280c6 100644 --- a/pcbnew/pad_draw_functions.cpp +++ b/pcbnew/pad_print_functions.cpp @@ -4,7 +4,7 @@ * Copyright (C) 2017 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck * Copyright (C) 2012 Wayne Stambaugh - * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.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 @@ -24,15 +24,11 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file class_pad_draw_functions.cpp - */ - #include #include #include #include -#include +#include #include #include #include @@ -44,21 +40,9 @@ #include -/* uncomment this line to show this pad with its specfic size and color - * when it is not on copper layers, and only one solder mask layer or solder paste layer - * is displayed for this pad - * After testing this feature,I am not sure this is a good idea - * but the code is left here. - */ - -//#define SHOW_PADMASK_REAL_SIZE_AND_COLOR - - // Helper class to store parameters used to draw a pad PAD_DRAWINFO::PAD_DRAWINFO() { - m_DrawPanel = NULL; - m_DrawMode = GR_COPY; m_Color = BLACK; m_HoleColor = BLACK; // could be DARKGRAY; m_NPHoleColor = YELLOW; @@ -73,18 +57,10 @@ PAD_DRAWINFO::PAD_DRAWINFO() } -void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, - const wxPoint& aOffset ) +void D_PAD::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset ) { wxSize mask_margin; // margin (clearance) used for some non copper layers -#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR - int showActualMaskSize = 0; /* Layer number if the actual pad size on mask layer can - * be displayed i.e. if only one layer is shown for this pad - * and this layer is a mask (solder mask or solder paste - */ -#endif - if( m_Flags & DO_NOT_DRAW ) return; @@ -104,8 +80,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, BOARD* brd = GetBoard(); - auto frame = static_cast ( aPanel->GetParent() ); - const auto& cds = frame->Settings().Colors(); + const auto& cds = aFrame->Settings().Colors(); bool frontVisible = brd->IsElementVisible( LAYER_PAD_FR ); bool backVisible = brd->IsElementVisible( LAYER_PAD_BK ); @@ -124,10 +99,8 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, return; - wxCHECK_RET( frame != NULL, wxT( "Panel has no parent frame window." ) ); - - auto displ_opts = (PCB_DISPLAY_OPTIONS*)( frame->GetDisplayOptions() ); - PCB_SCREEN* screen = frame->GetScreen(); + auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aFrame->GetDisplayOptions() ); + PCB_SCREEN* screen = aFrame->GetScreen(); if( displ_opts && displ_opts->m_DisplayPadFill == SKETCH ) drawInfo.m_ShowPadFilled = false; @@ -151,9 +124,6 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, // If the pad is on only one tech layer, use the layer color else use DARKGRAY LSET mask_non_copper_layers = m_layerMask & ~LSET::AllCuMask(); -#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR - mask_non_copper_layers &= brd->GetVisibleLayers(); -#endif PCB_LAYER_ID pad_layer = mask_non_copper_layers.ExtractLayer(); switch( (int) pad_layer ) @@ -167,125 +137,21 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, default: color = cds.GetLayerColor( pad_layer ); -#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR - showActualMaskSize = pad_layer; -#endif } } - // if SMD or connector pad and high contrast mode - if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && - ( GetAttribute() == PAD_ATTRIB_SMD || GetAttribute() == PAD_ATTRIB_CONN ) && - displ_opts && displ_opts->m_ContrastModeDisplay ) + if( ( IsOnLayer( B_Paste ) && brd->IsLayerVisible( B_Paste ) ) || + ( IsOnLayer( F_Paste ) && brd->IsLayerVisible( F_Paste ) ) ) { - // when routing tracks - if( frame->GetToolId() == ID_TRACK_BUTT ) - { - PCB_LAYER_ID routeTop = screen->m_Route_Layer_TOP; - PCB_LAYER_ID routeBot = screen->m_Route_Layer_BOTTOM; - - // if routing between copper and component layers, - // or the current layer is one of said 2 external copper layers, - // then highlight only the current layer. - if( ( screen->m_Active_Layer == F_Cu || screen->m_Active_Layer == B_Cu ) || - ( routeTop==F_Cu && routeBot==B_Cu ) || - ( routeTop==B_Cu && routeBot==F_Cu ) - ) - { - if( !IsOnLayer( screen->m_Active_Layer ) ) - color = COLOR4D( DARKDARKGRAY ); - } - // else routing between an internal signal layer and some other - // layer. Grey out all PAD_ATTRIB_SMD pads not on current or the single - // selected external layer. - else if( !IsOnLayer( screen->m_Active_Layer ) - && !IsOnLayer( routeTop ) - && !IsOnLayer( routeBot ) ) - { - color = COLOR4D( DARKDARKGRAY ); - } - } - // when not edting tracks, show PAD_ATTRIB_SMD components not on active layer - // as greyed out - else - { - if( !IsOnLayer( screen->m_Active_Layer ) ) - color = COLOR4D( DARKDARKGRAY ); - } + mask_margin = GetSolderPasteMargin(); } -#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR - if( showActualMaskSize ) + if( ( IsOnLayer( B_Mask ) && brd->IsLayerVisible( B_Mask ) ) || + ( IsOnLayer( F_Mask ) && brd->IsLayerVisible( F_Mask ) ) ) { - switch( showActualMaskSize ) - { - case B_Mask: - case F_Mask: - mask_margin.x = mask_margin.y = GetSolderMaskMargin(); - break; - - case B_Paste: - case F_Paste: - mask_margin = GetSolderPasteMargin(); - break; - - default: - // Another layer which has no margin to handle - break; - } + mask_margin.x = std::max( mask_margin.x, GetSolderMaskMargin() ); + mask_margin.y = std::max( mask_margin.y, GetSolderMaskMargin() ); } -#endif - - // if Contrast mode is ON and a technical layer active, show pads on this - // layer so we can see pads on paste or solder layer and the size of the - // mask - if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && - displ_opts && displ_opts->m_ContrastModeDisplay && !IsCopperLayer( screen->m_Active_Layer ) ) - { - if( IsOnLayer( screen->m_Active_Layer ) ) - { - color = cds.GetLayerColor( screen->m_Active_Layer ); - - // In high contrast mode, and if the active layer is the mask - // layer shows the pad size with the mask clearance - switch( screen->m_Active_Layer ) - { - case B_Mask: - case F_Mask: - mask_margin.x = mask_margin.y = GetSolderMaskMargin(); - break; - - case B_Paste: - case F_Paste: - mask_margin = GetSolderPasteMargin(); - break; - - default: - break; - } - } - else - color = DARKDARKGRAY; - } - // If use asks for masks to be printed, then print them. - else if( screen->m_IsPrinting ) - { - if( ( IsOnLayer( B_Paste ) && brd->IsLayerVisible( B_Paste ) ) || - ( IsOnLayer( F_Paste ) && brd->IsLayerVisible( F_Paste ) ) ) - { - mask_margin = GetSolderPasteMargin(); - } - - if( ( IsOnLayer( B_Mask ) && brd->IsLayerVisible( B_Mask ) ) || - ( IsOnLayer( F_Mask ) && brd->IsLayerVisible( F_Mask ) ) ) - { - mask_margin.x = std::max( mask_margin.x, GetSolderMaskMargin() ); - mask_margin.y = std::max( mask_margin.y, GetSolderMaskMargin() ); - } - } - - if( ( aDraw_mode & GR_HIGHLIGHT ) && !( aDraw_mode & GR_AND ) ) - color.SetToLegacyHighlightColor(); bool DisplayIsol = displ_opts && displ_opts->m_DisplayPadIsol; @@ -305,13 +171,11 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, drawInfo.m_NPHoleColor = cds.GetItemColor( LAYER_MOD_TEXT_INVISIBLE ); } - drawInfo.m_DrawMode = aDraw_mode; - drawInfo.m_Color = color; + drawInfo.m_Color = color; drawInfo.m_NoNetMarkColor = cds.GetItemColor( LAYER_NO_CONNECTS ); - drawInfo.m_DrawPanel = aPanel; - drawInfo.m_Mask_margin = mask_margin; - drawInfo.m_ShowNCMark = brd->IsElementVisible( LAYER_NO_CONNECTS ); - drawInfo.m_IsPrinting = screen->m_IsPrinting; + drawInfo.m_Mask_margin = mask_margin; + drawInfo.m_ShowNCMark = brd->IsElementVisible( LAYER_NO_CONNECTS ); + drawInfo.m_IsPrinting = screen->m_IsPrinting; color.a = 0.666; /* Get the pad clearance. This has a meaning only for Pcbnew. @@ -329,25 +193,17 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, (( displ_opts ->m_DisplayNetNamesMode == 0 ) || ( displ_opts->m_DisplayNetNamesMode == 2 )) ) drawInfo.m_Display_netname = false; - // Display net names is restricted to pads that are on the active layer - // in high contrast mode display - if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && - !IsOnLayer( screen->m_Active_Layer ) && displ_opts && displ_opts->m_ContrastModeDisplay ) - drawInfo.m_Display_netname = false; - - DrawShape( aPanel->GetClipBox(), aDC, drawInfo ); + PrintShape( aDC, drawInfo ); } -void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) +void D_PAD::PrintShape( wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) { #define SEGCOUNT 32 // number of segments to approximate a circle wxPoint coord[12]; double angle = m_Orient; int seg_width; - GRSetDrawMode( aDC, aDrawInfo.m_DrawMode ); - // calculate pad shape position : wxPoint shape_pos = ShapePos() - aDrawInfo.m_Offset; @@ -359,20 +215,18 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) { case PAD_SHAPE_CIRCLE: if( aDrawInfo.m_ShowPadFilled ) - GRFilledCircle( aClipBox, aDC, shape_pos.x, shape_pos.y, + GRFilledCircle( nullptr, aDC, shape_pos.x, shape_pos.y, halfsize.x + aDrawInfo.m_Mask_margin.x, 0, aDrawInfo.m_Color, aDrawInfo.m_Color ); else - GRCircle( aClipBox, aDC, shape_pos.x, shape_pos.y, + GRCircle( nullptr, aDC, shape_pos.x, shape_pos.y, halfsize.x + aDrawInfo.m_Mask_margin.x, m_PadSketchModePenSize, aDrawInfo.m_Color ); if( aDrawInfo.m_PadClearance ) { - GRCircle( aClipBox, - aDC, shape_pos.x, shape_pos.y, - halfsize.x + aDrawInfo.m_PadClearance, - 0, aDrawInfo.m_Color ); + GRCircle( nullptr, aDC, shape_pos.x, shape_pos.y, + halfsize.x + aDrawInfo.m_PadClearance, 0, aDrawInfo.m_Color ); } break; @@ -380,28 +234,27 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) case PAD_SHAPE_OVAL: { wxPoint segStart, segEnd; - seg_width = BuildSegmentFromOvalShape(segStart, segEnd, angle, - aDrawInfo.m_Mask_margin); + seg_width = BuildSegmentFromOvalShape( segStart, segEnd, angle, aDrawInfo.m_Mask_margin ); segStart += shape_pos; segEnd += shape_pos; if( aDrawInfo.m_ShowPadFilled ) { - GRFillCSegm( aClipBox, aDC, segStart.x, segStart.y, segEnd.x, segEnd.y, - seg_width, aDrawInfo.m_Color ); + GRFillCSegm( nullptr, aDC, segStart.x, segStart.y, segEnd.x, segEnd.y, seg_width, + aDrawInfo.m_Color ); } else { - GRCSegm( aClipBox, aDC, segStart.x, segStart.y, segEnd.x, segEnd.y, - seg_width, m_PadSketchModePenSize, aDrawInfo.m_Color ); + GRCSegm( nullptr, aDC, segStart.x, segStart.y, segEnd.x, segEnd.y, seg_width, + m_PadSketchModePenSize, aDrawInfo.m_Color ); } // Draw the clearance line if( aDrawInfo.m_PadClearance ) { seg_width += 2 * aDrawInfo.m_PadClearance; - GRCSegm( aClipBox, aDC, segStart.x, segStart.y, segEnd.x, segEnd.y, - seg_width, aDrawInfo.m_Color ); + GRCSegm( nullptr, aDC, segStart.x, segStart.y, segEnd.x, segEnd.y, seg_width, + aDrawInfo.m_Color ); } } break; @@ -413,7 +266,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) for( int ii = 0; ii < 4; ii++ ) coord[ii] += shape_pos; - GRClosedPoly( aClipBox, aDC, 4, coord, aDrawInfo.m_ShowPadFilled, + GRClosedPoly( nullptr, aDC, 4, coord, aDrawInfo.m_ShowPadFilled, aDrawInfo.m_ShowPadFilled ? 0 : m_PadSketchModePenSize, aDrawInfo.m_Color, aDrawInfo.m_Color ); @@ -429,9 +282,8 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) if( poly.PointCount() > 0 ) { - GRClosedPoly( aClipBox, aDC, poly.PointCount(), - (wxPoint*)&poly.Point( 0 ), false, 0, - aDrawInfo.m_Color, aDrawInfo.m_Color ); + GRClosedPoly( nullptr, aDC, poly.PointCount(), (wxPoint*)&poly.Point( 0 ), + false, 0, aDrawInfo.m_Color, aDrawInfo.m_Color ); } } } @@ -457,8 +309,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) SHAPE_LINE_CHAIN& poly = outline.Outline( 0 ); - GRClosedPoly( aClipBox, aDC, poly.PointCount(), - (wxPoint*)&poly.Point( 0 ), filled, 0, + GRClosedPoly( nullptr, aDC, poly.PointCount(), (wxPoint*)&poly.Point( 0 ), filled, 0, aDrawInfo.m_Color, aDrawInfo.m_Color ); if( aDrawInfo.m_PadClearance ) @@ -477,7 +328,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) // Draw the polygon: Inflate creates only one convex polygon SHAPE_LINE_CHAIN& clearance_poly = outline.Outline( 0 ); - GRClosedPoly( aClipBox, aDC, clearance_poly.PointCount(), + GRClosedPoly( nullptr, aDC, clearance_poly.PointCount(), (wxPoint*)&clearance_poly.Point( 0 ), false, 0, aDrawInfo.m_Color, aDrawInfo.m_Color ); } @@ -511,13 +362,12 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) poly[ii] += pad_pos; } - GRClosedPoly( aClipBox, aDC, 4, poly, false, 0, - aDrawInfo.m_Color, aDrawInfo.m_Color ); + GRClosedPoly( nullptr, aDC, 4, poly, false, 0, aDrawInfo.m_Color, + aDrawInfo.m_Color ); } else { - GRCircle( aClipBox, aDC, pad_pos.x, pad_pos.y, - halfsize.x, + GRCircle( nullptr, aDC, pad_pos.x, pad_pos.y, halfsize.x, m_PadSketchModePenSize, aDrawInfo.m_Color ); } } @@ -541,9 +391,8 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) { poly = &outline.Outline( jj ); - GRClosedPoly( aClipBox, aDC, poly->PointCount(), - (wxPoint*)&poly->Point( 0 ), aDrawInfo.m_ShowPadFilled, 0, - aDrawInfo.m_Color, aDrawInfo.m_Color ); + GRClosedPoly( nullptr, aDC, poly->PointCount(), (wxPoint*)&poly->Point( 0 ), + aDrawInfo.m_ShowPadFilled, 0, aDrawInfo.m_Color, aDrawInfo.m_Color ); } if( aDrawInfo.m_PadClearance ) @@ -561,9 +410,8 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) if( poly->PointCount() > 0 ) { - GRClosedPoly( aClipBox, aDC, poly->PointCount(), - (wxPoint*)&poly->Point( 0 ), false, 0, - aDrawInfo.m_Color, aDrawInfo.m_Color ); + GRClosedPoly( nullptr, aDC, poly->PointCount(), (wxPoint*)&poly->Point( 0 ), + false, 0, aDrawInfo.m_Color, aDrawInfo.m_Color ); } } } @@ -588,16 +436,9 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) aDrawInfo.m_HoleColor; COLOR4D hole_color = fillcolor; - if( aDrawInfo.m_IsPrinting ) - { - fillcolor = COLOR4D::WHITE; - blackpenstate = GetGRForceBlackPenState(); - GRForceBlackPen( false ); - } - else - { - GRSetDrawMode( aDC, ( aDrawInfo.m_DrawMode != GR_XOR ) ? GR_COPY : GR_XOR ); - } + fillcolor = COLOR4D::WHITE; + blackpenstate = GetGRForceBlackPenState(); + GRForceBlackPen( false ); if( blackpenstate ) hole_color = COLOR4D::BLACK; @@ -606,8 +447,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) { case PAD_DRILL_SHAPE_CIRCLE: if( aDC->LogicalToDeviceXRel( hole ) > 1 ) // hole is drawn if hole > 1pixel - GRFilledCircle( aClipBox, aDC, holepos.x, holepos.y, hole, 0, - hole_color, fillcolor ); + GRFilledCircle( nullptr, aDC, holepos.x, holepos.y, hole, 0, hole_color, fillcolor ); break; case PAD_DRILL_SHAPE_OBLONG: @@ -616,8 +456,8 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) GetOblongDrillGeometry( drl_start, drl_end, seg_width ); drl_start += holepos; drl_end += holepos; - GRFilledSegment( aClipBox, aDC, drl_start, drl_end, seg_width, fillcolor ); - GRCSegm( aClipBox, aDC, drl_start, drl_end, seg_width, hole_color ); + GRFilledSegment( nullptr, aDC, drl_start, drl_end, seg_width, fillcolor ); + GRCSegm( nullptr, aDC, drl_start, drl_end, seg_width, hole_color ); } break; @@ -629,25 +469,20 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) GRForceBlackPen( blackpenstate ); } - GRSetDrawMode( aDC, aDrawInfo.m_DrawMode ); - // Draw "No connect" ( / or \ or cross X ) if necessary if( GetNetCode() == 0 && aDrawInfo.m_ShowNCMark ) { int dx0 = std::min( halfsize.x, halfsize.y ); if( m_layerMask[F_Cu] ) /* Draw \ */ - GRLine( aClipBox, aDC, holepos.x - dx0, holepos.y - dx0, + GRLine( nullptr, aDC, holepos.x - dx0, holepos.y - dx0, holepos.x + dx0, holepos.y + dx0, 0, aDrawInfo.m_NoNetMarkColor ); if( m_layerMask[B_Cu] ) // Draw / - GRLine( aClipBox, aDC, holepos.x + dx0, holepos.y - dx0, + GRLine( nullptr, aDC, holepos.x + dx0, holepos.y - dx0, holepos.x - dx0, holepos.y + dx0, 0, aDrawInfo.m_NoNetMarkColor ); } - if( !aDrawInfo.m_IsPrinting ) - GRSetDrawMode( aDC, ( aDrawInfo.m_DrawMode != GR_XOR ) ? GR_COPY : GR_XOR ); - // Draw the pad number if( !aDrawInfo.m_Display_padnum && !aDrawInfo.m_Display_netname ) return; @@ -698,7 +533,6 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) constexpr int MIN_CHAR_COUNT = 3; unsigned int tsize; - EDA_RECT* clipBox = aDrawInfo.m_DrawPanel ? aDrawInfo.m_DrawPanel->GetClipBox() : NULL; if( aDrawInfo.m_Display_padnum ) { @@ -709,11 +543,9 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) { // tsize reserve room for marges and segments thickness tsize = ( tsize * 7 ) / 10; - DrawGraphicHaloText( clipBox, aDC, tpos, - aDrawInfo.m_Color, BLACK, WHITE, - m_name, t_angle, - wxSize( tsize , tsize ), GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false, false ); + GRHaloText( aDC, tpos, aDrawInfo.m_Color, BLACK, WHITE, m_name, t_angle, + wxSize( tsize , tsize ), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, + tsize / 7, false, false ); } } @@ -736,11 +568,9 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) // tsize reserve room for marges and segments thickness tsize = ( tsize * 7 ) / 10; - DrawGraphicHaloText( clipBox, aDC, tpos, - aDrawInfo.m_Color, BLACK, WHITE, - shortname, t_angle, wxSize( tsize, tsize ), - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, - tsize / 7, false, false ); + GRHaloText( aDC, tpos, aDrawInfo.m_Color, BLACK, WHITE, shortname, t_angle, + wxSize( tsize, tsize ), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, + tsize / 7, false, false ); } } @@ -752,8 +582,8 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) * aSegStart and aSegEnd are the ending points of the equivalent segment of the shape * aRotation is the asked rotation of the segment (usually m_Orient) */ -int D_PAD::BuildSegmentFromOvalShape(wxPoint& aSegStart, wxPoint& aSegEnd, - double aRotation, const wxSize& aMargin) const +int D_PAD::BuildSegmentFromOvalShape( wxPoint& aSegStart, wxPoint& aSegEnd, double aRotation, + const wxSize& aMargin ) const { int width; diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 26c18d49d4..4316e8a2ab 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -498,7 +497,7 @@ void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, PCB_LAYER_ID layer ) GetScreen()->m_Active_Layer = layer; if( displ_opts->m_ContrastModeDisplay ) - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } @@ -524,7 +523,7 @@ void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent ) } } - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } @@ -532,7 +531,7 @@ void PCB_BASE_FRAME::OnToggleGraphicDrawMode( wxCommandEvent& aEvent ) { auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions(); displ_opts->m_DisplayDrawItemsFill = !displ_opts->m_DisplayDrawItemsFill; - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } @@ -550,7 +549,7 @@ void PCB_BASE_FRAME::OnToggleEdgeDrawMode( wxCommandEvent& aEvent ) view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); } - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } @@ -568,7 +567,7 @@ void PCB_BASE_FRAME::OnToggleTextDrawMode( wxCommandEvent& aEvent ) view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); } - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } @@ -641,8 +640,8 @@ void PCB_BASE_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg ) // must do this after the tool has been set, otherwise pad::Draw() does // not show proper color when GetDisplayOptions().ContrastModeDisplay is true. - if( redraw && m_canvas ) - m_canvas->Refresh(); + if( redraw ) + GetGalCanvas()->Refresh(); } diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index e431b64e1e..147da9e29e 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -219,10 +219,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) EVT_TOOL( ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR, PCB_EDIT_FRAME::OnSelectOptionToolbar ) - // Vertical main toolbar: - EVT_TOOL_RANGE( ID_PCB_HIGHLIGHT_BUTT, ID_PCB_MEASUREMENT_TOOL, - PCB_EDIT_FRAME::OnSelectTool ) - EVT_MENU_RANGE( ID_POPUP_PCB_START_RANGE, ID_POPUP_PCB_END_RANGE, PCB_EDIT_FRAME::Process_Special_Functions ) @@ -397,11 +393,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : GetGalCanvas()->SwitchBackend( m_canvasType ); - // Set up viewport - KIGFX::VIEW* view = galCanvas->GetView(); - view->SetScale( GetZoomLevelCoeff() / m_canvas->GetScreen()->GetZoom() ); - view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); - + galCanvas->GetView()->SetScale( GetZoomLevelCoeff() / m_canvas->GetScreen()->GetZoom() ); ActivateGalCanvas(); // disable Export STEP item if kicad2step does not exist @@ -1034,9 +1026,7 @@ bool PCB_EDIT_FRAME::SetCurrentNetClass( const wxString& aNetClassName ) bool change = GetDesignSettings().SetCurrentNetClass( aNetClassName ); if( change ) - { ReCreateAuxiliaryToolbar(); - } return change; } @@ -1062,10 +1052,9 @@ bool PCB_EDIT_FRAME::FetchNetlistFromSchematic( NETLIST& aNetlist, FETCH_NETLIST { if( Kiface().IsSingle() ) { - DisplayError( this, _( "Cannot update the PCB, because Pcbnew is " - "opened in stand-alone mode. In order to create or update " - "PCBs from schematics, you need to launch the KiCad project manager " - "and create a PCB project." ) ); + DisplayError( this, _( "Cannot update the PCB because Pcbnew is opened in stand-alone " + "mode. In order to create or update PCBs from schematics, you " + "must launch the KiCad project manager and create a project." ) ); return false; } @@ -1251,7 +1240,7 @@ void PCB_EDIT_FRAME::InstallFootprintPropertiesDialog( MODULE* Module ) if( retvalue == DIALOG_FOOTPRINT_BOARD_EDITOR::PRM_EDITOR_EDIT_OK ) { // If something edited, push a refresh request - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } else if( retvalue == DIALOG_FOOTPRINT_BOARD_EDITOR::PRM_EDITOR_EDIT_BOARD_FOOTPRINT ) { @@ -1316,9 +1305,7 @@ void PCB_EDIT_FRAME::LockModule( MODULE* aModule, bool aLocked ) } else { - aModule = GetBoard()->m_Modules; - - for( ; aModule != NULL; aModule = aModule->Next() ) + for( aModule = GetBoard()->m_Modules; aModule != NULL; aModule = aModule->Next() ) { if( WildCompareString( ModulesMaskSelection, aModule->GetReference() ) ) { @@ -1329,22 +1316,19 @@ void PCB_EDIT_FRAME::LockModule( MODULE* aModule, bool aLocked ) } } + bool ExportBoardToHyperlynx( BOARD* aBoard, const wxFileName& aPath ); + void PCB_EDIT_FRAME::OnExportHyperlynx( wxCommandEvent& event ) { - wxString wildcard = wxT("*.hyp"); + wxString wildcard = wxT( "*.hyp" ); wxFileName fn = GetBoard()->GetFileName(); fn.SetExt( wxT("hyp") ); - wxFileDialog dlg( this, - _( "Export Hyperlynx Layout" ), - fn.GetPath(), - fn.GetFullName(), - wildcard, - wxFD_SAVE | wxFD_OVERWRITE_PROMPT - ); + wxFileDialog dlg( this, _( "Export Hyperlynx Layout" ), fn.GetPath(), fn.GetFullName(), + wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); if( dlg.ShowModal() != wxID_OK ) return; @@ -1352,7 +1336,7 @@ void PCB_EDIT_FRAME::OnExportHyperlynx( wxCommandEvent& event ) fn = dlg.GetPath(); // always enforce filename extension, user may not have entered it. - fn.SetExt( wxT("hyp") ); + fn.SetExt( wxT( "hyp" ) ); ExportBoardToHyperlynx( GetBoard(), fn ); } diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index 30039915c7..a60e0e2450 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -464,7 +464,6 @@ public: void OnCloseWindow( wxCloseEvent& Event ) override; void Process_Special_Functions( wxCommandEvent& event ); void Tracks_and_Vias_Size_Event( wxCommandEvent& event ); - void OnSelectTool( wxCommandEvent& aEvent ); /** * Function OnEditTextAndGraphics diff --git a/pcbnew/pcb_layer_widget.cpp b/pcbnew/pcb_layer_widget.cpp index 3da0c2c94e..e657e0f8cf 100644 --- a/pcbnew/pcb_layer_widget.cpp +++ b/pcbnew/pcb_layer_widget.cpp @@ -583,7 +583,7 @@ void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor ) myframe->ReCreateHToolbar(); - myframe->GetCanvas()->Refresh(); + myframe->GetGalCanvas()->Refresh(); if( aLayer == LAYER_PCB_BACKGROUND ) myframe->SetDrawBgColor( aColor ); @@ -605,7 +605,7 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( int aLayer ) if( m_alwaysShowActiveCopperLayer ) OnLayerSelected(); else if( displ_opts->m_ContrastModeDisplay ) - myframe->GetCanvas()->Refresh(); + myframe->GetGalCanvas()->Refresh(); return true; } @@ -649,7 +649,7 @@ void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal } if( isFinal ) - myframe->GetCanvas()->Refresh(); + myframe->GetGalCanvas()->Refresh(); } @@ -683,7 +683,7 @@ void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, COLOR4D aColor ) myframe->ReCreateHToolbar(); - myframe->GetCanvas()->Refresh(); + myframe->GetGalCanvas()->Refresh(); } @@ -719,7 +719,7 @@ void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled ) galCanvas->GetView()->SetLayerVisible( aId, isEnabled ); galCanvas->Refresh(); - myframe->GetCanvas()->Refresh(); + myframe->GetGalCanvas()->Refresh(); } //----------------------------------------------- diff --git a/pcbnew/pcb_legacy_draw_utils.cpp b/pcbnew/pcb_legacy_draw_utils.cpp index 992d572339..d2dc03af29 100644 --- a/pcbnew/pcb_legacy_draw_utils.cpp +++ b/pcbnew/pcb_legacy_draw_utils.cpp @@ -48,12 +48,12 @@ * and we want to see pad through. * The pads must appear on the layers selected in LayerMask */ -static void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* Module, - int ox, int oy, LSET LayerMask, GR_DRAWMODE draw_mode ); +static void Trace_Pads_Only( PCB_BASE_FRAME* aFrame, wxDC* DC, MODULE* Module, + int ox, int oy, LSET LayerMask ); // Redraw the BOARD items but not cursors, axis or grid -void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const wxPoint& offset ) +void BOARD::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset ) { /* The order of drawing is flexible on some systems and not on others. For * OSes which use OR to draw, the order is not important except for the @@ -75,7 +75,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const if( track->IsMoving() ) continue; - track->Draw( aPanel, DC, aDrawMode ); + track->Print( aFrame, DC ); } // Draw areas (i.e. zones) @@ -87,8 +87,8 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const // because these areas are drawn by ManageCursor() in a specific manner if( ( zone->GetEditFlags() & (IN_EDIT | IS_DRAGGED | IS_MOVED) ) == 0 ) { - zone->Draw( aPanel, DC, aDrawMode ); - zone->DrawFilledArea( aPanel, DC, aDrawMode ); + zone->Print( aFrame, DC ); + zone->PrintFilledArea( aFrame, DC ); } } @@ -104,7 +104,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const case PCB_TEXT_T: case PCB_TARGET_T: case PCB_LINE_T: - item->Draw( aPanel, DC, aDrawMode ); + item->Print( aFrame, DC ); break; default: @@ -139,15 +139,15 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const } if( display ) - module->Draw( aPanel, DC, aDrawMode ); + module->Print( aFrame, DC ); else - Trace_Pads_Only( aPanel, DC, module, 0, 0, layerMask, aDrawMode ); + Trace_Pads_Only( aFrame, DC, module, 0, 0, layerMask ); } // draw the BOARD's markers last, otherwise the high light will erase any marker on a pad for( unsigned i = 0; i < m_markers.size(); ++i ) { - m_markers[i]->Draw( aPanel, DC, aDrawMode ); + m_markers[i]->Print( aFrame, DC ); } } @@ -157,12 +157,11 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const * and we want to see pad through. * The pads must appear on the layers selected in LayerMask */ -static void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* aModule, - int ox, int oy, LSET aLayerMask, GR_DRAWMODE draw_mode ) +static void Trace_Pads_Only( PCB_BASE_FRAME* aFrame, wxDC* DC, MODULE* aModule, + int ox, int oy, LSET aLayerMask ) { - auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() ); - - int tmp = displ_opts->m_DisplayPadFill; + PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) aFrame->GetDisplayOptions(); + int tmp = displ_opts->m_DisplayPadFill; displ_opts->m_DisplayPadFill = false; @@ -172,7 +171,7 @@ static void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* aModule, if( (pad->GetLayerSet() & aLayerMask) == 0 ) continue; - pad->Draw( panel, DC, draw_mode, wxPoint( ox, oy ) ); + pad->Print( aFrame, DC, wxPoint( ox, oy ) ); } displ_opts->m_DisplayPadFill = tmp; diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 52aecf296c..7499e1a6c7 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index 575cd9d4c1..4431683f97 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/pcbnew/swig/pcbnew_action_plugins.cpp b/pcbnew/swig/pcbnew_action_plugins.cpp index e705b10ff9..4d6c82670a 100644 --- a/pcbnew/swig/pcbnew_action_plugins.cpp +++ b/pcbnew/swig/pcbnew_action_plugins.cpp @@ -39,7 +39,6 @@ #include #include #include -#include PYTHON_ACTION_PLUGIN::PYTHON_ACTION_PLUGIN( PyObject* aAction ) { diff --git a/pcbnew/tracks_cleaner.cpp b/pcbnew/tracks_cleaner.cpp index 9cc7529dde..584be339e3 100644 --- a/pcbnew/tracks_cleaner.cpp +++ b/pcbnew/tracks_cleaner.cpp @@ -692,7 +692,7 @@ bool PCB_EDIT_FRAME::RemoveMisConnectedTracks() Compile_Ratsnest( true ); } - m_canvas->Refresh( true ); + GetGalCanvas()->Refresh( true ); return isModified; } diff --git a/pcbnew/undo_redo.cpp b/pcbnew/undo_redo.cpp index 5aaaf0ebbb..d33277bc85 100644 --- a/pcbnew/undo_redo.cpp +++ b/pcbnew/undo_redo.cpp @@ -364,7 +364,7 @@ void PCB_BASE_EDIT_FRAME::RestoreCopyFromUndoList( wxCommandEvent& aEvent ) m_toolManager->ProcessEvent( { TC_MESSAGE, TA_UNDO_REDO_POST, AS_GLOBAL } ); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } @@ -393,7 +393,7 @@ void PCB_BASE_EDIT_FRAME::RestoreCopyFromRedoList( wxCommandEvent& aEvent ) m_toolManager->ProcessEvent( { TC_MESSAGE, TA_UNDO_REDO_POST, AS_GLOBAL } ); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } @@ -626,5 +626,5 @@ void PCB_BASE_EDIT_FRAME::RollbackFromUndo() undo->ClearListAndDeleteItems(); delete undo; - GetCanvas()->Refresh(); + GetGalCanvas()->Refresh(); } \ No newline at end of file diff --git a/pcbnew/zones_by_polygon_fill_functions.cpp b/pcbnew/zones_by_polygon_fill_functions.cpp index 6619ff4118..5d2dee01c2 100644 --- a/pcbnew/zones_by_polygon_fill_functions.cpp +++ b/pcbnew/zones_by_polygon_fill_functions.cpp @@ -80,8 +80,6 @@ void PCB_EDIT_FRAME::Check_All_Zones( wxWindow* aActiveWindow ) if( filler.Fill( toFill, true ) ) { m_ZoneFillsDirty = false; - GetGalCanvas()->ForceRefresh(); - GetCanvas()->Refresh(); } } diff --git a/qa/qa_utils/mocks.cpp b/qa/qa_utils/mocks.cpp index 221e5eec84..8d7c9a8496 100644 --- a/qa/qa_utils/mocks.cpp +++ b/qa/qa_utils/mocks.cpp @@ -188,7 +188,7 @@ KIFACE_I& Kiface() FP_LIB_TABLE GFootprintTable; -void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const wxPoint& offset ) +void BOARD::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset ) { } @@ -361,17 +361,8 @@ EDA_DRAW_FRAME* EDA_DRAW_PANEL::GetParent() const return nullptr; } -void* EDA_DRAW_PANEL::GetDisplayOptions() -{ - return nullptr; -} - BASE_SCREEN* EDA_DRAW_PANEL::GetScreen() { return nullptr; } -void DrawAndSizingBlockOutlines(EDA_DRAW_PANEL*, wxDC*, wxPoint const&, bool) -{ - -}