41 using namespace KIGFX;
73 const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
91 aVars->push_back( wxT(
"KICAD_VERSION" ) );
92 aVars->push_back( wxT(
"#" ) );
93 aVars->push_back( wxT(
"##" ) );
94 aVars->push_back( wxT(
"SHEETNAME" ) );
95 aVars->push_back( wxT(
"FILENAME" ) );
96 aVars->push_back( wxT(
"PAPER" ) );
97 aVars->push_back( wxT(
"LAYER" ) );
106 std::function<bool( wxString* )> wsResolver =
107 [ this ]( wxString* token ) ->
bool 109 bool tokenUpdated =
false;
111 if( token->IsSameAs( wxT(
"KICAD_VERSION" ) ) &&
PgmOrNull() )
118 Pgm().App().GetAppName(),
122 else if( token->IsSameAs( wxT(
"#" ) ) )
127 else if( token->IsSameAs( wxT(
"##" ) ) )
132 else if( token->IsSameAs( wxT(
"SHEETNAME" ) ) )
134 *token = m_sheetFullName;
137 else if( token->IsSameAs( wxT(
"FILENAME" ) ) )
139 wxFileName fn( m_fileName );
140 *token = fn.GetFullName();
143 else if( token->IsSameAs( wxT(
"PAPER" ) ) )
145 *token = m_paperFormat ? *m_paperFormat : wxString(
"" );
148 else if( token->IsSameAs( wxT(
"LAYER" ) ) )
150 *token = m_sheetLayer ? *m_sheetLayer : wxString(
"" );
153 else if( m_titleBlock )
155 m_titleBlock->TextVarResolver( token, m_project );
169 return ExpandTextVars( aTextbase, &wsResolver,
nullptr, m_project );
175 auto item = dynamic_cast<const EDA_ITEM*>( aItem );
180 switch( item->Type() )
188 default:
return false;
197 m_gal->SetIsStroke(
true );
198 m_gal->SetIsFill(
false );
199 m_gal->SetStrokeColor( m_renderSettings.GetColor( aItem, aLayer ) );
200 m_gal->SetLineWidth( std::max( aItem->
GetPenWidth(), m_renderSettings.GetDefaultPenWidth() ) );
207 m_gal->SetIsStroke(
true );
208 m_gal->SetIsFill(
false );
209 m_gal->SetStrokeColor( m_renderSettings.GetColor( aItem, aLayer ) );
210 m_gal->SetLineWidth( std::max( aItem->
GetPenWidth(), m_renderSettings.GetDefaultPenWidth() ) );
217 m_gal->SetFillColor( m_renderSettings.GetColor( aItem, aLayer ) );
218 m_gal->SetIsFill(
true );
219 m_gal->SetIsStroke(
false );
226 m_gal->DrawPolygon( outline );
235 m_renderSettings.GetDefaultPenWidth() );
238 m_gal->Translate( position );
240 m_gal->SetStrokeColor( m_renderSettings.GetColor( aItem, aLayer ) );
241 m_gal->SetLineWidth( penWidth );
242 m_gal->SetTextAttributes( aItem );
243 m_gal->SetIsFill(
false );
244 m_gal->SetIsStroke(
true );
253 auto* bitmap = static_cast<DS_DATA_ITEM_BITMAP*>( aItem->
GetPeer() );
256 m_gal->Translate( position );
260 double img_scale = bitmap->m_ImageBitmap->GetScale();
262 if( img_scale != 1.0 )
263 m_gal->Scale(
VECTOR2D( img_scale, img_scale ) );
265 m_gal->DrawBitmap( *bitmap->m_ImageBitmap );
267 #if 0 // For bounding box debug purpose only 269 m_gal->SetIsFill(
true );
270 m_gal->SetIsStroke(
true );
271 m_gal->SetFillColor(
COLOR4D( 1, 1, 1, 0.4 ) );
272 m_gal->SetStrokeColor(
COLOR4D( 0, 0, 0, 1 ) );
274 if( img_scale != 1.0 )
275 m_gal->Scale(
VECTOR2D( 1.0, 1.0 ) );
291 m_gal->SetIsStroke(
true );
294 m_gal->SetStrokeColor( m_renderSettings.m_pageBorderColor );
295 m_gal->SetIsFill(
false );
296 m_gal->SetLineWidth( m_renderSettings.GetDefaultPenWidth() );
298 m_gal->DrawRectangle( origin, end );
303 m_gal->SetStrokeColor( m_renderSettings.m_pageBorderColor );
307 m_gal->DrawCircle( pos, marker_size );
308 m_gal->DrawLine(
VECTOR2D( pos.
x - marker_size, pos.
y - marker_size),
309 VECTOR2D( pos.
x + marker_size, pos.
y + marker_size ) );
310 m_gal->DrawLine(
VECTOR2D( pos.
x + marker_size, pos.
y - marker_size),
311 VECTOR2D( pos.
x - marker_size, pos.
y + marker_size ) );
321 m_gal->SetIsStroke(
true );
323 m_gal->SetStrokeColor( m_renderSettings.m_pageBorderColor );
324 m_gal->SetIsFill(
false );
325 m_gal->DrawRectangle( origin, end );
int OutlineCount() const
Return the number of vertices in a given outline/hole.
const wxPoint & GetMarkerPos() const
The Cairo implementation of the graphics abstraction layer.
wxString BuildFullText(const wxString &aTextbase)
Return the full text corresponding to the aTextbase, after replacing format symbols by the correspond...
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
COLOR4D m_layerColors[LAYER_ID_COUNT]
wxPoint GetPosition() const override
int GetHeightMils() const
void DrawBorder(const PAGE_INFO *aPageInfo, int aScaleFactor) const
double GetTextAngle() const
bool IsBrightened() const
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
An abstract base class for deriving all objects that can be added to a VIEW.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
const wxPoint & GetStart() const
static const wxString productName
const wxPoint & GetStart() const
static void GetContextualTextVars(wxArrayString *aVars)
COLOR4D m_brightenedColor
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
COLOR4D Brightened(double aFactor) const
Return a color that is brighter by a given factor, without modifying object.
const wxPoint GetEnd() const
SHAPE_POLY_SET & GetPolygons()
VECTOR2< double > VECTOR2D
PGM_BASE * PgmOrNull()
similar to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from...
wxString GetBuildVersion()
Get the full KiCad version string.
static void GetTextVars(wxArrayString *aVars)
virtual void update()
Precalculates extra colors for layers (e.g.
SHAPE_LINE_CHAIN & Outline(int aIndex)
const wxPoint GetOrigin() const
Describe the page size and margins of a paper page on which to eventually print or plot.
wxSize GetPageSize() const
COLOR4D m_pageBorderColor
A rectangle with thick segment showing the page limits and a marker showing the coordinate origin.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Non filled rectangle with thick segment.
COLOR4D GetColor(int aLayer) const
DS_DATA_ITEM * GetPeer() const
COLOR4D m_backgroundColor
VECTOR2< T > Rotate(double aAngle) const
Rotate the vector by a given angle.
double GetMarkerSize() const
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
Handle the component boundary box.
A base class for most all the KiCad significant classes used in schematics and boards.
Color settings are a bit different than most of the settings objects in that there can be more than o...
const wxPoint & GetTextPos() const
const wxPoint & GetEnd() const
virtual bool Draw(const VIEW_ITEM *, int) override
Takes an instance of VIEW_ITEM and passes it to a function that knows how to draw the item.
virtual int GetPenWidth() const
BASE_SCREEN class implementation.
void LoadColors(const COLOR_SETTINGS *aSettings) override
virtual wxString GetShownText(int aDepth=0) const
Return the string actually shown after processing of the base text.
const wxPoint & GetEnd() const
void draw(const DS_DRAW_ITEM_LINE *aItem, int aLayer) const
A color representation with 4 components: red, green, blue, alpha.