7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 19:21:41 +00:00

Convert remaining legacy drawing code to print code.

This commit is contained in:
Jeff Young 2019-05-31 13:15:25 +01:00
parent 03bab2f4a9
commit d6e9bdf07b
167 changed files with 896 additions and 3180 deletions
3d-viewer/3d_canvas
common
cvpcb
eeschema
gerbview
include
pagelayout_editor
pcbnew
qa/qa_utils

View File

@ -50,7 +50,7 @@
#include <class_text_mod.h>
#include <convert_basic_shapes_to_polygon.h>
#include <trigo.h>
#include <draw_graphic_text.h>
#include <gr_text.h>
#include <utility>
#include <vector>
@ -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<wxPoint> 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 );
}
}

View File

@ -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

View File

@ -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 );

View File

@ -28,11 +28,10 @@
*/
#include <eda_text.h>
#include <draw_graphic_text.h>
#include <gr_text.h>
#include <eda_rect.h>
#include <macros.h>
#include <trigo.h> // RotatePoint
#include <class_drawpanel.h> // EDA_DRAW_PANEL
#include <basic_gal.h>
#include <base_units.h>
@ -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<wxPoint>* cornerBuffer = static_cast<std::vector<wxPoint>*>( 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<wxPoint>& aCornerBuffer ) const
{
wxSize size = GetTextSize();
@ -500,7 +482,7 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& 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<wxPoint>& 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 );
}
}

View File

@ -37,7 +37,7 @@
#include <trigo.h>
#include <macros.h>
#include <base_screen.h>
#include <draw_graphic_text.h>
#include <gr_text.h>
#include <basic_gal.h>
@ -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 );

View File

@ -34,7 +34,6 @@
#include <msgpanel.h>
#include <draw_frame.h>
#include <confirm.h>
#include <kicad_device_context.h>
#include <dialog_helpers.h>
#include <lockfile.h>
#include <trace_helpers.h>
@ -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 );

View File

@ -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 )
{
}

View File

@ -36,7 +36,6 @@
#include <msgpanel.h>
#include <draw_frame.h>
#include <confirm.h>
#include <kicad_device_context.h>
#include <dialog_helpers.h>
#include <base_units.h>
#include <math/box2.h>
@ -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;
}

View File

@ -32,9 +32,6 @@
#include <class_drawpanel.h>
#include <base_screen.h>
#include <trace_helpers.h>
#include <kicad_device_context.h>
#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();
}

View File

@ -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<wxPoint> 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
);
}

View File

@ -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<wxPoint> 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 );
}

View File

@ -50,7 +50,7 @@
*/
#include <fctsys.h>
#include <draw_graphic_text.h>
#include <gr_text.h>
#include <eda_rect.h>
#include <view/view.h>
#include <ws_painter.h>

View File

@ -46,7 +46,7 @@
#include <fctsys.h>
#include <kiface_i.h>
#include <draw_graphic_text.h>
#include <gr_text.h>
#include <ws_painter.h>
#include <title_block.h>
#include <ws_draw_item.h>

View File

@ -50,7 +50,7 @@
#include <fctsys.h>
#include <eda_rect.h>
#include <draw_graphic_text.h>
#include <gr_text.h>
#include <ws_draw_item.h>
#include <ws_data_model.h>
#include <base_units.h>
@ -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<wxPoint> 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 );
}

View File

@ -27,7 +27,7 @@
#include <plotter.h>
#include <ws_painter.h>
#include <base_screen.h>
#include <draw_graphic_text.h>
#include <gr_text.h>
#include <title_block.h>
#include "ws_draw_item.h"
#include "ws_data_item.h"

View File

@ -46,7 +46,7 @@
#include <plotter.h>
#include <macros.h>
#include <base_screen.h>
#include <draw_graphic_text.h>
#include <gr_text.h>
#include <geometry/shape_line_chain.h>
#include <geometry/geometry_utils.h>

View File

@ -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 );
}

View File

@ -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 );

View File

@ -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; }

View File

@ -35,7 +35,7 @@
#include <sch_draw_panel.h>
#include <general.h>
#include <draw_graphic_text.h>
#include <gr_text.h>
#include <confirm.h>
#include <sch_text.h>
#include <typeinfo>

View File

@ -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 );

View File

@ -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 );

View File

@ -25,11 +25,10 @@
#include <fctsys.h>
#include <gr_basic.h>
#include <base_struct.h>
#include <draw_graphic_text.h>
#include <gr_text.h>
#include <sch_draw_panel.h>
#include <confirm.h>
#include <sch_edit_frame.h>
#include <kicad_device_context.h>
#include <tool/tool_manager.h>
#include <tools/ee_actions.h>
#include <general.h>

View File

@ -31,7 +31,6 @@
#include <sch_draw_panel.h>
#include <confirm.h>
#include <sch_edit_frame.h>
#include <kicad_device_context.h>
#include <msgpanel.h>
#include <tool/tool_manager.h>
#include <tools/ee_actions.h>

View File

@ -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 );
}

Some files were not shown because too many files have changed in this diff Show More