pqNamedWidgets.cxx 49.8 KB
Newer Older
1
2
3
4
5
/*=========================================================================

   Program: ParaView
   Module:    pqNamedWidgets.cxx

6
   Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
7
8
9
   All rights reserved.

   ParaView is a free software; you can redistribute it and/or modify it
10
   under the terms of the ParaView license version 1.2. 
11

12
   See License_v1.2.txt for the full ParaView license.
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
   A copy of this license can be obtained by contacting
   Kitware Inc.
   28 Corporate Drive
   Clifton Park, NY 12065
   USA

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 AUTHORS 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.

=========================================================================*/

// this include
#include "pqNamedWidgets.h"

// Qt includes
#include <QCheckBox>
38
39
40
41
#include <QComboBox>
#include <QDoubleSpinBox>
#include <QGroupBox>
#include <QLayout>
42
43
#include <QLineEdit>
#include <QListWidget>
44
#include <QPushButton>
45
#include <QSlider>
46
47
48
#include <QtDebug>
#include <QTextEdit>
#include <QTreeWidget>
Clinton Stimpson's avatar
 
Clinton Stimpson committed
49
#include <QLabel>
Clinton Stimpson's avatar
 
Clinton Stimpson committed
50
51
#include <QMetaObject>
#include <QMetaProperty>
52
#include <QHeaderView>
53
54
55
56

// VTK includes

// ParaView Server Manager includes
57
58
59
60
61
#include "vtkCollection.h"
#include "vtkPVXMLElement.h"
#include "vtkSmartPointer.h"
#include "vtkSMCompositeTreeDomain.h"
#include "vtkSMDomainIterator.h"
62
#include "vtkSMEnumerationDomain.h"
63
#include "vtkSMOrderedPropertyIterator.h"
64
65
#include "vtkSMProperty.h"
#include "vtkSMPropertyIterator.h"
66
#include "vtkSMStringListDomain.h"
67
#include "vtkSMIntVectorProperty.h"
68
#include "vtkSMSILDomain.h"
69
70

// ParaView includes
71
#include "pq3DWidget.h"
72
#include "pqApplicationCore.h"
73
#include "pqCollapsedGroup.h"
74
75
76
77
#include "pqComboBoxDomain.h"
#include "pqDoubleRangeWidget.h"
#include "pqFieldSelectionAdaptor.h"
#include "pqFileChooserWidget.h"
78
#include "pqIntRangeWidget.h"
79
#include "pqListWidgetItemObject.h"
80
#include "pqObjectBuilder.h"
81
#include "pqObjectPanel.h"
82
#include "pqPipelineFilter.h"
83
#include "pqPropertyManager.h"
84
#include "pqProxySelectionWidget.h"
85
#include "pqProxySILModel.h"
86
#include "pqSelectionInputWidget.h"
87
#include "pqServerManagerModel.h"
88
#include "pqServerManagerObserver.h"
89
#include "pqSignalAdaptorCompositeTreeWidget.h"
90
#include "pqSignalAdaptorSelectionTreeWidget.h"
91
#include "pqSignalAdaptors.h"
92
#include "pqSILModel.h"
93
#include "pqSILWidget.h"
94
95
96
#include "pqSMAdaptor.h"
#include "pqSMProxy.h"
#include "pqSMSignalAdaptors.h"
97
#include "pqTreeView.h"
98
#include "pqTreeWidget.h"
99
#include "pqTreeWidgetSelectionHelper.h"
100
#include "pqWidgetRangeDomain.h"
101

102
//-----------------------------------------------------------------------------
103
104
105
void pqNamedWidgets::link(QWidget* parent, pqSMProxy proxy, 
  pqPropertyManager* property_manager,
  const QStringList* exceptions/*=0*/)
106
{
Clinton Stimpson's avatar
 
Clinton Stimpson committed
107
  if(!parent || !proxy || !property_manager)
108
109
110
111
112
113
114
    {
    return;
    }
    
  vtkSMPropertyIterator *iter = proxy->NewPropertyIterator();
  for(iter->Begin(); !iter->IsAtEnd(); iter->Next())
    {
Clinton Stimpson's avatar
 
Clinton Stimpson committed
115
    // all property names with special characters are changed
Clinton Stimpson's avatar
 
Clinton Stimpson committed
116
    QString propertyName = iter->GetKey();
117
118
119
120
    if (exceptions && exceptions->contains(propertyName))
      {
      continue;
      }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
121
    propertyName.replace(':', '_');
Clinton Stimpson's avatar
 
Clinton Stimpson committed
122
123
124
125
    
    // escape regex chars
    propertyName.replace(')', "\\)");
    propertyName.replace('(', "\\(");
Clinton Stimpson's avatar
 
Clinton Stimpson committed
126
127

    const QString regex = QString("^%1$|^%1_.*$").arg(propertyName);
128
129
130
131
    QList<QObject*> foundObjects = parent->findChildren<QObject*>(QRegExp(regex));
    for(int i=0; i<foundObjects.size(); i++)
      {
      QObject* foundObject = foundObjects[i];
132
133
134
135
136
      pqNamedWidgets::linkObject(foundObject, proxy, iter->GetKey(),
        property_manager);
      }
    }
  iter->Delete();
137

138
139
}

