LibreCAD
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lc::entity::Text Class Reference

#include <text.h>

Inheritance diagram for lc::entity::Text:
Collaboration diagram for lc::entity::Text:

Public Member Functions

 Text (const geo::Coordinate &insertion_point, const std::string text_value, const double height, const double angle, const std::string style, const TextConst::DrawingDirection textgeneration, const TextConst::HAlign halign, const TextConst::VAlign valign, const Layer_CSPtr layer, const MetaInfo_CSPtr metaInfo=nullptr, const Block_CSPtr block=nullptr)
 Text, default constructor. More...
 
 Text (const Text_CSPtr &other, bool sameID)
 
geo::Coordinate insertion_point () const
 
std::string const & text_value () const
 
double const angle () const
 
std::string const & style () const
 
TextConst::DrawingDirection const & textgeneration () const
 
TextConst::VAlign const & valign () const
 
TextConst::HAlign const & halign () const
 
double height () const
 
virtual CADEntity_CSPtr move (const geo::Coordinate &offset) const override
 move, moves by an offset More...
 
virtual CADEntity_CSPtr copy (const geo::Coordinate &offset) const override
 copy, copies line by an offset More...
 
virtual CADEntity_CSPtr rotate (const geo::Coordinate &rotation_center, const double rotation_angle) const override
 rotate, rotate operation More...
 
virtual CADEntity_CSPtr scale (const geo::Coordinate &scale_center, const geo::Coordinate &scale_factor) const override
 scale, scales the entity More...
 
virtual CADEntity_CSPtr mirror (const geo::Coordinate &axis1, const geo::Coordinate &axis2) const override
 
virtual const geo::Area boundingBox () const override
 boundingBox of the entity More...
 
virtual CADEntity_CSPtr modify (Layer_CSPtr layer, const MetaInfo_CSPtr metaInfo, Block_CSPtr block) const override
 modify Return a new entity with the same ID bit with possible modified metainfo and/pr layer information #return new entity with same ID More...
 
virtual void accept (GeoEntityVisitor &v) const override
 
virtual void dispatch (EntityDispatch &ed) const override
 
virtual std::map< unsigned int,
lc::geo::Coordinate
dragPoints () const override
 Get all points of the entity that can be dragged. More...
 
virtual CADEntity_CSPtr setDragPoints (std::map< unsigned int, lc::geo::Coordinate > dragPoints) const override
 Return modified entity. More...
 
- Public Member Functions inherited from lc::entity::CADEntity
 CADEntity ()
 
 CADEntity (Layer_CSPtr layer, const MetaInfo_CSPtr metaInfo=nullptr, const Block_CSPtr block=nullptr)
 CADEntity Constructor. More...
 
 CADEntity (CADEntity_CSPtr cadEntity, bool sameID)
 
 CADEntity (CADEntity_CSPtr cadEntity)
 
virtual ~CADEntity ()=default
 
Layer_CSPtr layer () const
 layer return the layer this entity is placed on More...
 
template<typename T >
const std::shared_ptr< const T > metaInfo (std::string metaName) const
 
MetaInfo_CSPtr metaInfo () const
 
Block_CSPtr block () const
 Return the current entity block. More...
 
- Public Member Functions inherited from lc::ID
 ID ()
 Default constructor, provides a new unique ID to each entity. More...
 
 ID (ID_DATATYPE)
 
virtual ~ID ()=default
 
ID_DATATYPE id () const
 returns the ID of the entity More...
 
bool operator== (const ID &id) const
 
void setID (ID_DATATYPE id)
 
- Public Member Functions inherited from lc::Visitable
virtual ~Visitable ()=default
 

Public Attributes

const geo::Coordinate _insertion_point
 
const std::string _text_value
 
const double _height
 
const double _angle
 
const std::string _style
 
const TextConst::DrawingDirection _textgeneration
 
const TextConst::VAlign _valign
 
const TextConst::HAlign _halign
 

Additional Inherited Members

- Static Public Attributes inherited from lc::ID
static std::atomic< ID_DATATYPE__idCounter
 
