diff --git a/.gitignore b/.gitignore index 1c6591d..330a2fe 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ build-Painter-Desktop_Qt_6_2_2_MinGW_64_bit-Debug/debug/commands.o build-Painter-Desktop_Qt_6_2_2_MinGW_64_bit-Debug/.qmake.stash PaintFigure.pro.user.9daa8a8 PaintFigure.pro.user.fa82d14 +PaintFigure.pro.user.0d910db diff --git a/PaintFigure.pro.user b/PaintFigure.pro.user index ed90fef..6886c06 100644 --- a/PaintFigure.pro.user +++ b/PaintFigure.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {0d910db4-7bb8-48b8-8dc3-42bbd1411033} + {c7d1764a-a256-486e-81e6-f150cd42ba37} ProjectExplorer.Project.ActiveTarget @@ -79,7 +79,7 @@ true true Builtin.DefaultTidyAndClazy - 4 + 6 @@ -99,8 +99,8 @@ 0 0 - C:\Users\zizo\Downloads\MyGitHub\New folder\build-PaintFigure-Desktop_Qt_6_2_2_MinGW_64_bit-Debug - C:/Users/zizo/Downloads/MyGitHub/New folder/build-PaintFigure-Desktop_Qt_6_2_2_MinGW_64_bit-Debug + C:\Users\youss\Downloads\paintfigure\build-PaintFigure-Desktop_Qt_6_2_2_MinGW_64_bit-Debug + C:/Users/youss/Downloads/paintfigure/build-PaintFigure-Desktop_Qt_6_2_2_MinGW_64_bit-Debug true @@ -136,11 +136,10 @@ Debug Qt4ProjectManager.Qt4BuildConfiguration 2 - 0 - C:\Users\zizo\Downloads\MyGitHub\New folder\build-PaintFigure-Desktop_Qt_6_2_2_MinGW_64_bit-Release - C:/Users/zizo/Downloads/MyGitHub/New folder/build-PaintFigure-Desktop_Qt_6_2_2_MinGW_64_bit-Release + C:\Users\youss\Downloads\paintfigure\build-PaintFigure-Desktop_Qt_6_2_2_MinGW_64_bit-Release + C:/Users/youss/Downloads/paintfigure/build-PaintFigure-Desktop_Qt_6_2_2_MinGW_64_bit-Release true @@ -180,8 +179,8 @@ 0 - C:\Users\zizo\Downloads\MyGitHub\New folder\build-PaintFigure-Desktop_Qt_6_2_2_MinGW_64_bit-Profile - C:/Users/zizo/Downloads/MyGitHub/New folder/build-PaintFigure-Desktop_Qt_6_2_2_MinGW_64_bit-Profile + C:\Users\youss\Downloads\paintfigure\build-PaintFigure-Desktop_Qt_6_2_2_MinGW_64_bit-Profile + C:/Users/youss/Downloads/paintfigure/build-PaintFigure-Desktop_Qt_6_2_2_MinGW_64_bit-Profile true @@ -242,14 +241,14 @@ 2 PaintFigure2 - Qt4ProjectManager.Qt4RunConfiguration:C:/Users/zizo/Downloads/MyGitHub/CMP2241_F21_Team01/PaintFigure.pro - C:/Users/zizo/Downloads/MyGitHub/CMP2241_F21_Team01/PaintFigure.pro + Qt4ProjectManager.Qt4RunConfiguration:D:/CMP2241_F21_Team01/PaintFigure.pro + D:/CMP2241_F21_Team01/PaintFigure.pro false true true false true - C:/Users/zizo/Downloads/MyGitHub/New folder/build-PaintFigure-Desktop_Qt_6_2_2_MinGW_64_bit-Debug + C:/Users/youss/Downloads/paintfigure/build-PaintFigure-Desktop_Qt_6_2_2_MinGW_64_bit-Debug 1 diff --git a/about.cpp b/about.cpp index d9b5016..040b9af 100644 --- a/about.cpp +++ b/about.cpp @@ -1,6 +1,7 @@ #include "about.h" #include "ui_about.h" + about::about(QWidget *parent) : QDialog(parent, Qt::FramelessWindowHint | Qt::WindowSystemMenuHint), ui(new Ui::about) diff --git a/about.h b/about.h index 810764f..606145f 100644 --- a/about.h +++ b/about.h @@ -7,6 +7,7 @@ namespace Ui { class about; } + class about : public QDialog { Q_OBJECT diff --git a/circle.cpp b/circle.cpp index 799fec7..3c7c3d5 100644 --- a/circle.cpp +++ b/circle.cpp @@ -2,6 +2,7 @@ #include #include + Circle::Circle(QPointF point,QColor color,int LineWeight, QColor fillColor, QObject *parent) : Figure(point,parent) { diff --git a/circle.h b/circle.h index 297d0ab..eb8fee9 100644 --- a/circle.h +++ b/circle.h @@ -5,6 +5,7 @@ #include #include "figure.h" + class Circle : public Figure { Q_OBJECT diff --git a/commands.cpp b/commands.cpp index f5218f6..8920bc3 100644 --- a/commands.cpp +++ b/commands.cpp @@ -3,6 +3,7 @@ #include "painttable.h" + AddCommand::AddCommand(PaintScene *scene,Figure* item, QPointF LastPoint,QTableWidget* table,QUndoCommand *parent) : QUndoCommand(parent) { diff --git a/commands.h b/commands.h index 173afa9..4ee59e0 100644 --- a/commands.h +++ b/commands.h @@ -6,6 +6,7 @@ #include "paintscene.h" #include + class AddCommand : public QUndoCommand { public: diff --git a/figure.cpp b/figure.cpp index 8bc276c..98b1c7a 100644 --- a/figure.cpp +++ b/figure.cpp @@ -1,6 +1,7 @@ #include "figure.h" #include + // Initializing the shapes counters to 1 int Figure::rCount = 1; int Figure::cCount = 1; diff --git a/figure.h b/figure.h index 3f8cb69..704bef0 100644 --- a/figure.h +++ b/figure.h @@ -7,6 +7,7 @@ + class Figure : public QObject, public QGraphicsItem { Q_OBJECT diff --git a/json_utilities.cpp b/json_utilities.cpp index 2a4e02c..fdf5aea 100644 --- a/json_utilities.cpp +++ b/json_utilities.cpp @@ -7,6 +7,7 @@ #include "painttable.h" #include "commands.h" + /* * ----------------------Save Method---------------------- * Take the path and the scene then save each figure in diff --git a/json_utilities.h b/json_utilities.h index f8a6b71..53f40c1 100644 --- a/json_utilities.h +++ b/json_utilities.h @@ -11,6 +11,7 @@ #include #include + class json_utilities { public: diff --git a/line.cpp b/line.cpp index 96bb304..3fca353 100644 --- a/line.cpp +++ b/line.cpp @@ -1,6 +1,7 @@ #include "line.h" #include + Line::Line(QPointF point,QColor color,int LineWeight, QObject *parent) : Figure(point,parent) { diff --git a/line.h b/line.h index 06ddd0d..8893089 100644 --- a/line.h +++ b/line.h @@ -5,6 +5,8 @@ #include #include "figure.h" + + class Line : public Figure { Q_OBJECT diff --git a/main.cpp b/main.cpp index 875ce13..04f2ca1 100644 --- a/main.cpp +++ b/main.cpp @@ -3,6 +3,7 @@ #include "welcomewindow.h" #include "messagedialog.h" + int main(int argc, char *argv[]) { QApplication a(argc, argv); diff --git a/mainwindow.cpp b/mainwindow.cpp deleted file mode 100644 index bb5f95f..0000000 --- a/mainwindow.cpp +++ /dev/null @@ -1,193 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include -#include -#include "paintscene.h" -#include "json_utilities.h" - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - scene = new PaintScene(ui->graphicsView); - ui->graphicsView->setScene(scene); - ui->graphicsView->setRenderHint(QPainter::Antialiasing); - ui->graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - ui->graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - - timer = new QTimer(); - connect(timer, &QTimer::timeout, this, &MainWindow::slotTimer); - timer->start(100); - undoView = new QUndoView(scene->undoStack); - undoView->setWindowTitle(tr("Command List")); - undoView->show(); - undoView->setAttribute(Qt::WA_QuitOnClose, false); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - -void MainWindow::slotTimer() -{ - - timer->stop(); - scene->setSceneRect(0,0, ui->graphicsView->width() - 20, ui->graphicsView->height() - 20); -} - -void MainWindow::resizeEvent(QResizeEvent *event) -{ - timer->start(100); - QMainWindow::resizeEvent(event); -} - -// Ромб -void MainWindow::on_pushButton_clicked() -{ - scene->setTypeFigure(PaintScene::RombType); -} - -// Квадрат -void MainWindow::on_pushButton_2_clicked() -{ - scene->setTypeFigure(PaintScene::SquareType); -} - -// Треугольник -void MainWindow::on_pushButton_3_clicked() -{ - scene->setTypeFigure(PaintScene::TriangleType); -} -void MainWindow::on_pushButton_4_clicked() -{ - scene->setTypeFigure(PaintScene::LineType); -} -void MainWindow::on_actionUndo_triggered() -{ - scene->undoStack->undo(); -} - - -void MainWindow::on_actionRedo_triggered() -{ - scene->undoStack->redo(); -} - - -void MainWindow::on_actionColor_triggered() -{ - QColor newColor = QColorDialog::getColor(); - if (newColor.isValid()){ - scene->setColor(newColor); - } - - -} - - - -void MainWindow::on_horizontalSlider_sliderMoved(int position) -{ - scene->setWeight(position); -} - - - -//method for sort AScending (by perimeter) button. -void MainWindow::on_actionSave_Json_triggered() -{ - - QString fileName = QFileDialog::getSaveFileName(this, - tr("Save As"), "", - tr("JSON (*.json);; All Files (*)")); - - qDebug() << fileName; - json_utilities *jsonSaveObject; - jsonSaveObject->save(scene, fileName); -} -//method for comparison that the sort() method will use when comparing the objects in the vector v -bool compareAs(const Figure* first, const Figure* second){ - return first->perimeter < second->perimeter; -} -//method for sort AScending (by perimeter) button. -void MainWindow::on_sortA_Btn_clicked() -{ - //we make sure the button works - qDebug()<<"sort ascending button pressed"; - - /*we sort the vector, parameters for sort here is begin,end of vector and the method used to compare LHs to LHs. - in this case the method is compareAs which has Lhs as smaller - complexity for this sort is Nlog2(N) where N is this distance bet. elements compared, - it also modifies the original vector*/ - std::sort(scene->ItemsVec->begin(), scene->ItemsVec->end(), compareAs); - //create a temporary vector that we use for printing. - QVector *TempVec = scene->ItemsVec; - //iterate on the temporary vector and disaply the stuff in it - for (int i=0;isize();i++){ - qDebug()<<(*TempVec)[i]->name<<"perimeter "<<(*TempVec)[i]->perimeter; - } - delete[] TempVec; - //here just signal the table element to update the vector and display it -} - - -//function that compares descendingly (bigger element is first) -bool compareDs(const Figure* first, const Figure* second){ - return first->perimeter > second->perimeter; -} -//method for button that sorts descendingly. -void MainWindow::on_sortD_Btn_clicked() -{ - //we make sure the button works - qDebug()<<"sort ascending button pressed"; - - //we sort the vector, parameters for sort here is begin,end of vector and the method used to compare LHs to LHs. - std::sort(scene->ItemsVec->begin(), scene->ItemsVec->end(), compareDs); - //create a temporary vector that we use for printing. - QVector *TempVec = scene->ItemsVec; - //iterate on the temporary vector and disaply the stuff in it - for (int i=0;isize();i++){ - qDebug()<<(*TempVec)[i]->name<<"perimeter "<<(*TempVec)[i]->perimeter; - } - delete[] TempVec; - //here just signal the table element to update the vector and display it -} - -//Function that runs when search button is clicked -void MainWindow::on_srch_Btn_clicked() -{ - //get the text from the textbox and place it into a string. - QString srchTxt = ui->lineEdit_srchTxt->text(); - qDebug()<<"Searching for : "< *TempVec = scene->ItemsVec; - //then we search that vector trying to find a match for (srchTxt), hopefully we can! - /* complextity of find_if= N applications where N = std::distance(first, last). */ - auto it = std::find_if(TempVec->begin(), TempVec->end(), [=] (Figure* const& element) { - return (element->name == srchTxt); - }); - bool found = (it != TempVec->end()); - if(found==true){ - //code for when the item is found - qDebug()<<"Item is here"; - }else { - //code for when the item is not found. - qDebug()<<"Item is not here"; - } -} - - -void MainWindow::on_actionOpen_File_triggered() -{ - QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), - "/c://", - tr("JSON (*.json)")); - - json_utilities *jsonSaveObject; - jsonSaveObject->open(scene, fileName); - -} - diff --git a/mainwindow.h b/mainwindow.h deleted file mode 100644 index 68a34f6..0000000 --- a/mainwindow.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include -#include -#include "paintscene.h" - -namespace Ui { -class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = 0); - ~MainWindow(); - -private: - Ui::MainWindow *ui; - PaintScene *scene; - QTimer *timer; - -private: - - void resizeEvent(QResizeEvent * event); - QUndoView *undoView; - -private slots: - void slotTimer(); - void on_pushButton_clicked(); - void on_pushButton_2_clicked(); - void on_pushButton_3_clicked(); - - void on_actionUndo_triggered(); - void on_actionRedo_triggered(); - void on_actionColor_triggered(); - void on_horizontalSlider_sliderMoved(int position); - void on_pushButton_4_clicked(); - void on_sortA_Btn_clicked(); - void on_actionSave_Json_triggered(); - void on_sortD_Btn_clicked(); - void on_srch_Btn_clicked(); - - void on_actionOpen_File_triggered(); -}; - -#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui deleted file mode 100644 index de68257..0000000 --- a/mainwindow.ui +++ /dev/null @@ -1,166 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - - Rectangle - - - - - - - 30 - - - Qt::Horizontal - - - - - - - - - - Circle - - - - - - - Triangle - - - - - - - Line - - - - - - - Sort Ascending (p) - - - - - - - Sort descending (p) - - - - - - - Search - - - - - - - - - - - - 0 - 0 - 800 - 22 - - - - - Edit - - - - - - - - - Line Weight - - - - - File - - - - - - - - - - - - - Undo - - - Ctrl+Z - - - - - Redo - - - Ctrl+Y - - - - - Color - - - - - Line Weight - - - - - Save Json - - - - - Save PNG - - - - - Open File - - - - - - - diff --git a/messagedialog.cpp b/messagedialog.cpp index 14fefca..4877517 100644 --- a/messagedialog.cpp +++ b/messagedialog.cpp @@ -3,6 +3,7 @@ #include #include "json_utilities.h" + messageDialog::messageDialog(QString message,QString LeftText,QString RightText,QWidget *parent) : QDialog(parent, Qt::FramelessWindowHint | Qt::WindowSystemMenuHint), ui(new Ui::messageDialog) diff --git a/messagedialog.h b/messagedialog.h index 44dd0d5..aca14d3 100644 --- a/messagedialog.h +++ b/messagedialog.h @@ -5,6 +5,7 @@ #include "paintwindow.h" #include + namespace Ui { class messageDialog; } diff --git a/paintscene.cpp b/paintscene.cpp index da794f6..5bab9b5 100644 --- a/paintscene.cpp +++ b/paintscene.cpp @@ -7,6 +7,7 @@ #include + PaintScene::PaintScene(QGraphicsView *view,QTableWidget* table, QObject *parent) : QGraphicsScene(parent) { this->view = view; diff --git a/paintscene.h b/paintscene.h index c6b0c70..572300c 100644 --- a/paintscene.h +++ b/paintscene.h @@ -11,6 +11,7 @@ + class PaintScene : public QGraphicsScene { Q_OBJECT diff --git a/painttable.cpp b/painttable.cpp index 98aa8e3..ea9b381 100644 --- a/painttable.cpp +++ b/painttable.cpp @@ -5,6 +5,7 @@ PaintTable::PaintTable() } + void PaintTable::UpdateTable(QTableWidget *table, QVector
ItemVec) { QStringList TableLabel; diff --git a/painttable.h b/painttable.h index 754183d..8e795b1 100644 --- a/painttable.h +++ b/painttable.h @@ -6,6 +6,7 @@ #include "figure.h" + class PaintTable { public: diff --git a/paintwindow.cpp b/paintwindow.cpp index 35688e4..761d356 100644 --- a/paintwindow.cpp +++ b/paintwindow.cpp @@ -13,6 +13,7 @@ + PaintWindow::PaintWindow(QWidget *parent) : QMainWindow(parent, Qt::FramelessWindowHint | Qt::WindowSystemMenuHint), ui(new Ui::PaintWindow) diff --git a/paintwindow.h b/paintwindow.h index 0c27e20..6a26bcd 100644 --- a/paintwindow.h +++ b/paintwindow.h @@ -7,6 +7,7 @@ #include "paintscene.h" #include "messagedialog.h" + namespace Ui { class PaintWindow; } diff --git a/rectangle.cpp b/rectangle.cpp index 20778ce..6ceab68 100644 --- a/rectangle.cpp +++ b/rectangle.cpp @@ -3,6 +3,7 @@ #include #include "commands.h" + Rectangle::Rectangle(QPointF point,QColor color,int LineWeight, QColor fillColor, QObject *parent) : Figure(point,parent) { diff --git a/rectangle.h b/rectangle.h index 9057cd2..c600acb 100644 --- a/rectangle.h +++ b/rectangle.h @@ -5,6 +5,7 @@ #include #include "figure.h" + class Rectangle : public Figure { Q_OBJECT diff --git a/triangle.cpp b/triangle.cpp index 7e5b279..4ad0a2f 100644 --- a/triangle.cpp +++ b/triangle.cpp @@ -1,6 +1,7 @@ #include "triangle.h" #include + Triangle::Triangle(QPointF point,QColor color,int LineWeight, QColor fillColor, QObject *parent) : Figure(point,parent) { diff --git a/triangle.h b/triangle.h index 620802d..e3807f8 100644 --- a/triangle.h +++ b/triangle.h @@ -5,6 +5,7 @@ #include #include "figure.h" + class Triangle : public Figure { Q_OBJECT diff --git a/welcomewindow.cpp b/welcomewindow.cpp index d2ac335..58d1842 100644 --- a/welcomewindow.cpp +++ b/welcomewindow.cpp @@ -2,6 +2,7 @@ #include "ui_welcomewindow.h" #include + WelcomeWindow::WelcomeWindow(QWidget *parent) : QMainWindow(parent, Qt::FramelessWindowHint | Qt::WindowSystemMenuHint), ui(new Ui::WelcomeWindow) diff --git a/welcomewindow.h b/welcomewindow.h index 63808b6..c026e30 100644 --- a/welcomewindow.h +++ b/welcomewindow.h @@ -4,6 +4,7 @@ #include #include "paintwindow.h" + namespace Ui { class WelcomeWindow; }