140
//-----------------------------------------------------------------------------
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
void pqNamedWidgets::linkObject(QObject* object, pqSMProxy proxy,
                         const QString& property, pqPropertyManager* property_manager)
{
  vtkSMProperty* SMProperty = proxy->GetProperty(property.toAscii().data());

  // update domains that we might ask for
  SMProperty->UpdateDependentDomains();

  pqSMAdaptor::PropertyType pt = pqSMAdaptor::getPropertyType(SMProperty);

  if(pt == pqSMAdaptor::MULTIPLE_ELEMENTS)
    {
    QWidget* propertyWidget = qobject_cast<QWidget*>(object);
    if(propertyWidget)
      {
      int index = -1;
      // get the index from the name, which should be at the end
      QString name = propertyWidget->objectName();
      QStringList split = name.split('_');
      if(split.size() > 1)
161
        {
162
163
164
        bool ok = false;
        index = split[split.size() - 1].toInt(&ok);
        if(!ok)
165
          {
166
          index = -1;
167
168
          }
        }
169
      if(index != -1)
170
        {
Clinton Stimpson's avatar
 
Clinton Stimpson committed
171
172
        QString userProperty, userSignal;
        if(pqNamedWidgets::propertyInformation(propertyWidget, userProperty, userSignal))
173
          {
Clinton Stimpson's avatar
 
Clinton Stimpson committed
174
175
          pqNamedWidgets::linkObject(propertyWidget, userProperty, userSignal,
            proxy, SMProperty, index, property_manager);
176
177
          }
        }
178
179
180
181
182
183
      }
    }
  else if(pt == pqSMAdaptor::ENUMERATION)
    {
    // enumerations can be combo boxes or check boxes
    QComboBox* comboBox = qobject_cast<QComboBox*>(object);
Clinton Stimpson's avatar
 
Clinton Stimpson committed
184
    if(comboBox)
185
186
187
188
189
190
191
192
193
194
195
      {
      pqComboBoxDomain* d0 = new pqComboBoxDomain(comboBox, SMProperty);
      d0->setObjectName("ComboBoxDomain");
      
      pqSignalAdaptorComboBox* adaptor = 
        new pqSignalAdaptorComboBox(comboBox);
      adaptor->setObjectName("ComboBoxAdaptor");
      property_manager->registerLink(
        adaptor, "currentText", SIGNAL(currentTextChanged(const QString&)),
        proxy, SMProperty);
      }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
196
    else
197
      {
Clinton Stimpson's avatar
 
Clinton Stimpson committed
198
199
200
201
202
203
      QString userProperty, userSignal;
      if(pqNamedWidgets::propertyInformation(object, userProperty, userSignal))
        {
        pqNamedWidgets::linkObject(object, userProperty, userSignal,
          proxy, SMProperty, -1, property_manager);
        }
204
      }
205
206
207
    }
  else if(pt == pqSMAdaptor::SELECTION)
    {
208
    // selections can be list or tree widgets
209
210
211
212
    QListWidget* listWidget = qobject_cast<QListWidget*>(object);
    QTreeWidget* treeWidget = qobject_cast<QTreeWidget*>(object);
    if(listWidget)
      {
213
214
      // for now, we're assuming selection domains don't change
      // if they do, we need to observe those changes
215
216
217
218
219
220
221
222
223
224
225
226
227
228
      listWidget->clear();
      QList<QVariant> sel_domain = 
        pqSMAdaptor::getSelectionPropertyDomain(SMProperty);
      for(int j=0; j<sel_domain.size(); j++)
        {
        pqListWidgetItemObject* item = 
          new pqListWidgetItemObject(sel_domain[j].toString(), listWidget);
        property_manager->registerLink(
          item, "checked", SIGNAL(checkedStateChanged(bool)),
          proxy, SMProperty, j);
        }
      }
    else if(treeWidget)
      {
229
230
231
232
233
234
      pqSignalAdaptorSelectionTreeWidget* adaptor = 
        new pqSignalAdaptorSelectionTreeWidget(treeWidget, SMProperty);
      adaptor->setObjectName("SelectionTreeWidgetAdaptor");
      property_manager->registerLink(
        adaptor, "values", SIGNAL(valuesChanged()),
        proxy, SMProperty);
235
236
237
238
239
240
241
      }
    }
  else if(pt == pqSMAdaptor::PROXY)
    {
    QComboBox* comboBox = qobject_cast<QComboBox*>(object);
    if(comboBox)
      {
242
243
      pqServerManagerModel* smmodel = 
        pqApplicationCore::instance()->getServerManagerModel();
244
245
246
247
248
      // TODO: use pqComboBoxDomain
      QList<pqSMProxy> propertyDomain = 
        pqSMAdaptor::getProxyPropertyDomain(SMProperty);
      comboBox->clear();
      foreach(pqSMProxy v, propertyDomain)
Clinton Stimpson's avatar
 
Clinton Stimpson committed
249
        {
250
        pqPipelineSource* o = smmodel->findItem<pqPipelineSource*>(v);
251
        if(o)
Clinton Stimpson's avatar
 
Clinton Stimpson committed
252
          {
253
          comboBox->addItem(o->getSMName());
Clinton Stimpson's avatar
 
Clinton Stimpson committed
254
255
          }
        }
256
257
258
259
260
261
262
263
264
265
      pqSignalAdaptorComboBox* comboAdaptor = 
        new pqSignalAdaptorComboBox(comboBox);
      comboAdaptor->setObjectName("ComboBoxAdaptor");
      pqSignalAdaptorProxy* proxyAdaptor = 
        new pqSignalAdaptorProxy(comboAdaptor, "currentText", 
                                 SIGNAL(currentTextChanged(const QString&)));
      proxyAdaptor->setObjectName("ComboBoxProxyAdaptor");
      property_manager->registerLink(
        proxyAdaptor, "proxy", SIGNAL(proxyChanged(const QVariant&)),
        proxy, SMProperty);
266
      }
267
268
269
270
271
272
273
274
275
276

    pqSelectionInputWidget *selectWidget
      = qobject_cast<pqSelectionInputWidget*>(object);
    if (selectWidget)
      {
      QString userProperty, userSignal;
      if (pqNamedWidgets::propertyInformation(object, userProperty, userSignal))
        {
        pqNamedWidgets::linkObject(object, userProperty, userSignal,
                                   proxy, SMProperty, -1, property_manager);
277
278
        QObject::connect(property_manager, SIGNAL(aboutToAccept()),
          selectWidget, SLOT(preAccept()));
279
        QObject::connect(property_manager, SIGNAL(accepted()),
280
          selectWidget, SLOT(postAccept()));
281
282
        }
      }
283
    }
284
285
  else if (pt == pqSMAdaptor::PROXYSELECTION)
    {
Clinton Stimpson's avatar
 
Clinton Stimpson committed
286
287
    pqProxySelectionWidget* w = qobject_cast<pqProxySelectionWidget*>(object);
    if(w)
288
      {
Clinton Stimpson's avatar
 
Clinton Stimpson committed
289
290
291
292
293
      property_manager->registerLink(
        w, "proxy", SIGNAL(proxyChanged(pqSMProxy)),
        proxy, SMProperty);

      QWidget* parent = w->parentWidget();
294
      pqObjectPanel* object_panel = qobject_cast<pqObjectPanel*>(parent);
Clinton Stimpson's avatar
 
Clinton Stimpson committed
295
      if(object_panel)
296
        {
297
298
299
        w->setView(object_panel->view());
        QObject::connect(parent, SIGNAL(viewChanged(pqView*)),
                         w, SLOT(setView(pqView*)));
Clinton Stimpson's avatar
 
Clinton Stimpson committed
300
301
302
303
        QObject::connect(parent, SIGNAL(onaccept()), w, SLOT(accept()));
        QObject::connect(parent, SIGNAL(onreset()), w, SLOT(reset()));
        QObject::connect(parent, SIGNAL(onselect()), w, SLOT(select()));
        QObject::connect(parent, SIGNAL(ondeselect()), w, SLOT(deselect()));
Clinton Stimpson's avatar
 
Clinton Stimpson committed
304
        QObject::connect(w, SIGNAL(modified()), parent, SLOT(setModified()));
305
        }
306

307
308
      }
    }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
309
  else if(pt == pqSMAdaptor::SINGLE_ELEMENT || pt == pqSMAdaptor::FILE_LIST)
310
311
312
    {
    QComboBox* comboBox = qobject_cast<QComboBox*>(object);
    QTextEdit* textEdit = qobject_cast<QTextEdit*>(object);
313

314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
    if(comboBox)
      {
      // these combo boxes tend to be true/false combos
      pqComboBoxDomain* d0 = new pqComboBoxDomain(comboBox, SMProperty);
      d0->setObjectName("ComboBoxDomain");

      pqSignalAdaptorComboBox* adaptor = 
        new pqSignalAdaptorComboBox(comboBox);
      adaptor->setObjectName("ComboBoxAdaptor");
      property_manager->registerLink(
        adaptor, "currentText", SIGNAL(currentTextChanged(const QString&)),
        proxy, SMProperty);
      }
    else if(textEdit)
      {
      pqSignalAdaptorTextEdit *adaptor = 
        new pqSignalAdaptorTextEdit(textEdit);
      adaptor->setObjectName("TextEditAdaptor");          
      property_manager->registerLink(
        adaptor, "text", SIGNAL(textChanged()),
        proxy, SMProperty);
      }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
336
    else
337
      {
Clinton Stimpson's avatar
 
Clinton Stimpson committed
338
339
340
341
342
343
      QString userProperty, userSignal;
      if(pqNamedWidgets::propertyInformation(object, userProperty, userSignal))
        {
        pqNamedWidgets::linkObject(object, userProperty, userSignal,
          proxy, SMProperty, -1, property_manager);
        }
344
345
346
347
348
349
350
351
352
      }
    }
  else if(pt == pqSMAdaptor::FIELD_SELECTION)
    {
    QComboBox* comboBox = qobject_cast<QComboBox*>(object);
    if(comboBox)
      {
      if(comboBox->objectName().contains(QRegExp("_mode$")))
        {
Clinton Stimpson's avatar
 
Clinton Stimpson committed
353
354
        pqComboBoxDomain* d0 = new pqComboBoxDomain(comboBox, SMProperty,
                                                    "field_list");
355
356
357
358
359
360
361
362
363
364
365
        d0->setObjectName("FieldModeDomain");

        pqSignalAdaptorComboBox* adaptor = 
          new pqSignalAdaptorComboBox(comboBox);
        adaptor->setObjectName("ComboBoxAdaptor");
        property_manager->registerLink(
          adaptor, "currentText", SIGNAL(currentTextChanged(const QString&)),
          proxy, SMProperty, 0);  // 0 means link mode for field selection
        }
      else if(comboBox->objectName().contains(QRegExp("_scalars$")))
        {
Clinton Stimpson's avatar
 
Clinton Stimpson committed
366
367
        pqComboBoxDomain* d0 = new pqComboBoxDomain(comboBox, SMProperty,
                                                    "array_list");
368
369
370
371
372
373
        d0->setObjectName("FieldScalarsDomain");

        pqSignalAdaptorComboBox* adaptor = 
          new pqSignalAdaptorComboBox(comboBox);
        adaptor->setObjectName("ComboBoxAdaptor");
        property_manager->registerLink(
374
          adaptor, "currentData", SIGNAL(currentTextChanged(const QString&)),
375
376
377
378
379
380
381
382
          proxy, SMProperty, 1);  // 1 means link scalar for field selection
        }
      else
        {
        // one combo for it all
        pqFieldSelectionAdaptor* adaptor = new
          pqFieldSelectionAdaptor(comboBox, SMProperty);
        adaptor->setObjectName("FieldSelectionAdaptor");
383
384
385
386
387
        property_manager->registerLink(adaptor,
                                       "selection",
                                       SIGNAL(selectionChanged()),
                                       proxy,
                                       SMProperty);
388
389
390
        }
      }
    }
391
392
  else if (pt == pqSMAdaptor::COMPOSITE_TREE)
    {
393
394
    QTreeWidget* tree = qobject_cast<QTreeWidget*>(object);
    if (tree)
395
      {
396
397
398
      pqSignalAdaptorCompositeTreeWidget* treeAdaptor = 
        new pqSignalAdaptorCompositeTreeWidget(tree,
          vtkSMIntVectorProperty::SafeDownCast(SMProperty));
399
400
401
      pqTreeWidgetSelectionHelper* helper = 
        new pqTreeWidgetSelectionHelper(tree);
      helper->setObjectName("CompositeTreeSelectionHelper");
402
      treeAdaptor->setObjectName("CompositeTreeAdaptor");
403
      property_manager->registerLink(
404
        treeAdaptor, "values", SIGNAL(valuesChanged()),
405
406
407
        proxy, SMProperty);
      }
    }
408
409
  else if (pt == pqSMAdaptor::SIL)
    {
410
    pqSILWidget* tree = qobject_cast<pqSILWidget*>(object);
411
412
413
    if (tree)
      {
      property_manager->registerLink(
414
        tree->activeModel(), "values", SIGNAL(valuesChanged()),
415
416
417
        proxy, SMProperty);
      }
    }
418
419
}

