GenerateWindow.h 83 KB
Newer Older
hrchilds's avatar
hrchilds committed
1 2
/*****************************************************************************
*
bonnell's avatar
bonnell committed
3
* Copyright (c) 2000 - 2015, Lawrence Livermore National Security, LLC
hrchilds's avatar
hrchilds committed
4
* Produced at the Lawrence Livermore National Laboratory
brugger's avatar
 
brugger committed
5
* LLNL-CODE-442911
hrchilds's avatar
hrchilds committed
6 7
* All rights reserved.
*
brugger's avatar
 
brugger committed
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
brugger's avatar
 
brugger committed
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
brugger's avatar
 
brugger committed
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
#ifndef GENERATE_WINDOW_H
#define GENERATE_WINDOW_H
hrchilds's avatar
hrchilds committed
41
#include <set>
whitlocb's avatar
whitlocb committed
42
#include <QTextStream>
hrchilds's avatar
hrchilds committed
43
#include "Field.h"
whitlocb's avatar
whitlocb committed
44 45 46
#include "PluginBase.h"

#define GENERATOR_NAME "xml2window"
hrchilds's avatar
hrchilds committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90

// ****************************************************************************
//  File:  GenerateWindow
//
//  Purpose:
//    Contains a set of classes which override the default implementation
//    to create a window.
//
//  Note: This file overrides --
//    FieldFactory
//    Field
//    Attribute
//    Enum
//    Plugin
//
//  Programmer:  Jeremy Meredith
//  Creation:    August 28, 2001
//
//  Modifications:
//    Jeremy Meredith, Mon Sep 24 17:36:08 PDT 2001
//    Added FloatArray.
//
//    Jeremy Meredith, Sat Jan  5 17:33:03 PST 2002
//    Added #include <string> and using std::string to the source file.
//
//    Jeremy Meredith, Fri Apr 19 15:25:46 PDT 2002
//    Added constants, includes, and a codefile.  Made the HasFunction,
//    PrintFunction, DeleteFunction all check to make sure we are trying
//    to override a builtin function.  Removed "enabler".
//
//    Jeremy Meredith, Fri May 31 11:09:58 PDT 2002
//    Renamed CreateWindow to CreateWindowContents.
//    Added classname to the writeSourceCallback and made Enums do the
//    appropriate cast from an int.
//
//    Jeremy Meredith, Fri Jul 12 16:28:28 PDT 2002
//    Some portability improvements.
//
//    Jeremy Meredith, Tue Aug 27 14:32:50 PDT 2002
//    Added mfiles, dbtype, and libs.  Allowed NULL atts.
//
//    Jeremy Meredith, Thu Oct 17 15:58:29 PDT 2002
//    Added some enhancements for the XML editor.
//
hrchilds's avatar
hrchilds committed
91 92 93 94
//    Jeremy Meredith, Tue Sep 23 16:59:03 PDT 2003
//    Added ability for enablers to dis/enable a widget's associated label.
//    Made haswriter be a bool.
//
hrchilds's avatar
hrchilds committed
95 96 97
//    Jeremy Meredith, Wed Nov  5 13:28:03 PST 2003
//    Added ability to disable plugins by default.
//
hrchilds's avatar
hrchilds committed
98 99 100
//    Jeremy Meredith, Tue Jun 15 10:39:32 PDT 2004
//    Added missing blockSignals wrapper in opacity's UpdateWindow.
//
hrchilds's avatar
hrchilds committed
101 102 103
//    Jeremy Meredith, Wed Jul  7 17:08:03 PDT 2004
//    Allow for mdserver-specific code in a plugin's source files.
//
hrchilds's avatar
hrchilds committed
104
//    Kathleen Bonnell, Thu Nov 11 16:56:21 PST 2004 
hrchilds's avatar
hrchilds committed
105 106 107 108 109
//    Added support for ucharVector.
//
//    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
110
//
hrchilds's avatar
hrchilds committed
111 112 113
//    Brad Whitlock, Wed Dec 8 15:56:14 PST 2004
//    Added support for variable names.
//
hrchilds's avatar
hrchilds committed
114 115 116
//    Hank Childs, Tue May 24 09:54:36 PDT 2005
//    Added bool to constructor for hasoptions.
//
hrchilds's avatar
hrchilds committed
117 118 119
//    Hank Childs, Fri Jun  9 09:53:32 PDT 2006
//    Added copyright string.
//
hrchilds's avatar
hrchilds committed
120 121 122 123
//    Brad Whitlock, Tue Feb 13 13:34:11 PST 2007
//    Made it use GetViewerMethods() and made it more aggressive about
//    blocking signals in the Update method.
//
hrchilds's avatar
hrchilds committed
124 125 126 127 128 129
//    Cyrus Harrison, Wed Mar  7 09:54:36 PST 2007
//    Allow for engine-specific code in a plugin's source files.
//
//    Cyrus Harrison, Thu Mar  8 16:20:50 PST 2007
//    Fixed problem with uninitialized labels for bool types.
//
whitlocb's avatar
whitlocb committed
130 131 132
//    Brad Whitlock, Mon Dec 17 11:21:58 PST 2007
//    Made it use new Attribute ids instead of ints.
//
whitlocb's avatar
whitlocb committed
133 134 135
//    Brad Whitlock, Wed Mar 5 11:42:27 PDT 2008
//    Added generatorName.
//
136 137 138
//    Brad Whitlock, Wed Apr  9 12:29:52 PDT 2008
//    Made it generate code that is easier to internationalize.
//
139 140 141
//    Brad Whitlock, Wed Apr 23 13:34:15 PDT 2008
//    Made it use QString::arg for internationalization.
//
142 143 144
//    Jeremy Meredith, Thu Aug  7 14:34:01 EDT 2008
//    Reorder constructor initializers to be the correct order.
//
whitlocb's avatar
whitlocb committed
145 146 147 148
//    Cyrus Harrison, Tue Aug 26 15:40:55 PDT 2008
//    Fix enable case for Enums with QButtonGroup, ensure QButtonGroup has
//    valid parent.
//
149 150 151
//    Dave Pugmire, Tue Feb 24 15:26:46 EST 2009
//    tempcolor wasn't declared as a QColor before it was used.
//
152 153 154 155
//    Dave Pugmire, Wed Sep  5 11:01:33 EDT 2012
//    Enablers produced bad code for checkboxes. There is no label. Added
//    a virtual method, HasLabel() to determine if code should be generated.
//
hrchilds's avatar
hrchilds committed
156 157 158 159
// ****************************************************************************

class WindowGeneratorField : public virtual Field
{
whitlocb's avatar
whitlocb committed
160 161
  protected:
    QString generatorName;
hrchilds's avatar
hrchilds committed
162 163
  public:
    WindowGeneratorField(const QString &t, const QString &n, const QString &l)
whitlocb's avatar
whitlocb committed
164
        : Field(t,n,l), generatorName(GENERATOR_NAME)
hrchilds's avatar
hrchilds committed
165 166 167
    {
    }
    // helper functions
whitlocb's avatar
whitlocb committed
168
    void writeSourceCreateLabel(QTextStream &c)
hrchilds's avatar
hrchilds committed
169
    {
whitlocb's avatar
whitlocb committed
170
        c << "    "<<name<<"Label = new QLabel(tr(\""<<label<<"\"), central);" << endl;
hrchilds's avatar
hrchilds committed
171
        c << "    mainLayout->addWidget("<<name<<"Label,"<<index<<",0);" << endl;
hrchilds's avatar
hrchilds committed
172 173
    }
    // virtual functions
whitlocb's avatar
whitlocb committed
174
    virtual void               writeHeaderCallback(QTextStream &h)
hrchilds's avatar
hrchilds committed
175 176 177
    {
        h << "    //writeHeaderCallback unknown for " << type << " (variable " << name << ")" << endl;
    }
whitlocb's avatar
whitlocb committed
178
    virtual void               writeHeaderLabelData(QTextStream &h)
hrchilds's avatar
hrchilds committed
179 180 181
    {
        h << "    QLabel *"<<name<<"Label;" << endl;
    }
whitlocb's avatar
whitlocb committed
182
    virtual void               writeHeaderData(QTextStream &h)
hrchilds's avatar
hrchilds committed
183 184 185
    {
        h << "    //writeHeaderData unknown for " << type << " (variable " << name << ")" << endl;
    }
whitlocb's avatar
whitlocb committed
186
    virtual void               writeSourceCreate(QTextStream &c)
hrchilds's avatar
hrchilds committed
187 188 189
    {
        c << "    //writeSourceCreate unknown for " << type << " (variable " << name << ")" << endl;
    }
whitlocb's avatar
whitlocb committed
190
    virtual bool               providesSourceGetCurrent() const { return false; }
whitlocb's avatar
whitlocb committed
191
    virtual void               writeSourceGetCurrent(QTextStream &c)
hrchilds's avatar
hrchilds committed
192 193 194
    {
        c << "        //writeSourceGetCurrent unknown for " << type << " (variable " << name << ")" << endl;
    }
whitlocb's avatar
whitlocb committed
195
    virtual void               writeSourceUpdateWindow(QTextStream &c)
hrchilds's avatar
hrchilds committed
196 197 198
    {
        c << "        //writeSourceUpdate unknown for " << type << " (variable " << name << ")" << endl;
    }
whitlocb's avatar
whitlocb committed
199
    virtual void               writeSourceCallback(QString &classname, QString &windowname, QTextStream &c, bool isEnabler)
hrchilds's avatar
hrchilds committed
200 201 202 203 204 205 206 207 208 209 210 211
    {
        c << "//writeSourceCallback unknown for " << type << " (variable " << name << ")" << endl;
    }
};

//
// ------------------------------------ Int -----------------------------------
//
class WindowGeneratorInt : public virtual Int , public virtual WindowGeneratorField
{
  public:
    WindowGeneratorInt(const QString &n, const QString &l)
212
        : Field("int",n,l), Int(n,l), WindowGeneratorField("int",n,l) { }
whitlocb's avatar
whitlocb committed
213
    virtual void            writeHeaderCallback(QTextStream &h)
hrchilds's avatar
hrchilds committed
214 215 216 217 218 219
    {
        if (rangeSet)
            h << "    void "<<name<<"Changed(int val);" << endl;
        else
            h << "    void "<<name<<"ProcessText();" << endl;
    }
whitlocb's avatar
whitlocb committed
220
    virtual void            writeHeaderData(QTextStream &h)
hrchilds's avatar
hrchilds committed
221 222 223 224 225 226
    {
        if (rangeSet)
            h << "    QSpinBox *"<<name<<";" << endl;
        else
            h << "    QLineEdit *"<<name<<";" << endl;
    }
whitlocb's avatar
whitlocb committed
227
    virtual void            writeSourceCreate(QTextStream &c)
hrchilds's avatar
hrchilds committed
228 229 230 231
    {
        writeSourceCreateLabel(c);
        if (rangeSet)
        {
whitlocb's avatar
whitlocb committed
232 233 234
            c << "    "<<name<<" = new QSpinBox(central);" << endl;
            c << "    "<<name<<"->setMinimum("<<min<<");"<<endl;
            c << "    "<<name<<"->setMaximum("<<max<<");"<<endl;
hrchilds's avatar
hrchilds committed
235 236 237 238 239
            c << "    connect("<<name<<", SIGNAL(valueChanged(int)), " << endl
              << "            this, SLOT("<<name<<"Changed(int)));" << endl;
        }
        else
        {
whitlocb's avatar
whitlocb committed
240
            c << "    "<<name<<" = new QLineEdit(central);" << endl;
hrchilds's avatar
hrchilds committed
241 242 243 244 245
            c << "    connect("<<name<<", SIGNAL(returnPressed())," << endl
              << "            this, SLOT("<<name<<"ProcessText()));" << endl;
        }
        c << "    mainLayout->addWidget("<<name<<", "<<index<<",1);" << endl;
    }
whitlocb's avatar
whitlocb committed
246
    virtual bool            providesSourceGetCurrent() const { return !rangeSet; }
whitlocb's avatar
whitlocb committed
247
    virtual void            writeSourceGetCurrent(QTextStream &c)
hrchilds's avatar
hrchilds committed
248 249 250 251 252 253 254
    {
        if (rangeSet)
        {
            c << "        // Nothing for " << name << endl;
        }
        else
        {
whitlocb's avatar
whitlocb committed
255 256 257 258
            c << "        int val;" << endl;
            c << "        if(LineEditGetInt("<<name<<", val))" << endl;
            c << "            atts->Set"<<Name<<"(val);" << endl;
            c << "        else" << endl;
hrchilds's avatar
hrchilds committed
259
            c << "        {" << endl;
whitlocb's avatar
whitlocb committed
260 261 262
            QString msgLabel = (label.length()>0) ? label : name;
            c << "            ResettingError(tr(\""<<msgLabel<<"\")," << endl;
            c << "                IntToQString(atts->Get"<<Name<<"()));" << endl;
hrchilds's avatar
hrchilds committed
263 264 265 266
            c << "            atts->Set"<<Name<<"(atts->Get"<<Name<<"());" << endl;
            c << "        }" << endl;
        }
    }
whitlocb's avatar
whitlocb committed
267
    virtual void            writeSourceUpdateWindow(QTextStream &c)
hrchilds's avatar
hrchilds committed
268 269 270
    {
        if (rangeSet)
        {
hrchilds's avatar
hrchilds committed
271
            c << "            "<<name<<"->blockSignals(true);" << endl;
hrchilds's avatar
hrchilds committed
272
            c << "            "<<name<<"->setValue(atts->Get"<<Name<<"());" << endl;
hrchilds's avatar
hrchilds committed
273
            c << "            "<<name<<"->blockSignals(false);" << endl;
hrchilds's avatar
hrchilds committed
274 275 276
        }
        else
        {
whitlocb's avatar
whitlocb committed
277
            c << "            "<<name<<"->setText(IntToQString(atts->Get"<<Name<<"()));" << endl;
hrchilds's avatar
hrchilds committed
278 279
        }
    }
whitlocb's avatar
whitlocb committed
280
    virtual void            writeSourceCallback(QString &classname, QString &windowname, QTextStream &c, bool isEnabler)
hrchilds's avatar
hrchilds committed
281 282 283 284 285 286 287
    {
        if (rangeSet)
        {
            c << "void" << endl;
            c << windowname<<"::"<<name<<"Changed(int val)" << endl;
            c << "{" << endl;
            c << "    atts->Set"<<Name<<"(val);" << endl;
hrchilds's avatar
hrchilds committed
288 289
            if(!isEnabler)
                c << "    SetUpdate(false);" << endl;
hrchilds's avatar
hrchilds committed
290 291 292 293 294 295 296 297
            c << "    Apply();" << endl;
            c << "}" << endl;
        }
        else
        {
            c << "void" << endl;
            c << windowname<<"::"<<name<<"ProcessText()" << endl;
            c << "{" << endl;
298
            c << "    GetCurrentValues("<<classname << "::ID_" << name<<");" << endl;
hrchilds's avatar
hrchilds committed
299 300 301 302 303 304 305 306 307 308 309 310 311 312
            c << "    Apply();" << endl;
            c << "}" << endl;
        }
    }
};


//
// ---------------------------------- IntArray --------------------------------
//
class WindowGeneratorIntArray : public virtual IntArray , public virtual WindowGeneratorField
{
  public:
    WindowGeneratorIntArray(const QString &s, const QString &n, const QString &l)
313
        : Field("intArray",n,l), IntArray(s,n,l), WindowGeneratorField("intArray",n,l) { }
whitlocb's avatar
whitlocb committed
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
    virtual void            writeHeaderCallback(QTextStream &h)
    {
        h << "    void "<<name<<"ProcessText();" << endl;
    }
    virtual void            writeHeaderData(QTextStream &h)
    {
        h << "    QLineEdit *"<<name<<";" << endl;
    }
    virtual void            writeSourceCreate(QTextStream &c)
    {
        writeSourceCreateLabel(c);
        c << "    "<<name<<" = new QLineEdit(central);" << endl;
        c << "    connect("<<name<<", SIGNAL(returnPressed())," << endl
          << "            this, SLOT("<<name<<"ProcessText()));" << endl;        
        c << "    mainLayout->addWidget("<<name<<", "<<index<<",1);" << endl;
    }
    virtual bool            providesSourceGetCurrent() const { return true; }
    virtual void            writeSourceGetCurrent(QTextStream &c)
    {
        c << "        int val[" << length << "];" << endl;
        c << "        if(LineEditGetInts("<<name<<", val, " << length << "))" << endl;
        c << "            atts->Set"<<Name<<"(val);" << endl;
        c << "        else" << endl;
        c << "        {" << endl;
        QString msgLabel = (label.length()>0) ? label : name;
        c << "            ResettingError(tr(\""<<msgLabel<<"\")," << endl;
        c << "                IntsToQString(atts->Get"<<Name<<"(), "<<length<<"));" << endl;
        c << "            atts->Set"<<Name<<"(atts->Get"<<Name<<"());" << endl;
        c << "        }" << endl;
    }
    virtual void            writeSourceUpdateWindow(QTextStream &c)
    {
        c << "            "<<name<<"->setText(IntsToQString(atts->Get"<<Name<<"(),"<<length<<"));" << endl;
    }
    virtual void            writeSourceCallback(QString &classname, QString &windowname, QTextStream &c, bool isEnabler)
    {
        c << "void" << endl;
        c << windowname<<"::"<<name<<"ProcessText()" << endl;
        c << "{" << endl;
        c << "    GetCurrentValues("<<classname << "::ID_" << name<<");" << endl;
        c << "    Apply();" << endl;
        c << "}" << endl;
    }
hrchilds's avatar
hrchilds committed
357 358 359 360 361 362 363 364 365 366
};


//
// --------------------------------- IntVector --------------------------------
//
class WindowGeneratorIntVector : public virtual IntVector , public virtual WindowGeneratorField
{
  public:
    WindowGeneratorIntVector(const QString &n, const QString &l)
367
        : Field("intVector",n,l), IntVector(n,l), WindowGeneratorField("intVector",n,l) { }
whitlocb's avatar
whitlocb committed
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410
    virtual void            writeHeaderCallback(QTextStream &h)
    {
        h << "    void "<<name<<"ProcessText();" << endl;
    }
    virtual void            writeHeaderData(QTextStream &h)
    {
        h << "    QLineEdit *"<<name<<";" << endl;
    }
    virtual void            writeSourceCreate(QTextStream &c)
    {
        writeSourceCreateLabel(c);
        c << "    "<<name<<" = new QLineEdit(central);" << endl;
        c << "    connect("<<name<<", SIGNAL(returnPressed())," << endl
          << "            this, SLOT("<<name<<"ProcessText()));" << endl;        
        c << "    mainLayout->addWidget("<<name<<", "<<index<<",1);" << endl;
    }
    virtual bool            providesSourceGetCurrent() const { return true; }
    virtual void            writeSourceGetCurrent(QTextStream &c)
    {
        c << "        intVector val;" << endl;
        c << "        if(LineEditGetInts("<<name<<", val))" << endl;
        c << "            atts->Set"<<Name<<"(val);" << endl;
        c << "        else" << endl;
        c << "        {" << endl;
        QString msgLabel = (label.length()>0) ? label : name;
        c << "            ResettingError(tr(\""<<msgLabel<<"\")," << endl;
        c << "                IntsToQString(atts->Get"<<Name<<"()));" << endl;
        c << "            atts->Set"<<Name<<"(atts->Get"<<Name<<"());" << endl;
        c << "        }" << endl;
    }
    virtual void            writeSourceUpdateWindow(QTextStream &c)
    {
        c << "            "<<name<<"->setText(IntsToQString(atts->Get"<<Name<<"()));" << endl;
    }
    virtual void            writeSourceCallback(QString &classname, QString &windowname, QTextStream &c, bool isEnabler)
    {
        c << "void" << endl;
        c << windowname<<"::"<<name<<"ProcessText()" << endl;
        c << "{" << endl;
        c << "    GetCurrentValues("<<classname << "::ID_" << name<<");" << endl;
        c << "    Apply();" << endl;
        c << "}" << endl;
    }
hrchilds's avatar
hrchilds committed
411 412 413 414 415 416 417 418 419 420
};


// 
// ----------------------------------- Bool -----------------------------------
//
class WindowGeneratorBool : public virtual Bool , public virtual WindowGeneratorField
{
  public:
    WindowGeneratorBool(const QString &n, const QString &l)
421
        : Field("bool",n,l), Bool(n,l), WindowGeneratorField("bool",n,l) { }
422
    virtual bool            HasLabel() {return false;}
whitlocb's avatar
whitlocb committed
423
    virtual void            writeHeaderCallback(QTextStream &h)
hrchilds's avatar
hrchilds committed
424 425 426
    {
        h << "    void "<<name<<"Changed(bool val);" << endl;
    }
whitlocb's avatar
whitlocb committed
427
    virtual void            writeHeaderData(QTextStream &h)
hrchilds's avatar
hrchilds committed
428 429 430
    {
        h << "    QCheckBox *"<<name<<";" << endl;
    }
whitlocb's avatar
whitlocb committed
431
    virtual void            writeSourceCreate(QTextStream &c)
hrchilds's avatar
hrchilds committed
432
    {
whitlocb's avatar
whitlocb committed
433
        c << "    "<<name<<" = new QCheckBox(tr(\""<<label<<"\"), central);" << endl;
hrchilds's avatar
hrchilds committed
434 435 436 437
        c << "    connect("<<name<<", SIGNAL(toggled(bool))," << endl
          << "            this, SLOT("<<name<<"Changed(bool)));" << endl;
        c << "    mainLayout->addWidget("<<name<<", "<<index<<",0);" << endl;
    }
whitlocb's avatar
whitlocb committed
438
    virtual void            writeHeaderLabelData(QTextStream &h)
whitlocb's avatar
whitlocb committed
439 440
    {
    }
whitlocb's avatar
whitlocb committed
441
    virtual void            writeSourceGetCurrent(QTextStream &c)
hrchilds's avatar
hrchilds committed
442 443 444
    {
        c << "        // Nothing for " << name << endl;
    }
whitlocb's avatar
whitlocb committed
445
    virtual void            writeSourceUpdateWindow(QTextStream &c)
hrchilds's avatar
hrchilds committed
446
    {
hrchilds's avatar
hrchilds committed
447
        c << "            "<<name<<"->blockSignals(true);" << endl;
hrchilds's avatar
hrchilds committed
448
        c << "            "<<name<<"->setChecked(atts->Get"<<Name<<"());" << endl;
hrchilds's avatar
hrchilds committed
449
        c << "            "<<name<<"->blockSignals(false);" << endl;
hrchilds's avatar
hrchilds committed
450
    }
whitlocb's avatar
whitlocb committed
451
    virtual void            writeSourceCallback(QString &, QString &windowname, QTextStream &c, bool isEnabler)
hrchilds's avatar
hrchilds committed
452 453 454 455 456
    {
        c << "void" << endl;
        c << windowname<<"::"<<name<<"Changed(bool val)" << endl;
        c << "{" << endl;
        c << "    atts->Set"<<Name<<"(val);" << endl;
hrchilds's avatar
hrchilds committed
457 458
        if(!isEnabler)
            c << "    SetUpdate(false);" << endl;
hrchilds's avatar
hrchilds committed
459 460 461 462 463 464 465 466 467 468 469 470 471
        c << "    Apply();" << endl;
        c << "}" << endl;
    }
};


//
// ----------------------------------- Float ----------------------------------
//
class WindowGeneratorFloat : public virtual Float , public virtual WindowGeneratorField
{
  public:
    WindowGeneratorFloat(const QString &n, const QString &l)
472
        : Field("float",n,l), Float(n,l), WindowGeneratorField("float",n,l) { }
whitlocb's avatar
whitlocb committed
473
    virtual void            writeHeaderCallback(QTextStream &h)
hrchilds's avatar
hrchilds committed
474 475 476
    {
        h << "    void "<<name<<"ProcessText();" << endl;
    }
whitlocb's avatar
whitlocb committed
477
    virtual void            writeHeaderData(QTextStream &h)
hrchilds's avatar
hrchilds committed
478 479 480
    {
        h << "    QLineEdit *"<<name<<";" << endl;
    }
whitlocb's avatar
whitlocb committed
481
    virtual void            writeSourceCreate(QTextStream &c)
hrchilds's avatar
hrchilds committed
482 483
    {
        writeSourceCreateLabel(c);
whitlocb's avatar
whitlocb committed
484
        c << "    "<<name<<" = new QLineEdit(central);" << endl;
hrchilds's avatar
hrchilds committed
485 486 487 488
        c << "    connect("<<name<<", SIGNAL(returnPressed())," << endl
          << "            this, SLOT("<<name<<"ProcessText()));" << endl;
        c << "    mainLayout->addWidget("<<name<<", "<<index<<",1);" << endl;
    }
whitlocb's avatar
whitlocb committed
489
    virtual bool            providesSourceGetCurrent() const { return true; }
whitlocb's avatar
whitlocb committed
490
    virtual void            writeSourceGetCurrent(QTextStream &c)
hrchilds's avatar
hrchilds committed
491
    {
whitlocb's avatar
whitlocb committed
492 493 494 495
        c << "        float val;" << endl;
        c << "        if(LineEditGetFloat("<<name<<", val))" <<endl;
        c << "            atts->Set"<<Name<<"(val);" << endl;
        c << "        else" << endl;
hrchilds's avatar
hrchilds committed
496
        c << "        {" << endl;
whitlocb's avatar
whitlocb committed
497 498 499
        QString msgLabel = (label.length()>0) ? label : name;
        c << "            ResettingError(tr(\""<<msgLabel<<"\")," << endl;
        c << "                FloatToQString(atts->Get"<<Name<<"()));" << endl;
hrchilds's avatar
hrchilds committed
500 501 502
        c << "            atts->Set"<<Name<<"(atts->Get"<<Name<<"());" << endl;
        c << "        }" << endl;
    }
whitlocb's avatar
whitlocb committed
503
    virtual void            writeSourceUpdateWindow(QTextStream &c)
hrchilds's avatar
hrchilds committed
504
    {
whitlocb's avatar
whitlocb committed
505
        c << "            "<<name<<"->setText(FloatToQString(atts->Get"<<Name<<"()));" << endl;
hrchilds's avatar
hrchilds committed
506
    }
whitlocb's avatar
whitlocb committed
507
    virtual void            writeSourceCallback(QString &classname, QString &windowname, QTextStream &c, bool isEnabler)
hrchilds's avatar
hrchilds committed
508 509 510 511
    {
        c << "void" << endl;
        c << windowname<<"::"<<name<<"ProcessText()" << endl;
        c << "{" << endl;
whitlocb's avatar
whitlocb committed
512
        c << "    GetCurrentValues("<<classname << "::ID_" << name<<");" << endl;
hrchilds's avatar
hrchilds committed
513 514 515 516 517 518 519 520 521 522 523 524 525
        c << "    Apply();" << endl;
        c << "}" << endl;
    }
};


//
// -------------------------------- FloatArray -------------------------------
//
class WindowGeneratorFloatArray : public virtual FloatArray , public virtual WindowGeneratorField
{
  public:
    WindowGeneratorFloatArray(const QString &s, const QString &n, const QString &l)
526
        : Field("floatArray",n,l), FloatArray(s,n,l), WindowGeneratorField("floatArray",n,l) { }
whitlocb's avatar
whitlocb committed
527
    virtual void               writeHeaderCallback(QTextStream &h)
hrchilds's avatar
hrchilds committed
528 529 530
    {
        h << "    void "<<name<<"ProcessText();" << endl;
    }
whitlocb's avatar
whitlocb committed
531
    virtual void               writeHeaderData(QTextStream &h)
hrchilds's avatar
hrchilds committed
532 533 534
    {
        h << "    QLineEdit *"<<name<<";" << endl;
    }
whitlocb's avatar
whitlocb committed
535
    virtual void               writeSourceCreate(QTextStream &c)
hrchilds's avatar
hrchilds committed
536 537
    {
        writeSourceCreateLabel(c);
whitlocb's avatar
whitlocb committed
538
        c << "    "<<name<<" = new QLineEdit(central);" << endl;
hrchilds's avatar
hrchilds committed
539 540 541 542
        c << "    connect("<<name<<", SIGNAL(returnPressed())," << endl
          << "            this, SLOT("<<name<<"ProcessText()));" << endl;
        c << "    mainLayout->addWidget("<<name<<", "<<index<<",1);" << endl;
    }
whitlocb's avatar
whitlocb committed
543
    virtual bool               providesSourceGetCurrent() const { return true; }
whitlocb's avatar
whitlocb committed
544
    virtual void               writeSourceGetCurrent(QTextStream &c)
hrchilds's avatar
hrchilds committed
545
    {
whitlocb's avatar
whitlocb committed
546 547 548 549
        c << "        float val["<<length<<"];"<<endl;
        c << "        if(LineEditGetFloats("<<name<<", val, " <<length<<"))" <<endl;
        c << "            atts->Set"<<Name<<"(val);" << endl;
        c << "        else" << endl;
hrchilds's avatar
hrchilds committed
550
        c << "        {" << endl;
whitlocb's avatar
whitlocb committed
551 552 553
        QString msgLabel = (label.length()>0) ? label : name;
        c << "            ResettingError(tr(\""<<msgLabel<<"\")," << endl;
        c << "                FloatsToQString(atts->Get"<<Name<<"()," << length <<"));" << endl;
hrchilds's avatar
hrchilds committed
554 555 556
        c << "            atts->Set"<<Name<<"(atts->Get"<<Name<<"());" << endl;
        c << "        }" << endl;
    }
whitlocb's avatar
whitlocb committed
557
    virtual void               writeSourceUpdateWindow(QTextStream &c)
hrchilds's avatar
hrchilds committed
558
    {
whitlocb's avatar
whitlocb committed
559
        c << "            "<<name<<"->setText(FloatsToQString(atts->Get"<<Name<<"(), "<<length<<");" << endl;
hrchilds's avatar
hrchilds committed
560
    }
whitlocb's avatar
whitlocb committed
561
    virtual void               writeSourceCallback(QString &classname, QString &windowname, QTextStream &c, bool isEnabler)
hrchilds's avatar
hrchilds committed
562 563 564 565
    {
        c << "void" << endl;
        c << windowname<<"::"<<name<<"ProcessText()" << endl;
        c << "{" << endl;
whitlocb's avatar
whitlocb committed
566
        c << "    GetCurrentValues("<<classname << "::ID_" << name<<");" << endl;
hrchilds's avatar
hrchilds committed
567 568 569 570 571 572
        c << "    Apply();" << endl;
        c << "}" << endl;
    }
};


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
//
// -------------------------------- FloatVector ------------------------------
//
class WindowGeneratorFloatVector : public virtual FloatVector , public virtual WindowGeneratorField
{
  public:
    WindowGeneratorFloatVector(const QString &n, const QString &l)
        : Field("floatVector",n,l), FloatVector(n,l), WindowGeneratorField("floatVector",n,l) { }
    virtual void               writeHeaderCallback(QTextStream &h)
    {
        h << "    void "<<name<<"ProcessText();" << endl;
    }
    virtual void               writeHeaderData(QTextStream &h)
    {
        h << "    QLineEdit *"<<name<<";" << endl;
    }
    virtual void               writeSourceCreate(QTextStream &c)
    {
        writeSourceCreateLabel(c);
        c << "    "<<name<<" = new QLineEdit(central);" << endl;
        c << "    connect("<<name<<", SIGNAL(returnPressed())," << endl
          << "            this, SLOT("<<name<<"ProcessText()));" << endl;
        c << "    mainLayout->addWidget("<<name<<", "<<index<<",1);" << endl;
    }
    virtual bool               providesSourceGetCurrent() const { return true; }
    virtual void               writeSourceGetCurrent(QTextStream &c)
    {
        c << "        floatVector val;"<<endl;
        c << "        if(LineEditGetFloats("<<name<<", val))" <<endl;
        c << "            atts->Set"<<Name<<"(val);" << endl;
        c << "        else" << endl;
        c << "        {" << endl;
        QString msgLabel = (label.length()>0) ? label : name;
        c << "            ResettingError(tr(\""<<msgLabel<<"\")," << endl;
        c << "                FloatsToQString(atts->Get"<<Name<<"()));" << endl;
        c << "            atts->Set"<<Name<<"(atts->Get"<<Name<<"());" << endl;
        c << "        }" << endl;
    }
    virtual void               writeSourceUpdateWindow(QTextStream &c)
    {
        c << "            "<<name<<"->setText(FloatsToQString(atts->Get"<<Name<<"()));" << endl;
    }
    virtual void               writeSourceCallback(QString &classname, QString &windowname, QTextStream &c, bool isEnabler)
    {
        c << "void" << endl;
        c << windowname<<"::"<<name<<"ProcessText()" << endl;
        c << "{" << endl;
        c << "    GetCurrentValues("<<classname << "::ID_" << name<<");" << endl;
        c << "    Apply();" << endl;
        c << "}" << endl;
    }
};

hrchilds's avatar
hrchilds committed
626 627 628 629 630 631 632
//
// ---------------------------------- Double ----------------------------------
//
class WindowGeneratorDouble : public virtual Double , public virtual WindowGeneratorField
{
  public:
    WindowGeneratorDouble(const QString &n, const QString &l)
633
        : Field("double",n,l), Double(n,l), WindowGeneratorField("double",n,l) { }
whitlocb's avatar
whitlocb committed
634
    virtual void            writeHeaderCallback(QTextStream &h)
hrchilds's avatar
hrchilds committed
635 636 637
    {
        h << "    void "<<name<<"ProcessText();" << endl;
    }
whitlocb's avatar
whitlocb committed
638
    virtual void            writeHeaderData(QTextStream &h)
hrchilds's avatar
hrchilds committed
639 640 641
    {
        h << "    QLineEdit *"<<name<<";" << endl;
    }
whitlocb's avatar
whitlocb committed
642
    virtual void            writeSourceCreate(QTextStream &c)
hrchilds's avatar
hrchilds committed
643 644
    {
        writeSourceCreateLabel(c);
whitlocb's avatar
whitlocb committed
645
        c << "    "<<name<<" = new QLineEdit(central);" << endl;
hrchilds's avatar
hrchilds committed
646 647 648 649
        c << "    connect("<<name<<", SIGNAL(returnPressed())," << endl
          << "            this, SLOT("<<name<<"ProcessText()));" << endl;
        c << "    mainLayout->addWidget("<<name<<", "<<index<<",1);" << endl;
    }
whitlocb's avatar
whitlocb committed
650
    virtual bool            providesSourceGetCurrent() const { return true; }
whitlocb's avatar
whitlocb committed
651
    virtual void            writeSourceGetCurrent(QTextStream &c)
hrchilds's avatar
hrchilds committed
652
    {
whitlocb's avatar
whitlocb committed
653 654 655 656
        c << "        double val;" << endl;
        c << "        if(LineEditGetDouble("<<name<<", val))" <<endl;
        c << "            atts->Set"<<Name<<"(val);" << endl;
        c << "        else" << endl;
hrchilds's avatar
hrchilds committed
657
        c << "        {" << endl;
whitlocb's avatar
whitlocb committed
658 659 660
        QString msgLabel = (label.length()>0) ? label : name;
        c << "            ResettingError(tr(\""<<msgLabel<<"\")," << endl;
        c << "                DoubleToQString(atts->Get"<<Name<<"()));" << endl;
hrchilds's avatar
hrchilds committed
661 662 663
        c << "            atts->Set"<<Name<<"(atts->Get"<<Name<<"());" << endl;
        c << "        }" << endl;
    }
whitlocb's avatar
whitlocb committed
664
    virtual void            writeSourceUpdateWindow(QTextStream &c)
hrchilds's avatar
hrchilds committed
665
    {
whitlocb's avatar
whitlocb committed
666
        c << "            "<<name<<"->setText(DoubleToQString(atts->Get"<<Name<<"()));" << endl;
hrchilds's avatar
hrchilds committed
667
    }
whitlocb's avatar
whitlocb committed
668
    virtual void            writeSourceCallback(QString &classname, QString &windowname, QTextStream &c, bool isEnabler)
hrchilds's avatar
hrchilds committed
669 670 671 672
    {
        c << "void" << endl;
        c << windowname<<"::"<<name<<"ProcessText()" << endl;
        c << "{" << endl;
whitlocb's avatar
whitlocb committed
673
        c << "    GetCurrentValues("<<classname << "::ID_" << name<<");" << endl;
hrchilds's avatar
hrchilds committed
674 675 676 677 678 679 680 681 682 683 684 685 686
        c << "    Apply();" << endl;
        c << "}" << endl;
    }
};


//
// -------------------------------- DoubleArray -------------------------------
//
class WindowGeneratorDoubleArray : public virtual DoubleArray , public virtual WindowGeneratorField
{
  public:
    WindowGeneratorDoubleArray(const QString &s, const QString &n, const QString &l)
687
        : Field("doubleArray",n,l), DoubleArray(s,n,l), WindowGeneratorField("doubleArray",n,l) { }
whitlocb's avatar
whitlocb committed
688
    virtual void               writeHeaderCallback(QTextStream &h)
hrchilds's avatar
hrchilds committed
689 690 691
    {
        h << "    void "<<name<<"ProcessText();" << endl;
    }
whitlocb's avatar
whitlocb committed
692
    virtual void               writeHeaderData(QTextStream &h)
hrchilds's avatar
hrchilds committed
693 694 695
    {
        h << "    QLineEdit *"<<name<<";" << endl;
    }
whitlocb's avatar
whitlocb committed
696
    virtual void               writeSourceCreate(QTextStream &c)
hrchilds's avatar
hrchilds committed
697 698
    {
        writeSourceCreateLabel(c);
whitlocb's avatar
whitlocb committed
699
        c << "    "<<name<<" = new QLineEdit(central);" << endl;
hrchilds's avatar
hrchilds committed
700 701 702 703
        c << "    connect("<<name<<", SIGNAL(returnPressed())," << endl
          << "            this, SLOT("<<name<<"ProcessText()));" << endl;
        c << "    mainLayout->addWidget("<<name<<", "<<index<<",1);" << endl;
    }
whitlocb's avatar
whitlocb committed
704
    virtual bool               providesSourceGetCurrent() const { return true; }
whitlocb's avatar
whitlocb committed
705
    virtual void               writeSourceGetCurrent(QTextStream &c)
hrchilds's avatar
hrchilds committed
706
    {
whitlocb's avatar
whitlocb committed
707 708 709 710
        c << "        double val["<<length<<"];"<<endl;
        c << "        if(LineEditGetDoubles("<<name<<", val, " <<length<<"))" <<endl;
        c << "            atts->Set"<<Name<<"(val);" << endl;
        c << "        else" << endl;
hrchilds's avatar
hrchilds committed
711
        c << "        {" << endl;
whitlocb's avatar
whitlocb committed
712 713 714
        QString msgLabel = (label.length()>0) ? label : name;
        c << "            ResettingError(tr(\""<<msgLabel<<"\")," << endl;
        c << "                DoublesToQString(atts->Get"<<Name<<"()," << length <<"));" << endl;
hrchilds's avatar
hrchilds committed
715 716 717
        c << "            atts->Set"<<Name<<"(atts->Get"<<Name<<"());" << endl;
        c << "        }" << endl;
    }
whitlocb's avatar
whitlocb committed
718
    virtual void               writeSourceUpdateWindow(QTextStream &c)
hrchilds's avatar
hrchilds committed
719
    {
whitlocb's avatar
whitlocb committed
720
        c << "            "<<name<<"->setText(DoublesToQString(atts->Get"<<Name<<"(), "<<length<<"));" << endl;
hrchilds's avatar
hrchilds committed
721
    }
whitlocb's avatar
whitlocb committed
722
    virtual void               writeSourceCallback(QString &classname, QString &windowname, QTextStream &c, bool isEnabler)
hrchilds's avatar
hrchilds committed
723 724 725 726
    {
        c << "void" << endl;
        c << windowname<<"::"<<name<<"ProcessText()" << endl;
        c << "{" << endl;
whitlocb's avatar
whitlocb committed
727
        c << "    GetCurrentValues("<<classname << "::ID_" << name<<");" << endl;
hrchilds's avatar
hrchilds committed
728 729 730 731 732 733 734 735 736 737 738 739 740
        c << "    Apply();" << endl;
        c << "}" << endl;
    }
};


//
// -------------------------------- DoubleVector ------------------------------
//
class WindowGeneratorDoubleVector : public virtual DoubleVector , public virtual WindowGeneratorField
{
  public:
    WindowGeneratorDoubleVector(const QString &n, const QString &l)
741
        : Field("doubleVector",n,l), DoubleVector(n,l), WindowGeneratorField("doubleVector",n,l) { }
whitlocb's avatar
whitlocb committed
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784
    virtual void               writeHeaderCallback(QTextStream &h)
    {
        h << "    void "<<name<<"ProcessText();" << endl;
    }
    virtual void               writeHeaderData(QTextStream &h)
    {
        h << "    QLineEdit *"<<name<<";" << endl;
    }
    virtual void               writeSourceCreate(QTextStream &c)
    {
        writeSourceCreateLabel(c);
        c << "    "<<name<<" = new QLineEdit(central);" << endl;
        c << "    connect("<<name<<", SIGNAL(returnPressed())," << endl
          << "            this, SLOT("<<name<<"ProcessText()));" << endl;
        c << "    mainLayout->addWidget("<<name<<", "<<index<<",1);" << endl;
    }
    virtual bool               providesSourceGetCurrent() const { return true; }
    virtual void               writeSourceGetCurrent(QTextStream &c)
    {
        c << "        doubleVector val;"<<endl;
        c << "        if(LineEditGetDoubles("<<name<<", val))" <<endl;
        c << "            atts->Set"<<Name<<"(val);" << endl;
        c << "        else" << endl;
        c << "        {" << endl;
        QString msgLabel = (label.length()>0) ? label : name;
        c << "            ResettingError(tr(\""<<msgLabel<<"\")," << endl;
        c << "                DoublesToQString(atts->Get"<<Name<<"()));" << endl;
        c << "            atts->Set"<<Name<<"(atts->Get"<<Name<<"());" << endl;
        c << "        }" << endl;
    }
    virtual void               writeSourceUpdateWindow(QTextStream &c)
    {
        c << "            "<<name<<"->setText(DoublesToQString(atts->Get"<<Name<<"()));" << endl;
    }
    virtual void               writeSourceCallback(QString &classname, QString &windowname, QTextStream &c, bool isEnabler)
    {
        c << "void" << endl;
        c << windowname<<"::"<<name<<"ProcessText()" << endl;
        c << "{" << endl;
        c << "    GetCurrentValues("<<classname << "::ID_" << name<<");" << endl;
        c << "    Apply();" << endl;
        c << "}" << endl;
    }
hrchilds's avatar
hrchilds committed
785 786 787 788 789 790 791 792 793 794
};


//
// ----------------------------------- UChar ----------------------------------
//
class WindowGeneratorUChar : public virtual UChar , public virtual WindowGeneratorField
{
  public:
    WindowGeneratorUChar(const QString &n, const QString &l)
795
        : Field("uchar",n,l), UChar(n,l), WindowGeneratorField("uchar",n,l) { }
hrchilds's avatar
hrchilds committed
796 797 798 799 800 801 802 803 804 805
};


//
// -------------------------------- UCharArray --------------------------------
//
class WindowGeneratorUCharArray : public virtual UCharArray , public virtual WindowGeneratorField
{
  public:
    WindowGeneratorUCharArray(const QString &s, const QString &n, const QString &l)
806
        : Field("ucharArray",n,l), UCharArray(s,n,l), WindowGeneratorField("ucharArray",n,l) { }
hrchilds's avatar
hrchilds committed
807 808
};

hrchilds's avatar
hrchilds committed
809 810 811 812 813 814 815
//
// -------------------------------- UCharVector --------------------------------
//
class WindowGeneratorUCharVector : public virtual UCharVector , public virtual WindowGeneratorField
{
  public:
    WindowGeneratorUCharVector(const QString &n, const QString &l)
816
        : Field("ucharVector",n,l), UCharVector(n,l), WindowGeneratorField("ucharVector",n,l) { }
hrchilds's avatar
hrchilds committed
817 818
};

hrchilds's avatar
hrchilds committed
819 820 821 822 823 824 825 826

//
// ---------------------------------- String ----------------------------------
//
class WindowGeneratorString : public virtual String , public virtual WindowGeneratorField
{
  public:
    WindowGeneratorString(const QString &n, const QString &l)
827
        : Field("string",n,l), String(n,l), WindowGeneratorField("string",n,l) { }
whitlocb's avatar
whitlocb committed
828
    virtual void            writeHeaderCallback(QTextStream &h)
hrchilds's avatar
hrchilds committed
829 830 831
    {
        h << "    void "<<name<<"ProcessText();" << endl;
    }
whitlocb's avatar
whitlocb committed
832
    virtual void            writeHeaderData(QTextStream &h)
hrchilds's avatar
hrchilds committed
833 834 835
    {
        h << "    QLineEdit *"<<name<<";" << endl;
    }
whitlocb's avatar
whitlocb committed
836
    virtual void            writeSourceCreate(QTextStream &c)
hrchilds's avatar
hrchilds committed
837 838
    {
        writeSourceCreateLabel(c);
whitlocb's avatar
whitlocb committed
839
        c << "    "<<name<<" = new QLineEdit(central);" << endl;
hrchilds's avatar
hrchilds committed
840 841 842 843
        c << "    connect("<<name<<", SIGNAL(returnPressed())," << endl
          << "            this, SLOT("<<name<<"ProcessText()));" << endl;
        c << "    mainLayout->addWidget("<<name<<", "<<index<<",1);" << endl;
    }
whitlocb's avatar
whitlocb committed
844
    virtual bool            providesSourceGetCurrent() const { return true; }
whitlocb's avatar
whitlocb committed
845
    virtual void            writeSourceGetCurrent(QTextStream &c)
hrchilds's avatar
hrchilds committed
846
    {
whitlocb's avatar
whitlocb committed
847 848 849 850
        c << "        QString temp = "<<name<<"->displayText();" << endl;
        c << "        if(!temp.isEmpty())" << endl;
        c << "            atts->Set"<<Name<<"(temp.toStdString());" << endl;
        c << "        else" << endl;
hrchilds's avatar
hrchilds committed
851
        c << "        {" << endl;
whitlocb's avatar
whitlocb committed
852 853 854
        QString msgLabel = (label.length()>0) ? label : name;
        c << "            ResettingError(tr(\""<<msgLabel<<"\")," << endl;
        c << "                QString(atts->Get"<<Name<<"().c_str()));" << endl;
hrchilds's avatar
hrchilds committed
855 856 857
        c << "            atts->Set"<<Name<<"(atts->Get"<<Name<<"());" << endl;
        c << "        }" << endl;
    }
whitlocb's avatar
whitlocb committed
858
    virtual void            writeSourceUpdateWindow(QTextStream &c)
hrchilds's avatar
hrchilds committed
859
    {
whitlocb's avatar
whitlocb committed
860
        c << "            "<<name<<"->setText(QString(atts->Get"<<Name<<"().c_str()));" << endl;
hrchilds's avatar
hrchilds committed
861
    }
whitlocb's avatar
whitlocb committed
862
    virtual void            writeSourceCallback(QString &classname, QString &windowname, QTextStream &c, bool isEnabler)
hrchilds's avatar
hrchilds committed
863 864 865 866
    {
        c << "void" << endl;
        c << windowname<<"::"<<name<<"ProcessText()" << endl;
        c << "{" << endl;
whitlocb's avatar
whitlocb committed
867
        c << "    GetCurrentValues("<<classname << "::ID_" << name<<");" << endl;
hrchilds's avatar
hrchilds committed
868 869 870 871 872 873 874 875 876 877 878 879 880
        c << "    Apply();" << endl;
        c << "}" << endl;
    }
};


//
// ------------------------------- StringVector -------------------------------
//
class WindowGeneratorStringVector : public virtual StringVector , public virtual WindowGeneratorField
{
  public:
    WindowGeneratorStringVector(const QString &n, const QString &l)
881
        : Field("stringVector",n,l), StringVector(n,l), WindowGeneratorField("stringVector",n,l) { }
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
    virtual void            writeHeaderCallback(QTextStream &h)
    {
        h << "    void "<<name<<"ProcessText();" << endl;
    }
    virtual void            writeHeaderData(QTextStream &h)
    {
        h << "    QLineEdit *"<<name<<";" << endl;
    }
    virtual void            writeSourceCreate(QTextStream &c)
    {
        writeSourceCreateLabel(c);
        c << "    "<<name<<" = new QLineEdit(central);" << endl;
        c << "    connect("<<name<<", SIGNAL(returnPressed())," << endl
          << "            this, SLOT("<<name<<"ProcessText()));" << endl;
        c << "    mainLayout->addWidget("<<name<<", "<<index<<",1);" << endl;
    }
    virtual bool            providesSourceGetCurrent() const { return true; }
    virtual void            writeSourceGetCurrent(QTextStream &c)
    {
        c << "        QString temp = "<<name<<"->displayText();" << endl;
        c << "        if(!temp.isEmpty())" << endl;
        c << "        {" << endl;
        c << "            QStringList s = temp.split(\" \", QString::SkipEmptyParts);" << endl;
        c << "            stringVector sv;" << endl;
        c << "            for(int i = 0; i < s.size(); ++i)" << endl;
        c << "                sv.push_back(s[i].toStdString());" << endl;
        c << "            atts->Set"<<Name<<"(sv);" << endl;
        c << "        }" << endl;
        c << "        else" << endl;
        c << "        {" << endl;
        c << "            atts->Set"<<Name<<"(atts->Get"<<Name<<"());" << endl;
        c << "        }" << endl;
    }
    virtual void            writeSourceUpdateWindow(QTextStream &c)
    {
        c << "            {" << endl;
        c << "            QString stmp;" << endl;
        c << "            for(size_t idx = 0; idx < atts->Get"<<Name<<"().size(); ++idx)" << endl;
        c << "            {" << endl;
        c << "                stmp.append(QString(atts->Get"<<Name<<"()[idx].c_str()));" << endl;
        c << "                if(idx < atts->Get"<<Name<<"().size()-1)" << endl;
        c << "                    stmp.append(\" \");" << endl;
        c << "            }" << endl;
        c << "            "<<name<<"->setText(stmp);" << endl;
        c << "            }" << endl;
    }
    virtual void            writeSourceCallback(QString &classname, QString &windowname, QTextStream &c, bool isEnabler)
    {
        c << "void" << endl;
        c << windowname<<"::"<<name<<"ProcessText()" << endl;
        c << "{" << endl;
        c << "    GetCurrentValues("<<classname << "::ID_" << name<<");" << endl;
        c << "    Apply();" << endl;
        c << "}" << endl;
    }
hrchilds's avatar
hrchilds committed
937 938 939 940 941 942 943 944 945 946
};


//
// -------------------------------- ColorTable --------------------------------
//
class WindowGeneratorColorTable : public virtual ColorTable , public virtual WindowGeneratorField
{
  public:
    WindowGeneratorColorTable(const QString &n, const QString &l)
947
        : Field("colortable",n,l), ColorTable(n,l), WindowGeneratorField("colortable",n,l) { }
whitlocb's avatar
whitlocb committed
948
    virtual void            writeHeaderCallback(QTextStream &h)
hrchilds's avatar
hrchilds committed
949 950 951
    {
        h << "    void "<<name<<"Changed(bool useDefault, const QString &ctName);" << endl;
    }
whitlocb's avatar
whitlocb committed
952
    virtual void            writeHeaderData(QTextStream &h)
hrchilds's avatar
hrchilds committed
953 954 955
    {
        h << "    QvisColorTableButton *"<<name<<";" << endl;
    }
whitlocb's avatar
whitlocb committed
956
    virtual void            writeSourceCreate(QTextStream &c)
hrchilds's avatar
hrchilds committed
957 958
    {
        writeSourceCreateLabel(c);
whitlocb's avatar
whitlocb committed
959
        c << "    "<<name<<" = new QvisColorTableButton(central);" << endl;
hrchilds's avatar
hrchilds committed
960 961 962 963
        c << "    connect("<<name<<", SIGNAL(selectedColorTable(bool, const QString&))," << endl
          << "            this, SLOT("<<name<<"Changed(bool, const QString&)));" << endl;
        c << "    mainLayout->addWidget("<<name<<", "<<index<<",1);" << endl;
    }
whitlocb's avatar
whitlocb committed
964
    virtual void            writeSourceGetCurrent(QTextStream &c)
hrchilds's avatar
hrchilds committed
965 966 967
    {
        c << "        // Nothing for " << name << endl;
    }
whitlocb's avatar
whitlocb committed
968
    virtual void            writeSourceUpdateWindow(QTextStream &c)
hrchilds's avatar
hrchilds committed
969
    {
hrchilds's avatar
hrchilds committed
970
        c << "            "<<name<<"->blockSignals(true);" << endl;
whitlocb's avatar
whitlocb committed
971
        c << "            "<<name<<"->setColorTable(QString(atts->Get"<<Name<<"().c_str()));" << endl;
hrchilds's avatar
hrchilds committed
972
        c << "            "<<name<<"->blockSignals(false);" << endl;
hrchilds's avatar
hrchilds committed
973
    }
whitlocb's avatar
whitlocb committed
974
    virtual void            writeSourceCallback(QString &, QString &windowname, QTextStream &c, bool isEnabler)
hrchilds's avatar
hrchilds committed
975 976 977 978
    {
        c << "void" << endl;
        c << windowname<<"::"<<name<<"Changed(bool useDefault, const QString &ctName)" << endl;
        c << "{" << endl;
whitlocb's avatar
whitlocb committed
979
        c << "    atts->Set"<<Name<<"(ctName.toStdString());" << endl;
hrchilds's avatar
hrchilds committed
980 981
        if(!isEnabler)
            c << "    SetUpdate(false);" << endl;
hrchilds's avatar
hrchilds committed
982 983 984 985 986 987 988 989 990 991 992 993 994
        c << "    Apply();" << endl;
        c << "}" << endl;
    }
};


//
// ----------------------------------- Color ----------------------------------
//
class WindowGeneratorColor : public virtual Color , public virtual WindowGeneratorField
{
  public:
    WindowGeneratorColor(const QString &n, const QString &l)
995
        : Field("color",n,l), Color(n,l), WindowGeneratorField("color",n,l) { }
whitlocb's avatar
whitlocb committed
996
    virtual void            writeHeaderCallback(QTextStream &h)
hrchilds's avatar
hrchilds committed
997 998 999
    {
        h << "    void "<<name<<"Changed(const QColor &color);" << endl;
    }
whitlocb's avatar
whitlocb committed
1000
    virtual void            writeHeaderData(QTextStream &h)
hrchilds's avatar
hrchilds committed
1001 1002 1003
    {
        h << "    QvisColorButton *"<<name<<";" << endl;
    }
whitlocb's avatar
whitlocb committed
1004
    virtual void            writeSourceCreate(QTextStream &c)
hrchilds's avatar
hrchilds committed
1005 1006
    {
        writeSourceCreateLabel(c);
whitlocb's avatar
whitlocb committed
1007
        c << "    "<<name<<" = new QvisColorButton(central);" << endl;
hrchilds's avatar
hrchilds committed
1008 1009 1010 1011
        c << "    connect("<<name<<", SIGNAL(selectedColor(const QColor&))," << endl
          << "            this, SLOT("<<name<<"Changed(const QColor&)));" << endl;
        c << "    mainLayout->addWidget("<<name<<", "<<index<<",1);" << endl;
    }
whitlocb's avatar
whitlocb committed
1012
    virtual void            writeSourceGetCurrent(QTextStream &c)
hrchilds's avatar
hrchilds committed
1013 1014 1015
    {
        c << "        // Nothing for " << name << endl;
    }
whitlocb's avatar
whitlocb committed
1016
    virtual void            writeSourceUpdateWindow(QTextStream &c)
hrchilds's avatar
hrchilds committed
1017
    {
whitlocb's avatar
whitlocb committed
1018
        c << "            { // new scope" << endl;
1019
        c << "                QColor tempcolor = QColor(atts->Get"<<Name<<"().Red()," << endl;
whitlocb's avatar
whitlocb committed
1020 1021 1022 1023 1024 1025
        c << "                                   atts->Get"<<Name<<"().Green()," << endl;
        c << "                                   atts->Get"<<Name<<"().Blue());" << endl;
        c << "                "<<name<<"->blockSignals(true);" << endl;
        c << "                "<<name<<"->setButtonColor(tempcolor);" << endl;
        c << "                "<<name<<"->blockSignals(false);" << endl;
        c << "            }" << endl;
hrchilds's avatar
hrchilds committed
1026
    }
whitlocb's avatar
whitlocb committed
1027
    virtual void            writeSourceCallback(QString &, QString &windowname, QTextStream &c, bool isEnabler)
hrchilds's avatar
hrchilds committed
1028 1029 1030 1031 1032 1033
    {
        c << "void" << endl;
        c << windowname<<"::"<<name<<"Changed(const QColor &color)" << endl;
        c << "{" << endl;
        c << "    ColorAttribute temp(color.red(), color.green(), color.blue());" << endl;
        c << "    atts->Set"<<Name<<"(temp);" << endl;
hrchilds's avatar
hrchilds committed
1034 1035
        if(!isEnabler)
            c << "    SetUpdate(false);" << endl;
hrchilds's avatar
hrchilds committed
1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048
        c << "    Apply();" << endl;
        c << "}" << endl;
    }
};


//
// --------------------------------- Opacity ----------------------------------
//
class WindowGeneratorOpacity : public virtual Opacity , public virtual WindowGeneratorField
{
  public:
    WindowGeneratorOpacity(const QString &n, const QString &l)
1049
        : Field("opacity",n,l), Opacity(n,l), WindowGeneratorField("opacity",n,l) { }
whitlocb's avatar
whitlocb committed
1050
    virtual void            writeHeaderCallback(QTextStream &h)
hrchilds's avatar
hrchilds committed
1051 1052 1053
    {
        h << "    void "<<name<<"Changed(int opacity, const void*);" << endl;
    }
whitlocb's avatar
whitlocb committed
1054
    virtual void            writeHeaderData(QTextStream &h)
hrchilds's avatar
hrchilds committed
1055 1056 1057
    {
        h << "    QvisOpacitySlider *"<<name<<";" << endl;
    }
whitlocb's avatar
whitlocb committed
1058
    virtual void            writeSourceCreate(QTextStream &c)
hrchilds's avatar
hrchilds committed
1059 1060
    {
        writeSourceCreateLabel(c);
whitlocb's avatar
whitlocb committed
1061
        c << "    "<<name<<" = new QvisOpacitySlider(0,255,25,255, central, NULL);" << endl;
hrchilds's avatar
hrchilds committed
1062 1063 1064 1065 1066 1067
        c << "    "<<name<<"->setTickInterval(64);" << endl;
        c << "    "<<name<<"->setGradientColor(QColor(0, 0, 0));" << endl;
        c << "    connect("<<name<<", SIGNAL(valueChanged(int, const void*))," << endl
          << "            this, SLOT("<<name<<"Changed(int, const void*)));" << endl;
        c << "    mainLayout->addWidget("<<name<<", "<<index<<",1);" << endl;
    }
whitlocb's avatar
whitlocb committed
1068
    virtual void            writeSourceGetCurrent(QTextStream &c)
hrchilds's avatar
hrchilds committed
1069 1070 1071
    {
        c << "        // Nothing for " << name << endl;
    }
whitlocb's avatar
whitlocb committed
1072
    virtual void            writeSourceUpdateWindow(QTextStream &c)
hrchilds's avatar
hrchilds committed
1073
    {
hrchilds's avatar
hrchilds committed
1074
        c << "            "<<name<<"->blockSignals(true);" << endl;
hrchilds's avatar
hrchilds committed
1075
        c << "            "<<name<<"->setValue(int(atts->Get"<<Name<<"()*255.));" << endl;
hrchilds's avatar
hrchilds committed
1076
        c << "            "<<name<<"->blockSignals(false);" << endl;
hrchilds's avatar
hrchilds committed
1077
    }
whitlocb's avatar
whitlocb committed
1078
    virtual void            writeSourceCallback(QString &, QString &windowname, QTextStream &c, bool isEnabler)
hrchilds's avatar
hrchilds committed
1079 1080 1081 1082 1083
    {
        c << "void" << endl;
        c << windowname<<"::"<<name<<"Changed(int opacity, const void*)" << endl;
        c << "{" << endl;
        c << "    atts->Set"<<Name<<"((float)opacity/255.);" << endl;