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

A Image that can be put in a drawing. More...

#include <image.h>

Inheritance diagram for lc::entity::Image:
Collaboration diagram for lc::entity::Image:

Public Member Functions

 Image (const std::string &name, const geo::Coordinate &base, const geo::Coordinate &uv, const geo::Coordinate &vv, double width, double height, double brightness, double contrast, double fade, const Layer_CSPtr layer, const MetaInfo_CSPtr metaInfo=nullptr, const Block_CSPtr block=nullptr)
 
 Image (const Image_CSPtr other, bool sameID=false)
 Construct a new line. More...
 
virtual std::vector
< EntityCoordinate
snapPoints (const geo::Coordinate &coord, const SimpleSnapConstrain &constrain, double minDistanceToSnap, int maxNumberOfSnapPoints) const override
 Find a number of snap points the line has available This function returns a ordered list, closest to coord and can return multiple snap points. More...
 
virtual geo::Coordinate nearestPointOnPath (const geo::Coordinate &coord) const override
 Find the nearest point on the path for this entity for the coordinate coord The path of a entity that it can possibly take. More...
 
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 Image 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...
 
const std::string & name () const
 
const geo::Coordinatebase () const
 
const geo::Coordinateuv () const
 
const geo::Coordinatevv () const
 
double width () const
 
double height () const
 
double brightness () const
 
double contrast () const
 
double fade () const
 
virtual void accept (GeoEntityVisitor &v) const override
 
virtual void dispatch (EntityDispatch &ed) const override
 
- 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
 

Private Attributes

std::string _name
 
geo::Coordinate _base
 
geo::Coordinate _uv
 
geo::Coordinate _vv
 
double _width
 
double _height
 
double _brightness
 Brightness value, code 281, (0-100) default 50. More...
 
double _contrast
 Brightness value, code 282, (0-100) default 50. More...
 
double _fade
 Brightness value, code 283, (0-100) default 0. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from lc::Snapable
static void remove_ifDistanceGreaterThen (std::vector< EntityCoordinate > &points, const geo::Coordinate &reference, const double distance)
 
static void snapPointsCleanup (std::vector< EntityCoordinate > &points, const geo::Coordinate &reference, const unsigned int maxNumberOfSnapPoints, const double minDistanceToSnap)
 
- 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

A Image that can be put in a drawing.

See also
CreateEntities::append
Author
R. van Twisk
Date
2016-04-16

Definition at line 23 of file image.h.

Constructor & Destructor Documentation

Image::Image ( const std::string &  name,
const geo::Coordinate base,
const geo::Coordinate uv,
const geo::Coordinate vv,
double  width,
double  height,
double  brightness,
double  contrast,
double  fade,
const Layer_CSPtr  layer,
const MetaInfo_CSPtr  metaInfo = nullptr,
const Block_CSPtr  block = nullptr 
)

Definition at line 11 of file image.cpp.

22  :
24  _name(name),
25  _base(base),
26  _uv(uv),
27  _vv(vv),
28  _width(width),
29  _height(height),
32  _fade(fade) {
33 
34 }
double _height
Definition: image.h:151
double fade() const
Definition: image.h:134
geo::Coordinate _uv
Definition: image.h:148
double _fade
Brightness value, code 283, (0-100) default 0.
Definition: image.h:155
Layer_CSPtr layer() const
layer return the layer this entity is placed on
Definition: cadentity.cpp:29
double width() const
Definition: image.h:118
MetaInfo_CSPtr metaInfo() const
Definition: cadentity.h:123
double contrast() const
Definition: image.h:130
geo::Coordinate _vv
Definition: image.h:149
double height() const
Definition: image.h:122
std::string _name
Definition: image.h:146
Block_CSPtr block() const
Return the current entity block.
Definition: cadentity.cpp:33
double _brightness
Brightness value, code 281, (0-100) default 50.
Definition: image.h:153
geo::Coordinate _base
Definition: image.h:147
double _width
Definition: image.h:150
double _contrast
Brightness value, code 282, (0-100) default 50.
Definition: image.h:154
const std::string & name() const
Definition: image.h:101
double brightness() const
Definition: image.h:126
Image::Image ( const Image_CSPtr  other,
bool  sameID = false 
)

Construct a new line.

Parameters
vectorCoordinate the line should start and end from
metaTypesA list of metatypes associated with this line
See also
Color
LineWidth
MetaType

Definition at line 36 of file image.cpp.

