QvisDatabaseCorrelationWindow.C 17.7 KB
Newer Older
hrchilds's avatar
hrchilds committed
1 2
/*****************************************************************************
*
3
* Copyright (c) 2000 - 2014, Lawrence Livermore National Security, LLC
hrchilds's avatar
hrchilds committed
4
* Produced at the Lawrence Livermore National Laboratory
5
* LLNL-CODE-442911
hrchilds's avatar
hrchilds committed
6 7
* All rights reserved.
*
8
* This file is  part of VisIt. For  details, see https://visit.llnl.gov/.  The
hrchilds's avatar
hrchilds committed
9 10 11 12 13 14 15 16 17 18
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution  and  use  in  source  and  binary  forms,  with  or  without
* modification, are permitted provided that the following conditions are met:
*
*  - Redistributions of  source code must  retain the above  copyright notice,
*    this list of conditions and the disclaimer below.
*  - Redistributions in binary form must reproduce the above copyright notice,
*    this  list of  conditions  and  the  disclaimer (as noted below)  in  the
19 20 21
*    documentation and/or other materials provided with the distribution.
*  - Neither the name of  the LLNS/LLNL nor the names of  its contributors may
*    be used to endorse or promote products derived from this software without
hrchilds's avatar
hrchilds committed
22 23 24 25 26
*    specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT  HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR  IMPLIED WARRANTIES, INCLUDING,  BUT NOT  LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND  FITNESS FOR A PARTICULAR  PURPOSE
27 28 29
* ARE  DISCLAIMED. IN  NO EVENT  SHALL LAWRENCE  LIVERMORE NATIONAL  SECURITY,
* LLC, THE  U.S.  DEPARTMENT OF  ENERGY  OR  CONTRIBUTORS BE  LIABLE  FOR  ANY
* DIRECT,  INDIRECT,   INCIDENTAL,   SPECIAL,   EXEMPLARY,  OR   CONSEQUENTIAL
hrchilds's avatar
hrchilds committed
30 31 32 33 34 35 36 37 38
* DAMAGES (INCLUDING, BUT NOT  LIMITED TO, PROCUREMENT OF  SUBSTITUTE GOODS OR
* SERVICES; LOSS OF  USE, DATA, OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER
* CAUSED  AND  ON  ANY  THEORY  OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT
* LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING IN ANY  WAY
* OUT OF THE  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/

hrchilds's avatar
hrchilds committed
39 40
#include <QvisDatabaseCorrelationWindow.h>

whitlocb's avatar
whitlocb committed
41 42 43 44 45 46
#include <QComboBox>
#include <QLabel>
#include <QLayout>
#include <QLineEdit>
#include <QListWidget>
#include <QPushButton>
hrchilds's avatar
hrchilds committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70

#include <DatabaseCorrelationList.h>
#include <DatabaseCorrelation.h>
#include <GlobalAttributes.h>
#include <NameSimplifier.h>
#include <ViewerProxy.h>

#include <map>

//
// Static members
//
int QvisDatabaseCorrelationWindow::instanceCount = 0;

// ****************************************************************************
// Method: QvisDatabaseCorrelationWindow::QvisDatabaseCorrelationWindow
//
// Purpose: 
//   Constructor for the QvisDatabaseCorrelationWindow class.
//
// Programmer: Brad Whitlock
// Creation:   Mon Mar 29 12:25:11 PDT 2004
//
// Modifications:
71 72 73
//   Brad Whitlock, Wed Apr  9 11:49:05 PDT 2008
//   QString for caption.
//
hrchilds's avatar
hrchilds committed
74 75 76
// ****************************************************************************

QvisDatabaseCorrelationWindow::QvisDatabaseCorrelationWindow(
77
    const QString &correlationName, const QString &caption) :
hrchilds's avatar
hrchilds committed
78 79 80
    QvisWindowBase(caption), createMode(true)
{
    DatabaseCorrelation emptyCorrelation;
whitlocb's avatar
whitlocb committed
81
    emptyCorrelation.SetName(correlationName.toStdString());
hrchilds's avatar
hrchilds committed
82 83 84 85
    CreateWidgets(emptyCorrelation);
}

QvisDatabaseCorrelationWindow::QvisDatabaseCorrelationWindow(
86
    const DatabaseCorrelation &correlation, const QString &caption) :
hrchilds's avatar
hrchilds committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
    QvisWindowBase(caption), createMode(false)
{
    CreateWidgets(correlation);
}

// ****************************************************************************
// Method: QvisDatabaseCorrelationWindow::~QvisDatabaseCorrelationWindow
//
// Purpose: 
//   Destructor for the QvisDatabaseCorrelationWindow class.
//
// Programmer: Brad Whitlock
// Creation:   Mon Mar 29 12:25:43 PDT 2004
//
// Modifications:
//   
// ****************************************************************************

QvisDatabaseCorrelationWindow::~QvisDatabaseCorrelationWindow()
{
}

// ****************************************************************************
// Method: QvisDatabaseCorrelationWindow::CreateWidgets
//
// Purpose: 
//   Creates widgets for the window using the specified database correlation.
//
// Arguments:
//   correlation : The database correlation to use when creating the window.
//
// Programmer: Brad Whitlock
// Creation:   Mon Mar 29 12:25:59 PDT 2004
//
// Modifications:
122 123
//   Brad Whitlock, Tue Apr  8 09:27:26 PDT 2008
//   Support for internationalization.
hrchilds's avatar
hrchilds committed
124
//   
whitlocb's avatar
whitlocb committed
125 126 127
//   Cyrus Harrison, Tue Jun 10 10:04:26 PDT 20
//   Initial Qt4 Port.
//
hrchilds's avatar
hrchilds committed
128 129 130 131 132 133 134 135 136 137 138 139 140 141
// ****************************************************************************

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.
whitlocb's avatar
whitlocb committed
142 143 144
    QGridLayout *gLayout = new QGridLayout();
    topLayout->addLayout(gLayout);
    correlationNameLineEdit = new QLineEdit(central);
hrchilds's avatar
hrchilds committed
145 146
    correlationNameLineEdit->setText(correlation.GetName().c_str());
    correlationNameLineEdit->setEnabled(createMode);
whitlocb's avatar
whitlocb committed
147
    QLabel *nameLabel = new QLabel(tr("Name"), central);
hrchilds's avatar
hrchilds committed
148 149 150 151 152
    nameLabel->setEnabled(createMode);
    gLayout->addWidget(nameLabel, 0, 0);
    gLayout->addWidget(correlationNameLineEdit, 0, 1);

    // Create the correlation method combobox.
whitlocb's avatar
whitlocb committed
153 154 155 156 157
    correlationMethodComboBox = new QComboBox(central);
    correlationMethodComboBox->addItem(tr("Padded index"));
    correlationMethodComboBox->addItem(tr("Stretched index"));
    correlationMethodComboBox->addItem(tr("Time"));
    correlationMethodComboBox->addItem(tr("Cycle"));
hrchilds's avatar
hrchilds committed
158
    int method = (int)correlation.GetMethod();
whitlocb's avatar
whitlocb committed
159
    correlationMethodComboBox->setCurrentIndex(method);
hrchilds's avatar
hrchilds committed
160
    gLayout->addWidget(correlationMethodComboBox, 1, 1);
whitlocb's avatar
whitlocb committed
161
    gLayout->addWidget(new QLabel(tr("Correlation method"), central), 1, 0);
hrchilds's avatar
hrchilds committed
162 163 164
    topLayout->addSpacing(10);

    // Create the widgets that let us add sources to the database correlation.
whitlocb's avatar
whitlocb committed
165 166
    QGridLayout *srcLayout = new QGridLayout();
    topLayout->addLayout(srcLayout);
hrchilds's avatar
hrchilds committed
167 168
    srcLayout->setSpacing(5);
    const int S[] = {1, 5, 1, 1, 5};
hkrishna's avatar
hkrishna committed
169
    size_t i;
hrchilds's avatar
hrchilds committed
170 171
    for(i = 0; i < 5; ++i)
        srcLayout->setRowStretch(i, S[i]);
whitlocb's avatar
whitlocb committed
172 173
    srcLayout->addWidget(new QLabel(tr("Sources"), central), 0, 0);
    srcLayout->addWidget(new QLabel(tr("Correlated sources"), central), 0, 2);
hrchilds's avatar
hrchilds committed
174 175 176 177 178

    //
    // Simplify the source names.
    //
    NameSimplifier simplifier;
hrchilds's avatar
hrchilds committed
179
    const stringVector &sources = GetViewerState()->GetGlobalAttributes()->GetSources();
hrchilds's avatar
hrchilds committed
180 181 182 183 184 185 186 187 188 189 190 191
    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.
whitlocb's avatar
whitlocb committed
192 193
    sourcesListBox = new QListWidget(central);
    sourcesListBox->setSelectionMode(QAbstractItemView::MultiSelection);
hrchilds's avatar
hrchilds committed
194 195 196
    for(i = 0; i < sources.size(); ++i)
    {
        if(!correlation.UsesDatabase(sources[i]))
whitlocb's avatar
whitlocb committed
197
            sourcesListBox->addItem(shortSources[i].c_str());
hrchilds's avatar
hrchilds committed
198 199 200
    }
    if(sources.size() > 0)
        sourcesListBox->setCurrentItem(0);
whitlocb's avatar
whitlocb committed
201
    connect(sourcesListBox, SIGNAL(currentRowChanged(int)),
hrchilds's avatar
hrchilds committed
202
            this, SLOT(setAddButtonEnabled(int)));
whitlocb's avatar
whitlocb committed
203
    srcLayout->addWidget(sourcesListBox, 1, 0, 5, 1);
hrchilds's avatar
hrchilds committed
204 205

    // Create and populate the list of correlated sources.
whitlocb's avatar
whitlocb committed
206 207
    correlatedSourcesListBox = new QListWidget(central);
    correlatedSourcesListBox->setSelectionMode(QAbstractItemView::MultiSelection);
hrchilds's avatar
hrchilds committed
208
    const stringVector &dbs = correlation.GetDatabaseNames();
hkrishna's avatar
hkrishna committed
209
    for(i = 0; i < (size_t)correlation.GetNumDatabases(); ++i)
whitlocb's avatar
whitlocb committed
210
        correlatedSourcesListBox->addItem(longToShort[dbs[i]].c_str());
hrchilds's avatar
hrchilds committed
211
    if(dbs.size() > 0)
whitlocb's avatar
whitlocb committed
212 213
        correlatedSourcesListBox->setCurrentRow(0);
    connect(correlatedSourcesListBox, SIGNAL(currentRowChanged(int)),
hrchilds's avatar
hrchilds committed
214
            this, SLOT(setRemoveButtonEnabled(int)));
whitlocb's avatar
whitlocb committed
215
    srcLayout->addWidget(correlatedSourcesListBox, 1, 2, 5, 1);
hrchilds's avatar
hrchilds committed
216 217

    // Create the add and remove buttons.
whitlocb's avatar
whitlocb committed
218
    addButton = new QPushButton("-->", central);
hrchilds's avatar
hrchilds committed
219 220 221 222
    connect(addButton, SIGNAL(clicked()),
            this, SLOT(addSources()));
    srcLayout->addWidget(addButton, 2, 1);

whitlocb's avatar
whitlocb committed
223
    removeButton = new QPushButton("<--", central);
hrchilds's avatar
hrchilds committed
224 225 226 227 228 229 230
    connect(removeButton, SIGNAL(clicked()),
            this, SLOT(removeSources()));
    srcLayout->addWidget(removeButton, 3, 1);

    UpdateAddRemoveButtonsEnabledState();

    // Add the action and cancel buttons.
whitlocb's avatar
whitlocb committed
231 232 233
    //topLayout->addSpacing(10);
    QHBoxLayout *actionButtonLayout = new QHBoxLayout();
    topLayout->addLayout(actionButtonLayout);
hrchilds's avatar
hrchilds committed
234
    QPushButton *actionButton = new QPushButton(
whitlocb's avatar
whitlocb committed
235
        createMode?tr("Create database correlation") : tr("Alter database correlation"), central);
hrchilds's avatar
hrchilds committed
236 237 238 239
    connect(actionButton, SIGNAL(clicked()),
            this, SLOT(actionClicked()));
    actionButtonLayout->addWidget(actionButton);
    actionButtonLayout->addStretch(10);
whitlocb's avatar
whitlocb committed
240
    QPushButton *cancelButton = new QPushButton(tr("Cancel"), central);
hrchilds's avatar
hrchilds committed
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
    connect(cancelButton, SIGNAL(clicked()),
            this, SLOT(cancelClicked()));
    actionButtonLayout->addWidget(cancelButton);
}

// ****************************************************************************
// Method: QvisDatabaseCorrelationWindow::SelectedCount
//
// Purpose: 
//   Determines how many items are selected in the specified list box.
//
// Arguments:
//   lb : The list box to check.
//
// Returns:    The number of selected items in the specified list box.
//
// Note:       
//
// Programmer: Brad Whitlock
// Creation:   Mon Mar 29 12:26:55 PDT 2004
//
// Modifications:
whitlocb's avatar
whitlocb committed
263 264 265
//   Cyrus Harrison, Tue Jun 10 10:04:26 PDT 20
//   Initial Qt4 Port.
//
hrchilds's avatar
hrchilds committed
266 267 268
// ****************************************************************************

int
whitlocb's avatar
whitlocb committed
269
QvisDatabaseCorrelationWindow::SelectedCount(const QListWidget *lb) const
hrchilds's avatar
hrchilds committed
270 271 272
{
    int selCount = 0;
    for(int i = 0; i < lb->count(); ++i)
whitlocb's avatar
whitlocb committed
273
        if(lb->item(i)->isSelected())
hrchilds's avatar
hrchilds committed
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
            ++selCount;

    return selCount;
}

// ****************************************************************************
// Method: QvisDatabaseCorrelationWindow::UpdateAddRemoveButtonsEnabledState
//
// Purpose: 
//   Updates the enabled state for the add/remove buttons.
//
// Programmer: Brad Whitlock
// Creation:   Mon Mar 29 12:27:38 PDT 2004
//
// Modifications:
//   
// ****************************************************************************

void
QvisDatabaseCorrelationWindow::UpdateAddRemoveButtonsEnabledState()
{
    addButton->setEnabled(SelectedCount(sourcesListBox) > 0);
    removeButton->setEnabled(SelectedCount(correlatedSourcesListBox) > 0);
}

// ****************************************************************************
// Method: QvisDatabaseCorrelationWindow::TransferItems
//
// Purpose: 
//   Transfers the selected items in one list box to the other list box.
//
// Arguments:
//   srcLB  : The source list box that is losing items.
//   destLB : The list box that is gaining items.
//
// Programmer: Brad Whitlock
// Creation:   Mon Mar 29 12:28:06 PDT 2004
//
// Modifications:
whitlocb's avatar
whitlocb committed
313 314 315
//   Cyrus Harrison, Tue Jun 10 10:04:26 PDT 20
//   Initial Qt4 Port.
//
hrchilds's avatar
hrchilds committed
316 317 318
// ****************************************************************************

void
whitlocb's avatar
whitlocb committed
319
QvisDatabaseCorrelationWindow::TransferItems(QListWidget *srcLB, QListWidget *destLB)
hrchilds's avatar
hrchilds committed
320 321 322
{
    stringVector src;
    stringVector dest;
hkrishna's avatar
hkrishna committed
323 324
    size_t i;
    for(i = 0; i < (size_t)srcLB->count(); ++i)
hrchilds's avatar
hrchilds committed
325
    {
whitlocb's avatar
whitlocb committed
326 327
        if(srcLB->item(i)->isSelected())
            dest.push_back(srcLB->item(i)->text().toStdString());
hrchilds's avatar
hrchilds committed
328
        else
whitlocb's avatar
whitlocb committed
329
            src.push_back(srcLB->item(i)->text().toStdString());
hrchilds's avatar
hrchilds committed
330 331
    }

hkrishna's avatar
hkrishna committed
332
    for(i = 0; i < (size_t)destLB->count(); ++i)
whitlocb's avatar
whitlocb committed
333
        dest.push_back(destLB->item(i)->text().toStdString());
hrchilds's avatar
hrchilds committed
334 335 336 337

    srcLB->blockSignals(true);
    srcLB->clear();
    for(i = 0; i < src.size(); ++i)
whitlocb's avatar
whitlocb committed
338
        srcLB->addItem(src[i].c_str());
hrchilds's avatar
hrchilds committed
339 340 341 342 343 344 345
    if(src.size() > 0)
        srcLB->setCurrentItem(0);
    srcLB->blockSignals(false);

    destLB->blockSignals(true);
    destLB->clear();
    for(i = 0; i < dest.size(); ++i)
whitlocb's avatar
whitlocb committed
346
        destLB->addItem(dest[i].c_str());
hrchilds's avatar
hrchilds committed
347
    if(dest.size() > 0)
whitlocb's avatar
whitlocb committed
348
        destLB->setCurrentRow(0);
hrchilds's avatar
hrchilds committed
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420
    destLB->blockSignals(false);

    UpdateAddRemoveButtonsEnabledState();
}

//
// Qt slot functions
//

void
QvisDatabaseCorrelationWindow::setAddButtonEnabled(int)
{
    UpdateAddRemoveButtonsEnabledState();
}

void
QvisDatabaseCorrelationWindow::setRemoveButtonEnabled(int)
{
    UpdateAddRemoveButtonsEnabledState();
}

// ****************************************************************************
// Method: QvisDatabaseCorrelationWindow::addSources
//
// Purpose: 
//   This is a Qt slot function that is called when you want to add sources
//   to the correlation.
//
// Programmer: Brad Whitlock
// Creation:   Mon Mar 29 12:29:28 PDT 2004
//
// Modifications:
//   
// ****************************************************************************

void
QvisDatabaseCorrelationWindow::addSources()
{
    TransferItems(sourcesListBox, correlatedSourcesListBox);
}

// ****************************************************************************
// Method: QvisDatabaseCorrelationWindow::removeSources
//
// Purpose: 
//   This is a Qt slot function that is called when you want to remove sources
//   from the correlation.
//
// Programmer: Brad Whitlock
// Creation:   Mon Mar 29 12:29:28 PDT 2004
//
// Modifications:
//   
// ****************************************************************************

void
QvisDatabaseCorrelationWindow::removeSources()
{
    TransferItems(correlatedSourcesListBox, sourcesListBox);
}

// ****************************************************************************
// Method: QvisDatabaseCorrelationWindow::actionClicked
//
// Purpose: 
//   This is a Qt slot function that is called when you click the button to
//   either create or alter the database correlation.
//
// Programmer: Brad Whitlock
// Creation:   Mon Mar 29 12:30:20 PDT 2004
//
// Modifications:
421 422
//   Brad Whitlock, Tue Apr  8 09:27:26 PDT 2008
//   Support for internationalization.
hrchilds's avatar
hrchilds committed
423
//   
whitlocb's avatar
whitlocb committed
424 425 426
//   Cyrus Harrison, Tue Jun 10 10:04:26 PDT 20
//   Initial Qt4 Port.
//
hrchilds's avatar
hrchilds committed
427 428 429 430 431 432 433
// ****************************************************************************

void
QvisDatabaseCorrelationWindow::actionClicked()
{
    std::string name;
    stringVector dbs;
whitlocb's avatar
whitlocb committed
434
    int method = correlationMethodComboBox->currentIndex();
hrchilds's avatar
hrchilds committed
435 436 437 438

    //
    // Get the name from the line edit.
    //
whitlocb's avatar
whitlocb committed
439
    name = correlationNameLineEdit->displayText().trimmed().toStdString();
hrchilds's avatar
hrchilds committed
440 441 442 443 444 445 446 447

    //
    // If we're creating a new correlation, check the name in the line edit.
    //
    if(createMode)
    {
        if(name.size() < 1)
        {
448
            Warning(tr("A new database correlation must have a name."));
whitlocb's avatar
whitlocb committed
449
            correlationNameLineEdit->activateWindow();
hrchilds's avatar
hrchilds committed
450 451 452 453 454 455 456 457
            correlationNameLineEdit->setFocus();
            correlationNameLineEdit->setSelection(0,
                correlationNameLineEdit->displayText().length());
            return;
        }
        else
        {
            // See if the name is already used.
hrchilds's avatar
hrchilds committed
458
            DatabaseCorrelationList *cL = GetViewerState()->GetDatabaseCorrelationList();
hrchilds's avatar
hrchilds committed
459 460
            if(cL->FindCorrelation(name))
            {
461
                Warning(tr("The given database correlation name is already "
hrchilds's avatar
hrchilds committed
462
                        "being used. Please change the name of this "
463
                        "correlation."));
whitlocb's avatar
whitlocb committed
464
                correlationNameLineEdit->activateWindow();
hrchilds's avatar
hrchilds committed
465 466 467 468 469 470 471 472 473 474 475 476
                correlationNameLineEdit->setFocus();
                correlationNameLineEdit->setSelection(0,
                    correlationNameLineEdit->displayText().length());
                return;
            }
        }
    }

    //
    // Simplify the current source names.
    //
    NameSimplifier simplifier;
hrchilds's avatar
hrchilds committed
477
    const stringVector &sources = GetViewerState()->GetGlobalAttributes()->GetSources();
hkrishna's avatar
hkrishna committed
478
    size_t i;
hrchilds's avatar
hrchilds committed
479 480 481 482 483 484 485 486 487
    for(i = 0; i < sources.size(); ++i)
        simplifier.AddName(sources[i]);
    stringVector shortSources;
    simplifier.GetSimplifiedNames(shortSources);
    std::map<std::string, std::string> shortToLong;
    for(i = 0; i < sources.size(); ++i)
        shortToLong[shortSources[i]] = sources[i];

    // Get the sources from the correlated source list.
hkrishna's avatar
hkrishna committed
488
    for(i = 0; i < (size_t)correlatedSourcesListBox->count(); ++i)
hrchilds's avatar
hrchilds committed
489
    {
whitlocb's avatar
whitlocb committed
490
        std::string srcName(correlatedSourcesListBox->item(i)->text().toStdString());
hrchilds's avatar
hrchilds committed
491 492 493 494 495
        dbs.push_back(shortToLong[srcName]);
    }
    if(dbs.size() < 1)
    {
        QString msg;
496 497 498 499 500 501 502
        QString s1(tr("A database correlation must have at least one correlated "
                      "source."));
        QString s2(tr("You must add a correlated source before you can create "
                      "this database correlation."));
        QString s3(tr("You must add a correlated source before you can alter "
                      "this database correlation."));
        msg = s1 + (createMode ? s2 : s3);
hrchilds's avatar
hrchilds committed
503 504 505 506 507 508 509 510
        Warning(msg);
    }

    //
    // Do the right thing in the viewer.
    //
    if(createMode)
    {
hrchilds's avatar
hrchilds committed
511
        GetViewerMethods()->CreateDatabaseCorrelation(name, dbs, method);
hrchilds's avatar
hrchilds committed
512 513 514
    }
    else
    {
hrchilds's avatar
hrchilds committed
515
        GetViewerMethods()->AlterDatabaseCorrelation(name, dbs, method);
hrchilds's avatar
hrchilds committed
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540
    }

    cancelClicked();
}

// ****************************************************************************
// Method: QvisDatabaseCorrelationWindow::cancelClicked
//
// Purpose: 
//   This is a Qt slot function that is called when the window is getting
//   dismissed.
//
// Programmer: Brad Whitlock
// Creation:   Mon Mar 29 12:31:28 PDT 2004
//
// Modifications:
//   
// ****************************************************************************

void
QvisDatabaseCorrelationWindow::cancelClicked()
{
    hide();
    emit deleteMe(this);
}