Skip to content

Commit 5a0ffe9

Browse files
committed
gui: Switch to inspector view only when double clicking on violation in drc viewer.
Signed-off-by: Christian COSTA <christian.costa@st.com>
1 parent ca004a3 commit 5a0ffe9

File tree

3 files changed

+42
-24
lines changed

3 files changed

+42
-24
lines changed

src/gui/src/drcWidget.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ DRCWidget::DRCWidget(QWidget* parent)
7777
setWidget(container);
7878

7979
connect(view_, &ObjectTree::clicked, this, &DRCWidget::clicked);
80+
connect(view_, &ObjectTree::doubleClicked, this, &DRCWidget::doubleClicked);
8081
connect(view_->selectionModel(),
8182
&QItemSelectionModel::selectionChanged,
8283
this,
@@ -189,7 +190,7 @@ bool DRCWidget::setVisibleDRC(QStandardItem* item,
189190
return false;
190191
}
191192

192-
void DRCWidget::clicked(const QModelIndex& index)
193+
void DRCWidget::showMarker(const QModelIndex& index, bool open_inspector)
193194
{
194195
QStandardItem* item = model_->itemFromIndex(index);
195196
QVariant data = item->data();
@@ -202,7 +203,7 @@ void DRCWidget::clicked(const QModelIndex& index)
202203
marker->setVisited(false);
203204
} else {
204205
Selected t = Gui::get()->makeSelected(marker);
205-
emit selectDRC(t);
206+
emit selectDRC(t, open_inspector);
206207
focusIndex(index);
207208
}
208209
} else {
@@ -216,6 +217,16 @@ void DRCWidget::clicked(const QModelIndex& index)
216217
}
217218
}
218219

220+
void DRCWidget::clicked(const QModelIndex& index)
221+
{
222+
showMarker(index, false);
223+
}
224+
225+
void DRCWidget::doubleClicked(const QModelIndex& index)
226+
{
227+
showMarker(index, true);
228+
}
229+
219230
void DRCWidget::setBlock(odb::dbBlock* block)
220231
{
221232
block_ = block;

src/gui/src/drcWidget.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,14 @@ class DRCWidget : public QDockWidget, public odb::dbBlockCallBackObj
6767
void inDbMarkerDestroy(odb::dbMarker* marker) override;
6868

6969
signals:
70-
void selectDRC(const Selected& selected);
70+
void selectDRC(const Selected& selected, bool open_inspector);
7171
void focus(const Selected& selected);
7272

7373
public slots:
7474
void loadReport(const QString& filename);
7575
void setBlock(odb::dbBlock* block);
7676
void clicked(const QModelIndex& index);
77+
void doubleClicked(const QModelIndex& index);
7778
void selectReport();
7879
void toggleRenderer(bool visible);
7980
void updateSelection(const Selected& selection);
@@ -112,6 +113,8 @@ class DRCWidget : public QDockWidget, public odb::dbBlockCallBackObj
112113
void toggleParent(QStandardItem* child);
113114
bool setVisibleDRC(QStandardItem* item, bool visible, bool announce_parent);
114115
void populateCategory(odb::dbMarkerCategory* category, QStandardItem* model);
116+
117+
void showMarker(const QModelIndex& index, bool open_inspector);
115118
};
116119

117120
} // namespace gui

src/gui/src/mainWindow.cpp

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -365,27 +365,31 @@ MainWindow::MainWindow(bool load_settings, QWidget* parent)
365365
connect(this, &MainWindow::blockLoaded, drc_viewer_, &DRCWidget::setBlock);
366366
connect(
367367
this, &MainWindow::blockLoaded, clock_viewer_, &ClockWidget::setBlock);
368-
connect(drc_viewer_, &DRCWidget::selectDRC, [this](const Selected& selected) {
369-
setSelected(selected, false);
370-
odb::Rect bbox;
371-
selected.getBBox(bbox);
372-
373-
auto* block = getBlock();
374-
int zoomout_dist = std::numeric_limits<int>::max();
375-
if (block != nullptr) {
376-
// 10 microns
377-
zoomout_dist = 10 * block->getDbUnitsPerMicron();
378-
}
379-
// twice the largest dimension of bounding box
380-
const int zoomout_box = 2 * std::max(bbox.dx(), bbox.dy());
381-
// pick smallest
382-
const int zoomout_margin = std::min(zoomout_dist, zoomout_box);
383-
bbox.set_xlo(bbox.xMin() - zoomout_margin);
384-
bbox.set_ylo(bbox.yMin() - zoomout_margin);
385-
bbox.set_xhi(bbox.xMax() + zoomout_margin);
386-
bbox.set_yhi(bbox.yMax() + zoomout_margin);
387-
zoomTo(bbox);
388-
});
368+
connect(drc_viewer_,
369+
&DRCWidget::selectDRC,
370+
[this](const Selected& selected, const bool open_inspector) {
371+
if (open_inspector) {
372+
setSelected(selected, false);
373+
}
374+
odb::Rect bbox;
375+
selected.getBBox(bbox);
376+
377+
auto* block = getBlock();
378+
int zoomout_dist = std::numeric_limits<int>::max();
379+
if (block != nullptr) {
380+
// 10 microns
381+
zoomout_dist = 10 * block->getDbUnitsPerMicron();
382+
}
383+
// twice the largest dimension of bounding box
384+
const int zoomout_box = 2 * std::max(bbox.dx(), bbox.dy());
385+
// pick smallest
386+
const int zoomout_margin = std::min(zoomout_dist, zoomout_box);
387+
bbox.set_xlo(bbox.xMin() - zoomout_margin);
388+
bbox.set_ylo(bbox.yMin() - zoomout_margin);
389+
bbox.set_xhi(bbox.xMax() + zoomout_margin);
390+
bbox.set_yhi(bbox.yMax() + zoomout_margin);
391+
zoomTo(bbox);
392+
});
389393
connect(this, &MainWindow::selectionChanged, [this]() {
390394
if (!selected_.empty()) {
391395
drc_viewer_->updateSelection(*selected_.begin());

0 commit comments

Comments
 (0)