Няма описание

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #include "drawingWindow.h"
  2. #include "ui_drawingWindow.h"
  3. #include <vector>
  4. /// \fn DrawingWindow::DrawingWindow(QWidget *parent)
  5. /// \~English
  6. /// \brief Constructor.
  7. /// \param parent when creating a DrawingWindow in the main function, leave this parameter empty
  8. /// \~Spanish
  9. /// \brief Constructor
  10. /// \param parent (ventana padre) Dejar el parametro de parent vacio cuando se cree el DrawingWindow en la funcion de main.
  11. DrawingWindow::DrawingWindow(QWidget *parent) :
  12. QMainWindow(parent),
  13. ui(new Ui::DrawingWindow)
  14. {
  15. ui->setupUi(this);
  16. vL = new vector<Line *>;
  17. // just hidding the toolbars to have a bigger drawing area.
  18. // Simplemente se esta escondiendo las barras de herramientas para tener
  19. // mas espacio para dibujar.
  20. QList<QToolBar *> toolbars = this->findChildren<QToolBar *>();
  21. foreach(QToolBar *t, toolbars) t->hide();
  22. QList<QStatusBar *> statusbars = this->findChildren<QStatusBar *>();
  23. foreach(QStatusBar *t, statusbars) t->hide();
  24. }
  25. /// \fn void DrawingWindow::addLine(int x0, int y0, int x1, int y1, int width, QColor color)
  26. /// \~English
  27. /// \brief Add a line to the window, specifying coordinates
  28. /// of the starting and end points.
  29. /// \param x0 starting x
  30. /// \param y0 starting y
  31. /// \param x1 end x
  32. /// \param y1 end y
  33. /// \param width - line width
  34. /// \param color - line color
  35. /// \~Spanish
  36. /// \brief Anade una linea a la ventana, especificando las coordenadas
  37. /// de los puntos inciales y finales.
  38. /// \param x0 x inicial
  39. /// \param y0 y inicial
  40. /// \param x1 x final
  41. /// \param y1 y final
  42. /// \param width ancho de la linea
  43. /// \param color color de la linea
  44. void DrawingWindow::addLine(int x0, int y0, int x1, int y1, int width, QColor color) {
  45. Line *tmp = new Line(x0,y0,x1,y1, width, color, this);
  46. tmp->show();
  47. vL->push_back(tmp);
  48. }
  49. /// \fn void DrawingWindow::addLinePolar(int x0, int y0, int length, double angle, int width, QColor color)
  50. /// \~English
  51. /// \brief Add a line to the window, specifying coordinates
  52. /// of the starting point, the length and angle.
  53. /// \param x0 starting x
  54. /// \param y0 starting y
  55. /// \param length length of the line
  56. /// \param angle angle
  57. /// \param width line width
  58. /// \param color line color
  59. /// \~Spanish
  60. /// \brief Anade una linea a la ventana, especificando las coordenadas
  61. /// del punto inicial, el largo y el angulo.
  62. /// \param x0 x incial
  63. /// \param y0 y inicial
  64. /// \param length largo de la linea
  65. /// \param angle angulo de la linea
  66. /// \param width ancho de la linea
  67. /// \param color color de la linea
  68. void DrawingWindow::addLinePolar(int x0, int y0, int length, double angle, int width, QColor color) {
  69. Line *tmp = new Line(x0,y0,length, angle, width, color, this);
  70. tmp->show();
  71. vL->push_back(tmp);
  72. }
  73. /// \fn DrawingWindow::~DrawingWindow - the destructor
  74. /// \~English
  75. /// \brief Destructor
  76. /// \~Spanish
  77. /// \brief Destructor
  78. DrawingWindow::~DrawingWindow()
  79. {
  80. foreach(Line *l, *vL) delete l;
  81. delete vL;
  82. delete ui;
  83. }
  84. /// \fn void DrawingWindow::paintEvent(QPaintEvent *)
  85. /// \~English
  86. /// \brief Function called in a paint event
  87. /// \~Spanish
  88. /// \brief Funcion invocada en un evento de pintar
  89. void DrawingWindow::paintEvent(QPaintEvent *) {
  90. QPainter p(this);
  91. QPen myPen;
  92. myPen.setWidth(1);
  93. myPen.setColor(QColor(0x0000ff));
  94. p.setPen(myPen);
  95. p.setBrush(Qt::cyan);
  96. }