|
@@ -0,0 +1,100 @@
|
|
|
+#include <QGuiApplication>
|
|
|
+#include <QScreen>
|
|
|
+#include <QWidget>
|
|
|
+#include <QMenuBar>
|
|
|
+#include <QFileDialog>
|
|
|
+#include <QHBoxLayout>
|
|
|
+#include <QPushButton>
|
|
|
+
|
|
|
+#include "MainWindow.hpp"
|
|
|
+
|
|
|
+
|
|
|
+MainWindow::MainWindow ()
|
|
|
+{
|
|
|
+ createActions ();
|
|
|
+ createMenus ();
|
|
|
+
|
|
|
+ setWindowTitle (tr ("DSL - Draw Strength Line"));
|
|
|
+
|
|
|
+ QScreen *screen = QGuiApplication::primaryScreen ();
|
|
|
+ QRect screenGeometry = screen->geometry ();
|
|
|
+ screenWidth = screenGeometry.width () - 200;
|
|
|
+ screenHeight = screenGeometry.height () - 200;
|
|
|
+
|
|
|
+ QWidget *central= new QWidget(this);
|
|
|
+ waLeft = new WorkArea ((screenWidth/2)-25, screenHeight, this);
|
|
|
+ waRight = new WorkArea ((screenWidth/2)-25, screenHeight, this);
|
|
|
+ QHBoxLayout *layout = new QHBoxLayout(this);
|
|
|
+ layout->addWidget(waLeft);
|
|
|
+ QPushButton *button = new QPushButton("coucou", this);
|
|
|
+ button->setFixedSize(QSize(50,20));
|
|
|
+ layout->addWidget(button);
|
|
|
+ layout->addWidget(waRight);
|
|
|
+ central->setLayout(layout);
|
|
|
+
|
|
|
+ setCentralWidget (central);
|
|
|
+
|
|
|
+ setFixedSize (screenWidth, screenHeight);
|
|
|
+}
|
|
|
+
|
|
|
+void
|
|
|
+MainWindow::open ()
|
|
|
+{
|
|
|
+ QString imageFilename = QFileDialog::getOpenFileName (this,
|
|
|
+ QObject::
|
|
|
+ tr ("Open image file"),
|
|
|
+ QDir::currentPath (),
|
|
|
+ QObject::
|
|
|
+ tr
|
|
|
+ ("Images files (*.jpg *.png);;All files (*.*)"));
|
|
|
+ QString SLLeftFilename = QFileDialog::getOpenFileName (this,
|
|
|
+ QObject::
|
|
|
+ tr ("Open strength lines file"),
|
|
|
+ QDir::currentPath (),
|
|
|
+ QObject::
|
|
|
+ tr
|
|
|
+ ("Text files (*.txt);;All files (*.*)"));
|
|
|
+ QString SLRightFilename = QFileDialog::getOpenFileName (this,
|
|
|
+ QObject::
|
|
|
+ tr ("Open strength lines file"),
|
|
|
+ QDir::currentPath (),
|
|
|
+ QObject::
|
|
|
+ tr
|
|
|
+ ("Text files (*.txt);;All files (*.*)"));
|
|
|
+
|
|
|
+ openC(imageFilename, SLLeftFilename, SLRightFilename);
|
|
|
+}
|
|
|
+
|
|
|
+void
|
|
|
+MainWindow::openC (QString image, QString leftSL, QString rightSL){
|
|
|
+ waLeft->loadImage (image.toStdString ());
|
|
|
+ waRight->loadImage (image.toStdString ());
|
|
|
+ waLeft->loadSL(leftSL.toStdString());
|
|
|
+ waRight->loadSL(rightSL.toStdString());
|
|
|
+ waLeft->setReadOnly(true);
|
|
|
+ waRight->setReadOnly(true);
|
|
|
+ setFixedSize (waLeft->geometry().width()*2+50, waLeft->geometry().height()+waLeft->geometry().y());
|
|
|
+}
|
|
|
+
|
|
|
+void
|
|
|
+MainWindow::createActions ()
|
|
|
+{
|
|
|
+ openAct = new QAction (tr ("&Open image"), this);
|
|
|
+ openAct->setShortcuts (QKeySequence::Open);
|
|
|
+ connect (openAct, &QAction::triggered, this, &MainWindow::open);
|
|
|
+
|
|
|
+ exitAct = new QAction (tr ("E&xit"), this);
|
|
|
+ exitAct->setShortcuts (QKeySequence::Quit);
|
|
|
+ connect (exitAct, &QAction::triggered, this, &QWidget::close);
|
|
|
+}
|
|
|
+
|
|
|
+void
|
|
|
+MainWindow::createMenus ()
|
|
|
+{
|
|
|
+ fileMenu = menuBar ()->addMenu (tr ("&File"));
|
|
|
+ fileMenu->addAction (openAct);
|
|
|
+
|
|
|
+ fileMenu->addSeparator ();
|
|
|
+
|
|
|
+ fileMenu->addAction (exitAct);
|
|
|
+}
|