Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wip #1690

Merged
merged 9 commits into from
Apr 30, 2024
Merged

Wip #1690

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/ant/ant/antService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2198,15 +2198,29 @@ Service::paste ()
}
}

std::vector<const db::DUserObject *> new_objects;

for (db::Clipboard::iterator c = db::Clipboard::instance ().begin (); c != db::Clipboard::instance ().end (); ++c) {
const db::ClipboardValue<ant::Object> *value = dynamic_cast<const db::ClipboardValue<ant::Object> *> (*c);
if (value) {
ant::Object *ruler = new ant::Object (value->get ());
ruler->id (++idmax);
mp_view->annotation_shapes ().insert (db::DUserObject (ruler));
new_objects.push_back (&mp_view->annotation_shapes ().insert (db::DUserObject (ruler)));
}
}

// make new objects selected

if (! new_objects.empty ()) {

for (auto r = new_objects.begin (); r != new_objects.end (); ++r) {
m_selected.insert (std::make_pair (mp_view->annotation_shapes ().iterator_from_pointer (*r), 0));
}

selection_to_view ();

}

}

}
Expand Down
5 changes: 5 additions & 0 deletions src/db/db/dbCircuit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,11 @@ void Circuit::set_pin_ref_for_pin (size_t pin_id, Net::pin_iterator iter)
m_pin_refs [pin_id] = iter;
}

bool Circuit::is_empty () const
{
return m_nets.empty () && m_pins.empty () && m_devices.empty () && m_subcircuits.empty ();
}

void Circuit::blank ()
{
tl_assert (netlist () != 0);
Expand Down
5 changes: 5 additions & 0 deletions src/db/db/dbCircuit.h
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,11 @@ class DB_PUBLIC Circuit
*/
void blank ();

/**
* @brief Gets a value indicating whether the circuit is empty
*/
bool is_empty () const;

/**
* @brief Generate memory statistics
*/
Expand Down
6 changes: 3 additions & 3 deletions src/db/db/dbEdgePairFilters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ bool EdgePairFilterByArea::selected (const db::EdgePair &edge_pair) const
// EdgePairFilterByArea implementation

InternalAngleEdgePairFilter::InternalAngleEdgePairFilter (double a, bool inverted)
: m_inverted (inverted), m_checker (a, true, a, true)
: m_checker (a, true, a, true, inverted, false)
{
// .. nothing yet ..
}

InternalAngleEdgePairFilter::InternalAngleEdgePairFilter (double amin, bool include_amin, double amax, bool include_amax, bool inverted)
: m_inverted (inverted), m_checker (amin, include_amin, amax, include_amax)
: m_checker (amin, include_amin, amax, include_amax, inverted, false)
{
// .. nothing yet ..
}
Expand All @@ -122,7 +122,7 @@ InternalAngleEdgePairFilter::selected (const db::EdgePair &edge_pair) const
std::swap (d1, d2);
}

return m_checker (d1, d2) != m_inverted;
return m_checker (d1, d2);
}

}
38 changes: 23 additions & 15 deletions src/db/db/dbEdgesUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,13 @@ EdgeSegmentSelector::process (const db::Edge &edge, std::vector<db::Edge> &res)
// -------------------------------------------------------------------------------------------------------------
// EdgeAngleChecker implementation

EdgeAngleChecker::EdgeAngleChecker (double angle_start, bool include_angle_start, double angle_end, bool include_angle_end)
EdgeAngleChecker::EdgeAngleChecker (double angle_start, bool include_angle_start, double angle_end, bool include_angle_end, bool inverse, bool absolute)
{
if (absolute && angle_start < -db::epsilon) {
angle_start = 0.0;
include_angle_start = true;
}

m_t_start = db::CplxTrans(1.0, angle_start, false, db::DVector ());
m_t_end = db::CplxTrans(1.0, angle_end, false, db::DVector ());

Expand All @@ -225,6 +230,9 @@ EdgeAngleChecker::EdgeAngleChecker (double angle_start, bool include_angle_start

m_big_angle = (angle_end - angle_start + db::epsilon) > 180.0;
m_all = (angle_end - angle_start - db::epsilon) > 360.0;

m_absolute = absolute;
m_inverse = inverse;
}

bool
Expand Down Expand Up @@ -255,14 +263,14 @@ EdgeAngleChecker::check (const db::Vector &a, const db::Vector &b) const
// -------------------------------------------------------------------------------------------------------------
// EdgeOrientationFilter implementation

EdgeOrientationFilter::EdgeOrientationFilter (double amin, bool include_amin, double amax, bool include_amax, bool inverse)
: m_inverse (inverse), m_checker (amin, include_amin, amax, include_amax)
EdgeOrientationFilter::EdgeOrientationFilter (double amin, bool include_amin, double amax, bool include_amax, bool inverse, bool absolute)
: m_checker (amin, include_amin, amax, include_amax, inverse, absolute)
{
// .. nothing yet ..
}

EdgeOrientationFilter::EdgeOrientationFilter (double a, bool inverse)
: m_inverse (inverse), m_checker (a, true, a, true)
EdgeOrientationFilter::EdgeOrientationFilter (double a, bool inverse, bool absolute)
: m_checker (a, true, a, true, inverse, absolute)
{
// .. nothing yet ..
}
Expand All @@ -273,9 +281,9 @@ EdgeOrientationFilter::selected (const db::Edge &edge) const
// NOTE: this edge normalization confines the angle to a range between (-90 .. 90] (-90 excluded).
// A horizontal edge has 0 degree, a vertical one has 90 degree.
if (edge.dx () < 0 || (edge.dx () == 0 && edge.dy () < 0)) {
return m_checker (db::Vector (edge.ortho_length (), 0), -edge.d ()) != m_inverse;
return m_checker (db::Vector (edge.ortho_length (), 0), -edge.d ());
} else {
return m_checker (db::Vector (edge.ortho_length (), 0), edge.d ()) != m_inverse;
return m_checker (db::Vector (edge.ortho_length (), 0), edge.d ());
}
}

