44 return wxT(
"SCH_RULE_AREA" );
50 return _(
"Rule Area" );
71 std::vector<SHAPE*> effectiveShapes;
88 if( width > 0 || !
IsFilled() || aEdgeOnly )
92 for(
int jj = 0; jj < segCount; jj++ )
104 return effectiveShapes;
109 int aUnit,
int aBodyStyle,
const VECTOR2I& aOffset,
bool aDimmed )
118 SCH_SHAPE::Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
120 static std::vector<VECTOR2I> ptList;
126 for(
const VECTOR2I& pt : polyPoints )
128 ptList.push_back( pt );
131 ptList.push_back( polyPoints[0] );
145 case FILL_T::FILLED_SHAPE:
148 case FILL_T::FILLED_WITH_COLOR:
152 case FILL_T::FILLED_WITH_BG_BODYCOLOR:
161 lineStyle = LINE_STYLE::SOLID;
168 if( lineStyle == LINE_STYLE::DEFAULT )
169 lineStyle = LINE_STYLE::SOLID;
171 if(
m_fill == FILL_T::FILLED_SHAPE )
174 fill = FILL_T::NO_FILL;
179 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->
GetColorMode() )
190 aPlotter->
SetDash( pen_size, lineStyle );
192 aPlotter->
PlotPoly( ptList, fill, pen_size );
194 aPlotter->
SetDash( pen_size, LINE_STYLE::SOLID );
200 return _(
"Schematic rule area" );
218 std::vector<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>>& forceUpdateRuleAreas )
224 std::unordered_set<SCH_DIRECTIVE_LABEL*> attachedDirectives;
227 for(
SCH_ITEM* candidateDirective : candidateDirectives )
231 assert( labelConnectionPoints.size() == 1 );
233 if(
GetPolyShape().CollideEdge( labelConnectionPoints[0],
nullptr, 5 ) )
241 forceUpdateRuleAreas.push_back( {
this, screen } );
246 for(
SCH_ITEM* areaItem : ruleAreaItems )
248 if( areaItem->IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } ) )
259 else if( areaItem->IsType(
260 { SCH_PIN_T, SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T } ) )
262 std::vector<VECTOR2I> connectionPoints = areaItem->GetConnectionPoints();
263 assert( connectionPoints.size() == 1 );
270 else if( areaItem->IsType( { SCH_SYMBOL_T } ) )
280 std::unordered_set<SCH_ITEM*> items =
m_items;
283 items.insert( item );
289std::vector<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>>
293 std::vector<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>> forceUpdateRuleAreas;
313 return forceUpdateRuleAreas;
331 std::vector<std::pair<wxString, SCH_ITEM*>> resolvedNetclasses;
335 directive->RunOnChildren(
340 SCH_FIELD* field = static_cast<SCH_FIELD*>( aChild );
342 if( field->GetCanonicalName() == wxT(
"Netclass" ) )
344 wxString netclass = field->GetText();
346 if( netclass != wxEmptyString )
347 resolvedNetclasses.push_back( { netclass, directive } );
355 return resolvedNetclasses;
363 label->ClearConnectedRuleAreas();
368 item->ClearRuleAreasCache();
374 aList.emplace_back(
_(
"Rule Area" ), wxEmptyString );
377 msg.Printf( wxS(
"%d" ),
GetPolyShape().Outline( 0 ).PointCount() );
378 aList.emplace_back(
_(
"Points" ), msg );
382 const std::vector<std::pair<wxString, SCH_ITEM*>> netclasses =
384 wxString resolvedNetclass =
_(
"<None>" );
386 if( netclasses.size() > 0 )
387 resolvedNetclass = netclasses[0].first;
389 aList.emplace_back(
_(
"Resolved netclass" ), resolvedNetclass );
407 label->ClearConnectedRuleAreas();
427 item->ClearRuleAreasCache();
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
SHAPE_POLY_SET & GetPolyShape()
COLOR4D GetFillColor() const
Implements an R-tree for fast spatial and type indexing of schematic items.
EE_TYPE Overlapping(const BOX2I &aRect) const
A color representation with 4 components: red, green, blue, alpha.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Base plotter engine class.
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle)=0
bool GetColorMode() const
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr)=0
Draw a polygon ( filled or not ).
virtual void SetColor(const COLOR4D &color)=0
Provide class metadata.Helper macro to map type hashes to names.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
void AddConnectedRuleArea(SCH_RULE_AREA *aRuleArea)
Adds an entry to the connected rule area cache.
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
void AddRuleAreaToCache(SCH_RULE_AREA *aRuleArea)
Adds a rule area to the item's cache.
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Segment description base class to describe items which have 2 end points (track, wire,...
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
const KIGFX::COLOR4D & GetBackgroundColor() const override
Return current background color settings.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the EDA_SHAPE.
const std::unordered_set< SCH_ITEM * > & GetContainedItems() const
Returns a set of all items contained within the rule area.
void ResetDirectivesAndItems(KIGFX::SCH_VIEW *view)
Clears and resets items and directives attached to this rule area.
void ResetCaches(KIGFX::SCH_VIEW *view)
Resets all item and directive caches, saving the current state first.
void addContainedItem(SCH_ITEM *item)
@briefs Adds an item to the list of items which this rule area affects
void addDirective(SCH_DIRECTIVE_LABEL *label, KIGFX::SCH_VIEW *view)
Adds a directive label which applies to items within ths rule area.
const std::unordered_set< SCH_DIRECTIVE_LABEL * > & GetDirectives() const
Returns the set of all directive labels attached to the rule area border.
wxString GetFriendlyName() const override
virtual void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
std::unordered_set< SCH_DIRECTIVE_LABEL * > m_directives
All SCH_DIRECTIVE_LABELs attached to the rule area border.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
std::unordered_set< SCH_ITEM * > m_prev_items
All SCH_ITEMs contained or intersecting the rule area in the previous update.
void RefreshContainedItemsAndDirectives(SCH_SCREEN *screen, KIGFX::SCH_VIEW *view, std::vector< std::pair< SCH_RULE_AREA *, SCH_SCREEN * > > &forceUpdateRuleAreas)
Refreshes the list of items which this rule area affects.
std::unordered_set< SCH_DIRECTIVE_LABEL * > m_prev_directives
All SCH_DIRECTIVE_LABELs attached to the rule area border in the previous update.
std::unordered_set< SCH_ITEM * > GetPastAndPresentContainedItems() const
Fetches all items which were, or are, within the rule area.
static std::vector< std::pair< SCH_RULE_AREA *, SCH_SCREEN * > > UpdateRuleAreasInScreens(std::unordered_set< SCH_SCREEN * > &screens, KIGFX::SCH_VIEW *view)
Updates all rule area connectvity / caches in the given sheet paths.
std::unordered_set< SCH_ITEM * > m_items
All SCH_ITEMs currently contained or intersecting the rule area.
const std::vector< std::pair< wxString, SCH_ITEM * > > GetResolvedNetclasses() const
Resolves the netclass of this rule area from connected directive labels.
void clearContainedItems()
Clears the list of items which this rule area affects.
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
void clearDirectives(KIGFX::SCH_VIEW *view)
Clears the list of directives.
wxString GetClass() const override
Return the class name.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Gets the message panel info for the rule area.
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the SCH_SHAPE.
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
STROKE_PARAMS GetStroke() const override
int GetEffectiveWidth() const override
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int SegmentCount() const
Return the number of segments in this line chain.
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
const std::vector< VECTOR2I > & CPoints() const
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int OutlineCount() const
Return the number of outlines in the set.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
void GetMsgPanelInfo(UNITS_PROVIDER *aUnitsProvider, std::vector< MSG_PANEL_ITEM > &aList, bool aIncludeStyle=true, bool aIncludeWidth=true)
LINE_STYLE GetLineStyle() const
KIGFX::COLOR4D GetColor() const
@ LAYER_DEVICE_BACKGROUND
@ LAYER_SELECTION_SHADOWS
@ REPAINT
Item needs to be redrawn.
static struct SCH_RULE_AREA_DESC _SCH_RULE_AREA_DESC
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
static bool Collide(const SHAPE_CIRCLE &aA, const SHAPE_CIRCLE &aB, int aClearance, int *aActual, VECTOR2I *aLocation, VECTOR2I *aMTV)
BOX2I boundingBox(T aObject)
Used by SHAPE_INDEX to get the bounding box of a generic T object.
LINE_STYLE
Dashed line types.
The EE_TYPE struct provides a type-specific auto-range iterator to the RTree.