420
//-----------------------------------------------------------------------------
421
void pqNamedWidgets::unlink(QWidget* parent, pqSMProxy proxy, pqPropertyManager* property_manager)
422
{
Clinton Stimpson's avatar
 
Clinton Stimpson committed
423
  if(!parent || !proxy || !property_manager)
424
425
426
427
428
429
430
    {
    return;
    }

  vtkSMPropertyIterator *iter = proxy->NewPropertyIterator();
  for(iter->Begin(); !iter->IsAtEnd(); iter->Next())
    {
Clinton Stimpson's avatar
 
Clinton Stimpson committed
431
    // all property names with special characters are changed
Clinton Stimpson's avatar
 
Clinton Stimpson committed
432
433
    QString propertyName = iter->GetKey();
    propertyName.replace(':', '_');
Clinton Stimpson's avatar
 
Clinton Stimpson committed
434
435
436
437
438

    // escape regex chars
    propertyName.replace(')', "\\)");
    propertyName.replace('(', "\\(");

Clinton Stimpson's avatar
 
Clinton Stimpson committed
439
    const QString regex = QString("^%1$|^%1_.*$").arg(propertyName);
440
441
442
443
    QList<QObject*> foundObjects = parent->findChildren<QObject*>(QRegExp(regex));
    for(int i=0; i<foundObjects.size(); i++)
      {
      QObject* foundObject = foundObjects[i];
444
445
446
447
448
449
450
      pqNamedWidgets::unlinkObject(foundObject, proxy, iter->GetKey(),
        property_manager);
      }
    }
  iter->Delete();
  proxy->UpdateVTKObjects();
}
451

