Açıklama Yok

drawingWindow.h 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3. #include <QMainWindow>
  4. #include <vector>
  5. #include "line.h"
  6. using namespace std;
  7. namespace Ui {
  8. class DrawingWindow;
  9. };
  10. class DrawingWindow : public QMainWindow
  11. {
  12. Q_OBJECT
  13. public:
  14. /// \fn DrawingWindow::DrawingWindow(QWidget *parent)
  15. /// \~English
  16. /// \brief Constructor.
  17. /// \param parent when creating a DrawingWindow in the main function, leave this parameter empty
  18. /// \~Spanish
  19. /// \brief Constructor
  20. /// \param parent ventana padre
  21. explicit DrawingWindow(QWidget *parent = 0);
  22. /// \fn DrawingWindow::~DrawingWindow - the destructor
  23. /// \~English
  24. /// \brief Destructor
  25. /// \~Spanish
  26. /// \brief Destructor
  27. ~DrawingWindow();
  28. /// \fn void DrawingWindow::addLine(int x0, int y0, int x1, int y1, int width, QColor color)
  29. /// \~English
  30. /// \brief Add a line to the window, specifying coordinates
  31. /// of the starting and end points.
  32. /// \param x0 starting x
  33. /// \param y0 starting y
  34. /// \param x1 end x
  35. /// \param y1 end y
  36. /// \param width - line width
  37. /// \param color - line color
  38. /// \~Spanish
  39. /// \brief Anade una linea a la ventana, especificando las coordenadas
  40. /// de los puntos inciales y finales.
  41. /// \param x0 x inicial
  42. /// \param y0 y inicial
  43. /// \param x1 x final
  44. /// \param y1 y final
  45. /// \param width ancho de la linea
  46. /// \param color color de la linea
  47. void addLine(int x0, int y0, int x1, int y1, int width, QColor color);
  48. /// \fn void DrawingWindow::addLinePolar(int x0, int y0, int length, double angle, int width, QColor color)
  49. /// \~English
  50. /// \brief Add a line to the window, specifying coordinates
  51. /// of the starting point, the length and angle.
  52. /// \param x0 starting x
  53. /// \param y0 starting y
  54. /// \param length length of the line
  55. /// \param angle angle
  56. /// \param width line width
  57. /// \param color line color
  58. /// \~Spanish
  59. /// \brief Anade una linea a la ventana, especificando las coordenadas
  60. /// del punto inicial, el largo y el angulo.
  61. /// \param x0 x incial
  62. /// \param y0 y inicial
  63. /// \param length largo de la linea
  64. /// \param angle angulo de la linea
  65. /// \param width ancho de la linea
  66. /// \param color color de la linea
  67. void addLinePolar(int x0, int y0, int length, double angle, int width, QColor color);
  68. /// \fn void DrawingWindow::box(int x, int y, int sideLength, QColor c)
  69. /// \~English
  70. /// \brief Draws a box with sides of size sideLength
  71. /// \param x initial x coordinate of the box
  72. /// \param y initial y coordinate of the box
  73. /// \param sideLength length of the sides of the box
  74. /// \param c color of the box
  75. /// \~Spanish
  76. /// \brief Dibuja una caja con los lados del tamano sideLength
  77. /// \param x coordenada inicial x de la caja
  78. /// \param y coordenada inicial y de la caja
  79. /// \param sideLength largo de los lados de la caja
  80. /// \param c color de la caja
  81. void box(int x, int y, int sideLength, QColor c) ;
  82. /// \fn void DrawingWindow::boxes(int x, int y, int sideLength, double shrinkFactor, int smallestLength, QColor c)
  83. /// \~English
  84. /// \brief Recursive function that draws smaller boxes inside the four
  85. /// corners of the boxes.
  86. /// \param x initial coordinate x
  87. /// \param y initial coordinate y
  88. /// \param sideLength length of the sides of the box
  89. /// \param shrinkFactor factor to decreese the sideLength in
  90. /// the recursion for the interior boxes
  91. /// \param smallestLength smallest length of the size of the
  92. /// side of the boxes
  93. /// \param c color of the boxes
  94. /// \~Spanish
  95. /// \brief Funcion recursiva que dibuja cajas mas pequenas dentro de las cuatro
  96. /// esquenas de las cajas.
  97. /// \param x coordenada inicial x
  98. /// \param y coordenada inicial y
  99. /// \param sideLength largo de los lados de la caja
  100. /// \param shrinkFactor factor para disminuir el tamano de los lados en
  101. /// la recursion para las cajas interiores
  102. /// \param smallestLength largo mas pequeno de el tamano de el
  103. /// lado de las cajas
  104. /// \param c color de las cajas
  105. void boxes(int x, int y, int sideLength, double shrinkFactor, int smallestLength, QColor c) ;
  106. /// \fn void DrawingWindow::snowHelper(int size, int level)
  107. /// \~English
  108. /// \brief interface function for the snowflake recursive function
  109. /// \param size snowflake size
  110. /// \param level recursion depth
  111. /// \~Spanish
  112. /// \brief function de interface para la funcion recursiva snowflake
  113. /// \param size tamano del copo de nieve
  114. /// \param level profundidad de la recursion
  115. void snowHelper(int size, int level) ;
  116. /// \fn void DrawingWindow::snowflake(int x, int y, int size, double angle, int level, QColor c) {
  117. /// \~English
  118. /// \brief Recursive figure, the snowflake presented at:
  119. /// https://sites.google.com/a/wellesley.edu/wellesley-cs118-spring13/lectures-labs/lab-6-turtle-recursion
  120. /// sf = sf(n-1) + 60 degrees sf(n-1) + 60 degrees sf(n-1) + s(n-1)
  121. /// sf(0) = line
  122. /// \param x initial coordinate x
  123. /// \param y initial coordinate y
  124. /// \param size size of the snowflake
  125. /// \param angle angle of a line of the snowflake
  126. /// \param level recursion depth
  127. /// \param c color of the lines (snowflake)
  128. /// \~Spanish
  129. /// \brief Figura recursiva, el copo de nieve presentado en:
  130. /// https://sites.google.com/a/wellesley.edu/wellesley-cs118-spring13/lectures-labs/lab-6-turtle-recursion
  131. /// sf = sf(n-1) + 60 grados sf(n-1) + 60 grados sf(n-1) + s(n-1)
  132. /// sf(0) = line
  133. /// \param x coordenada inicial x
  134. /// \param y coordenada inicial y
  135. /// \param size tamano del copo de nieve
  136. /// \param angle angulo de la linea del copo de nieve
  137. /// \param level profundidad de la recursion
  138. /// \param c color de las lineas (copo de nieve)
  139. void snowflake(int x, int y, int size, double angle, int level, QColor c) ;
  140. private:
  141. Ui::DrawingWindow *ui;
  142. vector <Line *> *vL;
  143. protected:
  144. /// \fn void DrawingWindow::paintEvent(QPaintEvent *)
  145. /// \~English
  146. /// \brief Function called in a paint event
  147. /// \~Spanish
  148. /// \brief Funcion invocada en un evento de pintar
  149. void paintEvent(QPaintEvent *);
  150. };
  151. #endif // MAINWINDOW_H