Skip to content

Commit

Permalink
Highlight error marker from netlist browser
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koefferlein committed Sep 26, 2023
1 parent 883b7e7 commit 001c224
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/db/db/dbLog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 ();
}

Expand Down
2 changes: 1 addition & 1 deletion src/db/db/dbLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class DB_PUBLIC LogEntryData
/**
* @brief Formats this message for printing
*/
std::string to_string () const;
std::string to_string (bool with_geometry = true) const;

private:
Severity m_severity;
Expand Down
53 changes: 47 additions & 6 deletions src/layui/layui/layNetlistBrowserPage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -798,22 +798,28 @@ 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);

QModelIndexList selection = log_view->selectionModel ()->selectedIndexes ();
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
Expand Down Expand Up @@ -1276,6 +1282,7 @@ NetlistBrowserPage::clear_highlights ()
{
m_current_path = lay::NetlistObjectsPath ();
m_selected_paths.clear ();
m_markers.clear ();

update_highlights ();
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 ());
}
Expand All @@ -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")) +
Expand Down
1 change: 1 addition & 0 deletions src/layui/layui/layNetlistBrowserPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ private slots:
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;
Expand Down
2 changes: 1 addition & 1 deletion src/layui/layui/layNetlistLogModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 001c224

Please sign in to comment.