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)" ),
111 severity += wxT(
" (excluded)" );
126 if( mainItem && auxItem )
128 msg.Printf( wxT(
"[%s]: %s\n %s; %s\n %s: %s\n %s: %s\n" ),
GetSettingsKey(), errorMessage, ruleDesc,
136 msg.Printf( wxT(
"[%s]: %s\n %s; %s\n %s: %s\n" ),
GetSettingsKey(), errorMessage, ruleDesc, severity,
142 msg.Printf( wxT(
"[%s]: %s\n %s; %s\n" ),
GetSettingsKey(), errorMessage, ruleDesc, severity );
146 msg += wxString::Format( wxS(
" %s\n" ),
m_parent->GetComment() );
183 aViolation.
items.emplace_back( item );
197 aViolation.
items.emplace_back( item );
208 const std::shared_ptr<RC_ITEM> rc_item = node->
m_RcItem;
216 if( rc_item->GetParent() )
217 return rc_item->GetParent()->GetUUID();
242 const std::shared_ptr<RC_ITEM>& aRcItem,
312 for(
int i = 0; i < count; ++i )
319 if( rcItem->GetMainItemID() !=
niluuid )
322 if( rcItem->GetAuxItemID() !=
niluuid )
325 if( rcItem->GetAuxItem2ID() !=
niluuid )
328 if( rcItem->GetAuxItem3ID() !=
niluuid )
333 if( marker->IsExcluded() && !marker->GetComment().IsEmpty() )
342 wxWindowUpdateLocker updateLock(
m_view );
344 std::shared_ptr<RC_ITEM> selectedRcItem =
nullptr;
349 selectedRcItem = selectedNode ? selectedNode->
m_RcItem :
nullptr;
358 rebuildTree( std::move( aProvider ), aSeverities );
370 m_view->AssociateModel(
this );
382 m_view->AppendTextColumn( wxEmptyString, 0, wxDATAVIEW_CELL_INERT, width );
393 if( candidate->m_RcItem == selectedRcItem )
414 if( !aEnable || !
m_view ||
m_view->GetColumnCount() > 0 )
419 new wxDataViewColumn( wxEmptyString, renderer, 0, std::max( 200,
m_view->GetClientSize().GetWidth() ),
420 wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE );
449 if( node ==
nullptr )
464 wxDataViewItemArray& aChildren )
const
467 const std::vector<RC_TREE_NODE*>& children = node ? node->
m_Children :
m_tree;
469 if( aItem.IsOk() && !node )
473 aChildren.push_back(
ToItem( child ) );
475 return children.size();
480 unsigned int aCol )
const
482 if( !aItem.IsOk() ||
m_view->IsFrozen() ||
m_tree.empty() )
490 const std::shared_ptr<RC_ITEM> rcItem = node->
m_RcItem;
505 msg =
_(
"Excluded warning: " );
507 msg =
_(
"Excluded error: " );
511 msg =
_(
"Warning: " );
515 msg =
_(
"Error: " );
519 msg += rcItem->GetErrorMessage(
true );
524 msg =
_(
"Drawing Sheet" );
526 item =
m_editFrame->ResolveItem( rcItem->GetMainItemID() );
531 item =
m_editFrame->ResolveItem( rcItem->GetAuxItemID() );
535 item =
m_editFrame->ResolveItem( rcItem->GetAuxItem2ID() );
539 item =
m_editFrame->ResolveItem( rcItem->GetAuxItem3ID() );
552 msg.Replace( wxS(
"\n" ), wxS(
" " ) );
559 wxDataViewItemAttr& aAttr )
const
561 if( !aItem.IsOk() ||
m_view->IsFrozen() ||
m_tree.empty() )
574 aAttr.SetBold(
true );
581 wxColour textColour = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXTEXT );
584 if( brightness > 0.5 )
586 int lightness =
static_cast<int>( brightness * ( heading ? 50 : 60 ) );
587 aAttr.SetColour( textColour.ChangeLightness( lightness ) );
591 aAttr.SetColour( textColour.ChangeLightness( heading ? 170 : 165 ) );
594 aAttr.SetItalic(
true );
610 wxDataViewItem markerItem =
ToItem( aNode );
612 wxDataViewModel::ValueChanged( markerItem, 0 );
615 wxDataViewModel::ValueChanged(
ToItem( child ), 0 );
619 const std::shared_ptr<RC_ITEM> rcItem = aNode->
m_RcItem;
620 MARKER_BASE* marker = rcItem ? rcItem->GetParent() :
nullptr;
628 commentNode =
nullptr;
630 if( needsCommentNode && !commentNode )
633 wxDataViewItemArray newItems;
634 newItems.push_back(
ToItem( commentNode ) );
637 ItemsAdded( markerItem, newItems );
639 else if( commentNode && !needsCommentNode )
641 wxDataViewItemArray deletedItems;
642 deletedItems.push_back(
ToItem( commentNode ) );
646 ItemsDeleted( markerItem, deletedItems );
662 const std::shared_ptr<RC_ITEM> current_item = current_node ? current_node->
m_RcItem :
nullptr;
664 std::vector<wxDataViewItem> expanded;
666 if( aCurrentOnly && !current_item )
674 if(
m_view && aCurrentOnly )
679 expanded.push_back(
ToItem( node ) );
684 bool itemDeleted =
false;
704 bool excluded =
false;
709 if( aCurrentOnly && itemDeleted && lastGood >= 0 )
712 if( aCurrentOnly && rcItem != current_item )
715 if( i < (
int)
m_tree.size() )
721 if( excluded && !aIncludeExclusions )
724 if( i < (
int)
m_tree.size() )
727 wxDataViewItemArray childItems;
728 wxDataViewItem parentItem =
ToItem(
m_tree[i]->m_Parent );
732 childItems.push_back(
ToItem( child ) );
736 ItemsDeleted( markerItem, childItems );
741 ItemDeleted( parentItem, markerItem );
755 if(
m_view && aCurrentOnly && lastGood >= 0 )
757 for(
const wxDataViewItem& item : expanded )
764 m_view->Select( selItem );
768 wxDataViewEvent selectEvent( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED,
m_view, selItem );
769 m_view->GetEventHandler()->ProcessEvent( selectEvent );
783 currentNode = currentNode->
m_Parent;
787 if( candidate == currentNode )
790 prevMarker = candidate;
803 currentNode = currentNode->
m_Parent;
806 bool trigger = currentNode ==
nullptr;
810 if( candidate == currentNode )
816 nextMarker = candidate;
828 wxCHECK( !
m_view->IsFrozen(), );
832 if( candidate->m_RcItem->GetParent() == aMarker )
843 wxCHECK( !
m_view->IsFrozen(), );
847 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
Interface for resolving EDA_ITEM instances by the KIID from an RC_ITEM.
EDA_ITEM * ResolveItemById(const KIID &aKiid) const
Resolve an item by its KIID.
virtual wxString ShowReport(UNITS_PROVIDER *aUnitsProvider, SEVERITY aSeverity, const RC_ITEM_RESOLVER &aResolver) const
Translate this object into a text string suitable for saving to disk in a report.
wxString GetErrorText(bool aTranslate) const
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 void GetJsonViolation(RC_JSON::VIOLATION &aViolation, UNITS_PROVIDER *aUnitsProvider, SEVERITY aSeverity, const RC_ITEM_RESOLVER &aResolver) const
Translate this object into an RC_JSON::VIOLATION object.
virtual KIID GetMainItemID() const
virtual KIID GetAuxItemID() const
void SetItems(const std::vector< KIID > &aIds)
wxString m_errorMessage
A message describing the details of this specific error.
wxString GetSettingsKey() const
std::vector< KIID > m_ids
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.
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