void ImageFilterExampleWidget::open() {
//    this->objPath=QFileDialog::getOpenFileName(this,"Open Image File",QDir::homePath(),"Image files (*.png *.jpg *.jpeg)");

    this->objPath = "";
    QStringList filenames;
    QFileDialog* fileDialog= new QFileDialog(this,"Open Image File",QDir::homePath(),"Image files (*.png *.jpg *.jpeg)");
    if(fileDialog->exec())
    {
        filenames = fileDialog->selectedFiles();
        fileDialog->hide();
        fileDialog->setHidden(true);
        delete fileDialog;
    }
    if(!filenames.isEmpty())
    {
        this->objPath = filenames[0];
    }
    if(!isFileValid())
        this->objPath="";
    if(isFileValid())
    {
        QImage* image = new QImage(objPath);
        beforeW->setFixedSize(400,image->height()*400/image->width());
        beforeW->setImage(image);
        beforeW->repaint(); //call repaint event so that the widget redraws
        processImages();
    }
}
Exemplo n.º 2
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());
}
Exemplo n.º 3
0
void ExportDbDlg::onExport(wxCommandEvent &)
{
    if(m_title->GetValue().IsEmpty())
    {
        wxMessageDialog message(this, _("Please enter a title for your document"));
        message.ShowModal();
    }
    else if(m_languages->GetSelection() == wxNOT_FOUND)
    {
        wxMessageDialog message(this, _("Please select a language for your document"));
        message.ShowModal();
    }
    else
    {
        LoginDlg loginDlg(this);
        if(loginDlg.ShowModal() == wxID_OK)
        {
            if(m_medocDb.checkUser(loginDlg.getLogin(),
                                   loginDlg.getPassword()))
            {
                wxString tesseractLanguage;
                wxString postgresLanguage;
                getCurrentLanguage(tesseractLanguage, postgresLanguage);
                m_medocDb.createDocument(m_title->GetValue(),
                                         m_calendar->GetDate(),
                                         postgresLanguage,
                                         processImages(tesseractLanguage),
                                         loginDlg.getPassword());
            }
            else
            {
                wxMessageDialog message(this, _("Bad key"));
                message.ShowModal();
            }
        }
        EndModal(wxID_OK);
    }
}
void ImageFilterExampleWidget::embossinImage() {
    curFilter = EMBOSSING;
    processImages();
}
void ImageFilterExampleWidget::blurImage() {
    curFilter = BLUR;
    processImages();
}
void ImageFilterExampleWidget::sharpingImage() {
    curFilter = SHARPING;
    processImages();
}
Exemplo n.º 7
0
/* Computation functions */
static PyObject* ccdToQ(PyObject *self, PyObject *args, PyObject *kwargs){
  PyArrayObject *angles = NULL;
  PyObject *_angles = NULL;
  PyArrayObject *ubinv = NULL;
  PyObject *_ubinv = NULL;
  PyArrayObject *qOut = NULL;
  CCD ccd;
  npy_intp dims[2];
  npy_intp nimages;
  int retval;

  int mode;

  double lambda;

  double *anglesp = NULL;
  double *qOutp = NULL;
  double *ubinvp = NULL;
  double *delgam = NULL;

  static char *kwlist[] = { "angles", "mode", "ccd_size", "ccd_pixsize",
			                      "ccd_cen", "dist", "wavelength",
			                      "UBinv", NULL };

  if(!PyArg_ParseTupleAndKeywords(args, kwargs, "Oi(ii)(dd)(dd)ddO", kwlist,
				                          &_angles,
				                          &mode,
				                          &ccd.xSize, &ccd.ySize,
				                          &ccd.xPixSize, &ccd.yPixSize,
				                          &ccd.xCen, &ccd.yCen,
				                          &ccd.dist,
				                          &lambda,
				                          &_ubinv)){

    return NULL;
  }

  ccd.size = ccd.xSize * ccd.ySize;

  angles = (PyArrayObject*)PyArray_FROMANY(_angles, NPY_DOUBLE, 2, 2, NPY_ARRAY_IN_ARRAY);
  if(!angles){
    goto cleanup;
  }

  ubinv = (PyArrayObject*)PyArray_FROMANY(_ubinv, NPY_DOUBLE, 2, 2, NPY_ARRAY_IN_ARRAY);
  if(!ubinv){
    goto cleanup;
  }

  ubinvp = (double *)PyArray_DATA(ubinv);

  nimages = PyArray_DIM(angles, 0);

  dims[0] = nimages * ccd.size;
  dims[1] = 3;

  qOut = (PyArrayObject*)PyArray_SimpleNew(2, dims, NPY_DOUBLE);
  if(!qOut){
    goto cleanup;
  }

  anglesp = (double *)PyArray_DATA(angles);
  qOutp = (double *)PyArray_DATA(qOut);

  // Now create the arrays for delta-gamma pairs
  delgam = (double*)malloc(nimages * ccd.size * sizeof(double) * 2);
  if(!delgam){
    goto cleanup;
  }

  // Ok now we don't touch Python Object ... Release the GIL
  Py_BEGIN_ALLOW_THREADS

  retval = processImages(delgam, anglesp, qOutp, lambda, mode, (unsigned long)nimages,
                         ubinvp, &ccd);

  // Now we have finished with the magic ... Obtain the GIL
  Py_END_ALLOW_THREADS

  if(retval){
    PyErr_SetString(PyExc_RuntimeError, "Error processing images");
    goto cleanup;
  }

  Py_XDECREF(ubinv);
  Py_XDECREF(angles);
  if(delgam) free(delgam);
  return Py_BuildValue("N", qOut);

 cleanup:
  Py_XDECREF(ubinv);
  Py_XDECREF(angles);
  Py_XDECREF(qOut);
  if(delgam) free(delgam);
  return NULL;
}