コード例 #1
0
void SystemProcessPath::Pathstr(std::string str)
{	
	boost::filesystem::path rootPath( str );
  if( exists( rootPath ) )
  {
    if( is_directory( rootPath ) )
      ScanDirectory( rootPath );
    else
      outputFileInfo( rootPath );
  }  
}
コード例 #2
0
void SystemProcessPath::ScanDirectory( const boost::filesystem::path& rPath )
{
  std::vector<boost::filesystem::path> vList;
  copy( boost::filesystem::directory_iterator(rPath), boost::filesystem::directory_iterator(), back_inserter( vList ) );
  for( std::vector<boost::filesystem::path>::const_iterator it = vList.begin(); it != vList.end(); ++ it )
  {
    if( is_directory( *it ) )
      ScanDirectory( *it );
    else
      outputFileInfo( *it );
  }
}
コード例 #3
0
ファイル: Gcc.cpp プロジェクト: nbeams/program-visualizer
bool Gcc::run(QString filename)
{
	if(!compile(filename))
		return false;

	QString outputString;
	QFileInfo outputFileInfo(m_outputFileName);
	QFile scriptFile;

#ifdef Q_OS_WIN32
	scriptFile.setFileName(QDir::temp().absoluteFilePath("kiprBatchFile.cmd"));
	outputString += "@echo off\n";
	outputString += "\"" + QDir::toNativeSeparators(outputFileInfo.absolutePath()) + "\\" + outputFileInfo.fileName() + "\"\n";
	outputString +=  "pause\n";
#else
	scriptFile.setFileName(QDir::temp().absoluteFilePath("kiprScript.sh"));
	outputString += "#!/bin/bash\n";
	outputString += "cd \"" + outputFileInfo.absolutePath() + "\"\n";
	outputString += "\"./" + outputFileInfo.fileName() + "\"\n";
#endif

	if(!scriptFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
		qWarning("Gcc::run() Unable to open temp file for writing");
		return false;
	}

	scriptFile.setPermissions(scriptFile.permissions() | QFile::ExeOwner);
	scriptFile.write(outputString.toLocal8Bit());
	scriptFile.close();

	QStringList args;
	QFileInfo scriptInfo(scriptFile);

	m_outputBinary.setWorkingDirectory(outputFileInfo.absolutePath());

#ifdef Q_OS_WIN32
	QString startLine = "start \"" + m_outputFileName + "\" \"cmd /c " +
						scriptInfo.absoluteFilePath() + "\"\n";
	args << "/k";
	m_outputBinary.start("cmd", args);
	m_outputBinary.write(startLine.toLocal8Bit());
	m_outputBinary.write("exit\n");
#elif defined(Q_OS_MAC)
	args << "-a" << "/Applications/Utilities/Terminal.app" << scriptInfo.absoluteFilePath();
	m_outputBinary.start("open", args);
#else
	args << "-e" << scriptInfo.absoluteFilePath() + " && echo \"\nQuitting in 5 secs...\" && sleep 5";
	m_outputBinary.start("xterm", args);
#endif

	return true;

}
コード例 #4
0
ファイル: spdrimport.cpp プロジェクト: sierdzio/spdr
/*!
  \internal

  Performs the requested file operation based on CopyMode and UpdateMode settings.

  Returns true if successful.
 */