36  :
37  CADEntity(other, sameID), _name(other->_name), _base(other->_base), _uv(other->_uv), _vv(other->_vv), _width(other->_width), _height(other->_height),
38  _brightness(other->_brightness), _contrast(other->_contrast), _fade(other->_fade) {
39 }
double _height
Definition: image.h:151
geo::Coordinate _uv
Definition: image.h:148
double _fade
Brightness value, code 283, (0-100) default 0.
Definition: image.h:155
geo::Coordinate _vv
Definition: image.h:149
std::string _name
Definition: image.h:146
double _brightness
Brightness value, code 281, (0-100) default 50.
Definition: image.h:153
geo::Coordinate _base
Definition: image.h:147
double _width
Definition: image.h:150
double _contrast
Brightness value, code 282, (0-100) default 50.
Definition: image.h:154

Member Function Documentation

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

Reimplemented from lc::entity::CADEntity.

Definition at line 139 of file image.h.

139 { v.visit(*this); }
const geo::Coordinate& lc::entity::Image::base ( ) const
inline

Definition at line 105 of file image.h.

105  {
106  return _base;
107  }
geo::Coordinate _base
Definition: image.h:147
const geo::Area Image::boundingBox ( ) const
overridevirtual

boundingBox of the entity

Returns
geo::Area area

Implements lc::entity::CADEntity.

Definition at line 112 of file image.cpp.

112  {
113  std::vector<geo::Coordinate> c;
114 // c.emplace_back(_base);
115 // c.emplace_back(_base.x(), _base.y() + _height);
116 // c.emplace_back(_base.x()+_width, _base.y() + _height);
117 // c.emplace_back(_base.x()+_width, _base.y());
118 
119  // Create 4 corners
120  c.emplace_back(0.,0.);
121  c.emplace_back(0., _height);
122  c.emplace_back(_width, _height);
123  c.emplace_back(_width, 0.);
124 
125  // Apply Transform
126  std::vector<geo::Coordinate> c2 = HelperMethods::transform2d<geo::Coordinate>(c, _uv.x(), _uv.y(), _vv.x(), _vv.y(), _base.x(), _base.y());
127 
128  // get bounding box
129  geo::Area area = geo::Area(c2.at(0), 0.,0.);
130  std::for_each(c2.begin(), c2.end(), [&](geo::Coordinate c) {area = area.merge(c);});
131 
132  return area;
133 }
double _height
Definition: image.h:151
double x() const
Returns x of Coordinate.
Definition: geocoordinate.h:26
geo::Coordinate _uv
Definition: image.h:148
double y() const
Returns y of Coordinate.
Definition: geocoordinate.h:34
geo::Coordinate _vv
Definition: image.h:149
geo::Coordinate _base
Definition: image.h:147
double _width
Definition: image.h:150
double lc::entity::Image::brightness ( ) const
inline

Definition at line 126 of file image.h.

126  {
127  return _brightness;
128  }
double _brightness
Brightness value, code 281, (0-100) default 50.
Definition: image.h:153
double lc::entity::Image::contrast ( ) const
inline

Definition at line 130 of file image.h.

130  {
131  return _contrast;
132  }
double _contrast
Brightness value, code 282, (0-100) default 50.
Definition: image.h:154
CADEntity_CSPtr Image::copy ( const geo::Coordinate offset) const
overridevirtual

copy, copies Image by an offset

Parameters
geo::Coordinateoffset
Returns
CADEntity_CSPtr copied entity

Implements lc::entity::CADEntity.

Definition at line 93 of file image.cpp.

93  {
94  auto newImage = std::make_shared<Image>(_name, _base + offset, _uv, _vv, _width, _height, _brightness, _contrast, _fade, layer(), metaInfo());
95  return newImage;
96 }
double _height
Definition: image.h:151
geo::Coordinate _uv
Definition: image.h:148
double _fade
Brightness value, code 283, (0-100) default 0.
Definition: image.h:155
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
geo::Coordinate _vv
Definition: image.h:149
std::string _name
Definition: image.h:146
double _brightness
Brightness value, code 281, (0-100) default 50.
Definition: image.h:153
geo::Coordinate _base
Definition: image.h:147
double _width
Definition: image.h:150
double _contrast
Brightness value, code 282, (0-100) default 50.
Definition: image.h:154
virtual void lc::entity::Image::dispatch ( EntityDispatch ed) const
inlineoverridevirtual

