QvisRenderingWindow.C 47.1 KB
Newer Older
hrchilds's avatar
hrchilds committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
/*****************************************************************************
*
* Copyright (c) 2000 - 2006, The Regents of the University of California
* Produced at the Lawrence Livermore National Laboratory
* All rights reserved.
*
* This file is part of VisIt. For details, see http://www.llnl.gov/visit/. The
* 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
*    documentation and/or materials provided with the distribution.
*  - Neither the name of the UC/LLNL nor  the names of its contributors may be
*    used to  endorse or  promote products derived from  this software without
*    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
* ARE  DISCLAIMED.  IN  NO  EVENT  SHALL  THE  REGENTS  OF  THE  UNIVERSITY OF
* CALIFORNIA, THE U.S.  DEPARTMENT  OF  ENERGY OR CONTRIBUTORS BE  LIABLE  FOR
* ANY  DIRECT,  INDIRECT,  INCIDENTAL,  SPECIAL,  EXEMPLARY,  OR CONSEQUENTIAL
* 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
38 39
#include <QvisRenderingWindow.h>
#include <float.h>
hrchilds's avatar
hrchilds committed
40
#include <limits.h>
hrchilds's avatar
hrchilds committed
41 42 43 44 45 46 47 48

#include <qbuttongroup.h>
#include <qcheckbox.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qradiobutton.h>
#include <qslider.h>
hrchilds's avatar
hrchilds committed
49
#include <qspinbox.h>
hrchilds's avatar
hrchilds committed
50 51 52 53

#include <RenderingAttributes.h>
#include <ViewerProxy.h>
#include <WindowInformation.h>
hrchilds's avatar
hrchilds committed
54
#include <QvisOpacitySlider.h>
hrchilds's avatar
hrchilds committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70

// ****************************************************************************
// Method: QvisRenderingWindow::QvisRenderingWindow
//
// Purpose: 
//   Constructor for the QvisRenderingWindow class.
//
// Arguments:
//   caption : The window caption.
//   shortName : The name shown in the notepad.
//   n         : The notepad area.
//
// Programmer: Brad Whitlock
// Creation:   Mon Sep 23 14:46:40 PST 2002
//
// Modifications:
hrchilds's avatar
hrchilds committed
71 72 73
//
//   Mark C. Miller, Tue Apr 27 14:41:35 PDT 2004
//   Changed name of scalableThreshold to scalrenActivationMode
hrchilds's avatar
hrchilds committed
74
//   
hrchilds's avatar
hrchilds committed
75 76 77
//   Hank Childs, Sun May  9 15:54:29 PDT 2004
//   Initialize dlMode.
//
hrchilds's avatar
hrchilds committed
78 79
//   Mark C. Miller, Thu Nov  3 16:59:41 PST 2005
//   Added compression controls
hrchilds's avatar
hrchilds committed
80 81 82 83
// ****************************************************************************

QvisRenderingWindow::QvisRenderingWindow(const char *caption,
    const char *shortName, QvisNotepadArea *n) :
hrchilds's avatar
hrchilds committed
84
    QvisPostableWindowSimpleObserver(caption, shortName, n, ApplyButton)
hrchilds's avatar
hrchilds committed
85 86 87 88 89
{
    renderAtts = 0;
    windowInfo = 0;

    objectRepresentation = 0;
hrchilds's avatar
hrchilds committed
90
    dlMode = 0;
hrchilds's avatar
hrchilds committed
91
    stereoType = 0;
hrchilds's avatar
hrchilds committed
92
    scalrenActivationMode = 0;
hrchilds's avatar
hrchilds committed
93
    scalrenCompressMode = 0;
hrchilds's avatar
hrchilds committed
94 95 96 97 98 99 100 101 102 103 104 105 106
}

// ****************************************************************************
// Method: QvisRenderingWindow::~QvisRenderingWindow
//
// Purpose: 
//   This is the destructor for the QvisRenderingWindow class.
//
// Programmer: Brad Whitlock
// Creation:   Mon Sep 23 14:47:29 PST 2002
//
// Modifications:
//   
hrchilds's avatar
hrchilds committed
107 108
//   Mark C. Miller, Tue Apr 27 14:41:35 PDT 2004
//   Changed name of scalableThreshold to scalrenActivationMode
hrchilds's avatar
hrchilds committed
109 110 111 112
//
//   Hank Childs, Sun May  9 15:54:29 PDT 2004
//   Delete dlMode.
//
hrchilds's avatar
hrchilds committed
113 114
//   Mark C. Miller, Thu Nov  3 16:59:41 PST 2005
//   Added compression controls
hrchilds's avatar
hrchilds committed
115 116 117 118 119
// ****************************************************************************

QvisRenderingWindow::~QvisRenderingWindow()
{
    delete objectRepresentation;
hrchilds's avatar
hrchilds committed
120
    delete dlMode;
hrchilds's avatar
hrchilds committed
121
    delete stereoType;
hrchilds's avatar
hrchilds committed
122
    delete scalrenActivationMode;
hrchilds's avatar
hrchilds committed
123
    delete scalrenCompressMode;
hrchilds's avatar
hrchilds committed
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147

    if(renderAtts)
        renderAtts->Detach(this);

    if(windowInfo)
        windowInfo->Detach(this);
}

// ****************************************************************************
// Method: QvisRenderingWindow::CreateWindowContents
//
// Purpose: 
//   This method creates all of the window's widgets.
//
// Programmer: Brad Whitlock
// Creation:   Mon Sep 23 14:47:57 PST 2002
//
// Modifications:
//   Brad Whitlock, Thu Oct 24 13:33:31 PST 2002
//   I made the stereo radio buttons class members.
//   
//   Kathleen Bonnell, Wed Dec  4 18:42:48 PST 2002 
//   Removed antialiasingQuality slider, no longer needed. 
//   
hrchilds's avatar
hrchilds committed
148 149 150
//   Jeremy Meredith, Fri Nov 14 17:47:19 PST 2003
//   Added specular options.
//
hrchilds's avatar
hrchilds committed
151 152 153
//   Mark C. Miller, Tue Apr 27 14:41:35 PDT 2004
//   Added scalable threshold spinbox
//
hrchilds's avatar
hrchilds committed
154 155 156
//   Hank Childs, Sun May  9 15:54:29 PDT 2004
//   Add support for multiple display list modes.
//
hrchilds's avatar
hrchilds committed
157 158 159 160
//   Mark C. Miller, Tue May 11 20:21:24 PDT 2004
//   Changed scalable rendering controls to use activation mode and auto
//   threshold
//
hrchilds's avatar
hrchilds committed
161 162 163
//   Hank Childs, Sun Oct 24 07:36:18 PDT 2004
//   Added shadow options.
//
hrchilds's avatar
hrchilds committed
164 165 166
//   Mark C. Miller, Fri Mar  4 13:05:02 PST 2005
//   Changed approxNumTriangles to approxNumPrimitives
//
hrchilds's avatar
hrchilds committed
167 168 169
//   Kathleen Bonnell, Thu Jun 30 15:29:55 PDT 2005 
//   Added redgreen radiobutton.
//
hrchilds's avatar
hrchilds committed
170 171
//   Mark C. Miller, Thu Nov  3 16:59:41 PST 2005
//   Added compression controls
hrchilds's avatar
hrchilds committed
172 173 174
//
//   Mark C. Miller, Wed Nov 16 14:17:01 PST 2005
//   Changed label string for compression 
hrchilds's avatar
hrchilds committed
175 176 177 178
//
//   Brad Whitlock, Mon Sep 18 10:46:02 PDT 2006
//   Added colorTexturing check box.
//
hrchilds's avatar
hrchilds committed
179 180 181 182 183 184 185 186 187 188 189 190 191 192
// ****************************************************************************

void
QvisRenderingWindow::CreateWindowContents()
{
    //
    // Create the renderer options group.
    //
    QGroupBox *options = new QGroupBox(central, "options");
    options->setTitle("Options");
    topLayout->addWidget(options);

    QVBoxLayout *spacer = new QVBoxLayout(options);
    spacer->addSpacing(10);
hrchilds's avatar
hrchilds committed
193
    QGridLayout *oLayout = new QGridLayout(spacer, 19, 4);
hrchilds's avatar
hrchilds committed
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
    oLayout->setSpacing(5);
    oLayout->setMargin(10);

    // Create the antialiasing widgets.
    antialiasingToggle = new QCheckBox("Antialiasing", options,
        "antialiasingToggle");
    connect(antialiasingToggle, SIGNAL(toggled(bool)),
            this, SLOT(antialiasingToggled(bool)));
    oLayout->addMultiCellWidget(antialiasingToggle, 0, 0, 0, 1);

    // Create the surface rep widgets.
    QLabel *drawObjLabel = new QLabel("Draw objects as", options, "drawObjLabel");
    oLayout->addMultiCellWidget(drawObjLabel, 2, 2, 0, 3);
    objectRepresentation = new QButtonGroup(0, "objectRepresentation");
    connect(objectRepresentation, SIGNAL(clicked(int)),
            this, SLOT(objectRepresentationChanged(int)));
    QRadioButton *surfaces = new QRadioButton("Surfaces", options, "surfaces");
    objectRepresentation->insert(surfaces);
    oLayout->addWidget(surfaces, 3, 1);
    QRadioButton *wires = new QRadioButton("Wireframe", options,
        "wires");
    objectRepresentation->insert(wires);
    oLayout->addWidget(wires, 3, 2);
    QRadioButton *points = new QRadioButton("Points", options,
        "points");
    objectRepresentation->insert(points);
    oLayout->addWidget(points, 3, 3);

hrchilds's avatar
hrchilds committed
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
    // Create the display list widgets.
    QLabel *displayListLabel = new QLabel("Use display lists", options, "displayListLabel");
    oLayout->addMultiCellWidget(displayListLabel, 4, 4, 0, 3);
    dlMode = new QButtonGroup(0, "displayList");
    connect(dlMode, SIGNAL(clicked(int)),
            this, SLOT(displayListModeChanged(int)));
    QRadioButton *dl_auto = new QRadioButton("Auto", options, "dl_auto");
    dlMode->insert(dl_auto);
    oLayout->addWidget(dl_auto, 5, 1);
    QRadioButton *dl_always = new QRadioButton("Always", options,
        "dl_always");
    dlMode->insert(dl_always);
    oLayout->addWidget(dl_always, 5, 2);
    QRadioButton *dl_never = new QRadioButton("Never", options,
        "dl_never");
    dlMode->insert(dl_never);
    oLayout->addWidget(dl_never, 5, 3);
hrchilds's avatar
hrchilds committed
239 240 241 242 243 244

    // Create the stereo widgets.
    stereoToggle = new QCheckBox("Stereo", options,
        "stereoToggle");
    connect(stereoToggle, SIGNAL(toggled(bool)),
            this, SLOT(stereoToggled(bool)));
hrchilds's avatar
hrchilds committed
245
    oLayout->addMultiCellWidget(stereoToggle, 6, 6, 0, 3);
hrchilds's avatar
hrchilds committed
246 247 248 249 250
    stereoType = new QButtonGroup(0, "stereoType");
    connect(stereoType, SIGNAL(clicked(int)),
            this, SLOT(stereoTypeChanged(int)));
    redblue = new QRadioButton("Red/Blue", options, "redblue");
    stereoType->insert(redblue);
hrchilds's avatar
hrchilds committed
251
    oLayout->addWidget(redblue, 7, 1);
hrchilds's avatar
hrchilds committed
252 253 254
    interlace = new QRadioButton("Interlace", options,
        "interlace");
    stereoType->insert(interlace);
hrchilds's avatar
hrchilds committed
255
    oLayout->addWidget(interlace, 7, 2);
hrchilds's avatar
hrchilds committed
256 257 258
    crystalEyes = new QRadioButton("Crystal Eyes", options,
        "crystalEyes");
    stereoType->insert(crystalEyes);
hrchilds's avatar
hrchilds committed
259 260 261 262
    oLayout->addWidget(crystalEyes, 8, 1);
    redgreen = new QRadioButton("Red/Green", options, "redgreen");
    stereoType->insert(redgreen);
    oLayout->addWidget(redgreen, 8, 2);
hrchilds's avatar
hrchilds committed
263 264

    // Create the scalable rendering widgets.
hrchilds's avatar
hrchilds committed
265
    QLabel *scalrenLabel = new QLabel("Use scalable rendering", options,"scalrenLabel");
hrchilds's avatar
hrchilds committed
266
    oLayout->addMultiCellWidget(scalrenLabel, 9, 9, 0, 3);
hrchilds's avatar
hrchilds committed
267 268 269
    scalrenActivationMode = new QButtonGroup(0, "scalrenActivationMode");
    connect(scalrenActivationMode, SIGNAL(clicked(int)),
            this, SLOT(scalrenActivationModeChanged(int)));
hrchilds's avatar
hrchilds committed
270
    scalrenAuto = new QRadioButton("Auto", options, "auto");
hrchilds's avatar
hrchilds committed
271
    scalrenActivationMode->insert(scalrenAuto);
hrchilds's avatar
hrchilds committed
272
    oLayout->addWidget(scalrenAuto, 10, 1);
hrchilds's avatar
hrchilds committed
273
    scalrenAlways = new QRadioButton("Always", options, "always");
hrchilds's avatar
hrchilds committed
274
    scalrenActivationMode->insert(scalrenAlways);
hrchilds's avatar
hrchilds committed
275
    oLayout->addWidget(scalrenAlways, 10, 2);
hrchilds's avatar
hrchilds committed
276
    scalrenNever = new QRadioButton("Never", options, "never");
hrchilds's avatar
hrchilds committed
277
    scalrenActivationMode->insert(scalrenNever);
hrchilds's avatar
hrchilds committed
278
    oLayout->addWidget(scalrenNever, 10, 3);
hrchilds's avatar
hrchilds committed
279

hrchilds's avatar
hrchilds committed
280 281
    // Create the polygon count spin box for scalable rendering threshold
    scalrenGeometryLabel =  new QLabel("When polygon count exceeds", options, "scalrenGeometryLabel");
hrchilds's avatar
hrchilds committed
282
    oLayout->addMultiCellWidget(scalrenGeometryLabel, 11, 11, 1, 2);
hrchilds's avatar
hrchilds committed
283
    scalrenAutoThreshold = new QSpinBox(0, 10000, 500, options, "scalrenAutoThreshold");
hrchilds's avatar
hrchilds committed
284 285
    scalrenAutoThreshold->setValue(RenderingAttributes::DEFAULT_SCALABLE_AUTO_THRESHOLD);
    scalrenAutoThresholdChanged(RenderingAttributes::DEFAULT_SCALABLE_AUTO_THRESHOLD);
hrchilds's avatar
hrchilds committed
286 287
    connect(scalrenAutoThreshold, SIGNAL(valueChanged(int)),
            this, SLOT(scalrenAutoThresholdChanged(int)));
hrchilds's avatar
hrchilds committed
288
    oLayout->addWidget(scalrenAutoThreshold, 11, 3);
hrchilds's avatar
hrchilds committed
289

hrchilds's avatar
hrchilds committed
290
    // Create the compress mode widgets.
hrchilds's avatar
hrchilds committed
291
    scalrenCompressLabel = new QLabel("Compress images (geom too) from engine",
hrchilds's avatar
hrchilds committed
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
                                                   options, "compressModeLabel");
    oLayout->addMultiCellWidget(scalrenCompressLabel, 12, 12, 0, 3);
    scalrenCompressMode = new QButtonGroup(0, "compressMode");
    connect(scalrenCompressMode, SIGNAL(clicked(int)),
            this, SLOT(scalrenCompressModeChanged(int)));
    QRadioButton *cmp_auto = new QRadioButton("Auto", options, "cmp_auto");
    cmp_auto->setEnabled(0); // disabled until implemented
    scalrenCompressMode->insert(cmp_auto);
    oLayout->addWidget(cmp_auto, 13, 1);
    QRadioButton *cmp_always = new QRadioButton("Always", options,
        "cmp_always");
    scalrenCompressMode->insert(cmp_always);
    oLayout->addWidget(cmp_always, 13, 2);
    QRadioButton *cmp_never = new QRadioButton("Never", options,
        "cmp_never");
    scalrenCompressMode->insert(cmp_never);
    oLayout->addWidget(cmp_never, 13, 3);

hrchilds's avatar
hrchilds committed
310
    // Create the specular lighting options
hrchilds's avatar
hrchilds committed
311 312 313 314
    specularToggle = new QCheckBox("Specular lighting", options,
                                   "specularToggle");
    connect(specularToggle, SIGNAL(toggled(bool)),
            this, SLOT(specularToggled(bool)));
hrchilds's avatar
hrchilds committed
315
    oLayout->addMultiCellWidget(specularToggle, 14, 14, 0,3);
hrchilds's avatar
hrchilds committed
316 317 318 319 320 321 322 323

    specularStrengthSlider = new QvisOpacitySlider(0, 100, 10, 60, options,
                                             "specularStrengthSlider", NULL);
    specularStrengthSlider->setTickInterval(25);
    connect(specularStrengthSlider, SIGNAL(valueChanged(int, const void*)),
            this, SLOT(specularStrengthChanged(int, const void*)));
    specularStrengthLabel = new QLabel(specularStrengthSlider, "Strength",
                                       options, "specularStrengthLabel");
hrchilds's avatar
hrchilds committed
324 325
    oLayout->addWidget(specularStrengthLabel, 15,1);
    oLayout->addMultiCellWidget(specularStrengthSlider, 15,15, 2,3);
hrchilds's avatar
hrchilds committed
326 327 328 329 330 331 332 333

    specularPowerSlider = new QvisOpacitySlider(0, 1000, 100, 100, options,
                                                "specularPowerSlider", NULL);
    specularPowerSlider->setTickInterval(100);
    connect(specularPowerSlider, SIGNAL(valueChanged(int, const void*)),
            this, SLOT(specularPowerChanged(int, const void*)));
    specularPowerLabel = new QLabel(specularPowerSlider, "Sharpness",
                                    options, "specularPowerLabel");
hrchilds's avatar
hrchilds committed
334 335
    oLayout->addWidget(specularPowerLabel, 16,1);
    oLayout->addMultiCellWidget(specularPowerSlider, 16,16, 2,3);
hrchilds's avatar
hrchilds committed
336

hrchilds's avatar
hrchilds committed
337 338 339 340 341
    // Create the shadow lighting options
    shadowToggle = new QCheckBox("Shadows", options,
                                   "shadowToggle");
    connect(shadowToggle, SIGNAL(toggled(bool)),
            this, SLOT(shadowToggled(bool)));
hrchilds's avatar
hrchilds committed
342
    oLayout->addMultiCellWidget(shadowToggle, 17, 17, 0,3);
hrchilds's avatar
hrchilds committed
343 344 345 346 347 348 349 350

    shadowStrengthSlider = new QvisOpacitySlider(0, 100, 10, 60, options,
                                             "shadowStrengthSlider", NULL);
    shadowStrengthSlider->setTickInterval(25);
    connect(shadowStrengthSlider, SIGNAL(valueChanged(int, const void*)),
            this, SLOT(shadowStrengthChanged(int, const void*)));
    shadowStrengthLabel = new QLabel(shadowStrengthSlider, "Strength",
                                       options, "shadowStrengthLabel");
hrchilds's avatar
hrchilds committed
351 352
    oLayout->addWidget(shadowStrengthLabel, 18,1);
    oLayout->addMultiCellWidget(shadowStrengthSlider, 18,18, 2,3);
hrchilds's avatar
hrchilds committed
353

hrchilds's avatar
hrchilds committed
354 355 356 357 358 359
    // Create color texturing options.
    colorTexturingToggle = new QCheckBox("Apply color using textures", options,
        "colorTexturingToggle");
    connect(colorTexturingToggle, SIGNAL(toggled(bool)),
            this, SLOT(colorTexturingToggled(bool)));
    oLayout->addMultiCellWidget(colorTexturingToggle, 19, 19, 0, 3);
hrchilds's avatar
hrchilds committed
360

hrchilds's avatar
hrchilds committed
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
    //
    // Create the renderer information group.
    //
    QGroupBox *info = new QGroupBox(central, "info");
    info->setTitle("Information");
    topLayout->addWidget(info);

    QVBoxLayout *vLayout = new QVBoxLayout(info);
    vLayout->addSpacing(10);
    vLayout->setMargin(10);

    renderNotifyToggle = new QCheckBox("Query after each render", info,
        "renderNotifyToggle");
    connect(renderNotifyToggle, SIGNAL(toggled(bool)),
            this, SLOT(renderNotifyToggled(bool)));
    vLayout->addWidget(renderNotifyToggle);
    vLayout->addSpacing(5);

hrchilds's avatar
hrchilds committed
379 380 381 382 383 384 385 386
    QGridLayout *scalrenLayout = new QGridLayout(vLayout, 2, 4);
    scalrenLayout->setSpacing(5);
    QLabel *scalrenLabel2 = new QLabel("Using Scalable Rendering: ", info, "scalrenLabel2");
    scalrenLayout->addWidget(scalrenLabel2, 0, 0);
    scalrenUsingLabel = new QLabel("N/A", info, "scalrenUsingLabel");
    scalrenLayout->addWidget(scalrenUsingLabel, 0, 1);
    vLayout->addSpacing(5);

hrchilds's avatar
hrchilds committed
387 388
    QGridLayout *iLayout = new QGridLayout(vLayout, 2, 4);
    iLayout->setSpacing(5);
hrchilds's avatar
hrchilds committed
389 390
    fpsLabel = new QLabel("Frames per second:", info, "fpsLabel");
    iLayout->addWidget(fpsLabel, 0, 0);
hrchilds's avatar
hrchilds committed
391 392 393 394 395 396 397
    fpsMinLabel = new QLabel("0.", info, "fpsMinLabel");
    iLayout->addWidget(fpsMinLabel, 0, 1);
    fpsAvgLabel = new QLabel("0.", info, "fpsAvgLabel");
    iLayout->addWidget(fpsAvgLabel, 0, 2);
    fpsMaxLabel = new QLabel("0.", info, "fpsMaxLabel");
    iLayout->addWidget(fpsMaxLabel, 0, 3);

hrchilds's avatar
hrchilds committed
398
    QLabel *ntri = new QLabel("Approximate polygon count:", info, "ntri");
hrchilds's avatar
hrchilds committed
399
    iLayout->addWidget(ntri, 1, 0);
hrchilds's avatar
hrchilds committed
400 401
    approxNumPrimitives = new QLabel("0.", info, "approxNumPrimitives");
    iLayout->addWidget(approxNumPrimitives, 1, 1);
hrchilds's avatar
hrchilds committed
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
    vLayout->addSpacing(5);

    QGridLayout *eLayout = new QGridLayout(vLayout, 3, 3);
    eLayout->setSpacing(5);
    QLabel *xExtentsLabel = new QLabel("X Extents:", info, "xExtentsLabel");
    eLayout->addWidget(xExtentsLabel, 3, 0);
    extents[0] = new QLabel("0.", info, "extents_0");
    eLayout->addWidget(extents[0], 3, 1);
    extents[1] = new QLabel("0.", info, "extents_1");
    eLayout->addWidget(extents[1], 3, 2);

    QLabel *yExtentsLabel = new QLabel("Y Extents:", info, "yExtentsLabel");
    eLayout->addWidget(yExtentsLabel, 4, 0);
    extents[2] = new QLabel("0.", info, "extents_2");
    eLayout->addWidget(extents[2], 4, 1);
    extents[3] = new QLabel("0.", info, "extents_3");
    eLayout->addWidget(extents[3], 4, 2);

    QLabel *zExtentsLabel = new QLabel("Z Extents:", info, "zExtentsLabel");
    eLayout->addWidget(zExtentsLabel, 5, 0);
    extents[4] = new QLabel("0.", info, "extents_4");
    eLayout->addWidget(extents[4], 5, 1);
    extents[5] = new QLabel("0.", info, "extents_5");
    eLayout->addWidget(extents[5], 5, 2);
}

// ****************************************************************************
// Method: QvisRenderingWindow::UpdateWindow
//
// Purpose: 
//   This method updates the window's widgets when its subjects update.
//
// Arguments:
//   doAll : Whether or not to ignore field selection.
//
// Programmer: Brad Whitlock
// Creation:   Mon Sep 23 14:48:24 PST 2002
//
// Modifications:
hrchilds's avatar
hrchilds committed
441
//
hrchilds's avatar
hrchilds committed
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471
// ****************************************************************************

void
QvisRenderingWindow::UpdateWindow(bool doAll)
{
    if(SelectedSubject() == renderAtts || doAll)
        UpdateOptions(doAll);
    if(SelectedSubject() == windowInfo || doAll)
        UpdateInformation(doAll);
}

// ****************************************************************************
// Method: QvisRenderingWindow::UpdateOptions
//
// Purpose: 
//   Updates the widgets that control the rendering options.
//
// Arguments:
//   doAll : Whether or not to ignore selection and update all widgets.
//
// Programmer: Brad Whitlock
// Creation:   Tue Sep 24 11:28:53 PDT 2002
//
// Modifications:
//   Brad Whitlock, Thu Oct 24 13:35:22 PST 2002
//   I added code to enable/disable the stereo rendering buttons.
//
//   Kathleen Bonnell, Wed Dec  4 18:42:48 PST 2002 
//   Renumber switch cases, to reflect antialisingFrames removed from atts. 
//
hrchilds's avatar
hrchilds committed
472 473 474
//   Jeremy Meredith, Fri Nov 14 17:44:35 PST 2003
//   Added specular options.
//
hrchilds's avatar
hrchilds committed
475 476 477
//   Mark C. Miller, Tue Apr 27 14:41:35 PDT 2004
//   Changed name of scalableThreshld to scalrenActivationMode
//
hrchilds's avatar
hrchilds committed
478 479 480
//   Hank Childs, Sun May  9 15:54:29 PDT 2004
//   Add support for multiple display list modes.
//
hrchilds's avatar
hrchilds committed
481 482 483 484
//   Mark C. Miller, Tue May 11 20:21:24 PDT 2004
//   Changed scalable rendering controls to use activation mode and auto
//   threshold
//
hrchilds's avatar
hrchilds committed
485 486 487
//   Hank Childs, Sun Oct 24 07:36:18 PDT 2004
//   Added shadow options.
//
hrchilds's avatar
hrchilds committed
488 489 490
//   Mark C. Miller, Tue Jan  4 10:23:19 PST 2005
//   Fixed problem with updating scalable auto threshold
//
hrchilds's avatar
hrchilds committed
491 492 493
//   Kathleen Bonnell, Thu Jun 30 15:29:55 PDT 2005 
//   Added redgreen radiobutton.
//
hrchilds's avatar
hrchilds committed
494 495
//   Mark C. Miller, Thu Nov  3 16:59:41 PST 2005
//   Added compression controls
hrchilds's avatar
hrchilds committed
496 497 498 499
//
//   Brad Whitlock, Mon Sep 18 10:49:51 PDT 2006
//   Added colorTexturingFlag.
//
hrchilds's avatar
hrchilds committed
500 501 502 503 504 505
// ****************************************************************************

void
QvisRenderingWindow::UpdateOptions(bool doAll)
{
    QString tmp;
hrchilds's avatar
hrchilds committed
506
    int itmp, itmp2;
hrchilds's avatar
hrchilds committed
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

    // Loop through all the attributes and do something for
    // each of them that changed. This function is only responsible
    // for displaying the state values and setting widget sensitivity.
    for(int i = 0; i < renderAtts->NumAttributes(); ++i)
    {
        if(!doAll)
        {
            if(!renderAtts->IsSelected(i))
            continue;
        }

        switch(i)
        {
        case 0: //antialiasing
            antialiasingToggle->blockSignals(true);
            antialiasingToggle->setChecked(renderAtts->GetAntialiasing());
            antialiasingToggle->blockSignals(false);
            break;
        case 1: //geometryRepresentation
            itmp = (int)renderAtts->GetGeometryRepresentation();
            objectRepresentation->blockSignals(true);
            objectRepresentation->setButton(itmp);
            objectRepresentation->blockSignals(false);
            break;
        case 2: //displayLists
hrchilds's avatar
hrchilds committed
533 534 535 536 537 538 539 540 541 542
            itmp = (int) renderAtts->GetDisplayListMode();
            if (itmp == 2) // Auto for atts's enum type order
                itmp2 = 0; // Order of Auto in window
            else if (itmp == 1) // Always for atts' enum type order
                itmp2 = 1; // Order of Always in window.
            else           // Never for atts' enum type order
                itmp2 = 2; // Order of Never in window.
            dlMode->blockSignals(true);
            dlMode->setButton(itmp2);
            dlMode->blockSignals(false);
hrchilds's avatar
hrchilds committed
543 544 545 546 547 548 549 550 551
            break;
        case 3: //stereoRendering
            stereoToggle->blockSignals(true);
            stereoToggle->setChecked(renderAtts->GetStereoRendering());
            stereoToggle->blockSignals(false);
            stereoType->setEnabled(renderAtts->GetStereoRendering());
            redblue->setEnabled(renderAtts->GetStereoRendering());
            interlace->setEnabled(renderAtts->GetStereoRendering());
            crystalEyes->setEnabled(renderAtts->GetStereoRendering());
hrchilds's avatar
hrchilds committed
552
            redgreen->setEnabled(renderAtts->GetStereoRendering());
hrchilds's avatar
hrchilds committed
553 554 555 556 557 558 559 560 561 562 563
            break;
        case 4: //stereoType
            stereoType->blockSignals(true);
            stereoType->setButton((int)renderAtts->GetStereoType());
            stereoType->blockSignals(false);
            break;
        case 5: //notifyForEachRender
            renderNotifyToggle->blockSignals(true);
            renderNotifyToggle->setChecked(renderAtts->GetNotifyForEachRender());
            renderNotifyToggle->blockSignals(false);
            break;
hrchilds's avatar
hrchilds committed
564
        case 6: //scalrenActivationMode
hrchilds's avatar
hrchilds committed
565 566
            RenderingAttributes::TriStateMode rtmp;
            rtmp = renderAtts->GetScalableActivationMode();
hrchilds's avatar
hrchilds committed
567
            scalrenActivationMode->blockSignals(true);
hrchilds's avatar
hrchilds committed
568
            if (rtmp == RenderingAttributes::Always)
hrchilds's avatar
hrchilds committed
569
               scalrenActivationMode->setButton(1);
hrchilds's avatar
hrchilds committed
570
            else if (rtmp == RenderingAttributes::Never)
hrchilds's avatar
hrchilds committed
571
               scalrenActivationMode->setButton(2);
hrchilds's avatar
hrchilds committed
572
            else
hrchilds's avatar
hrchilds committed
573 574
               scalrenActivationMode->setButton(0);
            scalrenActivationMode->blockSignals(false);
hrchilds's avatar
hrchilds committed
575 576
            shadowToggle->setEnabled(rtmp == RenderingAttributes::Always);
            if (rtmp != RenderingAttributes::Always)
hrchilds's avatar
hrchilds committed
577
                shadowStrengthSlider->setEnabled(false);
hrchilds's avatar
hrchilds committed
578
            break;
hrchilds's avatar
hrchilds committed
579 580 581 582 583 584 585 586 587 588 589 590 591
        case 7: //scalrenAutoThreshold
        {
            QString suffix;           
            int step, widgetVal;
            int actualVal = renderAtts->GetScalableAutoThreshold();
            InterpretScalableAutoThreshold(actualVal, &step, &suffix, &widgetVal);
            scalrenAutoThreshold->blockSignals(true);
            scalrenAutoThreshold->setLineStep(step);
            scalrenAutoThreshold->setSuffix(suffix);
            scalrenAutoThreshold->setValue(widgetVal);
            scalrenAutoThreshold->blockSignals(false);
            break;
        }
hrchilds's avatar
hrchilds committed
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613
        case 8: //specularFlag
            specularToggle->blockSignals(true);
            specularToggle->setChecked(renderAtts->GetSpecularFlag());
            specularToggle->blockSignals(false);
            specularStrengthSlider->setEnabled(renderAtts->GetSpecularFlag());
            specularPowerSlider->setEnabled(renderAtts->GetSpecularFlag());
            specularStrengthLabel->setEnabled(renderAtts->GetSpecularFlag());
            specularPowerLabel->setEnabled(renderAtts->GetSpecularFlag());
            break;
        case 9: //specularCoeff
            specularStrengthSlider->blockSignals(true);
            specularStrengthSlider->setValue(int(renderAtts->GetSpecularCoeff()*100.));
            specularStrengthSlider->blockSignals(false);
            break;
        case 10: //specularPower
            specularPowerSlider->blockSignals(true);
            specularPowerSlider->setValue(int(renderAtts->GetSpecularPower()*10.));
            specularPowerSlider->blockSignals(false);
            break;
        case 11: //specularColor
            // Not user-modifiable at this time
            break;
hrchilds's avatar
hrchilds committed
614 615 616 617 618 619 620 621 622 623 624 625
        case 12: //shadowFlag
            shadowToggle->blockSignals(true);
            shadowToggle->setChecked(renderAtts->GetDoShadowing());
            shadowToggle->blockSignals(false);
            shadowStrengthSlider->setEnabled(renderAtts->GetDoShadowing());
            shadowStrengthLabel->setEnabled(renderAtts->GetDoShadowing());
            break;
        case 13: //shadowStrength
            shadowStrengthSlider->blockSignals(true);
            shadowStrengthSlider->setValue(int(renderAtts->GetShadowStrength()*100.));
            shadowStrengthSlider->blockSignals(false);
            break;
hrchilds's avatar
hrchilds committed
626 627 628 629 630 631 632 633 634 635 636 637
        case 14: //scalrenCompressMode
            itmp = (int) renderAtts->GetCompressionActivationMode();
            if (itmp == 2) // Auto for atts's enum type order
                itmp2 = 0; // Order of Auto in window
            else if (itmp == 1) // Always for atts' enum type order
                itmp2 = 1; // Order of Always in window.
            else           // Never for atts' enum type order
                itmp2 = 2; // Order of Never in window.
            scalrenCompressMode->blockSignals(true);
            scalrenCompressMode->setButton(itmp2);
            scalrenCompressMode->blockSignals(false);
            break;
hrchilds's avatar
hrchilds committed
638 639 640 641 642
        case 15: //colorTexturingFlag
            colorTexturingToggle->blockSignals(true);
            colorTexturingToggle->setChecked(renderAtts->GetColorTexturingFlag());
            colorTexturingToggle->blockSignals(false);
            break;
hrchilds's avatar
hrchilds committed
643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662
        }
    }
}

// ****************************************************************************
// Method: QvisRenderingWindow::UpdateInformation
//
// Purpose: 
//   Updates the information labels with statistics from the viewer.
//
// Arguments:
//   doAll : Whether or not to ignore selection and update all widgets.
//
// Programmer: Brad Whitlock
// Creation:   Tue Sep 24 11:29:35 PDT 2002
//
// Modifications:
//   Eric Brugger, Fri Apr 18 11:52:33 PDT 2003
//   I removed auto center view.
//   
hrchilds's avatar
hrchilds committed
663 664 665 666
//   Jeremy Meredith, Tue Nov 16 11:39:53 PST 2004
//   Replaced simple QString::sprintf's with a setNum because there seems
//   to be a bug causing numbers to be incremented by .00001.  See '5263.
//
hrchilds's avatar
hrchilds committed
667 668 669
//   Mark C. Miller, Wed Jan  5 16:23:01 PST 2005
//   Fixed problem with case lables not matching Select statements
//
hrchilds's avatar
hrchilds committed
670 671 672
//   Mark C. Miller, Fri Mar  4 13:05:02 PST 2005
//   Changed GetNumTriangles to GetNumPrimitives
//
hrchilds's avatar
hrchilds committed
673 674 675
//   Mark C. Miller, Thu Jul 21 20:16:42 PDT 2005
//   Added a break; statement after case label 16
//
hrchilds's avatar
hrchilds committed
676 677
//   Mark C. Miller, Wed Nov 16 10:46:36 PST 2005
//   Added seconds per frame for < 1 fps cases 
hrchilds's avatar
hrchilds committed
678 679 680 681 682 683 684
// ****************************************************************************

void
QvisRenderingWindow::UpdateInformation(bool doAll)
{
    QString tmp;
    float fps;
hrchilds's avatar
hrchilds committed
685
    int j;
hrchilds's avatar
hrchilds committed
686 687 688 689 690 691 692 693 694 695 696 697 698 699

    // Loop through all the attributes and do something for
    // each of them that changed. This function is only responsible
    // for displaying the state values and setting widget sensitivity.
    for(int i = 0; i < windowInfo->NumAttributes(); ++i)
    {
        if(!doAll)
        {
            if(!windowInfo->IsSelected(i))
            continue;
        }

        switch(i)
        {
hrchilds's avatar
hrchilds committed
700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716
        case 0: //activeSource
        case 1: //activeTimeSlider
        case 2: //timeSliders
        case 3: //timeSliderCurrentStates
        case 4: //animationMode
        case 5: //windowMode
        case 6: //boundingBoxNavigate
        case 7: //spin
        case 8: //fullFrame
        case 9: //perspective
        case 10: //lockView
        case 11: //lockTools
        case 12: //lockTime
        case 13: //viewExtentsType
        case 14: //viewDimension
        case 15: //viewKeyframes
        case 16: //cameraViewMode
hrchilds's avatar
hrchilds committed
717
            break;
hrchilds's avatar
hrchilds committed
718 719
        case 17: // usingScalableRendering
            scalrenUsingLabel->setText(windowInfo->GetUsingScalableRendering() ? "yes" : "no");
hrchilds's avatar
hrchilds committed
720
            break;
hrchilds's avatar
hrchilds committed
721
        case 18: //lastRenderMin
hrchilds's avatar
hrchilds committed
722 723 724 725 726 727 728 729 730
            // Determine the fps.
            if(windowInfo->GetLastRenderMin() > 0. &&
               windowInfo->GetLastRenderMin() < 1.e05)
                fps = 1. / windowInfo->GetLastRenderMin();
            else
                fps = 0.;
            tmp.sprintf("%1.3g", fps);
            fpsMaxLabel->setText(tmp);
            break;
hrchilds's avatar
hrchilds committed
731
        case 19: //lastRenderAvg
hrchilds's avatar
hrchilds committed
732 733 734 735 736
            // Determine the fps.
            if(windowInfo->GetLastRenderAvg() > 0.)
                fps = 1. / windowInfo->GetLastRenderAvg();
            else
                fps = 0.;
hrchilds's avatar
hrchilds committed
737 738 739 740 741 742 743 744 745
            if (fps > 0.0 && fps < 1.0)
            {
                fps = 1.0 / fps;
                fpsLabel->setText("Seconds per frame:");
            }
            else
            {
                fpsLabel->setText("Frames per second:");
            }
hrchilds's avatar
hrchilds committed
746 747 748
            tmp.sprintf("%1.3g", fps);
            fpsAvgLabel->setText(tmp);
            break;
hrchilds's avatar
hrchilds committed
749
        case 20: //lastRenderMax
hrchilds's avatar
hrchilds committed
750 751 752 753 754 755 756 757
            // Determine the fps.
            if(windowInfo->GetLastRenderMax() > 0.)
                fps = 1. / windowInfo->GetLastRenderMax();
            else
                fps = 0.;
            tmp.sprintf("%1.3g", fps);
            fpsMinLabel->setText(tmp);
            break;
hrchilds's avatar
hrchilds committed
758 759 760
        case 21: //numPrimitives
            tmp.sprintf("%d", windowInfo->GetNumPrimitives());
            approxNumPrimitives->setText(tmp);
hrchilds's avatar
hrchilds committed
761
            break;
hrchilds's avatar
hrchilds committed
762
        case 22: //extents
hrchilds's avatar
hrchilds committed
763
            for(j = 0; j < 6; ++j)
hrchilds's avatar
hrchilds committed
764 765 766 767 768
            {
                double d = windowInfo->GetExtents()[j];
                if(d == DBL_MAX || d == -DBL_MAX)
                    tmp = "not set";
                else
hrchilds's avatar
hrchilds committed
769
                    tmp.setNum(windowInfo->GetExtents()[j]);
hrchilds's avatar
hrchilds committed
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799
                extents[j]->setText(tmp);
            }
            break;
        }            
    }
}

// ****************************************************************************
// Method: QvisRenderingWindow::Apply
//
// Purpose: 
//   Tells the viewer to apply the rendering attributes.
//
// Arguments:
//   ignore : A flag that causes us to unconditionally apply the
//            rendering attributes.
//
// Programmer: Brad Whitlock
// Creation:   Mon Sep 23 14:49:19 PST 2002
//
// Modifications:
//   
// ****************************************************************************

void
QvisRenderingWindow::Apply(bool ignore)
{
    if(AutoUpdate() || ignore)
    {
        renderAtts->Notify();
hrchilds's avatar
hrchilds committed
800
        GetViewerMethods()->SetRenderingAttributes();
hrchilds's avatar
hrchilds committed
801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950
    }
    else
        renderAtts->Notify();
}

// ****************************************************************************
// Method: QvisRenderingWindow::SubjectRemoved
//
// Purpose: 
//   This method makes sure that we don't Detach from the subject if it is
//   destroyed first.
//
// Arguments:
//   TheRemovedSubject : The subject being deleted.
//
// Programmer: Brad Whitlock
// Creation:   Mon Sep 23 14:50:04 PST 2002
//
// Modifications:
//   
// ****************************************************************************

void
QvisRenderingWindow::SubjectRemoved(Subject *TheRemovedSubject)
{
    if(TheRemovedSubject == renderAtts)
        renderAtts = 0;
    else if(TheRemovedSubject == windowInfo)
        windowInfo = 0;
}

// ****************************************************************************
// Method: QvisRenderingWindow::ConnectRenderingAttributes
//
// Purpose: 
//   Makes this window observe the rendering attributes.
//
// Arguments:
//   w : The rendering attributes.
//
// Programmer: Brad Whitlock
// Creation:   Mon Sep 23 14:51:11 PST 2002
//
// Modifications:
//   
// ****************************************************************************

void
QvisRenderingWindow::ConnectRenderingAttributes(RenderingAttributes *w)
{
    renderAtts = w;
    renderAtts->Attach(this);
}

// ****************************************************************************
// Method: QvisRenderingWindow::ConnectWindowInformation
//
// Purpose: 
//   Makes this window observe the window information.
//
// Arguments:
//   w : The window information.
//
// Programmer: Brad Whitlock
// Creation:   Mon Sep 23 14:51:11 PST 2002
//
// Modifications:
//   
// ****************************************************************************

void
QvisRenderingWindow::ConnectWindowInformation(WindowInformation *w)
{
    windowInfo = w;
    windowInfo->Attach(this);
}

//
// Qt slot functions
//

// ****************************************************************************
// Method: QvisRenderingWindow::apply
//
// Purpose: 
//   This Qt slot function is called by clicking the apply button.
//
// Programmer: Brad Whitlock
// Creation:   Mon Sep 23 14:51:45 PST 2002
//
// Modifications:
//   
// ****************************************************************************

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

// ****************************************************************************
// Method: QvisRenderingWindow::antialiasingToggled
//
// Purpose: 
//   This Qt slot function is called when the antialiasing checkbox is clicked.
//
// Arguments:
//   val : The new AA value.
//
// Programmer: Brad Whitlock
// Creation:   Mon Sep 23 14:52:07 PST 2002
//
// Modifications:
//   
// ****************************************************************************

void
QvisRenderingWindow::antialiasingToggled(bool val)
{
    renderAtts->SetAntialiasing(val);
    SetUpdate(false);
    Apply();
}

// ****************************************************************************
// Method: QvisRenderingWindow::objectRepresentationChanged
//
// Purpose: 
//   This Qt slot function is called when we change surface representations.
//
// Arguments:
//   val : The new surface representation.
//
// Programmer: Brad Whitlock
// Creation:   Mon Sep 23 14:53:28 PST 2002
//
// Modifications:
//   
// ****************************************************************************

void
QvisRenderingWindow::objectRepresentationChanged(int val)
{
    renderAtts->SetGeometryRepresentation(
        (RenderingAttributes::GeometryRepresentation)val);
    SetUpdate(false);
    Apply();
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
951
// Method: QvisRenderingWindow::displayListModeChanged
hrchilds's avatar
hrchilds committed
952 953
//
// Purpose: 
hrchilds's avatar
hrchilds committed
954
//   This Qt slot function is called when we change the display list mode.
hrchilds's avatar
hrchilds committed
955 956
//
// Arguments:
hrchilds's avatar
hrchilds committed
957
//   mode : The new display list mode.
hrchilds's avatar
hrchilds committed
958
//
hrchilds's avatar
hrchilds committed
959 960
// Programmer: Hank Childs
// Creation:   May 9, 2004
hrchilds's avatar
hrchilds committed
961 962 963 964 965 966
//
// Modifications:
//   
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
967
QvisRenderingWindow::displayListModeChanged(int mode)
hrchilds's avatar
hrchilds committed
968
{
hrchilds's avatar
hrchilds committed
969 970 971 972 973 974 975 976
    int itmp = 0;
    if (mode == 0)      // Auto in Window
        itmp = 2;       // Auto for atts' enum type
    else if (mode == 1) // Always in window
        itmp = 1;       // Always for atts' enum type
    else                // Never in window.
        itmp = 0;       // Never for atts' enum type

hrchilds's avatar
hrchilds committed
977
    renderAtts->SetDisplayListMode((RenderingAttributes::TriStateMode)itmp);
hrchilds's avatar
hrchilds committed
978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054
    SetUpdate(false);
    Apply();
}

// ****************************************************************************
// Method: QvisRenderingWindow::stereoToggled
//
// Purpose: 
//   This Qt slot function is called when we change turn stereo on/off.
//
// Arguments:
//   val : The new stereo enabled mode.
//
// Programmer: Brad Whitlock
// Creation:   Mon Sep 23 14:54:52 PST 2002
//
// Modifications:
//   
// ****************************************************************************

void
QvisRenderingWindow::stereoToggled(bool val)
{
    renderAtts->SetStereoRendering(val);
    Apply();
}

// ****************************************************************************
// Method: QvisRenderingWindow::stereoTypeChanged
//
// Purpose: 
//   This Qt slot function is called when the stereo type changes.
//
// Arguments:
//   val : The new stereo type.
//
// Programmer: Brad Whitlock
// Creation:   Mon Sep 23 14:55:32 PST 2002
//
// Modifications:
//   
// ****************************************************************************

void
QvisRenderingWindow::stereoTypeChanged(int val)
{
    renderAtts->SetStereoType((RenderingAttributes::StereoTypes)val);
    SetUpdate(false);
    Apply();
}

// ****************************************************************************
// Method: QvisRenderingWindow::renderNotifyToggled
//
// Purpose: 
//   This Qt slot function is called when the "Query after render" toggle
//   button is clicked.
//
// Arguments:
//   val : The new query mode.
//
// Programmer: Brad Whitlock
// Creation:   Mon Sep 23 14:56:12 PST 2002
//
// Modifications:
//   
// ****************************************************************************

void
QvisRenderingWindow::renderNotifyToggled(bool val)
{
    renderAtts->SetNotifyForEachRender(val);
    SetUpdate(false);
    Apply();
}

// ****************************************************************************
hrchilds's avatar
hrchilds committed
1055
// Method: QvisRenderingWindow::scalrenActivationModeChanged
hrchilds's avatar
hrchilds committed
1056 1057
//
// Purpose: 
hrchilds's avatar
hrchilds committed
1058
//   This Qt slot function is called when the scalable activation mode changes.
hrchilds's avatar
hrchilds committed
1059 1060
//
// Arguments:
hrchilds's avatar
hrchilds committed
1061
//   val : The new scalable activation mode flag.
hrchilds's avatar
hrchilds committed
1062
//         0 = Auto, 1 = Always, 2 = Never
hrchilds's avatar
hrchilds committed
1063 1064 1065 1066 1067
//
// Programmer: Mark C. Miller 
// Creation:   Wed Nov 20 17:09:59 PST 2002 
//
// Modifications:
hrchilds's avatar
hrchilds committed
1068 1069 1070
//
//   Mark C. Miller, Tue Apr 27 14:41:35 PDT 2004
//   Added scalrenAutoThreshold spinbox and geometry label
hrchilds's avatar
hrchilds committed
1071
//   
hrchilds's avatar
hrchilds committed
1072 1073 1074 1075
//   Mark C. Miller, Tue May 11 20:21:24 PDT 2004
//   Changed scalable rendering controls to use activation mode and auto
//   threshold
//
hrchilds's avatar
hrchilds committed
1076 1077 1078
//   Hank Childs, Sun Dec  4 18:41:39 PST 2005
//   Automatically update the shadow toggle ['5596].
//
hrchilds's avatar
hrchilds committed
1079 1080 1081
// ****************************************************************************

void
hrchilds's avatar
hrchilds committed
1082
QvisRenderingWindow::scalrenActivationModeChanged(int val)
hrchilds's avatar
hrchilds committed
1083
{
hrchilds's avatar
hrchilds committed
1084
    if (val == 0)
hrchilds's avatar
hrchilds committed
1085 1086 1087
    {
        scalrenAutoThreshold->setEnabled(1);
        scalrenGeometryLabel->setEnabled(1);
hrchilds's avatar
hrchilds committed
1088
        renderAtts->SetScalableActivationMode(RenderingAttributes::Auto);
hrchilds's avatar
hrchilds committed
1089
        scalrenAutoThresholdChanged(scalrenAutoThreshold->value());
hrchilds's avatar
hrchilds committed
1090
        shadowToggle->setEnabled(false);
hrchilds's avatar
hrchilds committed
1091
    }
hrchilds's avatar
hrchilds committed
1092
    else if (val == 1)
hrchilds's avatar
hrchilds committed
1093 1094 1095
    {
        scalrenAutoThreshold->setEnabled(0);
        scalrenGeometryLabel->setEnabled(0);
hrchilds's avatar
hrchilds committed
1096
        shadowToggle->setEnabled(true);
hrchilds's avatar
hrchilds committed
1097
        renderAtts->SetScalableActivationMode(RenderingAttributes::Always);
hrchilds's avatar
hrchilds committed
1098
    }
hrchilds's avatar
hrchilds committed
1099
    else
hrchilds's avatar
hrchilds committed
1100 1101 1102
    {
        scalrenAutoThreshold->setEnabled(0);
        scalrenGeometryLabel->setEnabled(0);
hrchilds's avatar
hrchilds committed
1103
        renderAtts->SetScalableActivationMode(RenderingAttributes::Never);
hrchilds's avatar
hrchilds committed
1104
        shadowToggle->setEnabled(false);
hrchilds's avatar
hrchilds committed
1105 1106 1107 1108 1109
    }
    SetUpdate(false);
    Apply();
}

hrchilds's avatar
hrchilds committed
1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142
// ****************************************************************************
// Method: QvisRenderingWindow::InterpretScalableAutoThreshold
//
// Purpose: Determine widget controls given scalable auto threshold 
//
// Programmer: Mark C. Miller 
// Creation:   January 4, 2005 
//
// ****************************************************************************
void
QvisRenderingWindow::InterpretScalableAutoThreshold(int actualVal,
    int *step, QString *suffix, int *widgetVal) const
{
    // compute the step size and suffix for the displayed value in the GUI
    if      (actualVal < 1e3) { *step = 50;  *suffix = "  Polys"; }
    else if (actualVal < 1e4) { *step = 500; *suffix = "  Polys"; }
    else if (actualVal < 1e5) { *step = 5;   *suffix = " KPolys"; }
    else if (actualVal < 1e6) { *step = 50;  *suffix = " KPolys"; }
    else if (actualVal < 1e7) { *step = 500; *suffix = " KPolys"; }
    else if (actualVal < 1e8) { *step = 5;   *suffix = " MPolys"; }
    else if (actualVal < 1e9) { *step = 50;  *suffix = " MPolys"; }
    else                      { *step = 1;   *suffix = " GPolys"; }

    // compute the divisor for the displayed value in the GUI
    int div;
    if      (*suffix == " KPolys") div = (int) 1e3;
    else if (*suffix == " MPolys") div = (int) 1e6; 
    else if (*suffix == " GPolys") div = (int) 1e9;
    else                          div = 1;

    *widgetVal = actualVal / div;
}

hrchilds's avatar
hrchilds committed
1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157
// ****************************************************************************
// Method: QvisRenderingWindow::scalrenAutoThresholdChanged
//
// Purpose: 
//   This Qt slot function is called when the scalable rendering automatic
//   polygon count threshold changes.
//
// Arguments:
//   val : The new polygon count threshold.
//
// Programmer: Mark C. Miller 
// Creation:   Wed Apr 21 22:42:57 PDT 2004 
//
// Modifications:
//   
hrchilds's avatar
hrchilds committed
1158 1159 1160 1161
//   Mark C. Miller, Tue May 11 20:21:24 PDT 2004
//   Changed scalable rendering controls to use activation mode and auto
//   threshold
//
hrchilds's avatar
hrchilds committed
1162 1163 1164
//   Mark C. Miller, Tue Jan  4 10:23:19 PST 2005
//   Changed to use InterpretScalableAutoThreshold
//
hrchilds's avatar
hrchilds committed
1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198
// ****************************************************************************
void
QvisRenderingWindow::scalrenAutoThresholdChanged(int val)
{
    // determine the actual value from the given value and the current suffix
    int actualVal;
    if (scalrenAutoThreshold->suffix() == " GPolys")
        actualVal = val * (int) 1e9;
    else if (scalrenAutoThreshold->suffix() == " MPolys")
        actualVal = val * (int) 1e6;
    else if (scalrenAutoThreshold->suffix() == " KPolys")
        actualVal = val * (int) 1e3;
    else if (scalrenAutoThreshold->suffix() == "  Polys")
        actualVal = val;
    else
        actualVal = val;

    // deal with stepping backwards
    int step = scalrenAutoThreshold->lineStep();
    if ((val == 500) && (step == 500) && (scalrenAutoThreshold->suffix() == "  Polys"))
        actualVal = 950;
    else if ((val == 5) && (step == 5) && (scalrenAutoThreshold->suffix() == " KPolys"))
        actualVal = 9500;
    else if ((val == 50) && (step == 50) && (scalrenAutoThreshold->suffix() == " KPolys"))
        actualVal = 95000;
    else if ((val == 500) && (step == 500) && (scalrenAutoThreshold->suffix() == " KPolys"))
        actualVal = 950000;
    else if ((val == 5) && (step == 5) && (scalrenAutoThreshold->suffix() == " MPolys"))
        actualVal = 9500000;
    else if ((val == 50) && (step == 50) && (scalrenAutoThreshold->suffix() == " MPolys"))
        actualVal = 95000000;
    else if ((val == 0) && (step == 1) && (scalrenAutoThreshold->suffix() == " GPolys"))
        actualVal = 950000000;

hrchilds's avatar
hrchilds committed
1199
    int widgetVal;
hrchilds's avatar
hrchilds committed
1200
    QString suffix;
hrchilds's avatar
hrchilds committed
1201
    InterpretScalableAutoThreshold(actualVal, &step, &suffix, &widgetVal);
hrchilds's avatar
hrchilds committed
1202 1203 1204 1205

    // set the new GUI value
    scalrenAutoThreshold->setLineStep(step);
    scalrenAutoThreshold->setSuffix(suffix);
hrchilds's avatar
hrchilds committed
1206 1207
    scalrenAutoThreshold->setValue(widgetVal);

hrchilds's avatar
hrchilds committed
1208
    renderAtts->SetScalableAutoThreshold(actualVal);
hrchilds's avatar
hrchilds committed
1209

hrchilds's avatar
hrchilds committed
1210 1211 1212
    SetUpdate(false);
    Apply();
}
hrchilds's avatar
hrchilds committed
1213

hrchilds's avatar
hrchilds committed
1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236
// ****************************************************************************
// Method: QvisRenderingWindow::scalrenCompressModeChanged
//
// Programmer: Mark C. Miller
// Creation:   November 2, 2005 
//
// ****************************************************************************

void
QvisRenderingWindow::scalrenCompressModeChanged(int mode)
{
    int itmp = 0;
    if (mode == 0)      // Auto in Window
        itmp = 2;       // Auto for atts' enum type
    else if (mode == 1) // Always in window
        itmp = 1;       // Always for atts' enum type
    else                // Never in window.
        itmp = 0;       // Never for atts' enum type

    renderAtts->SetCompressionActivationMode((RenderingAttributes::TriStateMode)itmp);
    SetUpdate(false);
    Apply();
}
hrchilds's avatar
hrchilds committed
1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282
// ****************************************************************************
//  Method:  QvisRenderingWindow::shadowToggled
//
//  Purpose:
//    Callback for the shadow toggle button
//
//  Arguments:
//    val        true to enable shadow
//
//  Programmer:  Hank Childs
//  Creation:    October 24, 2004
//
// ****************************************************************************

void
QvisRenderingWindow::shadowToggled(bool val)
{
    renderAtts->SetDoShadowing(val);
    shadowStrengthSlider->setEnabled(renderAtts->GetDoShadowing());
    shadowStrengthLabel->setEnabled(renderAtts->GetDoShadowing());
    SetUpdate(false);
    Apply();
}

// ****************************************************************************
//  Method:  QvisRenderingWindow::shadowStrengthChanged
//
//  Purpose:
//    Callback for the shadow coefficient slider
//
//  Arguments:
//    val        the new coefficient
//
//  Programmer:  Hank Childs
//  Creation:    October 24, 2004
//
// ****************************************************************************

void
QvisRenderingWindow::shadowStrengthChanged(int val, const void*)
{
    renderAtts->SetShadowStrength(float(val)/100.);
    SetUpdate(false);
    Apply();
}

hrchilds's avatar
hrchilds committed
1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351
// ****************************************************************************
//  Method:  QvisRenderingWindow::specularToggled
//
//  Purpose:
//    Callback for the specular toggle button
//
//  Arguments:
//    val        true to enable specular
//
//  Programmer:  Jeremy Meredith
//  Creation:    November 14, 2003
//
// ****************************************************************************

void
QvisRenderingWindow::specularToggled(bool val)
{
    renderAtts->SetSpecularFlag(val);
    specularStrengthSlider->setEnabled(renderAtts->GetSpecularFlag());
    specularPowerSlider->setEnabled(renderAtts->GetSpecularFlag());
    specularStrengthLabel->setEnabled(renderAtts->GetSpecularFlag());
    specularPowerLabel->setEnabled(renderAtts->GetSpecularFlag());
    SetUpdate(false);
    Apply();
}

// ****************************************************************************
//  Method:  QvisRenderingWindow::specularStrengthChanged
//
//  Purpose:
//    Callback for the specular coefficient slider
//
//  Arguments:
//    val        the new coefficient
//
//  Programmer:  Jeremy Meredith
//  Creation:    November 14, 2003
//
// ****************************************************************************

void
QvisRenderingWindow::specularStrengthChanged(int val, const void*)
{
    renderAtts->SetSpecularCoeff(float(val)/100.);
    SetUpdate(false);
    Apply();
}

// ****************************************************************************
//  Method:  QvisRenderingWindow::specularPowerChanged
//
//  Purpose:
//    Callback for the specular exponent slider.
//
//  Arguments:
//    val        the new value
//
//  Programmer:  Jeremy Meredith
//  Creation:    November 14, 2003
//
// ****************************************************************************

void
QvisRenderingWindow::specularPowerChanged(int val, const void*)
{
    renderAtts->SetSpecularPower(float(val)/10.);
    SetUpdate(false);
    Apply();
}
hrchilds's avatar
hrchilds committed
1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376

// ****************************************************************************
// Method: QvisRenderingWindow::colorTexturingToggled
//
// Purpose: 
//   This is a Qt slot function that is called when the colorTexturing check
//   box is toggled.
//
// Arguments:
//   val : The new on/off value for the widget.
//
// Programmer: Brad Whitlock
// Creation:   Mon Sep 18 10:52:30 PDT 2006
//
// Modifications:
//   
// ****************************************************************************

void
QvisRenderingWindow::colorTexturingToggled(bool val)
{
    renderAtts->SetColorTexturingFlag(val);
    SetUpdate(false);
    Apply();
}