Expand All @@ -289,20 +297,20 @@ SpecialEdgeOrientationFilter::SpecialEdgeOrientationFilter (FilterType type, boo
}

static EdgeAngleChecker s_ortho_checkers [] = {
EdgeAngleChecker (0.0, true, 0.0, true),
EdgeAngleChecker (90.0, true, 90.0, true)
EdgeAngleChecker (0.0, true, 0.0, true, false, false),
EdgeAngleChecker (90.0, true, 90.0, true, false, false)
};

static EdgeAngleChecker s_diagonal_checkers [] = {
EdgeAngleChecker (-45.0, true, -45.0, true),
EdgeAngleChecker (45.0, true, 45.0, true)
EdgeAngleChecker (-45.0, true, -45.0, true, false, false),
EdgeAngleChecker (45.0, true, 45.0, true, false, false)
};

static EdgeAngleChecker s_orthodiagonal_checkers [] = {
EdgeAngleChecker (-45.0, true, -45.0, true),
EdgeAngleChecker (0.0, true, 0.0, true),
EdgeAngleChecker (45.0, true, 45.0, true),
EdgeAngleChecker (90.0, true, 90.0, true)
EdgeAngleChecker (-45.0, true, -45.0, true, false, false),
EdgeAngleChecker (0.0, true, 0.0, true, false, false),
EdgeAngleChecker (45.0, true, 45.0, true, false, false),
EdgeAngleChecker (90.0, true, 90.0, true, false, false)
};

bool
Expand Down
13 changes: 8 additions & 5 deletions src/db/db/dbEdgesUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,23 @@ struct DB_PUBLIC EdgeLengthFilter
class DB_PUBLIC EdgeAngleChecker
{
public:
EdgeAngleChecker (double angle_start, bool include_angle_start, double angle_end, bool include_angle_end);
EdgeAngleChecker (double angle_start, bool include_angle_start, double angle_end, bool include_angle_end, bool inverse, bool absolute);

bool operator() (const db::Edge &a, const db::Edge &b) const
{
return m_all || check (a.d (), b.d ());
return (m_all || check (a.d (), b.d ()) || (m_absolute && check (b.d (), a.d ()))) != m_inverse;
}

bool operator() (const db::Vector &a, const db::Vector &b) const
{
return m_all || check (a, b);
return (m_all || check (a, b) || (m_absolute && check (b, a))) != m_inverse;
}

private:
db::CplxTrans m_t_start, m_t_end;
bool m_include_start, m_include_end;
bool m_big_angle, m_all;
bool m_inverse, m_absolute;

bool check (const db::Vector &a, const db::Vector &b) const;
};
Expand All @@ -181,22 +182,24 @@ struct DB_PUBLIC EdgeOrientationFilter
* @param amin The minimum angle (measured against the x axis)
* @param amax The maximum angle (measured against the x axis)
* @param inverse If set to true, only edges not matching this criterion will be filtered
* @param absolute Angles are always positive
*
* This filter will filter out all edges whose angle against x axis
* is larger or equal to amin and less than amax.
*/
EdgeOrientationFilter (double amin, bool include_amin, double amax, bool include_amax, bool inverse);
EdgeOrientationFilter (double amin, bool include_amin, double amax, bool include_amax, bool inverse, bool absolute);

/**
* @brief Constructor
*
* @param a The angle (measured against the x axis)
* @param inverse If set to true, only edges not matching this criterion will be filtered
* @param absolute Angles are always positive
*
* This filter will filter out all edges whose angle against x axis
* is equal to a.
*/
EdgeOrientationFilter (double a, bool inverse);
EdgeOrientationFilter (double a, bool inverse, bool absolute);

