Developer documentation | Axl-2.5.1

axlInspectorUtils.h
Go to the documentation of this file.
1 /* axlInspectorUtils.h ---
2  *
3  * Author: Meriadeg Perrinel
4  * Copyright (C) 2008 - Meriadeg Perrinel, Inria.
5  * Created: Tue Nov 9 16:58:59 2010 (+0100)
6  * Version: $Id$
7  * Last-Updated: Tue Nov 9 17:09:38 2010 (+0100)
8  * By: Meriadeg Perrinel
9  * Update #: 19
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 
20 #ifndef AXLINSPECTORUTILS_H
21 #define AXLINSPECTORUTILS_H
22 
23 #include "axlGuiExport.h"
24 #include <QtCore>
25 
26 #define AXL_PROPERTY_COLOR 0
27 #define AXL_PROPERTY_OPACITY 1
28 #define AXL_PROPERTY_SHADER 2
29 #define AXL_PROPERTY_SIZE 3
30 
31 bool AXLGUI_EXPORT caseInsensitiveLessThan(const QString &s1, const QString &s2);
32 
33 #ifndef addColorButton
34 #define addColorButton(layoutTop, colorButton, slot, init)\
35  colorButton = new dtkColorButton(this);\
36  QHBoxLayout *layoutColorButton = new QHBoxLayout;\
37  layoutColorButton->addWidget(new QLabel("Color",this));\
38  layoutColorButton->addWidget(colorButton);\
39  colorButton->setColor(this->initColorValue());\
40  layoutTop->addLayout(layoutColorButton);\
41  connect(colorButton, SIGNAL(colorChanged(QColor)), this, SLOT(slot (QColor)));
42 #endif
43 
44 #ifndef addSizeSlider
45 #define addSizeSlider(layoutTop, sliderSize, slot, init)\
46  sliderSize = new QSlider(Qt::Horizontal, this);\
47  QHBoxLayout *layoutSize = new QHBoxLayout;\
48  layoutSize->addWidget(new QLabel("Size",this));\
49  layoutSize->addWidget(sliderSize);\
50  sliderSize->setMinimum(-800);\
51  sliderSize->setMaximum(500);\
52  sliderSize->setValue(init);\
53  layoutTop->addLayout(layoutSize);\
54  connect(sliderSize, SIGNAL(valueChanged(int)), this, SLOT(slot (int)));
55 #endif
56 
57 #ifndef addOpacitySlider
58 #define addOpacitySlider(layoutTop, sliderOpacity, slot, init)\
59  sliderOpacity = new QSlider(Qt::Horizontal, this);\
60  sliderOpacity->setMaximum(100);\
61  sliderOpacity->setValue(init);\
62  QHBoxLayout *layoutOpacity = new QHBoxLayout;\
63  layoutOpacity->addWidget(new QLabel("Opacity", this));\
64  layoutOpacity->addWidget(sliderOpacity);\
65  layoutTop->addLayout(layoutOpacity);\
66  connect(sliderOpacity, SIGNAL(valueChanged(int)), this, SLOT(slot (int)));
67 #endif
68 
69 #ifndef addShaderComboBox
70 #define addShaderComboBox(layoutTop, comboBoxShader, checkBoxShader, lineEditShader, buttonShader,\
71  onComboBoxChanged, onCheckBoxChanged, onTextChanged, openShader, init)\
72  comboBoxShader = new QComboBox(this);\
73  comboBoxShader->setInsertPolicy(QComboBox::InsertAlphabetically);\
74  checkBoxShader = new QCheckBox(this);\
75  lineEditShader = new QLineEdit(this);\
76  buttonShader = new QPushButton(this);\
77  buttonShader->setText("open");\
78  lineEditShader->setText(init);\
79  this->initComboBoxShaderValue(comboBoxShader,lineEditShader);\
80  if(lineEditShader->text().isEmpty())\
81  {\
82  lineEditShader->setEnabled(false);\
83  buttonShader->setEnabled(false);\
84  comboBoxShader->setEnabled(false);\
85  }\
86  else\
87  checkBoxShader->setChecked(true);\
88  \
89  QVBoxLayout *layoutShader = new QVBoxLayout;\
90  QHBoxLayout *layoutShader1 = new QHBoxLayout;\
91  \
92  QLabel *labelShader = new QLabel("Shader",this);\
93  layoutShader1->addWidget(labelShader);\
94  layoutShader1->addWidget(checkBoxShader);\
95  layoutShader1->addWidget(comboBoxShader);\
96  layoutShader1->addWidget(buttonShader);\
97  \
98  layoutShader1->setStretchFactor(labelShader, 2);\
99  layoutShader1->setStretchFactor(checkBoxShader, 1);\
100  layoutShader1->setStretchFactor(comboBoxShader, 4);\
101  layoutShader1->setStretchFactor(buttonShader, 3);\
102  \
103  layoutShader->addLayout(layoutShader1);\
104  layoutShader->addWidget(lineEditShader);\
105  layoutTop->addLayout(layoutShader);\
106  connect(comboBoxShader, SIGNAL(currentIndexChanged(QString)), this, SLOT(onComboBoxChanged (QString)));\
107  connect(checkBoxShader, SIGNAL(clicked(bool)), this, SLOT(onCheckBoxChanged (bool)));\
108  connect(buttonShader, SIGNAL(clicked()), this, SLOT(openShader ()));\
109  connect(lineEditShader, SIGNAL(textChanged(QString)), this, SLOT(onTextChanged (QString)));
110 #endif
111 
112 #ifndef addPointLayout
113 #define addPointLayout(layoutTop, name, title, coordinatePoint, slot, init)\
114  coordinatePoint##_x = new QDoubleSpinBox(this);\
115  coordinatePoint##_x->setRange(-1000, 1000);\
116  coordinatePoint##_x->setValue(init->x());\
117  coordinatePoint##_x->setSingleStep(0.1);\
118  \
119  coordinatePoint##_y = new QDoubleSpinBox(this);\
120  coordinatePoint##_y->setRange(-1000, 1000);\
121  coordinatePoint##_y->setValue(init->y());\
122  coordinatePoint##_y->setSingleStep(0.1);\
123  \
124  coordinatePoint##_z = new QDoubleSpinBox(this);\
125  coordinatePoint##_z->setRange(-1000, 1000);\
126  coordinatePoint##_z->setValue(init->z());\
127  coordinatePoint##_z->setSingleStep(0.1);\
128  \
129  QHBoxLayout * name##LayoutCoordinate_x = new QHBoxLayout;\
130  name##LayoutCoordinate_x->addWidget(new QLabel("X",this));\
131  name##LayoutCoordinate_x->addWidget(coordinatePoint##_x);\
132  \
133  QHBoxLayout *name##LayoutCoordinate_y = new QHBoxLayout;\
134  name##LayoutCoordinate_y->addWidget(new QLabel("Y",this));\
135  name##LayoutCoordinate_y->addWidget(coordinatePoint##_y);\
136  \
137  QHBoxLayout *name##LayoutCoordinate_z = new QHBoxLayout;\
138  name##LayoutCoordinate_z->addWidget(new QLabel("Z",this));\
139  name##LayoutCoordinate_z->addWidget(coordinatePoint##_z);\
140  \
141  layoutTop->addWidget(new QLabel(title,this));\
142  layoutTop->addLayout(name##LayoutCoordinate_x);\
143  layoutTop->addLayout(name##LayoutCoordinate_y);\
144  layoutTop->addLayout(name##LayoutCoordinate_z);\
145  \
146  connect(coordinatePoint##_x, SIGNAL(valueChanged(double)), this, SLOT(slot##_x (double)));\
147  connect(coordinatePoint##_y, SIGNAL(valueChanged(double)), this, SLOT(slot##_y (double)));\
148  connect(coordinatePoint##_z, SIGNAL(valueChanged(double)), this, SLOT(slot##_z (double)));
149 
150 #endif
151 
152 #ifndef addValueLayout
153 #define addValueLayout(layoutTop, name, title, data, slot, init)\
154  \
155  data = new QDoubleSpinBox(this);\
156  data->setValue(init);\
157  data->setSingleStep(0.1);\
158  \
159  QHBoxLayout* name##Layout = new QHBoxLayout;\
160  name##Layout->addWidget(new QLabel(title,this));\
161  name##Layout->addWidget(data);\
162  data->setValue(init);\
163  layoutTop->addLayout(name##Layout);\
164  connect(data, SIGNAL(valueChanged(double)), this, SLOT(slot (double)));
165 
166 #endif
167 
168 #endif // AXLINSPECTORUTILS_H
#define AXLGUI_EXPORT
Definition: axlGuiExport2.h:15
bool AXLGUI_EXPORT caseInsensitiveLessThan(const QString &s1, const QString &s2)