73 m_ShowHiddenText( true ),
74 m_ShowHiddenPins( true ),
75 m_ShowPinsElectricalType( true ),
76 m_ShowDisabled( false ),
77 m_ShowGraphicsDisabled( false ),
78 m_ShowUmbilicals( true ),
79 m_OverrideItemColors( false ),
80 m_TextOffsetRatio( 0.08 ),
116 return dynamic_cast<EESCHEMA_SETTINGS*>(
Kiface().KifaceSettings() );
139 part =
new LIB_PART( wxEmptyString );
143 square->MoveTo( wxPoint( Mils2iu( -200 ), Mils2iu( 200 ) ) );
144 square->SetEndPosition( wxPoint( Mils2iu( 200 ), Mils2iu( -200 ) ) );
148 text->
SetTextSize( wxSize( Mils2iu( 150 ), Mils2iu( 150 ) ) );
149 text->
SetText( wxString( wxT(
"??" ) ) );
161 m_schematic( nullptr )
165 #define HANDLE_ITEM( type_id, type_name ) \ 166 case type_id: draw( (type_name *) item, aLayer ); break 171 const auto item = dynamic_cast<const EDA_ITEM*>( aItem );
176 #ifdef CONNECTIVITY_DEBUG 178 auto sch_item = dynamic_cast<const SCH_ITEM*>( item );
179 auto conn = sch_item ? sch_item->Connection( *g_CurrentSheet ) :
nullptr;
183 auto pos = item->GetBoundingBox().Centre();
184 auto label = conn->Name(
true );
198 BOX2I box = item->GetBoundingBox();
201 box = static_cast<const SCH_COMPONENT*>( item )->GetBodyBoundingBox();
211 switch( item->Type() )
238 default:
return false;
281 COLOR4D lineColor = static_cast<const SCH_LINE*>( aItem )->GetLineColor();
288 COLOR4D busEntryColor = static_cast<const SCH_BUS_WIRE_ENTRY*>( aItem )->GetStrokeColor();
291 color = busEntryColor;
295 COLOR4D junctionColor = static_cast<const SCH_JUNCTION*>( aItem )->GetJunctionColor();
298 color = junctionColor;
324 if( aDrawingShadows )
358 return std::max( width, 1.0f );
422 std::unique_ptr< LIB_PART > tmpPart;
428 drawnPart = tmpPart.get();
436 if( aUnit && item.GetUnit() && aUnit != item.GetUnit() )
439 if( aConvert && item.GetConvert() && aConvert != item.GetConvert() )
442 Draw( &item, aLayer );
449 return VECTOR2D( aCoord.x, -aCoord.y );
570 if( !
TRANSFORM().MapAngles( &sai, &eai ) )
582 double sa = (double) sai * M_PI / 1800.0;
583 double ea = (double) eai * M_PI / 1800.0 ;
600 std::deque<VECTOR2D> vtx;
625 bool foundLayer =
false;
629 for(
int i = 0; i < layers_count; ++i )
631 if( layers[i] == aLayer )
829 const int diam = radius*2;
857 pc = p0 - dir * clock_size ;
869 pc = p0 - dir * clock_size ;
938 p0 +
VECTOR2D( dir.
x + dir.
y, dir.
y - dir.
x ) * radius );
940 p0 +
VECTOR2D( dir.
x - dir.
y, dir.
x + dir.
y ) * radius );
958 float nameLineWidth =
getLineWidth( aPin, drawingShadows );
960 float numLineWidth =
getLineWidth( aPin, drawingShadows );
963 #define PIN_TEXT_MARGIN 4.0 966 enum { INSIDE = 0,
OUTSIDE, ABOVE, BELOW };
967 int size[4] = { 0, 0, 0, 0 };
968 float thickness[4] = { numLineWidth, numLineWidth, numLineWidth, numLineWidth };
976 thickness[INSIDE] = nameLineWidth;
978 text [INSIDE] = aPin->
GetName();
981 thickness[ABOVE] = numLineWidth;
989 thickness[ABOVE] = nameLineWidth;
991 text [ABOVE] = aPin->
GetName();
994 thickness[BELOW] = numLineWidth;
1013 int insideOffset = textOffset;
1014 int outsideOffset = 10;
1016 float aboveOffset = Mils2iu(
PIN_TEXT_MARGIN ) + ( thickness[ABOVE] + lineThickness ) / 2.0;
1017 float belowOffset = Mils2iu(
PIN_TEXT_MARGIN ) + ( thickness[BELOW] + lineThickness ) / 2.0;
1019 if( drawingShadows )
1021 for(
float& t : thickness )
1028 #define SET_DC( i ) \ 1029 m_gal->SetGlyphSize( VECTOR2D( size[i], size[i] ) ); \ 1030 m_gal->SetLineWidth( thickness[i] ); \ 1031 m_gal->SetStrokeColor( colour[i] ) 1161 wxFAIL_MSG(
"Unknown pin orientation" );
1174 std::vector<wxPoint> pts;
1175 std::deque<VECTOR2D> pts_xformed;
1178 for(
const wxPoint &p : pts )
1179 pts_xformed.push_back(
mapCoords( p ) );
1213 if( junctionSize > 1 )
1249 EDA_RECT clip( (wxPoint)start, wxSize( end.
x - start.x, end.
y - start.y ) );
1252 double theta = atan2( end.
y - start.y, end.
x - start.x );
1270 for(
size_t i = 0; i < 10000; ++i )
1274 VECTOR2D next( start.x + strokes[ i % 4 ] * cos( theta ),
1275 start.y + strokes[ i % 4 ] * sin( theta ) );
1281 if(
ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) )
1283 else if( i % 2 == 0 )
1311 switch( aText->
Type() )
1326 if( conn && conn->
IsBus() )
1348 if( drawingShadows )
1372 if( !shownText.IsEmpty() )
1411 ORIENT o = orientations[ 0 ];
1413 for(
auto& i : orientations )
1415 if( i.flag == orientation )
1424 for(
int i = 0; i < o.n_rots; i++ )
1425 item.Rotate( wxPoint(0, 0 ),
true );
1428 item.MirrorVertical( wxPoint( 0, 0 ) );
1431 item.MirrorHorizontal( wxPoint( 0, 0 ) );
1444 originalPart->
GetPins( originalPins, unit, convert );
1447 LIB_PART tempPart( *originalPart );
1449 tempPart.
GetPins( tempPins, unit, convert );
1457 tempItem.SetFlags( aSymbol->
GetFlags() );
1462 for(
unsigned i = 0; i < tempPins.size(); ++ i )
1465 LIB_PIN* tempPin = tempPins[ i ];
1482 draw( &field, aLayer );
1490 if( drawingShadows && !aField->
IsSelected() )
1514 bool underline =
false;
1527 if( static_cast<SCH_COMPONENT*>( aField->
GetParent() )->GetTransform().y1 )
1548 wxPoint textpos = boundaryBox.
Centre();
1553 if( drawingShadows &&
eeconfig()->m_Selection.text_as_box )
1594 if( !drawingShadows || aLabel->
IsSelected() )
1598 std::vector<wxPoint> pts;
1599 std::deque<VECTOR2D> pts2;
1603 for(
const wxPoint& p : pts )
1604 pts2.emplace_back(
VECTOR2D( p.x, p.y ) );
1618 draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1621 if( !drawingShadows ||
eeconfig()->m_Selection.draw_selected_children || !aLabel->
IsSelected() )
1632 if( drawingShadows && !aLabel->
IsSelected() )
1641 if( conn && conn->
IsBus() )
1645 std::vector<wxPoint> pts;
1646 std::deque<VECTOR2D> pts2;
1651 pts2.emplace_back(
VECTOR2D( p.x, p.y ) );
1660 draw( static_cast<const SCH_TEXT*>( aLabel ), aLayer );
1672 if( drawingShadows && !aSheet->
IsSelected() && !sheetPin->IsSelected() )
1682 wxPoint initial_pos = sheetPin->GetTextPos();
1683 wxPoint offset_pos = initial_pos;
1686 switch( sheetPin->GetEdge() )
1695 sheetPin->SetTextPos( offset_pos );
1696 draw( static_cast<SCH_HIERLABEL*>( sheetPin ), aLayer );
1698 sheetPin->SetTextPos( initial_pos );
1723 if( drawingShadows && !
eeconfig()->m_Selection.draw_selected_children && aSheet->
IsSelected() )
1727 draw( &field, aLayer );
1757 if( drawingShadows && !aEntry->
IsSelected() )
1779 draw( &line, aLayer );
1804 if( img_scale != 1.0 )
1827 bm_size.
x /= img_scale;
1828 bm_size.y /= img_scale;
1829 VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
1844 if( drawingShadows && !aMarker->
IsSelected() )
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.
bool IsDangling() const override
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
void draw(const LIB_RECTANGLE *aRect, int aLayer)
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
virtual int GetPenWidth() const =0
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
float GetLineWidth() const
Get the line width.
#define TARGET_BUSENTRY_RADIUS
void drawDanglingSymbol(const wxPoint &aPos, int aWidth, bool aDrawingShadows)
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
SCH_LAYER_ID GetColorLayer() const
int GetOrientation()
Get the display symbol orientation.
The Cairo implementation of the graphics abstraction layer.
wxPoint GetStartPoint() const
bool IsWire() const
Returns true if the line is a wire.
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
void drawPinDanglingSymbol(const VECTOR2I &aPos, bool aDrawingShadows)
wxPoint GetPosition() const override
wxPoint GetPosition() const override
to handle and draw images bitmaps
COLOR4D m_layerColors[LAYER_ID_COUNT]
Define a symbol library graphical text item.
int GetOrientation() const
virtual STROKE_PARAMS GetStroke() const override
static constexpr double IU_PER_MM
Mock up a conversion function.
LIB_PART * GetParent() const
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
wxPoint GetPosition() const override
void GetPoly(std::vector< wxPoint > &aOutput, int aMinSegLen=0)
Convert a Bezier curve to a polygon.
void SetShape(GRAPHIC_PINSHAPE aShape)
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
GRAPHIC_PINSHAPE GetShape() const
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle)
Draw an arc.
Field object used in symbol libraries.
float getTextThickness(const SCH_TEXT *aItem, bool aDrawingShadows) const
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
bool isUnitAndConversionShown(const LIB_ITEM *aItem) const
virtual void DrawBitmap(const BITMAP_BASE &aBitmap)
Draw a bitmap image.
bool IsHypertext() const override
Allows items to support hypertext actions when hovered/clicked.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
double GetTextAngle() const
wxPoint GetPosition() const override
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
void CreateGraphicShape(const RENDER_SETTINGS *aRenderSettings, std::vector< wxPoint > &aPoints, const wxPoint &aPos) override
Calculate the graphic shape (a polygon) associated to the text.
bool draw_selected_children
void CalcRadiusAngles()
Calculate the radius and angle of an arc using the start, end, and center points.
#define DASH_MARK_LEN(aLineWidth)
KIGFX::COLOR4D GetBorderColor() const
bool IsBrightened() 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...
#define IS_ROLLOVER
Rollover active. Used for hyperlink highlighting.
#define DEFAULT_JUNCTION_DIAM
The default bus and wire enty size in mils.
void SetTextSize(const wxSize &aNewSize)
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape.
An abstract base class for deriving all objects that can be added to a VIEW.
wxPoint GetPosition() const override
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
void RevertYAxis()
Mirror the rectangle from the X axis (negate Y pos and size).
float getShadowWidth() const
virtual wxPoint GetSchematicTextOffset(const RENDER_SETTINGS *aSettings) const
EESCHEMA_SETTINGS * eeconfig()
bool IsDangling() const override
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
bool ClipLine(const EDA_RECT *aClipBox, int &x1, int &y1, int &x2, int &y2)
Test if any part of a line falls within the bounds of a rectangle.
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
bool IsVoid() const
Function IsVoid returns true if the field is either empty or holds "~".
void fillIfSelection(int aLayer)
bool IsDanglingEnd() const
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
The base class for drawable items used by schematic library components.
bool IsPowerConnection() const
Return whether this pin forms an implicit power connection: i.e., is hidden and of type POWER_IN.
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populates a std::vector with SCH_FIELDs.
void SetEndPoint(const wxPoint &aPosition)
KIGFX::COLOR4D GetBackgroundColor() const
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Base class for a bus or wire entry.
void AddDrawItem(LIB_ITEM *aItem)
Add a new draw aItem to the draw object list.
const std::vector< wxPoint > & GetPolyPoints() const
PLOT_DASH_TYPE GetStrokeStyle() const
void GetPins(LIB_PINS &aList, int aUnit=0, int aConvert=0)
Return a list of pin object pointers from the draw item list.
std::vector< SCH_FIELD > & GetFields()
void CreateGraphicShape(const RENDER_SETTINGS *aSettings, std::vector< wxPoint > &aPoints, const wxPoint &Pos) override
Calculate the graphic shape (a polygon) associated to the text.
int GetSecondRadiusAngle() const
const wxPoint GetEnd() const
void SetFontBold(const bool aBold)
Set bold property of current font.
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
FILL_TYPE GetFillMode() const
Contains all the knowledge about how to draw graphical object onto any particular output device.
void SetLineStyle(const PLOT_DASH_TYPE aStyle)
void SetType(ELECTRICAL_PINTYPE aType)
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize Don't allow text to become cluttered up in its own fatness.
Auxiliary items (guides, rule, etc)
bool IsDanglingStart() const
void SetEnd(const wxPoint &aPoint)
void SetFlags(STATUS_FLAGS aMask)
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
virtual void SetText(const wxString &aText)
VECTOR2< double > VECTOR2D
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
BITMAP_BASE * GetImage() const
#define DANGLING_SYMBOL_SIZE
bool m_OverrideItemColors
wxPoint GetPosition() const override
wxString const GetElectricalTypeName() const
const wxString & GetName() const
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
bool IsEndDangling() const
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draw a vector type text using preloaded Newstroke font.
const wxSize & GetTextSize() const
int GetPenWidth() const override
const wxPoint GetPosition() const
void SetStartPoint(const wxPoint &aPosition)
void SetLayer(SCH_LAYER_ID aLayer)
Set the layer this item is on.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
float GetDanglineSymbolThickness() const
#define DOT_MARK_LEN(aLineWidth)
Define a library symbol object.
void strokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
EDA_ITEM * GetParent() const
const std::vector< wxPoint > & GetPoints() const
bool m_ShowGraphicsDisabled
void triLine(const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c)
a few functions useful in geometry calculations.
Text appears outside the dimension line (default)
LABEL_SPIN_STYLE GetLabelSpinStyle() const
void SetLineColor(const COLOR4D &aColor)
GRAPHIC_PINSHAPE GetShape() const
Define a sheet pin (label) used in sheets to create hierarchical schematics.
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
std::unique_ptr< LIB_PART > & GetPartRef()
int GetNameTextSize() const
std::unique_ptr< LIB_PART > Flatten() const
Return a flattened symbol inheritance to the caller.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
static VECTOR2D mapCoords(const wxPoint &aCoord)
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
wxPoint GetPosition() const override
void SetFontItalic(bool aItalic)
Set italic property of current font.
#define DEFAULT_LINE_THICKNESS
The default wire width in mils. (can be changed in preference menu)
Object to handle a bitmap image that can be inserted in a schematic.
virtual int GetPenWidth() const
virtual void Scale(const VECTOR2D &aScale)
Scale the context.
double m_MinPlotPenWidth
Sets an absolute minimum pen width for plotting.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
PLOT_DASH_TYPE
Dashed line types.
#define DEFAULT_BUS_THICKNESS
The default noconnect size in mils.
wxPoint GetPosition() const override
static void orientPart(LIB_PART *part, int orientation)
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
std::vector< SCH_SHEET_PIN * > & GetPins()
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon, int aScale=-1) const
Return the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to the...
double GetTextAngleRadians() const
void Normalize()
Ensures that the height ant width are positive.
SCH_FIELD * GetIntersheetRefs()
int externalPinDecoSize(const LIB_PIN &aPin)
const wxString & GetNumber() const
ELECTRICAL_PINTYPE GetType() const
void LoadColors(const COLOR_SETTINGS *aSettings) override
COLOR4D GetColor(int aLayer) const
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
Bezier curves to polygon converter.
COLOR4D m_backgroundColor
void SetGlyphSize(const VECTOR2D aSize)
Set the font glyph size.
virtual void SetStroke(const STROKE_PARAMS &aStroke) override
bool IsForceVisible() const
int GetNumberTextSize() const
int m_DefaultWireThickness
virtual void Restore()
Restore the context.
bool m_DrawBoundingBoxes
Draw GAL bounding boxes in painters.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
void SetName(const wxString &aName)
void SetFontUnderlined(bool aUnderlined)
PLOT_DASH_TYPE GetEffectiveLineStyle() const
Segment description base class to describe items which have 2 end points (track, wire,...
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
const EDA_RECT GetBoundingBox() const override
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
int internalPinDecoSize(const LIB_PIN &aPin)
#define HANDLE_ITEM(type_id, type_name)
#define DEFAULT_WIRE_THICKNESS
The default bus width in mils. (can be changed in preference menu)
ELECTRICAL_PINTYPE GetType() const
bool IsStartDangling() const
double GetImageScale() const
Handle the component boundary box.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
wxPoint GetPosition() const override
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
#define DASH_GAP_LEN(aLineWidth)
#define TARGET_PIN_RADIUS
A base class for most all the KiCad significant classes used in schematics and boards.
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows) const
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
int GetDefaultPenWidth() const
Color settings are a bit different than most of the settings objects in that there can be more than o...
const wxPoint & GetTextPos() const
int GetFirstRadiusAngle() const
void SetStart(const wxPoint &aPoint)
#define DEFAULT_TEXT_SIZE
Ratio of the font height to the baseline of the text above the wire.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
bool GetOverrideSchItemColors() const
#define IS_DANGLING
indicates a pin is dangling
virtual void Save()
Save the context.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
Definition for part library class.
const Vec & GetOrigin() const
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows) const
SCH_SHEET_PATH & CurrentSheet() const override
void SetDefaultPenWidth(int aWidth)
not connected (must be left open)
wxPoint GetParentPosition() const
STATUS_FLAGS GetFlags() const
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
static constexpr int Millimeter2iu(double mm)
bool m_ShowPinsElectricalType
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual const wxString & GetText() const
Return the string associated with the text object.
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
wxPoint GetPosition() const override
bool HasFlag(STATUS_FLAGS aFlag) const
SCH_RENDER_SETTINGS m_schSettings
KICAD_T Type() const
Returns the type of object.
Abstract interface for drawing on a 2D-surface.
Define a bezier curve graphic body item.
wxPoint GetPosition() const override
A color representation with 4 components: red, green, blue, alpha.
wxPoint GetPosition() const override
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
wxPoint GetEndPoint() const