Ejemplo n.º 1
0
MainWindow::MainWindow(QWidget *parent) :
   QMainWindow(parent),
   ui(new Ui::MainWindow),
   theCurImageIndex(0),
   theProcessingInProgressFlag(false)
{
   ui->setupUi(this);

   theDragModeStrings.insert(QGraphicsView::NoDrag, "No Drag Mode");
   theDragModeStrings.insert(QGraphicsView::RubberBandDrag, "Selection Mode");
   theDragModeStrings.insert(QGraphicsView::ScrollHandDrag, "Scroll Mode");

   connect(ui->thePic, SIGNAL(scrollModeChanged(QGraphicsView::DragMode)),
           this, SLOT(updateStatusBar(QGraphicsView::DragMode)));

   connect(ui->thePic, SIGNAL(rectangleSelected(QPoint,QPoint)),
           this, SLOT(rectangleSelection(QPoint,QPoint)));

   // List manipulation button handlers
   connect(ui->theUpButton, SIGNAL(clicked()),
           this, SLOT(movePageSelectionUp()));
   connect(ui->theDownButton, SIGNAL(clicked()),
           this, SLOT(movePageSelectionDown()));
   connect(ui->theDeleteButton, SIGNAL(clicked()),
           this, SLOT(deletePageSelection()));

   // Want to know when the Process Images button should be enabled.  The rectangleSelection and deletePageSelection
   // button are the two buttons that effect the number of items in the list
   connect(ui->thePic, SIGNAL(rectangleSelected(QPoint,QPoint)),
           this, SLOT(isImageProcessingAllowed()));
   connect(ui->theDeleteButton, SIGNAL(clicked()),
           this, SLOT(isImageProcessingAllowed()));

   connect(ui->theNextImageButton, SIGNAL(clicked()),
           this, SLOT(nextImage()));
   connect(ui->thePreviousImageButton, SIGNAL(clicked()),
           this, SLOT(previousImage()));

   connect(ui->theProcessImagesButton, SIGNAL(clicked()),
           this, SLOT(processImages()));
   connect(ui->theWritePdfButton, SIGNAL(clicked()),
           this, SLOT(writePdf()));

   // Connect menu buttons
   connect(ui->actionAbout, SIGNAL(triggered()),
           this, SLOT(showAboutDialog()));
   connect(ui->actionAbout_Qt, SIGNAL(triggered()),
           this, SLOT(showAboutQtDialog()));
   connect(ui->actionStart_Server, SIGNAL(triggered()),
           this, SLOT(startServerDialog()));
   connect(ui->actionOpen_Directory, SIGNAL(triggered()),
           this, SLOT(openDirectoryChooser()));

   updateStatusBar(ui->thePic->dragMode());
}
Ejemplo n.º 2
0
void MainWindow::crop(QRect rect)
{
  int index = ui->imagesTabWidget->currentIndex();
  QString name = ui->imagesTabWidget->tabText(index);

  if (rect.width() != 0 && rect.height() != 0) {
    cv::Rect roi(rect.x(), rect.y(), rect.width(), rect.height());
    cv::Mat mat = workingImage->current(roi);

    Image* newImage = new Image(mat, this);
    images.push_back(newImage);

    ui->imagesTabWidget->insertTab(++index, newImage, name + " (crop)");
  }

  enableAllTabs();
  enableAllOperations();

  disconnect(workingImage,  SIGNAL(rectangleSelected(QRect)),
             this,          SLOT(crop(QRect)));

  disconnect(workingImage,  SIGNAL(status(QString)),
             ui->statusBar, SLOT(showMessage(QString)));

  ui->statusBar->clearMessage();
}
Ejemplo n.º 3
0
void MainWindow::on_actionCrop_triggered()
{
  if (workingImage) {
    disableOtherTabs();
    setOperationsEnabled(false);

    connect(workingImage, SIGNAL(rectangleSelected(QRect)),
            this,         SLOT(crop(QRect)));

    connect(workingImage,   SIGNAL(status(QString)),
            ui->statusBar,  SLOT(showMessage(QString)));

    workingImage->setSelectionMode(Image::Rectangle);
  }
}
Ejemplo n.º 4
0
void DisplayWidget::mouseReleaseEvent(QMouseEvent *event)
{
    QRect rubberRect = QRect(origin, event->pos()).normalized();
    emit rectangleSelected(rubberRect);
}