mainwindow.cc 14.5 KB
Newer Older
Guillaume Lazzara's avatar
Guillaume Lazzara committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena 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, version 2 of the License.
//
// Olena 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 Olena.  If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction.  Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License.  This
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.

#include <QtCore>
#include <QtGui>

#include <mln/core/image/image2d.hh>
#include <mln/logical/not.hh>
#include <mln/io/pbm/all.hh>

#include <src/mainwindow.hh>


const char * modes[][4] = {
Guillaume Lazzara's avatar
Guillaume Lazzara committed
37
38
  { "Text in pictures", "pics", "../src/text_in_photo_ppm", "image-x-generic.png" },
  { "Text in docs", "doc", "../src/text_in_doc", "edit-find.png" },
Guillaume Lazzara's avatar
Guillaume Lazzara committed
39
  { (const char *)(1), 0, 0, 0}, // Separator
Guillaume Lazzara's avatar
Guillaume Lazzara committed
40
41
  { "Handwritten text lines", "hsc", "../../milena/sandbox/icdar/2009/hsc/input_to_lines", "text-x-generic.png" },
  { "Handwritten text words", "hsc", "../../milena/sandbox/icdar/2009/hsc/input_to_words", "text-x-generic.png" },
Guillaume Lazzara's avatar
Guillaume Lazzara committed
42
  { (const char *)(1), 0, 0, 0}, // Separator
Guillaume Lazzara's avatar
Guillaume Lazzara committed
43
44
45
46
  { "Horizontal and Vertical Lines", "hvl", "../src/extract/primitive/find_discontinued_lines", "list-add.png" },
  { "Tables", "hvl", "../src/table/extract", "x-office-spreadsheet.png" },
  { "Pre-processing", "pproc", "../src/preprocess", "format-indent-more.png" },
  { "OCR", "ocr", "../src/recognition", "edit-find.png" },
Guillaume Lazzara's avatar
Guillaume Lazzara committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
  { 0, 0, 0 } // Empty line, do NOT delete.
};


// Allow to set up to 3 extra arguments to the binaries.
//
// A program will be launched as follow:
//
//    ./my_program input.pbm <arg1> <arg2> <arg3> output.ppm
//
// Unused arguments are set to 0.
// Each line must be mapped to the related on in the previous
// array "modes". So DO preserve the order.
//
const char *args_list[][3] = {
  { 0, 0, 0 }, // Text in Pictures
Guillaume Lazzara's avatar
Guillaume Lazzara committed
63
  { 0, 0, 0 }, // Text in Docs
Guillaume Lazzara's avatar
Guillaume Lazzara committed
64
65
66
67
  { (const char *)(1), 0, 0}, // Separator
  { "/dev/null",  0,  0 }, // Handwritten text lines
  { "/dev/null",  0,  0 }, // Handwritten text words
  { (const char *)(1), 0, 0}, // Separator
Guillaume Lazzara's avatar
Guillaume Lazzara committed
68
  { "51", 0, 0 }, // Horizontal and Vertical lines
Guillaume Lazzara's avatar
Guillaume Lazzara committed
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
  { "/dev/null",  0,  0 }, // Tables
  { 0, 0, 0 }, // Pre-processing
  { 0, 0, 0 }, // OCR
  // Not empty line needed.
};



namespace scribo
{

  namespace demo
  {