bool SpdrImportPrivate::performFileOperation(const QString &inputFile, const QString &outputFile) const
{
    Q_Q(const SpdrImport);

    bool result = true;

    if (areFilesTheSame(inputFile, outputFile)) {
        q->log(QCoreApplication::translate("SpdrImportPrivate",
                                           "COPY: Skipping copying %1 to %2: files are identical")
               .arg(inputFile).arg(outputFile), Spdr::MediumLogging);
    } else {
        if (!q->simulate()) {
            bool skip = false;

            if (QFile(outputFile).exists()) {
                if (q->updateMode() == Spdr::Overwrite) {
                    result = QFile::remove(outputFile);
                } else if (q->updateMode() == Spdr::Ignore) {
                    skip = true;
                } else if (q->updateMode() == Spdr::Ask) { // TODO: implement Spdr::Ask
                    q->log(QCoreApplication::translate("SpdrImportPrivate",
                                                       "This feature has not been implemented yet: Spdr::%1")
                           .arg(Spdr::updateModeToString(Spdr::Ask)), Spdr::Critical);
                    return false;
                }
            }

            if (!skip && result) {
                QFileInfo outputFileInfo(outputFile);
                QDir().mkpath(outputFileInfo.absolutePath());

                if (q->copyMode() == SpdrImport::Move) {
                    result = QFile::rename(inputFile, outputFile);
                } else {
                    result = QFile::copy(inputFile, outputFile);
                }
            }
        }

        q->log(QCoreApplication::translate("SpdrImportPrivate", "COPY: Copying %1 to %2 was a: %3").arg(inputFile).arg(outputFile)
               .arg(Spdr::getOperationStatusFromBool(result)), Spdr::MediumLogging);
    }

    return result;
}
コード例 #5
0
ファイル: heatmapgui.cpp プロジェクト: GavrisAS/QGIS
void HeatmapGui::on_mBrowseButton_clicked()
{
  QSettings s;
  QString lastDir = s.value( "/Heatmap/lastOutputDir", QDir::homePath() ).toString();

  QString outputFilename = QFileDialog::getSaveFileName( nullptr, tr( "Save Heatmap as:" ), lastDir );
  if ( !outputFilename.isEmpty() )
  {
    mOutputRasterLineEdit->setText( outputFilename );
    QFileInfo outputFileInfo( outputFilename );
    QDir outputDir = outputFileInfo.absoluteDir();
    if ( outputDir.exists() )
    {
      s.setValue( "/Heatmap/lastOutputDir", outputFileInfo.absolutePath() );
    }
  }

  enableOrDisableOkButton();
}
コード例 #6
0
/**
 * @brief ShaderWidget::ShaderWidget
 * @param parent
 * @param shareWidget
 */
