mirror of https://github.com/KLayout/klayout.git
WIP: same sorting of subcircuit connections and circuit pins.
This commit is contained in:
parent
8bb7342147
commit
27d1f2fac1
|
|
@ -798,11 +798,6 @@ static std::string search_string_from_names (const std::pair<const Obj *, const
|
|||
}
|
||||
}
|
||||
|
||||
static std::string rewire_subcircuit_pins_status_hint ()
|
||||
{
|
||||
return tl::to_string (tr ("Either pins or nets don't form a good pair.\nThis means either pin swapping happens (in this case, the nets will still match)\nor the subcircuit wiring is not correct (you'll see an error on the net)."));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// item class declarations
|
||||
|
||||
|
|
@ -1112,36 +1107,6 @@ private:
|
|||
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
||||
// @@@ TODO: remove?
|
||||
class CircuitPinNetItemData
|
||||
: public NetlistModelItemData
|
||||
{
|
||||
public:
|
||||
CircuitPinNetItemData (NetlistModelItemData *parent, const IndexedNetlistModel::net_pair &np);
|
||||
|
||||
virtual void do_ensure_children (NetlistBrowserModel *model);
|
||||
virtual QIcon icon (NetlistBrowserModel *model);
|
||||
virtual QString text (int column, NetlistBrowserModel *model);
|
||||
virtual QString search_text ();
|
||||
virtual std::string tooltip (NetlistBrowserModel *model);
|
||||
virtual db::NetlistCrossReference::Status status (NetlistBrowserModel *model);
|
||||
|
||||
IndexedNetlistModel::pin_pair pp ()
|
||||
{
|
||||
return pins ();
|
||||
}
|
||||
|
||||
virtual std::pair<const db::Net *, const db::Net *> nets_of_this ()
|
||||
{
|
||||
return m_np;
|
||||
}
|
||||
|
||||
private:
|
||||
IndexedNetlistModel::net_pair m_np;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
||||
class CircuitSubCircuitPinsItemData
|
||||
: public NetlistModelItemData
|
||||
{
|
||||
|
|
@ -1794,56 +1759,6 @@ CircuitPinItemData::icon (NetlistBrowserModel * /*model*/)
|
|||
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
||||
// @@@ remove?
|
||||
CircuitPinNetItemData::CircuitPinNetItemData (NetlistModelItemData *parent, const IndexedNetlistModel::net_pair &np)
|
||||
: NetlistModelItemData (parent), m_np (np)
|
||||
{ }
|
||||
|
||||
void
|
||||
CircuitPinNetItemData::do_ensure_children (NetlistBrowserModel * /*model*/)
|
||||
{
|
||||
// nothing (leaf node)
|
||||
}
|
||||
|
||||
QIcon
|
||||
CircuitPinNetItemData::icon (NetlistBrowserModel *model)
|
||||
{
|
||||
return model->icon_for_connection (m_np);
|
||||
}
|
||||
|
||||
QString
|
||||
CircuitPinNetItemData::text (int column, NetlistBrowserModel *model)
|
||||
{
|
||||
// circuit/pin/net: header column = name, second column link to net
|
||||
if (column == model->object_column ()) {
|
||||
return escaped (str_from_expanded_names (m_np, model->indexer ()->is_single ()));
|
||||
} else if (column == model->first_column () || column == model->second_column ()) {
|
||||
return model->make_link_to (m_np, column);
|
||||
}
|
||||
|
||||
return QString ();
|
||||
}
|
||||
|
||||
QString
|
||||
CircuitPinNetItemData::search_text ()
|
||||
{
|
||||
return tl::to_qstring (search_string_from_expanded_names (nets_from_circuit_pins (circuits (), pp ())));
|
||||
}
|
||||
|
||||
std::string
|
||||
CircuitPinNetItemData::tooltip (NetlistBrowserModel * /*model*/)
|
||||
{
|
||||
return std::string ();
|
||||
}
|
||||
|
||||
db::NetlistCrossReference::Status
|
||||
CircuitPinNetItemData::status (NetlistBrowserModel * /*model*/)
|
||||
{
|
||||
return db::NetlistCrossReference::None;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
||||
CircuitNetItemData::CircuitNetItemData (NetlistModelItemData *parent, const IndexedNetlistModel::net_pair &np)
|
||||
: NetlistModelItemData (parent), m_np (np), m_seen (parent && parent->derived_from_nets (np))
|
||||
{ }
|
||||
|
|
|
|||
|
|
@ -310,17 +310,73 @@ const db::Circuit *NetlistCrossReferenceModel::second_circuit_for (const db::Cir
|
|||
|
||||
namespace {
|
||||
|
||||
struct CompareNetRefsByPins
|
||||
// TODO: borrowed from dbNetlistCrossReference.cc
|
||||
|
||||
static int string_value_compare (const std::string &a, const std::string &b)
|
||||
{
|
||||
bool operator () (const std::pair<const db::NetSubcircuitPinRef *, const db::NetSubcircuitPinRef *> &a,
|
||||
const std::pair<const db::NetSubcircuitPinRef *, const db::NetSubcircuitPinRef *> &b)
|
||||
return a == b ? 0 : (a < b ? -1 : 1);
|
||||
}
|
||||
|
||||
template <class Obj>
|
||||
struct by_expanded_name_value_compare
|
||||
{
|
||||
int operator() (const Obj &a, const Obj &b) const
|
||||
{
|
||||
size_t pin_id1 = a.first ? a.first->pin_id () : (a.second ? a.second->pin_id () : std::numeric_limits<size_t>::max ());
|
||||
size_t pin_id2 = b.first ? b.first->pin_id () : (b.second ? b.second->pin_id () : std::numeric_limits<size_t>::max ());
|
||||
return pin_id1 < pin_id2;
|
||||
return string_value_compare (a.expanded_name (), b.expanded_name ());
|
||||
}
|
||||
};
|
||||
|
||||
template <class Obj> struct net_object_compare;
|
||||
|
||||
template <>
|
||||
struct net_object_compare<db::NetSubcircuitPinRef>
|
||||
{
|
||||
int operator() (const db::NetSubcircuitPinRef &a, const db::NetSubcircuitPinRef &b) const
|
||||
{
|
||||
int ct = by_expanded_name_value_compare<db::SubCircuit> () (*a.subcircuit (), *b.subcircuit ());
|
||||
if (ct == 0) {
|
||||
return by_expanded_name_value_compare<db::Pin> () (*a.pin (), *b.pin ());
|
||||
} else {
|
||||
return ct;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class Obj, class ValueCompare>
|
||||
struct two_pointer_compare
|
||||
{
|
||||
int operator() (const Obj *a, const Obj *b) const
|
||||
{
|
||||
if ((a == 0) != (b == 0)) {
|
||||
return (a == 0) > (b == 0) ? -1 : 1;
|
||||
}
|
||||
if (a != 0) {
|
||||
return ValueCompare () (*a, *b);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class Obj, class ValueCompare>
|
||||
struct two_pair_compare
|
||||
{
|
||||
bool operator() (const std::pair<const Obj *, const Obj *> &a, const std::pair<const Obj *, const Obj *> &b)
|
||||
{
|
||||
int ct = two_pointer_compare<Obj, ValueCompare> () (a.first, b.first);
|
||||
if (ct != 0) {
|
||||
return ct < 0;
|
||||
}
|
||||
return two_pointer_compare<Obj, ValueCompare> () (a.second, b.second) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct SortNetSubCircuitPins
|
||||
: public two_pair_compare<db::NetSubcircuitPinRef, net_object_compare<db::NetSubcircuitPinRef> >
|
||||
{
|
||||
// .. nothing yet ..
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
void NetlistCrossReferenceModel::ensure_subcircuit_data_built () const
|
||||
|
|
@ -370,7 +426,7 @@ void NetlistCrossReferenceModel::ensure_subcircuit_data_built () const
|
|||
}
|
||||
}
|
||||
|
||||
std::sort (sc_data.nets_per_pins.begin (), sc_data.nets_per_pins.end (), CompareNetRefsByPins ());
|
||||
std::sort (sc_data.nets_per_pins.begin (), sc_data.nets_per_pins.end (), SortNetSubCircuitPins ());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue