Developer documentation | Axl-2.5.1

axlInspectorObjectSceneWidgetFieldScalar.cpp
Go to the documentation of this file.
1 /* axlInspectorObjectSceneWidgetFieldScalar.cpp ---
2  *
3  * Author: Julien Wintz
4  * Copyright (C) 2008 - Julien Wintz, Inria.
5  * Created: Fri Dec 17 22:48:33 2010 (+0100)
6  * Version: $Id$
7  * Last-Updated: Wed Jul 20 22:18:05 2011 (+0200)
8  * By: Julien Wintz
9  * Update #: 100
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 
23 
26 
27 #include <dtkCoreSupport/dtkGlobal.h>
28 
29 #include <QtGui>
30 
31 class axlInspectorObjectSceneWidgetFieldScalarPrivate
32 {
33 public:
34  axlAbstractField *field;
37  axlAbstractView *view;
38 
39 public:
40  QPushButton *disp_non_button;
41  QPushButton *disp_col_button;
42  QPushButton *disp_iso_button;
43 
44  QVBoxLayout *layout;
45 };
46 
47 axlInspectorObjectSceneWidgetFieldScalar::axlInspectorObjectSceneWidgetFieldScalar(QWidget *parent) : QWidget(parent), d(new axlInspectorObjectSceneWidgetFieldScalarPrivate)
48 {
49  d->field = NULL;
50  d->col = NULL;
51  d->iso = NULL;
52  d->view = NULL;
53 
54  d->disp_col_button = new QPushButton("Color mapping");
55  d->disp_col_button->setCheckable(true);
56  d->disp_col_button->setChecked(false);
57  d->disp_col_button->setObjectName("left");
58 
59  d->disp_iso_button = new QPushButton("Iso contours");
60  d->disp_iso_button->setCheckable(true);
61  d->disp_iso_button->setChecked(false);
62  d->disp_iso_button->setObjectName("right");
63 
64 
65  d->disp_non_button = new QPushButton("Nothing");
66  d->disp_non_button->setCheckable(true);
67  d->disp_non_button->setChecked(false);
68  d->disp_non_button->setObjectName("overleft");
69 
70  QHBoxLayout *disp_layout = new QHBoxLayout;
71  disp_layout->setContentsMargins(0, 0, 0, 0);
72  disp_layout->setSpacing(0);
73  disp_layout->addWidget(d->disp_non_button);
74  disp_layout->addSpacerItem(new QSpacerItem(10, 1));
75  disp_layout->addWidget(d->disp_col_button);
76  disp_layout->addSpacerItem(new QSpacerItem(10, 1));
77  disp_layout->addWidget(d->disp_iso_button);
78 
79  d->layout = new QVBoxLayout(this);
80  d->layout->setContentsMargins(0, 0, 0, 0);
81  d->layout->addWidget(new QLabel("Display", this));
82  d->layout->addLayout(disp_layout);
83 
84  connect(d->disp_col_button, SIGNAL(clicked()), this, SLOT(onDisplayAsColorClicked()));
85  connect(d->disp_iso_button, SIGNAL(clicked()), this, SLOT(onDisplayAsIsoClicked()));
86  connect(d->disp_non_button, SIGNAL(clicked()), this, SLOT(onDisplayAsNothingClicked()));
87 
88 
89 }
90 
92 {
93  delete d;
94 
95  d = NULL;
96 }
97 
99 {
100  if (d->iso)
101  d->iso->setCount(count);
102 }
103 
105 {
106  if (d->iso)
107  d->iso->setMin(min);
108 }
109 
111 {
112  if (d->iso)
113  d->iso->setMax(max);
114 }
115 
117 {
118  d->field = field;
119 }
120 
122 {
123  d->view = view;
124 }
125 
127 {
128  this->onDisplayAsColorClicked();
129 }
130 
132 {
133  if (!d->disp_non_button->isChecked())
134  return;
135 
136  d->disp_non_button->setChecked(true);
137  d->disp_col_button->setChecked(false);
138  d->disp_iso_button->setChecked(false);
139 
140  if (d->col) {
141  d->layout->removeWidget(d->col);
142  delete d->col;
143  d->col = NULL;
144  }
145 
146  if (d->iso) {
147  d->layout->removeWidget(d->iso);
148  delete d->iso;
149  d->iso = NULL;
150  }
151 
152  emit displayAsNone();
153 }
154 
156 {
157 
158  if (!d->disp_col_button->isChecked())
159  return;
160 
161  d->disp_non_button->setChecked(false);
162  d->disp_col_button->setChecked(true);
163  d->disp_iso_button->setChecked(false);
164 
165  if (d->col) {
166  d->layout->removeWidget(d->col);
167  delete d->col;
168  d->col = NULL;
169  }
170 
171  if (d->iso) {
172  d->layout->removeWidget(d->iso);
173  delete d->iso;
174  d->iso = NULL;
175  }
176 
178  d->col->setField(d->field);
179  d->col->setView(d->view);
180 
181  connect(d->col, SIGNAL(colRangeMinChanged(double)), this, SIGNAL(colRangeMinChanged(double)));
182  connect(d->col, SIGNAL(colRangeMaxChanged(double)), this, SIGNAL(colRangeMaxChanged(double)));
183 
184  d->layout->addWidget(d->col);
185 
186  emit displayAsColor();
187 }
188 
190 {
191  if (!d->disp_iso_button->isChecked())
192  return;
193 
194  d->disp_non_button->setChecked(false);
195  d->disp_col_button->setChecked(false);
196  d->disp_iso_button->setChecked(true);
197 
198  if (d->col) {
199  d->layout->removeWidget(d->col);
200  delete d->col;
201  d->col = NULL;
202  }
203 
204  if (d->iso) {
205  d->layout->removeWidget(d->iso);
206  delete d->iso;
207  d->iso = NULL;
208  }
209 
211  d->iso->setField(d->field);
212  d->iso->setView(d->view);
213 
214  connect(d->iso, SIGNAL(isoCountChanged(int)), this, SIGNAL(isoCountChanged(int)));
215  connect(d->iso, SIGNAL(isoRadiusChanged(double)), this, SIGNAL(isoRadiusChanged(double)));
216  connect(d->iso, SIGNAL(isoRangeMinChanged(double)), this, SIGNAL(isoRangeMinChanged(double)));
217  connect(d->iso, SIGNAL(isoRangeMaxChanged(double)), this, SIGNAL(isoRangeMaxChanged(double)));
218 
219  d->layout->addWidget(d->iso);
220 
221  emit displayAsIso();
222 }
Class axlAbstractField defines an API for arrays of numeric data.