ShaderWidget::ShaderWidget(QWidget *parent) :
    QGLWidget(parent)
{
    obj = new ObjLoader2();
    shaderProgram=NULL;
    glDisable(GL_MULTISAMPLE);
    glDisable(GL_BLEND);
    glDisable(GL_LIGHTING);
    glDisable(GL_SMOOTH);
    glDisable(GL_LINE_SMOOTH);

    // First load the 2D and 3D points
    //QMessageBox::information(0, "2D points selection", "Please select the 2D points file for the calibration. The points file must contain just two columns of pixel coordinates.");

    QString points2Dfilename = "I:/Images/23July2013/2D_points.txt";
    //QString points2Dfilename = "/home/carlo/Desktop/JORDANKA/Calibrations/2D_points.txt";
    //QFileDialog::getOpenFileName(this,"Select 2D projected points correspondence",QDir::currentPath(),"*.txt");

    if (points2Dfilename.isEmpty())
    {
        QMessageBox::critical(this,"Error","Select a valid (non-empty) file for 2D points. Now exiting...");
        QCoreApplication::exit(-1);
    }
    QFileInfo fileInfo2dpoints(points2Dfilename);
    //QMessageBox::information(this, "3D points selection", "Please select the corresponding 3D points file for the calibration. The points file must contain just three columns of world coordinates.\nThe number of 3D points must be the same of the 2D points.");

    QString points3Dfilename = "I:/Images/23July2013/3D_points.txt";
    // QFileDialog::getOpenFileName(this,"Select 3D projected points correspondence", fileInfo2dpoints.absolutePath(),"*.txt");

    if ( points3Dfilename.isEmpty() )
    {
        QMessageBox::critical(this,"Error","Select a valid (non-empty)  file for 3D points. Now exiting...");
        QCoreApplication::exit(-1);
    }

    //QMessageBox::information(this, "Output images", "Please select the output path for the generated images");

    //QString outputFileName = "I:/Images/05July2013/images/tmp/img";//QFileDialog::getSaveFileName(NULL,"Select output images path",fileInfo2dpoints.absolutePath());
    //QString outputFileName = "I:/Images/05July2013/images/tmp/img";//QFileDialog::getSaveFileName(NULL,"Select output images path",fileInfo2dpoints.absolutePath());
    QString outputFileName = "I:/Images/23July2013/images/img";
    if ( outputFileName.isEmpty() )
    {
        QMessageBox::critical(this,"Error","Select a valid (non-empty) file name for output points. Now exiting...");
        QCoreApplication::quit();
    }

    QFileInfo outputFileInfo(outputFileName);
    this->folderName = outputFileInfo.absolutePath();
    this->imagesFilesFolderName = outputFileInfo.absolutePath();
    this->imagesFileBaseName = outputFileInfo.baseName();

    double zNear = 0.1;
    double zFar = 100;
    int width = 604;
    int height = 608;
    bool decomposePMatrix = true;
    bool computeOpenGLMatrices = true;
    CameraDirectLinearTransformation cam(points2Dfilename.toStdString(),points3Dfilename.toStdString(),true,true,0,0,width,height,zNear,zFar);

    this->Projection.resize(4,4);
    this->ModelView.resize(4,4);
    this->Projection << cam.getOpenGLProjectionMatrix().matrix();
    this->ModelView << cam.getOpenGLModelViewMatrix().matrix();

    cerr << this->Projection.matrix() << endl;
    cerr << this->ModelView.matrix() << endl;
    //QMessageBox::information(this, "Wavefront Object loading", "Please select the 3D mesh in Wavefront OBJ format to be loaded.");
    //QString objFileName = "C:/workspace/cncsvisioncmake/data/objmodels/face.obj";
    //QString objFileName = "/home/carlo/workspace/cncsvisioncmake/data/objmodels/head_decimated.obj";
	QString objFileName = "C:/workspace/cncsvisioncmake/data/objmodels/face.obj";
    //QFileDialog::getOpenFileName(this,"Select Wavefront OBJ mesh file",QDir::currentPath(),"*.obj");
    qDebug() << objFileName ;
    if (objFileName.isEmpty())
    {
        QMessageBox::critical(this,"Error","Select a valid (non-empty) file name for OBJ model to load.");
        QCoreApplication::exit(-1);
    }
    this->loadObjFile(objFileName.toStdString());
    //QMessageBox::information(this, "Wavefront Object loading", "Please select the projector parameters file.");
    //QString projectorParametersFileName = "I:/Images/05July2013/ProjectoParameters.txt";
    QString projectorParametersFileName = "I:/Images/23July2013/ProjectorParameters.txt";
    //QFileDialog::getOpenFileName(this,"Select projector parameters file name",fileInfo2dpoints.absolutePath(),"*.txt");
    if (projectorParametersFileName.isEmpty())
    {
        QCoreApplication::exit(-1);
    }
    this->projectorParameters.loadParameterFile(projectorParametersFileName.toStdString());

    // Typical parameters are
    // ProjectorAreaWidth 604
    // ProjectorAreaHeight 684
    // ProjectionHeightMM 250
    // ViewerDistanceMM : 500
    // ViewerHeightMM: 0.0
    // SlicesNumber: 96
    this->projectorPixelWidth =604;
    this->projectorPixelHeight= 608;
    this->projectorHeight= 250.0;
    this->viewerDistance= 500.0;
    this->viewerHeight= 0.0;
    this->viewsNumber=96;
	this->objectScale=10.0;
	
    try
    {
        this->projectorHeight= util::str2num<double>(this->projectorParameters.find("ProjectorHeightMM") );
        this->viewerDistance= util::str2num<double>(this->projectorParameters.find("ViewerDistanceMM") );
        this->viewerHeight= util::str2num<double>(this->projectorParameters.find("ViewerHeightMM") );
        this->viewsNumber= util::str2num<int>(this->projectorParameters.find("ViewsNumber") );
        this->objectScale= util::str2num<double>(this->projectorParameters.find("ObjectScale") );
    }
    catch ( std::invalid_argument &e )
    {
        cerr << e.what() << endl;
        QMessageBox::critical(this,"Parameters files error ",e.what());
        QCoreApplication::exit(-1);
    }

	mirrorAngleRad=M_PI;
	
    this->resize(projectorPixelWidth,projectorPixelHeight);
    glPointSize(0.1f);
    glLineWidth(0.1f);
    QTimer *timer = new QTimer(this);
    timer->start(15);
    QObject::connect(timer,SIGNAL(timeout()),this,SLOT(repaint()));
    this->updateView();
    this->setFocus();
    frameNumber=0; //very important to count the number of frames
}