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
96 severity += wxT(
" (excluded)" );
103 if( ii != aItemMap.end() )
104 mainItem = ii->second;
108 if( ii != aItemMap.end() )
109 auxItem = ii->second;
116 if( mainItem && auxItem )
155 const std::shared_ptr<RC_ITEM> rc_item = node->
m_RcItem;
162 if( rc_item->GetParent() )
163 return rc_item->GetParent()->GetUUID();
179 m_editFrame( aParentFrame ),
182 m_rcItemsProvider( nullptr )
198 wxWindowUpdateLocker updateLock(
m_view );
200 std::shared_ptr<RC_ITEM> selectedRcItem =
nullptr;
205 selectedRcItem = selectedNode ? selectedNode->
m_RcItem :
nullptr;
233 for(
int i = 0; i < count; ++i )
240 if( rcItem->GetMainItemID() !=
niluuid )
243 if( rcItem->GetAuxItemID() !=
niluuid )
246 if( rcItem->GetAuxItem2ID() !=
niluuid )
249 if( rcItem->GetAuxItem3ID() !=
niluuid )
263 m_view->AssociateModel(
this );
268 m_view->AppendTextColumn( wxEmptyString, 0, wxDATAVIEW_CELL_INERT, width );
278 if( candidate->m_RcItem == selectedRcItem )
304 if(
ToNode( aItem ) ==
nullptr )
318 wxDataViewItemArray& aChildren )
const
321 const std::vector<RC_TREE_NODE*>& children = node ? node->
m_Children :
m_tree;
324 aChildren.push_back(
ToItem( child ) );
326 return children.size();
331 wxDataViewItem
const& aItem,
332 unsigned int aCol )
const
335 const std::shared_ptr<RC_ITEM> rcItem = node->
m_RcItem;
343 if( rcItem->GetParent() )
345 SEVERITY severity = rcItem->GetParent()->GetSeverity();
350 prefix =
_(
"Excluded warning: " );
352 prefix =
_(
"Excluded error: " );
356 prefix =
_(
"Warning: " );
360 prefix =
_(
"Error: " );
364 aVariant = prefix + rcItem->GetErrorMessage();
371 aVariant =
_(
"Drawing Sheet" );
408 wxDataViewItemAttr& aAttr )
const
418 aAttr.SetBold(
true );
425 wxColour textColour = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXTEXT );
428 if( brightness > 0.5 )
430 int lightness =
static_cast<int>( brightness * ( heading ? 50 : 60 ) );
431 aAttr.SetColour( textColour.ChangeLightness( lightness ) );
435 aAttr.SetColour( textColour.ChangeLightness( heading ? 170 : 165 ) );
438 aAttr.SetItalic(
true );
455 wxDataViewModel::ValueChanged(
ToItem( aNode ), 0 );
458 wxDataViewModel::ValueChanged(
ToItem( child ), 0 );
472 const std::shared_ptr<RC_ITEM> current_item = current_node ? current_node->
m_RcItem :
nullptr;
475 std::vector<RC_TREE_NODE*> to_delete;
477 if( aCurrentOnly && !current_item )
484 bool itemDeleted =
false;
500 bool excluded =
false;
505 if( aCurrentOnly && itemDeleted && lastGood >= 0 )
508 if( aCurrentOnly && rcItem != current_item )
514 if( excluded && !aIncludeExclusions )
517 if( i < (
int)
m_tree.size() )
520 wxDataViewItemArray childItems;
521 wxDataViewItem parentItem =
ToItem(
m_tree[i]->m_Parent );
525 childItems.push_back(
ToItem( child ) );
526 to_delete.push_back( child );
529 m_tree[i]->m_Children.clear();
530 ItemsDeleted( markerItem, childItems );
532 to_delete.push_back(
m_tree[i] );
534 ItemDeleted( parentItem, markerItem );
547 if(
m_view && aCurrentOnly && lastGood >= 0 )
564 currentNode = currentNode->
m_Parent;
568 if( candidate == currentNode )
571 prevMarker = candidate;
584 currentNode = currentNode->
m_Parent;
587 bool trigger = currentNode ==
nullptr;
591 if( candidate == currentNode )
597 nextMarker = candidate;
611 if( candidate->m_RcItem->GetParent() == aMarker )
624 if( candidate->m_RcItem->GetParent() == aMarker )
637 if(
m_view->GetColumnCount() > 0 )
638 m_view->GetColumn( 0 )->SetWidth( width );
virtual SEVERITY GetSeverity(int aErrorCode) const
The base class for create windows for drawing purpose.
virtual EDA_ITEM * GetItem(const KIID &aId) const
Fetch an item by KIID.
A base class for most all the KiCad significant classes used in schematics and boards.
virtual VECTOR2I GetPosition() const
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const
Return a user-visible description string of this item.
A color representation with 4 components: red, green, blue, alpha.
double GetBrightness() const
Returns the brightness value of the color ranged from 0.0 to 1.0.
virtual SEVERITY GetSeverity() const
void AddItem(EDA_ITEM *aItem)
MARKER_BASE * m_parent
The marker this item belongs to, if any.
virtual KIID GetMainItemID() const
virtual KIID GetAuxItemID() const
wxString GetErrorText() const
virtual wxString ShowReport(UNITS_PROVIDER *aUnitsProvider, 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 wxString GetErrorMessage() const
wxString m_errorMessage
A message describing the details of this specific error.
wxString GetSettingsKey() const
virtual wxString GetViolatingRuleDesc() const
void SetItems(const KIIDS &aIds)
void onSizeView(wxSizeEvent &aEvent)
void GetValue(wxVariant &aVariant, wxDataViewItem const &aItem, unsigned int aCol) const override
Called by the wxDataView to fetch an item's value.
std::vector< RC_TREE_NODE * > m_tree
unsigned int GetChildren(wxDataViewItem const &aItem, wxDataViewItemArray &aChildren) const override
EDA_DRAW_FRAME * m_editFrame
static wxDataViewItem ToItem(RC_TREE_NODE const *aNode)
void SelectMarker(const MARKER_BASE *aMarker)
RC_TREE_MODEL(EDA_DRAW_FRAME *aParentFrame, wxDataViewCtrl *aView)
static RC_TREE_NODE * ToNode(wxDataViewItem aItem)
void Update(std::shared_ptr< RC_ITEMS_PROVIDER > aProvider, int aSeverities)
bool GetAttr(wxDataViewItem const &aItem, unsigned int aCol, wxDataViewItemAttr &aAttr) const override
Called by the wxDataView to fetch an item's formatting.
void DeleteItems(bool aCurrentOnly, bool aIncludeExclusions, bool aDeep)
Deletes the current item or all items.
void DeleteCurrentItem(bool aDeep)
wxDataViewItem GetParent(wxDataViewItem const &aItem) const override
void CenterMarker(const MARKER_BASE *aMarker)
static KIID ToUUID(wxDataViewItem aItem)
std::shared_ptr< RC_ITEMS_PROVIDER > m_rcItemsProvider
void ValueChanged(const RC_TREE_NODE *aNode)
bool IsContainer(wxDataViewItem const &aItem) const override
void rebuildModel(std::shared_ptr< RC_ITEMS_PROVIDER > aProvider, int aSeverities)
std::shared_ptr< RC_ITEM > m_RcItem
std::vector< RC_TREE_NODE * > m_Children
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
static wxString showCoord(UNITS_PROVIDER *aUnitsProvider, const VECTOR2I &aPos)
#define WX_DATAVIEW_WINDOW_PADDING
Functions to provide common constants and other functions to assist in making a consistent UI.