    MainWindow::MainWindow(QWidget *parent)
      : QMainWindow(parent), context_(this)
    {
      setupUi(this);

Guillaume Lazzara's avatar
Guillaume Lazzara committed
88
89
90
91
92
93
94
95
      unsigned nmodes = 0;
      for (unsigned i = 0; modes[i][0] != 0; ++i)
	++nmodes;

      cached_result_.resize(nmodes);
      mainRefItem_ = 0;
      mainResultItem_ = 0;
      exec_prefix_ = "";
Guillaume Lazzara's avatar
Guillaume Lazzara committed
96
97
      base_img_dir_ = QCoreApplication::applicationDirPath();

Guillaume Lazzara's avatar
Guillaume Lazzara committed
98
99
100
101
      pdialog_.setRange(0,0);
      pdialog_.setLabelText(tr("Please wait while computing..."));
      pdialog_.setWindowModality(Qt::WindowModal);

Guillaume Lazzara's avatar
Guillaume Lazzara committed
102
103
      exec_.setReadChannel(QProcess::StandardOutput);

Guillaume Lazzara's avatar
Guillaume Lazzara committed
104
105
      qDebug() << "Cache located in " << QDir::tempPath();

Guillaume Lazzara's avatar
Guillaume Lazzara committed
106
107
108
109
110
      connect(&pdialog_, SIGNAL(canceled()), this, SLOT(compute_canceled()));

      connect(&context_, SIGNAL(triggered(QAction *)),
	      this, SLOT(context_changed(QAction *)));

Guillaume Lazzara's avatar
Guillaume Lazzara committed
111
112
113
114
115
116
117
118
119
120
      connect(imageResult->verticalScrollBar(), SIGNAL(valueChanged(int)),
	      this, SLOT(move_vertical_sliders(int)));
      connect(imageResult->horizontalScrollBar(), SIGNAL(valueChanged(int)),
	      this, SLOT(move_horizontal_sliders(int)));
      connect(imageRef->verticalScrollBar(), SIGNAL(valueChanged(int)),
	      this, SLOT(move_vertical_sliders(int)));
      connect(imageRef->horizontalScrollBar(), SIGNAL(valueChanged(int)),
	      this, SLOT(move_horizontal_sliders(int)));
      connect(&timer_, SIGNAL(timeout()), this, SLOT(timer_timeout()));

Guillaume Lazzara's avatar
Guillaume Lazzara committed
121
122
      connect_compute_process();

Guillaume Lazzara's avatar
Guillaume Lazzara committed
123
124
      context_.setExclusive(true);

Guillaume Lazzara's avatar
Guillaume Lazzara committed
125
126
127
      // No status bar.
      setStatusBar(0);

Guillaume Lazzara's avatar
Guillaume Lazzara committed
128
129
130
131
      initToolBar();
      setup_scene();
    }

Guillaume Lazzara's avatar
Guillaume Lazzara committed
132
133
134
135
136
137
138
139
140
141
142
    MainWindow::~MainWindow()
    {
      for (int i = 0; i < cached_result_.size(); ++i)
	foreach(QString value, cached_result_[i])
	{
	  QFile f(value);
	  f.remove();
	}
    }


Guillaume Lazzara's avatar
Guillaume Lazzara committed
143
144
145
146
147
148
    void MainWindow::set_base_img_dir(const QString& dir)
    {
      QDir d(dir);
      base_img_dir_ = d.absolutePath();
    }

Guillaume Lazzara's avatar
Guillaume Lazzara committed
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166

    void MainWindow::initToolBar()
    {
      QToolBar *tbar = new QToolBar("Tools");
      tbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);

      for (unsigned i = 0; modes[i][0]; ++i)
      {
	if (modes[i][0] == (const char *)(1))
	{
	  tbar->addSeparator();
	  continue;
	}

        QAction *action = tbar->addAction(modes[i][0]);
	context_.addAction(action);
	action->setCheckable(true);
	action->setData(i);
Guillaume Lazzara's avatar
Guillaume Lazzara committed
167
	action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0 + i));
Guillaume Lazzara's avatar
Guillaume Lazzara committed
168
	action->setEnabled(QFile::exists(modes[i][2]));
Guillaume Lazzara's avatar
Guillaume Lazzara committed
169
170
171
172
173
174
175
176
177
178
179
180
181

	if (modes[i][3] != 0)
	  action->setIcon(QIcon(QString(":/icons/") + modes[i][3]));
      }

      addToolBar(Qt::TopToolBarArea, tbar);
      context_.actions().first()->trigger();
    }



    void MainWindow::on_browseBtn_clicked(bool)
    {
Guillaume Lazzara's avatar
Guillaume Lazzara committed
182
      QString current_dir = current_mode() + "/";
Guillaume Lazzara's avatar
Guillaume Lazzara committed
183
184
185
186

      QString
	filename = QFileDialog::getOpenFileName(this,
	  tr("Open Image."),
Guillaume Lazzara's avatar
Guillaume Lazzara committed
187
	  base_img_dir_ + "/" + current_dir,
Guillaume Lazzara's avatar
Guillaume Lazzara committed
188
189
	  tr("Images (*.pbm *.pgm *.ppm)"));

Guillaume Lazzara's avatar
Guillaume Lazzara committed
190
191
192
193
194
      prepare_for_run(filename);
    }

    void MainWindow::prepare_for_run(const QString& filename)
    {
Guillaume Lazzara's avatar
Guillaume Lazzara committed
195
196
197
      if (!filename.isEmpty())
      {
        filepath->setText(filename);
Guillaume Lazzara's avatar
Guillaume Lazzara committed
198
199
200
201
202
203

	update_pixmap(imageRef, filename);
	update_pixmap(imageResult);

	if (autoRun->isChecked())
	  on_runBtn_clicked();
Guillaume Lazzara's avatar
Guillaume Lazzara committed
204
205
206
      }
    }

Guillaume Lazzara's avatar
Guillaume Lazzara committed
207
    void MainWindow::on_runBtn_clicked()
Guillaume Lazzara's avatar
Guillaume Lazzara committed
208
    {
Guillaume Lazzara's avatar
Guillaume Lazzara committed
209
210
      if (useCache->isChecked()
	  && cached_result_[mode_].contains(filepath->text()))
Guillaume Lazzara's avatar
Guillaume Lazzara committed
211
212
213
214
215
216
      {
	last_output_ = cached_result_[mode_][filepath->text()];
	exec_finished(0, QProcess::NormalExit);
	return;
      }

Guillaume Lazzara's avatar
Guillaume Lazzara committed
217
218
219
      wait_for_result();

      QStringList args;
Guillaume Lazzara's avatar
Guillaume Lazzara committed
220
221
222
223

      QString input = filepath->text();

      args << input;
Guillaume Lazzara's avatar
Guillaume Lazzara committed
224
225
226
      for (unsigned i = 0; args_list[mode_][i]; ++i)
	args << args_list[mode_][i];

Guillaume Lazzara's avatar
Guillaume Lazzara committed
227
228
//      if (!is_in_ocr_mode())
//      {
Guillaume Lazzara's avatar
Guillaume Lazzara committed
229
230
231
232
      QTemporaryFile f;
      f.open();
      args << f.fileName();
      last_output_ = f.fileName();
Guillaume Lazzara's avatar
Guillaume Lazzara committed
233
//      }
Guillaume Lazzara's avatar
Guillaume Lazzara committed
234

Guillaume Lazzara's avatar
Guillaume Lazzara committed
235
236
//      reset_progress_dialog();

Guillaume Lazzara's avatar
Guillaume Lazzara committed
237
238
239
240
241
242
      exec_.start(exec_prefix_ + modes[mode_][2], args);
    }


    void MainWindow::on_displayBtn_clicked(bool)
    {
Guillaume Lazzara's avatar
Guillaume Lazzara committed
243
      update_pixmap(imageRef, filepath->text());
Guillaume Lazzara's avatar
Guillaume Lazzara committed
244
245
246
247
248
249
250
251
252
253
254
255
    }


    void MainWindow::on_filepath_textChanged()
    {
      bool b = !filepath->text().isEmpty();

      runBtn->setEnabled(b);
      displayBtn->setEnabled(b);
    }


Guillaume Lazzara's avatar
Guillaume Lazzara committed
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
    void MainWindow::on_zoomIn_clicked()
    {
	imageResult->scale(1.2, 1.2);
	imageRef->scale(1.2, 1.2);
    }

    void MainWindow::on_zoomOut_clicked()
    {
	imageResult->scale(1 / 1.2, 1 / 1.2);
	imageRef->scale(1 / 1.2, 1 / 1.2);
    }

    QGraphicsItem *& MainWindow::view_to_item(QGraphicsView *view)
    {
      if (view == imageResult)
	return mainResultItem_;
      else
	return mainRefItem_;
    }

    void MainWindow::update_pixmap(QGraphicsView* view, const QString& name)
Guillaume Lazzara's avatar
Guillaume Lazzara committed
277
    {
Guillaume Lazzara's avatar
Guillaume Lazzara committed
278
279
280
281
282
283
284
285
      if (name.isEmpty())
      {
	update_status_message("");
	return;
      }

      QGraphicsItem* item = view_to_item(view);

Guillaume Lazzara's avatar
Guillaume Lazzara committed
286
287
288
289
290
291
292
293
      QPixmap pixmap;
      if (!pixmap.load(name))
      {
	qDebug() << "Invalid file format!";
	update_status_message(tr("Invalid file format!"));
	return;
      }

Guillaume Lazzara's avatar
Guillaume Lazzara committed
294
295
296
      QFileInfo finfo(name);
      if (item != mainResultItem_ && current_mode() != "hsc"
	  && current_mode() != "pproc"
Guillaume Lazzara's avatar
Guillaume Lazzara committed
297
298
	  && (current_mode() != "pics" || finfo.suffix() == "pbm")
	  && ! is_in_doc_mode())
Guillaume Lazzara's avatar
Guillaume Lazzara committed
299
300
301
302
303
304
305
306
307
308
309
310
311
312
      {
	QImage image(pixmap.toImage());
	image.invertPixels();
	pixmap = QPixmap::fromImage(image);
      }

      if (item != 0)
      {
	view->scene()->removeItem(item);
	delete item;
      }
      item = view->scene()->addPixmap(pixmap);
      view->scene()->setSceneRect(item->boundingRect());
      Q_ASSERT(item != 0);
Guillaume Lazzara's avatar
Guillaume Lazzara committed
313
314
      if (pixmap.width() > view->maximumViewportSize().width())
	view->fitInView(item->boundingRect(), Qt::KeepAspectRatio);
Guillaume Lazzara's avatar
Guillaume Lazzara committed
315
316
317
318
319
320
321
322
      view_to_item(view) = item;

      bool b = (mainResultItem_ != 0 || mainRefItem_ != 0);
      zoomLabel->setEnabled(b);
      zoomIn->setEnabled(b);
      zoomOut->setEnabled(b);
      zoomFixed->setEnabled(b);
      zoomOriginal->setEnabled(b);
Guillaume Lazzara's avatar
Guillaume Lazzara committed
323
324
325
326
327
328
329
330
331
332
    }


    void MainWindow::exec_finished(int rvalue, QProcess::ExitStatus status)
    {
      pdialog_.hide();
      if (rvalue == 0)
      {
	if (status != QProcess::CrashExit)
	{
Guillaume Lazzara's avatar
Guillaume Lazzara committed
333
334
335
	  if (useCache->isChecked())
	    cached_result_[mode_][filepath->text()] = last_output_;

Guillaume Lazzara's avatar
Guillaume Lazzara committed
336
	  setEnabled(true);
Guillaume Lazzara's avatar
Guillaume Lazzara committed
337
	  if (is_in_ocr_mode() || is_in_doc_mode())
Guillaume Lazzara's avatar
Guillaume Lazzara committed
338
	  {
Guillaume Lazzara's avatar
Guillaume Lazzara committed
339
340
341
342
	    QFile f(last_output_);
	    f.open(QIODevice::ReadOnly);
	    textBrowser->setText(QString::fromUtf8(f.readAll().data()));
//	    textBrowser->setText(exec_.readAllStandardOutput());
Guillaume Lazzara's avatar
Guillaume Lazzara committed
343
344
345
346
	    on_displayBtn_clicked(true);
	    tabWidget->setCurrentIndex(1);
	  }
	  else
Guillaume Lazzara's avatar
Guillaume Lazzara committed
347
	    update_pixmap(imageResult, last_output_);
Guillaume Lazzara's avatar
Guillaume Lazzara committed
348
349
350
351
352
	}
	// Else : canceled.
      }
      else
	exec_error(tr("Error during last run."));
Guillaume Lazzara's avatar
Guillaume Lazzara committed
353
354
355
356

      imageResult->setFocus();
      if (autoDemo->isChecked())
	timer_.start(timeoutDelay->text().toInt() * 1000);
Guillaume Lazzara's avatar
Guillaume Lazzara committed
357
358
359
360
361
362
363
364
    }


    void MainWindow::setup_scene()
    {
      QGraphicsScene *scene = new QGraphicsScene();
      imageResult->setScene(scene);

Guillaume Lazzara's avatar
Guillaume Lazzara committed
365
366
367
      scene = new QGraphicsScene();
      imageRef->setScene(scene);

Guillaume Lazzara's avatar
Guillaume Lazzara committed
368
369
370
371
      update_status_message(tr("1) Choose an algorithm.\n\
2) Select an image.\n3) Run."));

      imageResult->show();
Guillaume Lazzara's avatar
Guillaume Lazzara committed
372
      imageRef->show();
Guillaume Lazzara's avatar
Guillaume Lazzara committed
373
374
375
376
377
    }


    void MainWindow::wait_for_result()
    {
Guillaume Lazzara's avatar
Guillaume Lazzara committed
378
379
      reset_progress_dialog();

Guillaume Lazzara's avatar
Guillaume Lazzara committed
380
381
382
      pdialog_.show();
      setEnabled(false);

Guillaume Lazzara's avatar
Guillaume Lazzara committed
383
      if (!is_in_ocr_mode() && !is_in_ocr_mode())
Guillaume Lazzara's avatar
Guillaume Lazzara committed
384
	update_status_message("");
Guillaume Lazzara's avatar
Guillaume Lazzara committed
385
386
387
388
389
    }


    void MainWindow::update_status_message(const QString& msg)
    {
Guillaume Lazzara's avatar
Guillaume Lazzara committed
390
391
392
393
394
395
      if (mainResultItem_ != 0)
      {
	imageResult->scene()->removeItem(mainResultItem_);
	delete mainResultItem_;
      }
      mainResultItem_ = imageResult->scene()->addText(msg);
Guillaume Lazzara's avatar
Guillaume Lazzara committed
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
    }


    void MainWindow::exec_error(const QString& msg)
    {
      setEnabled(true);
      QMessageBox::critical(0, tr("Error!"),
			    tr("The result cannot be computed!"));
      update_status_message(msg);
      qDebug() << exec_.readAllStandardOutput();
    }

    void MainWindow::exec_error(QProcess::ProcessError error)
    {
      if (error == QProcess::FailedToStart)
        exec_error(tr("This program does not exist: ")
		    + exec_prefix_ + modes[mode_][2]);
      else
Guillaume Lazzara's avatar
Guillaume Lazzara committed
414
415
        exec_error(tr("The computation stopped.")
		    + exec_prefix_ + modes[mode_][2]);
Guillaume Lazzara's avatar
Guillaume Lazzara committed
416
417
418
419
420
421
422
    }


    void MainWindow::context_changed(QAction *action)
    {
      mode_ = action->data().toInt();
      filepath->clear();
Guillaume Lazzara's avatar
Guillaume Lazzara committed
423
      tabWidget->setTabEnabled(1, is_in_ocr_mode() || is_in_doc_mode());
Guillaume Lazzara's avatar
Guillaume Lazzara committed
424
425
426
427
428
429
    }


    void MainWindow::compute_canceled()
    {
      setEnabled(true);
Guillaume Lazzara's avatar
Guillaume Lazzara committed
430
431

      exec_.disconnect();
Guillaume Lazzara's avatar
Guillaume Lazzara committed
432
      exec_.kill();
Guillaume Lazzara's avatar
Guillaume Lazzara committed
433
434
      connect_compute_process();

Guillaume Lazzara's avatar
Guillaume Lazzara committed
435
436
437
438
      update_status_message("Computation canceled.");
    }


