/* "qtSimpleGraph" - Проект для изучения машинной графики на основе последовательного рисования примитивов Copyright 2020 Проскурнев Артем Сергеевич Этот файл — часть проекта qtSimpleGraph. qtSimpleGraph - свободная программа: вы можете перераспространять ее и/или изменять ее на условиях Стандартной общественной лицензии GNU в том виде, в каком она была опубликована Фондом свободного программного обеспечения; либо версии 3 лицензии, либо (по вашему выбору) любой более поздней версии. Весы распространяется в надежде, что она будет полезной, но БЕЗО ВСЯКИХ ГАРАНТИЙ; даже без неявной гарантии ТОВАРНОГО ВИДА или ПРИГОДНОСТИ ДЛЯ ОПРЕДЕЛЕННЫХ ЦЕЛЕЙ. Подробнее см. в Стандартной общественной лицензии GNU. Вы должны были получить копию Стандартной общественной лицензии GNU вместе с этой программой. Если это не так, см. . This file is part of qtSimpleGraph. qtSimpleGraph is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Vesi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Vesi. If not, see . */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define clRed 0x00FF0000 #define clGreen 0x0000FF00 #define clBlue 0x000000FF #define clBlack 0x00000000 #define clWhite 0x00FFFFFF class QTSGraph : public QMainWindow { Q_OBJECT public: QTSGraph(int w = 640, int h = 480, int x = -1, int y = -1, QWidget *parent = nullptr); ~QTSGraph(); void Circle(int x, int y, int radius); void Delay(int ms = 1000); QRgb GetPixel(int x, int y); void Line(int x1, int y1, int x2, int y2); bool KeyPressed(); bool MouseClicked(); void OutTextXY(int x, int y, std::string caption); void PutPixel(int x, int y, QRgb c = 0x00000000, int PenWidth = 1); int ReadKey(); void Rectangle(int x1, int y1, int x2, int y2); void SetColor(QRgb c); void SetFillStyle(int Pattern, QRgb Color); // Стиль и цыет заливки /* 0 - NoBrush 1 - SolidPattern 2 - Dense1Pattern 3 - Dense2Pattern 4 - Dense3Pattern 5 - Dense4Pattern 6 - Dense5Pattern 7 - Dense6Pattern 8 - Dense7Pattern 9 - HorPattern 10 - VerPattern 11 - CrossPattern 12 - BDiagPattern 13 - FDiagPattern 14 - DiagCrossPattern 15 - LinearGradientPattern 16 - RadialGradientPattern 17 - ConicalGradientPattern */ void SetPenStyle(int PenWidth, int PenStyle = 1); // Толщина и стиль линии /* 0 - NoPen 1 - SolidLine 2 - DashLine 3 - DotLine 4 - DashDotLine 5 - DashDotDotLine */ void SetPenWidth(int PenWidth); private slots: void slotStartTimer(); void slotResetTimer(); private: QPixmap Canvas; QTimer *StartTimer; QTimer *ResetTimer; bool EventMouseClicked = false; bool EventKeyPressed = false; int IDPressedKey = -1; void PaintBox(); QBrush Brush; QPen Pen; protected: void paintEvent(QPaintEvent *event) override; void mousePressEvent(QMouseEvent *event) override; void keyPressEvent(QKeyEvent *event) override; };