452
//-----------------------------------------------------------------------------
453
454
455
void pqNamedWidgets::unlinkObject(QObject* object, pqSMProxy proxy,
                           const QString& property, pqPropertyManager* property_manager)
{
456

457
458
459
460
461
462
463
464
465
466
467
468
469
470
  vtkSMProperty* SMProperty = proxy->GetProperty(property.toAscii().data());
  
  pqSMAdaptor::PropertyType pt = pqSMAdaptor::getPropertyType(SMProperty);

  if(pt == pqSMAdaptor::MULTIPLE_ELEMENTS)
    {
    QWidget* propertyWidget = qobject_cast<QWidget*>(object);
    if(propertyWidget)
      {
      int index = -1;
      // get the index from the name
      QString name = propertyWidget->objectName();
      QStringList split = name.split('_');
      if(split.size() > 1)
471
        {
472
473
474
        bool ok = false;
        index = split[split.size() - 1].toInt(&ok);
        if(!ok)
475
          {
476
          index = -1;
477
478
          }
        }
479
      if(index != -1)
480
        {
Clinton Stimpson's avatar
 
Clinton Stimpson committed
481
482
        QString userProperty, userSignal;
        if(pqNamedWidgets::propertyInformation(propertyWidget, userProperty, userSignal))
483
          {
Clinton Stimpson's avatar
 
Clinton Stimpson committed
484
485
          pqNamedWidgets::unlinkObject(propertyWidget, userProperty, userSignal,
            proxy, SMProperty, index, property_manager);
486
487
          }
        }
488
489
490
491
492
493
      }
    }
  else if(pt == pqSMAdaptor::ENUMERATION)
    {
    // enumerations can be combo boxes or check boxes
    QComboBox* comboBox = qobject_cast<QComboBox*>(object);
Clinton Stimpson's avatar
 
Clinton Stimpson committed
494
    if(comboBox)
495
496
497
498
499
500
501
502
503
504
505
      {
      pqComboBoxDomain* d0 =
        comboBox->findChild<pqComboBoxDomain*>("ComboBoxDomain");
      if(d0)
        {
        delete d0;
        }

      pqSignalAdaptorComboBox* adaptor = 
        comboBox->findChild<pqSignalAdaptorComboBox*>("ComboBoxAdaptor");
      if(adaptor)
506
        {
507
508
509
510
511
512
        property_manager->unregisterLink(
          adaptor, "currentText", SIGNAL(currentTextChanged(const QString&)),
          proxy, SMProperty);
        delete adaptor;
        }
      }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
513
    else
514
      {
Clinton Stimpson's avatar
 
Clinton Stimpson committed
515
516
517
518
519
520
      QString userProperty, userSignal;
      if(pqNamedWidgets::propertyInformation(object, userProperty, userSignal))
        {
        pqNamedWidgets::unlinkObject(object, userProperty, userSignal,
          proxy, SMProperty, -1, property_manager);
        }
521
      }
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
    }
  else if(pt == pqSMAdaptor::SELECTION)
    {
    // selections can be list widgets
    QListWidget* listWidget = qobject_cast<QListWidget*>(object);
    QTreeWidget* treeWidget = qobject_cast<QTreeWidget*>(object);
    if(listWidget)
      {
      for(int ii=0; ii<listWidget->count(); ii++)
        {
        pqListWidgetItemObject* item = 
          static_cast<pqListWidgetItemObject*>(listWidget->item(ii));
        property_manager->unregisterLink(
          item, "checked", SIGNAL(checkedStateChanged(bool)),
          proxy, SMProperty, ii);
        }
      listWidget->clear();
      }
    if(treeWidget)
      {
542
543
544
545
546
547
      QObject* adaptor = 
        treeWidget->findChild<pqSignalAdaptorComboBox*>("SelectionTreeWidgetAdaptor");
      property_manager->unregisterLink(
        adaptor, "values", SIGNAL(valuesChanged()),
        proxy, SMProperty);
      delete adaptor;
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
      }
    }
  else if(pt == pqSMAdaptor::PROXY)
    {
    QComboBox* comboBox = qobject_cast<QComboBox*>(object);
    if(comboBox)
      {
      QObject* comboAdaptor = 
        comboBox->findChild<pqSignalAdaptorComboBox*>("ComboBoxAdaptor");
      QObject* proxyAdaptor = 
        comboBox->findChild<pqSignalAdaptorComboBox*>("ComboBoxProxyAdaptor");
      property_manager->unregisterLink(
        proxyAdaptor, "proxy", SIGNAL(proxyChanged(const QVariant&)),
        proxy, SMProperty);
      delete proxyAdaptor;
      delete comboAdaptor;
      }
    }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
566
  else if(pt == pqSMAdaptor::SINGLE_ELEMENT || pt == pqSMAdaptor::FILE_LIST)
567
568
    {
    QComboBox* comboBox = qobject_cast<QComboBox*>(object);
569
    QTextEdit* textEdit = qobject_cast<QTextEdit*>(object);
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
    if(comboBox)
      {
      pqComboBoxDomain* d0 =
        comboBox->findChild<pqComboBoxDomain*>("ComboBoxDomain");
      if(d0)
        {
        delete d0;
        }

      pqSignalAdaptorComboBox* adaptor = 
        comboBox->findChild<pqSignalAdaptorComboBox*>("ComboBoxAdaptor");
      property_manager->unregisterLink(
        adaptor, "currentText", SIGNAL(currentTextChanged(const QString&)),
        proxy, SMProperty);
      delete adaptor;
      }
586
587
588
589
590
591
592
593
    else if(textEdit)
      {
      pqSignalAdaptorTextEdit* adaptor = 
        textEdit->findChild<pqSignalAdaptorTextEdit*>("TextEditAdaptor");
      property_manager->unregisterLink(
        adaptor, "text", SIGNAL(textChanged()),
        proxy, SMProperty);
      }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
594
    else
595
      {
Clinton Stimpson's avatar
 
Clinton Stimpson committed
596
597
      QString userProperty, userSignal;
      if(pqNamedWidgets::propertyInformation(object, userProperty, userSignal))
598
        {
Clinton Stimpson's avatar
 
Clinton Stimpson committed
599
600
        pqNamedWidgets::unlinkObject(object, userProperty, userSignal,
          proxy, SMProperty, -1, property_manager);
601
        }
602
603
      }
    }
604
605
606
607
608
609
610
611
612
613
614
615
  else if (pt == pqSMAdaptor::COMPOSITE_TREE)
    {
    QTreeWidget* tree = qobject_cast<QTreeWidget*>(object);
    if (tree)
      {
      pqSignalAdaptorCompositeTreeWidget* treeAdaptor = 
        tree->findChild<pqSignalAdaptorCompositeTreeWidget*>(
          "CompositeTreeAdaptor");
      property_manager->unregisterLink(
        treeAdaptor, "values", SIGNAL(valuesChanged()),
        proxy, SMProperty);
      delete treeAdaptor;
616
617
618
619
620

      pqTreeWidgetSelectionHelper* helper = 
        tree->findChild<pqTreeWidgetSelectionHelper*>(
          "CompositeTreeSelectionHelper");
      delete helper;
621
622
      }
    }
623
624
625
626
627
628
629
630
631
632
  else if(pt == pqSMAdaptor::FIELD_SELECTION)
    {
    QComboBox* comboBox = qobject_cast<QComboBox*>(object);
    if(comboBox)
      {
      if(comboBox->objectName().contains(QRegExp("_mode$")))
        {
        pqComboBoxDomain* d0 =
          comboBox->findChild<pqComboBoxDomain*>("FieldModeDomain");
        if(d0)
633
          {
634
          delete d0;
635
          }
636
637
638
639

        pqSignalAdaptorComboBox* adaptor = 
          comboBox->findChild<pqSignalAdaptorComboBox*>("ComboBoxAdaptor");
        if(adaptor)
Clinton Stimpson's avatar
 
Clinton Stimpson committed
640
641
          {
          property_manager->unregisterLink(
642
643
644
645
            adaptor, "currentText", SIGNAL(currentTextChanged(const QString&)),
            proxy, SMProperty, 0);  // 0 means link mode for field selection
          
          delete adaptor;
Clinton Stimpson's avatar
 
Clinton Stimpson committed
646
          }
647
        }
648
      else if(comboBox->objectName().contains(QRegExp("_scalars$")))
649
        {
650
651
652
        pqComboBoxDomain* d0 =
          comboBox->findChild<pqComboBoxDomain*>("FieldScalarsDomain");
        if(d0)
653
          {
654
          delete d0;
655
          }
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680

        pqSignalAdaptorComboBox* adaptor = 
          comboBox->findChild<pqSignalAdaptorComboBox*>("ComboBoxAdaptor");
        if(adaptor)
          {
          property_manager->unregisterLink(
            adaptor, "currentText", SIGNAL(currentTextChanged(const QString&)),
            proxy, SMProperty, 1);  // 1 means link scalars for field selection
          
          delete adaptor;
          }
        }
      else
        {
        pqFieldSelectionAdaptor* adaptor = 
          comboBox->findChild<pqFieldSelectionAdaptor*>("FieldSelectionAdaptor");
        // one combo for it all
        property_manager->unregisterLink(
          adaptor, "attributeMode", SIGNAL(selectionChanged()),
          proxy, SMProperty, 0);
        property_manager->unregisterLink(
          adaptor, "scalar", SIGNAL(selectionChanged()),
          proxy, SMProperty, 1);
        
        delete adaptor;
681
        }
682
683
684
      }
    }
}
685

