QvisAppearanceWindow.C 21.1 KB
Newer Older
hrchilds's avatar
hrchilds committed
1 2
/*****************************************************************************
*
3
* Copyright (c) 2000 - 2015, 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
#include <QvisAppearanceWindow.h>
whitlocb's avatar
whitlocb committed
40 41 42 43 44 45 46
#include <QApplication>
#include <QCheckBox>
#include <QComboBox>
#include <QLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
47
#include <QStyleFactory>
hrchilds's avatar
hrchilds committed
48

hrchilds's avatar
hrchilds committed
49
#include <QvisColorButton.h>
hrchilds's avatar
hrchilds committed
50
#include <QvisDialogLineEdit.h>
hrchilds's avatar
hrchilds committed
51 52 53
#include <AppearanceAttributes.h>
#include <ViewerProxy.h>

hrchilds's avatar
hrchilds committed
54

hrchilds's avatar
hrchilds committed
55 56 57 58 59 60 61 62 63 64
// ****************************************************************************
// Method: QvisAppearanceWindow::QvisAppearanceWindow
//
// Purpose: 
//   This is the constructor for the QvisAppearanceWindow class.
//
// Programmer: Brad Whitlock
// Creation:   Thu Sep 6 12:27:16 PDT 2001
//
// Modifications:
65 66 67
//   Brad Whitlock, Wed Apr  9 11:10:51 PDT 2008
//   QString for caption, shortName.
//
68 69 70
//   Kathleen Biagas, Fri Jan 22 14:12:09 PST 2016
//   Retrieve style names from QStyleFactory.
//
hrchilds's avatar
hrchilds committed
71 72 73
// ****************************************************************************

QvisAppearanceWindow::QvisAppearanceWindow(AppearanceAttributes *subj,
74
    const QString &caption, const QString &shortName, QvisNotepadArea *notepad) :
hrchilds's avatar
hrchilds committed
75 76 77
    QvisPostableWindowObserver(subj, caption, shortName, notepad,
                               QvisPostableWindowObserver::ApplyButton)
{
78
    styleNames = QStyleFactory::keys();
hrchilds's avatar
hrchilds committed
79 80 81 82 83 84 85 86 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
}

// ****************************************************************************
// Method: QvisAppearanceWindow::~QvisAppearanceWindow
//
// Purpose: 
//   This is the destructor for the QvisAppearanceWindow class.
//
// Programmer: Brad Whitlock
// Creation:   Thu Sep 6 12:28:27 PDT 2001
//
// Modifications:
//   
// ****************************************************************************

QvisAppearanceWindow::~QvisAppearanceWindow()
{
    // Nothing here
}

// ****************************************************************************
// Method: QvisAppearanceWindow::CreateWindowContents
//
// Purpose: 
//   This method creates the widgets for the window.
//
// Programmer: Brad Whitlock
// Creation:   Thu Sep 6 12:31:03 PDT 2001
//
// Modifications:
//   Brad Whitlock, Tue Jan 29 13:16:20 PST 2002
//   Added orientation combo box.
//
hrchilds's avatar
hrchilds committed
112 113 114
//   Brad Whitlock, Fri Aug 15 13:08:37 PST 2003
//   I changed how the style menu is populated.
//
hrchilds's avatar
hrchilds committed
115 116 117
//   Brad Whitlock, Thu Mar 15 15:25:51 PST 2007
//   Added font support.
//
118 119 120
//   Brad Whitlock, Tue Apr  8 09:27:26 PDT 2008
//   Support for internationalization.
//
whitlocb's avatar
whitlocb committed
121 122 123 124 125 126
//   Brad Whitlock, Thu Jun 19 11:11:54 PDT 2008
//   Qt 4.
//
//   Cyrus Harrison, Mon Nov 24 11:57:42 PST 2008
//   Support for default system appearance.
//
127 128 129
//   Kathleen Biagas, Fri Jan 22 14:12:31 PST 2016
//   styleNames now stored as a QStringList.
//
hrchilds's avatar
hrchilds committed
130 131 132 133 134
// ****************************************************************************

void
QvisAppearanceWindow::CreateWindowContents()
{
whitlocb's avatar
whitlocb committed
135 136 137 138 139 140 141
    QGridLayout *mainLayout = new QGridLayout(0);
    mainLayout->setSpacing(10);
    topLayout->addLayout(mainLayout);

    int row = 0;
    
    useSysDefaultCheckBox = new QCheckBox(central);
142 143
    connect(useSysDefaultCheckBox , SIGNAL(toggled(bool)),
            this, SLOT(useSysDefaultChanged(bool)));
whitlocb's avatar
whitlocb committed
144
    useSysDefaultCheckBox->setText(
145
      tr("Use default system appearance"));
whitlocb's avatar
whitlocb committed
146 147 148
    mainLayout->addWidget(useSysDefaultCheckBox,row,0,1,3);
    row++;
    
hrchilds's avatar
hrchilds committed
149
    // Create the background color button.
whitlocb's avatar
whitlocb committed
150
    backgroundColorButton = new QvisColorButton(central);
hrchilds's avatar
hrchilds committed
151 152
    connect(backgroundColorButton, SIGNAL(selectedColor(const QColor &)),
            this, SLOT(backgroundChanged(const QColor &)));
whitlocb's avatar
whitlocb committed
153 154 155 156 157
    mainLayout->addWidget(backgroundColorButton, row, 1);
    backgroundColorLabel = new QLabel(tr("GUI background"), central);
    backgroundColorLabel->setBuddy(backgroundColorButton);
    mainLayout->addWidget(backgroundColorLabel, row, 0);
    row++;
hrchilds's avatar
hrchilds committed
158 159

    // Create the background color button.
whitlocb's avatar
whitlocb committed
160
    foregroundColorButton = new QvisColorButton(central);
hrchilds's avatar
hrchilds committed
161 162
    connect(foregroundColorButton, SIGNAL(selectedColor(const QColor &)),
            this, SLOT(foregroundChanged(const QColor &)));
whitlocb's avatar
whitlocb committed
163 164 165 166 167 168
    mainLayout->addWidget(foregroundColorButton, row, 1);
    foregroundColorLabel = new QLabel(tr("GUI foreground"), central);
    foregroundColorLabel->setBuddy(foregroundColorButton);
    mainLayout->addWidget(foregroundColorLabel, row, 0);
    row++;
    
hrchilds's avatar
hrchilds committed
169
    // Create the style combo box.
whitlocb's avatar
whitlocb committed
170
    styleComboBox = new QComboBox(central);
171 172
    for(int i = 0; i < styleNames.size(); ++i)
        styleComboBox->addItem(styleNames.at(i));
hrchilds's avatar
hrchilds committed
173 174
    connect(styleComboBox, SIGNAL(activated(int)),
            this, SLOT(styleChanged(int)));
whitlocb's avatar
whitlocb committed
175 176 177 178 179
    mainLayout->addWidget(styleComboBox, row, 1);
    styleLabel = new QLabel(tr("GUI style"), central);
    styleLabel->setBuddy(styleComboBox);
    mainLayout->addWidget(styleLabel, row, 0);
    row++;
hrchilds's avatar
hrchilds committed
180 181

    // Create the orientation combo box.
whitlocb's avatar
whitlocb committed
182 183 184
    orientationComboBox = new QComboBox(central);
    orientationComboBox->addItem(tr("Vertical"));
    orientationComboBox->addItem(tr("Horizontal"));
hrchilds's avatar
hrchilds committed
185 186
    connect(orientationComboBox, SIGNAL(activated(int)),
            this, SLOT(orientationChanged(int)));
whitlocb's avatar
whitlocb committed
187 188 189 190 191
    mainLayout->addWidget(orientationComboBox, row, 1);
    orientationLabel = new QLabel(tr("GUI orientation"), central);
    orientationLabel->setBuddy(orientationComboBox);
    mainLayout->addWidget(orientationLabel, row, 0);
    row++;
hrchilds's avatar
hrchilds committed
192

hrchilds's avatar
hrchilds committed
193
    // Create the font edit.
whitlocb's avatar
whitlocb committed
194
    fontName = new QvisDialogLineEdit(central);
hrchilds's avatar
hrchilds committed
195 196 197
    fontName->setDialogMode(QvisDialogLineEdit::ChooseFont);
    connect(fontName, SIGNAL(textChanged(const QString &)),
            this, SLOT(fontNameChanged(const QString &)));
whitlocb's avatar
whitlocb committed
198 199 200 201 202
    mainLayout->addWidget(fontName, row, 1, 1, 2);
    fontLabel = new QLabel(tr("GUI font"), central);
    fontLabel->setBuddy(fontName);
    mainLayout->addWidget(fontLabel, row, 0);
    row++;
hrchilds's avatar
hrchilds committed
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
}

// ****************************************************************************
// Method: QvisAppearanceWindow::UpdateWindow
//
// Purpose: 
//   This method is called when the appearance attributes are updated.
//
// Arguments:
//   doAll : Whether or not to update all widgets.
//
// Programmer: Brad Whitlock
// Creation:   Thu Sep 6 12:57:29 PDT 2001
//
// Modifications:
//   Brad Whitlock, Tue Jan 29 13:14:42 PST 2002
//   Added orientation combo box.
//
//   Brad Whitlock, Tue Apr 1 09:15:14 PDT 2003
//   I made it use QColor's parsing instead of sscanf.
//
hrchilds's avatar
hrchilds committed
224 225 226
//   Brad Whitlock, Fri Aug 15 13:10:28 PST 2003
//   I changed how the styles are set.
//
hrchilds's avatar
hrchilds committed
227 228 229
//   Brad Whitlock, Thu Mar 15 15:26:07 PST 2007
//   Added font support.
//
whitlocb's avatar
whitlocb committed
230 231 232
//   Brad Whitlock, Fri Dec 14 16:57:53 PST 2007
//   Made it use ids.
//
whitlocb's avatar
whitlocb committed
233 234 235 236 237 238
//   Brad Whitlock, Thu Jun 19 11:20:42 PDT 2008
//   Qt 4.
//
//   Cyrus Harrison, Mon Nov 24 11:57:42 PST 2008
//   Support for default system appearance.
//
239 240 241 242
//   Brad Whitlock, Tue Nov 25 15:52:04 PST 2008
//   Make the window reflect the state object when we're using the
//   system defaults.
//
243 244 245
//   Kathleen Biagas, Fri Jan 22 14:12:31 PST 2016
//   styleNames now stored as a QStringList.
//
hrchilds's avatar
hrchilds committed
246 247 248 249 250 251
// ****************************************************************************

void
QvisAppearanceWindow::UpdateWindow(bool doAll)
{
    AppearanceAttributes *atts = (AppearanceAttributes *)subject;
hrchilds's avatar
hrchilds committed
252
    int  j;
hrchilds's avatar
hrchilds committed
253 254 255 256 257 258 259 260 261 262 263

    for(int i = 0; i < atts->NumAttributes(); ++i)
    {
        if(!doAll)
        {
            if(!atts->IsSelected(i))
                continue;
        }

        switch(i)
        {
whitlocb's avatar
whitlocb committed
264 265 266 267 268 269 270 271 272 273 274
        case AppearanceAttributes::ID_useSystemDefault:
            { // new scope
            bool val = atts->GetUseSystemDefault();
            useSysDefaultCheckBox->blockSignals(true);
            if(val)
                useSysDefaultCheckBox->setCheckState(Qt::Checked);
            else
                useSysDefaultCheckBox->setCheckState(Qt::Unchecked);
            useSysDefaultCheckBox->blockSignals(false);
            }
            break;
whitlocb's avatar
whitlocb committed
275
        case AppearanceAttributes::ID_background:
whitlocb's avatar
whitlocb committed
276
            { // new scope
277 278 279 280 281
            QColor bg;
            if(atts->GetUseSystemDefault())
                bg = QColor(atts->GetDefaultBackground().c_str());
            else
                bg = QColor(atts->GetBackground().c_str());
hrchilds's avatar
hrchilds committed
282 283 284
            backgroundColorButton->blockSignals(true);
            backgroundColorButton->setButtonColor(bg);
            backgroundColorButton->blockSignals(false);
whitlocb's avatar
whitlocb committed
285
            }
hrchilds's avatar
hrchilds committed
286
            break;
whitlocb's avatar
whitlocb committed
287
        case AppearanceAttributes::ID_foreground:
whitlocb's avatar
whitlocb committed
288
            { // new scope
289 290 291 292 293
            QColor fg;
            if(atts->GetUseSystemDefault())
                fg = QColor(atts->GetDefaultForeground().c_str());
            else
                fg = QColor(atts->GetForeground().c_str());
hrchilds's avatar
hrchilds committed
294 295 296
            foregroundColorButton->blockSignals(true);
            foregroundColorButton->setButtonColor(fg);
            foregroundColorButton->blockSignals(false);
whitlocb's avatar
whitlocb committed
297
            }
hrchilds's avatar
hrchilds committed
298
            break;
whitlocb's avatar
whitlocb committed
299
        case AppearanceAttributes::ID_fontName:
hrchilds's avatar
hrchilds committed
300
            fontName->blockSignals(true);
301 302 303 304
            if(atts->GetUseSystemDefault())
                fontName->setText(atts->GetDefaultFontName().c_str());
            else
                fontName->setText(atts->GetFontName().c_str());
hrchilds's avatar
hrchilds committed
305
            fontName->blockSignals(false);
hrchilds's avatar
hrchilds committed
306
            break;
whitlocb's avatar
whitlocb committed
307
        case AppearanceAttributes::ID_style:
308 309 310 311 312 313
            { // new scope
            std::string styleName;
            if(atts->GetUseSystemDefault())
                styleName = atts->GetDefaultStyle();
            else
                styleName = atts->GetStyle();
314
            for(j = 0; j < styleNames.size(); ++j)
hrchilds's avatar
hrchilds committed
315
            {
316
                if(styleName == styleNames.at(j).toStdString())
hrchilds's avatar
hrchilds committed
317 318
                {
                    styleComboBox->blockSignals(true);
whitlocb's avatar
whitlocb committed
319
                    styleComboBox->setCurrentIndex(j);
hrchilds's avatar
hrchilds committed
320 321 322 323
                    styleComboBox->blockSignals(false);
                    break;
                }
            }
324
            }
hrchilds's avatar
hrchilds committed
325
            break;
whitlocb's avatar
whitlocb committed
326
        case AppearanceAttributes::ID_orientation:
hrchilds's avatar
hrchilds committed
327 328
            orientationComboBox->blockSignals(true);
            if(atts->GetOrientation() == 0)
whitlocb's avatar
whitlocb committed
329
                orientationComboBox->setCurrentIndex(0);
hrchilds's avatar
hrchilds committed
330
            else
whitlocb's avatar
whitlocb committed
331
                orientationComboBox->setCurrentIndex(1);
hrchilds's avatar
hrchilds committed
332 333 334 335
            orientationComboBox->blockSignals(false);
            break;
        }
    }
whitlocb's avatar
whitlocb committed
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
    
    UpdateWindowSensitivity();
}

// ****************************************************************************
// Method: QvisAppearanceWindow::UpdateWindowSensitivity
//
// Purpose: 
//   This method is called to update window sensitivity
//
//
// Programmer: Cyrus Harrison
// Creation:   Mon Nov 24 10:28:26 PST 2008
//
// Modifications:
//
// ****************************************************************************

void
QvisAppearanceWindow::UpdateWindowSensitivity()
{
    AppearanceAttributes *atts = (AppearanceAttributes *)subject;
    bool val = !atts->GetUseSystemDefault();
    backgroundColorButton->setEnabled(val);
    backgroundColorLabel->setEnabled(val);
    foregroundColorButton->setEnabled(val);
    foregroundColorLabel->setEnabled(val);
    fontName->setEnabled(val);
    fontLabel->setEnabled(val);
    styleComboBox->setEnabled(val);
    styleLabel->setEnabled(val);
    orientationComboBox->setEnabled(val);
368
    orientationLabel->setEnabled(val);   
hrchilds's avatar
hrchilds committed
369 370
}

hrchilds's avatar
hrchilds committed
371 372 373 374 375 376 377 378 379 380 381 382 383
// ****************************************************************************
// Method: QvisAppearanceWindow::GetCurrentValues
//
// Purpose: 
//   This method gets the current values from line edits.
//
// Arguments:
//   which : The index of the widget that we want to get.
//
// Programmer: Brad Whitlock
// Creation:   Thu Mar 15 15:45:17 PST 2007
//
// Modifications:
384 385 386
//   Brad Whitlock, Wed Nov 26 11:29:38 PDT 2008
//   I removed code that no longer seemed needed.
//
hrchilds's avatar
hrchilds committed
387 388 389 390 391 392 393
// ****************************************************************************

void
QvisAppearanceWindow::GetCurrentValues(int which)
{
}

hrchilds's avatar
hrchilds committed
394 395 396 397 398 399 400 401 402 403 404 405 406
// ****************************************************************************
// Method: QvisAppearanceWindow::Apply
//
// Purpose: 
//   This method applies the changes to the appearance.
//
// Programmer: Brad Whitlock
// Creation:   Thu Sep 6 13:15:11 PST 2001
//
// Modifications:
//   Brad Whitlock, Tue Sep 18 13:58:39 PST 2001
//   Removed an unused variable.
//
hrchilds's avatar
hrchilds committed
407 408 409
//   Brad Whitlock, Thu Mar 15 15:51:22 PST 2007
//   Call GetCurrentValues.
//
hrchilds's avatar
hrchilds committed
410 411 412 413 414 415 416
// ****************************************************************************

void
QvisAppearanceWindow::Apply(bool ignore)
{
    if(AutoUpdate() || ignore)
    {
hrchilds's avatar
hrchilds committed
417 418
        GetCurrentValues(-1);

hrchilds's avatar
hrchilds committed
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441
        emit changeAppearance(true);
    }
}

// ****************************************************************************
// Method: QvisAppearanceWindow::apply
//
// Purpose: 
//   This is a Qt slot function that is called when the apply button is clicked.
//
// Programmer: Brad Whitlock
// Creation:   Thu Sep 6 13:16:09 PST 2001
//
// Modifications:
//   
// ****************************************************************************

void
QvisAppearanceWindow::apply()
{
    Apply(true);
}

hrchilds's avatar
hrchilds committed
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
// ****************************************************************************
// Method: QvisAppearanceWindow::ColorsNotTooClose
//
// Purpose: 
//   Prevents bad colors from being used together.
//
// Arguments:
//   c0    : The first color to check.
//   c1str : The string representation of the second color to check.
//
// Returns:    True if the colors can be used together; false otherwise.
//
// Programmer: Brad Whitlock
// Creation:   Fri Oct 3 10:02:10 PDT 2003
//
// Modifications:
458 459 460
//   Brad Whitlock, Tue Apr  8 09:27:26 PDT 2008
//   Support for internationalization.
// 
hrchilds's avatar
hrchilds committed
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483
// ****************************************************************************

bool
QvisAppearanceWindow::ColorsNotTooClose(const QColor &c0, const char *c1str)
{
    QColor c1(c1str);

    int dR = int(c0.red()) - int(c1.red());
    int dG = int(c0.green()) - int(c1.green());
    int dB = int(c0.blue()) - int(c1.blue());

    const int threshold = 10;
    bool rClose = dR > -threshold && dR < threshold;
    bool gClose = dG > -threshold && dG < threshold;
    bool bClose = dB > -threshold && dB < threshold;

    bool retval = true;
    if(rClose && gClose && bClose)
    {
        // Update the window so the color buttons get set back properly.
        UpdateWindow(true);

        // Tell the user that it was a bad idea.
484 485 486
        Warning(tr("The background color and foreground color will not be "
                   "changed because the selected colors are too similar and "
                   "using them would make it too difficult to use VisIt."));
hrchilds's avatar
hrchilds committed
487 488 489 490 491 492
        retval = false;
    }

    return retval;
}

whitlocb's avatar
whitlocb committed
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
// ****************************************************************************
// Method: QvisAppearanceWindow::useSysDefaultChanged
//
// Purpose: 
//   This is a Qt slot function that is called when the user changes the 
//   the "Use System Default Appearance" Check Box.
//
// Arguments:
//   state : The check state.
//
// Programmer: Cyrus Harrison
// Creation:   Mon Nov 24 10:20:10 PST 2008
//
// Modifications:
//
// ****************************************************************************

void
511
QvisAppearanceWindow::useSysDefaultChanged(bool val)
whitlocb's avatar
whitlocb committed
512 513
{
    AppearanceAttributes *atts = (AppearanceAttributes *)subject;
514 515 516
    atts->SetUseSystemDefault(val);
    atts->SelectAll();
    atts->Notify();
whitlocb's avatar
whitlocb committed
517 518
}

hrchilds's avatar
hrchilds committed
519 520 521 522 523 524 525 526 527 528 529 530 531 532
// ****************************************************************************
// Method: QvisAppearanceWindow::backgroundChanged
//
// Purpose: 
//   This is a Qt slot function that is called when the user changes the GUI
//   background color via the color button.
//
// Arguments:
//   bg : The new background color.
//
// Programmer: Brad Whitlock
// Creation:   Thu Sep 6 13:16:36 PST 2001
//
// Modifications:
hrchilds's avatar
hrchilds committed
533 534 535
//   Brad Whitlock, Fri Oct 3 10:03:19 PDT 2003
//   Prevented bad colors from being used together.
//
hrchilds's avatar
hrchilds committed
536 537 538 539 540 541
// ****************************************************************************

void
QvisAppearanceWindow::backgroundChanged(const QColor &bg)
{
    AppearanceAttributes *atts = (AppearanceAttributes *)subject;
hrchilds's avatar
hrchilds committed
542 543 544 545 546

    if(ColorsNotTooClose(bg, atts->GetForeground().c_str()))
    {
        QString tmp;
        tmp.sprintf("#%02x%02x%02x", bg.red(), bg.green(), bg.blue());
whitlocb's avatar
whitlocb committed
547
        atts->SetBackground(tmp.toStdString());
hrchilds's avatar
hrchilds committed
548 549 550
        SetUpdate(false);
        Apply();
    }
hrchilds's avatar
hrchilds committed
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566
}

// ****************************************************************************
// Method: QvisAppearanceWindow::foregroundChanged
//
// Purpose: 
//   This is a Qt slot function that is called when the user changes the GUI
//   foreground color via the color button.
//
// Arguments:
//   fg : The new foreground color.
//
// Programmer: Brad Whitlock
// Creation:   Thu Sep 6 13:16:36 PST 2001
//
// Modifications:
hrchilds's avatar
hrchilds committed
567 568
//   Brad Whitlock, Fri Oct 3 10:03:19 PDT 2003
//   Prevented bad colors from being used together.
hrchilds's avatar
hrchilds committed
569 570 571 572 573 574 575
//   
// ****************************************************************************

void
QvisAppearanceWindow::foregroundChanged(const QColor &fg)
{
    AppearanceAttributes *atts = (AppearanceAttributes *)subject;
hrchilds's avatar
hrchilds committed
576 577 578 579 580

    if(ColorsNotTooClose(fg, atts->GetBackground().c_str()))
    {
        QString tmp;
        tmp.sprintf("#%02x%02x%02x", fg.red(), fg.green(), fg.blue());
whitlocb's avatar
whitlocb committed
581
        atts->SetForeground(tmp.toStdString());
hrchilds's avatar
hrchilds committed
582 583 584
        SetUpdate(false);
        Apply();
    }
hrchilds's avatar
hrchilds committed
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599
}

// ****************************************************************************
// Method: QvisAppearanceWindow::styleChanged
//
// Purpose: 
//   This is a Qt slot function that is called when the user changes the style.
//
// Arguments:
//   index : The index of the new style.
//
// Programmer: Brad Whitlock
// Creation:   Thu Sep 6 13:17:42 PST 2001
//
// Modifications:
hrchilds's avatar
hrchilds committed
600 601 602
//   Brad Whitlock, Fri Aug 15 13:11:13 PST 2003
//   I made it use a table lookup.
//
603 604 605
//   Kathleen Biagas, Fri Jan 22 14:12:31 PST 2016
//   styleNames now stored as a QStringList.
//
hrchilds's avatar
hrchilds committed
606 607 608 609 610 611
// ****************************************************************************

void
QvisAppearanceWindow::styleChanged(int index)
{
    AppearanceAttributes *atts = (AppearanceAttributes *)subject;
612
    atts->SetStyle(styleNames.at(index).toStdString());
hrchilds's avatar
hrchilds committed
613 614 615 616 617
    SetUpdate(false);
    Apply();
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
618
// Method: QvisAppearanceWindow::fontNameChanged
hrchilds's avatar
hrchilds committed
619 620 621 622 623 624 625 626 627
//
// Purpose: 
//   This is a Qt slot function that is called when the Font... button is
//   clicked.
//
// Programmer: Brad Whitlock
// Creation:   Thu Sep 6 19:38:04 PST 2001
//
// Modifications:
hrchilds's avatar
hrchilds committed
628 629 630
//   Brad Whitlock, Thu Mar 15 15:31:57 PST 2007
//   Rewrote.
//
hrchilds's avatar
hrchilds committed
631 632 633
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
634
QvisAppearanceWindow::fontNameChanged(const QString &newFont)
hrchilds's avatar
hrchilds committed
635 636
{
    AppearanceAttributes *atts = (AppearanceAttributes *)subject;
whitlocb's avatar
whitlocb committed
637
    atts->SetFontName(newFont.toStdString());
hrchilds's avatar
hrchilds committed
638 639
    SetUpdate(false);
    Apply();
hrchilds's avatar
hrchilds committed
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665
}

// ****************************************************************************
// Method: QvisAppearanceWindow::orientationChanged
//
// Purpose: 
//   This is a Qt slot function that is called when the orientation is changed.
//
// Arguments:
//   index : The new orientation.
//
// Programmer: Brad Whitlock
// Creation:   Tue Jan 29 13:21:26 PST 2002
//
// Modifications:
//   
// ****************************************************************************

void
QvisAppearanceWindow::orientationChanged(int index)
{
    AppearanceAttributes *atts = (AppearanceAttributes *)subject;
    atts->SetOrientation((index == 0) ? 0 : 2);
    SetUpdate(false);
    Apply();
}