25 #include <wx/wupdlock.h> 26 #include <wx/dataview.h> 27 #include <wx/settings.h> 35 #define WX_DATAVIEW_WINDOW_PADDING 6 80 const std::map<KIID, EDA_ITEM*>& aItemMap )
const 94 severity += wxT(
" (excluded)" );
101 if( ii != aItemMap.end() )
102 mainItem = ii->second;
106 if( ii != aItemMap.end() )
107 auxItem = ii->second;
114 if( mainItem && auxItem )
153 const std::shared_ptr<RC_ITEM> rc_item = node->
m_RcItem;
160 if( rc_item->GetParent() )
161 return rc_item->GetParent()->GetUUID();
177 m_editFrame( aParentFrame ),
180 m_rcItemsProvider( nullptr )
182 m_view->GetMainWindow()->Connect( wxEVT_SIZE,
199 wxWindowUpdateLocker updateLock(
m_view );
201 std::shared_ptr<RC_ITEM> selectedRcItem =
nullptr;
206 selectedRcItem = selectedNode ? selectedNode->
m_RcItem :
nullptr;
238 for(
int i = 0; i < count; ++i )
245 if( rcItem->GetMainItemID() !=
niluuid )
248 if( rcItem->GetAuxItemID() !=
niluuid )
251 if( rcItem->GetAuxItem2ID() !=
niluuid )
254 if( rcItem->GetAuxItem3ID() !=
niluuid )
268 m_view->AssociateModel(
this );
273 m_view->AppendTextColumn( wxEmptyString, 0, wxDATAVIEW_CELL_INERT, width );
283 if( candidate->m_RcItem == selectedRcItem )
315 if(
ToNode( aItem ) ==
nullptr )
329 wxDataViewItemArray& aChildren )
const 332 const std::vector<RC_TREE_NODE*>& children = node ? node->
m_Children :
m_tree;
335 aChildren.push_back(
ToItem( child ) );
337 return children.size();
342 wxDataViewItem
const& aItem,
343 unsigned int aCol )
const 346 const std::shared_ptr<RC_ITEM> rcItem = node->
m_RcItem;
354 if( rcItem->GetParent() && rcItem->GetParent()->IsExcluded() )
355 prefix =
_(
"Excluded " );
370 aVariant = prefix + rcItem->GetErrorMessage();
407 wxDataViewItemAttr& aAttr )
const 417 aAttr.SetBold(
true );
421 if( node->
m_RcItem->GetParent() && node->
m_RcItem->GetParent()->IsExcluded() )
423 wxColour textColour = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXTEXT );
426 if( brightness > 0.5 )
428 int lightness = static_cast<int>( brightness * ( heading ? 50 : 60 ) );
429 aAttr.SetColour( textColour.ChangeLightness( lightness ) );
433 aAttr.SetColour( textColour.ChangeLightness( heading ? 170 : 165 ) );
436 aAttr.SetItalic(
true );
453 wxDataViewModel::ValueChanged(
ToItem( aNode ), 0 );
456 wxDataViewModel::ValueChanged(
ToItem( child ), 0 );
470 const std::shared_ptr<RC_ITEM> current_item = current_node ? current_node->
m_RcItem :
nullptr;
473 std::vector<RC_TREE_NODE*> to_delete;
475 if( aCurrentOnly && !current_item )
485 bool itemDeleted =
false;
498 bool excluded = marker ? marker->
IsExcluded() :
false;
500 if( aCurrentOnly && itemDeleted && lastGood >= 0 )
503 if( aCurrentOnly && rcItem != current_item )
509 if( excluded && !aIncludeExclusions )
512 if( i < (
int)
m_tree.size() )
515 wxDataViewItemArray childItems;
516 wxDataViewItem parentItem =
ToItem(
m_tree[i]->m_Parent );
520 childItems.push_back(
ToItem( child ) );
521 to_delete.push_back( child );
524 m_tree[i]->m_Children.clear();
525 ItemsDeleted( markerItem, childItems );
527 to_delete.push_back(
m_tree[i] );
529 ItemDeleted( parentItem, markerItem );
542 if(
m_view && aCurrentOnly && lastGood >= 0 )
562 currentNode = currentNode->
m_Parent;
566 if( candidate == currentNode )
569 prevMarker = candidate;
582 currentNode = currentNode->
m_Parent;
585 bool trigger = currentNode ==
nullptr;
589 if( candidate == currentNode )
595 nextMarker = candidate;
609 if( candidate->m_RcItem->GetParent() == aMarker )
622 if( candidate->m_RcItem->GetParent() == aMarker )
635 if(
m_view->GetColumnCount() > 0 )
636 m_view->GetColumn( 0 )->SetWidth( width );
void DeleteItems(bool aCurrentOnly, bool aIncludeExclusions, bool aDeep)
Deletes the current item or all items.
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
virtual void DeleteAllItems(bool aIncludeExclusions, bool aDeep)=0
double GetBrightness() const
Returns the brightness value of the color ranged from 0.0 to 1.0.
static wxDataViewItem ToItem(RC_TREE_NODE const *aNode)
void SetProvider(RC_ITEMS_PROVIDER *aProvider)
void CenterMarker(const MARKER_BASE *aMarker)
Implementation of conversion functions that require both schematic and board internal units.
bool GetAttr(wxDataViewItem const &aItem, unsigned int aCol, wxDataViewItemAttr &aAttr) const override
Called by the wxDataView to fetch an item's formatting.
static KIID ToUUID(wxDataViewItem aItem)
virtual SEVERITY GetSeverity(int aErrorCode) const
#define WX_DATAVIEW_WINDOW_PADDING
virtual wxPoint GetPosition() const
virtual int GetCount(int aSeverity=-1) const =0
The base class for create windows for drawing purpose.
void DeleteCurrentItem(bool aDeep)
void SetSeverities(int aSeverities)
Provide an abstract interface of a RC_ITEM* list manager.
void GetValue(wxVariant &aVariant, wxDataViewItem const &aItem, unsigned int aCol) const override
Called by the wxDataView to fetch an item's value.
wxString GetErrorText() const
std::vector< RC_TREE_NODE * > m_Children
virtual wxString GetViolatingRuleDesc() const
RC_ITEMS_PROVIDER * m_rcItemsProvider
std::shared_ptr< RC_ITEM > m_RcItem
void rebuildModel(RC_ITEMS_PROVIDER *aProvider, int aSeverities)
static RC_TREE_NODE * ToNode(wxDataViewItem aItem)
static wxString ShowCoord(EDA_UNITS aUnits, const wxPoint &aPos)
Format a coordinate or position to text.
RC_TREE_MODEL(EDA_DRAW_FRAME *aParentFrame, wxDataViewCtrl *aView)
void SelectMarker(const MARKER_BASE *aMarker)
Functions to provide common constants and other functions to assist in making a consistent UI.
virtual KIID GetMainItemID() const
EDA_DRAW_FRAME * m_editFrame
wxString m_errorMessage
A message describing the details of this specific error.
void onSizeView(wxSizeEvent &aEvent)
virtual KIID GetAuxItemID() const
virtual void SetSeverities(int aSeverities)=0
unsigned int GetChildren(wxDataViewItem const &aItem, wxDataViewItemArray &aChildren) const override
virtual EDA_ITEM * GetItem(const KIID &aId) const
Fetch an item by KIID.
void AddItem(EDA_ITEM *aItem)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
std::vector< RC_TREE_NODE * > m_tree
virtual wxString ShowReport(EDA_UNITS aUnits, SEVERITY aSeverity, const std::map< KIID, EDA_ITEM * > &aItemMap) const
Translate this object into a text string suitable for saving to disk in a report.
virtual std::shared_ptr< RC_ITEM > GetItem(int aIndex) const =0
Retrieve a RC_ITEM by index.
MARKER_BASE * m_parent
The marker this item belongs to, if any.
void SetItems(const KIIDS &aIds)
virtual wxString GetSelectMenuText(EDA_UNITS aUnits) const
Return the text to display to be used in the selection clarification context menu when multiple items...
A base class for most all the KiCad significant classes used in schematics and boards.
wxString GetSettingsKey() const
void ValueChanged(const RC_TREE_NODE *aNode)
bool IsContainer(wxDataViewItem const &aItem) const override
wxDataViewItem GetParent(wxDataViewItem const &aItem) const override
virtual wxString GetErrorMessage() const
Return the error message of a RC_ITEM.
virtual void DeleteItem(int aIndex, bool aDeep)=0
Remove (and optionally deletes) the indexed item from the list.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
A color representation with 4 components: red, green, blue, alpha.