Exemplo n.º 1
0
QString QG_FileDialog::getOpenFile(RS2::FormatType* type){
//    bool fileAccepted = false;
    setAcceptMode ( QFileDialog::AcceptOpen );
    // read default settings:
    RS_SETTINGS->beginGroup("/Paths");
    QString defDir = RS_SETTINGS->readEntry("/Open",
                                              RS_SYSTEM->getHomeDir());
    RS_SETTINGS->endGroup();

    RS_DEBUG->print("defDir: %s", defDir.toLatin1().data());
    QString fn = "";
    QStringList filters;
    filters << fDxfrw  << fDxf1 << fLff << fCxf << fJww;

    setWindowTitle(tr("Open %1").arg(name));
#if QT_VERSION >= 0x040400
    setNameFilters(filters);
#endif
    setDirectory(defDir);
    setFileMode(QFileDialog::ExistingFile);
#if QT_VERSION >= 0x040400
    selectNameFilter(fDxfrw);
#endif
    ftype= RS2::FormatDXFRW;
    RS_DEBUG->print("defFilter: %s", fDxfrw.toLatin1().data());

    /* preview RVT PORT preview is currently not supported by QT4
    RS_Graphic* gr = new RS_Graphic;
    QG_GraphicView* prev = new QG_GraphicView(parent);
    prev->setContainer(gr);
    prev->setBorders(1, 1, 1, 1);
    fileDlg->setContentsPreviewEnabled(true);
    fileDlg->setContentsPreview(prev, prev); */

    if (exec()==QDialog::Accepted) {
        QStringList fl = selectedFiles();
        if (!fl.isEmpty()) {
            fn = fl[0];
        }
        fn = QDir::toNativeSeparators( QFileInfo(fn).absoluteFilePath() );

        if (type!=NULL) {
                getType(selectedFilter());
                *type = ftype;
        }

    // store new default settings:
        RS_SETTINGS->beginGroup("/Paths");
        RS_SETTINGS->writeEntry("/Open", QFileInfo(fn).absolutePath());
        RS_SETTINGS->writeEntry("/OpenFilter", selectedFilter());
        RS_SETTINGS->endGroup();
    }

    RS_DEBUG->print("QG_FileDialog::getOpenFileName: fileName: %s", fn.toLatin1().data());
    RS_DEBUG->print("QG_FileDialog::getOpenFileName: OK");

    // RVT PORT delete prev;
    // RVT PORT delete gr;
    return fn;
}
Exemplo n.º 2
0
//-------------------------------------------------------------------------
void MainWindow::exportRectDialog(const QRectF& exportRectangle )
{
	//Select filename & export type
	QString savePath = getFileDialogPath();
	if ( savePath == "" )
		savePath = windowFilePath();
	savePath += "/" + QFileInfo(windowFilePath()).fileName();

	QString filters =	PNG_FILE_FILTER 
					+	QString("\n") +	PDF_FILE_FILTER
//					+	QString("\n") +	PS_FILE_FILTER
					;
	QString selectedFilter("");
	QString fileName = QFileDialog::getSaveFileName(this, tr("Export the scene"),
							savePath,
							tr(filters.toAscii().data()) ,
							&selectedFilter);

	if ( fileName.isEmpty() )
		return;
	
	setLastManagedFile(fileName);
	formatFileName(fileName,selectedFilter,filters);

	exportRect( exportRectangle , fileName , selectedFilter );
}
Exemplo n.º 3
0
//-------------------------------------------------------------------------
void MainWindow::exportItemToMidi()
{
	QLanguageItem * container = dynamic_cast<QLanguageItem *>( sender() );
	assert(container);

	QString savePath;
	if ( container->file().length() )
		savePath = QFileInfo( container->file() ).absolutePath();
	if ( savePath == "" )	
		savePath = windowFilePath();
	if ( savePath == "" )
		savePath = QDir::homePath();

	savePath += "/" + container->name();

	QString filters = MIDI_FILE_FILTER;

	QString selectedFilter("");
	QString fileName = QFileDialog::getSaveFileName(this, tr("Export item"),
                            savePath,
                            tr(filters.toAscii().data()) ,
							&selectedFilter);

	if ( fileName.isEmpty() )
		return;

	formatFileName(fileName,selectedFilter,filters);

	QGuidoAR::midiExport(container->code() , fileName );
}
Exemplo n.º 4
0
QString QG_FileDialog::getSaveFile(RS2::FormatType* type){
    setAcceptMode ( QFileDialog::AcceptSave );
    // read default settings:
    RS_SETTINGS->beginGroup("/Paths");
    QString defDir = RS_SETTINGS->readEntry("/Save",
                                              RS_SYSTEM->getHomeDir());
/*    QString defFilter = RS_SETTINGS->readEntry("/SaveFilter",
                                                 "Drawing Exchange DXF 2000 (*.dxf)");*/
    RS_SETTINGS->endGroup();

    RS_DEBUG->print("defDir: %s", defDir.toLatin1().data());
    QString fn = "";
    QStringList filters;
#ifdef USE_DXFRW
    filters << fDxf2000 << fDxfrw2000  << fDxfR12 << fLff << fCxf << fJww;
#else
    filters << fDxf2000 << fDxfR12 << fLff << fCxf << fJww;
#endif

    setWindowTitle(tr("Save Drawing As"));
    setFileMode(QFileDialog::AnyFile);
    setDirectory(defDir);
    setFilters(filters);
#if QT_VERSION >= 0x040400
    selectNameFilter(fDxf2000);
#endif
    ftype= RS2::FormatDXF;
    RS_DEBUG->print("defFilter: %s", fDxf2000.toLatin1().data());

    if (exec()==QDialog::Accepted) {
        QStringList fl = selectedFiles();
        if (!fl.isEmpty())
            fn = fl[0];
        fn = QDir::convertSeparators( QFileInfo(fn).absoluteFilePath() );
        getType(selectedFilter());
        if (type!=NULL)
                *type = ftype;
        // append default extension:
        if (QFileInfo(fn).fileName().indexOf('.')==-1) {
            fn += getExtension(ftype);
        }

    // store new default settings:
        RS_SETTINGS->beginGroup("/Paths");
        RS_SETTINGS->writeEntry("/Save", QFileInfo(fn).absolutePath());
        //RS_SETTINGS->writeEntry("/SaveFilter", fileDlg->selectedFilter());
        RS_SETTINGS->endGroup();
    }

    return fn;
}
QString KexiStartupFileDialogBase::currentFilter() const
{
    //(js)filterWidget->currentFilter();

    //we need to convert Qt filter format to KDE format
    //Qt format: "some text (*.first *.second)" or "All (*)"
    //KDE format: "*.first *.second" or "*"
    QString f = selectedFilter();
    if (f.find('(') != -1)
        f = f.mid(f.find('(') + 1);
    if (f.mid(f.find(')') != -1))
        f = f.left(f.find(')'));
    return f;
}
Exemplo n.º 6
0
//-------------------------------------------------------------------------
void MainWindow::exportItem(QGuidoItemContainer * item)
{
	//Select filename & export type
	QString savePath;
	if ( item->file().length() )
		savePath = QFileInfo( item->file() ).absolutePath();
	if ( savePath == "" )	
		savePath = getFileDialogPath();

	savePath += "/" + item->name();

	QString filters =	PNG_FILE_FILTER 
					+	QString("\n") +	PDF_FILE_FILTER
//					+	QString("\n") +	GMN_FILE_FILTER
//						+	QString("\n") +	PS_FILE_FILTER
					;
	QString selectedFilter("");
	QString fileName = QFileDialog::getSaveFileName(this, "Export the selected " + GraphicsSceneMainWindow::applicationSettings().mLanguageNameShort + " item",
							savePath,
							tr(filters.toAscii().data()) ,
							&selectedFilter);

	if ( fileName.isEmpty() )
		return;
		
	formatFileName(fileName,selectedFilter,filters);
	setLastManagedFile(fileName );


	if ( selectedFilter == PNG_FILE_FILTER )
	{
		int result = QResolutionDialog( item->guidoItem()->boundingRect() , EXPORT_MIN_DETAIL , EXPORT_MAX_DETAIL , EXPORT_DEFAULT_DETAIL , EXPORT_DETAIL_TO_SCALE_FACTOR ).exec();
		if ( result )
			itemToImage( item->guidoItem() , result * EXPORT_DETAIL_TO_SCALE_FACTOR , QColor(Qt::white).rgb() ).save( fileName );

		return;
	}
	
	if ( selectedFilter == PDF_FILE_FILTER )
	{
		item->exportToPdf( fileName );
		return;
	}

	assert(0);
}
Exemplo n.º 7
0
void QPreviewFileDialog::format()
{
  ImageIOSupporter iisup;
  QString ext;
//did the user type an extension ?
  mImageFormat = iisup.getFormatByFilename(mFilePath);
  if(mImageFormat.isEmpty())
  {
    //if there's no extension, try to get the format from the currently
    //selected filter
    mImageFormat = iisup.getFormatByFilter(selectedFilter());
    if(!mImageFormat.isEmpty())
    {
      ext = iisup.getExtensionByFormat(mImageFormat);
      mFilePath+= ext;
    }
  }
}
Exemplo n.º 8
0
void QPreviewFileDialog::accept()
{
  ImageIOSupporter iisup;
  QString qs;
  mFilePath = selectedFile();
  format();
  if(mFilePath == xmlConfig->absConfDirPath()+".scantemp.pnm")
  {
    QMessageBox::information(this,tr("Information"),
                 tr("You can not save the image under the name\n"
                    "of the temporary image file, because it\n"
                    "will be overwritten with the next scan."),tr("OK"));	
    return;
  }
  if(mImageFormat == "")
  {
    QMessageBox::information(this,tr("Information"),
                 tr("You did not specify a valid image format.\n"
                    "Either append a valid extension to the filename,\n"
                    "or select a file filter."),tr("OK"));	
    return;
  }
  if(!iisup.saveImageInteractive(mFilePath,*mpImage,mImageFormat,this))
  {
    return;
  }
  xmlConfig->setStringValue("SINGLEFILE_SAVE_PATH",dir()->absPath());
  int view_mode = int(viewMode());
  //What the hell is this? Not enough, that viewMode() only works, as
  //long as the dialog is visible, it also returns the wrong values
  //(0 when it should return 1 and vice versa)
  //At least, this stupid behaviour is consistent in all versions
  //of Qt2.2.x. If this is fixed in Qt3, the following lines must
  //be removed.
  if(view_mode == 0)
    view_mode = 1;
  else if(view_mode == 1)
    view_mode = 0;
  xmlConfig->setIntValue("SINGLEFILE_VIEW_MODE",view_mode);
  xmlConfig->setStringValue("VIEWER_IMAGE_TYPE",
                            iisup.getDataFromOutFilter(selectedFilter()));
  if(mpImage && mMustDeleteImage) delete mpImage;
  QDialog::accept();
}
Exemplo n.º 9
0
QString QG_FileDialog::getSaveFile(RS2::FormatType* type){
    setAcceptMode ( QFileDialog::AcceptSave );
    // read default settings:
    RS_SETTINGS->beginGroup("/Paths");
    QString defDir = RS_SETTINGS->readEntry("/Save",
                                              RS_SYSTEM->getHomeDir());
/*    QString defFilter = RS_SETTINGS->readEntry("/SaveFilter",
                                                 "Drawing Exchange DXF 2000 (*.dxf)");*/
    RS_SETTINGS->endGroup();

    if(!defDir.endsWith("/") && !defDir.endsWith("\\"))
        defDir += QDir::separator();

    RS_DEBUG->print("defDir: %s", defDir.toLatin1().data());

    // setup filters
    QStringList filters;

    filters << fDxfrw2007 << fDxfrw2004 << fDxfrw2000 << fDxfrw14 << fDxfrw12 << fLff << fCxf << fJww;

    ftype = RS2::FormatDXFRW;
    RS_DEBUG->print("defFilter: %s", fDxfrw2007.toLatin1().data());

    // when defFilter is added the below should use the default extension.
    // generate an untitled name
    QString fn = "Untitled";
    if(QFile::exists( defDir + fn + getExtension( ftype ) ))
    {
        int fileCount = 1;
        while(QFile::exists( defDir + fn + QString("%1").arg(fileCount) +
                             getExtension(ftype)) )
            ++fileCount;
        fn += QString("%1").arg(fileCount);
    }

    // initialize dialog properties
    setWindowTitle(tr("Save %1 As").arg(name));
    setFileMode(QFileDialog::AnyFile);
    setDirectory(defDir);
    setFilters(filters);
    selectNameFilter(fDxfrw2007);
    selectFile(fn);
    auto&& ext=getExtension(ftype);
    if(ext.size()==4){
        if(ext[0]=='.') ext.remove(0,1);
    }
    if(ext.size()==3) setDefaultSuffix (ext);


    // only return non empty string when we have a complete, user approved, file name.
    if (exec()!=QDialog::Accepted)
        return QString("");

    QStringList fl = selectedFiles();
    if (fl.isEmpty())
        return QString("");

    QFileInfo fi = QFileInfo( fl[0] );
    fn = QDir::toNativeSeparators( fi.absoluteFilePath() );

    getType(selectedFilter());
    if (type!=NULL)
        *type = ftype;

    // append default extension:
    if (fi.fileName().endsWith(".dxf",Qt::CaseInsensitive)==-1)
        fn += getExtension(ftype);

    // store new default settings:
    RS_SETTINGS->beginGroup("/Paths");
    RS_SETTINGS->writeEntry("/Save", fi.absolutePath());
    //RS_SETTINGS->writeEntry("/SaveFilter", fileDlg->selectedFilter());
    RS_SETTINGS->endGroup();

    return fn;
}
Exemplo n.º 10
0
void QmitkToFRecorderWidget::OnStartRecorder()
{
  m_Controls->m_StartRecordingButton->setChecked(true);
  m_Controls->m_RecorderGroupBox->setEnabled(false);
  this->repaint();

  int numOfFrames = m_Controls->m_NumOfFramesSpinBox->value();
  try
  {
    bool fileOK = true;
    bool distanceImageSelected = true;
    bool amplitudeImageSelected = false;
    bool intensityImageSelected = false;
    bool rgbImageSelected = false;
    bool rawDataSelected = false;

    //Set check boxes in dialog according to device properties
    m_ToFImageGrabber->GetCameraDevice()->GetBoolProperty("HasAmplitudeImage",amplitudeImageSelected);
    m_ToFImageGrabber->GetCameraDevice()->GetBoolProperty("HasIntensityImage",intensityImageSelected);
    m_ToFImageGrabber->GetCameraDevice()->GetBoolProperty("HasRGBImage",rgbImageSelected);

    QString tmpFileName("");
    QString selectedFilter("");
    QString imageFileName("");
    mitk::ToFImageWriter::ToFImageType tofImageType;
    tmpFileName = QmitkToFRecorderWidget::getSaveFileName(tofImageType,
      distanceImageSelected, amplitudeImageSelected, intensityImageSelected, rgbImageSelected, rawDataSelected,
      NULL, "Save Image To...", imageFileName, "NRRD Images (*.nrrd);;PIC Images - deprecated (*.pic);;Text (*.csv)", &selectedFilter);

    if (tmpFileName.isEmpty())
    {
      fileOK = false;
    }
    else
    {
      imageFileName = tmpFileName;
    }

    if (fileOK)
    {
      std::string dir = itksys::SystemTools::GetFilenamePath( imageFileName.toStdString() );
      std::string baseFilename = itksys::SystemTools::GetFilenameWithoutLastExtension( imageFileName.toStdString() );
      std::string extension = itksys::SystemTools::GetFilenameLastExtension( imageFileName.toStdString() );

      int integrationTime = this->m_ToFImageGrabber->GetIntegrationTime();
      int modulationFreq = this->m_ToFImageGrabber->GetModulationFrequency();

      QString integrationTimeStr;
      integrationTimeStr.setNum(integrationTime);
      QString modulationFreqStr;
      modulationFreqStr.setNum(modulationFreq);
      QString numOfFramesStr("");
      if (this->m_RecordMode == mitk::ToFImageRecorder::PerFrames)
      {
        numOfFramesStr.setNum(numOfFrames);
      }

      std::string distImageFileName = prepareFilename(dir, baseFilename, modulationFreqStr.toStdString(),
        integrationTimeStr.toStdString(), numOfFramesStr.toStdString(), extension, "_DistanceImage");
      MITK_INFO << "Save distance data to: " << distImageFileName;

      std::string amplImageFileName = prepareFilename(dir, baseFilename, modulationFreqStr.toStdString(),
        integrationTimeStr.toStdString(), numOfFramesStr.toStdString(), extension, "_AmplitudeImage");
      MITK_INFO << "Save amplitude data to: " << amplImageFileName;

      std::string intenImageFileName = prepareFilename(dir, baseFilename, modulationFreqStr.toStdString(),
        integrationTimeStr.toStdString(), numOfFramesStr.toStdString(), extension, "_IntensityImage");
      MITK_INFO << "Save intensity data to: " << intenImageFileName;

      std::string rgbImageFileName = prepareFilename(dir, baseFilename, modulationFreqStr.toStdString(),
        integrationTimeStr.toStdString(), numOfFramesStr.toStdString(), extension, "_RGBImage");
      MITK_INFO << "Save intensity data to: " << rgbImageFileName;

      if (selectedFilter.compare("Text (*.csv)") == 0)
      {
        this->m_ToFImageRecorder->SetFileFormat(".csv");
      }
      else if (selectedFilter.compare("PIC Images - deprecated (*.pic)") == 0)
      {
        //default
        this->m_ToFImageRecorder->SetFileFormat(".pic");

        QMessageBox::warning(NULL, "Deprecated File Format!",
          "Please note that *.pic file format is deprecated and not longer supported! The suggested file format for images is *.nrrd!");
      }
      else if (selectedFilter.compare("NRRD Images (*.nrrd)") == 0)
      {
        this->m_ToFImageRecorder->SetFileFormat(".nrrd");
      }
      else
      {
        QMessageBox::warning(NULL, "Unsupported file format!", "Please specify one of the supported file formats *.nrrd, *.csv!");
        return;
      }

      numOfFrames = m_Controls->m_NumOfFramesSpinBox->value();
      this->m_ToFImageRecorder->SetDistanceImageFileName(distImageFileName);
      this->m_ToFImageRecorder->SetAmplitudeImageFileName(amplImageFileName);
      this->m_ToFImageRecorder->SetIntensityImageFileName(intenImageFileName);
      this->m_ToFImageRecorder->SetRGBImageFileName(rgbImageFileName);
      this->m_ToFImageRecorder->SetToFImageType(tofImageType);
      this->m_ToFImageRecorder->SetDistanceImageSelected(distanceImageSelected);
      this->m_ToFImageRecorder->SetAmplitudeImageSelected(amplitudeImageSelected);
      this->m_ToFImageRecorder->SetIntensityImageSelected(intensityImageSelected);
      this->m_ToFImageRecorder->SetRGBImageSelected(rgbImageSelected);
      this->m_ToFImageRecorder->SetRecordMode(this->m_RecordMode);
      this->m_ToFImageRecorder->SetNumOfFrames(numOfFrames);

      emit RecordingStarted();
      this->m_ToFImageRecorder->StartRecording();
    }
    else
    {
      this->OnRecordingStopped();
    }
  }
  catch(std::exception& e)
  {
    QMessageBox::critical(NULL, "Error", QString(e.what()));
    this->OnRecordingStopped();
  }
}