Parcourir la source

Bug correction and adding vsl, a soft to visualize strength lines

Rémi Synave il y a 1 an
Parent
commit
dbc2c08a22
6 fichiers modifiés avec 169 ajouts et 0 suppressions
  1. 2 0
      csl/Experiment.cpp
  2. 1 0
      dsl/MainWindow.cpp
  3. 95 0
      vsl/MainWindow.cpp
  4. 42 0
      vsl/MainWindow.hpp
  5. 12 0
      vsl/main.cpp
  6. 17 0
      vsl/vsl.pro

+ 2 - 0
csl/Experiment.cpp

@@ -161,6 +161,8 @@ Experiment::openC (QString image, QString leftSL, QString rightSL){
   waRight->loadSL(rightSL.toStdString());
   waLeft->setReadOnly(true);
   waRight->setReadOnly(true);
+  waLeft->repaint();
+  waRight->repaint();
   setFixedSize (waLeft->geometry().width()*2+spaceInBetween, waLeft->geometry().height()+waLeft->geometry().y()+spaceInBetween+leftButton->geometry().height()+22); // +22 ??!!
 }
 

+ 1 - 0
dsl/MainWindow.cpp

@@ -40,6 +40,7 @@ MainWindow::open ()
 						   QObject::tr("Images files (*.jpg *.png);;All files (*.*)"));
   QDir::setCurrent(QString(filename).remove(QUrl(filename).fileName()));
   wa->loadImage (filename.toStdString ());
+  wa->repaint();
   setFixedSize (wa->geometry().width(), wa->geometry().height()+wa->geometry().y());
 }
 

+ 95 - 0
vsl/MainWindow.cpp

@@ -0,0 +1,95 @@
+#include <QGuiApplication>
+#include <QScreen>
+#include <QWidget>
+#include <QMenuBar>
+#include <QFileDialog>
+#include <QUrl>
+#include <QFileInfo>
+
+#include <QDebug>
+
+#include "MainWindow.hpp"
+
+
+MainWindow::MainWindow ()
+{
+  createActions ();
+  createMenus ();
+
+  setWindowTitle (tr ("DSL - Draw Strength Line"));
+
+  QScreen *screen = QGuiApplication::primaryScreen ();
+  QRect screenGeometry = screen->geometry ();
+  int screenWidth = screenGeometry.width () - 200;
+  int screenHeight = screenGeometry.height () - 200;
+  
+  wa = new WorkArea (screenWidth, screenHeight, this);
+  
+  setCentralWidget (wa);
+
+  setFixedSize (screenWidth, screenHeight);
+}
+
+void
+MainWindow::open ()
+{
+  filename = QFileDialog::getOpenFileName (this,
+						   QObject::
+						   tr ("Open image file"),
+						   QDir::currentPath (),
+						   QObject::tr("Images files (*.jpg *.png);;All files (*.*)"));
+  QDir::setCurrent(QString(filename).remove(QUrl(filename).fileName()));
+  QString SLFilename = QFileDialog::getOpenFileName (this,
+						     QObject::
+						     tr ("Open strength lines file"),
+						     QDir::currentPath (),
+						     QObject::
+						     tr
+						     ("Json files (*.json);;All files (*.*)"));
+  wa->loadImage (filename.toStdString ());
+  wa->loadSL(SLFilename.toStdString());
+  wa->setReadOnly(true);
+  wa->repaint();
+  setFixedSize (wa->geometry().width(), wa->geometry().height()+wa->geometry().y());
+}
+
+void
+MainWindow::save ()
+{
+  QString fileToSave = QFileDialog::getSaveFileName (this,
+						   QObject::tr ("Save file"),
+						   QDir::currentPath ().append("/").append(QFileInfo(filename).baseName()).append(".json"),
+						   QObject::tr("JSON file (*.json);;All files (*.*)"));
+  if(!fileToSave.endsWith(".json"))
+    fileToSave.append(".json");
+  wa->saveStrengthLine (fileToSave.toStdString ());
+}
+
+
+void
+MainWindow::createActions ()
+{
+  openAct = new QAction (tr ("&Open image"), this);
+  openAct->setShortcuts (QKeySequence::Open);
+  connect (openAct, &QAction::triggered, this, &MainWindow::open);
+
+  saveAct = new QAction (tr ("&Save"), this);
+  saveAct->setShortcuts (QKeySequence::Save);
+  connect (saveAct, &QAction::triggered, this, &MainWindow::save);
+
+  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->addAction (saveAct);
+
+  fileMenu->addSeparator ();
+
+  fileMenu->addAction (exitAct);
+}

+ 42 - 0
vsl/MainWindow.hpp

@@ -0,0 +1,42 @@
+#ifndef MAINWINDOW_HPP
+#define MAINWINDOW_HPP
+
+#include <QMainWindow>
+#include <QAction>
+#include <QMenu>
+#include <QString>
+
+#include "WorkArea.hpp"
+
+
+class MainWindow: public QMainWindow
+{
+  Q_OBJECT 
+
+
+private:
+  QMenu *fileMenu;
+
+  QAction *openAct;
+  QAction *saveAct;
+  QAction *exitAct;
+
+  WorkArea *wa;
+
+  QString filename;
+
+  void createActions ();
+  void createMenus ();
+
+		     
+private slots:
+  void open ();
+  void save ();
+
+  
+public:
+  MainWindow ();
+  
+};
+
+#endif

+ 12 - 0
vsl/main.cpp

@@ -0,0 +1,12 @@
+#include <QApplication>
+
+#include "MainWindow.hpp"
+
+int
+main (int argc, char *argv[])
+{
+  QApplication app (argc, argv);
+  MainWindow window;
+  window.show ();
+  return app.exec ();
+}

+ 17 - 0
vsl/vsl.pro

@@ -0,0 +1,17 @@
+QT += core gui widgets
+
+INCLUDEPATH = ../StrengthLine/ \
+              ../WorkArea/
+
+HEADERS = ../StrengthLine/StrengthLine.hpp \
+          ../WorkArea/WorkArea.hpp \
+          MainWindow.hpp
+                
+SOURCES = ../StrengthLine/StrengthLine.cpp \
+          ../WorkArea/WorkArea.cpp \
+          MainWindow.cpp \
+          main.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/dsl
+INSTALLS += target