Clinton Stimpson's avatar
 
Clinton Stimpson committed
686
687
688
689
690
//-----------------------------------------------------------------------------
// Process hints and form complex widgets using hints.
static void processHints(QGridLayout* panelLayout,
                         vtkSMProxy* smProxy,
                         QStringList& propertiesToHide,
691
                         QStringList& propertiesToShow,
Sebastien Jourdain's avatar
Sebastien Jourdain committed
692
                         bool vtkNotUsed(summaryOnly))
Clinton Stimpson's avatar
 
Clinton Stimpson committed
693
{
694
695
696
697
698
699
700
701
  // Obtain the list of input ports, we don't show any widgets for input ports.
  QList<const char*> inputPortNames = 
    pqPipelineFilter::getInputPorts(smProxy);
  foreach (const char* pname, inputPortNames)
    {
    propertiesToHide.push_back(pname);
    }

Clinton Stimpson's avatar
 
Clinton Stimpson committed
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
  // Get the hints for this proxy.
  // The hints may contain stuff about property groupping/layout
  // etc etc.
  vtkPVXMLElement* hints = smProxy->GetHints();
  if (!hints)
    {
    return;
    }

  // Check for any hints about whether to show or hide the widget associated
  // with a particular property.
  unsigned int numHints = hints->GetNumberOfNestedElements();
  for (unsigned int i = 0; i < numHints; i++)
    {
    vtkPVXMLElement *element = hints->GetNestedElement(i);
    if (QString("Property") == element->GetName())
      {
      QString propertyName = element->GetAttribute("name");
      int showProperty;
      if (element->GetScalarAttribute("show", &showProperty))
        {
        if (showProperty)
          {
          propertiesToShow.push_back(propertyName);
          }
        else
          {
          propertiesToHide.push_back(propertyName);
          }
        }
      }
    }

  pqObjectPanel* panel =
    qobject_cast<pqObjectPanel*>(panelLayout->parentWidget());

  // See if any properties are grouped into 3D widgets.
  QList<pq3DWidget*> widgets = pq3DWidget::createWidgets(smProxy, smProxy);  // TODO seems a bit odd to pass both the same
  if (widgets.size() == 0)
    {
    return;
    }
  int rowCount = 0;
  foreach (pq3DWidget* widget, widgets)
    {
    pqCollapsedGroup* group = 
      new pqCollapsedGroup(panel);
    group->setLayout(new QVBoxLayout(group));
    group->setTitle(widget->getHints()->GetAttribute("label"));
    widget->setParent(group);
752
753
754
    QObject::connect(panel, SIGNAL(viewChanged(pqView*)),
      widget,SLOT(setView(pqView*)));
    widget->setView(panel->view());
Clinton Stimpson's avatar
 
Clinton Stimpson committed
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
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
    widget->resetBounds();
    widget->reset();
    
    QObject::connect(panel, SIGNAL(onselect()), widget, SLOT(select()));
    QObject::connect(panel, SIGNAL(ondeselect()), widget, SLOT(deselect()));
    QObject::connect(panel, SIGNAL(onaccept()), widget, SLOT(accept()));
    QObject::connect(panel, SIGNAL(onreset()), widget, SLOT(reset()));
    QObject::connect(widget, SIGNAL(modified()),
                     panel, SLOT(setModified()));

    group->layout()->addWidget(widget);
    panelLayout->addWidget(group, rowCount++, 0, 1, 2);

    vtkSmartPointer<vtkCollection> elements = 
      vtkSmartPointer<vtkCollection>::New();
    vtkPVXMLElement* widgetHints = widget->getHints();
    widgetHints->GetElementsByName("Property", elements);
    for (int cc=0; cc < elements->GetNumberOfItems(); ++cc)
      {
      vtkPVXMLElement* child = vtkPVXMLElement::SafeDownCast(
        elements->GetItemAsObject(cc));
      if (!child)
        {
        continue;
        }
      propertiesToHide.push_back(child->GetAttribute("name"));
      }
    }
}

