25#include <wx/wupdlock.h>
26#include <wx/dataview.h>
27#include <wx/settings.h>
36#define WX_DATAVIEW_WINDOW_PADDING 6
50 return wxString::Format( wxT(
"@(%s, %s)" ),
101 const std::map<KIID, EDA_ITEM*>& aItemMap )
const
106 severity += wxT(
" (excluded)" );
113 if( ii != aItemMap.end() )
114 mainItem = ii->second;
118 if( ii != aItemMap.end() )
119 auxItem = ii->second;
128 if( mainItem && auxItem )
130 msg.Printf( wxT(
"[%s]: %s\n %s; %s\n %s: %s\n %s: %s\n" ),
142 msg.Printf( wxT(
"[%s]: %s\n %s; %s\n %s: %s\n" ),
152 msg.Printf( wxT(
"[%s]: %s\n %s; %s\n" ),
160 msg += wxString::Format( wxS(
" %s\n" ),
m_parent->GetComment() );
167 SEVERITY aSeverity,
const std::map<KIID, EDA_ITEM*>& aItemMap )
const
188 if( ii != aItemMap.end() )
189 mainItem = ii->second;
193 if( ii != aItemMap.end() )
194 auxItem = ii->second;
207 aViolation.
items.emplace_back( item );
221 aViolation.
items.emplace_back( item );
232 const std::shared_ptr<RC_ITEM> rc_item = node->
m_RcItem;
240 if( rc_item->GetParent() )
241 return rc_item->GetParent()->GetUUID();
266 const std::shared_ptr<RC_ITEM>& aRcItem,
271 m_handles.push_back( std::make_unique<RC_TREE_NODE::HANDLE>() );
313 wxWindowUpdateLocker updateLock(
m_view );
315 std::shared_ptr<RC_ITEM> selectedRcItem =
nullptr;
320 selectedRcItem = selectedNode ? selectedNode->
m_RcItem :
nullptr;
352 for(
int i = 0; i < count; ++i )
359 if( rcItem->GetMainItemID() !=
niluuid )
362 if( rcItem->GetAuxItemID() !=
niluuid )
365 if( rcItem->GetAuxItem2ID() !=
niluuid )
368 if( rcItem->GetAuxItem3ID() !=
niluuid )
373 if( marker->IsExcluded() && !marker->GetComment().IsEmpty() )
388 m_view->AssociateModel(
this );
392 m_view->AppendTextColumn( wxEmptyString, 0, wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_AUTOSIZE );
402 if( candidate->m_RcItem == selectedRcItem )
433 if( node ==
nullptr )
448 wxDataViewItemArray& aChildren )
const
451 const std::vector<RC_TREE_NODE*>& children = node ? node->
m_Children :
m_tree;
453 if( aItem.IsOk() && !node )
457 aChildren.push_back(
ToItem( child ) );
459 return children.size();
464 unsigned int aCol )
const
466 if( !aItem.IsOk() ||
m_view->IsFrozen() ||
m_tree.empty() )
474 const std::shared_ptr<RC_ITEM> rcItem = node->
m_RcItem;
489 msg =
_(
"Excluded warning: " );
491 msg =
_(
"Excluded error: " );
495 msg =
_(
"Warning: " );
499 msg =
_(
"Error: " );
503 msg += rcItem->GetErrorMessage(
true );
508 msg =
_(
"Drawing Sheet" );
510 item =
m_editFrame->ResolveItem( rcItem->GetMainItemID() );
515 item =
m_editFrame->ResolveItem( rcItem->GetAuxItemID() );
519 item =
m_editFrame->ResolveItem( rcItem->GetAuxItem2ID() );
523 item =
m_editFrame->ResolveItem( rcItem->GetAuxItem3ID() );
536 msg.Replace( wxS(
"\n" ), wxS(
" " ) );
543 wxDataViewItemAttr& aAttr )
const
545 if( !aItem.IsOk() ||
m_view->IsFrozen() ||
m_tree.empty() )
558 aAttr.SetBold(
true );
565 wxColour textColour = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXTEXT );
568 if( brightness > 0.5 )
570 int lightness =
static_cast<int>( brightness * ( heading ? 50 : 60 ) );
571 aAttr.SetColour( textColour.ChangeLightness( lightness ) );
575 aAttr.SetColour( textColour.ChangeLightness( heading ? 170 : 165 ) );
578 aAttr.SetItalic(
true );
594 wxDataViewItem markerItem =
ToItem( aNode );
596 wxDataViewModel::ValueChanged( markerItem, 0 );
599 wxDataViewModel::ValueChanged(
ToItem( child ), 0 );
603 const std::shared_ptr<RC_ITEM> rcItem = aNode->
m_RcItem;
604 MARKER_BASE* marker = rcItem ? rcItem->GetParent() :
nullptr;
612 commentNode =
nullptr;
614 if( needsCommentNode && !commentNode )
617 wxDataViewItemArray newItems;
618 newItems.push_back(
ToItem( commentNode ) );
621 ItemsAdded( markerItem, newItems );
623 else if( commentNode && !needsCommentNode )
625 wxDataViewItemArray deletedItems;
626 deletedItems.push_back(
ToItem( commentNode ) );
630 ItemsDeleted( markerItem, deletedItems );
646 const std::shared_ptr<RC_ITEM> current_item = current_node ? current_node->
m_RcItem :
nullptr;
648 std::vector<wxDataViewItem> expanded;
650 if( aCurrentOnly && !current_item )
658 if(
m_view && aCurrentOnly )
663 expanded.push_back(
ToItem( node ) );
668 bool itemDeleted =
false;
688 bool excluded =
false;
693 if( aCurrentOnly && itemDeleted && lastGood >= 0 )
696 if( aCurrentOnly && rcItem != current_item )
702 if( excluded && !aIncludeExclusions )
705 if( i < (
int)
m_tree.size() )
708 wxDataViewItemArray childItems;
709 wxDataViewItem parentItem =
ToItem(
m_tree[i]->m_Parent );
713 childItems.push_back(
ToItem( child ) );
717 ItemsDeleted( markerItem, childItems );
722 ItemDeleted( parentItem, markerItem );
736 if(
m_view && aCurrentOnly && lastGood >= 0 )
738 for(
const wxDataViewItem& item : expanded )
745 m_view->Select( selItem );
749 wxDataViewEvent selectEvent( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED,
m_view, selItem );
750 m_view->GetEventHandler()->ProcessEvent( selectEvent );
764 currentNode = currentNode->
m_Parent;
768 if( candidate == currentNode )
771 prevMarker = candidate;
784 currentNode = currentNode->
m_Parent;
787 bool trigger = currentNode ==
nullptr;
791 if( candidate == currentNode )
797 nextMarker = candidate;
809 wxCHECK( !
m_view->IsFrozen(), );
813 if( candidate->m_RcItem->GetParent() == aMarker )
824 wxCHECK( !
m_view->IsFrozen(), );
828 if( candidate->m_RcItem->GetParent() == aMarker )
The base class for create windows for drawing purpose.
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, bool aFull) 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.
wxString AsString() const
Marker are mainly used to show a DRC or ERC error or warning.
virtual SEVERITY GetSeverity() const
enum MARKER_T GetMarkerType() const
wxString GetComment() const
wxString GetErrorText(bool aTranslate) const
virtual void GetJsonViolation(RC_JSON::VIOLATION &aViolation, UNITS_PROVIDER *aUnitsProvider, SEVERITY aSeverity, const std::map< KIID, EDA_ITEM * > &aItemMap) const
Translate this object into an RC_JSON::VIOLATION object.
static wxString getSeverityString(SEVERITY aSeverity)
virtual wxString GetViolatingRuleDesc(bool aTranslate) const
MARKER_BASE * GetParent() 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
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.
wxString m_errorMessage
A message describing the details of this specific error.
wxString GetSettingsKey() const
virtual wxString GetErrorMessage(bool aTranslate) const
void SetItems(const KIIDS &aIds)
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
std::vector< std::unique_ptr< RC_TREE_NODE::HANDLE > > m_handles
EDA_DRAW_FRAME * m_editFrame
void retireNodeTree(RC_TREE_NODE *aNode)
static wxDataViewItem ToItem(RC_TREE_NODE const *aNode)
void SelectMarker(const MARKER_BASE *aMarker)
RC_TREE_MODEL(EDA_DRAW_FRAME *aParentFrame, wxDataViewCtrl *aView)
void deleteNodeTree(RC_TREE_NODE *aNode)
static RC_TREE_NODE * ToNode(wxDataViewItem aItem)
void ValueChanged(RC_TREE_NODE *aNode)
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)
Delete the current item or all items.
RC_TREE_NODE * createNode(RC_TREE_NODE *aParent, const std::shared_ptr< RC_ITEM > &aRcItem, RC_TREE_NODE::NODE_TYPE aType)
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
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
const EDA_IU_SCALE & GetIuScale() const
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
EDA_UNITS GetUserUnits() const
KICOMMON_API double ToUserUnit(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
Convert aValue in internal units to the appropriate user units defined by aUnit.
static wxString showCoord(UNITS_PROVIDER *aUnitsProvider, const VECTOR2I &aPos)
std::vector< AFFECTED_ITEM > items
Functions to provide common constants and other functions to assist in making a consistent UI.
VECTOR2< int32_t > VECTOR2I