Highlight error marker from netlist browser

This commit is contained in:
Matthias Koefferlein 2023-09-26 23:39:46 +02:00
parent 883b7e7db8
commit 001c2240e2
5 changed files with 52 additions and 10 deletions

View File

@ -158,7 +158,7 @@ LogEntryData::set_cell_name (const std::string &n)
}
std::string
LogEntryData::to_string () const
LogEntryData::to_string (bool with_geometry) const
{
std::string res;
@ -178,7 +178,7 @@ LogEntryData::to_string () const
res += message ();
if (! m_geometry.box ().empty ()) {
if (with_geometry && ! m_geometry.box ().empty ()) {
res += tl::to_string (tr (", shape: ")) + m_geometry.to_string ();
}

View File

@ -161,7 +161,7 @@ public:
/**
* @brief Formats this message for printing
*/
std::string to_string () const;
std::string to_string (bool with_geometry = true) const;
private:
Severity m_severity;

View File

@ -798,6 +798,10 @@ NetlistBrowserPage::log_selection_changed ()
{
clear_highlights ();
if (! mp_database.get () || ! mp_database->netlist ()) {
return;
}
NetlistLogModel *model = dynamic_cast<NetlistLogModel *> (log_view->model ());
tl_assert (model != 0);
@ -805,15 +809,17 @@ NetlistBrowserPage::log_selection_changed ()
for (QModelIndexList::const_iterator i = selection.begin (); i != selection.end (); ++i) {
if (i->column () == 0) {
const db::LogEntryData *le = model->log_entry (*i);
if (le && le->geometry () != db::DPolygon ()) {
// @@@ TODO: add highlight for error here.
if (le && le->geometry () != db::DPolygon () && ! le->cell_name ().empty ()) {
const db::Circuit *c = mp_database->netlist ()->circuit_by_name (le->cell_name ());
if (c) {
m_markers.push_back (std::make_pair (c, le->geometry ()));
}
}
}
}
update_highlights ();
adjust_view ();
}
void
@ -1276,6 +1282,7 @@ NetlistBrowserPage::clear_highlights ()
{
m_current_path = lay::NetlistObjectsPath ();
m_selected_paths.clear ();
m_markers.clear ();
update_highlights ();
}
@ -1435,6 +1442,17 @@ NetlistBrowserPage::adjust_view ()
}
// add markers boxes
for (auto marker = m_markers.begin (); marker != m_markers.end (); ++marker) {
std::pair<bool, db::DCplxTrans> tr = trans_for (marker->first, *layout, *cell, m_cell_context_cache, cv.context_dtrans ());
if (tr.first) {
bbox += (tr.second * marker->second).box ();
}
}
if (! bbox.empty ()) {
std::vector<db::DCplxTrans> tv = mp_view->cv_transform_variants (m_cv_index);
@ -1676,10 +1694,12 @@ NetlistBrowserPage::update_highlights ()
}
}
std::vector<db::DCplxTrans> tv = mp_view->cv_transform_variants (m_cv_index);
size_t n_markers = 0;
bool not_all_shapes_are_shown = false;
for (std::vector<lay::NetlistObjectsPath>::const_iterator path = m_selected_paths.begin (); path != m_selected_paths.end (); ++path) {
for (auto path = m_selected_paths.begin (); path != m_selected_paths.end (); ++path) {
const db::Circuit *circuit = path->root.first;
if (! circuit) {
@ -1711,7 +1731,6 @@ NetlistBrowserPage::update_highlights ()
// a map of display properties vs. layer properties
// correct DBU differences between the storage layout and the original layout
std::vector<db::DCplxTrans> tv = mp_view->cv_transform_variants (m_cv_index);
for (std::vector<db::DCplxTrans>::iterator t = tv.begin (); t != tv.end (); ++t) {
*t = *t * trans * db::DCplxTrans (layout->dbu () / original_layout.dbu ());
}
@ -1732,6 +1751,28 @@ NetlistBrowserPage::update_highlights ()
}
for (auto marker = m_markers.begin (); marker != m_markers.end (); ++marker) {
// computes the transformation supplied by the path
std::pair<bool, db::DCplxTrans> tr = trans_for (marker->first, *layout, *cell, m_cell_context_cache, cv.context_dtrans ());
if (! tr.first) {
continue;
}
// creates a highlight from the marker
tl::Color color = make_valid_color (m_colorizer.marker_color ());
mp_markers.push_back (new lay::Marker (mp_view, m_cv_index));
mp_markers.back ()->set (marker->second, db::DCplxTrans (1.0 / original_layout.dbu ()) * tr.second, tv);
mp_markers.back ()->set_color (color);
mp_markers.back ()->set_frame_color (color);
configure_marker (mp_markers.back (), true);
}
if (not_all_shapes_are_shown) {
info_label->setText (tl::to_qstring ("<html><p style=\"color:red; font-weight: bold\">" +
tl::to_string (QObject::tr ("Not all shapes are highlighted")) +

View File

@ -244,6 +244,7 @@ private:
bool m_update_needed;
lay::NetlistObjectsPath m_current_path;
std::vector<lay::NetlistObjectsPath> m_selected_paths;
std::vector<std::pair<const db::Circuit *, db::DPolygon> > m_markers;
lay::NetInfoDialog *mp_info_dialog;
tl::DeferredMethod<NetlistBrowserPage> dm_update_highlights;
tl::DeferredMethod<NetlistBrowserPage> dm_rerun_macro;

View File

@ -218,7 +218,7 @@ NetlistLogModel::data (const QModelIndex &index, int role) const
} else if (role == Qt::DisplayRole) {
if (le) {
return QVariant (tl::to_qstring (le->to_string ()));
return QVariant (tl::to_qstring (le->to_string (false)));
} else if (! index.parent ().isValid () && index.row () >= m_global_entries && index.row () < int (m_circuits.size ()) + m_global_entries) {
const std::pair<const db::Circuit *, const db::Circuit *> &cp = m_circuits [index.row () - m_global_entries].first;
if (! cp.first) {