ModelLayer.cpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817
  1. /*
  2. * author: Patrick-Christopher Mattulat
  3. * dev-tools: JetBrains CLion
  4. * created: 29.08.2018
  5. * last updated: 19.10.2018
  6. */
  7. #include "../LynarMoon.h"
  8. #include "../Module/Module.h"
  9. #include <map>
  10. //////////////////////////////////////////////////
  11. //////////////////////////////////////////////////
  12. //// constructor / destructor
  13. //////////////////////////////////////////////////
  14. //////////////////////////////////////////////////
  15. LynarMoon::ModelLayer::ModelLayer(LynarMoon* lm, const std::string& objectName, std::shared_ptr<ErrorHandler>& errorHandler)
  16. {
  17. this->errorHandler = errorHandler;
  18. this->objectName = objectName;
  19. this->parent = lm;
  20. this->ModelList = std::make_shared<SmartList<ModelModule>>(this->errorHandler, objectName);
  21. this->parent->modelModuleList = this->ModelList;
  22. }
  23. LynarMoon::ModelLayer::~ModelLayer() = default;
  24. //////////////////////////////////////////////////
  25. //////////////////////////////////////////////////
  26. //// public
  27. //////////////////////////////////////////////////
  28. //////////////////////////////////////////////////
  29. int LynarMoon::ModelLayer::addClone(uint32_t id, uint32_t idClone)
  30. {
  31. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  32. std::string functionName = "ModelLayer::addClone()";
  33. int result;
  34. if(model != nullptr) {
  35. result = model.get()->addClone(idClone);
  36. if(result) {
  37. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(idClone));
  38. }
  39. }
  40. else {
  41. result = LE_ID_NOEXIST;
  42. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  43. }
  44. return result;
  45. }
  46. int LynarMoon::ModelLayer::addDirection(uint32_t id, uint32_t idDirection, LynarMath::_Vec2_d direction)
  47. {
  48. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  49. std::string functionName = "ModelLayer::addDirection()";
  50. int result;
  51. if(model != nullptr) {
  52. result = model.get()->addDirection(idDirection, direction);
  53. if(result) {
  54. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(idDirection));
  55. }
  56. }
  57. else {
  58. result = LE_ID_NOEXIST;
  59. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  60. }
  61. return result;
  62. }
  63. int LynarMoon::ModelLayer::addTexture(uint32_t id, uint32_t idTexture, const std::string& file)
  64. {
  65. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  66. std::string functionName = "ModelLayer::addTexture()";
  67. int result;
  68. if(model != nullptr) {
  69. result = model.get()->addTexture(idTexture, file);
  70. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  71. }
  72. else {
  73. result = LE_ID_NOEXIST;
  74. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  75. }
  76. return result;
  77. }
  78. int LynarMoon::ModelLayer::addTexture(uint32_t id, uint32_t idTexture, SDL_Surface* surface)
  79. {
  80. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  81. std::string functionName = "ModelLayer::addTexture()";
  82. int result;
  83. if(model != nullptr) {
  84. result = model.get()->addTexture(idTexture, surface);
  85. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  86. }
  87. else {
  88. result = LE_ID_NOEXIST;
  89. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  90. }
  91. return result;
  92. }
  93. int LynarMoon::ModelLayer::addTexturePartialArea(uint32_t id, uint32_t idTexture, uint32_t idArea, LynarMath::_Rectangle_d area)
  94. {
  95. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  96. std::string functionName = "ModelLayer::addTexturePartialArea()";
  97. int result;
  98. if(model != nullptr) {
  99. result = model.get()->addTexturePartialArea(idTexture, idArea, area);
  100. }
  101. else {
  102. result = LE_ID_NOEXIST;
  103. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  104. }
  105. return result;
  106. }
  107. int LynarMoon::ModelLayer::changeDirection(uint32_t id, uint32_t idDirection, LynarMath::_Vec2_d direction)
  108. {
  109. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  110. std::string functionName = "ModelLayer::changeDirection()";
  111. int result;
  112. if(model != nullptr) {
  113. result = model.get()->changeDirection(idDirection, direction);
  114. if(result) {
  115. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(idDirection));
  116. }
  117. }
  118. else {
  119. result = LE_ID_NOEXIST;
  120. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  121. }
  122. return result;
  123. }
  124. int LynarMoon::ModelLayer::changeTexturePartialArea(uint32_t id, uint32_t idTexture, uint32_t idArea, LynarMath::_Rectangle_d area)
  125. {
  126. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  127. std::string functionName = "ModelLayer::changeTexturePartialArea()";
  128. int result;
  129. if(model != nullptr) {
  130. result = model.get()->changeTexturePartialArea(idTexture, idArea, area);
  131. }
  132. else {
  133. result = LE_ID_NOEXIST;
  134. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  135. }
  136. return result;
  137. }
  138. void LynarMoon::ModelLayer::clear()
  139. {
  140. this->ModelList.get()->clear();
  141. }
  142. int LynarMoon::ModelLayer::clearDirections(uint32_t id)
  143. {
  144. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  145. std::string functionName = "ModelLayer::clearDirections()";
  146. int result = LE_NO_ERROR;
  147. if(model != nullptr) {
  148. model.get()->clearDirections();
  149. }
  150. else {
  151. result = LE_ID_NOEXIST;
  152. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  153. }
  154. return result;
  155. }
  156. int LynarMoon::ModelLayer::clearTextures(uint32_t id)
  157. {
  158. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  159. std::string functionName = "ModelLayer::clearTextures()";
  160. int result = LE_NO_ERROR;
  161. if(model != nullptr) {
  162. model.get()->clearTextures();
  163. }
  164. else {
  165. result = LE_ID_NOEXIST;
  166. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  167. }
  168. return result;
  169. }
  170. int LynarMoon::ModelLayer::colorOperation(uint32_t id, uint32_t idTexture, _ColorValue_d colorValue, uint8_t operation)
  171. {
  172. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  173. std::string functionName = "ModelLayer::colorOperation()";
  174. int result;
  175. if(model != nullptr) {
  176. result = model.get()->colorOperation(idTexture, colorValue, operation);
  177. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  178. }
  179. else {
  180. result = LE_ID_NOEXIST;
  181. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  182. }
  183. return result;
  184. }
  185. int LynarMoon::ModelLayer::create(uint32_t id)
  186. {
  187. std::shared_ptr<ModelModule> model = std::make_shared<ModelModule>(id, parent->renderer);
  188. int result = this->ModelList.get()->addElement(model);
  189. ZindexInfo zindexInfo;
  190. std::string functionName = "ModelLayer::create()";
  191. if(!result) {
  192. zindexInfo = model->getZindex();
  193. this->parent->zindexHandler.add(zindexInfo);
  194. }
  195. if(result) {
  196. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  197. }
  198. return result;
  199. }
  200. int LynarMoon::ModelLayer::focusTexturePartialArea(uint32_t id, uint32_t idTexture, uint32_t idArea)
  201. {
  202. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  203. std::string functionName = "ModelLayer::focusTexturePartialArea()";
  204. int result;
  205. if(model != nullptr) {
  206. result = model.get()->focusTexturePartialArea(idTexture, idArea);
  207. }
  208. else {
  209. result = LE_ID_NOEXIST;
  210. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  211. }
  212. return result;
  213. }
  214. uint32_t LynarMoon::ModelLayer::getAmount()
  215. {
  216. return this->ModelList.get()->getAmount();
  217. }
  218. uint32_t LynarMoon::ModelLayer::getAmountOfClones(uint32_t id)
  219. {
  220. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  221. std::string functionName = "ModelLayer::getAmountOfClones()";
  222. uint32_t amount = 0;
  223. if(model != nullptr) {
  224. amount = model.get()->getAmountOfClones();
  225. }
  226. else {
  227. this->errorHandler->output(LE_ID_NOEXIST, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  228. }
  229. return amount;
  230. }
  231. uint32_t LynarMoon::ModelLayer::getAmountOfDirections(uint32_t id)
  232. {
  233. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  234. std::string functionName = "ModelLayer::getAmountOfDirections()";
  235. uint32_t amount = 0;
  236. if(model != nullptr) {
  237. amount = model.get()->getAmountOfDirections();
  238. }
  239. else {
  240. this->errorHandler->output(LE_ID_NOEXIST, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  241. }
  242. return amount;
  243. }
  244. uint32_t LynarMoon::ModelLayer::getAmountOfTexturePartialAreas(uint32_t id, uint32_t idTexture)
  245. {
  246. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  247. std::string functionName = "ModelLayer::getAmountOfTexturePartialAreas()";
  248. uint32_t amount = 0;
  249. if(model != nullptr) {
  250. amount = model.get()->getAmountOfTexturePartialAreas(idTexture);
  251. }
  252. else {
  253. this->errorHandler->output(LE_ID_NOEXIST, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  254. }
  255. return amount;
  256. }
  257. uint32_t LynarMoon::ModelLayer::getAmountOfTextures(uint32_t id)
  258. {
  259. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  260. std::string functionName = "ModelLayer::getAmountOfTextures()";
  261. uint32_t amount = 0;
  262. if(model != nullptr) {
  263. amount = model.get()->getAmountOfTextures();
  264. }
  265. else {
  266. this->errorHandler->output(LE_ID_NOEXIST, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  267. }
  268. return amount;
  269. }
  270. double LynarMoon::ModelLayer::getAngle(uint32_t id)
  271. {
  272. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  273. std::string functionName = "ModelLayer::getAngle()";
  274. double angle = 0.0f;
  275. if(model != nullptr) {
  276. angle = model.get()->getAngle();
  277. }
  278. else {
  279. this->errorHandler->output(LE_ID_NOEXIST, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  280. }
  281. return angle;
  282. }
  283. ModelCloneRendererInfo LynarMoon::ModelLayer::getCloneRendererInfo(uint32_t id, uint32_t idClone)
  284. {
  285. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  286. std::string functionName = "ModelLayer::getCloneRendererInfo()";
  287. ModelCloneRendererInfo info;
  288. if(model != nullptr) {
  289. info = model.get()->getCloneRendererInfo(idClone);
  290. }
  291. else {
  292. this->errorHandler->output(LE_ID_NOEXIST, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  293. }
  294. return info;
  295. }
  296. LynarMath::_Vec2_d LynarMoon::ModelLayer::getDirection(uint32_t id, uint32_t idDirection)
  297. {
  298. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  299. std::string functionName = "ModelLayer::getDirection()";
  300. LynarMath::_Vec2_d direction = {0.0f, 0.0f};
  301. if(model != nullptr) {
  302. direction = model.get()->getDirection(idDirection);
  303. }
  304. else {
  305. this->errorHandler->output(LE_ID_NOEXIST, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  306. }
  307. return direction;
  308. }
  309. LynarMath::_Point_d LynarMoon::ModelLayer::getPosition(uint32_t id)
  310. {
  311. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  312. std::string functionName = "ModelLayer::getPosition()";
  313. LynarMath::_Point_d position = {0.0f, 0.0f};
  314. if(model != nullptr) {
  315. position = model.get()->getPosition();
  316. }
  317. else {
  318. this->errorHandler->output(LE_ID_NOEXIST, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  319. }
  320. return position;
  321. }
  322. LynarMath::_Point_d LynarMoon::ModelLayer::getSize(uint32_t id)
  323. {
  324. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  325. std::string functionName = "ModelLayer::getSize()";
  326. LynarMath::_Point_d size = {0.0f, 0.0f};
  327. if(model != nullptr) {
  328. size = model.get()->getSize();
  329. }
  330. else {
  331. this->errorHandler->output(LE_ID_NOEXIST, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  332. }
  333. return size;
  334. }
  335. double LynarMoon::ModelLayer::getSizeFactor(uint32_t id)
  336. {
  337. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  338. std::string functionName = "ModelLayer::getSizeFactor()";
  339. double sizeFactor = 0.0f;
  340. if(model != nullptr) {
  341. sizeFactor = model.get()->getSizeFactor();
  342. }
  343. else {
  344. this->errorHandler->output(LE_ID_NOEXIST, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  345. }
  346. return sizeFactor;
  347. }
  348. LynarMath::_Rectangle_d LynarMoon::ModelLayer::getTexturePartialArea(uint32_t id, uint32_t idTexture, uint32_t idArea)
  349. {
  350. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  351. std::string functionName = "ModelLayer::getTexturePartialArea()";
  352. LynarMath::_Rectangle_d area = {0.0f, 0.0f, 0.0f, 0.0f};
  353. if(model != nullptr) {
  354. area = model.get()->getTexturePartialArea(idTexture, idArea);
  355. }
  356. else {
  357. this->errorHandler->output(LE_ID_NOEXIST, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  358. }
  359. return area;
  360. }
  361. LynarMath::_Point_d LynarMoon::ModelLayer::getTexturePosition(uint32_t id, uint32_t idTexture)
  362. {
  363. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  364. std::string functionName = "ModelLayer::getTexturePosition()";
  365. LynarMath::_Point_d position = {0, 0};
  366. if(model != nullptr) {
  367. position = model.get()->getTexturePosition(idTexture);
  368. }
  369. else {
  370. this->errorHandler->output(LE_ID_NOEXIST, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  371. }
  372. return position;
  373. }
  374. uint32_t LynarMoon::ModelLayer::getTextureZindex(uint32_t id, uint32_t idTexture)
  375. {
  376. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  377. std::string functionName = "ModelLayer::getTextureZindex()";
  378. uint32_t zindex = 0;
  379. if(model != nullptr) {
  380. zindex = model.get()->getTextureZindex(idTexture);
  381. }
  382. else {
  383. this->errorHandler->output(LE_ID_NOEXIST, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  384. }
  385. return zindex;
  386. }
  387. uint32_t LynarMoon::ModelLayer::getZindex(uint32_t id)
  388. {
  389. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  390. std::string functionName = "ModelLayer::getZindex()";
  391. ZindexInfo zindexInfo(id, MODULE_NOT_SELECTED, 1);
  392. if(model != nullptr) {
  393. zindexInfo = model.get()->getZindex();
  394. }
  395. else {
  396. this->errorHandler->output(LE_ID_NOEXIST, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  397. }
  398. return zindexInfo.zindex;
  399. }
  400. bool LynarMoon::ModelLayer::isTextureVisible(uint32_t id, uint32_t idTexture)
  401. {
  402. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  403. std::string functionName = "ModelLayer::isTextureVisible()";
  404. bool visible = false;
  405. if(model != nullptr) {
  406. visible = model.get()->isTextureVisible(idTexture);
  407. }
  408. else {
  409. this->errorHandler->output(LE_ID_NOEXIST, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  410. }
  411. return visible;
  412. }
  413. bool LynarMoon::ModelLayer::isVisible(uint32_t id)
  414. {
  415. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  416. std::string functionName = "ModelLayer::isVisible()";
  417. bool visible = false;
  418. if(model != nullptr) {
  419. visible = model.get()->isVisible();
  420. }
  421. else {
  422. this->errorHandler->output(LE_ID_NOEXIST, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  423. }
  424. return visible;
  425. }
  426. int LynarMoon::ModelLayer::makeTextureVisible(uint32_t id, uint32_t idTexture, bool visible)
  427. {
  428. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  429. std::string functionName = "ModelLayer::makeTextureVisible()";
  430. int result = LE_NO_ERROR;
  431. if(model != nullptr) {
  432. model.get()->makeTextureVisible(idTexture, visible);
  433. }
  434. else {
  435. result = LE_ID_NOEXIST;
  436. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  437. }
  438. return result;
  439. }
  440. int LynarMoon::ModelLayer::makeVisible(uint32_t id, bool visible)
  441. {
  442. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  443. std::string functionName = "ModelLayer::makeVisible()";
  444. int result = LE_NO_ERROR;
  445. if(model != nullptr) {
  446. model.get()->makeVisible(visible);
  447. }
  448. else {
  449. result = LE_ID_NOEXIST;
  450. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  451. }
  452. return result;
  453. }
  454. int LynarMoon::ModelLayer::moveInDirection(uint32_t id, uint32_t idDirection)
  455. {
  456. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  457. std::string functionName = "ModelLayer::moveInDirection()";
  458. int result;
  459. if(model != nullptr) {
  460. result = model.get()->moveInDirection(idDirection, this->parent->getTimestep());
  461. if(result) {
  462. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(idDirection));
  463. }
  464. }
  465. else {
  466. result = LE_ID_NOEXIST;
  467. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  468. }
  469. return result;
  470. }
  471. int LynarMoon::ModelLayer::remove(uint32_t id)
  472. {
  473. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  474. uint8_t module = MODULE_NOT_SELECTED;
  475. if(model != nullptr) {
  476. module = model->getModule();
  477. }
  478. int result = this->ModelList.get()->removeElement(id);
  479. std::string functionName = "ModelLayer::remove()";
  480. if(result) {
  481. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  482. }
  483. else {
  484. this->parent->zindexHandler.remove(id, module);
  485. }
  486. return result;
  487. }
  488. int LynarMoon::ModelLayer::removeClone(uint32_t id, uint32_t idClone)
  489. {
  490. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  491. std::string functionName = "ModelLayer::removeClone()";
  492. int result;
  493. if(model != nullptr) {
  494. result = model.get()->removeClone(idClone);
  495. if(result) {
  496. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(idClone));
  497. }
  498. }
  499. else {
  500. result = LE_ID_NOEXIST;
  501. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  502. }
  503. return result;
  504. }
  505. int LynarMoon::ModelLayer::removeDirection(uint32_t id, uint32_t idDirection)
  506. {
  507. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  508. std::string functionName = "ModelLayer::removeDirection()";
  509. int result;
  510. if(model != nullptr) {
  511. result = model.get()->removeDirection(idDirection);
  512. if(result) {
  513. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(idDirection));
  514. }
  515. }
  516. else {
  517. result = LE_ID_NOEXIST;
  518. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  519. }
  520. return result;
  521. }
  522. int LynarMoon::ModelLayer::removeTexture(uint32_t id, uint32_t idTexture)
  523. {
  524. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  525. std::string functionName = "ModelLayer::removeTexture()";
  526. int result;
  527. if(model != nullptr) {
  528. result = model.get()->removeTexture(idTexture);
  529. if(result) {
  530. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(idTexture));
  531. }
  532. }
  533. else {
  534. result = LE_ID_NOEXIST;
  535. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  536. }
  537. return result;
  538. }
  539. int LynarMoon::ModelLayer::removeTexturePartialArea(uint32_t id, uint32_t idTexture, uint32_t idArea)
  540. {
  541. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  542. std::string functionName = "ModelLayer::removeTexturePartialArea()";
  543. int result;
  544. if(model != nullptr) {
  545. result = model.get()->removeTexturePartialArea(idTexture, idArea);
  546. }
  547. else {
  548. result = LE_ID_NOEXIST;
  549. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  550. }
  551. return result;
  552. }
  553. int LynarMoon::ModelLayer::setAngle(uint32_t id, double angle)
  554. {
  555. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  556. std::string functionName = "ModelLayer::setAngle()";
  557. int result = LE_NO_ERROR;
  558. if(model != nullptr) {
  559. model.get()->setAngle(angle);
  560. }
  561. else {
  562. result = LE_ID_NOEXIST;
  563. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  564. }
  565. return result;
  566. }
  567. int LynarMoon::ModelLayer::setCloneRendererInfo(uint32_t id, uint32_t idClone, ModelCloneRendererInfo info)
  568. {
  569. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  570. std::string functionName = "ModelLayer::setCloneRendererInfo()";
  571. int result;
  572. if(model != nullptr) {
  573. result = model.get()->setCloneRendererInfo(idClone, info);
  574. }
  575. else {
  576. result = LE_ID_NOEXIST;
  577. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  578. }
  579. return result;
  580. }
  581. int LynarMoon::ModelLayer::setPosition(uint32_t id, LynarMath::_Point_d position)
  582. {
  583. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  584. std::string functionName = "ModelLayer::setPosition()";
  585. int result = LE_NO_ERROR;
  586. if(model != nullptr) {
  587. model.get()->setPosition(position);
  588. }
  589. else {
  590. result = LE_ID_NOEXIST;
  591. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  592. }
  593. return result;
  594. }
  595. int LynarMoon::ModelLayer::setSize(uint32_t id, LynarMath::_Point_d size)
  596. {
  597. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  598. std::string functionName = "ModelLayer::setSize()";
  599. int result = LE_NO_ERROR;
  600. if(model != nullptr) {
  601. model.get()->setSize(size);
  602. }
  603. else {
  604. result = LE_ID_NOEXIST;
  605. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  606. }
  607. return result;
  608. }
  609. int LynarMoon::ModelLayer::setSizeFactor(uint32_t id, double sizeFactor)
  610. {
  611. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  612. std::string functionName = "ModelLayer::setSizeFactor()";
  613. int result = LE_NO_ERROR;
  614. if(model != nullptr) {
  615. model.get()->setSizeFactor(sizeFactor);
  616. }
  617. else {
  618. result = LE_ID_NOEXIST;
  619. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  620. }
  621. return result;
  622. }
  623. int LynarMoon::ModelLayer::setTexturePosition(uint32_t id, uint32_t idTexture, LynarMath::_Point_d position)
  624. {
  625. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  626. std::string functionName = "ModelLayer::setTexturePosition()";
  627. int result;
  628. if(model != nullptr) {
  629. result = model.get()->setTexturePosition(idTexture, position);
  630. }
  631. else {
  632. result = LE_ID_NOEXIST;
  633. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  634. }
  635. return result;
  636. }
  637. int LynarMoon::ModelLayer::setTextureZindex(uint32_t id, uint32_t idTexture, uint32_t zindex)
  638. {
  639. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  640. std::string functionName = "ModelLayer::setTextureZindex()";
  641. int result;
  642. if(model != nullptr) {
  643. result = model.get()->setTextureZindex(idTexture, zindex);
  644. }
  645. else {
  646. result = LE_ID_NOEXIST;
  647. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  648. }
  649. return result;
  650. }
  651. int LynarMoon::ModelLayer::setZindex(uint32_t id, uint32_t zindex)
  652. {
  653. std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
  654. std::string functionName = "ModelLayer::setZindex()";
  655. ZindexInfo zindexInfo(id, MODULE_NOT_SELECTED, 1);
  656. int result = LE_NO_ERROR;
  657. if(model != nullptr) {
  658. model.get()->setZindex(zindex);
  659. zindexInfo.zindex = zindex;
  660. zindexInfo.module = model.get()->getModule();
  661. this->parent->zindexHandler.add(zindexInfo);
  662. }
  663. else {
  664. result = LE_ID_NOEXIST;
  665. this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
  666. }
  667. return result;
  668. }