QvisLineoutWindow.C 11.3 KB
Newer Older
hrchilds's avatar
hrchilds committed
1 2
/*****************************************************************************
*
bonnell's avatar
bonnell committed
3
* Copyright (c) 2000 - 2017, 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 41 42
#include "QvisLineoutWindow.h"

#include <LineoutAttributes.h>

whitlocb's avatar
whitlocb committed
43 44 45 46
#include <QCheckBox>
#include <QGroupBox>
#include <QLabel>
#include <QLayout>
hrchilds's avatar
hrchilds committed
47
#include <QNarrowLineEdit.h>
hrchilds's avatar
hrchilds committed
48 49 50 51 52 53 54 55

// ****************************************************************************
// Method: QvisLineoutWindow::QvisLineoutWindow
//
// Purpose: 
//   Constructor
//
// Programmer: xml2window
hrchilds's avatar
hrchilds committed
56
// Creation:   Fri Nov 19 11:39:48 PDT 2004
hrchilds's avatar
hrchilds committed
57 58 59 60 61 62 63
//
// Modifications:
//   
// ****************************************************************************

QvisLineoutWindow::QvisLineoutWindow(const int type,
                         LineoutAttributes *subj,
64 65
                         const QString &caption,
                         const QString &shortName,
hrchilds's avatar
hrchilds committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79
                         QvisNotepadArea *notepad)
    : QvisOperatorWindow(type,subj, caption, shortName, notepad)
{
    atts = subj;
}


// ****************************************************************************
// Method: QvisLineoutWindow::~QvisLineoutWindow
//
// Purpose: 
//   Destructor
//
// Programmer: xml2window
hrchilds's avatar
hrchilds committed
80
// Creation:   Fri Nov 19 11:39:48 PDT 2004
hrchilds's avatar
hrchilds committed
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
//
// Modifications:
//   
// ****************************************************************************

QvisLineoutWindow::~QvisLineoutWindow()
{
}


// ****************************************************************************
// Method: QvisLineoutWindow::CreateWindowContents
//
// Purpose: 
//   Creates the widgets for the window.
//
// Programmer: xml2window
hrchilds's avatar
hrchilds committed
98
// Creation:   Fri Nov 19 11:39:48 PDT 2004
hrchilds's avatar
hrchilds committed
99 100
//
// Modifications:
hrchilds's avatar
hrchilds committed
101 102 103
//   Brad Whitlock, Tue Dec 21 11:53:09 PDT 2004
//   Added code to support Qt pre-3.2.
//
104 105 106
//   Brad Whitlock, Fri Apr 25 09:00:46 PDT 2008
//   Added tr()'s
//
whitlocb's avatar
whitlocb committed
107 108 109
//   Cyrus Harrison, Tue Aug 19 11:37:56 PDT 2008
//   Qt4 Port. (Removed pre Qt 3.2 logic)
//
hrchilds's avatar
hrchilds committed
110 111 112 113 114
// ****************************************************************************

void
QvisLineoutWindow::CreateWindowContents()
{
whitlocb's avatar
whitlocb committed
115 116
    QGridLayout *mainLayout = new QGridLayout();
    topLayout->addLayout(mainLayout);
hrchilds's avatar
hrchilds committed
117

hrchilds's avatar
hrchilds committed
118 119 120
    //
    // Point1
    //
whitlocb's avatar
whitlocb committed
121
    point1 = new QLineEdit(central);
hrchilds's avatar
hrchilds committed
122 123
    connect(point1, SIGNAL(returnPressed()),
            this, SLOT(point1ProcessText()));
whitlocb's avatar
whitlocb committed
124
    mainLayout->addWidget(new QLabel(tr("Point 1"), central), 0,0);
hrchilds's avatar
hrchilds committed
125 126
    mainLayout->addWidget(point1, 0,1);

hrchilds's avatar
hrchilds committed
127 128 129
    //
    // Point2
    //
whitlocb's avatar
whitlocb committed
130
    point2 = new QLineEdit(central);
hrchilds's avatar
hrchilds committed
131 132
    connect(point2, SIGNAL(returnPressed()),
            this, SLOT(point2ProcessText()));
whitlocb's avatar
whitlocb committed
133
    mainLayout->addWidget(new QLabel(tr("Point 2"), central), 1,0);
hrchilds's avatar
hrchilds committed
134 135
    mainLayout->addWidget(point2, 1,1);

hrchilds's avatar
hrchilds committed
136 137 138
    //
    // Interactive
    //
whitlocb's avatar
whitlocb committed
139
    interactive = new QCheckBox(tr("Interactive"), central);
hrchilds's avatar
hrchilds committed
140 141
    connect(interactive, SIGNAL(toggled(bool)),
            this, SLOT(interactiveChanged(bool)));
whitlocb's avatar
whitlocb committed
142
    mainLayout->addWidget(interactive, 2,0,1,2);
hrchilds's avatar
hrchilds committed
143 144 145 146

    //
    // IgnoreGlobal
    //
hrchilds's avatar
hrchilds committed
147
    QGroupBox *globalGroup;
whitlocb's avatar
whitlocb committed
148

149
    ignoreGlobal = new QGroupBox(tr("Override Global Lineout Settings"),
whitlocb's avatar
whitlocb committed
150
                                 central);
hrchilds's avatar
hrchilds committed
151
    ignoreGlobal->setCheckable(true);
hrchilds's avatar
hrchilds committed
152
    globalGroup = ignoreGlobal;
hrchilds's avatar
hrchilds committed
153 154 155
    connect(ignoreGlobal, SIGNAL(toggled(bool)),
            this, SLOT(ignoreGlobalChanged(bool)));
    topLayout->addWidget(ignoreGlobal);
hrchilds's avatar
hrchilds committed
156 157

    QVBoxLayout *blayout = new QVBoxLayout(globalGroup);
whitlocb's avatar
whitlocb committed
158 159
    QGridLayout *qgrid  = new QGridLayout();
    blayout->addLayout(qgrid);
hrchilds's avatar
hrchilds committed
160 161 162 163

    //
    // SamplingOn
    //
whitlocb's avatar
whitlocb committed
164
    samplingOn = new QCheckBox(tr("Use Sampling"), globalGroup);
hrchilds's avatar
hrchilds committed
165 166
    connect(samplingOn, SIGNAL(toggled(bool)),
            this, SLOT(samplingOnChanged(bool)));
hrchilds's avatar
hrchilds committed
167 168 169 170 171
    qgrid->addWidget(samplingOn, 1,0);

    //
    // NumberOfSamplePoints
    //
whitlocb's avatar
whitlocb committed
172
    numberOfSamplePointsLabel = new QLabel(tr("Samples"),  globalGroup);
hrchilds's avatar
hrchilds committed
173 174
    numberOfSamplePointsLabel->setAlignment(Qt::AlignCenter);
    qgrid->addWidget(numberOfSamplePointsLabel,2,0);
whitlocb's avatar
whitlocb committed
175
    numberOfSamplePoints = new QNarrowLineEdit(globalGroup);
hrchilds's avatar
hrchilds committed
176 177
    connect(numberOfSamplePoints, SIGNAL(returnPressed()),
            this, SLOT(numberOfSamplePointsProcessText()));
hrchilds's avatar
hrchilds committed
178
    qgrid->addWidget(numberOfSamplePoints, 2,1);
hrchilds's avatar
hrchilds committed
179

hrchilds's avatar
hrchilds committed
180 181 182
    //
    // ReflineLabels
    //
whitlocb's avatar
whitlocb committed
183
    reflineLabels = new QCheckBox(tr("Refline Labels"), globalGroup);
hrchilds's avatar
hrchilds committed
184 185
    connect(reflineLabels, SIGNAL(toggled(bool)),
            this, SLOT(reflineLabelsChanged(bool)));
hrchilds's avatar
hrchilds committed
186
    qgrid->addWidget(reflineLabels, 3,0);
hrchilds's avatar
hrchilds committed
187 188 189 190 191 192 193 194 195 196
}


// ****************************************************************************
// Method: QvisLineoutWindow::UpdateWindow
//
// Purpose: 
//   Updates the widgets in the window when the subject changes.
//
// Programmer: xml2window
hrchilds's avatar
hrchilds committed
197
// Creation:   Fri Nov 19 11:39:48 PDT 2004
hrchilds's avatar
hrchilds committed
198 199
//
// Modifications:
hrchilds's avatar
hrchilds committed
200 201 202
//   Brad Whitlock, Tue Dec 21 11:51:46 PDT 2004
//   Added code to block signals and also some code to support Qt pre-3.2.
//
whitlocb's avatar
whitlocb committed
203 204 205
//   Cyrus Harrison, Tue Aug 19 11:37:56 PDT 2008
//   Qt4 Port. (Removed pre Qt 3.2 logic)
//
hrchilds's avatar
hrchilds committed
206 207 208 209 210
// ****************************************************************************

void
QvisLineoutWindow::UpdateWindow(bool doAll)
{
whitlocb's avatar
whitlocb committed
211
    bool flag;
hrchilds's avatar
hrchilds committed
212 213 214 215 216 217 218 219 220 221 222 223
    for(int i = 0; i < atts->NumAttributes(); ++i)
    {
        if(!doAll)
        {
            if(!atts->IsSelected(i))
            {
                continue;
            }
        }

        switch(i)
        {
whitlocb's avatar
whitlocb committed
224 225
          case LineoutAttributes::ID_point1:
            point1->setText(DoublesToQString(atts->GetPoint1(),3));
hrchilds's avatar
hrchilds committed
226
            break;
whitlocb's avatar
whitlocb committed
227 228
          case LineoutAttributes::ID_point2:
            point2->setText(DoublesToQString(atts->GetPoint2(),3));
hrchilds's avatar
hrchilds committed
229
            break;
whitlocb's avatar
whitlocb committed
230
          case LineoutAttributes::ID_interactive:
hrchilds's avatar
hrchilds committed
231
            interactive->blockSignals(true);
hrchilds's avatar
hrchilds committed
232
            interactive->setChecked(atts->GetInteractive());
hrchilds's avatar
hrchilds committed
233
            interactive->blockSignals(false);
hrchilds's avatar
hrchilds committed
234
            break;
whitlocb's avatar
whitlocb committed
235
          case LineoutAttributes::ID_ignoreGlobal: 
hrchilds's avatar
hrchilds committed
236
            ignoreGlobal->blockSignals(true);
hrchilds's avatar
hrchilds committed
237
            ignoreGlobal->setChecked(atts->GetIgnoreGlobal());
hrchilds's avatar
hrchilds committed
238
            ignoreGlobal->blockSignals(false);
hrchilds's avatar
hrchilds committed
239
            break;
whitlocb's avatar
whitlocb committed
240
          case LineoutAttributes::ID_samplingOn:
hrchilds's avatar
hrchilds committed
241 242 243 244 245
            flag = atts->GetSamplingOn();
            numberOfSamplePoints->setEnabled(flag);
            numberOfSamplePointsLabel->setEnabled(flag);
            samplingOn->setChecked(flag);
            break;
whitlocb's avatar
whitlocb committed
246 247
          case LineoutAttributes::ID_numberOfSamplePoints:
            numberOfSamplePoints->setText(IntToQString(atts->GetNumberOfSamplePoints()));
hrchilds's avatar
hrchilds committed
248
            break;
whitlocb's avatar
whitlocb committed
249
          case LineoutAttributes::ID_reflineLabels:
hrchilds's avatar
hrchilds committed
250
            reflineLabels->blockSignals(true);
hrchilds's avatar
hrchilds committed
251
            reflineLabels->setChecked(atts->GetReflineLabels());
hrchilds's avatar
hrchilds committed
252
            reflineLabels->blockSignals(false);
hrchilds's avatar
hrchilds committed
253 254 255
            break;
        }
    }
hrchilds's avatar
hrchilds committed
256

hrchilds's avatar
hrchilds committed
257 258 259 260 261 262 263 264 265 266
}


// ****************************************************************************
// Method: QvisLineoutWindow::GetCurrentValues
//
// Purpose: 
//   Gets values from certain widgets and stores them in the subject.
//
// Programmer: xml2window
hrchilds's avatar
hrchilds committed
267
// Creation:   Fri Nov 19 11:39:48 PDT 2004
hrchilds's avatar
hrchilds committed
268 269
//
// Modifications:
whitlocb's avatar
whitlocb committed
270 271 272
//   Cyrus Harrison, Tue Aug 19 11:37:56 PDT 2008
//   Qt4 Port. (Removed pre Qt 3.2 logic)
//
hrchilds's avatar
hrchilds committed
273 274 275 276 277
// ****************************************************************************

void
QvisLineoutWindow::GetCurrentValues(int which_widget)
{
whitlocb's avatar
whitlocb committed
278
    bool doAll = (which_widget == -1);
hrchilds's avatar
hrchilds committed
279 280

    // Do point1
whitlocb's avatar
whitlocb committed
281
    if(which_widget == LineoutAttributes::ID_point1 || doAll)
hrchilds's avatar
hrchilds committed
282
    {
whitlocb's avatar
whitlocb committed
283 284 285 286
        double val[3];
        if(LineEditGetDoubles(point1, val, 3))
            atts->SetPoint1(val);
        else if(LineEditGetDoubles(point1, val, 2))
hrchilds's avatar
hrchilds committed
287
        {
whitlocb's avatar
whitlocb committed
288 289
            val[2] = 0.0;
            atts->SetPoint1(val);
hrchilds's avatar
hrchilds committed
290
        }
whitlocb's avatar
whitlocb committed
291
        else
hrchilds's avatar
hrchilds committed
292
        {
whitlocb's avatar
whitlocb committed
293 294
            ResettingError(tr("Point 1"),
                DoublesToQString(atts->GetPoint1(),3));
hrchilds's avatar
hrchilds committed
295 296 297 298 299
            atts->SetPoint1(atts->GetPoint1());
        }
    }

    // Do point2
whitlocb's avatar
whitlocb committed
300
    if(which_widget == LineoutAttributes::ID_point2 || doAll)
hrchilds's avatar
hrchilds committed
301
    {
whitlocb's avatar
whitlocb committed
302 303 304 305
        double val[3];
        if(LineEditGetDoubles(point2, val, 3))
            atts->SetPoint2(val);
        else if(LineEditGetDoubles(point2, val, 2))
hrchilds's avatar
hrchilds committed
306
        {
whitlocb's avatar
whitlocb committed
307 308
            val[2] = 0.0;
            atts->SetPoint2(val);
hrchilds's avatar
hrchilds committed
309
        }
whitlocb's avatar
whitlocb committed
310
        else
hrchilds's avatar
hrchilds committed
311
        {
whitlocb's avatar
whitlocb committed
312 313
            ResettingError(tr("Point 2"),
                DoublesToQString(atts->GetPoint2(),3));
hrchilds's avatar
hrchilds committed
314 315 316 317
            atts->SetPoint2(atts->GetPoint2());
        }
    }

hrchilds's avatar
hrchilds committed
318
    // Do numberOfSamplePoints
whitlocb's avatar
whitlocb committed
319
    if(which_widget == LineoutAttributes::ID_numberOfSamplePoints || doAll)
hrchilds's avatar
hrchilds committed
320
    {
whitlocb's avatar
whitlocb committed
321 322 323 324
        int val;
        if(LineEditGetInt(numberOfSamplePoints, val))
            atts->SetNumberOfSamplePoints(val);
        else
hrchilds's avatar
hrchilds committed
325
        {
whitlocb's avatar
whitlocb committed
326 327
            ResettingError(tr("Number of Sample Points "),
                IntToQString(atts->GetNumberOfSamplePoints()));
hrchilds's avatar
hrchilds committed
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342
            atts->SetNumberOfSamplePoints(atts->GetNumberOfSamplePoints());
        }
    }

}


//
// Qt Slot functions
//


void
QvisLineoutWindow::point1ProcessText()
{
whitlocb's avatar
whitlocb committed
343
    GetCurrentValues(LineoutAttributes::ID_point1);
hrchilds's avatar
hrchilds committed
344 345 346 347 348 349 350
    Apply();
}


void
QvisLineoutWindow::point2ProcessText()
{
whitlocb's avatar
whitlocb committed
351
    GetCurrentValues(LineoutAttributes::ID_point2);
hrchilds's avatar
hrchilds committed
352 353 354 355
    Apply();
}


hrchilds's avatar
hrchilds committed
356
void
hrchilds's avatar
hrchilds committed
357
QvisLineoutWindow::interactiveChanged(bool val)
hrchilds's avatar
hrchilds committed
358
{
hrchilds's avatar
hrchilds committed
359
    atts->SetInteractive(val);
hrchilds's avatar
hrchilds committed
360 361 362 363
    Apply();
}


hrchilds's avatar
hrchilds committed
364
void
hrchilds's avatar
hrchilds committed
365
QvisLineoutWindow::ignoreGlobalChanged(bool val)
hrchilds's avatar
hrchilds committed
366
{
hrchilds's avatar
hrchilds committed
367
    atts->SetIgnoreGlobal(val);
hrchilds's avatar
hrchilds committed
368 369 370 371 372
    Apply();
}


void
hrchilds's avatar
hrchilds committed
373
QvisLineoutWindow::samplingOnChanged(bool val)
hrchilds's avatar
hrchilds committed
374
{
hrchilds's avatar
hrchilds committed
375 376 377 378 379 380 381 382
    atts->SetSamplingOn(val);
    Apply();
}


void
QvisLineoutWindow::numberOfSamplePointsProcessText()
{
whitlocb's avatar
whitlocb committed
383
    GetCurrentValues(LineoutAttributes::ID_numberOfSamplePoints);
hrchilds's avatar
hrchilds committed
384 385 386 387 388 389 390 391 392 393 394 395
    Apply();
}


void
QvisLineoutWindow::reflineLabelsChanged(bool val)
{
    atts->SetReflineLabels(val);
    Apply();
}