Implements lc::entity::CADEntity.

Definition at line 141 of file image.h.

141  {
142  ed.visit(shared_from_this());
143  }
double lc::entity::Image::fade ( ) const
inline

Definition at line 134 of file image.h.

134  {
135  return _fade;
136  }
double _fade
Brightness value, code 283, (0-100) default 0.
Definition: image.h:155
double lc::entity::Image::height ( ) const
inline

Definition at line 122 of file image.h.

122  {
123  return _height;
124  }
double _height
Definition: image.h:151
virtual CADEntity_CSPtr lc::entity::Image::mirror ( const geo::Coordinate axis1,
const geo::Coordinate axis2 
) const
inlineoverridevirtual

Implements lc::entity::CADEntity.

Definition at line 88 of file image.h.

89  {
90  return NULL; // TODO: no return statement, not implemented in lwpolyline.cpp
91  }
CADEntity_CSPtr Image::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 135 of file image.cpp.

135  {
136  auto newImage = std::make_shared<Image>(
137  _name,
138  _base,
139  _uv,
140  _vv,
141  _width,
142  _height,
143  _brightness,
144  _contrast,
145  _fade,
146  layer,
147  metaInfo,
148  block
149  );
150  return newImage;
151 }
double _height
Definition: image.h:151
geo::Coordinate _uv
Definition: image.h:148
double _fade
Brightness value, code 283, (0-100) default 0.
Definition: image.h:155
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
geo::Coordinate _vv
Definition: image.h:149
std::string _name
Definition: image.h:146
Block_CSPtr block() const
Return the current entity block.
Definition: cadentity.cpp:33
double _brightness
Brightness value, code 281, (0-100) default 50.
Definition: image.h:153
geo::Coordinate _base
Definition: image.h:147
double _width
Definition: image.h:150
double _contrast
Brightness value, code 282, (0-100) default 50.
Definition: image.h:154
CADEntity_CSPtr Image::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 87 of file image.cpp.

87  {
88  auto newImage = std::make_shared<Image>(_name, _base + offset, _uv, _vv, _width, _height, _brightness, _contrast, _fade, layer(), metaInfo());
89  newImage->setID(this->id());
90  return newImage;
91 }
double _height
Definition: image.h:151
geo::Coordinate _uv
Definition: image.h:148
double _fade
Brightness value, code 283, (0-100) default 0.
Definition: image.h:155
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
geo::Coordinate _vv
Definition: image.h:149
std::string _name
Definition: image.h:146
double _brightness
Brightness value, code 281, (0-100) default 50.
Definition: image.h:153
geo::Coordinate _base
Definition: image.h:147
double _width
Definition: image.h:150
double _contrast
Brightness value, code 282, (0-100) default 50.
Definition: image.h:154
const std::string& lc::entity::Image::name ( ) const
inline

Definition at line 101 of file image.h.

101  {
102  return _name;
103  }
std::string _name
Definition: image.h:146
geo::Coordinate Image::nearestPointOnPath ( const geo::Coordinate coord) const
overridevirtual

Find the nearest point on the path for this entity for the coordinate coord The path of a entity that it can possibly take.

For example for any Arc the path is the full circle if the start/stop angle is 0 to 2*pi

Parameters
coordCoordinate to lookup the nearest coordinate from
See also
lc::entity::CADEntity

Implements lc::Snapable.

Definition at line 70 of file image.cpp.

70  {
71  std::vector<geo::Coordinate> points;
72 /*
73  auto v1 = geo::Vector(_bottomLeft, geo::Coordinate(_bottomLeft.x(), _topRight.y()));
74  auto v2 = geo::Vector(_bottomLeft, geo::Coordinate(_topRight.x(), _bottomLeft.y()));
75  auto v3 = geo::Vector(_topRight, geo::Coordinate(_topRight.x(), _bottomLeft.y()));
76  auto v4 = geo::Vector(_topRight, geo::Coordinate(_bottomLeft.x(), _topRight.y()));
77 
78  points.push_back(v1.nearestPointOnEntity(coord));
79  points.push_back(v2.nearestPointOnEntity(coord));
80  points.push_back(v3.nearestPointOnEntity(coord));
81  points.push_back(v4.nearestPointOnEntity(coord));
82  std::sort(points.begin(), points.end(), geo::CoordinateDistanceSort(coord));
83 */
84  return geo::Coordinate();
85 }
CADEntity_CSPtr Image::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 98 of file image.cpp.

