Skip to content

Commit c211925

Browse files
author
Matthias Koefferlein
committed
Implemented solution for #2306
First of all, NetlistBrowserDialog#current_path now has a setter. Changing the selection will navigate to the location of the selected object, but not issue an "on_selection_changed" event. In addition, the following features have been added: * NetlistBrowserDialog#db_index * NetlistBrowserDialog#view
1 parent 415650b commit c211925

7 files changed

Lines changed: 108 additions & 31 deletions

src/layui/layui/gsiDeclLayNetlistBrowserDialog.cc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,20 @@ static lay::NetlistObjectPath current_path_second (lay::NetlistBrowserDialog *di
169169
return dialog->current_path ().second ();
170170
}
171171

172+
static void set_current_path (lay::NetlistBrowserDialog *dialog, const lay::NetlistObjectsPath *path)
173+
{
174+
if (! path) {
175+
dialog->set_current_path (lay::NetlistObjectsPath ());
176+
} else {
177+
dialog->set_current_path (*path);
178+
}
179+
}
180+
181+
static lay::LayoutViewBase *get_view (lay::NetlistBrowserDialog *dialog)
182+
{
183+
return dialog->view ();
184+
}
185+
172186
Class<lay::NetlistBrowserDialog> decl_NetlistBrowserDialog ("lay", "NetlistBrowserDialog",
173187
gsi::event ("on_current_db_changed", &lay::NetlistBrowserDialog::current_db_changed_event,
174188
"@brief This event is triggered when the current database is changed.\n"
@@ -187,6 +201,16 @@ Class<lay::NetlistBrowserDialog> decl_NetlistBrowserDialog ("lay", "NetlistBrows
187201
gsi::method ("db", &lay::NetlistBrowserDialog::db,
188202
"@brief Gets the database the browser is connected to.\n"
189203
) +
204+
gsi::method ("db_index", &lay::NetlistBrowserDialog::l2n_index,
205+
"@brief Gets the database index inside the view the browser is connected to.\n"
206+
"\n"
207+
"This attribute has been introduced in version 0.30.8.\n"
208+
) +
209+
gsi::method_ext ("view", &get_view,
210+
"@brief Gets the view the browser is connected to.\n"
211+
"\n"
212+
"This attribute has been introduced in version 0.30.8.\n"
213+
) +
190214
gsi::method_ext ("current_path_first", &current_path_first,
191215
"@brief Gets the path of the current object on the first (layout in case of LVS database) side.\n"
192216
) +
@@ -196,6 +220,14 @@ Class<lay::NetlistBrowserDialog> decl_NetlistBrowserDialog ("lay", "NetlistBrows
196220
gsi::method ("current_path", &lay::NetlistBrowserDialog::current_path,
197221
"@brief Gets the path of the current object as a path pair (combines layout and schematic object paths in case of a LVS database view).\n"
198222
) +
223+
gsi::method_ext ("current_path=", &set_current_path,
224+
"@brief Sets the current path.\n"
225+
"This is the setter corresponding to the 'current_path' getter. Passing nil clears the selection.\n"
226+
"Changing the selection will update the highlights and navigate to the location depending on the "
227+
"settings. An \\on_selection_changed signal is not emitted.\n"
228+
"\n"
229+
"This setter has been introduced in version 0.30.8.\n"
230+
) +
199231
gsi::method ("selected_paths", &lay::NetlistBrowserDialog::selected_paths,
200232
"@brief Gets the nets currently selected objects (paths) in the netlist database browser.\n"
201233
"The result is an array of path pairs. See \\NetlistObjectsPath for details about these pairs."

src/layui/layui/layIndexedNetlistModel.cc

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -306,28 +306,28 @@ SingleIndexedNetlistModel::parent_of (const subcircuit_pair &subcircuits) const
306306
return std::make_pair (subcircuits.first ? subcircuits.first->circuit () : 0, (const db::Circuit *) 0);
307307
}
308308

309-
std::pair<IndexedNetlistModel::circuit_pair, std::pair<IndexedNetlistModel::Status, std::string> > SingleIndexedNetlistModel::top_circuit_from_index(size_t index) const
309+
std::pair<IndexedNetlistModel::circuit_pair, std::pair<IndexedNetlistModel::Status, std::string> > SingleIndexedNetlistModel::top_circuit_from_index (size_t index) const
310310
{
311311
db::Netlist::const_top_down_circuit_iterator none;
312312
return std::make_pair (attr_by_object_and_index (std::make_pair ((const db::Circuit *) 0, (const db::Circuit *) 0), index, mp_netlist->begin_top_down (), mp_netlist->begin_top_down () + mp_netlist->top_circuit_count (), none, none, m_child_circuit_by_circuit_and_index, sort_by_name<db::Circuit> ()), std::make_pair (db::NetlistCrossReference::None, std::string ()));
313313
}
314314

315-
std::pair<IndexedNetlistModel::circuit_pair, std::pair<IndexedNetlistModel::Status, std::string> > SingleIndexedNetlistModel::child_circuit_from_index(const circuit_pair &circuits, size_t index) const
315+
std::pair<IndexedNetlistModel::circuit_pair, std::pair<IndexedNetlistModel::Status, std::string> > SingleIndexedNetlistModel::child_circuit_from_index (const circuit_pair &circuits, size_t index) const
316316
{
317317
db::Circuit::const_child_circuit_iterator none;
318318
return std::make_pair (attr_by_object_and_index (circuits, index, circuits.first->begin_children (), circuits.first->end_children (), none, none, m_child_circuit_by_circuit_and_index, sort_by_name<db::Circuit> ()), std::make_pair (db::NetlistCrossReference::None, std::string ()));
319319
}
320320

321-
std::pair<IndexedNetlistModel::circuit_pair, std::pair<IndexedNetlistModel::Status, std::string> > SingleIndexedNetlistModel::circuit_from_index(size_t index) const
321+
std::pair<IndexedNetlistModel::circuit_pair, std::pair<IndexedNetlistModel::Status, std::string> > SingleIndexedNetlistModel::circuit_from_index (size_t index) const
322322
{
323323
db::Netlist::const_circuit_iterator none;
324324
return std::make_pair (attr_by_object_and_index (std::make_pair (mp_netlist, (const db::Netlist *) 0), index, mp_netlist->begin_circuits (), mp_netlist->end_circuits (), none, none, m_circuit_by_index, sort_by_name<db::Circuit> ()), std::make_pair (db::NetlistCrossReference::None, std::string ()));
325325
}
326326

327-
std::pair<IndexedNetlistModel::net_pair, std::pair<IndexedNetlistModel::Status, std::string> > SingleIndexedNetlistModel::net_from_index(const circuit_pair &circuits, size_t index) const
327+
std::pair<IndexedNetlistModel::net_pair, std::pair<IndexedNetlistModel::Status, std::string> > SingleIndexedNetlistModel::net_from_index (const circuit_pair &circuits, size_t index) const
328328
{
329329
db::Circuit::const_net_iterator none;
330-
return std::make_pair (attr_by_object_and_index (circuits, index, circuits.first->begin_nets (), circuits.first->end_nets (), none, none, m_net_by_circuit_and_index, sort_by_expanded_name<db::Net> ()), std::make_pair (db::NetlistCrossReference::None, std::string ()));
330+
return std::make_pair (attr_by_object_and_index (std::make_pair (circuits.first, (const db::Circuit *) 0), index, circuits.first->begin_nets (), circuits.first->end_nets (), none, none, m_net_by_circuit_and_index, sort_by_expanded_name<db::Net> ()), std::make_pair (db::NetlistCrossReference::None, std::string ()));
331331
}
332332

333333
const db::Net *
@@ -346,12 +346,15 @@ IndexedNetlistModel::net_subcircuit_pin_pair
346346
SingleIndexedNetlistModel::net_subcircuit_pinref_from_index (const net_pair &nets, size_t index) const
347347
{
348348
db::Net::const_subcircuit_pin_iterator none;
349-
return attr_by_object_and_index (nets, index, nets.first->begin_subcircuit_pins (), nets.first->end_subcircuit_pins (), none, none, m_subcircuit_pinref_by_net_and_index, sort_by_pin_name<db::NetSubcircuitPinRef> ());
349+
return attr_by_object_and_index (std::make_pair (nets.first, (const db::Net *) 0), index, nets.first->begin_subcircuit_pins (), nets.first->end_subcircuit_pins (), none, none, m_subcircuit_pinref_by_net_and_index, sort_by_pin_name<db::NetSubcircuitPinRef> ());
350350
}
351351

352352
IndexedNetlistModel::net_subcircuit_pin_pair
353-
SingleIndexedNetlistModel::subcircuit_pinref_from_index (const subcircuit_pair &subcircuits, size_t index) const
353+
SingleIndexedNetlistModel::subcircuit_pinref_from_index (const subcircuit_pair &subcircuits_in, size_t index) const
354354
{
355+
subcircuit_pair subcircuits = subcircuits_in;
356+
subcircuits.second = 0;
357+
355358
if (! subcircuits.first) {
356359
return IndexedNetlistModel::net_subcircuit_pin_pair ((const db::NetSubcircuitPinRef *) 0, (const db::NetSubcircuitPinRef *) 0);
357360
}
@@ -381,62 +384,68 @@ IndexedNetlistModel::net_terminal_pair
381384
SingleIndexedNetlistModel::net_terminalref_from_index (const net_pair &nets, size_t index) const
382385
{
383386
db::Net::const_terminal_iterator none;
384-
return attr_by_object_and_index (nets, index, nets.first->begin_terminals (), nets.first->end_terminals (), none, none, m_terminalref_by_net_and_index, sort_by_terminal_id<db::NetTerminalRef> ());
387+
return attr_by_object_and_index (std::make_pair (nets.first, (const db::Net *) 0), index, nets.first->begin_terminals (), nets.first->end_terminals (), none, none, m_terminalref_by_net_and_index, sort_by_terminal_id<db::NetTerminalRef> ());
385388
}
386389

387390
IndexedNetlistModel::net_pin_pair
388391
SingleIndexedNetlistModel::net_pinref_from_index (const net_pair &nets, size_t index) const
389392
{
390393
db::Net::const_pin_iterator none;
391-
return attr_by_object_and_index (nets, index, nets.first->begin_pins (), nets.first->end_pins (), none, none, m_pinref_by_net_and_index, sort_by_pin_name<db::NetPinRef> ());
394+
return attr_by_object_and_index (std::make_pair (nets.first, (const db::Net *) 0), index, nets.first->begin_pins (), nets.first->end_pins (), none, none, m_pinref_by_net_and_index, sort_by_pin_name<db::NetPinRef> ());
392395
}
393396

394-
std::pair<IndexedNetlistModel::device_pair, std::pair<IndexedNetlistModel::Status, std::string> > SingleIndexedNetlistModel::device_from_index(const circuit_pair &circuits, size_t index) const
397+
std::pair<IndexedNetlistModel::device_pair, std::pair<IndexedNetlistModel::Status, std::string> > SingleIndexedNetlistModel::device_from_index (const circuit_pair &circuits, size_t index) const
395398
{
396399
db::Circuit::const_device_iterator none;
397-
return std::make_pair (attr_by_object_and_index (circuits, index, circuits.first->begin_devices (), circuits.first->end_devices (), none, none, m_device_by_circuit_and_index, sort_by_expanded_name<db::Device> ()), std::make_pair (db::NetlistCrossReference::None, std::string ()));
400+
return std::make_pair (attr_by_object_and_index (std::make_pair (circuits.first, (const db::Circuit *) 0), index, circuits.first->begin_devices (), circuits.first->end_devices (), none, none, m_device_by_circuit_and_index, sort_by_expanded_name<db::Device> ()), std::make_pair (db::NetlistCrossReference::None, std::string ()));
398401
}
399402

400-
std::pair<IndexedNetlistModel::pin_pair, std::pair<IndexedNetlistModel::Status, std::string> > SingleIndexedNetlistModel::pin_from_index(const circuit_pair &circuits, size_t index) const
403+
std::pair<IndexedNetlistModel::pin_pair, std::pair<IndexedNetlistModel::Status, std::string> > SingleIndexedNetlistModel::pin_from_index (const circuit_pair &circuits, size_t index) const
401404
{
402405
db::Circuit::const_pin_iterator none;
403-
return std::make_pair (attr_by_object_and_index (circuits, index, circuits.first->begin_pins (), circuits.first->end_pins (), none, none, m_pin_by_circuit_and_index, Unsorted ()), std::make_pair (db::NetlistCrossReference::None, std::string ()));
406+
return std::make_pair (attr_by_object_and_index (std::make_pair (circuits.first, (const db::Circuit *) 0), index, circuits.first->begin_pins (), circuits.first->end_pins (), none, none, m_pin_by_circuit_and_index, Unsorted ()), std::make_pair (db::NetlistCrossReference::None, std::string ()));
404407
}
405408

406-
std::pair<IndexedNetlistModel::subcircuit_pair, std::pair<IndexedNetlistModel::Status, std::string> > SingleIndexedNetlistModel::subcircuit_from_index(const circuit_pair &circuits, size_t index) const
409+
std::pair<IndexedNetlistModel::subcircuit_pair, std::pair<IndexedNetlistModel::Status, std::string> > SingleIndexedNetlistModel::subcircuit_from_index (const circuit_pair &circuits, size_t index) const
407410
{
408411
db::Circuit::const_subcircuit_iterator none;
409-
return std::make_pair (attr_by_object_and_index (circuits, index, circuits.first->begin_subcircuits (), circuits.first->end_subcircuits (), none, none, m_subcircuit_by_circuit_and_index, sort_by_expanded_name<db::SubCircuit> ()), std::make_pair (db::NetlistCrossReference::None, std::string ()));
412+
return std::make_pair (attr_by_object_and_index (std::make_pair (circuits.first, (const db::Circuit *) 0), index, circuits.first->begin_subcircuits (), circuits.first->end_subcircuits (), none, none, m_subcircuit_by_circuit_and_index, sort_by_expanded_name<db::SubCircuit> ()), std::make_pair (db::NetlistCrossReference::None, std::string ()));
410413
}
411414

412415
size_t
413416
SingleIndexedNetlistModel::circuit_index (const circuit_pair &circuits) const
414417
{
415418
db::Netlist::const_circuit_iterator none;
416-
return index_from_attr (circuits, mp_netlist->begin_circuits (), mp_netlist->end_circuits (), none, none, m_circuit_index_by_object, sort_by_name<db::Circuit> ());
419+
return index_from_attr (std::make_pair (circuits.first, (const db::Circuit *) 0), mp_netlist->begin_circuits (), mp_netlist->end_circuits (), none, none, m_circuit_index_by_object, sort_by_name<db::Circuit> ());
417420
}
418421

419422
size_t
420-
SingleIndexedNetlistModel::net_index (const net_pair &nets) const
423+
SingleIndexedNetlistModel::net_index (const net_pair &nets_in) const
421424
{
422425
db::Circuit::const_net_iterator none;
423426

427+
net_pair nets = nets_in;
428+
nets.second = 0;
429+
424430
circuit_pair circuits = parent_of (nets);
425431
return index_from_attr (nets,
426432
circuits.first ? circuits.first->begin_nets () : none, circuits.first ? circuits.first->end_nets () : none,
427-
circuits.second ? circuits.second->begin_nets () : none, circuits.second ? circuits.second->end_nets () : none,
433+
none, none,
428434
m_net_index_by_object, sort_by_expanded_name<db::Net> ());
429435
}
430436

431437
size_t
432-
SingleIndexedNetlistModel::device_index (const device_pair &devices) const
438+
SingleIndexedNetlistModel::device_index (const device_pair &devices_in) const
433439
{
434440
db::Circuit::const_device_iterator none;
435441

442+
device_pair devices = devices_in;
443+
devices.second = 0;
444+
436445
circuit_pair circuits = parent_of (devices);
437446
return index_from_attr (devices,
438447
circuits.first ? circuits.first->begin_devices () : none, circuits.first ? circuits.first->end_devices () : none,
439-
circuits.second ? circuits.second->begin_devices () : none, circuits.second ? circuits.second->end_devices () : none,
448+
none, none,
440449
m_device_index_by_object, sort_by_expanded_name<db::Device> ());
441450
}
442451

@@ -445,21 +454,24 @@ SingleIndexedNetlistModel::pin_index (const pin_pair &pins, const circuit_pair &
445454
{
446455
db::Circuit::const_pin_iterator none;
447456

448-
return index_from_attr (pins,
457+
return index_from_attr (std::make_pair (pins.first, (const db::Pin *) 0),
449458
circuits.first ? circuits.first->begin_pins () : none, circuits.first ? circuits.first->end_pins () : none,
450-
circuits.second ? circuits.second->begin_pins () : none, circuits.second ? circuits.second->end_pins () : none,
459+
none, none,
451460
m_pin_index_by_object, sort_by_expanded_name<db::Pin> ());
452461
}
453462

454463
size_t
455-
SingleIndexedNetlistModel::subcircuit_index (const subcircuit_pair &subcircuits) const
464+
SingleIndexedNetlistModel::subcircuit_index (const subcircuit_pair &subcircuits_in) const
456465
{
457466
db::Circuit::const_subcircuit_iterator none;
458467

468+
subcircuit_pair subcircuits = subcircuits_in;
469+
subcircuits.second = 0;
470+
459471
circuit_pair circuits = parent_of (subcircuits);
460472
return index_from_attr (subcircuits,
461473
circuits.first ? circuits.first->begin_subcircuits () : none, circuits.first ? circuits.first->end_subcircuits () : none,
462-
circuits.second ? circuits.second->begin_subcircuits () : none, circuits.second ? circuits.second->end_subcircuits () : none,
474+
none, none,
463475
m_subcircuit_index_by_object, sort_by_expanded_name<db::SubCircuit> ());
464476
}
465477

src/layui/layui/layNetlistBrowserDialog.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ NetlistBrowserDialog::db ()
141141
return mp_ui->browser_page->db ();
142142
}
143143

144+
int
145+
NetlistBrowserDialog::l2n_index ()
146+
{
147+
return m_l2n_index;
148+
}
149+
144150
const lay::NetlistObjectsPath &
145151
NetlistBrowserDialog::current_path () const
146152
{
@@ -152,6 +158,14 @@ NetlistBrowserDialog::current_path () const
152158
}
153159
}
154160

161+
void
162+
NetlistBrowserDialog::set_current_path (const lay::NetlistObjectsPath &path)
163+
{
164+
if (mp_ui->browser_page) {
165+
mp_ui->browser_page->select_path (path);
166+
}
167+
}
168+
155169
const std::vector<lay::NetlistObjectsPath> &
156170
NetlistBrowserDialog::selected_paths () const
157171
{

src/layui/layui/layNetlistBrowserDialog.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,26 @@ class LAYUI_PUBLIC NetlistBrowserDialog
7777
*/
7878
db::LayoutToNetlist *db ();
7979

80+
/**
81+
* @brief Gets the index of the currently selected database in the view
82+
*/
83+
int l2n_index ();
84+
8085
/**
8186
* @brief Gets the current object's path
8287
*/
8388
const lay::NetlistObjectsPath &current_path () const;
8489

90+
/**
91+
* @brief Sets the current object's path
92+
*
93+
* This will make the given netlist object the current one and change the
94+
* selection to this one.
95+
*
96+
* Passing a null path will clear the selection.
97+
*/
98+
void set_current_path (const lay::NetlistObjectsPath &path);
99+
85100
/**
86101
* @brief Gets the selected nets
87102
*/

src/layui/layui/layNetlistBrowserModel.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3025,9 +3025,9 @@ NetlistBrowserModel::index_from_subcircuit (const std::pair<const db::SubCircuit
30253025
}
30263026

30273027
QModelIndex
3028-
NetlistBrowserModel::index_from_circuit (const db::Circuit *net) const
3028+
NetlistBrowserModel::index_from_circuit (const db::Circuit *circuit) const
30293029
{
3030-
return index_from_circuit (std::make_pair (net, mp_indexer->second_circuit_for (net)));
3030+
return index_from_circuit (std::make_pair (circuit, mp_indexer->second_circuit_for (circuit)));
30313031
}
30323032

30333033
std::pair<const db::Circuit *, const db::Circuit *>

src/layui/layui/layNetlistBrowserPage.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,9 @@ NetlistBrowserPage::select_path (const lay::NetlistObjectsPath &path)
502502
{
503503
if (path.is_null ()) {
504504

505-
nl_directory_tree->clearSelection ();
506-
sch_directory_tree->clearSelection ();
507-
xref_directory_tree->clearSelection ();
505+
nl_directory_tree->setCurrentIndex (QModelIndex ());
506+
sch_directory_tree->setCurrentIndex (QModelIndex ());
507+
xref_directory_tree->setCurrentIndex (QModelIndex ());
508508

509509
} else {
510510

@@ -1315,7 +1315,7 @@ NetlistBrowserPage::clear_highlights ()
13151315
void
13161316
NetlistBrowserPage::highlight (const NetlistObjectsPath &current_path, const std::vector<NetlistObjectsPath> &selected_paths)
13171317
{
1318-
if (current_path != m_current_path && selected_paths != m_selected_paths) {
1318+
if (current_path != m_current_path || selected_paths != m_selected_paths) {
13191319

13201320
m_current_path = current_path;
13211321
m_selected_paths = selected_paths;

src/layui/layui/layNetlistBrowserPage.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ Q_OBJECT
169169
*/
170170
void update_highlights ();
171171

172+
/**
173+
* @brief Adjusts the view depending on the current settings
174+
*/
175+
void adjust_view ();
176+
172177
/**
173178
* @brief Gets the current object's path
174179
*/
@@ -255,7 +260,6 @@ private slots:
255260
void setup_trees ();
256261
void add_to_history (const QModelIndex &index, bool fwd);
257262
void navigate_to (const QModelIndex &index, bool forward = true);
258-
void adjust_view ();
259263
void clear_markers ();
260264
void highlight (const NetlistObjectsPath &current_path, const std::vector<NetlistObjectsPath> &selected_paths);
261265
void clear_highlights ();

0 commit comments

Comments
 (0)