WorkArea.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*********************************************************************/
  2. /* */
  3. /* Copyright 2022-2023 Rémi Synave - remi.synave@univ-littoral.fr */
  4. /* */
  5. /* This file is part of DSL. */
  6. /* This software uses Qt to build the Graphical User Interface */
  7. /* https://www.qt.io/ */
  8. /* */
  9. /* DSL is free software: you can redistribute it and/or modify */
  10. /* it under the terms of the GNU General Public License as published */
  11. /* by the Free Software Foundation, either version 3 of the License, */
  12. /* or (at your option) any later version. */
  13. /* */
  14. /* DSL is distributed in the hope that it will be useful, */
  15. /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
  16. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
  17. /* GNU General Public License for more details. */
  18. /* */
  19. /* You should have received a copy of the GNU General Public License */
  20. /* along with DSL. If not, see <http://www.gnu.org/licenses/>. */
  21. /* */
  22. /*********************************************************************/
  23. #ifndef WORKAREA_HPP
  24. #define WORKAREA_HPP
  25. #include <string>
  26. #include <QWidget>
  27. #include <QPainter>
  28. #include <QMouseEvent>
  29. #include <QPoint>
  30. #include <QImage>
  31. #include <QImageReader>
  32. #include "StrengthLine.hpp"
  33. class WorkArea: public QWidget
  34. {
  35. Q_OBJECT
  36. private:
  37. const int taillePoint = 10;
  38. const int epaisseurLigne = 6;
  39. unsigned int screenSizeX, screenSizeY;
  40. bool readOnly;
  41. bool modificationInProgress;
  42. QImage *original;
  43. QImage *img;
  44. double resizeFactor;
  45. QList < QPoint * >liste_points;
  46. int indexPointClicked;
  47. int maxLines;
  48. protected:
  49. void paintEvent (QPaintEvent * event) override;
  50. void mousePressEvent (QMouseEvent * event);
  51. void mouseMoveEvent (QMouseEvent * event);
  52. void mouseReleaseEvent (QMouseEvent * event);
  53. public:
  54. WorkArea (int screenSizeX, int screenSizeY, QWidget * parent = nullptr);
  55. WorkArea (int screenSizeX, int screenSizeY, const std::string & filename, QWidget * parent = nullptr);
  56. WorkArea (int screenSizeX, int screenSizeY, const std::string & imageFilename, const std::string & SLFilename, bool readOnly, QWidget * parent = nullptr);
  57. ~WorkArea ();
  58. void paint (QPainter & painter);
  59. void loadImage (const std::string & filename);
  60. void loadSL (const std::string & filename);
  61. void saveStrengthLine (const std::string & filename);
  62. void exportPNG (const std::string & filename);
  63. void exportJPG (const std::string & filename);
  64. void setReadOnly(bool readOnly);
  65. bool getReadOnly();
  66. QImage* getOriginalImage() const;
  67. QImage* getResizedImage() const;
  68. void setModificationInProgress(bool mip);
  69. bool getModificationInProgress();
  70. int getNumberOfLines() const;
  71. void addSL(const StrengthLine *sl);
  72. void addRandomSL();
  73. signals:
  74. void click();
  75. };
  76. #endif