Geen omschrijving

line.h 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #ifndef LINE_H
  2. #define LINE_H
  3. #include <QWidget>
  4. #include <QPainter>
  5. /// \~English
  6. /// A class to describe lines.
  7. /// \~Spanish
  8. /// Una clase para describir lineas
  9. class Line : public QWidget
  10. {
  11. Q_OBJECT
  12. public:
  13. /// \fn Line::Line(QWidget *parent)
  14. /// \~English
  15. /// \brief Constructor sets coordinates to 0, pen color to black and pen
  16. /// width to 1
  17. /// \~Spanish
  18. /// \brief Constructor que ajusta las coordenadas a 0, el color y el ancho del
  19. /// boligrafo a negro y 1 respectivamente.
  20. explicit Line(QWidget *parent = 0);
  21. /// \fn Line::Line(int fromX, int fromY, int toX, int toY, int w, QColor c, QWidget *parent)
  22. /// \~English
  23. /// \brief Constructor for a line, specifying the (fromX,fromY) and (toX,toY)
  24. /// \param fromX starting x coordinate
  25. /// \param fromY starting y coordinate
  26. /// \param toX end x coordinate
  27. /// \param toY end y coordinate
  28. /// \param w pen width
  29. /// \param c line color
  30. /// \param parent parent of this line
  31. /// \~Spanish
  32. /// \brief Constructor de una linea, especificando las coordenadas
  33. /// (fromX,fromY) y (toX,toY)
  34. /// \param fromX coordenada x inicial
  35. /// \param fromY coordenada y inicial
  36. /// \param toX coordenada x final
  37. /// \param toY end coordenada y final
  38. /// \param w ancho del boligrafo
  39. /// \param c color de la linea.
  40. /// \param parent parent of this line
  41. Line(int fromX, int fromY, int toX, int toY, int w, QColor c, QWidget *parent = 0);
  42. /// \fn Line::Line(int fromX, int fromY, int length, double angle, int w, QColor c, QWidget *parent)
  43. /// \~English
  44. /// \brief Constructor for a line, specifying (fromX, fromY) and the
  45. /// **length** and **angle**.
  46. /// \param fromX starting x coordinate
  47. /// \param fromY starting y coordinate
  48. /// \param length length of the line
  49. /// \param angle angle
  50. /// \param w pen width
  51. /// \param c line color
  52. /// \param parent parent of this line
  53. /// \~Spanish
  54. /// \brief Constructor de una linea, especificando la coordenada
  55. /// (fromX, fromY) and el largo (length) y el angulo (angle).
  56. /// \param fromX coordenada x inicial
  57. /// \param fromY coordenada y inicia
  58. /// \param length largo de la linea
  59. /// \param angle angulo de la linea
  60. /// \param w ancho de la linea
  61. /// \param c color de la linea
  62. /// \param parent padre de esta linea
  63. Line(int fromX, int fromY, int length, double angle, int w, QColor c, QWidget *parent = 0);
  64. /// \fn void Line::setCoords(int fromX, int fromY, int toX, int toY)
  65. /// \~English
  66. /// \brief Setter for the line coordinates
  67. /// \param fromX starting x coordinate
  68. /// \param fromY starting y coordinate
  69. /// \param toX end x coordinate
  70. /// \param toY end y coordinate
  71. /// \~Spanish
  72. /// \brief Ajustador de las coordenadas de la linea
  73. /// \param fromX coordenada x inicial
  74. /// \param fromY coordenada y inicial
  75. /// \param toX coordenada x final
  76. /// \param toY end coordenada y final
  77. void setCoords(int fromX, int fromY, int toX, int toY);
  78. /// \fn void Line::setpenColor(QColor c)
  79. /// \~English
  80. /// \brief Setter for the pen color
  81. /// \param c line color
  82. /// \~Spanish
  83. /// \brief Ajustador del color del boligrafo
  84. /// \param c color de la linea
  85. void setpenColor(QColor c);
  86. /// \fn void Line::setPenWidth(int w)
  87. /// \~English
  88. /// \brief Setter for the pen width
  89. /// \param w pen width
  90. /// \~Spanish
  91. /// \brief Ajustador del ancho del boligrafo
  92. /// \param w ancho de la linea
  93. void setPenWidth(int w);
  94. /// \fn int Line::getX0()
  95. /// \~English
  96. /// \brief Getter for the starting coordinate x.
  97. /// \return starting coordinate x.
  98. /// \~Spanish
  99. /// \brief Devuelve la coordenada inicial x.
  100. /// \return coordenada inicial x
  101. int getX0();
  102. /// \fn int Line::getY0()
  103. /// \~English
  104. /// \brief Getter for the starting coordinate y.
  105. /// \return starting coordinate y.
  106. /// \~Spanish
  107. /// \brief Devuelve la coordenada inicial y.
  108. /// \return coordenada inicial y
  109. int getY0();
  110. /// \fn int Line::getX1()
  111. /// \~English
  112. /// \brief Getter for the ending coordinate x.
  113. /// \return ending coordinate x.
  114. /// \~Spanish
  115. /// \brief Devuelve la coordenada final x.
  116. /// \return coordenada final x.
  117. int getX1();
  118. /// \fn int Line::getY1()
  119. /// \~English
  120. /// \brief Getter for the ending coordinate y.
  121. /// \return ending coordinate y.
  122. /// \~Spanish
  123. /// \brief Devuelve la coordenada final y.
  124. /// \return coordenada final y
  125. int getY1();
  126. signals:
  127. public slots:
  128. protected:
  129. /// \fn void Line::paintEvent(QPaintEvent *)
  130. /// \~English
  131. /// \brief The paint event function is automatically invoked
  132. /// whenever a resize or repaint happens.
  133. /// \~Spanish
  134. /// \brief La funcion para el evento de pintar es invocada automaticamente
  135. /// cada ves que evento de repintar ocurre.
  136. void paintEvent(QPaintEvent *);
  137. private:
  138. int x0, /**< initial coord x / coordenada inicial x */
  139. y0, /**< initial coord y / coordenada inicial y */
  140. x1, /**< ending coord x / coordenada final x */
  141. y1; /**< ending coord y / coordenada final y */
  142. int penWidth; /**< pen width / ancho del boligrafo */
  143. QColor penColor; /**< pen color / color del boligrafo */
  144. };
  145. #endif // LINE_H