Parcourir la source

graphical bug solved

Rémi Synave il y a 6 mois
Parent
commit
ba42c48472
7 fichiers modifiés avec 39 ajouts et 6 suppressions
  1. 24 1
      WorkArea/WorkArea.cpp
  2. 2 1
      WorkArea/WorkArea.hpp
  3. 2 2
      clf/MainWindow.cpp
  4. 2 2
      clf/MainWindow.hpp
  5. 1 0
      csl/Experiment.hpp
  6. 7 0
      dsl/MainWindow.cpp
  7. 1 0
      dsl/MainWindow.hpp

+ 24 - 1
WorkArea/WorkArea.cpp

@@ -149,6 +149,29 @@ WorkArea::saveStrengthLine (const std::string & filename)
 
 void
 WorkArea::exportPNG (const std::string & filename)
+{
+  QImage tempImg(*original);
+  QPainter painter(&tempImg);
+
+  for (int i = 0; i < liste_points.length (); i++)
+    {
+      if ((i % 2) == 1)
+	{
+	  painter.setPen (QPen (Qt::red, epaisseurLigne/resizeFactor));
+	  std::pair < QPoint *, QPoint * > endPoints =
+	    StrengthLine (liste_points[i - 1], liste_points[i]).toDraw (tempImg.width()*resizeFactor, tempImg.height()*resizeFactor);
+
+	  painter.drawLine (*(std::get < 0 > (endPoints))/resizeFactor,
+			    *(std::get < 1 > (endPoints))/resizeFactor);
+	}
+
+    }
+  tempImg.save(QString::fromStdString (filename));
+  
+}
+
+void
+WorkArea::exportJPG (const std::string & filename)
 {
   QImage tempImg(*original);
   QPainter painter(&tempImg);
@@ -158,7 +181,7 @@ WorkArea::exportPNG (const std::string & filename)
 	{
 	  painter.setPen (QPen (Qt::red, epaisseurLigne/resizeFactor));
 	  std::pair < QPoint *, QPoint * > endPoints =
-	    StrengthLine (liste_points[i - 1], liste_points[i]).toDraw (&tempImg);
+	    StrengthLine (liste_points[i - 1], liste_points[i]).toDraw (tempImg.width()*resizeFactor, tempImg.height()*resizeFactor);
 	  painter.drawLine (*(std::get < 0 > (endPoints))/resizeFactor,
 			    *(std::get < 1 > (endPoints))/resizeFactor);
 	}

+ 2 - 1
WorkArea/WorkArea.hpp

@@ -45,7 +45,7 @@ class WorkArea: public QWidget
   
 private:
   const int taillePoint = 10;
-  const int epaisseurLigne = 3;
+  const int epaisseurLigne = 6;
   
   unsigned int screenSizeX, screenSizeY;
   bool readOnly;
@@ -79,6 +79,7 @@ public:
   void loadSL (const std::string & filename);
   void saveStrengthLine (const std::string & filename);
   void exportPNG (const std::string & filename);
+  void exportJPG (const std::string & filename);
   void setReadOnly(bool readOnly);
   bool getReadOnly();
   QImage* getOriginalImage() const;

+ 2 - 2
clf/MainWindow.cpp

@@ -64,7 +64,7 @@ MainWindow::MainWindow ()
 
   layoutV->addWidget(wa);
 
-  la = new QLabel(QString("Distance entre les deux lignes : ")+QString::number(wa->getDistance()), central);
+  la = new QLabel(QString("Distance entre les deux lignes : ")+QString::number(1-wa->getDistance()), central);
   layoutV->addWidget(la);
 
   connect (wa, SIGNAL(click()), this, SLOT(majDistance()));
@@ -75,6 +75,6 @@ MainWindow::MainWindow ()
 void
 MainWindow::majDistance()
 {
-  la->setText(QString("Distance entre les deux lignes : ")+QString::number(wa->getDistance()));
+  la->setText(QString("Distance entre les deux lignes : ")+QString::number(1-wa->getDistance()));
 }
 

+ 2 - 2
clf/MainWindow.hpp

@@ -40,8 +40,8 @@ class MainWindow: public QMainWindow
 
 
 private:
-  const int sizeX = 1000;
-  const int sizeY = 600;
+  const int sizeX = 800;
+  const int sizeY = 800;
   
   WorkArea *wa;
   QLabel *la;

+ 1 - 0
csl/Experiment.hpp

@@ -23,6 +23,7 @@ private:
   const int maxProgressBar = 100;
   const QString *suffix_IA = new QString("_algo");
   const QString *suffix_random = new QString("_random");
+  const QString *suffix_expert = new QString("_expert");
   QString *dataPath;
   QString *resultPath;
   int screenWidth, screenHeight;

+ 7 - 0
dsl/MainWindow.cpp

@@ -140,6 +140,13 @@ MainWindow::exportPNG ()
   wa->exportPNG (toSave.toStdString ());
 }
 
+void
+MainWindow::exportJPG ()
+{
+  QString toSave =  QDir::currentPath ().append("/").append(QFileInfo(filenames->at(openedImage)).baseName().append(*suffix).append(".jpg"));
+  wa->exportPNG (toSave.toStdString ());
+}
+
 QMessageBox::StandardButton
 MainWindow::checkModificationinProgress()
 {

+ 1 - 0
dsl/MainWindow.hpp

@@ -77,6 +77,7 @@ private slots:
   void openFile ();
   void save ();
   void exportPNG ();
+  void exportJPG ();
   void firstImage ();
   void previousImage ();
   void nextImage ();