QvisVariableButton.C 34.6 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 <QvisVariableButton.h>

whitlocb's avatar
whitlocb committed
41
#ifndef DESIGNER_PLUGIN
hrchilds's avatar
hrchilds committed
42 43 44
#include <QvisVariableButtonHelper.h>
#include <QvisVariablePopupMenu.h>
#include <VariableMenuPopulator.h>
whitlocb's avatar
whitlocb committed
45 46 47 48
#else
#include <QMenu>
#endif

hrchilds's avatar
hrchilds committed
49
#include <PlotPluginInfo.h>
whitlocb's avatar
whitlocb committed
50
#include <QTimer>
hrchilds's avatar
hrchilds committed
51

whitlocb's avatar
whitlocb committed
52 53
#define DELETE_MENU_TO_FREE_POPUPS

hrchilds's avatar
hrchilds committed
54
#define N_VAR_CATEGORIES 11
55

hrchilds's avatar
hrchilds committed
56 57 58 59 60 61 62 63 64 65 66 67 68
//
// Masks of the types of variables in the order that we want them
// to appear in the menu; not their real order.
//
static int categoryMasks[] = {
    VAR_CATEGORY_SCALAR,
    VAR_CATEGORY_VECTOR,
    VAR_CATEGORY_MESH,
    VAR_CATEGORY_MATERIAL,
    VAR_CATEGORY_SUBSET,
    VAR_CATEGORY_SPECIES,
    VAR_CATEGORY_CURVE,
    VAR_CATEGORY_TENSOR,
hrchilds's avatar
hrchilds committed
69
    VAR_CATEGORY_SYMMETRIC_TENSOR,
hrchilds's avatar
hrchilds committed
70 71
    VAR_CATEGORY_LABEL,
    VAR_CATEGORY_ARRAY
hrchilds's avatar
hrchilds committed
72 73
};

whitlocb's avatar
whitlocb committed
74
#ifndef DESIGNER_PLUGIN
hrchilds's avatar
hrchilds committed
75
// ****************************************************************************
hrchilds's avatar
hrchilds committed
76
// Method: QvisBaseVariableButton::VariablePopupInfo::VariablePopupInfo
hrchilds's avatar
hrchilds committed
77 78 79 80 81 82 83 84
//
// Purpose: 
//   Constructor for the VariablePopupInfo class.
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:41:32 PST 2004
//
// Modifications:
85 86 87
//   Brad Whitlock, Wed Apr  9 12:10:04 PDT 2008
//   Support for internationalization.
//
hrchilds's avatar
hrchilds committed
88 89
// ****************************************************************************

