Developer documentation | Axl-2.5.1

axlInspectorObjectSceneWidgetFieldScalarCol.cpp
Go to the documentation of this file.
1 /* axlInspectorObjectSceneWidgetFieldScalarCol.cpp ---
2  *
3  * Author: Thibaud Kloczko
4  * Copyright (C) 2011 - Thibaud Kloczko, Inria.
5  * Created: Mon Jun 20 14:16:20 2011 (+0200)
6  * Version: $Id$
7  * Last-Updated: Wed Jul 20 22:11:34 2011 (+0200)
8  * By: Julien Wintz
9  * Update #: 18
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 
21 
25 
26 #include <dtkCoreSupport/dtkGlobal.h>
27 
28 #include <QtGui>
29 
30 class axlInspectorObjectSceneWidgetFieldScalarColPrivate
31 {
32 public:
33  axlAbstractField *field;
34  axlAbstractView *view;
35 
36 public:
37  QSpinBox *col_count_spin;
38  QDoubleSpinBox *col_range_min_spin;
39  QDoubleSpinBox *col_range_max_spin;
40  QPushButton *button_reset_min;
41  QPushButton *button_reset_max;
42 };
43 
44 axlInspectorObjectSceneWidgetFieldScalarCol::axlInspectorObjectSceneWidgetFieldScalarCol(QWidget *parent) : QWidget(parent), d(new axlInspectorObjectSceneWidgetFieldScalarColPrivate)
45 {
46  d->field = NULL;
47  d->view = NULL;
48 
49  QWidget *col_form = new QWidget(this);
50  col_form->setObjectName("axlInspectorObjectSceneWidgetFieldScalarColForm");
51 
52  QWidget *col_form_range_min = new QWidget(col_form);
53  QWidget *col_form_range_max = new QWidget(col_form);
54 
55  d->col_range_min_spin = new QDoubleSpinBox(col_form);
56  d->col_range_min_spin->setDecimals(6);
57  d->col_range_min_spin->setMinimum(-1.e6);
58  d->col_range_min_spin->setMaximum(1.e6);
59 
60  d->col_range_max_spin = new QDoubleSpinBox(col_form);
61  d->col_range_max_spin->setDecimals(6);
62  d->col_range_max_spin->setMinimum(-1.e6);
63  d->col_range_max_spin->setMaximum(1.e6);
64 
65  d->button_reset_min = new QPushButton("reset", col_form);
66  d->button_reset_max = new QPushButton("reset", col_form);
67 
68  QHBoxLayout *col_form_range_min_layout = new QHBoxLayout(col_form_range_min);
69  col_form_range_min_layout->setContentsMargins(0, 0, 0, 0);
70  col_form_range_min_layout->addWidget(d->col_range_min_spin);
71  col_form_range_min_layout->addWidget(d->button_reset_min);
72 
73  QHBoxLayout *col_form_range_max_layout = new QHBoxLayout(col_form_range_max);
74  col_form_range_max_layout->setContentsMargins(0, 0, 0, 0);
75  col_form_range_max_layout->addWidget(d->col_range_max_spin);
76  col_form_range_max_layout->addWidget(d->button_reset_max);
77 
78  QFormLayout *col_form_layout = new QFormLayout(col_form);
79  col_form_layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
80  col_form_layout->setContentsMargins(0, 0, 0, 0);
81  col_form_layout->addRow(new QLabel("Range", this));
82  col_form_layout->addRow("Minimum value:", col_form_range_min);
83  col_form_layout->addRow("Maximum value:", col_form_range_max);
84 
85  QVBoxLayout *layout = new QVBoxLayout(this);
86  layout->setContentsMargins(0, 0, 0, 0);
87  layout->addWidget(col_form);
88 
89 
90  connect(d->col_range_min_spin, SIGNAL(valueChanged(double)), this, SIGNAL(colRangeMinChanged(double)));
91  connect(d->button_reset_min, SIGNAL(clicked()), this, SLOT(onResetMinimalValueClicked()));
92  connect(d->col_range_max_spin, SIGNAL(valueChanged(double)), this, SIGNAL(colRangeMaxChanged(double)));
93  connect(d->button_reset_max, SIGNAL(clicked()), this, SLOT(onResetMaximalValueClicked()));
94 }
95 
97 {
98  delete d;
99 
100  d = NULL;
101 }
102 
104 {
105  d->col_range_min_spin->setValue(min);
106 }
107 
109 {
110  d->col_range_max_spin->setValue(max);
111 }
112 
114 {
115  d->field = field;
116 
117  if(!d->view)
118  return;
119 
120  if(axlAbstractActorField *actor = dynamic_cast<axlAbstractActorField *>(d->view->actor(d->field))) {
121  this->setMax(actor->colRangeMax());
122  this->setMin(actor->colRangeMin());
123  }
124 }
125 
127 {
128  d->view = view;
129 
130  if(!d->field)
131  return;
132 
133  if(axlAbstractActorField *actor = dynamic_cast<axlAbstractActorField *>(d->view->actor(d->field))) {
134  this->setMax(actor->colRangeMax());
135  this->setMin(actor->colRangeMin());
136  }
137 }
138 
140 {
141  this->setMin(d->field->minValue());
142 }
143 
145 {
146  this->setMax(d->field->maxValue());
147 }
Class axlAbstractField defines an API for arrays of numeric data.