bool FemPostPipeline::canRead(Base::FileInfo File) {

    if (File.hasExtension("vtk") ||
        // from FemResult only unstructural mesh is supported in femvtktoools.cpp
        File.hasExtension("vtp") ||
        File.hasExtension("vts") ||
        File.hasExtension("vtr") ||
        File.hasExtension("vti") ||
        File.hasExtension("vtu"))
        return true;

    return false;
}
void FemPostPipeline::read(Base::FileInfo File) {

    // checking on the file
    if (!File.isReadable())
        throw Base::FileException("File to load not existing or not readable", File);

    if (File.hasExtension("vtu"))
        readXMLFile<vtkXMLUnstructuredGridReader>(File.filePath());
    else if (File.hasExtension("vtp"))
        readXMLFile<vtkXMLPolyDataReader>(File.filePath());
    else if (File.hasExtension("vts"))
        readXMLFile<vtkXMLStructuredGridReader>(File.filePath());
    else if (File.hasExtension("vtr"))
        readXMLFile<vtkXMLRectilinearGridReader>(File.filePath());
    else if (File.hasExtension("vti"))
        readXMLFile<vtkXMLImageDataReader>(File.filePath());
    else if (File.hasExtension("vtk"))
        readXMLFile<vtkDataSetReader>(File.filePath());
    else
        throw Base::FileException("Unknown extension");
}
Exemplo n.º 3
0
bool Assistant::startAssistant()
{
#if QT_VERSION < 0x040400
    QMessageBox::critical(0, QObject::tr("Help"),
    QObject::tr("Unable to load documentation.\n"
    "In order to load it Qt 4.4 or higher is required."));
    return false;
#endif

    if (!proc) {
        proc = new QProcess();
        connect(proc, SIGNAL(readyReadStandardOutput()),
                this, SLOT(readyReadStandardOutput()));
        connect(proc, SIGNAL(readyReadStandardError()),
                this, SLOT(readyReadStandardError()));
    }

    if (proc->state() != QProcess::Running) {
#ifdef Q_OS_WIN
        QString app;
        app = QDir::toNativeSeparators(QString::fromUtf8
            (App::GetApplication().getHomePath()) + QLatin1String("bin/"));
#else
        QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator();
#endif 
#if !defined(Q_OS_MAC)
        app += QLatin1String("assistant");
#else
        app += QLatin1String("Assistant.app/Contents/MacOS/Assistant");
#endif

        // get the name of the executable and the doc path
        QString exe = QString::fromUtf8(App::GetApplication().getExecutableName());
        QString doc = QString::fromUtf8(App::Application::getHelpDir().c_str());
        QString qhc = doc + exe.toLower() + QLatin1String(".qhc");

        Base::FileInfo fi ( (const char*)qhc.toUtf8() );
        if (!fi.isReadable()) {
            QMessageBox::critical(0, tr("%1 Help").arg(exe),
                tr("%1 help files not found (%2). You might need to install the %1 documentation package.").arg(exe).arg(qhc));
            return false;
        }

        static bool first = true;
        if (first) {
            Base::Console().Log("Help file at %s\n", (const char*)qhc.toUtf8());
            first = false;
        }

        QStringList args;

        args << QLatin1String("-collectionFile") << qhc
             << QLatin1String("-enableRemoteControl");

        proc->start(app, args);

        if (!proc->waitForStarted()) {
            QMessageBox::critical(0, tr("%1 Help").arg(exe),
                tr("Unable to launch Qt Assistant (%1)").arg(app));
            return false;
        }
    }

    return true;
}