- Protected Member Functions inherited from lc::entity::CADEntity
 CADEntity (const lc::builder::CADEntityBuilder &builder)
 

Detailed Description

Definition at line 17 of file text.h.

Constructor & Destructor Documentation

Text::Text ( const geo::Coordinate insertion_point,
const std::string  text_value,
const double  height,
const double  angle,
const std::string  style,
const TextConst::DrawingDirection  textgeneration,
const TextConst::HAlign  halign,
const TextConst::VAlign  valign,
const Layer_CSPtr  layer,
const MetaInfo_CSPtr  metaInfo = nullptr,
const Block_CSPtr  block = nullptr 
)

Text, default constructor.

Parameters
geo::Coordinateinsertion_point, insertion_point of the text
doubleheight, height of the text
stringtext_value, the text itself
doubleangle, angle of obliqueness
stringstyle, name of text style
TextConst::DrawingDirectiontextgeneration, Text drawing direction
TextConst::HAlignhalign, Horizontal alignment
TextConst::VAlignvalign, Vertical alignment
Layer_CSPtrlayer, Layer of the entity
metatypesmetatypes of the cad entity

Definition at line 9 of file text.cpp.

19  :
21  _insertion_point(insertion_point),
23  _height(height),
24  _angle(angle),
25  _style(style),
27  _valign(valign),
28  _halign(halign) {
29 }
std::string const & style() const
Definition: text.h:70
const TextConst::HAlign _halign
Definition: text.h:55
double height() const
Definition: text.h:86
const TextConst::VAlign _valign
Definition: text.h:54
Layer_CSPtr layer() const
layer return the layer this entity is placed on
Definition: cadentity.cpp:29
const std::string _style
Definition: text.h:52
const TextConst::DrawingDirection _textgeneration
Definition: text.h:53
MetaInfo_CSPtr metaInfo() const
Definition: cadentity.h:123
std::string const & text_value() const
Definition: text.h:62
const geo::Coordinate _insertion_point
Definition: text.h:48
double const angle() const
Definition: text.h:66
const double _angle
Definition: text.h:51
const double _height
Definition: text.h:50
Block_CSPtr block() const
Return the current entity block.
Definition: cadentity.cpp:33
TextConst::VAlign const & valign() const
Definition: text.h:78
TextConst::HAlign const & halign() const
Definition: text.h:82
const std::string _text_value
Definition: text.h:49
TextConst::DrawingDirection const & textgeneration() const
Definition: text.h:74
Text::Text ( const Text_CSPtr &  other,
bool  sameID 
)

Definition at line 31 of file text.cpp.

31  : CADEntity(other, sameID),
32  _insertion_point(other->_insertion_point),
33  _text_value(other->_text_value),
34  _height(other->_height),
35  _angle(other->_angle),
36  _style(other->_style),
37  _textgeneration(other->_textgeneration),
38  _valign(other->_valign),
39  _halign(other->_halign) {
40 }
const TextConst::HAlign _halign
Definition: text.h:55
const TextConst::VAlign _valign
Definition: text.h:54
const std::string _style
Definition: text.h:52
const TextConst::DrawingDirection _textgeneration
Definition: text.h:53
const geo::Coordinate _insertion_point
Definition: text.h:48
const double _angle
Definition: text.h:51
const double _height
Definition: text.h:50
const std::string _text_value
Definition: text.h:49

Member Function Documentation

virtual void lc::entity::Text::accept ( GeoEntityVisitor v) const
inlineoverridevirtual

Reimplemented from lc::entity::CADEntity.

Definition at line 136 of file text.h.

136 { v.visit(*this); }
double const lc::entity::Text::angle ( ) const
inline

Definition at line 66 of file text.h.

66  {
67  return _angle;
68  }
const double _angle
Definition: text.h:51
const geo::Area Text::boundingBox ( ) const
overridevirtual

boundingBox of the entity

Returns
geo::Area area

Implements lc::entity::CADEntity.

Definition at line 104 of file text.cpp.

