/*
" qtSimpleGraph " - П р о е к т д л я и з у ч е н и я м а ш и н н о й г р а ф и к и н а о с н о в е п о с л е д о в а т е л ь н о г о р и с о в а н и я п р и м и т и в о в
Copyright ( c ) 2020 П р о с к у р н е в А р т е м С е р г е е в и ч
Э т о т ф а й л — ч а с т ь п р о е к т а qtSimpleGraph .
qtSimpleGraph - с в о б о д н а я п р о г р а м м а : в ы м о ж е т е п е р е р а с п р о с т р а н я т ь е е и / и л и
и з м е н я т ь е е н а у с л о в и я х С т а н д а р т н о й о б щ е с т в е н н о й л и ц е н з и и GNU в т о м в и д е ,
в к а к о м о н а б ы л а о п у б л и к о в а н а Ф о н д о м с в о б о д н о г о п р о г р а м м н о г о о б е с п е ч е н и я ;
л и б о в е р с и и 3 л и ц е н з и и , л и б о ( п о в а ш е м у в ы б о р у ) л ю б о й б о л е е п о з д н е й
в е р с и и .
В е с ы р а с п р о с т р а н я е т с я в н а д е ж д е , ч т о о н а б у д е т п о л е з н о й ,
н о Б Е З О В С Я К И Х Г А Р А Н Т И Й ; д а ж е б е з н е я в н о й г а р а н т и и Т О В А Р Н О Г О В И Д А
и л и П Р И Г О Д Н О С Т И Д Л Я О П Р Е Д Е Л Е Н Н Ы Х Ц Е Л Е Й . П о д р о б н е е с м . в С т а н д а р т н о й
о б щ е с т в е н н о й л и ц е н з и и GNU .
В ы д о л ж н ы б ы л и п о л у ч и т ь к о п и ю С т а н д а р т н о й о б щ е с т в е н н о й л и ц е н з и и GNU
в м е с т е с э т о й п р о г р а м м о й . Е с л и э т о н е т а к , с м .
< http : //www.gnu.org/licenses/>.
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 < http : //www.gnu.org/licenses/>.
*/
# include <QApplication>
# include <QMainWindow>
# include <QPainter>
# include <QDesktopWidget>
# include <QBrush>
# include <QFont>
# include <QPen>
# include <QWidget>
# include <QMouseEvent>
# include <QKeyEvent>
# include <QTimer>
# include <QTime>
# include <string>
# include <QDebug>
# include <math.h>
# define clRed 0xFF0000
# define clGreen 0x00FF00
# define clBlue 0x0000FF
# define clBlack 0x000000
# define clWhite 0xFFFFFF
# define clYellow 0xFFFF00
# define clMagenta 0xFF00FF
# define clCyan 0x00FFFF
struct TPixel
{
int x , y ;
unsigned int color ;
} ;
class QTSGraph : public QMainWindow
{
Q_OBJECT
public :
QTSGraph ( int w = 640 , int h = 480 , int x = - 1 , int y = - 1 , QWidget * parent = nullptr ) ;
~ QTSGraph ( ) ;
bool SwapYAxis = false ;
bool MoveOtoCenter = false ;
void ShowAxes ( ) ;
void HideAxes ( ) ;
void Circle ( int x , int y , int radius ) ;
void Delay ( int ms = 1000 ) ;
void Ellipse ( int x1 , int y1 , int x2 , int y2 ) ;
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 ( ) ;
int ReadMouseButton ( ) ;
TPixel ReadMousePosition ( ) ;
TPixel GetLastMouseClickPosition ( ) ;
void Rectangle ( int x1 , int y1 , int x2 , int y2 ) ;
void SetColor ( const QColor & c = Qt : : black ) ;
void SetColor ( const QRgb c = 0x00000000 ) ;
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 ) ;
void SetTextStyle ( int CharSize , int Direction = 0 , int idFont = 0 ) ;
/*
0 - serif
1 - sans
2 - mono
*/
private slots :
void slotResetTimer ( ) ;
void slotStartTimer ( ) ;
private :
bool AxesVisible = false ;
bool EventMouseClicked = false ;
bool EventKeyPressed = false ;
int IDPressedKey = - 1 ;
int IDMouseButton = - 1 ;
int ResetInterval ;
int TextDirection = 0 ;
QPoint LastMouseClickPosition ;
QPoint MouseMovePosition ;
QBrush Brush ;
QPixmap Canvas ;
QFont Font ;
QPen Pen ;
QTimer * ResetTimer ;
QTimer * StartTimer ;
void ChangeCoord ( int * x , int * y ) ;
void PaintBox ( ) ;
protected :
void closeEvent ( QCloseEvent * event ) override ;
void keyPressEvent ( QKeyEvent * event ) override ;
void mousePressEvent ( QMouseEvent * event ) override ;
void mouseMoveEvent ( QMouseEvent * event ) override ;
void paintEvent ( QPaintEvent * event ) override ;
} ;