WorkArea.hpp 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. class WorkArea: public QWidget
  32. {
  33. Q_OBJECT
  34. private:
  35. const int taillePoint = 10;
  36. const int epaisseurLigne = 3;
  37. unsigned int screenSizeX, screenSizeY;
  38. bool readOnly;
  39. bool modificationInProgress;
  40. QImage *original;
  41. QImage *img;
  42. double resizeFactor;
  43. QList < QPoint * >liste_points;
  44. int indexPointClicked;
  45. int maxLines;
  46. protected:
  47. void paintEvent (QPaintEvent * event) override;
  48. void mousePressEvent (QMouseEvent * event);
  49. void mouseMoveEvent (QMouseEvent * event);
  50. void mouseReleaseEvent (QMouseEvent * event);
  51. public:
  52. WorkArea (int screenSizeX, int screenSizeY, QWidget * parent = nullptr);
  53. WorkArea (int screenSizeX, int screenSizeY, const std::string & filename, QWidget * parent = nullptr);
  54. WorkArea (int screenSizeX, int screenSizeY, const std::string & imageFilename, const std::string & SLFilename, bool readOnly, QWidget * parent = nullptr);
  55. ~WorkArea ();
  56. void paint (QPainter & painter);
  57. void loadImage (const std::string & filename);
  58. void loadSL (const std::string & filename);
  59. void saveStrengthLine (const std::string & filename);
  60. void exportPNG (const std::string & filename);
  61. void setReadOnly(bool readOnly);
  62. bool getReadOnly();
  63. void setModificationInProgress(bool mip);
  64. bool getModificationInProgress();
  65. };
  66. #endif