21#include <wx/wupdlock.h>
22#include <wx/dataview.h>
23#include <wx/settings.h>
34#define WX_DATAVIEW_WINDOW_PADDING 6
48 return wxString::Format( wxT(
"@(%s, %s)" ),
106 const std::map<KIID, EDA_ITEM*>& aItemMap )
const
112 severity += wxT(
" (excluded)" );
119 if( ii != aItemMap.end() )
120 mainItem = ii->second;
124 if( ii != aItemMap.end() )
125 auxItem = ii->second;
137 if( mainItem && auxItem )
139 msg.Printf( wxT(
"[%s]: %s\n %s; %s\n %s: %s\n %s: %s\n" ),
GetSettingsKey(), errorMessage, ruleDesc,
147 msg.Printf( wxT(
"[%s]: %s\n %s; %s\n %s: %s\n" ),
GetSettingsKey(), errorMessage, ruleDesc, severity,
153 msg.Printf( wxT(
"[%s]: %s\n %s; %s\n" ),
GetSettingsKey(), errorMessage, ruleDesc, severity );
157 msg += wxString::Format( wxS(
" %s\n" ),
m_parent->GetComment() );
164 SEVERITY aSeverity,
const std::map<KIID, EDA_ITEM*>& aItemMap )
const
185 if( ii != aItemMap.end() )
186 mainItem = ii->second;
190 if( ii != aItemMap.end() )
191 auxItem = ii->second;
204 aViolation.
items.emplace_back( item );
218 aViolation.
items.emplace_back( item );
229 const std::shared_ptr<RC_ITEM> rc_item = node->
m_RcItem;
237 if( rc_item->GetParent() )
238 return rc_item->GetParent()->GetUUID();
263 const std::shared_ptr<RC_ITEM>& aRcItem,
333 for(
int i = 0; i < count; ++i )
340 if( rcItem->GetMainItemID() !=
niluuid )
343 if( rcItem->GetAuxItemID() !=
niluuid )
346 if( rcItem->GetAuxItem2ID() !=
niluuid )
349 if( rcItem->GetAuxItem3ID() !=
niluuid )
354 if( marker->IsExcluded() && !marker->GetComment().IsEmpty() )
363 wxWindowUpdateLocker updateLock(
m_view );
365 std::shared_ptr<RC_ITEM> selectedRcItem =
nullptr;
370 selectedRcItem = selectedNode ? selectedNode->
m_RcItem :
nullptr;
379 rebuildTree( std::move( aProvider ), aSeverities );
391 m_view->AssociateModel(
this );
403 m_view->AppendTextColumn( wxEmptyString, 0, wxDATAVIEW_CELL_INERT, width );
414 if( candidate->m_RcItem == selectedRcItem )
435 if( !aEnable || !
m_view ||
m_view->GetColumnCount() > 0 )
440 new wxDataViewColumn( wxEmptyString, renderer, 0, std::max( 200,
m_view->GetClientSize().GetWidth() ),
441 wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE );
470 if( node ==
nullptr )
485 wxDataViewItemArray& aChildren )
const
488 const std::vector<RC_TREE_NODE*>& children = node ? node->
m_Children :
m_tree;
490 if( aItem.IsOk() && !node )
494 aChildren.push_back(
ToItem( child ) );
496 return children.size();
501 unsigned int aCol )
const
503 if( !aItem.IsOk() ||
m_view->IsFrozen() ||
m_tree.empty() )
511 const std::shared_ptr<RC_ITEM> rcItem = node->
m_RcItem;
526 msg =
_(
"Excluded warning: " );
528 msg =
_(
"Excluded error: " );
532 msg =
_(
"Warning: " );
536 msg =
_(
"Error: " );
540 msg += rcItem->GetErrorMessage(
true );
545 msg =
_(
"Drawing Sheet" );
547 item =
m_editFrame->ResolveItem( rcItem->GetMainItemID() );
552 item =
m_editFrame->ResolveItem( rcItem->GetAuxItemID() );
556 item =
m_editFrame->ResolveItem( rcItem->GetAuxItem2ID() );
560 item =
m_editFrame->ResolveItem( rcItem->GetAuxItem3ID() );
573 msg.Replace( wxS(
"\n" ), wxS(
" " ) );
580 wxDataViewItemAttr& aAttr )
const
582 if( !aItem.IsOk() ||
m_view->IsFrozen() ||
m_tree.empty() )
595 aAttr.SetBold(
true );
602 wxColour textColour = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXTEXT );
605 if( brightness > 0.5 )
607 int lightness =
static_cast<int>( brightness * ( heading ? 50 : 60 ) );
608 aAttr.SetColour( textColour.ChangeLightness( lightness ) );
612 aAttr.SetColour( textColour.ChangeLightness( heading ? 170 : 165 ) );
615 aAttr.SetItalic(
true );
631 wxDataViewItem markerItem =
ToItem( aNode );
633 wxDataViewModel::ValueChanged( markerItem, 0 );
636 wxDataViewModel::ValueChanged(
ToItem( child ), 0 );
640 const std::shared_ptr<RC_ITEM> rcItem = aNode->
m_RcItem;
641 MARKER_BASE* marker = rcItem ? rcItem->GetParent() :
nullptr;
649 commentNode =
nullptr;
651 if( needsCommentNode && !commentNode )
654 wxDataViewItemArray newItems;
655 newItems.push_back(
ToItem( commentNode ) );
658 ItemsAdded( markerItem, newItems );
660 else if( commentNode && !needsCommentNode )
662 wxDataViewItemArray deletedItems;
663 deletedItems.push_back(
ToItem( commentNode ) );
667 ItemsDeleted( markerItem, deletedItems );
683 const std::shared_ptr<RC_ITEM> current_item = current_node ? current_node->
m_RcItem :
nullptr;
685 std::vector<wxDataViewItem> expanded;
687 if( aCurrentOnly && !current_item )
695 if(
m_view && aCurrentOnly )
700 expanded.push_back(
ToItem( node ) );
705 bool itemDeleted =
false;
725 bool excluded =
false;
730 if( aCurrentOnly && itemDeleted && lastGood >= 0 )
733 if( aCurrentOnly && rcItem != current_item )
739 if( excluded && !aIncludeExclusions )
742 if( i < (
int)
m_tree.size() )
745 wxDataViewItemArray childItems;
746 wxDataViewItem parentItem =
ToItem(
m_tree[i]->m_Parent );
750 childItems.push_back(
ToItem( child ) );
754 ItemsDeleted( markerItem, childItems );
759 ItemDeleted( parentItem, markerItem );
773 if(
m_view && aCurrentOnly && lastGood >= 0 )
775 for(
const wxDataViewItem& item : expanded )
782 m_view->Select( selItem );
786 wxDataViewEvent selectEvent( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED,
m_view, selItem );
787 m_view->GetEventHandler()->ProcessEvent( selectEvent );
801 currentNode = currentNode->
m_Parent;
805 if( candidate == currentNode )
808 prevMarker = candidate;
821 currentNode = currentNode->
m_Parent;
824 bool trigger = currentNode ==
nullptr;
828 if( candidate == currentNode )
834 nextMarker = candidate;
846 wxCHECK( !
m_view->IsFrozen(), );
850 if( candidate->m_RcItem->GetParent() == aMarker )
861 wxCHECK( !
m_view->IsFrozen(), );
865 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.
wxDataViewCtrl renderer that draws [label](url) markup as clickable link runs inline with plain text.
static wxString StripMarkup(const wxString &aValue)
Flatten [label](url) markup, keeping just the label.
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
virtual wxString getItemDescription(EDA_ITEM *aItem, int aIndex, UNITS_PROVIDER *aUnitsProvider) const
Resolve the description string used for an affected item in ShowReport and GetJsonViolation.
void SetItems(const KIIDS &aIds)
std::deque< RC_TREE_NODE::HANDLE > m_handles
Stable wx item IDs.
void onViewSize(wxSizeEvent &aEvent)
wxDataViewColumn * m_hyperlinkColumn
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
void retireNodeTree(RC_TREE_NODE *aNode)
static wxDataViewItem ToItem(RC_TREE_NODE const *aNode)
void rebuildTree(std::shared_ptr< RC_ITEMS_PROVIDER > aProvider, int aSeverities)
Repopulate the node tree from aProvider.
void clearTree()
Retire and destroy every node in the tree.
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)
void EnableHyperlinks(bool aEnable)
Render [label](url) markup as clickable links.
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)
#define WX_DATAVIEW_WINDOW_PADDING
std::vector< AFFECTED_ITEM > items
Functions to provide common constants and other functions to assist in making a consistent UI.
VECTOR2< int32_t > VECTOR2I