示例#1
0
void
SimpleVisApp::openFile(const QString &filename)
{
    if(!filename.isEmpty())
    {
        // Open the file.
        viewer->Methods()->OpenDatabase(filename.toStdString());

        // Get the file's metadata and populate the variable list.
        const avtDatabaseMetaData *md = viewer->GetMetaData(filename.toStdString());
        if(md != 0)
        {
            variables->blockSignals(true);
            for(int i = 0; i < md->GetNumScalars(); ++i)
                variables->addItem(md->GetScalar(i)->name.c_str());
            variables->setCurrentRow(0);
            variables->blockSignals(false);
            if(md->GetNumScalars() > 0)
            {
                variables->setEnabled(true);
                plotTypeWidget->setEnabled(true);
                contourWidget->setEnabled(plotType->checkedId() == 1);
                // Add a plot of the first variable
                changePlotType(plotType->checkedId());
            }
            scalarLabel->setEnabled(true);
            variables->setEnabled(true);
        }
        else
            resetWindow();
    }
    else
        resetWindow();
}
//-------------------------------Constructors
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    _ui(new Ui::MainWindow),
    _application(std::unique_ptr<Application>(new Application()))
{
    _ui->setupUi(this);
    _application->initialiseSubjects(false);
    QObject::connect(_application.get(), SIGNAL(pointClicked(uint, float, float)), this, SLOT(displayXY(uint, float, float)));
    QObject::connect(this, SIGNAL(plotTypeChanged(PlotType)), _application.get(), SLOT(changePlotType(PlotType)));
    QObject::connect(this, SIGNAL(orientationEnabled(bool)), _application.get(), SLOT(enableOrientation(bool)));
    QObject::connect(this, SIGNAL(fixedSourceSelected(bool)), _application.get(), SLOT(fixSource(bool)));
    QObject::connect(this, SIGNAL(fixedTargetSelected(bool)), _application.get(), SLOT(fixTarget(bool)));
}