104  {
105  // TODO create bounding box for text
106  return geo::Area(geo::Coordinate(0., 0.), geo::Coordinate(0., 0.));
107 }
CADEntity_CSPtr Text::copy ( const geo::Coordinate offset) const
overridevirtual

copy, copies line by an offset

Parameters
geo::Coordinateoffset
Returns
CADEntity_CSPtr copied entity

Implements lc::entity::CADEntity.

Definition at line 57 of file text.cpp.

57  {
58  auto newText = std::make_shared<Text>(
59  this->_insertion_point + offset,
60  this->_text_value,
61  this->_height,
62  this->_angle,
63  this->_style,
64  this->_textgeneration,
65  this->_halign,
66  this->_valign,
67  layer(),
68  metaInfo());
69  newText->setID(this->id());
70  return newText;
71 }
const TextConst::HAlign _halign
Definition: text.h:55
const TextConst::VAlign _valign
Definition: text.h:54
Layer_CSPtr layer() const
layer return the layer this entity is placed on
Definition: cadentity.cpp:29
const std::string _style
Definition: text.h:52
const TextConst::DrawingDirection _textgeneration
Definition: text.h:53
MetaInfo_CSPtr metaInfo() const
Definition: cadentity.h:123
const geo::Coordinate _insertion_point
Definition: text.h:48
const double _angle
Definition: text.h:51
const double _height
Definition: text.h:50
const std::string _text_value
Definition: text.h:49
virtual void lc::entity::Text::dispatch ( EntityDispatch ed) const
inlineoverridevirtual

Implements lc::entity::CADEntity.

Definition at line 138 of file text.h.

138  {
139  ed.visit(shared_from_this());
140  }
std::map< unsigned int, lc::geo::Coordinate > Text::dragPoints ( ) const
overridevirtual

Get all points of the entity that can be dragged.

Returns
Map of points

Implements lc::Draggable.

Definition at line 128 of file text.cpp.

128  {
129  std::map<unsigned int, geo::Coordinate> dragPoints;
130 
131  dragPoints[0] = _insertion_point;
132 
133  return dragPoints;
134 }
const geo::Coordinate _insertion_point
Definition: text.h:48
virtual std::map< unsigned int, lc::geo::Coordinate > dragPoints() const override
Get all points of the entity that can be dragged.
Definition: text.cpp:128
TextConst::HAlign const& lc::entity::Text::halign ( ) const
inline

Definition at line 82 of file text.h.

82  {
83  return _halign;
84  }
const TextConst::HAlign _halign
Definition: text.h:55
double lc::entity::Text::height ( ) const
inline

Definition at line 86 of file text.h.

86  {
87  return _height;
88  }
const double _height
Definition: text.h:50
geo::Coordinate lc::entity::Text::insertion_point ( ) const
inline

Definition at line 58 of file text.h.

58  {
59  return _insertion_point;
60  }
const geo::Coordinate _insertion_point
Definition: text.h:48
virtual CADEntity_CSPtr lc::entity::Text::mirror ( const geo::Coordinate axis1,
const geo::Coordinate axis2 
) const
inlineoverridevirtual

Implements lc::entity::CADEntity.

Definition at line 122 of file text.h.

123  {
124  return NULL; // TODO: no return statement, not implemented in lwpolyline.cpp
125  }
CADEntity_CSPtr Text::modify ( Layer_CSPtr  layer,
const MetaInfo_CSPtr  metaInfo,
Block_CSPtr  block 
) const
overridevirtual

modify Return a new entity with the same ID bit with possible modified metainfo and/pr layer information #return new entity with same ID

Implements lc::entity::CADEntity.

Definition at line 109 of file text.cpp.

