Permalink
Browse files

Create abstract class MetaLineWidth

  • Loading branch information...
feragon committed Jun 16, 2017
1 parent cbe7278 commit 3d348d4b8d99747444461ef2a54a3d13f4092a48
@@ -48,7 +48,7 @@ void DXFimpl::setBlock(const int _blockHandle) {
}
void DXFimpl::addBlock(const DRW_Block& data) {
auto lw = getLcLineWidth<lc::EntityMetaType>(data.lWeight);
auto lw = getLcLineWidth<lc::MetaLineWidth>(data.lWeight);
auto color = icol.intToColor(data.color);
lc::DxfLinePattern_CSPtr lp = nullptr;
@@ -1,7 +1,7 @@
#include "block.h"
lc::Block::Block(std::string name, lc::geo::Coordinate base,
lc::MetaColor_CSPtr color, lc::EntityMetaType_CSPtr lineWidth, lc::DxfLinePattern_CSPtr linePattern) :
lc::MetaColor_CSPtr color, lc::MetaLineWidth_CSPtr lineWidth, lc::DxfLinePattern_CSPtr linePattern) :
_name(name),
_base(base),
_color(color),
@@ -5,14 +5,15 @@
#include <cad/geometry/geocoordinate.h>
#include "metacolor.h"
#include "dxflinepattern.h"
#include "metalinewidth.h"
#define BLOCK_ID_PREFIX "BLOCK"
namespace lc {
class Block : public DocumentMetaType {
public:
Block(std::string name, geo::Coordinate base,
lc::MetaColor_CSPtr color, lc::EntityMetaType_CSPtr lineWidth, lc::DxfLinePattern_CSPtr linePattern);
lc::MetaColor_CSPtr color, lc::MetaLineWidth_CSPtr lineWidth, lc::DxfLinePattern_CSPtr linePattern);
const std::string id() const override;
const std::string name() const override;
@@ -26,7 +27,7 @@ namespace lc {
std::string _name;
geo::Coordinate _base;
lc::MetaColor_CSPtr _color; //TODO: that's should probably be changed to a pointer to lc::Color
lc::EntityMetaType_CSPtr _lineWidth; //TODO: we should have a better type for LineWidth
lc::MetaLineWidth_CSPtr _lineWidth;
lc::DxfLinePattern_CSPtr _linePattern;
};
@@ -3,19 +3,35 @@
using namespace lc;
MetaLineWidthByBlock::MetaLineWidthByBlock() : EntityMetaType() {
const std::string MetaLineWidth::LCMETANAME() {
return "_LINEWIDTH";
}
const std::string MetaLineWidth::id() const {
return LCMETANAME();
}
MetaLineWidthByBlock::MetaLineWidthByBlock() : MetaLineWidth() {
}
const std::string MetaLineWidthByBlock::metaTypeID() const {
return MetaLineWidthByBlock::LCMETANAME();
}
MetaLineWidthByValue::MetaLineWidthByValue() : EntityMetaType(), DocumentMetaType(), _width(0.) {
MetaLineWidthByValue::MetaLineWidthByValue() :
MetaLineWidth(),
DocumentMetaType(),
_width(0.) {
assert(_width >= 0. && "Line width must be >= 0.");
}
MetaLineWidthByValue::MetaLineWidthByValue(const double width): EntityMetaType(), _width(width) {
MetaLineWidthByValue::MetaLineWidthByValue(const double width):
MetaLineWidth(),
DocumentMetaType(),
_width(width) {
assert(_width>=0. && "Line width must be >= 0.");
}
@@ -26,3 +42,7 @@ const std::string MetaLineWidthByValue::metaTypeID() const {
double MetaLineWidthByValue::width() const {
return _width;
}
const std::string MetaLineWidthByValue::name() const {
return LCMETANAME();
}
@@ -8,31 +8,35 @@
#include "cad/const.h"
#include <iostream>
namespace lc {
class MetaLineWidth : public EntityMetaType {
public:
static const std::string LCMETANAME();
virtual const std::string id() const override;
class MetaLineWidthByBlock : public EntityMetaType {
private:
friend std::ostream& operator<<(std::ostream& os, const MetaLineWidth& lineWidth) {
os << "MetaLineWidth()";
return os;
}
};
class MetaLineWidthByBlock : public MetaLineWidth {
public:
MetaLineWidthByBlock();
virtual ~MetaLineWidthByBlock() = default;
virtual const std::string metaTypeID() const override;
virtual const std::string id () const override {
return MetaLineWidthByBlock::LCMETANAME();
}
static const std::string LCMETANAME() {
return "_LINEWIDTH";
}
private:
friend std::ostream& operator<<(std::ostream& os, const MetaLineWidthByBlock& lineWidth) {
os << "MetaLineWidthByBlock()";
return os;
}
};
class MetaLineWidthByValue : public EntityMetaType, public DocumentMetaType {
class MetaLineWidthByValue : public MetaLineWidth, public DocumentMetaType {
public:
MetaLineWidthByValue();
@@ -46,13 +50,8 @@ namespace lc {
return MetaLineWidthByValue::LCMETANAME() + "_" + std::to_string(_width);
}
virtual const std::string name() const override {
return MetaLineWidthByValue::LCMETANAME();
}
const std::string name() const override;
static const std::string LCMETANAME() {
return "_LINEWIDTH";
}
private:
double _width;
@@ -63,10 +62,12 @@ namespace lc {
}
};
using MetaLineWidth_SPtr = std::shared_ptr<MetaLineWidth>;
using MetaLineWidth_CSPtr = std::shared_ptr<const MetaLineWidth>;
using MetaLineWidthByValue_SPtr = std::shared_ptr<MetaLineWidthByValue>;
using MetaLineWidthByValue_CSPtr = std::shared_ptr<const MetaLineWidthByValue>;
using MetaLineWidthByBlock_SPtr = std::shared_ptr<MetaLineWidthByBlock>;
using MetaLineWidthByBlock_CSPtr = std::shared_ptr<const MetaLineWidthByBlock>;
}
// LINEWIDTH_H

0 comments on commit 3d348d4

Please sign in to comment.