/**
* @brief Returns true if the edge orientation matches the criterion
Expand Down
17 changes: 16 additions & 1 deletion src/db/db/dbNetlistSpiceReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,12 @@ SpiceNetlistBuilder::circuit_for (const SpiceCachedCircuit *cc, const parameters
if (cp == c->second.end ()) {
return 0;
}

// a null pointer indicates that we are currently defining this circuit
if (cp->second == 0) {
error (tl::sprintf (tl::to_string (tr ("Subcircuit '%s' called recursively")), cc->name ()));
}

return cp->second;
}

Expand Down Expand Up @@ -1055,7 +1061,8 @@ SpiceNetlistBuilder::build_circuit (const SpiceCachedCircuit *cc, const paramete
c->set_name (make_circuit_name (cc->name (), pv));
}

register_circuit_for (cc, pv, c, anonymous_top_level);
// pre-register the circuit - allows detecting recursive calls
register_circuit_for (cc, pv, 0, false);

std::unique_ptr<std::map<std::string, db::Net *> > n2n (mp_nets_by_name.release ());
mp_nets_by_name.reset (0);
Expand Down Expand Up @@ -1095,6 +1102,14 @@ SpiceNetlistBuilder::build_circuit (const SpiceCachedCircuit *cc, const paramete
std::swap (c, mp_netlist_circuit);
std::swap (vars, m_variables);

// final registration if required
if (! anonymous_top_level || ! c->is_empty ()) {
register_circuit_for (cc, pv, c, anonymous_top_level);
} else {
mp_netlist->remove_circuit (c);
c = 0;
}

return c;
}

Expand Down
4 changes: 2 additions & 2 deletions src/db/db/dbRegionProcessors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ namespace db
// -----------------------------------------------------------------------------------
// CornerDetectorCore implementation

CornerDetectorCore::CornerDetectorCore (double angle_start, bool include_angle_start, double angle_end, bool include_angle_end)
: m_checker (angle_start, include_angle_start, angle_end, include_angle_end)
CornerDetectorCore::CornerDetectorCore (double angle_start, bool include_angle_start, double angle_end, bool include_angle_end, bool inverse, bool absolute)
: m_checker (angle_start, include_angle_start, angle_end, include_angle_end, inverse, absolute)
{
// .. nothing yet ..
}
Expand Down
14 changes: 7 additions & 7 deletions src/db/db/dbRegionProcessors.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class DB_PUBLIC CornerEdgePairDelivery
class DB_PUBLIC CornerDetectorCore
{
public:
CornerDetectorCore (double angle_start, bool include_angle_start, double angle_end, bool include_angle_end);
CornerDetectorCore (double angle_start, bool include_angle_start, double angle_end, bool include_angle_end, bool inverse, bool absolute);
virtual ~CornerDetectorCore () { }

void detect_corners (const db::Polygon &poly, const CornerPointDelivery &delivery) const;
Expand All @@ -130,8 +130,8 @@ class DB_PUBLIC CornersAsRectangles
: public db::PolygonProcessorBase, private CornerDetectorCore
{
public:
CornersAsRectangles (double angle_start, bool include_angle_start, double angle_end, bool include_angle_end, db::Coord dim = 1)
: CornerDetectorCore (angle_start, include_angle_start, angle_end, include_angle_end), m_dim (dim)
CornersAsRectangles (double angle_start, bool include_angle_start, double angle_end, bool include_angle_end, bool inverse, bool absolute, db::Coord dim = 1)
: CornerDetectorCore (angle_start, include_angle_start, angle_end, include_angle_end, inverse, absolute), m_dim (dim)
{
// .. nothing yet ..
}
Expand Down Expand Up @@ -159,8 +159,8 @@ class DB_PUBLIC CornersAsDots
: public db::PolygonToEdgeProcessorBase, private CornerDetectorCore
{
public:
CornersAsDots (double angle_start, bool include_angle_start, double angle_end, bool include_angle_end)
: CornerDetectorCore (angle_start, include_angle_start, angle_end, include_angle_end)
CornersAsDots (double angle_start, bool include_angle_start, double angle_end, bool include_angle_end, bool inverse, bool absolute)
: CornerDetectorCore (angle_start, include_angle_start, angle_end, include_angle_end, inverse, absolute)
{
// .. nothing yet ..
}
Expand All @@ -184,8 +184,8 @@ class DB_PUBLIC CornersAsEdgePairs
: public db::PolygonToEdgePairProcessorBase, private CornerDetectorCore
{
public:
CornersAsEdgePairs (double angle_start, bool include_angle_start, double angle_end, bool include_angle_end)
: CornerDetectorCore (angle_start, include_angle_start, angle_end, include_angle_end)
CornersAsEdgePairs (double angle_start, bool include_angle_start, double angle_end, bool include_angle_end, bool inverse, bool absolute)
: CornerDetectorCore (angle_start, include_angle_start, angle_end, include_angle_end, inverse, absolute)
{
// .. nothing yet ..
}
Expand Down
Loading
Loading