109  {
110  auto newText = std::make_shared<Text>(
111  this->_insertion_point,
112  this->_text_value,
113  this->_height,
114  this->_angle,
115  this->_style,
116  this->_textgeneration,
117  this->_halign,
118  this->_valign,
119  layer,
120  metaInfo,
121  block
122  );
123  newText->setID(this->id());
124 
125  return newText;
126 }
const TextConst::HAlign _halign
Definition: text.h:55
const TextConst::VAlign _valign
Definition: text.h:54
Layer_CSPtr layer() const
layer return the layer this entity is placed on
Definition: cadentity.cpp:29
const std::string _style
Definition: text.h:52
const TextConst::DrawingDirection _textgeneration
Definition: text.h:53
MetaInfo_CSPtr metaInfo() const
Definition: cadentity.h:123
const geo::Coordinate _insertion_point
Definition: text.h:48
const double _angle
Definition: text.h:51
const double _height
Definition: text.h:50
Block_CSPtr block() const
Return the current entity block.
Definition: cadentity.cpp:33
const std::string _text_value
Definition: text.h:49
CADEntity_CSPtr Text::move ( const geo::Coordinate offset) const
overridevirtual

move, moves by an offset

Parameters
geo::Coordinateoffset
Returns
CADEntity_CSPtr moved entity

Implements lc::entity::CADEntity.

Definition at line 42 of file text.cpp.

42  {
43  auto newText = std::make_shared<Text>(this->_insertion_point + offset,
44  this->_text_value,
45  this->_height,
46  this->_angle,
47  this->_style,
48  this->_textgeneration,
49  this->_halign,
50  this->_valign,
51  layer(),
52  metaInfo());
53  newText->setID(this->id());
54  return newText;
55 }
const TextConst::HAlign _halign
Definition: text.h:55
const TextConst::VAlign _valign
Definition: text.h:54
Layer_CSPtr layer() const
layer return the layer this entity is placed on
Definition: cadentity.cpp:29
const std::string _style
Definition: text.h:52
const TextConst::DrawingDirection _textgeneration
Definition: text.h:53
MetaInfo_CSPtr metaInfo() const
Definition: cadentity.h:123
const geo::Coordinate _insertion_point
Definition: text.h:48
const double _angle
Definition: text.h:51
const double _height
Definition: text.h:50
const std::string _text_value
Definition: text.h:49
CADEntity_CSPtr Text::rotate ( const geo::Coordinate rotation_center,
const double  rotation_angle 
) const
overridevirtual

rotate, rotate operation

Parameters
geo::Coordinaterotation_center
doublerotation_angle
Returns
CADEntity_CSPtr rotated entity

Implements lc::entity::CADEntity.

Definition at line 73 of file text.cpp.

73  {
74  auto newText = std::make_shared<Text>(
75  this->_insertion_point.rotate(rotation_center, rotation_angle),
76  this->_text_value,
77  this->_height,
78  this->_angle,
79  this->_style,
80  this->_textgeneration,
81  this->_halign,
82  this->_valign,
83  layer(),
84  metaInfo());
85  return newText;
86 }
const TextConst::HAlign _halign
Definition: text.h:55
const TextConst::VAlign _valign
Definition: text.h:54
Layer_CSPtr layer() const
layer return the layer this entity is placed on
Definition: cadentity.cpp:29
const std::string _style
Definition: text.h:52
const TextConst::DrawingDirection _textgeneration
Definition: text.h:53
MetaInfo_CSPtr metaInfo() const
Definition: cadentity.h:123
const geo::Coordinate _insertion_point
Definition: text.h:48
Coordinate rotate(const Coordinate &angleVector) const
rotate around (0.,0.) with a given angle vector
const double _angle
Definition: text.h:51
const double _height
Definition: text.h:50
const std::string _text_value
Definition: text.h:49
CADEntity_CSPtr Text::scale ( const geo::Coordinate scale_center,
const geo::Coordinate scale_factor 
) const
overridevirtual

scale, scales the entity

Parameters
geo::Coordinatescale_center
doublescale_factor
Returns

Implements lc::entity::CADEntity.

Definition at line 88 of file text.cpp.

