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)" ),
100 const std::map<KIID, EDA_ITEM*>& aItemMap )
const
105 severity += wxT(
" (excluded)" );
112 if( ii != aItemMap.end() )
113 mainItem = ii->second;
117 if( ii != aItemMap.end() )
118 auxItem = ii->second;
125 if( mainItem && auxItem )
127 return wxString::Format( wxT(
"[%s]: %s\n %s; %s\n %s: %s\n %s: %s\n" ),
139 return wxString::Format( wxT(
"[%s]: %s\n %s; %s\n %s: %s\n" ),
149 return wxString::Format( wxT(
"[%s]: %s\n %s; %s\n" ),
160 const std::map<KIID, EDA_ITEM*>& aItemMap )
const
173 if( ii != aItemMap.end() )
174 mainItem = ii->second;
178 if( ii != aItemMap.end() )
179 auxItem = ii->second;
192 aViolation.
items.emplace_back( item );
206 aViolation.
items.emplace_back( item );
217 const std::shared_ptr<RC_ITEM> rc_item = node->
m_RcItem;
224 if( rc_item->GetParent() )
225 return rc_item->GetParent()->GetUUID();
241 m_editFrame( aParentFrame ),
244 m_rcItemsProvider( nullptr )
260 wxWindowUpdateLocker updateLock(
m_view );
262 std::shared_ptr<RC_ITEM> selectedRcItem =
nullptr;
267 selectedRcItem = selectedNode ? selectedNode->
m_RcItem :
nullptr;
295 for(
int i = 0; i < count; ++i )
302 if( rcItem->GetMainItemID() !=
niluuid )
305 if( rcItem->GetAuxItemID() !=
niluuid )
308 if( rcItem->GetAuxItem2ID() !=
niluuid )
311 if( rcItem->GetAuxItem3ID() !=
niluuid )
325 m_view->AssociateModel(
this );
330 m_view->AppendTextColumn( wxEmptyString, 0, wxDATAVIEW_CELL_INERT, width );
340 if( candidate->m_RcItem == selectedRcItem )
366 if(
ToNode( aItem ) ==
nullptr )
380 wxDataViewItemArray& aChildren )
const
383 const std::vector<RC_TREE_NODE*>& children = node ? node->
m_Children :
m_tree;
386 aChildren.push_back(
ToItem( child ) );
388 return children.size();
393 wxDataViewItem
const& aItem,
394 unsigned int aCol )
const
397 const std::shared_ptr<RC_ITEM> rcItem = node->
m_RcItem;
412 msg =
_(
"Excluded warning: " );
414 msg =
_(
"Excluded error: " );
418 msg =
_(
"Warning: " );
422 msg =
_(
"Error: " );
426 msg += rcItem->GetErrorMessage();
431 msg =
_(
"Drawing Sheet" );
453 msg.Replace( wxS(
"\n" ), wxS(
" " ) );
460 wxDataViewItemAttr& aAttr )
const
470 aAttr.SetBold(
true );
477 wxColour textColour = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXTEXT );
480 if( brightness > 0.5 )
482 int lightness =
static_cast<int>( brightness * ( heading ? 50 : 60 ) );
483 aAttr.SetColour( textColour.ChangeLightness( lightness ) );
487 aAttr.SetColour( textColour.ChangeLightness( heading ? 170 : 165 ) );
490 aAttr.SetItalic(
true );
507 wxDataViewModel::ValueChanged(
ToItem( aNode ), 0 );
510 wxDataViewModel::ValueChanged(
ToItem( child ), 0 );
524 const std::shared_ptr<RC_ITEM> current_item = current_node ? current_node->
m_RcItem :
nullptr;
527 std::vector<RC_TREE_NODE*> to_delete;
529 if( aCurrentOnly && !current_item )
536 bool itemDeleted =
false;
552 bool excluded =
false;
557 if( aCurrentOnly && itemDeleted && lastGood >= 0 )
560 if( aCurrentOnly && rcItem != current_item )
566 if( excluded && !aIncludeExclusions )
569 if( i < (
int)
m_tree.size() )
572 wxDataViewItemArray childItems;
573 wxDataViewItem parentItem =
ToItem(
m_tree[i]->m_Parent );
577 childItems.push_back(
ToItem( child ) );
578 to_delete.push_back( child );
581 m_tree[i]->m_Children.clear();
582 ItemsDeleted( markerItem, childItems );
584 to_delete.push_back(
m_tree[i] );
586 ItemDeleted( parentItem, markerItem );
599 if(
m_view && aCurrentOnly && lastGood >= 0 )
616 currentNode = currentNode->
m_Parent;
620 if( candidate == currentNode )
623 prevMarker = candidate;
636 currentNode = currentNode->
m_Parent;
639 bool trigger = currentNode ==
nullptr;
643 if( candidate == currentNode )
649 nextMarker = candidate;
663 if( candidate->m_RcItem->GetParent() == aMarker )
676 if( candidate->m_RcItem->GetParent() == aMarker )
689 if(
m_view->GetColumnCount() > 0 )
690 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.
wxString AsString() const
virtual SEVERITY GetSeverity() const
enum TYPEMARKER GetMarkerType() 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.
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
const EDA_IU_SCALE & GetIuScale() const
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
EDA_UNITS GetUserUnits() const
KICOMMON_API double ToUserUnit(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
static wxString showCoord(UNITS_PROVIDER *aUnitsProvider, const VECTOR2I &aPos)
wxString getSeverityString(SEVERITY aSeverity)
#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.