Guillaume Lazzara's avatar
Guillaume Lazzara committed
439
    bool MainWindow::is_in_ocr_mode() const
Guillaume Lazzara's avatar
Guillaume Lazzara committed
440
    {
Guillaume Lazzara's avatar
Guillaume Lazzara committed
441
442
443
      return current_mode() == "ocr";
    }

Guillaume Lazzara's avatar
Guillaume Lazzara committed
444
445
446
447
448
449
450
451
452
453
    bool MainWindow::is_in_pics_mode() const
    {
      return current_mode() == "pics";
    }

    bool MainWindow::is_in_doc_mode() const
    {
      return current_mode() == "doc";
    }

Guillaume Lazzara's avatar
Guillaume Lazzara committed
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539

    void MainWindow::resize_pixmaps(const QRectF& rect)
    {
      if (mainRefItem_ != 0)
	imageRef->fitInView(rect, Qt::KeepAspectRatio);
      if (mainResultItem_ != 0)
	imageResult->fitInView(rect, Qt::KeepAspectRatio);
    }

    void MainWindow::move_vertical_sliders(int value)
    {
      imageRef->verticalScrollBar()->setValue(value);
      imageResult->verticalScrollBar()->setValue(value);
    }

    void MainWindow::move_horizontal_sliders(int value)
    {
      imageRef->horizontalScrollBar()->setValue(value);
      imageResult->horizontalScrollBar()->setValue(value);
    }


    void MainWindow::on_zoomFixed_clicked()
    {
      resize_pixmaps(mainRefItem_->boundingRect());
    }

    void MainWindow::on_zoomOriginal_clicked()
    {
      resize_pixmaps(imageResult->viewport()->geometry());
    }

    void MainWindow::on_autoDemo_clicked(bool checked)
    {
      if (checked)
	timer_.start(100);
      else
	timer_.stop();
    }

    void MainWindow::resizeEvent(QResizeEvent * event)
    {
      if (mainRefItem_ != 0)
	resize_pixmaps(mainRefItem_->boundingRect());
      event->ignore();
    }

    void MainWindow::keyPressEvent(QKeyEvent *event)
    {
      if (event->text() == QString("+"))
      {
	on_zoomIn_clicked();
	event->accept();
      }
      else if (event->text() == QString("-"))
      {
	on_zoomOut_clicked();
	event->accept();
      }
      else
	event->ignore();
    }

    QString MainWindow::current_mode() const
    {
      return modes[mode_][1];
    }

    void MainWindow::timer_timeout()
    {
      update_auto_demo_dir();
      timer_.stop();
      prepare_for_run(demoDir_.absolutePath() + "/"
		      + demo_files_[demo_index_]);
      demo_index_ = (demo_index_ + 1) % demo_files_.size();
    }

    void MainWindow::update_auto_demo_dir()
    {
      QString tmp_path = base_img_dir_ + "/" + current_mode();
      if (demoDir_.path() != tmp_path)
      {
	demoDir_.setPath(tmp_path);
	demo_index_ = 0;
	demo_files_ = demoDir_.entryList(QDir::NoDotAndDotDot | QDir::Files);
      }
Guillaume Lazzara's avatar
Guillaume Lazzara committed
540
541
    }

Guillaume Lazzara's avatar
Guillaume Lazzara committed
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567

    void MainWindow::update_process_status()
    {
      if (is_in_pics_mode() || is_in_doc_mode())
	pdialog_.setLabelText(tr(exec_.readAllStandardOutput()));
    }


    void MainWindow::reset_progress_dialog()
    {
      pdialog_.reset();
      pdialog_.setLabelText(tr("Please wait while computing..."));
    }


    void MainWindow::connect_compute_process()
    {
      connect(&exec_, SIGNAL(finished(int, QProcess::ExitStatus)),
	      this, SLOT(exec_finished(int, QProcess::ExitStatus)));
      connect(&exec_, SIGNAL(error(QProcess::ProcessError)),
	      this, SLOT(exec_error(QProcess::ProcessError)));
      connect(&exec_, SIGNAL(readyReadStandardOutput()),
	      this, SLOT(update_process_status()));
    }


Guillaume Lazzara's avatar
Guillaume Lazzara committed
568
569
570
  } // end of namespace scribo::demo

} // end of namespace scribo