98  {
99  // auto newImage = std::make_shared<Image>(_bottomLeft.rotate(rotation_center, rotation_angle),
100  // _topRight.rotate(rotation_center, rotation_angle), layer());
101  // newImage->setID(this->id());
102  return nullptr;
103 }
CADEntity_CSPtr Image::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 105 of file image.cpp.

105  {
106  // auto newImage = std::make_shared<Image>(_bottomLeft.scale(scale_center, scale_factor),
107  // _topRight.scale(scale_center, scale_factor), layer());
108  //newImage->setID(this->id());
109  return nullptr;
110 }
std::vector< EntityCoordinate > Image::snapPoints ( const geo::Coordinate coord,
const SimpleSnapConstrain simpleSnapConstrain,
double  minDistanceToSnap,
int  maxNumberOfSnapPoints 
) const
overridevirtual

Find a number of snap points the line has available This function returns a ordered list, closest to coord and can return multiple snap points.

Parameters
coordCoordinate to lookup the nearest coordinate from
minDistanceToSnapMinimum distance to the path to snap into. THis is a hint parameter and we should follow this, but it will be later filtered again
maxNumberOfSnapPointsMaximum number of snappoints that have to be looked up
See also
lc::EntityCoordinate

Implements lc::Snapable.

Definition at line 42 of file image.cpp.

42  {
43  std::vector<EntityCoordinate> points;
44 
45  if (constrain.constrain() & SimpleSnapConstrain::LOGICAL) {
46  // points.emplace_back(_bottomLeft, 0);
47  // points.emplace_back(_topRight, 1);
48  }
49 
50 
51  const geo::Coordinate npoe = nearestPointOnPath(coord);
52  if (constrain.constrain() & SimpleSnapConstrain::ON_ENTITYPATH) {
53  points.emplace_back(npoe, 2);
54  }
55 
56  /*
57  if (constrain.constrain() & SimpleSnapConstrain::ON_ENTITY) {
58  if (this->nearestPointOnEntity(coord).distanceTo(coord)<minDistanceToSnap) {
59  points.emplace_back(npoe, 3);
60  }
61  }
62  */
63 
64  // Cleanup array of snappoints
65  Snapable::snapPointsCleanup(points, coord, maxNumberOfSnapPoints, minDistanceToSnap);
66 
67  return points;
68 }
static const uint16_t LOGICAL
Definition: snapconstrain.h:22
static const uint16_t ON_ENTITYPATH
Definition: snapconstrain.h:19
static void snapPointsCleanup(std::vector< EntityCoordinate > &points, const geo::Coordinate &reference, const unsigned int maxNumberOfSnapPoints, const double minDistanceToSnap)
Definition: snapable.h:53
virtual geo::Coordinate nearestPointOnPath(const geo::Coordinate &coord) const override
Find the nearest point on the path for this entity for the coordinate coord The path of a entity that...
Definition: image.cpp:70
const geo::Coordinate& lc::entity::Image::uv ( ) const
inline

Definition at line 109 of file image.h.

109  {
110  return _uv;
111  }
geo::Coordinate _uv
Definition: image.h:148
const geo::Coordinate& lc::entity::Image::vv ( ) const
inline

Definition at line 113 of file image.h.

113  {
114  return _vv;
115  }
geo::Coordinate _vv
Definition: image.h:149
double lc::entity::Image::width ( ) const
inline

Definition at line 118 of file image.h.

118  {
119  return _width;
120  }
double _width
Definition: image.h:150

Member Data Documentation

geo::Coordinate lc::entity::Image::_base
private

Definition at line 147 of file image.h.

double lc::entity::Image::_brightness
private

Brightness value, code 281, (0-100) default 50.

Definition at line 153 of file image.h.

double lc::entity::Image::_contrast
private

Brightness value, code 282, (0-100) default 50.

Definition at line 154 of file image.h.

double lc::entity::Image::_fade
private

Brightness value, code 283, (0-100) default 0.

Definition at line 155 of file image.h.

double lc::entity::Image::_height
private

Definition at line 151 of file image.h.

std::string lc::entity::Image::_name
private

Definition at line 146 of file image.h.

geo::Coordinate lc::entity::Image::_uv
private

Definition at line 148 of file image.h.

geo::Coordinate lc::entity::Image::_vv
private

Definition at line 149 of file image.h.

double lc::entity::Image::_width
private

Definition at line 150 of file image.h.


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