mirror of https://github.com/KLayout/klayout.git
WIP
This commit is contained in:
parent
2a50c87969
commit
8d7919e054
|
|
@ -117,8 +117,8 @@ private:
|
|||
// --------------------------------------------------------------------
|
||||
// MeasureEval implementation
|
||||
|
||||
MeasureEval::MeasureEval ()
|
||||
: m_shape_type (None), m_prop_id (0)
|
||||
MeasureEval::MeasureEval (double dbu)
|
||||
: m_shape_type (None), m_prop_id (0), m_dbu (dbu)
|
||||
{
|
||||
mp_shape.any = 0;
|
||||
}
|
||||
|
|
@ -196,21 +196,54 @@ MeasureEval::resolve_name (const std::string &name, const tl::EvalFunction *&fun
|
|||
tl::Variant
|
||||
MeasureEval::shape_func () const
|
||||
{
|
||||
switch (m_shape_type)
|
||||
{
|
||||
case None:
|
||||
default:
|
||||
return tl::Variant ();
|
||||
case Polygon:
|
||||
return tl::Variant (mp_shape.poly);
|
||||
case PolygonRef:
|
||||
return tl::Variant (mp_shape.poly_ref);
|
||||
case Edge:
|
||||
return tl::Variant (mp_shape.edge);
|
||||
case EdgePair:
|
||||
return tl::Variant (mp_shape.edge_pair);
|
||||
case Text:
|
||||
return tl::Variant (mp_shape.text);
|
||||
if (m_dbu > 1e-10) {
|
||||
|
||||
db::CplxTrans tr (m_dbu);
|
||||
|
||||
switch (m_shape_type)
|
||||
{
|
||||
case None:
|
||||
default:
|
||||
return tl::Variant ();
|
||||
case Polygon:
|
||||
return tl::Variant (tr * *mp_shape.poly);
|
||||
case PolygonRef:
|
||||
{
|
||||
db::Polygon poly;
|
||||
mp_shape.poly_ref->instantiate (poly);
|
||||
return tl::Variant (tr * poly);
|
||||
}
|
||||
case Edge:
|
||||
return tl::Variant (tr * *mp_shape.edge);
|
||||
case EdgePair:
|
||||
return tl::Variant (tr * *mp_shape.edge_pair);
|
||||
case Text:
|
||||
return tl::Variant (tr * *mp_shape.text);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
switch (m_shape_type)
|
||||
{
|
||||
case None:
|
||||
default:
|
||||
return tl::Variant ();
|
||||
case Polygon:
|
||||
return tl::Variant (*mp_shape.poly);
|
||||
case PolygonRef:
|
||||
{
|
||||
db::Polygon poly;
|
||||
mp_shape.poly_ref->instantiate (poly);
|
||||
return tl::Variant (poly);
|
||||
}
|
||||
case Edge:
|
||||
return tl::Variant (*mp_shape.edge);
|
||||
case EdgePair:
|
||||
return tl::Variant (*mp_shape.edge_pair);
|
||||
case Text:
|
||||
return tl::Variant (*mp_shape.text);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class DB_PUBLIC MeasureEval
|
|||
: public tl::Eval
|
||||
{
|
||||
public:
|
||||
MeasureEval ();
|
||||
MeasureEval (double dbu);
|
||||
|
||||
void init ();
|
||||
|
||||
|
|
@ -92,6 +92,7 @@ private:
|
|||
mutable ShapeType m_shape_type;
|
||||
mutable ShapeRef mp_shape;
|
||||
mutable db::properties_id_type m_prop_id;
|
||||
double m_dbu;
|
||||
|
||||
tl::Variant shape_func () const;
|
||||
tl::Variant value_func (db::property_names_id_type name_id) const;
|
||||
|
|
@ -162,8 +163,8 @@ public:
|
|||
typedef typename ProcessorBase::shape_type shape_type;
|
||||
typedef typename ProcessorBase::result_type result_type;
|
||||
|
||||
property_computation_processor (const Container *container, const std::map<tl::Variant, std::string> &expressions, bool copy_properties)
|
||||
: m_eval (), m_copy_properties (copy_properties), m_expression_strings (expressions)
|
||||
property_computation_processor (const Container *container, const std::map<tl::Variant, std::string> &expressions, bool copy_properties, double dbu)
|
||||
: m_eval (dbu), m_copy_properties (copy_properties), m_expression_strings (expressions)
|
||||
{
|
||||
if (container) {
|
||||
this->set_result_is_merged (is_merged (container));
|
||||
|
|
@ -222,8 +223,8 @@ class expression_filter
|
|||
public:
|
||||
typedef typename FilterBase::shape_type shape_type;
|
||||
|
||||
expression_filter (const std::string &expression, bool inverse)
|
||||
: m_eval (), m_inverse (inverse), m_expression_string (expression)
|
||||
expression_filter (const std::string &expression, bool inverse, double dbu)
|
||||
: m_eval (dbu), m_inverse (inverse), m_expression_string (expression)
|
||||
{
|
||||
m_eval.init ();
|
||||
|
||||
|
|
|
|||
|
|
@ -109,9 +109,9 @@ static gsi::PolygonFilterBase *make_pg (const tl::Variant &name, const std::stri
|
|||
return new PolygonPropertiesFilter (name, pattern, inverse);
|
||||
}
|
||||
|
||||
static gsi::PolygonFilterBase *make_pe (const std::string &expression, bool inverse)
|
||||
static gsi::PolygonFilterBase *make_pe (const std::string &expression, bool inverse, double dbu)
|
||||
{
|
||||
return new gsi::expression_filter<gsi::PolygonFilterBase, db::Region> (expression, inverse);
|
||||
return new gsi::expression_filter<gsi::PolygonFilterBase, db::Region> (expression, inverse, dbu);
|
||||
}
|
||||
|
||||
Class<gsi::PolygonFilterBase> decl_PolygonFilterBase ("db", "PolygonFilterBase",
|
||||
|
|
@ -155,17 +155,18 @@ Class<gsi::PolygonFilterBase> decl_PolygonFilterBase ("db", "PolygonFilterBase",
|
|||
"\n"
|
||||
"This feature has been introduced in version 0.30."
|
||||
) +
|
||||
gsi::constructor ("expression_filter", &make_pe, gsi::arg ("expression"), gsi::arg ("inverse", false),
|
||||
gsi::constructor ("expression_filter", &make_pe, gsi::arg ("expression"), gsi::arg ("inverse", false), gsi::arg ("dbu", 0.0),
|
||||
"@brief Creates an expression-based filter\n"
|
||||
"@param expression The expression to evaluate.\n"
|
||||
"@param inverse If true, inverts the selection - i.e. all polygons without a property with the given name and value range are selected.\n"
|
||||
"@param dbu If given and greater than zero, the shapes delivered by the 'shape' function will be in micrometer units.\n"
|
||||
"\n"
|
||||
"Creates a filter that will evaluate the given expression on every shape and select the shape "
|
||||
"when the expression renders a boolean true value. "
|
||||
"The expression may use the following variables and functions:\n"
|
||||
"\n"
|
||||
"@ul\n"
|
||||
"@li @b shape @/b: The current shape @/li\n"
|
||||
"@li @b shape @/b: The current shape (i.e. 'Polygon' without DBU specified or 'DPolygon' otherwise) @/li\n"
|
||||
"@li @b value(<name>) @/b: The value of the property with the given name (the first one if there are multiple properties with the same name) @/li\n"
|
||||
"@li @b values(<name>) @/b: All values of the properties with the given name (returns a list) @/li\n"
|
||||
"@li @b <name> @/b: A shortcut for 'value(<name>)' (<name> is used as a symbol) @/li\n"
|
||||
|
|
@ -276,19 +277,20 @@ Class<shape_processor_impl<db::PolygonProcessorBase> > decl_PolygonOperator (dec
|
|||
|
||||
static
|
||||
property_computation_processor<db::PolygonProcessorBase, db::Region> *
|
||||
new_pcp (const db::Region *container, const std::map<tl::Variant, std::string> &expressions, bool copy_properties)
|
||||
new_pcp (const db::Region *container, const std::map<tl::Variant, std::string> &expressions, bool copy_properties, double dbu)
|
||||
{
|
||||
return new property_computation_processor<db::PolygonProcessorBase, db::Region> (container, expressions, copy_properties);
|
||||
return new property_computation_processor<db::PolygonProcessorBase, db::Region> (container, expressions, copy_properties, dbu);
|
||||
}
|
||||
|
||||
Class<property_computation_processor<db::PolygonProcessorBase, db::Region> > decl_PolygonPropertiesExpressions (decl_PolygonProcessorBase, "db", "PolygonPropertiesExpressions",
|
||||
property_computation_processor<db::PolygonProcessorBase, db::Region>::method_decls (true) +
|
||||
gsi::constructor ("new", &new_pcp, gsi::arg ("region"), gsi::arg ("expressions"), gsi::arg ("copy_properties", false),
|
||||
gsi::constructor ("new", &new_pcp, gsi::arg ("region"), gsi::arg ("expressions"), gsi::arg ("copy_properties", false), gsi::arg ("dbu", 0.0),
|
||||
"@brief Creates a new properties expressions operator\n"
|
||||
"\n"
|
||||
"@param region The region, the processor will be used on. Can be nil, but if given, allows some optimization.\n"
|
||||
"@param expressions A map of property names and expressions used to generate the values of the properties (see class description for details).\n"
|
||||
"@param copy_properties If true, new properties will be added to existing ones.\n"
|
||||
"@param dbu If not zero, this value specifies the database unit to use. If given, the shapes returned by the 'shape' function will be micrometer-unit objects.\n"
|
||||
),
|
||||
"@brief An operator attaching computed properties to the polygons\n"
|
||||
"\n"
|
||||
|
|
@ -300,7 +302,7 @@ Class<property_computation_processor<db::PolygonProcessorBase, db::Region> > dec
|
|||
"The expression may use the following variables and functions:\n"
|
||||
"\n"
|
||||
"@ul\n"
|
||||
"@li @b shape @/b: The current shape @/li\n"
|
||||
"@li @b shape @/b: The current shape (i.e. 'Polygon' without DBU specified or 'DPolygon' otherwise) @/li\n"
|
||||
"@li @b value(<name>) @/b: The value of the property with the given name (the first one if there are multiple properties with the same name) @/li\n"
|
||||
"@li @b values(<name>) @/b: All values of the properties with the given name (returns a list) @/li\n"
|
||||
"@li @b <name> @/b: A shortcut for 'value(<name>)' (<name> is used as a symbol) @/li\n"
|
||||
|
|
|
|||
Loading…
Reference in New Issue