Пример #1
0
void MainWindow::open(std::unique_ptr<Project> project) {
    assert(project);

    project_ = std::move(project);

    imageChanged();
    instructionsChanged();
    treeChanged();

    /* Log messages to the log window. */
    project_->setLogToken(logToken_);

    /* Connect the project to the slots for updating views. */
    connect(project_.get(), SIGNAL(nameChanged()), this, SLOT(updateGuiState()));
    connect(project_.get(), SIGNAL(imageChanged()), this, SLOT(imageChanged()));
    connect(project_.get(), SIGNAL(instructionsChanged()), this, SLOT(instructionsChanged()));
    connect(project_.get(), SIGNAL(treeChanged()), this, SLOT(treeChanged()));

    /* Connect the project to the progress dialog. */
    connect(project_->commandQueue(), SIGNAL(nextCommand()), this, SLOT(updateGuiState()));
    connect(project_->commandQueue(), SIGNAL(idle()), this, SLOT(updateGuiState()));
    connect(progressDialog_, SIGNAL(canceled()), project_.get(), SLOT(cancelAll()));

    /* Delegate "Cancel All" to the project. */
    connect(cancelAllAction_, SIGNAL(triggered()), project_.get(), SLOT(cancelAll()));

    updateGuiState();
}
ClientControllerWidget::ClientControllerWidget(Client *client, QWidget *parent, Qt::WindowFlags f) :
  QWidget(parent, f),
  _client(client)
{
  _ui.setupUi(this);
  _ui.savePath->setObjectName(QDir::homePath());
  _ui.filesView->setModel(new ClientFilesModel(_client, this));
  connect(_ui.savePathButton, SIGNAL(clicked()), SLOT(onSavePathButtonClicked()));
  connect(_client, SIGNAL(serverConnected()), SLOT(updateGuiState()));
  connect(_client, SIGNAL(serverDisconnected()), SLOT(updateGuiState()));
}
Пример #3
0
void PythonEditor::openScript() {

    if (!PythonModule::getInstance()) {
        LERROR("PythonModule not instantiated");
        return;
    }

    //create filter with supported file formats
    QString filter = "Python Script (*.py)";
    QString fileName = getOpenFileName(filter);
    if (!fileName.isEmpty()) {
        clearScript();

        script_ = PythonModule::getInstance()->loadScript(fileName.toStdString(), false);
        if (!script_) {
            QMessageBox::critical(this, tr("Python Error"), tr("Python script '%1' could not be loaded.").arg(fileName));
        }
        else {
            // retrieve script source from script object and assign it to code editor
            QString source = QString::fromStdString(script_->getSource());
            source = source.replace("\t", "    ");  //< replace tabs with four spaces
            codeEdit_->setPlainText(source);
            scriptOwner_ = false;
        }
        updateGuiState();
    }
}
Пример #4
0
void QgsLine3DSymbolWidget::setSymbol( const QgsLine3DSymbol &symbol )
{
  spinWidth->setValue( symbol.width() );
  spinHeight->setValue( symbol.height() );
  spinExtrusion->setValue( symbol.extrusionHeight() );
  cboAltClamping->setCurrentIndex( static_cast<int>( symbol.altitudeClamping() ) );
  cboAltBinding->setCurrentIndex( static_cast<int>( symbol.altitudeBinding() ) );
  chkSimpleLines->setChecked( symbol.renderAsSimpleLines() );
  widgetMaterial->setMaterial( symbol.material() );
  updateGuiState();
}
Пример #5
0
void PythonEditor::initialize() throw (tgt::Exception) {
    VoreenVEPlugin::initialize();

    if (PythonModule::getInstance()) {
        PythonModule::getInstance()->addOutputListener(this);
        newScript();
    }
    else
        LWARNING("Python module class not instantiated");

    updateGuiState();
}
Пример #6
0
void PythonEditor::saveScript() {
    tgtAssert(codeEdit_, "No code editor");

    if (!script_) {
        LERROR("No script");
        return;
    }

    if (script_->getFilename().empty()) {
        LERROR("Script has no filename");
    }
    else {
        if (!saveScriptInternal(QString::fromStdString(script_->getFilename()), codeEdit_->toPlainText())) {
            QString message = tr("Failed to save script to file '%1'").arg(QString::fromStdString(script_->getFilename()));
            QMessageBox::critical(this, tr("Python Error"), message);
        }
    }

    updateGuiState();
}
Пример #7
0
void PythonEditor::newScript() {
    clearScript();
    if (PythonModule::getInstance() && PythonModule::getInstance()->isInitialized()) {
        script_ = PythonModule::getInstance()->loadScript("template.py", false);
        if (script_) {
            QString source = QString::fromStdString(script_->getSource());
            source = source.replace("\t", "    ");  //< replace tabs with four spaces
            PythonModule::getInstance()->dispose(script_);

            script_ = new PythonScript();
            script_->setSource(source.toStdString());
            codeEdit_->setPlainText(source);
            scriptOwner_ = true;
        }
    }
    else {
        QMessageBox::critical(this, tr("Python Error"), tr("Failed to create Python script: module not initialized"));
    }
    updateGuiState();
}
Пример #8
0
void PythonEditor::saveScriptAs() {

    if (!PythonModule::getInstance()) {
        LERROR("PythonModule not instantiated");
        return;
    }

    if (!script_) {
        LERROR("No script");
        return;
    }

    //create filter with supported file formats
    QStringList filter;
    filter << "Python Script (*.py)";

    QString fileName = getSaveFileName(filter);
    if (!fileName.isEmpty()) {
        if (saveScriptInternal(fileName, codeEdit_->toPlainText())) {
            clearScript();
            script_ = PythonModule::getInstance()->loadScript(fileName.toStdString(), false);
            scriptOwner_ = false;
            if (script_) {
                codeEdit_->setPlainText(QString::fromStdString(script_->getSource()));
            }
            else {
                QMessageBox::critical(this, tr("Python Error"), tr("Saved script '%1' could not be loaded.").arg(fileName));
            }
        }
        else {
            QString message = tr("Failed to save script to file '%1'").arg(fileName);
            QMessageBox::critical(this, tr("Python Error"), message);
        }
    }

    updateGuiState();
}
Пример #9
0
VolumeListingDialog::VolumeListingDialog(QWidget* parent) 
    : QWidget(parent)
    , reader_(0)
{
    setWindowFlags(Qt::Dialog);
    setWindowModality(Qt::WindowModal);
    setWindowTitle(tr("Volume Selection"));

    // table configuration
    table_ = new QTableWidget();
    table_->setSelectionBehavior(QAbstractItemView::SelectRows);
    table_->setSortingEnabled(true);
    table_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

    // top label
    QVBoxLayout* mainLayout = new QVBoxLayout();
    titleLabel_ = new QLabel(tr("The selected file contains multiple volumes. Please select the volumes to load:"));
    QFont labelFont = titleLabel_->font();
    labelFont.setPointSize(titleLabel_->font().pointSize()+1);
    labelFont.setBold(true);
    titleLabel_->setFont(labelFont);
    mainLayout->addWidget(titleLabel_);
    
    // filter bar
    QHBoxLayout* searchLayout = new QHBoxLayout();
    filterLabel_ = new QLabel(tr("Filter: "));
    searchLayout->addWidget(filterLabel_);
    filterTextBox_ = new QLineEdit();
    searchLayout->addWidget(filterTextBox_);
    comboBoxFilterAttribute_ = new QComboBox();
    comboBoxFilterAttribute_->setMinimumWidth(100);
    searchLayout->addWidget(comboBoxFilterAttribute_);
    mainLayout->addLayout(searchLayout);

    // table
    mainLayout->addWidget(table_);

    // buttons
    QHBoxLayout* buttonLayout = new QHBoxLayout();
    buttonLayout->addStretch();
    cancelButton_ = new QPushButton(tr("Cancel"));
    cancelButton_->setFixedWidth(100);
    buttonLayout->addWidget(cancelButton_);
    selectAllButton_ = new QPushButton(tr("Select All"));
    selectAllButton_->setFixedWidth(100);
    buttonLayout->addWidget(selectAllButton_);
    loadButton_ = new QPushButton(tr("Load"));
    loadButton_->setFixedWidth(100);
    QFont loadFont(loadButton_->font());
    loadFont.setBold(true);
    loadButton_->setFont(loadFont);
    buttonLayout->addWidget(loadButton_);
    mainLayout->addLayout(buttonLayout);

    setLayout(mainLayout);

    connect(table_, SIGNAL(itemSelectionChanged()), this, SLOT(updateGuiState()));
    connect(table_, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(cellDoubleClicked()));

    connect(filterTextBox_, SIGNAL(textChanged(const QString&)), this, SLOT(updateTableRows()));
    connect(filterTextBox_, SIGNAL(editingFinished()), this, SLOT(updateTableRows()));
    connect(comboBoxFilterAttribute_, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTableRows()));

    connect(loadButton_, SIGNAL(clicked()), this, SLOT(loadClicked()));
    connect(selectAllButton_, SIGNAL(clicked()), this, SLOT(selectAllClicked()));
    connect(cancelButton_, SIGNAL(clicked()), this, SLOT(cancelClicked()));

    resize(600, 300);
    updateGuiState();
}
Пример #10
0
void VolumeListingDialog::updateTableRows() {
    tgtAssert(table_->columnCount() == metaDataKeys_.size() + 1 /*+1 for URL*/, "column count mismatch");

    QString filterAttribute;
    if (comboBoxFilterAttribute_->currentIndex() > 0)
        filterAttribute = comboBoxFilterAttribute_->currentText();

    std::vector<VolumeOrigin> filteredOriginsNew = getFilteredOrigins(filterTextBox_->text().trimmed(), filterAttribute);
    if (filteredOrigins_ == filteredOriginsNew)
        return;
    else
        filteredOrigins_ = filteredOriginsNew;
    
    table_->clearContents();
    table_->setRowCount(static_cast<int>(filteredOrigins_.size()));

    // disable sorting during insertion 
    table_->setSortingEnabled(false);  

    // iterate over filter origins create a row for each
    for (size_t i=0; i<filteredOrigins_.size(); i++) {
        VolumeOrigin& origin = filteredOrigins_.at(i);
        // fill row cells with meta data entries
        for (int m=0; m<metaDataKeys_.size(); m++) {
            std::string key = metaDataKeys_.at(m).toStdString();
            std::string cellText;
            const MetaDataBase* metaDate = origin.getMetaDataContainer().getMetaData(key); 
            if (metaDate)
                cellText = metaDate->toString();

            // set cell content type according to type of meta data item
            QTableWidgetItem* cellItem = new QTableWidgetItem(); 
            if (dynamic_cast<const IntMetaData*>(metaDate))
                cellItem->setData(Qt::DisplayRole, static_cast<const IntMetaData*>(metaDate)->getValue());
            else if (dynamic_cast<const SizeTMetaData*>(metaDate))
                cellItem->setData(Qt::DisplayRole, static_cast<qulonglong>(static_cast<const SizeTMetaData*>(metaDate)->getValue())); 
            else if (dynamic_cast<const FloatMetaData*>(metaDate))
                cellItem->setData(Qt::DisplayRole, static_cast<const FloatMetaData*>(metaDate)->getValue()); 
            else if (dynamic_cast<const DoubleMetaData*>(metaDate))
                cellItem->setData(Qt::DisplayRole, static_cast<const DoubleMetaData*>(metaDate)->getValue()); 
            else
                cellItem->setData(Qt::DisplayRole, QString::fromStdString(cellText));

            cellItem->setToolTip(QString::fromStdString(key) + ": " + QString::fromStdString(cellText));
            //cellItem->setTextAlignment(Qt::AlignLeft);
            cellItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
            table_->setItem(static_cast<int>(i), m, cellItem);
        }

        // put URL into last cell
        QTableWidgetItem* urlItem = new QTableWidgetItem(QString::fromStdString(origin.getURL())); 
        urlItem->setToolTip("URL: " + QString::fromStdString(origin.getURL()));
        //urlItem->setTextAlignment(Qt::AlignLeft);
        urlItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
        table_->setItem(static_cast<int>(i), table_->columnCount()-1, urlItem);
    }

    table_->setSortingEnabled(true);  

    updateGuiState();
}