//-----------------------------------------------------------------------------
static void setupValidator(QLineEdit* lineEdit, QVariant::Type type)
{
  switch (type)
    {
  case QVariant::Double:
    lineEdit->setValidator(new QDoubleValidator(lineEdit));
    break;

  case QVariant::Int:
    lineEdit->setValidator(new QIntValidator(lineEdit));
    break;

  default:
    break;
    }
}

803
//-----------------------------------------------------------------------------
804
static QLabel* createPanelLabel(QWidget* parent, QString text, QString pname)
Clinton Stimpson's avatar
 
Clinton Stimpson committed
805
806
{
  QLabel* label = new QLabel(parent);
Clinton Stimpson's avatar
 
Clinton Stimpson committed
807
  label->setObjectName(QString("_labelFor")+pname);
Clinton Stimpson's avatar
 
Clinton Stimpson committed
808
809
810
811
812
  label->setText(text);
  label->setWordWrap(true);
  return label;
}

813
//-----------------------------------------------------------------------------
814
void pqNamedWidgets::createWidgets(QGridLayout* panelLayout, vtkSMProxy* pxy, bool summaryOnly)
Clinton Stimpson's avatar
 
Clinton Stimpson committed
815
{
816
817
  bool row_streched = false; // when set, the extra setRowStretch() at the end
                             // is skipped
Clinton Stimpson's avatar
 
Clinton Stimpson committed
818
  int rowCount = 0;
Utkarsh Ayachit's avatar
ENH:  
Utkarsh Ayachit committed
819
  bool isCompoundProxy = pxy->IsA("vtkSMCompoundSourceProxy");
Clinton Stimpson's avatar
 
Clinton Stimpson committed
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

  // query for proxy properties, and create widgets
  vtkSMOrderedPropertyIterator *iter = vtkSMOrderedPropertyIterator::New();
  iter->SetProxy(pxy);

  int hasCellArrayStatus = 0;
  int hasPointArrayStatus = 0;

  // check for both CellArrayStatus & PointArrayStatus
  for(iter->Begin(); !iter->IsAtEnd(); iter->Next())
    {
    if(QString(iter->GetKey()) == QString("CellArrayStatus"))
      {
      hasCellArrayStatus = 1;
      }
    if(QString(iter->GetKey()) == QString("PointArrayStatus"))
      {
      hasPointArrayStatus = 1;
      }
    }

  int hasCellPointArrayStatus = 0;
  if(hasPointArrayStatus && hasCellArrayStatus)
    {
    hasCellPointArrayStatus = 1;
    }
  int cellPointArrayStatusWidgetAdded = 0;

  QStringList propertiesToHide;
  QStringList propertiesToShow;
850
  processHints(panelLayout, pxy, propertiesToHide, propertiesToShow, summaryOnly);
851
852
853
854
855
856
857
858
859
860

  // Skip the filename property, unless the user has indicated that the filename
  // should be shown on the property panel.
  QString filenameProperty = pqObjectBuilder::getFileNamePropertyName(pxy);
  if (!filenameProperty.isEmpty() &&
    !propertiesToShow.contains(filenameProperty))
    {
    propertiesToHide.push_back(filenameProperty);
    }

Clinton Stimpson's avatar
 
Clinton Stimpson committed
861
862
863
864
  rowCount = panelLayout->rowCount();
  for(iter->Begin(); !iter->IsAtEnd(); iter->Next())
    {
    vtkSMProperty* SMProperty = iter->GetProperty();
Clinton Stimpson's avatar
 
Clinton Stimpson committed
865
866
    bool informationOnly = SMProperty->GetInformationOnly();

Clinton Stimpson's avatar
 
Clinton Stimpson committed
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
    QString propertyName = iter->GetKey();
    if (propertiesToHide.contains(propertyName))
      {
      continue;
      }
    propertyName.replace(':', '_');

    // When this proxy represents a custom filter, we want to use the property 
    //  names the user provided rather than the built in property labels:
    QString propertyLabel;
    if(isCompoundProxy)
      {
      propertyLabel = iter->GetKey();
      }
    else
      {
      propertyLabel = SMProperty->GetXMLLabel();
      }

    // skip information properties
Clinton Stimpson's avatar
 
Clinton Stimpson committed
887
    if((!propertiesToShow.contains(propertyName) && informationOnly) || 
888
        SMProperty->GetIsInternal())
Clinton Stimpson's avatar
 
Clinton Stimpson committed
889
890
891
892
      {
      continue;
      }

893
894
    vtkPVXMLElement *hints = SMProperty->GetHints();

Clinton Stimpson's avatar
 
Clinton Stimpson committed
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
    // update domains we might ask for
    SMProperty->UpdateDependentDomains();

    pqSMAdaptor::PropertyType pt = pqSMAdaptor::getPropertyType(SMProperty);
    QList<QString> domainsTypes = pqSMAdaptor::getDomainTypes(SMProperty);

    // skip input properties
    if(pt == pqSMAdaptor::PROXY || pt == pqSMAdaptor::PROXYLIST)
      {
      if(SMProperty == pxy->GetProperty("Input"))
        {
        continue;
        }
      }

    if(pt == pqSMAdaptor::PROXY)
      {
912
      if (hints && hints->FindNestedElementByName("SelectionInput"))
Clinton Stimpson's avatar
 
Clinton Stimpson committed
913
        {
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
        // Create a widget for grabbing the current selection.
        pqSelectionInputWidget *selectWidget
          = new pqSelectionInputWidget(panelLayout->parentWidget());
        selectWidget->setObjectName(propertyName);
        panelLayout->addWidget(selectWidget, rowCount, 0, 1, -1);
        rowCount++;
        }
      else
        {
        // create a combo box with list of proxies
        QComboBox* combo = new QComboBox(panelLayout->parentWidget());
        if(informationOnly)
          {
          combo->setEnabled(false);
          }
        combo->setObjectName(propertyName);
        QLabel* label = createPanelLabel(panelLayout->parentWidget(),
                                         propertyLabel,
                                         propertyName);
        panelLayout->addWidget(label, rowCount, 0, 1, 1);
        panelLayout->addWidget(combo, rowCount, 1, 1, 1);
        rowCount++;
Clinton Stimpson's avatar
 
Clinton Stimpson committed
936
        }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
937
938
939
940
941
942
943
944
945
946
947
948
      }
    else if(pt == pqSMAdaptor::PROXYLIST)
      {
      // create a list of selections of proxies
      }
    else if (pt==pqSMAdaptor::PROXYSELECTION)
      {
      // for now, support only one level deep of proxy selections
      pqProxySelectionWidget* w = 
        new pqProxySelectionWidget(pxy, iter->GetKey(),
                                   propertyLabel,
                                   panelLayout->parentWidget());
Clinton Stimpson's avatar
 
Clinton Stimpson committed
949
950
951
952
      if(informationOnly)
        {
        w->setEnabled(false);
        }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
953
954
955
956
957
958
959
960
961
962
963
964
965
      w->setObjectName(propertyName);
      panelLayout->addWidget(w, rowCount, 0, 1, 2);
      rowCount++;
      }
    else if(pt == pqSMAdaptor::ENUMERATION)
      {
      QVariant enum_property = pqSMAdaptor::getEnumerationProperty(SMProperty);
      if(enum_property.type() == QVariant::Bool)
        {
        // check box for true/false
        QCheckBox* check;
        check = new QCheckBox(propertyLabel, 
                              panelLayout->parentWidget());
Clinton Stimpson's avatar
 
Clinton Stimpson committed
966
967
968
969
        if(informationOnly)
          {
          check->setEnabled(false);
          }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
970
971
972
973
974
975
976
977
978
979
980
981
982
        check->setObjectName(propertyName);
        panelLayout->addWidget(check, rowCount, 0, 1, 2);
        rowCount++;
        }
      else
        {
        vtkSMVectorProperty* vp = vtkSMVectorProperty::SafeDownCast(SMProperty);
        // Some enumeration properties, we add
        // ability to select mutliple elements. This is the case if the
        // SM property has repeat command flag set.
        if (vp && vp->GetRepeatCommand())
          {
          QTreeWidget* tw = new pqTreeWidget(panelLayout->parentWidget());
Clinton Stimpson's avatar
 
Clinton Stimpson committed
983
984
985
986
          if(informationOnly)
            {
            tw->setEnabled(false);
            }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
987
988
989
990
991
992
          tw->setColumnCount(1);
          tw->setRootIsDecorated(false);
          QTreeWidgetItem* h = new QTreeWidgetItem();
          h->setData(0, Qt::DisplayRole, propertyLabel);
          tw->setHeaderItem(h);
          tw->setObjectName(propertyName);
993
994
995
          pqTreeWidgetSelectionHelper* helper = 
            new pqTreeWidgetSelectionHelper(tw);
          helper->setObjectName(QString("%1Helper").arg(propertyName));
Clinton Stimpson's avatar
 
Clinton Stimpson committed
996
997
998
999
1000
1001
1002
          panelLayout->addWidget(tw, rowCount, 0, 1, 2);
          rowCount++;
          }
        else
          {
          // combo box with strings
          QComboBox* combo = new QComboBox(panelLayout->parentWidget());
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1003
1004
1005
1006
          if(informationOnly)
            {
            combo->setEnabled(false);
            }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1007
1008
          combo->setObjectName(propertyName);
          QLabel* label = createPanelLabel(panelLayout->parentWidget(),
1009
1010
                                           propertyLabel,
                                           propertyName);
Clinton Stimpson's avatar
 
Clinton Stimpson committed
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
          panelLayout->addWidget(label, rowCount, 0, 1, 1);
          panelLayout->addWidget(combo, rowCount, 1, 1, 1);
          }
        rowCount++;
        }
      }
    else if(pt == pqSMAdaptor::SELECTION)
      {
      int doIt = 1;
      QString name = propertyName;
      QString header = propertyLabel;

      if((propertyName == QString("CellArrayStatus") ||
         propertyName == QString("PointArrayStatus")) &&
         hasCellPointArrayStatus == 1)
        {
        if(cellPointArrayStatusWidgetAdded == 1)
          {
          doIt = 0;
          }
        else
          {
          cellPointArrayStatusWidgetAdded = 1;
          name = "CellAndPointArrayStatus";
          header = "Cell/Point Array Status";
          }
        }
      if(doIt)
        {
        QList<QList<QVariant> > items;
        items = pqSMAdaptor::getSelectionProperty(SMProperty);
        QTreeWidget* tw = new pqTreeWidget(panelLayout->parentWidget());
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1043
1044
1045
1046
        if(informationOnly)
          {
          tw->setEnabled(false);
          }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1047
1048
1049
1050
1051
1052
        tw->setColumnCount(1);
        tw->setRootIsDecorated(false);
        QTreeWidgetItem* h = new QTreeWidgetItem();
        h->setData(0, Qt::DisplayRole, header);
        tw->setHeaderItem(h);
        tw->setObjectName(name);
1053
        pqTreeWidgetSelectionHelper* helper =
1054
1055
          new pqTreeWidgetSelectionHelper(tw);
        helper->setObjectName(QString("%1Helper").arg(propertyName));
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
        panelLayout->addWidget(tw, rowCount, 0, 1, 2);
        rowCount++;
        }
      }
    else if(pt == pqSMAdaptor::SINGLE_ELEMENT)
      {
      QVariant elem_property = pqSMAdaptor::getElementProperty(SMProperty);
      QList<QVariant> propertyDomain;
      propertyDomain = pqSMAdaptor::getElementPropertyDomain(SMProperty);
      if(elem_property.type() == QVariant::String && propertyDomain.size())
        {
        // combo box with strings
        QComboBox* combo = new QComboBox(panelLayout->parentWidget());
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1069
1070
1071
1072
        if(informationOnly)
          {
          combo->setEnabled(false);
          }
1073
        row_streched = true;
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1074
1075
        combo->setObjectName(propertyName);
        QLabel* label = createPanelLabel(panelLayout->parentWidget(),
1076
1077
                                         propertyLabel,
                                         propertyName);
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1078
1079
1080
1081
1082
1083
        
        panelLayout->addWidget(label, rowCount, 0, 1, 1);
        panelLayout->addWidget(combo, rowCount, 1, 1, 1);
        rowCount++;
        }
      else if(elem_property.type() == QVariant::Int && 
1084
1085
              propertyDomain.size() == 2 &&
              propertyDomain[0].isValid() && propertyDomain[1].isValid())
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1086
1087
        {
        QLabel* label = createPanelLabel(panelLayout->parentWidget(),
1088
1089
                                         propertyLabel,
                                         propertyName);
1090
1091
1092

        pqIntRangeWidget* range;
        range = new pqIntRangeWidget(panelLayout->parentWidget());
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1093
1094
1095
1096
        if(informationOnly)
          {
          range->setEnabled(false);
          }
1097
1098
1099
        range->setObjectName(propertyName);
        range->setMinimum(propertyDomain[0].toInt());
        range->setMaximum(propertyDomain[1].toInt());
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1100
        panelLayout->addWidget(label, rowCount, 0, 1, 1);
1101
1102
        panelLayout->addWidget(range, rowCount, 1, 1, 1);
        range->show();
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1103
1104
1105
1106
        rowCount++;
        }
      else if(elem_property.type() == QVariant::Double && 
              propertyDomain.size() == 2 && 
1107
              propertyDomain[0].isValid() && propertyDomain[1].isValid() &&
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1108
1109
1110
              domainsTypes.contains("vtkSMDoubleRangeDomain"))
        {
        QLabel* label = createPanelLabel(panelLayout->parentWidget(),
1111
1112
                                         propertyLabel,
                                         propertyName);
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1113
1114
        pqDoubleRangeWidget* range;
        range = new pqDoubleRangeWidget(panelLayout->parentWidget());
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1115
1116
1117
1118
        if(informationOnly)
          {
          range->setEnabled(false);
          }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
        range->setObjectName(propertyName);
        range->setMinimum(propertyDomain[0].toDouble());
        range->setMaximum(propertyDomain[1].toDouble());

        panelLayout->addWidget(label, rowCount, 0, 1, 1);
        panelLayout->addWidget(range, rowCount, 1, 1, 1);
        rowCount++;
        }
      else
        {
        //  what entry widget we should use for a stringvectorproperty
        bool multiLineString = false;
        if (hints)
          {
          vtkPVXMLElement* widgetHint = hints->FindNestedElementByName("Widget");
          if (widgetHint)
            {
            if (widgetHint->GetAttribute("type") &&
                strcmp(widgetHint->GetAttribute("type"), "multi_line") == 0)
              {
              multiLineString = true;
              }
            }
          }

        if (!multiLineString)
          {
          QLineEdit* lineEdit = new QLineEdit(panelLayout->parentWidget());
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1147
1148
1149
1150
          if(informationOnly)
            {
            lineEdit->setEnabled(false);
            }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1151
1152
1153
1154
          lineEdit->setObjectName(propertyName);
          setupValidator(lineEdit, elem_property.type()); 
          
          QLabel* label = createPanelLabel(panelLayout->parentWidget(),
1155
1156
                                           propertyLabel,
                                           propertyName);
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1157
1158
1159
1160
1161
1162
1163
1164
          
          panelLayout->addWidget(label, rowCount, 0, 1, 1);
          panelLayout->addWidget(lineEdit, rowCount, 1, 1, 1);
          rowCount++;
          }
        else
          {
          QTextEdit *textEdit = new QTextEdit(panelLayout->parentWidget());
1165
1166
          QFont textFont("Courier");
          textEdit->setFont(textFont);
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1167
1168
1169
1170
          if(informationOnly)
            {
            textEdit->setEnabled(false);
            }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1171
1172
1173
1174
1175
1176
1177
1178
          textEdit->setObjectName(propertyName);
          textEdit->setAcceptRichText(false);
          // The default tab stop is too big
          textEdit->setTabStopWidth(textEdit->tabStopWidth()/4);
          // We don't want line wrap when editing, for example, a python script
          textEdit->setLineWrapMode(QTextEdit::NoWrap);
          
          QLabel* label = createPanelLabel(panelLayout->parentWidget(),
1179
1180
                                           QString(propertyLabel)+":",
                                           propertyName);
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1181
1182
1183
1184
1185
1186
          
          panelLayout->addWidget(label, rowCount, 0, 1, 2);
          rowCount++;

          panelLayout->addWidget(textEdit, rowCount, 0, 1, 2);
          panelLayout->setRowStretch(rowCount, 1);
1187
          row_streched = true;
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
          rowCount++;
          }
        }
      }
    else if(pt == pqSMAdaptor::MULTIPLE_ELEMENTS)
      {
      QList<QVariant> list_property;
      list_property = pqSMAdaptor::getMultipleElementProperty(SMProperty);
      QList<QList<QVariant> > domain;
      domain = pqSMAdaptor::getMultipleElementPropertyDomain(SMProperty);
      
      QLabel* label = createPanelLabel(panelLayout->parentWidget(),
1200
1201
                                       propertyLabel,
                                       propertyName);
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1202
1203
      panelLayout->addWidget(label, rowCount, 0, 1, 1);
      QGridLayout* glayout = new QGridLayout;
1204
      glayout->setSpacing(0);
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
      glayout->setObjectName(propertyName);
      panelLayout->addLayout(glayout, rowCount, 1, 1, 1);

      // we have a few different layouts
      static const int LayoutThreeByTwo = 0;
      static const int LayoutRow = 1;
      static const int LayoutColumn = 2;

      // let's peek at what property types and domains we have to determine
      // which layout to use
      int layoutMethod = LayoutRow;
      if(list_property.size() == 6)
        {
        layoutMethod = LayoutThreeByTwo;
        }
      else if(list_property.size() > 3)  // that many won't fit in a row
        {
        layoutMethod = LayoutColumn;
        }

      int i=0;
      foreach(QVariant v, list_property)
        {
        QLayoutItem* item = NULL;

        // create the widget(s)
        if( 0 /*v.type() == QVariant::String && 
           domain.size() && domain[i].size() */)  // link not supported yet
          {
          QComboBox* combo = new QComboBox(panelLayout->parentWidget());
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1235
1236
1237
1238
          if(informationOnly)
            {
            combo->setEnabled(false);
            }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1239
1240
1241
1242
          combo->setObjectName(QString("%1_%2").arg(propertyName).arg(i));
          item = new QWidgetItem(combo);
          }
        else if(v.type() == QVariant::Int && 
1243
1244
           domain.size() && domain[i].size() == 2 &&
           domain[i][0].isValid() && domain[i][1].isValid())
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1245
1246
1247
1248
1249
1250
          {
          int range[2];
          range[0] = domain[i][0].toInt();
          range[1] = domain[i][1].toInt();
          QSpinBox* spinBox;
          spinBox = new QSpinBox(panelLayout->parentWidget());
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1251
1252
1253
1254
          if(informationOnly)
            {
            spinBox->setEnabled(false);
            }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1255
1256
1257
1258
1259
          spinBox->setObjectName(QString("%1_%2").arg(propertyName).arg(i));
          spinBox->setRange(range[0], range[1]);
          item = new QWidgetItem(spinBox);
          }
        else if(v.type() == QVariant::Double && 
1260
1261
                domain.size() && domain[i].size() == 2 &&
                domain[i][0].isValid() && domain[i][1].isValid())
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1262
1263
1264
          {
          pqDoubleRangeWidget* range;
          range = new pqDoubleRangeWidget(panelLayout->parentWidget());
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1265
1266
1267
1268
          if(informationOnly)
            {
            range->setEnabled(false);
            }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1269
1270
1271
1272
1273
1274
1275
1276
          range->setObjectName(QString("%1_%2").arg(propertyName).arg(i));
          range->setMinimum(domain[i][0].toDouble());
          range->setMaximum(domain[i][1].toDouble());
          item = new QWidgetItem(range);
          }
        else
          {
          QLineEdit* lineEdit = new QLineEdit(panelLayout->parentWidget());
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1277
1278
1279
1280
          if(informationOnly)
            {
            lineEdit->setEnabled(false);
            }
Clinton Stimpson's avatar
 
Clinton Stimpson committed
1281
1282
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