88  {
89  auto newText = std::make_shared<Text>(
90  this->_insertion_point.scale(scale_center, scale_factor),
91  this->_text_value,
92  this->_height * std::sqrt(scale_factor.x() * scale_factor.y()), // Does this make sense?
93  this->_angle,
94  this->_style,
95  this->_textgeneration,
96  this->_halign,
97  this->_valign,
98  this->layer(),
99  this->metaInfo());
100  newText->setID(this->id());
101  return newText;
102 }
double x() const
Returns x of Coordinate.
Definition: geocoordinate.h:26
const TextConst::HAlign _halign
Definition: text.h:55
const TextConst::VAlign _valign
Definition: text.h:54
Layer_CSPtr layer() const
layer return the layer this entity is placed on
Definition: cadentity.cpp:29
double y() const
Returns y of Coordinate.
Definition: geocoordinate.h:34
Coordinate scale(const double &scale_factor) const
const std::string _style
Definition: text.h:52
const TextConst::DrawingDirection _textgeneration
Definition: text.h:53
MetaInfo_CSPtr metaInfo() const
Definition: cadentity.h:123
const geo::Coordinate _insertion_point
Definition: text.h:48
const double _angle
Definition: text.h:51
const double _height
Definition: text.h:50
const std::string _text_value
Definition: text.h:49
CADEntity_CSPtr Text::setDragPoints ( std::map< unsigned int, lc::geo::Coordinate dragPoints) const
overridevirtual

Return modified entity.

Parameters
dragPointsModified points
Returns
New entity or same entity if an error occurred Return the new entity which corresponds to the given points. Points must be associated to the same number given in dragPoints().

Implements lc::Draggable.

Definition at line 136 of file text.cpp.

136  {
137  try {
138  auto newEntity = std::make_shared<Text>(dragPoints.at(0), text_value(), height(), angle(), style(), textgeneration(), halign(), valign(), layer(), metaInfo());
139  newEntity->setID(id());
140  return newEntity;
141  }
142  catch(std::out_of_range& e) {
143  return shared_from_this();
144  }
145 }
std::string const & style() const
Definition: text.h:70
double height() const
Definition: text.h:86
Layer_CSPtr layer() const
layer return the layer this entity is placed on
Definition: cadentity.cpp:29
MetaInfo_CSPtr metaInfo() const
Definition: cadentity.h:123
std::string const & text_value() const
Definition: text.h:62
double const angle() const
Definition: text.h:66
virtual std::map< unsigned int, lc::geo::Coordinate > dragPoints() const override
Get all points of the entity that can be dragged.
Definition: text.cpp:128
TextConst::VAlign const & valign() const
Definition: text.h:78
TextConst::HAlign const & halign() const
Definition: text.h:82
TextConst::DrawingDirection const & textgeneration() const
Definition: text.h:74
std::string const& lc::entity::Text::style ( ) const
inline

Definition at line 70 of file text.h.

70  {
71  return _style;
72  }
const std::string _style
Definition: text.h:52
std::string const& lc::entity::Text::text_value ( ) const
inline

Definition at line 62 of file text.h.

62  {
63  return _text_value;
64  }
const std::string _text_value
Definition: text.h:49
TextConst::DrawingDirection const& lc::entity::Text::textgeneration ( ) const
inline

Definition at line 74 of file text.h.

74  {
75  return _textgeneration;
76  }
const TextConst::DrawingDirection _textgeneration
Definition: text.h:53
TextConst::VAlign const& lc::entity::Text::valign ( ) const
inline

Definition at line 78 of file text.h.

78  {
79  return _valign;
80  }
const TextConst::VAlign _valign
Definition: text.h:54

Member Data Documentation

const double lc::entity::Text::_angle

Definition at line 51 of file text.h.

const TextConst::HAlign lc::entity::Text::_halign

Definition at line 55 of file text.h.

const double lc::entity::Text::_height

Definition at line 50 of file text.h.

const geo::Coordinate lc::entity::Text::_insertion_point

Definition at line 48 of file text.h.

const std::string lc::entity::Text::_style

Definition at line 52 of file text.h.

const std::string lc::entity::Text::_text_value

Definition at line 49 of file text.h.

const TextConst::DrawingDirection lc::entity::Text::_textgeneration

Definition at line 53 of file text.h.

const TextConst::VAlign lc::entity::Text::_valign

Definition at line 54 of file text.h.


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