hrchilds's avatar
hrchilds committed
90
QvisBaseVariableButton::VariablePopupInfo::VariablePopupInfo()
hrchilds's avatar
hrchilds committed
91 92 93 94 95 96
{
    varMenus = 0;
    helper = 0;
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
97
// Method: QvisBaseVariableButton::VariablePopupInfo::~VariablePopupInfo
hrchilds's avatar
hrchilds committed
98 99 100 101 102 103 104 105 106 107 108
//
// Purpose: 
//   Destructor for the VariablePopupInfo class.
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:41:32 PST 2004
//
// Modifications:
//   
// ****************************************************************************

hrchilds's avatar
hrchilds committed
109
QvisBaseVariableButton::VariablePopupInfo::~VariablePopupInfo()
hrchilds's avatar
hrchilds committed
110 111 112 113 114 115 116 117 118 119 120 121 122 123
{
    if(varMenus != 0)
    {
        for(int cat = 0; cat < N_VAR_CATEGORIES; ++cat)
            delete varMenus[cat];
    
        delete [] varMenus;

        if(helper != 0 && helper->parent() == 0)
            delete helper;
    }
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
124
// Method: QvisBaseVariableButton::VariablePopupInfo::Initialize
hrchilds's avatar
hrchilds committed
125 126 127 128 129 130 131 132
//
// Purpose: 
//   Initializes the object and creates the shared menus.
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:42:11 PST 2004
//
// Modifications:
whitlocb's avatar
whitlocb committed
133 134 135
//   Brad Whitlock, Thu May 22 11:36:40 PDT 2008
//   Qt 4.
//
hrchilds's avatar
hrchilds committed
136 137 138
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
139
QvisBaseVariableButton::VariablePopupInfo::Initialize()
hrchilds's avatar
hrchilds committed
140 141 142
{
    if(varMenus == 0)
    {
whitlocb's avatar
whitlocb committed
143
        helper = new QvisVariableButtonHelper(0);
hrchilds's avatar
hrchilds committed
144 145 146

        varMenus = new QvisVariablePopupMenu*[N_VAR_CATEGORIES];        
        for(int i = 0; i < N_VAR_CATEGORIES; ++i)
whitlocb's avatar
whitlocb committed
147 148 149 150 151
            CreateMenu(i);
    }
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
152
// Method: QvisBaseVariableButton::VariablePopupInfo::CreateMenu
whitlocb's avatar
whitlocb committed
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
//
// Purpose: 
//   Create the i'th menu.
//
// Arguments:
//   i : The index of the menu to create.
//
// Returns:    
//
// Note:       
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 20 12:39:47 PST 2007
//
// Modifications:
whitlocb's avatar
whitlocb committed
168 169 170
//   Brad Whitlock, Fri May  9 12:14:35 PDT 2008
//   Qt 4.
//
whitlocb's avatar
whitlocb committed
171 172 173
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
174
QvisBaseVariableButton::VariablePopupInfo::CreateMenu(int i)
whitlocb's avatar
whitlocb committed
175
{
whitlocb's avatar
whitlocb committed
176 177
    varMenus[i] = new QvisVariablePopupMenu(0, 0);
    varMenus[i]->setTitle(categoryMenuNames->operator[](i));
whitlocb's avatar
whitlocb committed
178 179 180 181 182
    QObject::connect(varMenus[i], SIGNAL(activated(int, const QString &)),
                     helper, SLOT(activated(int, const QString &)));
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
183
// Method: QvisBaseVariableButton::VariablePopupInfo::DeleteMenu
whitlocb's avatar
whitlocb committed
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
//
// Purpose: 
//   Destroy the i'th menu.
//
// Arguments:
//   i : The index of the menu to destroy.
//
// Returns:    
//
// Note:       
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 20 12:40:11 PST 2007
//
// Modifications:
//   
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
203
QvisBaseVariableButton::VariablePopupInfo::DeleteMenu(int i)
whitlocb's avatar
whitlocb committed
204 205 206 207 208 209 210
{
    if(varMenus[i] != 0)
    { 
        QObject::disconnect(varMenus[i], SIGNAL(activated(int, const QString &)),
                            helper, SLOT(activated(int, const QString &)));
        delete varMenus[i];
        varMenus[i] = 0;
hrchilds's avatar
hrchilds committed
211 212 213 214
    }
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
215
// Method: QvisBaseVariableButton::VariablePopupInfo::UpdateMenus
hrchilds's avatar
hrchilds committed
216 217 218 219 220 221 222 223 224 225 226 227
//
// Purpose: 
//   Updates the menus so they contain the variables prescribed by the
//   specified variable populator.
//
// Arguments:
//   pop : The variable menu populator to use.
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:43:03 PST 2004
//
// Modifications:
whitlocb's avatar
whitlocb committed
228 229 230 231
//   Brad Whitlock, Thu Dec 20 12:38:49 PST 2007
//   I made it delete and recreate the menus when updating them so we really
//   free up the menus that get created.
//
hrchilds's avatar
hrchilds committed
232 233 234
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
235
QvisBaseVariableButton::VariablePopupInfo::UpdateMenus(VariableMenuPopulator *pop)
hrchilds's avatar
hrchilds committed
236 237 238 239 240 241
{
    Initialize();

    // Insert the real list of variables.
    for(int i = 0; i < N_VAR_CATEGORIES; ++i)
    {
whitlocb's avatar
whitlocb committed
242 243 244 245
#ifdef DELETE_MENU_TO_FREE_POPUPS
        DeleteMenu(i);
        CreateMenu(i);
#else
hrchilds's avatar
hrchilds committed
246
        varMenus[i]->clear();
whitlocb's avatar
whitlocb committed
247 248
#endif
        // Update the menu with only 1 type of variable.
hrchilds's avatar
hrchilds committed
249 250 251 252 253 254
        pop->UpdateSingleVariableMenu(varMenus[i], categoryMasks[i],
            helper, SLOT(activated(int, const QString &)));
    }
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
255
// Method: QvisBaseVariableButton::VariablePopupInfo::connect
hrchilds's avatar
hrchilds committed
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
//
// Purpose: 
//   Makes a particular button be associated with the variable menus.
//
// Arguments:
//   b : The button to associate with the menus.
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:44:00 PST 2004
//
// Modifications:
//   
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
271
QvisBaseVariableButton::VariablePopupInfo::connect(QvisBaseVariableButton *b)
hrchilds's avatar
hrchilds committed
272 273 274 275 276 277
{
    Initialize();
    helper->setButton(b);
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
278
// Method: QvisBaseVariableButton::VariablePopupInfo::disconnect
hrchilds's avatar
hrchilds committed
279 280 281 282 283 284 285 286 287 288 289 290
//
// Purpose: 
//   Dissociates a variable button from the menus.
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:45:10 PST 2004
//
// Modifications:
//   
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
291
QvisBaseVariableButton::VariablePopupInfo::disconnect()
hrchilds's avatar
hrchilds committed
292 293 294 295 296 297 298 299 300
{
    Initialize();
    helper->setButton(0);
}


//
// Static
//
hrchilds's avatar
hrchilds committed
301
QList<QObject*> QvisBaseVariableButton::instances;
whitlocb's avatar
whitlocb committed
302 303
QvisVariableButton::VariablePopupInfo *QvisVariableButton::activeSourceInfo = 0;
QvisVariableButton::VariablePopupInfo *QvisVariableButton::plotSourceInfo = 0;
hrchilds's avatar
hrchilds committed
304 305
QObject *QvisBaseVariableButton::expressionCreator = 0;
const char *QvisBaseVariableButton::expressionSlot = 0;
whitlocb's avatar
whitlocb committed
306
#endif
hrchilds's avatar
hrchilds committed
307
QStringList *QvisBaseVariableButton::categoryMenuNames = 0;
hrchilds's avatar
hrchilds committed
308 309 310 311

//
// The VAR_CATEGORY_... macros come from PlotPluginInfo.h
//
hrchilds's avatar
hrchilds committed
312 313 314 315 316 317 318 319 320 321 322
const int QvisBaseVariableButton::Scalars          = VAR_CATEGORY_SCALAR;
const int QvisBaseVariableButton::Vectors          = VAR_CATEGORY_VECTOR;
const int QvisBaseVariableButton::Meshes           = VAR_CATEGORY_MESH;
const int QvisBaseVariableButton::Materials        = VAR_CATEGORY_MATERIAL;
const int QvisBaseVariableButton::Subsets          = VAR_CATEGORY_SUBSET;
const int QvisBaseVariableButton::Species          = VAR_CATEGORY_SPECIES;
const int QvisBaseVariableButton::Curves           = VAR_CATEGORY_CURVE;
const int QvisBaseVariableButton::Tensors          = VAR_CATEGORY_TENSOR;
const int QvisBaseVariableButton::SymmetricTensors = VAR_CATEGORY_SYMMETRIC_TENSOR;
const int QvisBaseVariableButton::Labels           = VAR_CATEGORY_LABEL;
const int QvisBaseVariableButton::Arrays           = VAR_CATEGORY_ARRAY;
hrchilds's avatar
hrchilds committed
323 324

// ****************************************************************************
hrchilds's avatar
hrchilds committed
325
// Method: QvisBaseVariableButton::QvisBaseVariableButton
hrchilds's avatar
hrchilds committed
326 327
//
// Purpose: 
hrchilds's avatar
hrchilds committed
328
//   Constructor for the QvisBaseVariableButton class.
hrchilds's avatar
hrchilds committed
329 330 331 332 333 334 335 336 337 338 339 340 341 342
//
// Arguments:
//   addDefault_ : Tells the object to add a menu option for the "default" var.
//   addExpr_    : Tells the object to add a menu option for creating expressions.
//   usePlot     : Tells the object whether it should use the menus for the 
//                 plot source or active source.
//   mask        : The types of variables that should appear in the menu.
//   parent      : The widget's parent.
//   name        : The widget's name.
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:45:44 PST 2004
//
// Modifications:
whitlocb's avatar
whitlocb committed
343 344 345 346
//   Brad Whitlock, Fri May  9 12:05:04 PDT 2008
//   Qt 4. Moved some initialization code to here. Added support for a
//   stripped down version that can stand in for the real thing in designer.
//
hrchilds's avatar
hrchilds committed
347 348
// ****************************************************************************

hrchilds's avatar
hrchilds committed
349
QvisBaseVariableButton::QvisBaseVariableButton(QWidget *parent) :
whitlocb's avatar
whitlocb committed
350
    QPushButton(parent), defaultVariable("default")
hrchilds's avatar
hrchilds committed
351
{
whitlocb's avatar
whitlocb committed
352
    InitializeCategoryNames();
hrchilds's avatar
hrchilds committed
353 354 355 356 357 358 359

    addDefault = true;
    addExpr = true;
    changeTextOnVarChange = true;
    varTypes = -1;
    setText(defaultVariable);

whitlocb's avatar
whitlocb committed
360 361 362
#ifndef DESIGNER_PLUGIN
    instances.append(this);

hrchilds's avatar
hrchilds committed
363 364 365 366
    //
    // Create this button's menu and add the menus for the
    // variable types in which this variable button is interested.
    //
whitlocb's avatar
whitlocb committed
367
    menu = new QvisVariablePopupMenu(0, this);
hrchilds's avatar
hrchilds committed
368 369 370 371
    connect(menu, SIGNAL(activated(int, const QString &)),
            this, SLOT(changeVariable(int, const QString &)));
    connect(menu, SIGNAL(aboutToShow()),
            this, SLOT(connectMenu()));
whitlocb's avatar
whitlocb committed
372 373 374
#else
    menu = new QMenu(this);
#endif
hrchilds's avatar
hrchilds committed
375 376 377
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
378
// Method: QvisBaseVariableButton::QvisBaseVariableButton
hrchilds's avatar
hrchilds committed
379 380
//
// Purpose: 
hrchilds's avatar
hrchilds committed
381
//   Constructor for the QvisBaseVariableButton class.
hrchilds's avatar
hrchilds committed
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
//
// Arguments:
//   addDefault_ : Tells the object to add a menu option for the "default" var.
//   addExpr_    : Tells the object to add a menu option for creating expressions.
//   usePlot     : Tells the object whether it should use the menus for the 
//                 plot source or active source.
//   mask        : The types of variables that should appear in the menu.
//   parent      : The widget's parent.
//   name        : The widget's name.
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:45:44 PST 2004
//
// Modifications:
//   Brad Whitlock, Thu Nov 16 16:56:03 PST 2006
//   Added variable.
//
whitlocb's avatar
whitlocb committed
399 400 401
//   Brad Whitlock, Fri May  9 12:05:42 PDT 2008
//   Qt 4.
//
hrchilds's avatar
hrchilds committed
402 403
// ****************************************************************************

hrchilds's avatar
hrchilds committed
404 405
QvisBaseVariableButton::QvisBaseVariableButton(bool addDefault_, bool addExpr_,
    int mask, QWidget *parent) :
whitlocb's avatar
whitlocb committed
406
    QPushButton(parent), variable("default"), defaultVariable("default")
hrchilds's avatar
hrchilds committed
407
{
whitlocb's avatar
whitlocb committed
408
    InitializeCategoryNames();
hrchilds's avatar
hrchilds committed
409 410 411 412 413 414 415

    addDefault = addDefault_;
    addExpr = addExpr_;
    changeTextOnVarChange = true;
    varTypes = mask;
    setText(defaultVariable);

whitlocb's avatar
whitlocb committed
416 417 418
#ifndef DESIGNER_PLUGIN
    instances.append(this);

hrchilds's avatar
hrchilds committed
419 420 421 422
    //
    // Create this button's menu and add the menus for the
    // variable types in which this variable button is interested.
    //
whitlocb's avatar
whitlocb committed
423
    menu = new QvisVariablePopupMenu(0, this);
hrchilds's avatar
hrchilds committed
424 425 426 427
    connect(menu, SIGNAL(activated(int, const QString &)),
            this, SLOT(changeVariable(int, const QString &)));
    connect(menu, SIGNAL(aboutToShow()),
            this, SLOT(connectMenu()));
whitlocb's avatar
whitlocb committed
428 429 430
#else
    menu = new QMenu(this);
#endif 
hrchilds's avatar
hrchilds committed
431 432 433
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
434
// Method: QvisBaseVariableButton::~QvisBaseVariableButton
hrchilds's avatar
hrchilds committed
435 436
//
// Purpose: 
hrchilds's avatar
hrchilds committed
437
//   Destructor for the QvisBaseVariableButton class.
hrchilds's avatar
hrchilds committed
438 439 440 441 442
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:47:56 PST 2004
//
// Modifications:
whitlocb's avatar
whitlocb committed
443 444 445
//   Brad Whitlock, Fri May  9 12:15:47 PDT 2008
//   Qt 4.
//
hrchilds's avatar
hrchilds committed
446 447
// ****************************************************************************

hrchilds's avatar
hrchilds committed
448
QvisBaseVariableButton::~QvisBaseVariableButton()
hrchilds's avatar
hrchilds committed
449
{
whitlocb's avatar
whitlocb committed
450 451 452 453
#ifndef DESIGNER_PLUGIN
    instances.removeAll(this);

    if(instances.size() == 0)
hrchilds's avatar
hrchilds committed
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 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 541 542
    {
        delete categoryMenuNames;
        categoryMenuNames = 0;
    }
#endif
}

// ****************************************************************************
// Method: QvisVariableButton::QvisVariableButton
//
// Purpose:
//    Constructor for QvisVariableButton class.
//
// Notes:      The content of this method comes from a refactorization.
//
// Programmer: Hank Childs
// Creation:   August 2, 2010
//
// Modifications:
//
// ****************************************************************************

QvisVariableButton::QvisVariableButton(QWidget *parent)
   : QvisBaseVariableButton(parent)
{
    usePlotSource = true;

#ifndef DESIGNER_PLUGIN
    if(activeSourceInfo == 0)
        activeSourceInfo = new VariablePopupInfo;
    if(plotSourceInfo == 0)
        plotSourceInfo = new VariablePopupInfo;
#endif
    // Insert some standard menu options.
    UpdateMenu();
    setMenu(menu);
}

// ****************************************************************************
// Method: QvisVariableButton::QvisVariableButton
//
// Purpose:
//    Constructor for QvisVariableButton class.
//
// Notes:      The content of this method comes from a refactorization.
//
// Programmer: Hank Childs
// Creation:   August 2, 2010
//
// Modifications:
//
// ****************************************************************************

QvisVariableButton::QvisVariableButton(bool addDefault_, bool addExpr_, 
                                       bool usePlot, int mask, QWidget *parent)
   : QvisBaseVariableButton(addDefault_, addExpr_, mask, parent)
{
    usePlotSource = usePlot;

#ifndef DESIGNER_PLUGIN
    if(activeSourceInfo == 0)
        activeSourceInfo = new VariablePopupInfo;
    if(plotSourceInfo == 0)
        plotSourceInfo = new VariablePopupInfo;
#endif
    // Insert some standard menu options.
    UpdateMenu();
    setMenu(menu);
}

// ****************************************************************************
// Method: QvisVariableButton::~QvisVariableButton
//
// Purpose:
//    Constructor for QvisVariableButton class.
//
// Notes:      The content of this method comes from a refactorization.
//
// Programmer: Hank Childs
// Creation:   August 2, 2010
//
// Modifications:
//
// ****************************************************************************

QvisVariableButton::~QvisVariableButton()
{
#ifndef DESIGNER_PLUGIN
    if (instances.size() == 1)  // the base class destructor will decrement
whitlocb's avatar
whitlocb committed
543 544 545 546 547 548 549 550 551 552
    {
        delete activeSourceInfo;
        activeSourceInfo = 0;

        delete plotSourceInfo;
        plotSourceInfo = 0;
    }
#endif
}

hrchilds's avatar
hrchilds committed
553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647

// ****************************************************************************
// Method: QvisCustomSourceVariableButton::QvisCustomSourceVariableButton
//
// Purpose:
//    Constructor for QvisCustomSourceVariableButton class.
//
// Programmer: Hank Childs
// Creation:   August 2, 2010
//
// Modifications:
//
// ****************************************************************************

QvisCustomSourceVariableButton::QvisCustomSourceVariableButton(QWidget *parent)
   : QvisBaseVariableButton(parent)
{
    customSourceInfo = NULL;

    // Insert some standard menu options.
    UpdateMenu();
    setMenu(menu);
}

// ****************************************************************************
// Method: QvisCustomSourceVariableButton::QvisCustomSourceVariableButton
//
// Purpose:
//    Constructor for QvisCustomSourceVariableButton class.
//
// Programmer: Hank Childs
// Creation:   August 2, 2010
//
// Modifications:
//
// ****************************************************************************

QvisCustomSourceVariableButton::QvisCustomSourceVariableButton(bool addDefault_,
                             bool addExpr_, VariableMenuPopulator *pop,
                             int mask, QWidget *parent)
   : QvisBaseVariableButton(addDefault_, addExpr_, mask, parent)
{
    customSourceInfo = new VariablePopupInfo;
    customSourceInfo->Initialize();
    // Update the menus.
    if(pop)
        customSourceInfo->UpdateMenus(pop);
    UpdateMenu();
    setMenu(menu);
}

// ****************************************************************************
// Method: QvisCustomSourceVariableButton::~QvisCustomSourceVariableButton
//
// Purpose:
//    Constructor for QvisCustomSourceVariableButton class.
//
// Programmer: Hank Childs
// Creation:   August 2, 2010
//
// Modifications:
//
// ****************************************************************************

QvisCustomSourceVariableButton::~QvisCustomSourceVariableButton()
{
    delete customSourceInfo;
}


// ****************************************************************************
// Method: QvisCustomSourceVariableButton::ResetPopulator
//
// Purpose:
//    Resets the populator.
//
// Programmer: Hank Childs
// Creation:   August 2, 2010
//
// Modifications:
//
// ****************************************************************************
void
QvisCustomSourceVariableButton::ResetPopulator(VariableMenuPopulator *pop)
{
    if(pop)
    {
        customSourceInfo->UpdateMenus(pop);
        customSourceInfo->Initialize();
    }
    UpdateMenu();
    setMenu(menu);
}


whitlocb's avatar
whitlocb committed
648
// ****************************************************************************
hrchilds's avatar
hrchilds committed
649
// Method: QvisBaseVariableButton::InitializeCategoryNames
whitlocb's avatar
whitlocb committed
650 651 652 653 654 655 656 657 658 659 660 661
//
// Purpose: 
//   Initializes the category menu names.
//
// Programmer: Brad Whitlock
// Creation:   Thu Oct 16 15:07:54 PDT 2008
//
// Modifications:
//   
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
662
QvisBaseVariableButton::InitializeCategoryNames()
whitlocb's avatar
whitlocb committed
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677
{
    if(categoryMenuNames == 0)
        categoryMenuNames = new QStringList;
    categoryMenuNames->clear();
    (*categoryMenuNames) << tr("Scalars")
                      << tr("Vectors")
                      << tr("Meshes")
                      << tr("Materials")
                      << tr("Subsets")
                      << tr("Species")
                      << tr("Curves")
                      << tr("Tensors")
                      << tr("Symmetric Tensors")
                      << tr("Labels")
                      << tr("Arrays");
hrchilds's avatar
hrchilds committed
678 679 680
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
681
// Method: QvisBaseVariableButton::UpdateMenu
hrchilds's avatar
hrchilds committed
682 683 684 685 686 687 688 689
//
// Purpose: 
//   Updates the button's menu.
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:48:18 PST 2004
//
// Modifications:
690 691 692
//   Brad Whitlock, Wed Apr  9 12:11:08 PDT 2008
//   Support for internationalization.
//
whitlocb's avatar
whitlocb committed
693 694 695
//   Brad Whitlock, Fri May  9 12:18:55 PDT 2008
//   Qt 4. Designer support.
//
696 697 698
//   Cyrus Harrison, Fri May 21 11:41:21 PDT 2010
//   Connect top level menu actions to slots.
//
hrchilds's avatar
hrchilds committed
699 700 701
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
702
QvisBaseVariableButton::UpdateMenu()
whitlocb's avatar
whitlocb committed
703
{ 
hrchilds's avatar
hrchilds committed
704 705 706 707
    menu->clear();

    // Insert some extra menu options.
    if(addDefault)
708
        menu->addAction(defaultVariable,this,SLOT(onDefaultVar()));
hrchilds's avatar
hrchilds committed
709
    if(addExpr)
710
        menu->addAction(tr("Create new expression ..."),this,SLOT(onCreateExpr()));
hrchilds's avatar
hrchilds committed
711 712 713 714 715 716 717 718 719 720 721 722 723

    if(addDefault || addExpr)
    {
        // Count the number of menus that there will be.
        int menuCount = 0;
        for(int i = 0; i < N_VAR_CATEGORIES; ++i)
        {
            if(varTypes & categoryMasks[i])
                ++menuCount;
        }

        // If we're going to insert menus then add a separator.
        if(menuCount > 0)
whitlocb's avatar
whitlocb committed
724
            menu->addSeparator();
hrchilds's avatar
hrchilds committed
725 726 727 728 729 730
    }

    for(int i = 0; i < N_VAR_CATEGORIES; ++i)
    {
        if(varTypes & categoryMasks[i])
        {
whitlocb's avatar
whitlocb committed
731
#ifndef DESIGNER_PLUGIN
hrchilds's avatar
hrchilds committed
732
            QvisVariablePopupMenu **vm = GetSourceInfo()->varMenus;
hrchilds's avatar
hrchilds committed
733 734
            if(vm != 0 && vm[i]->count() > 0)
            {
whitlocb's avatar
whitlocb committed
735
                menu->addMenu(vm[i]);
hrchilds's avatar
hrchilds committed
736 737 738
            }
            else
            {
whitlocb's avatar
whitlocb committed
739
#endif
hrchilds's avatar
hrchilds committed
740 741
                // The menu has no items in it. Insert a regular
                // menu entry and disable it.
whitlocb's avatar
whitlocb committed
742 743 744
                QAction *a = menu->addAction(categoryMenuNames->operator[](i));
                a->setEnabled(false);
#ifndef DESIGNER_PLUGIN
hrchilds's avatar
hrchilds committed
745
            }
whitlocb's avatar
whitlocb committed
746
#endif
hrchilds's avatar
hrchilds committed
747 748 749 750
        }
    }
}

hrchilds's avatar
hrchilds committed
751
// ****************************************************************************
hrchilds's avatar
hrchilds committed
752
// Method: QvisBaseVariableButton::getVariable
hrchilds's avatar
hrchilds committed
753 754 755 756 757 758 759 760 761 762 763 764 765 766
//
// Purpose: 
//   Gets the variable.
//
// Returns:    The variable.
//
// Programmer: Brad Whitlock
// Creation:   Thu Nov 16 16:54:59 PST 2006
//
// Modifications:
//   
// ****************************************************************************

const QString &
hrchilds's avatar
hrchilds committed
767
QvisBaseVariableButton::getVariable() const
hrchilds's avatar
hrchilds committed
768 769 770 771 772
{
    return variable;
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
773
// Method: QvisBaseVariableButton::setVariable
hrchilds's avatar
hrchilds committed
774 775 776 777 778 779 780 781 782 783 784 785 786 787 788
//
// Purpose: 
//   Sets the variable for the menu.
//
// Arguments:
//   var : the new variable.
//
// Programmer: Brad Whitlock
// Creation:   Thu Nov 16 16:55:21 PST 2006
//
// Modifications:
//   
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
789
QvisBaseVariableButton::setVariable(const QString &var)
hrchilds's avatar
hrchilds committed
790 791 792 793
{
    changeVariable(0, var);
}

hrchilds's avatar
hrchilds committed
794
// ****************************************************************************
hrchilds's avatar
hrchilds committed
795
// Method: QvisBaseVariableButton::setChangeTextOnVariableChange
hrchilds's avatar
hrchilds committed
796 797 798 799 800 801 802 803 804 805 806 807 808 809 810
//
// Purpose: 
//   Sets whether we change the button's text when changing the variable.
//
// Arguments:
//   val : Whether to change the button text.
//
// Programmer: Brad Whitlock
// Creation:   Fri Dec 10 14:31:33 PST 2004
//
// Modifications:
//   
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
811
QvisBaseVariableButton::setChangeTextOnVariableChange(bool val)
hrchilds's avatar
hrchilds committed
812 813 814 815 816
{
    changeTextOnVarChange = val;
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
817
// Method: QvisBaseVariableButton::setText
hrchilds's avatar
hrchilds committed
818 819 820 821 822 823 824 825 826 827 828 829
//
// Purpose: 
//   Sets tbe button's text so that long variable names are truncated and
//   the button is given a tooltip.
//
// Arguments:
//   var : The text to use for the button.
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:49:39 PST 2004
//
// Modifications:
whitlocb's avatar
whitlocb committed
830 831 832
//   Brad Whitlock, Fri May  9 12:09:15 PDT 2008
//   Qt 4.
//
hrchilds's avatar
hrchilds committed
833 834 835
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
836
QvisBaseVariableButton::setText(const QString &var)
hrchilds's avatar
hrchilds committed
837 838 839 840 841 842 843 844 845
{
    QString displayVar(var);

    if(changeTextOnVarChange)
    {
        bool tip = false;

        // If the variable contains a slash then display everything to the
        // right of the slash.
whitlocb's avatar
whitlocb committed
846
        int index = var.lastIndexOf("/");
hrchilds's avatar
hrchilds committed
847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870
        if(index != -1)
        {
            displayVar = var.right(var.length() - index - 1);
            tip = true;
        }

        // Make the variable short enough to probably fit in the button.
        if(fontMetrics().boundingRect(displayVar).width() > width())
        {
            int reduceBy = 3;
            QString shortVar(displayVar);
            do
            {
                shortVar = displayVar.left(displayVar.length()-reduceBy)+"...";
                ++reduceBy;
            } while(shortVar.length() > 1 &&
                    fontMetrics().boundingRect(shortVar).width() > width());
            displayVar = shortVar;
            tip = true;
        }

        // Put a tool tip on the pushbutton so the user can see
        // the whole variable name.
        if(tip)
whitlocb's avatar
whitlocb committed
871
            setToolTip(var);
hrchilds's avatar
hrchilds committed
872
        else
whitlocb's avatar
whitlocb committed
873
            setToolTip("");
hrchilds's avatar
hrchilds committed
874 875 876 877 878 879 880
    }

    // Set the text to display into the button.
    QPushButton::setText(displayVar);
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
881
// Method: QvisBaseVariableButton::setDefaultVariable
hrchilds's avatar
hrchilds committed
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896
//
// Purpose: 
//   Sets the default variable to be displayed in the menu.
//
// Arguments:
//   var : The default variable.
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:50:40 PST 2004
//
// Modifications:
//   
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
897
QvisBaseVariableButton::setDefaultVariable(const QString &var)
hrchilds's avatar
hrchilds committed
898 899 900 901 902 903 904 905
{
    bool showingDefaultVar = (var == text());
    defaultVariable = var;
    if(showingDefaultVar && changeTextOnVarChange)
        setText(defaultVariable);
    UpdateMenu();
}

906
// ****************************************************************************
hrchilds's avatar
hrchilds committed
907
// Method: QvisBaseVariableButton::setVarTypes
908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924
//
// Purpose: 
//   Sets the varTypes.
//
// Arguments:
//   t : The var types.
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:50:40 PST 2004
//
// Modifications:
//   Kathleen Bonnell, Tue Jun 24 11:38:02 PDT 2008
//   Moved from header file, added call to UpdateMenu.
//   
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
925
QvisBaseVariableButton::setVarTypes(int t)
926 927 928 929 930 931 932 933
{
    if (varTypes != t)
    {
        varTypes = t;
        UpdateMenu();
    }
}

whitlocb's avatar
whitlocb committed
934
bool
hrchilds's avatar
hrchilds committed
935
QvisBaseVariableButton::getAddExpr() const
whitlocb's avatar
whitlocb committed
936 937 938 939 940
{
    return addExpr;
}

void
hrchilds's avatar
hrchilds committed
941
QvisBaseVariableButton::setAddExpr(bool val)
whitlocb's avatar
whitlocb committed
942 943 944 945 946 947 948 949 950
{
    if(val != addExpr)
    {
        addExpr = val;
        UpdateMenu();
    }
}

bool
hrchilds's avatar
hrchilds committed
951
QvisBaseVariableButton::getAddDefault() const
whitlocb's avatar
whitlocb committed
952 953 954 955 956
{
    return addDefault;
}

void
hrchilds's avatar
hrchilds committed
957
QvisBaseVariableButton::setAddDefault(bool val)
whitlocb's avatar
whitlocb committed
958 959 960 961 962 963 964 965 966
{
    if(val != addDefault)
    {
        addDefault = val;
        UpdateMenu();
    }
}

#ifndef DESIGNER_PLUGIN
hrchilds's avatar
hrchilds committed
967 968 969 970 971 972 973 974 975 976 977 978 979
// ****************************************************************************
// Method: QvisVariableButton::UpdateActiveSourceButtons
//
// Purpose: 
//   Static method that updates all buttons that use the active source's menu.
//
// Arguments:
//   pop : The active source's menu populator.
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:51:10 PST 2004
//
// Modifications:
whitlocb's avatar
whitlocb committed
980 981 982
//   Brad Whitlock, Fri May  9 12:07:54 PDT 2008
//   Qt 4.
//
hrchilds's avatar
hrchilds committed
983 984 985 986 987 988
// ****************************************************************************

void
QvisVariableButton::UpdateActiveSourceButtons(VariableMenuPopulator *pop)
{
    // Create the menus if they have not been created yet.
whitlocb's avatar
whitlocb committed
989
    activeSourceInfo->Initialize();
hrchilds's avatar
hrchilds committed
990 991 992

    // Update the menus.
    if(pop)
whitlocb's avatar
whitlocb committed
993
        activeSourceInfo->UpdateMenus(pop);
hrchilds's avatar
hrchilds committed
994 995 996 997
 
    //
    // Iterate over the variable buttons and create any missing populators.
    //
whitlocb's avatar
whitlocb committed
998 999
    for(QList<QObject*>::const_iterator it = instances.constBegin();
        it != instances.end(); ++it)
hrchilds's avatar
hrchilds committed
1000
    {
hrchilds's avatar
hrchilds committed
1001 1002 1003
        QvisBaseVariableButton *bbutton = (QvisBaseVariableButton *)*it;
        if (! bbutton->DowncastToNormalButton())
            continue;
whitlocb's avatar
whitlocb committed
1004
        QvisVariableButton *button = (QvisVariableButton *)*it;
hrchilds's avatar
hrchilds committed
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022
        if(!button->usePlotSource)
            button->UpdateMenu();
    }
}

// ****************************************************************************
// Method: QvisVariableButton::UpdatePlotSourceButtons
//
// Purpose: 
//   Static method that updates all buttons that use the plot source's menu.
//
// Arguments:
//   pop : The plot source's menu populator.
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:51:10 PST 2004
//
// Modifications:
whitlocb's avatar
whitlocb committed
1023 1024
//   Qt 4.
//
hrchilds's avatar
hrchilds committed
1025 1026 1027 1028 1029 1030
// ****************************************************************************

void
QvisVariableButton::UpdatePlotSourceButtons(VariableMenuPopulator *pop)
{
    // Create the menus if they have not been created yet.
whitlocb's avatar
whitlocb committed
1031
    plotSourceInfo->Initialize();
hrchilds's avatar
hrchilds committed
1032 1033 1034

    // Update the menus.
    if(pop)
whitlocb's avatar
whitlocb committed
1035
        plotSourceInfo->UpdateMenus(pop);
hrchilds's avatar
hrchilds committed
1036 1037 1038 1039
 
    //
    // Iterate over the variable buttons and create any missing populators.
    //
whitlocb's avatar
whitlocb committed
1040 1041
    for(QList<QObject*>::const_iterator it = instances.constBegin();
        it != instances.end(); ++it)
hrchilds's avatar
hrchilds committed
1042
    {
hrchilds's avatar
hrchilds committed
1043 1044 1045
        QvisBaseVariableButton *bbutton = (QvisBaseVariableButton *)*it;
        if (! bbutton->DowncastToNormalButton())
            continue;
whitlocb's avatar
whitlocb committed
1046
        QvisVariableButton *button = (QvisVariableButton *)*it;
hrchilds's avatar
hrchilds committed
1047 1048 1049 1050 1051 1052
        if(button->usePlotSource)
            button->UpdateMenu();
    }
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
1053
// Method: QvisBaseVariableButton::ConnectExpressionCreation
hrchilds's avatar
hrchilds committed
1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070
//
// Purpose: 
//   Sets the object and slot function that will be called when the user
//   clicks on the option to create an expression.
//
// Arguments:
//   receiver : The object that will handle the event.
//   slot     : The slot function that will be called.
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:52:26 PST 2004
//
// Modifications:
//   
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
1071
QvisBaseVariableButton::ConnectExpressionCreation(QObject *receiver,
hrchilds's avatar
hrchilds committed
1072 1073 1074 1075 1076
    const char *slot)
{
    expressionCreator = receiver;
    expressionSlot = slot;
}
whitlocb's avatar
whitlocb committed
1077
#endif
hrchilds's avatar
hrchilds committed
1078 1079 1080 1081 1082 1083

//
// Qt slot functions.
//

// ****************************************************************************
hrchilds's avatar
hrchilds committed
1084
// Method: QvisBaseVariableButton::changeVariable
hrchilds's avatar
hrchilds committed
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096
//
// Purpose: 
//   This is a Qt slot function that is called by the helper object when
//   the user selects a variable from the list.
//
// Arguments:
//   var : The variable that the user selected.
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:53:50 PST 2004
//
// Modifications:
hrchilds's avatar
hrchilds committed
1097 1098 1099
//   Brad Whitlock, Thu Nov 16 16:53:34 PST 2006
//   Keep track of the variable that the user selected so it can be queried.
//
1100 1101 1102
//   Brad Whitlock, Wed Apr  9 12:11:33 PDT 2008
//   Support for internationalization.
//
whitlocb's avatar
whitlocb committed
1103 1104 1105
//   Brad Whitlock, Fri Aug  8 15:19:54 PDT 2008
//   Qt 4.
//
hrchilds's avatar
hrchilds committed
1106 1107 1108
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
1109
QvisBaseVariableButton::changeVariable(int i, const QString &var)
hrchilds's avatar
hrchilds committed
1110
{
whitlocb's avatar
whitlocb committed
1111 1112
    // We chose a menu option so it's safe to schedule the disconnect of the menu.
    deferredDisconnectMenu();
hrchilds's avatar
hrchilds committed
1113

1114
    if(var == tr("Create new expression ..."))
hrchilds's avatar
hrchilds committed
1115
    {
whitlocb's avatar
whitlocb committed
1116
#ifndef DESIGNER_PLUGIN
hrchilds's avatar
hrchilds committed
1117 1118 1119
        // Call the expression creator object's slot.
        if(expressionCreator != 0 && expressionSlot)
            QTimer::singleShot(0, expressionCreator, expressionSlot);
whitlocb's avatar
whitlocb committed
1120
#endif
hrchilds's avatar
hrchilds committed
1121 1122 1123 1124 1125 1126 1127
    }
    else
    {
        // Set the text on the button.
        if(changeTextOnVarChange)
            setText(var);

hrchilds's avatar
hrchilds committed
1128 1129
        variable = var;

hrchilds's avatar
hrchilds committed
1130 1131 1132 1133 1134 1135
        // Tell other Qt objects that we chose a variable.
        emit activated(var);
    }
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
1136
// Method: QvisBaseVariableButton::onCreateExpr
1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148
//
// Purpose:
//   Called when top level "Create new expression" option is selected.
//
// Programmer: Cyrus Harrison
// Creation:   Fri May 21 11:33:34 PDT 2010
//
// Modifications:
//
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
1149
QvisBaseVariableButton::onCreateExpr()
1150 1151 1152 1153 1154
{
    changeVariable(0,tr("Create new expression ..."));
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
1155
// Method: QvisBaseVariableButton::onDefaultVar
1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167
//
// Purpose:
//   Called when top level 'default' option is selected.
//
// Programmer: Cyrus Harrison
// Creation:   Fri May 21 11:33:34 PDT 2010
//
// Modifications:
//
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
1168
QvisBaseVariableButton::onDefaultVar()
1169 1170 1171 1172 1173
{
    changeVariable(0,defaultVariable);
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
1174
// Method: QvisBaseVariableButton::connectMenu
hrchilds's avatar
hrchilds committed
1175 1176 1177 1178 1179 1180 1181 1182 1183
//
// Purpose: 
//   This is a Qt slot function that connects the button to the shared
//   menus.
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:54:44 PST 2004
//
// Modifications:
whitlocb's avatar
whitlocb committed
1184 1185 1186
//   Brad Whitlock, Thu Oct 16 15:00:53 PDT 2008
//   Designer support.
//
hrchilds's avatar
hrchilds committed
1187 1188 1189
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
1190
QvisBaseVariableButton::connectMenu()
hrchilds's avatar
hrchilds committed
1191
{
whitlocb's avatar
whitlocb committed
1192
#ifndef DESIGNER_PLUGIN
hrchilds's avatar
hrchilds committed
1193 1194 1195 1196
    //
    // Connect all of the relevant variable menus so we don't
    // ever accidentally select variables for a different variable button.
    //
hrchilds's avatar
hrchilds committed
1197
    GetSourceInfo()->connect(this);
whitlocb's avatar
whitlocb committed
1198
#endif
hrchilds's avatar
hrchilds committed
1199 1200 1201
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
1202
// Method: QvisBaseVariableButton::deferredDisconnectMenu
hrchilds's avatar
hrchilds committed
1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215
//
// Purpose: 
//   This method disconnects the button from the menu in a deferred manner
//   to the slots are called in the right order.
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:55:20 PST 2004
//
// Modifications:
//   
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
1216
QvisBaseVariableButton::deferredDisconnectMenu()
hrchilds's avatar
hrchilds committed
1217 1218 1219 1220 1221
{
    QTimer::singleShot(100, this, SLOT(disconnectMenu()));
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
1222
// Method: QvisBaseVariableButton::disconnectMenu
hrchilds's avatar
hrchilds committed
1223 1224 1225 1226 1227 1228 1229 1230 1231
//
// Purpose: 
//   This is a Qt slot function that disconnects the button from the shared
//   menus.
//
// Programmer: Brad Whitlock
// Creation:   Thu Dec 9 16:56:04 PST 2004
//
// Modifications:
whitlocb's avatar
whitlocb committed
1232 1233 1234
//   Brad Whitlock, Thu Oct 16 15:00:44 PDT 2008
//   Designer support.
//
hrchilds's avatar
hrchilds committed
1235 1236 1237
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
1238
QvisBaseVariableButton::disconnectMenu()
hrchilds's avatar
hrchilds committed
1239
{
whitlocb's avatar
whitlocb committed
1240
#ifndef DESIGNER_PLUGIN
hrchilds's avatar
hrchilds committed
1241
    GetSourceInfo()->disconnect();
whitlocb's avatar
whitlocb committed
1242
#endif
hrchilds's avatar
hrchilds committed
1243
}