PointModule.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * author: Patrick-Christopher Mattulat
  3. * dev-tools: JetBrains CLion
  4. * created: 26.08.2018
  5. * last updated: 29.08.2018
  6. */
  7. #include "PointModule.h"
  8. #include "../Module.h"
  9. //////////////////////////////////////////////////
  10. //////////////////////////////////////////////////
  11. //// constructor / destructor
  12. //////////////////////////////////////////////////
  13. //////////////////////////////////////////////////
  14. PointModule::PointModule(uint32_t id):
  15. module(MODULE_POINT)
  16. {
  17. this->id.store(id);
  18. this->zindexInfo = ZindexInfo(this->id.load(), this->module.load(), 1);
  19. }
  20. PointModule::~PointModule() = default;
  21. //////////////////////////////////////////////////
  22. //////////////////////////////////////////////////
  23. //// public
  24. //////////////////////////////////////////////////
  25. //////////////////////////////////////////////////
  26. int PointModule::addDirection(uint32_t idDirection, LynarMath::_Vec2_d direction)
  27. {
  28. std::shared_ptr<Direction> d = std::make_shared<Direction>(idDirection);
  29. d.get()->set(direction);
  30. return this->directionList.addElement(d);
  31. }
  32. int PointModule::changeDirection(uint32_t idDirection, LynarMath::_Vec2_d direction)
  33. {
  34. int result;
  35. std::shared_ptr<Direction> d = this->directionList.getElement(idDirection);
  36. if(d != nullptr) {
  37. d.get()->set(direction);
  38. result = this->directionList.updateElement(idDirection, d);
  39. }
  40. else {
  41. result = LE_ID_NOEXIST;
  42. }
  43. return result;
  44. }
  45. void PointModule::clearDirections()
  46. {
  47. this->directionList.clear();
  48. }
  49. LynarMath::_Point_d PointModule::get()
  50. {
  51. return this->rendererInfo.point;
  52. }
  53. uint32_t PointModule::getAmountOfDirections()
  54. {
  55. return this->directionList.getAmount();
  56. }
  57. _ColorValue_d PointModule::getColor()
  58. {
  59. return this->rendererInfo.colorValue;
  60. }
  61. LynarMath::_Vec2_d PointModule::getDirection(uint32_t idDirection)
  62. {
  63. LynarMath::_Vec2_d direction = {0.0f, 0.0f};
  64. std::shared_ptr<Direction> d = this->directionList.getElement(idDirection);
  65. if(d != nullptr) {
  66. direction = d.get()->get();
  67. }
  68. return direction;
  69. }
  70. uint32_t PointModule::getId()
  71. {
  72. return this->id.load();
  73. }
  74. uint8_t PointModule::getModule()
  75. {
  76. return this->module.load();
  77. }
  78. PointRendererInfo PointModule::getRendererInfo()
  79. {
  80. return this->rendererInfo;
  81. }
  82. ZindexInfo PointModule::getZindex()
  83. {
  84. return this->zindexInfo;
  85. }
  86. bool PointModule::isVisible()
  87. {
  88. return this->rendererInfo.visible;
  89. }
  90. void PointModule::makeVisible(bool visible)
  91. {
  92. this->rendererInfo.visible = visible;
  93. }
  94. int PointModule::removeDirection(uint32_t idDirection)
  95. {
  96. return this->directionList.removeElement(idDirection);
  97. }
  98. void PointModule::set(LynarMath::_Point_d point)
  99. {
  100. this->rendererInfo.point = point;
  101. }
  102. void PointModule::setColor(_ColorValue_d colorValue)
  103. {
  104. this->rendererInfo.colorValue = colorValue;
  105. }
  106. void PointModule::setZindex(uint32_t zindex)
  107. {
  108. this->zindexInfo.zindex = zindex;
  109. }