void ViewerDatabaseCorrelationMethods::UpdateDatabaseCorrelation(const std::string &cName) { DatabaseCorrelation *c = GetViewerState()->GetDatabaseCorrelationList()->FindCorrelation(cName); if(c != 0) { DatabaseCorrelation *replacementCorrelation = CreateDatabaseCorrelation( c->GetName(), c->GetDatabaseNames(), (int)c->GetMethod()); if(replacementCorrelation != 0) { // Copy over the old database correlation. *c = *replacementCorrelation; } } }
DatabaseCorrelation * DatabaseCorrelationList::FindCorrelation(const std::string &name) const { DatabaseCorrelation *retval = 0; for(size_t i = 0; i < correlations.size(); ++i) { DatabaseCorrelation *c = (DatabaseCorrelation *)correlations[i]; if(name == c->GetName()) { retval = c; break; } } return retval; }
void QvisDatabaseCorrelationWindow::CreateWidgets( const DatabaseCorrelation &correlation) { QWidget *central = new QWidget(this); setCentralWidget(central); QVBoxLayout *topLayout = new QVBoxLayout(central); topLayout->setMargin(10); topLayout->setSpacing(5); // Create the name line edit. QGridLayout *gLayout = new QGridLayout(); topLayout->addLayout(gLayout); correlationNameLineEdit = new QLineEdit(central); correlationNameLineEdit->setText(correlation.GetName().c_str()); correlationNameLineEdit->setEnabled(createMode); QLabel *nameLabel = new QLabel(tr("Name"), central); nameLabel->setEnabled(createMode); gLayout->addWidget(nameLabel, 0, 0); gLayout->addWidget(correlationNameLineEdit, 0, 1); // Create the correlation method combobox. correlationMethodComboBox = new QComboBox(central); correlationMethodComboBox->addItem(tr("Padded index")); correlationMethodComboBox->addItem(tr("Stretched index")); correlationMethodComboBox->addItem(tr("Time")); correlationMethodComboBox->addItem(tr("Cycle")); int method = (int)correlation.GetMethod(); correlationMethodComboBox->setCurrentIndex(method); gLayout->addWidget(correlationMethodComboBox, 1, 1); gLayout->addWidget(new QLabel(tr("Correlation method"), central), 1, 0); topLayout->addSpacing(10); // Create the widgets that let us add sources to the database correlation. QGridLayout *srcLayout = new QGridLayout(); topLayout->addLayout(srcLayout); srcLayout->setSpacing(5); const int S[] = {1, 5, 1, 1, 5}; int i; for(i = 0; i < 5; ++i) srcLayout->setRowStretch(i, S[i]); srcLayout->addWidget(new QLabel(tr("Sources"), central), 0, 0); srcLayout->addWidget(new QLabel(tr("Correlated sources"), central), 0, 2); // // Simplify the source names. // NameSimplifier simplifier; const stringVector &sources = GetViewerState()->GetGlobalAttributes()->GetSources(); for(i = 0; i < sources.size(); ++i) simplifier.AddName(sources[i]); stringVector shortSources; simplifier.GetSimplifiedNames(shortSources); std::map<std::string, std::string> shortToLong, longToShort; for(i = 0; i < sources.size(); ++i) { shortToLong[shortSources[i]] = sources[i]; longToShort[sources[i]] = shortSources[i]; } // Create and populate the list of sources. sourcesListBox = new QListWidget(central); sourcesListBox->setSelectionMode(QAbstractItemView::MultiSelection); for(i = 0; i < sources.size(); ++i) { if(!correlation.UsesDatabase(sources[i])) sourcesListBox->addItem(shortSources[i].c_str()); } if(sources.size() > 0) sourcesListBox->setCurrentItem(0); connect(sourcesListBox, SIGNAL(currentRowChanged(int)), this, SLOT(setAddButtonEnabled(int))); srcLayout->addWidget(sourcesListBox, 1, 0, 5, 1); // Create and populate the list of correlated sources. correlatedSourcesListBox = new QListWidget(central); correlatedSourcesListBox->setSelectionMode(QAbstractItemView::MultiSelection); const stringVector &dbs = correlation.GetDatabaseNames(); for(i = 0; i < correlation.GetNumDatabases(); ++i) correlatedSourcesListBox->addItem(longToShort[dbs[i]].c_str()); if(dbs.size() > 0) correlatedSourcesListBox->setCurrentRow(0); connect(correlatedSourcesListBox, SIGNAL(currentRowChanged(int)), this, SLOT(setRemoveButtonEnabled(int))); srcLayout->addWidget(correlatedSourcesListBox, 1, 2, 5, 1); // Create the add and remove buttons. addButton = new QPushButton("-->", central); connect(addButton, SIGNAL(clicked()), this, SLOT(addSources())); srcLayout->addWidget(addButton, 2, 1); removeButton = new QPushButton("<--", central); connect(removeButton, SIGNAL(clicked()), this, SLOT(removeSources())); srcLayout->addWidget(removeButton, 3, 1); UpdateAddRemoveButtonsEnabledState(); // Add the action and cancel buttons. //topLayout->addSpacing(10); QHBoxLayout *actionButtonLayout = new QHBoxLayout(); topLayout->addLayout(actionButtonLayout); QPushButton *actionButton = new QPushButton( createMode?tr("Create database correlation") : tr("Alter database correlation"), central); connect(actionButton, SIGNAL(clicked()), this, SLOT(actionClicked())); actionButtonLayout->addWidget(actionButton); actionButtonLayout->addStretch(10); QPushButton *cancelButton = new QPushButton(tr("Cancel"), central); connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelClicked())); actionButtonLayout->addWidget(cancelButton); }