degate  0.1.2
Public Types | Public Member Functions | Protected Member Functions | Private Attributes
degate::Annotation Class Reference

An annotation is a descriptive meta object that can be placed on a logic model's layer to mark a region of interest. More...

#include <Annotation.h>

Inheritance diagram for degate::Annotation:
Inheritance graph
[legend]

List of all members.

Public Types

enum  ANNOTATION_TYPE {
  UNDEFINED = 0,
  SUBPROJECT = 1
}
 Enums to declare the type of annotation. More...
typedef unsigned int class_id_t
typedef std::map< std::string,
std::string > 
parameter_set_type

Public Member Functions

 Annotation ()
 Annotation (int _min_x, int _max_x, int _min_y, int _max_y, class_id_t _class_id=UNDEFINED)
 Create a new annotation.
 Annotation (BoundingBox const &bbox, class_id_t _class_id=UNDEFINED)
 Create a new annotation.
virtual ~Annotation ()
 The destructor for an annotaion.
virtual class_id_t get_class_id () const
 Get the class ID for an annotation.
virtual void set_class_id (class_id_t _class_id)
 Set the class ID for an annotation.
virtual const std::string get_descriptive_identifier () const
 Get a human readable string that describes the whole logic model object.
virtual const std::string get_object_type_name () const
 Get a human readable string that names the object type.
void print (std::ostream &os=std::cout, int n_tabs=0) const
 Print annotation.
void shift_x (int delta_x)
 Shift the shape vertically.
void shift_y (int delta_y)
 Shift the shape horizontally.
virtual bool in_bounding_box (BoundingBox const &bbox) const
 Check, if this rectangle is in the bounding box.
virtual BoundingBox const & get_bounding_box () const
 Get the bounding box.
virtual bool in_shape (int x, int y, int max_distance=0) const
 Check in the Point with coordinates x and y is within the area of the shape.
template<typename NewType >
NewType get_parameter (std::string parameter_name) const
 Get a parameter value.
parameter_set_type::const_iterator parameters_begin () const
 Get an iterator to iterate over parameters.
parameter_set_type::const_iterator parameters_end () const
 Get an end marker for the parameter iteration.
