38#include <api/schematic/schematic_types.pb.h>
49 item->RemoveRuleAreaFromCache(
this );
52 label->RemoveConnectedRuleArea(
this );
58 return wxT(
"SCH_RULE_AREA" );
64 return _(
"Rule Area" );
80 kiapi::schematic::types::SchematicRuleArea ruleArea;
82 ruleArea.mutable_id()->set_value(
m_Uuid.AsStdString() );
83 ruleArea.set_locked(
IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
84 : kiapi::common::types::LockedState::LS_UNLOCKED );
88 ruleArea.set_dnp(
m_DNP );
93 aContainer.PackFrom( ruleArea );
99 kiapi::schematic::types::SchematicRuleArea ruleArea;
101 if( !aContainer.UnpackTo( &ruleArea ) )
105 SetLocked( ruleArea.locked() == kiapi::common::types::LockedState::LS_LOCKED );
130 std::vector<SHAPE*> effectiveShapes;
150 for(
int jj = 0; jj < segCount; jj++ )
161 return effectiveShapes;
166 int aUnit,
int aBodyStyle,
const VECTOR2I& aOffset,
bool aDimmed )
175 SCH_SHAPE::Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
177 static std::vector<VECTOR2I> ptList;
183 for(
const VECTOR2I& pt : polyPoints )
184 ptList.push_back( pt );
186 ptList.push_back( polyPoints[0] );
243 color = color.
Mix( bg, 0.5f );
248 aPlotter->
SetDash( pen_size, lineStyle );
250 aPlotter->
PlotPoly( ptList, fill, pen_size,
nullptr );
258 return _(
"Schematic rule area" );
283 std::unordered_set<SCH_DIRECTIVE_LABEL*> attachedDirectives;
286 for(
SCH_ITEM* candidateDirective : candidateDirectives )
290 assert( labelConnectionPoints.size() == 1 );
292 if(
GetPolyShape().CollideEdge( labelConnectionPoints[0],
nullptr, 5 ) )
299 for(
SCH_ITEM* areaItem : ruleAreaItems )
301 if( areaItem->IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } ) )
310 else if( areaItem->IsType( { SCH_PIN_T, SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T } ) )
312 std::vector<VECTOR2I> connectionPoints = areaItem->GetConnectionPoints();
313 wxASSERT( connectionPoints.size() == 1 );
318 else if( areaItem->IsType( { SCH_SYMBOL_T } ) )
336 else if( areaItem->IsType( { SCH_SHEET_T } ) )
338 const BOX2I sheetBb = areaItem->GetBoundingBox();
350std::vector<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>>
353 std::vector<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>> forceUpdateRuleAreas;
359 for(
SCH_ITEM* item : screen->Items() )
367 item->ClearRuleAreasCache();
378 forceUpdateRuleAreas.push_back( { ruleArea, screen } );
382 return forceUpdateRuleAreas;
404const std::vector<std::pair<wxString, SCH_ITEM*>>
407 std::vector<std::pair<wxString, SCH_ITEM*>> resolvedNetclasses;
411 directive->RunOnChildren(
422 if( netclass != wxEmptyString )
423 resolvedNetclasses.push_back( { netclass, directive } );
432 return resolvedNetclasses;
438 aList.emplace_back(
_(
"Rule Area" ), wxEmptyString );
441 msg.Printf( wxS(
"%d" ),
GetPolyShape().Outline( 0 ).PointCount() );
442 aList.emplace_back(
_(
"Points" ), msg );
444 m_stroke.GetMsgPanelInfo( aFrame, aList );
447 wxString resolvedNetclass =
_(
"<None>" );
449 if( netclasses.size() > 0 )
450 resolvedNetclass = netclasses[0].first;
452 aList.emplace_back(
_(
"Resolved netclass" ), resolvedNetclass );
499 const wxString groupAttributes =
_HKI(
"Attributes" );
constexpr EDA_IU_SCALE schIUScale
static const COLOR4D WHITE
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
The base class for create windows for drawing purpose.
KICAD_T Type() const
Returns the type of object.
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
SHAPE_POLY_SET & GetPolyShape()
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
COLOR4D GetFillColor() const
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Implement 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.
std::shared_ptr< wxString > m_text
COLOR4D & Desaturate()
Removes color (in HSL model)
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
void Update(const KIGFX::VIEW_ITEM *aItem, int aUpdateFlags) const override
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, void *aData)=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()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
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.
wxString GetUntranslatedName() const
Get the untranslated field name for storage, variable look-up, etc.
wxString GetShownText(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, const wxString &aVariantName=wxEmptyString, int aDepth=0) const
Base class for any item which can be embedded within the SCHEMATIC container class,...
void SetLocked(bool aLocked) override
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
bool IsLocked() const override
void AddRuleAreaToCache(SCH_RULE_AREA *aRuleArea)
Add a rule area to the item's cache.
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
wxString ResolveText(const wxString &aText, const SCH_SHEET_PATH *aPath, int aDepth=0) const
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.
std::unordered_set< KIID > m_directiveIDs
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
Return a set of all items contained within the rule area.
void addContainedItem(SCH_ITEM *item)
Add an item to the list of items which this rule area affects.
std::unordered_set< KIID > m_prev_items
All SCH_ITEM objectss contained or intersecting the rule area in the previous update.
std::unordered_set< KIID > m_prev_directives
All SCH_DIRECTIVE_LABEL objects attached to the rule area border in the previous update.
void RefreshContainedItemsAndDirectives(SCH_SCREEN *screen)
Refresh the list of items which this rule area affects.
void SetExcludedFromBOMProp(bool aExcludeFromBOM)
bool m_DNP
True if symbol is set to 'Do Not Populate'.
void resetCaches()
Reset all item and directive caches, saving the current state first.
const std::unordered_set< SCH_DIRECTIVE_LABEL * > & GetDirectives() const
Return the set of all directive labels attached to the rule area border.
void addDirective(SCH_DIRECTIVE_LABEL *label)
Add a directive label which applies to items within ths rule area.
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
bool GetExcludedFromBoardProp() const
void SetExcludedFromSimProp(bool aExcludeFromSim)
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_LABEL objects attached to the rule area border. No ownership.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
bool GetExcludedFromSimProp() const
const std::vector< std::pair< wxString, SCH_ITEM * > > GetResolvedNetclasses(const SCH_SHEET_PATH *aSheetPath) const
Resolve the netclass of this rule area from connected directive labels.
void SetDNP(bool aDNP, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
void SetExcludedFromSim(bool aExcludeFromSim, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from simulation flag.
static std::vector< std::pair< SCH_RULE_AREA *, SCH_SCREEN * > > UpdateRuleAreasInScreens(std::unordered_set< SCH_SCREEN * > &screens, KIGFX::SCH_VIEW *view)
Update all rule area connectvity / caches in the given sheet paths.
void SetExcludedFromBOM(bool aExcludeFromBOM, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from schematic bill of materials flag.
std::unordered_set< SCH_ITEM * > m_items
All SCH_ITEM objects currently contained or intersecting the rule area. No ownership.
const std::unordered_set< KIID > & GetPastContainedItems() const
void SetExcludedFromBoardProp(bool aExclude)
std::unordered_set< KIID > m_itemIDs
void RemoveDirective(SCH_DIRECTIVE_LABEL *aLabel)
Remove a directive label from this rule area's caches (called when the label is deleted).
bool GetExcludedFromBOMProp() const
wxString GetClass() const override
Return the class name.
void RemoveItem(SCH_ITEM *aItem)
Remove an item from this rule area's caches (called when the item is deleted).
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Get the message panel info for the rule area.
void SetExcludedFromBoard(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear exclude from board netlist flag.
void SetDNPProp(bool aDNP)
EE_RTREE & Items()
Get 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
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
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.
LINE_STYLE GetLineStyle() const
KIGFX::COLOR4D GetColor() const
@ FILLED_WITH_BG_BODYCOLOR
@ FILLED_SHAPE
Fill with object color.
@ LAYER_DEVICE_BACKGROUND
@ LAYER_SELECTION_SHADOWS
@ REPAINT
Item needs to be redrawn.
KICOMMON_API void PackCustomProperties(google::protobuf::RepeatedPtrField< types::CustomProperty > *aOutput, const EDA_ITEM &aItem)
KICOMMON_API void UnpackCustomProperties(const google::protobuf::RepeatedPtrField< types::CustomProperty > &aInput, EDA_ITEM &aItem)
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, int aLayer)
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.
VECTOR2< int32_t > VECTOR2I