LibreCAD
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
dxflinepattern.h
Go to the documentation of this file.
1 //
2 // Created by R. van Twisk on 4/14/16.
3 //
4 
5 #pragma once
6 
8 #include "cad/const.h"
9 #include <cassert>
10 #include <vector>
11 #include <map>
13 
14 namespace lc {
19  public:
20  virtual const std::string metaTypeID() const override {
22  }
23 
24  static std::string LCMETANAME() {
25  return "_LINEPATTERN";
26  }
27 
28  virtual const std::string id() const override {
29  return DxfLinePattern::LCMETANAME() + "_" + name();
30  }
31 
32  virtual std::string description() const;
33  };
34 
37  public:
39  DxfLinePatternByValue(const std::string &_name, const std::string &_description, const std::vector<double> &_path, const double length);
40  virtual ~DxfLinePatternByValue() = default;
41 
45  static double calculatePathLength(const std::vector<double> &_path);
46 
47  const std::string name() const override;
48  std::string description() const override;
49  const std::vector<double>& path() const;
50  double length() const;
51 
60  std::vector<double> generatePattern(const std::vector<double> & dxfPattern, const double length, const double lineWidth) const;
61 
68  const std::vector<double> lcPattern(double lineWidth = 1) const;
69 
70  private:
72 
73  std::string _name;
74  std::string _description;
75  std::vector<double> _path;
76 
77  //Might grow out of proportions if too much line sizes are rendered
78  //We should find a way to remove widths unrendered for x drawing cycles
79  mutable std::map<double, std::vector<double>> _lcPatterns;
80 
81  double _length;
82  };
83 
85  public:
86  virtual const std::string name() const override;
87  };
88 
92 }
static double calculatePathLength(const std::vector< double > &_path)
virtual std::string description() const
DECLARE_SHORT_SHARED_PTR(Document)
const std::vector< double > lcPattern(double lineWidth=1) const
Get cached LibreCAD compatible pattern.
Definition: cadentity.h:12
const std::vector< double > & path() const
const std::string name() const override
virtual const std::string metaTypeID() const override
std::map< double, std::vector< double > > _lcPatterns
std::string description() const override
virtual const std::string name() const override
std::vector< double > _path
static std::string LCMETANAME()
virtual const std::string name() const =0
virtual const std::string id() const override
std::vector< double > generatePattern(const std::vector< double > &dxfPattern, const double length, const double lineWidth) const
Generate new LibreCAD compatible pattern.
virtual ~DxfLinePatternByValue()=default