DeepCopyable_shptr cloneShallow () const
 Return a copy of this object, but with all references to other DeepCopyables cleared (e.g.
void cloneDeepInto (DeepCopyable_shptr destination, oldnew_t *oldnew) const
 Deep-copy all members to destination.

Protected Member Functions

void set_parameter (std::string const &parameter_name, std::string const &parameter_value)
 Set a parameter.

Private Attributes

class_id_t class_id
parameter_set_type parameters

Detailed Description

An annotation is a descriptive meta object that can be placed on a logic model's layer to mark a region of interest.

The semantics of an annotation is user defined. The libdegate does not establish a relationship from an annotaion to another logic model object or to an background image region.

Each annotation should have a class ID. This might be used to classify the kind of annotation. For example you can place an annotation 'above' a distored part of the background image to remember yourself, that this image part should be rephotographed. An image recognition algorithm may auto-annotate, that it is unsure e.g. if there is a via or not due to fuzzy thresholds.

You can set a name and a description for the annotation as well.

This class is designed to be derived for concrete annotations.

See also:
set_name()
set_description()

Definition at line 62 of file Annotation.h.


Member Typedef Documentation

typedef unsigned int degate::Annotation::class_id_t

Definition at line 66 of file Annotation.h.

typedef std::map<std::string, std::string > degate::Annotation::parameter_set_type

Definition at line 78 of file Annotation.h.


Member Enumeration Documentation

Enums to declare the type of annotation.

Enumerator:
UNDEFINED 
SUBPROJECT 

Definition at line 72 of file Annotation.h.

                         {
      UNDEFINED = 0,
      SUBPROJECT = 1
    };

Constructor & Destructor Documentation

degate::Annotation::Annotation ( ) [inline, explicit]

Definition at line 99 of file Annotation.h.

{};
Annotation::Annotation ( int  _min_x,
int  _max_x,
int  _min_y,
int  _max_y,
class_id_t  _class_id = UNDEFINED 
)

Create a new annotation.

Definition at line 29 of file Annotation.cc.

                                             :
  Rectangle(_min_x, _max_x, _min_y, _max_y), class_id(_class_id) {

}
Annotation::Annotation ( BoundingBox const &  bbox,
class_id_t  _class_id = UNDEFINED 
)

Create a new annotation.

Definition at line 35 of file Annotation.cc.

                                                                    :
  Rectangle(bbox.get_min_x(), bbox.get_max_x(),
            bbox.get_min_y(), bbox.get_max_y()),
  class_id(_class_id) {
}
Annotation::~Annotation ( ) [virtual]

The destructor for an annotaion.

Definition at line 41 of file Annotation.cc.

                        {
}

Member Function Documentation

void Annotation::cloneDeepInto ( DeepCopyable_shptr  destination,
oldnew_t oldnew 
) const [virtual]

Deep-copy all members to destination.

Todo:
Find out whether the default assignment operator can be used to simplify implementations of this method.

Reimplemented from degate::PlacedLogicModelObject.

Definition at line 49 of file Annotation.cc.

References class_id, and parameters.

                                                                              {
  auto clone = std::dynamic_pointer_cast<Annotation>(dest);
  clone->class_id = class_id;
  clone->parameters = parameters;
  Rectangle::cloneDeepInto(dest, oldnew);
  PlacedLogicModelObject::cloneDeepInto(dest, oldnew);
}

Return a copy of this object, but with all references to other DeepCopyables cleared (e.g.

set to 0-pointer).

Implements degate::DeepCopyable.

Definition at line 44 of file Annotation.cc.

                                                  {
  auto clone = std::make_shared<Annotation>();
  return clone;
}
virtual BoundingBox const& degate::Annotation::get_bounding_box ( ) const [inline, virtual]

Get the bounding box.

Reimplemented from degate::Rectangle.

Definition at line 176 of file Annotation.h.

Referenced by print().

Here is the caller graph for this function:

Get the class ID for an annotation.

Definition at line 57 of file Annotation.cc.

References class_id.

Referenced by get_descriptive_identifier(), and print().

                                                    {
  return class_id;
}

Here is the caller graph for this function:

const std::string Annotation::get_descriptive_identifier ( ) const [virtual]

Get a human readable string that describes the whole logic model object.

The string should be unique in order to let the user identify the concrete object. But that is not a must.

Reimplemented from degate::LogicModelObjectBase.

Definition at line 65 of file Annotation.cc.

References get_class_id(), degate::LogicModelObjectBase::get_name(), and degate::LogicModelObjectBase::get_object_id().

                                                             {
  boost::format fmter("%1% (id=%2%,class=%3%)");
  fmter % get_object_id() % get_name() % get_class_id();
  return fmter.str();
}

Here is the call graph for this function:

const std::string Annotation::get_object_type_name ( ) const [virtual]

Get a human readable string that names the object type.

Here it is "Annotation".

Reimplemented from degate::LogicModelObjectBase.

Definition at line 71 of file Annotation.cc.

                                                       {
  return std::string("Annotation");
}
template<typename NewType >
NewType degate::Annotation::get_parameter ( std::string  parameter_name) const [inline]

Get a parameter value.

Exceptions:
boost::bad_lexical_castThis exception is thrown if the parameter value cannot be converted to the desired type.
CollectionLookupExceptionThis exception is thrown if the parameter is not stored in the lookup table.

Definition at line 195 of file Annotation.h.

References debug(), parameters, and TM.

                                                          {

      parameter_set_type::const_iterator iter = parameters.find(parameter_name);
      if(iter == parameters.end()) {
        boost::format f("Failed to lookup parameter %1%.");
        f % parameter_name;
        throw CollectionLookupException(f.str());
      }

      if(typeid(NewType) == typeid(std::string) ||
         typeid(NewType) == typeid(boost::filesystem::path)) {

        return NewType(iter->second);
      }

      try {
        return boost::lexical_cast<NewType>(iter->second);
      }
      catch(boost::bad_lexical_cast &) {
        debug(TM, "Failed to convert value string '%s'.", iter->second.c_str());
        throw;
      }
    }

Here is the call graph for this function:

virtual bool degate::Annotation::in_bounding_box ( BoundingBox const &  bbox) const [inline, virtual]

Check, if this rectangle is in the bounding box.

Reimplemented from degate::Rectangle.

Definition at line 172 of file Annotation.h.

                                                                {
      return in_bounding_box(bbox);
    }
virtual bool degate::Annotation::in_shape ( int  x,
int  y,
int  max_distance = 0 
) const [inline, virtual]

Check in the Point with coordinates x and y is within the area of the shape.

Reimplemented from degate::Rectangle.

Definition at line 180 of file Annotation.h.

                                                                    {
      return Rectangle::in_shape(x, y, max_distance);
    }
Annotation::parameter_set_type::const_iterator Annotation::parameters_begin ( ) const

Get an iterator to iterate over parameters.

Definition at line 89 of file Annotation.cc.

References parameters.

                                                                              {
  return parameters.begin();
}
Annotation::parameter_set_type::const_iterator Annotation::parameters_end ( ) const

Get an end marker for the parameter iteration.

Definition at line 93 of file Annotation.cc.

References parameters.

                                                                            {
  return parameters.end();
}
void Annotation::print ( std::ostream &  os = std::cout,
int  n_tabs = 0 
) const [virtual]

Print annotation.

Implements degate::PlacedLogicModelObject.

Definition at line 75 of file Annotation.cc.

References degate::gen_tabs(), get_bounding_box(), get_class_id(), degate::LogicModelObjectBase::get_description(), degate::LogicModelObjectBase::get_name(), degate::LogicModelObjectBase::get_object_id(), and degate::BoundingBox::to_string().

                                                        {

  os
    << gen_tabs(n_tabs) << "Annotation name  : " << get_name() << std::endl
    << gen_tabs(n_tabs) << "Description      : " << get_description() << std::endl
    << gen_tabs(n_tabs) << "Object ID        : " << get_object_id() << std::endl
    << gen_tabs(n_tabs) << "Bounding box     : " << Rectangle::get_bounding_box().to_string() << std::endl
    << gen_tabs(n_tabs) << "Annotation class : " << get_class_id() << std::endl
    << std::endl;

  os << std::endl;

}

Here is the call graph for this function:

void Annotation::set_class_id ( Annotation::class_id_t  _class_id) [virtual]

Set the class ID for an annotation.

Definition at line 61 of file Annotation.cc.

References class_id.

                                                            {
  class_id = _class_id;
}
void degate::Annotation::set_parameter ( std::string const &  parameter_name,
std::string const &  parameter_value 
) [inline, protected]

Set a parameter.

Definition at line 92 of file Annotation.h.

References parameters.

Referenced by degate::SubProjectAnnotation::set_path().

                                                         {
      parameters[parameter_name] = parameter_value;
    }

Here is the caller graph for this function:

void degate::Annotation::shift_x ( int  delta_x) [inline, virtual]

Shift the shape vertically.

Note: If you store this shape in a QuadTree, you have to manage the changes in your QuadTree by yourself.

Reimplemented from degate::Rectangle.

Definition at line 162 of file Annotation.h.

References degate::PlacedLogicModelObject::notify_shape_change().

Here is the call graph for this function:

void degate::Annotation::shift_y ( int  delta_y) [inline, virtual]

Shift the shape horizontally.

Note: If you store this shape in a QuadTree, you have to manage the changes in your QuadTree by yourself.

Reimplemented from degate::Rectangle.

Definition at line 167 of file Annotation.h.

References degate::PlacedLogicModelObject::notify_shape_change().

Here is the call graph for this function:


Member Data Documentation

Definition at line 82 of file Annotation.h.

Referenced by cloneDeepInto(), get_class_id(), and set_class_id().


The documentation for this class was generated from the following files: