Vuo  2.0.3
VuoDetailsEditorPoint.cc
Go to the documentation of this file.
1 
10 #include "VuoDetailsEditorPoint.hh"
12 #include "VuoRendererFonts.hh"
13 #include "VuoType.hh"
14 
20  QWidget(parent)
21 {
22  this->type = type;
23 }
24 
28 json_object * VuoDetailsEditorPoint::show(QPoint portLeftCenter, json_object *originalDetails)
29 {
30  json_object *o = NULL;
31 
32  bool isDark = false;
33  if (json_object_object_get_ex(originalDetails, "isDark", &o))
34  isDark = json_object_get_boolean(o);
35 
36  VuoDialogForInputEditor dialog(isDark, false);
37  dialog.setFont(getDefaultFont());
38  setUpDialog(dialog, originalDetails);
39 
40  // Move children to account for margins.
41  QMargins margin = dialog.getPopoverContentsMargins();
42  QPoint topLeftMargin = QPoint(margin.left(),margin.top());
43  foreach (QObject *widget, dialog.children())
44  static_cast<QWidget *>(widget)->move(static_cast<QWidget *>(widget)->pos() + topLeftMargin);
45 
46  // Resize dialog to enclose child widgets and margins.
47  dialog.resize(margin.left() + dialog.childrenRect().width() + margin.right(), margin.top() + dialog.childrenRect().height() + margin.bottom());
48 
49  // Position the right center of the dialog at the left center of the port.
50  QPoint dialogTopLeft = portLeftCenter - QPoint(dialog.width() - margin.right(), dialog.height()/2.);
51  dialog.move(dialogTopLeft);
52 
53  dialog.show(); // Needed to position the dialog. (https://bugreports.qt-project.org/browse/QTBUG-31406)
54  dialog.exec();
55 
56  return (dialog.result() == QDialog::Accepted ? getAcceptedValue() : originalDetails);
57 }
58 
62 void VuoDetailsEditorPoint::setUpDialog(QDialog &dialog, json_object *originalDetails)
63 {
64  // See https://b33p.net/kosada/node/5724
65  const int decimalPrecision = 6;
66 
67  QValidator *validator = static_cast<QValidator *>(new QDoubleValidator(NULL));
68 
69  json_object *suggestedMinValue = NULL;
70  json_object *suggestedMaxValue = NULL;
71  json_object *suggestedStepValue = NULL;
72 
73  // Parse supported port annotations from the port's "details" JSON object:
74  if (originalDetails)
75  {
76  // "suggestedMin"
77  json_object_object_get_ex(originalDetails, "suggestedMin", &suggestedMinValue);
78 
79  // "suggestedMax"
80  json_object_object_get_ex(originalDetails, "suggestedMax", &suggestedMaxValue);
81 
82  // "suggestedStep"
83  json_object_object_get_ex(originalDetails, "suggestedStep", &suggestedStepValue);
84  }
85 
86  // Layout details
87  const int widgetVerticalSpacing = 10;
88  const int widgetHorizontalSpacing = 8;
89 
90  labelForDetail[suggestedMinX] = new QLabel(&dialog);
91  labelForDetail[suggestedMinX]->setText(tr("X Suggested Min"));
92  labelForDetail[suggestedMinX]->adjustSize();
93 
94  labelForDetail[suggestedMaxX] = new QLabel(&dialog);
95  labelForDetail[suggestedMaxX]->setText(tr("X Suggested Max"));
96  labelForDetail[suggestedMaxX]->adjustSize();
97 
98  labelForDetail[suggestedStepX] = new QLabel(&dialog);
99  labelForDetail[suggestedStepX]->setText(tr("X Suggested Step"));
100  labelForDetail[suggestedStepX]->adjustSize();
101 
102  labelForDetail[suggestedMinY] = new QLabel(&dialog);
103  labelForDetail[suggestedMinY]->setText(tr("Y Suggested Min"));
104  labelForDetail[suggestedMinY]->adjustSize();
105 
106  labelForDetail[suggestedMaxY] = new QLabel(&dialog);
107  labelForDetail[suggestedMaxY]->setText(tr("Y Suggested Max"));
108  labelForDetail[suggestedMaxY]->adjustSize();
109 
110  labelForDetail[suggestedStepY] = new QLabel(&dialog);
111  labelForDetail[suggestedStepY]->setText(tr("Y Suggested Step"));
112  labelForDetail[suggestedStepY]->adjustSize();
113 
114  labelForDetail[suggestedMinZ] = new QLabel(&dialog);
115  labelForDetail[suggestedMinZ]->setText(tr("Z Suggested Min"));
116  labelForDetail[suggestedMinZ]->adjustSize();
117 
118  labelForDetail[suggestedMaxZ] = new QLabel(&dialog);
119  labelForDetail[suggestedMaxZ]->setText(tr("Z Suggested Max"));
120  labelForDetail[suggestedMaxZ]->adjustSize();
121 
122  labelForDetail[suggestedStepZ] = new QLabel(&dialog);
123  labelForDetail[suggestedStepZ]->setText(tr("Z Suggested Step"));
124  labelForDetail[suggestedStepZ]->adjustSize();
125 
126  labelForDetail[suggestedMinW] = new QLabel(&dialog);
127  labelForDetail[suggestedMinW]->setText(tr("W Suggested Min"));
128  labelForDetail[suggestedMinW]->adjustSize();
129 
130  labelForDetail[suggestedMaxW] = new QLabel(&dialog);
131  labelForDetail[suggestedMaxW]->setText(tr("W Suggested Max"));
132  labelForDetail[suggestedMaxW]->adjustSize();
133 
134  labelForDetail[suggestedStepW] = new QLabel(&dialog);
135  labelForDetail[suggestedStepW]->setText(tr("W Suggested Step"));
136  labelForDetail[suggestedStepW]->adjustSize();
137 
138  if (dynamic_cast<QDoubleValidator *>(validator))
139  static_cast<QDoubleValidator *>(validator)->setDecimals(decimalPrecision);
140 
141  // Setup of X line edits
142  lineEditForDetail[suggestedMinX] = new QLineEdit(&dialog);
143  lineEditForDetail[suggestedMinX]->setValidator(validator);
144  lineEditForDetail[suggestedMaxX] = new QLineEdit(&dialog);
145  lineEditForDetail[suggestedMaxX]->setValidator(validator);
146  lineEditForDetail[suggestedStepX] = new QLineEdit(&dialog);
147  lineEditForDetail[suggestedStepX]->setValidator(validator);
148 
149  // Setup of Y line edits
150  lineEditForDetail[suggestedMinY] = new QLineEdit(&dialog);
151  lineEditForDetail[suggestedMinY]->setValidator(validator);
152  lineEditForDetail[suggestedMaxY] = new QLineEdit(&dialog);
153  lineEditForDetail[suggestedMaxY]->setValidator(validator);
154  lineEditForDetail[suggestedStepY] = new QLineEdit(&dialog);
155  lineEditForDetail[suggestedStepY]->setValidator(validator);
156 
157  // Setup of Z line edits
158  lineEditForDetail[suggestedMinZ] = new QLineEdit(&dialog);
159  lineEditForDetail[suggestedMinZ]->setValidator(validator);
160  lineEditForDetail[suggestedMaxZ] = new QLineEdit(&dialog);
161  lineEditForDetail[suggestedMaxZ]->setValidator(validator);
162  lineEditForDetail[suggestedStepZ] = new QLineEdit(&dialog);
163  lineEditForDetail[suggestedStepZ]->setValidator(validator);
164 
165  // Setup of W line edits
166  lineEditForDetail[suggestedMinW] = new QLineEdit(&dialog);
167  lineEditForDetail[suggestedMinW]->setValidator(validator);
168  lineEditForDetail[suggestedMaxW] = new QLineEdit(&dialog);
169  lineEditForDetail[suggestedMaxW]->setValidator(validator);
170  lineEditForDetail[suggestedStepW] = new QLineEdit(&dialog);
171  lineEditForDetail[suggestedStepW]->setValidator(validator);
172 
173  if (this->type->getModuleKey() == "VuoPoint2d")
174  {
175  setUpLineEdit(lineEditForDetail[suggestedMinX], VuoPoint2d_makeFromJson(suggestedMinValue).x, suggestedMinValue);
176  setUpLineEdit(lineEditForDetail[suggestedMaxX], VuoPoint2d_makeFromJson(suggestedMaxValue).x, suggestedMaxValue);
177  setUpLineEdit(lineEditForDetail[suggestedStepX], VuoPoint2d_makeFromJson(suggestedStepValue).x, suggestedStepValue);
178 
179  setUpLineEdit(lineEditForDetail[suggestedMinY], VuoPoint2d_makeFromJson(suggestedMinValue).y, suggestedMinValue);
180  setUpLineEdit(lineEditForDetail[suggestedMaxY], VuoPoint2d_makeFromJson(suggestedMaxValue).y, suggestedMaxValue);
181  setUpLineEdit(lineEditForDetail[suggestedStepY], VuoPoint2d_makeFromJson(suggestedStepValue).y, suggestedStepValue);
182  }
183  else if (this->type->getModuleKey() == "VuoPoint3d")
184  {
185  setUpLineEdit(lineEditForDetail[suggestedMinX], VuoPoint3d_makeFromJson(suggestedMinValue).x, suggestedMinValue);
186  setUpLineEdit(lineEditForDetail[suggestedMaxX], VuoPoint3d_makeFromJson(suggestedMaxValue).x, suggestedMaxValue);
187  setUpLineEdit(lineEditForDetail[suggestedStepX], VuoPoint3d_makeFromJson(suggestedStepValue).x, suggestedStepValue);
188 
189  setUpLineEdit(lineEditForDetail[suggestedMinY], VuoPoint3d_makeFromJson(suggestedMinValue).y, suggestedMinValue);
190  setUpLineEdit(lineEditForDetail[suggestedMaxY], VuoPoint3d_makeFromJson(suggestedMaxValue).y, suggestedMaxValue);
191  setUpLineEdit(lineEditForDetail[suggestedStepY], VuoPoint3d_makeFromJson(suggestedStepValue).y, suggestedStepValue);
192 
193  setUpLineEdit(lineEditForDetail[suggestedMinZ], VuoPoint3d_makeFromJson(suggestedMinValue).z, suggestedMinValue);
194  setUpLineEdit(lineEditForDetail[suggestedMaxZ], VuoPoint3d_makeFromJson(suggestedMaxValue).z, suggestedMaxValue);
195  setUpLineEdit(lineEditForDetail[suggestedStepZ], VuoPoint3d_makeFromJson(suggestedStepValue).z, suggestedStepValue);
196  }
197  else if (this->type->getModuleKey() == "VuoPoint4d")
198  {
199  setUpLineEdit(lineEditForDetail[suggestedMinX], VuoPoint4d_makeFromJson(suggestedMinValue).x, suggestedMinValue);
200  setUpLineEdit(lineEditForDetail[suggestedMaxX], VuoPoint4d_makeFromJson(suggestedMaxValue).x, suggestedMaxValue);
201  setUpLineEdit(lineEditForDetail[suggestedStepX], VuoPoint4d_makeFromJson(suggestedStepValue).x, suggestedStepValue);
202 
203  setUpLineEdit(lineEditForDetail[suggestedMinY], VuoPoint4d_makeFromJson(suggestedMinValue).y, suggestedMinValue);
204  setUpLineEdit(lineEditForDetail[suggestedMaxY], VuoPoint4d_makeFromJson(suggestedMaxValue).y, suggestedMaxValue);
205  setUpLineEdit(lineEditForDetail[suggestedStepY], VuoPoint4d_makeFromJson(suggestedStepValue).y, suggestedStepValue);
206 
207  setUpLineEdit(lineEditForDetail[suggestedMinZ], VuoPoint4d_makeFromJson(suggestedMinValue).z, suggestedMinValue);
208  setUpLineEdit(lineEditForDetail[suggestedMaxZ], VuoPoint4d_makeFromJson(suggestedMaxValue).z, suggestedMaxValue);
209  setUpLineEdit(lineEditForDetail[suggestedStepZ], VuoPoint4d_makeFromJson(suggestedStepValue).z, suggestedStepValue);
210 
211  setUpLineEdit(lineEditForDetail[suggestedMinW], VuoPoint4d_makeFromJson(suggestedMinValue).w, suggestedMinValue);
212  setUpLineEdit(lineEditForDetail[suggestedMaxW], VuoPoint4d_makeFromJson(suggestedMaxValue).w, suggestedMaxValue);
213  setUpLineEdit(lineEditForDetail[suggestedStepW], VuoPoint4d_makeFromJson(suggestedStepValue).w, suggestedStepValue);
214  }
215 
216  // Layout of X fields
217  lineEditForDetail[suggestedMinX]->move(labelForDetail[suggestedMinX]->pos().x()+labelForDetail[suggestedMinX]->width()+2*widgetHorizontalSpacing, lineEditForDetail[suggestedMinX]->pos().y());
218  labelForDetail[suggestedMinX]->show();
219 
220  labelForDetail[suggestedMaxX]->move(0, labelForDetail[suggestedMinX]->pos().y() + labelForDetail[suggestedMinX]->height() + widgetVerticalSpacing);
221  lineEditForDetail[suggestedMaxX]->move(labelForDetail[suggestedMinX]->pos().x()+labelForDetail[suggestedMinX]->width()+2*widgetHorizontalSpacing, labelForDetail[suggestedMinX]->pos().y() + labelForDetail[suggestedMinX]->height() + widgetVerticalSpacing);
222  labelForDetail[suggestedMaxX]->show();
223 
224  labelForDetail[suggestedStepX]->move(0, labelForDetail[suggestedMaxX]->pos().y() + labelForDetail[suggestedMaxX]->height() + widgetVerticalSpacing);
225  lineEditForDetail[suggestedStepX]->move(labelForDetail[suggestedMinX]->pos().x()+labelForDetail[suggestedMinX]->width()+2*widgetHorizontalSpacing, labelForDetail[suggestedMaxX]->pos().y() + labelForDetail[suggestedMaxX]->height() + widgetVerticalSpacing);
226  labelForDetail[suggestedStepX]->show();
227 
228  // Layout of Y fields
229  labelForDetail[suggestedMinY]->move(0, labelForDetail[suggestedStepX]->pos().y() + labelForDetail[suggestedStepX]->height() + widgetVerticalSpacing);
230  lineEditForDetail[suggestedMinY]->move(labelForDetail[suggestedMinX]->pos().x()+labelForDetail[suggestedMinX]->width()+2*widgetHorizontalSpacing, labelForDetail[suggestedStepX]->pos().y() + labelForDetail[suggestedStepX]->height() + widgetVerticalSpacing);
231  labelForDetail[suggestedMinY]->show();
232 
233  labelForDetail[suggestedMaxY]->move(0, labelForDetail[suggestedMinY]->pos().y() + labelForDetail[suggestedMinY]->height() + widgetVerticalSpacing);
234  lineEditForDetail[suggestedMaxY]->move(labelForDetail[suggestedMinX]->pos().x()+labelForDetail[suggestedMinX]->width()+2*widgetHorizontalSpacing, labelForDetail[suggestedMinY]->pos().y() + labelForDetail[suggestedMinY]->height() + widgetVerticalSpacing);
235  labelForDetail[suggestedMaxY]->show();
236 
237  labelForDetail[suggestedStepY]->move(0, labelForDetail[suggestedMaxY]->pos().y() + labelForDetail[suggestedMaxY]->height() + widgetVerticalSpacing);
238  lineEditForDetail[suggestedStepY]->move(labelForDetail[suggestedMinX]->pos().x()+labelForDetail[suggestedMinX]->width()+2*widgetHorizontalSpacing, labelForDetail[suggestedMaxY]->pos().y() + labelForDetail[suggestedMaxY]->height() + widgetVerticalSpacing);
239  labelForDetail[suggestedStepY]->show();
240 
241  // Hide Z and W fields by default
242  labelForDetail[suggestedMinZ]->hide();
243  labelForDetail[suggestedMaxZ]->hide();
244  labelForDetail[suggestedStepZ]->hide();
245  lineEditForDetail[suggestedMinZ]->hide();
246  lineEditForDetail[suggestedMaxZ]->hide();
247  lineEditForDetail[suggestedStepZ]->hide();
248 
249  labelForDetail[suggestedMinW]->hide();
250  labelForDetail[suggestedMaxW]->hide();
251  labelForDetail[suggestedStepW]->hide();
252  lineEditForDetail[suggestedMinW]->hide();
253  lineEditForDetail[suggestedMaxW]->hide();
254  lineEditForDetail[suggestedStepW]->hide();
255 
256  if ((this->type->getModuleKey() == "VuoPoint3d") || (this->type->getModuleKey() == "VuoPoint4d"))
257  {
258  // Layout of Z fields
259  labelForDetail[suggestedMinZ]->move(0, labelForDetail[suggestedStepY]->pos().y() + labelForDetail[suggestedStepY]->height() + widgetVerticalSpacing);
260  lineEditForDetail[suggestedMinZ]->move(labelForDetail[suggestedMinX]->pos().x()+labelForDetail[suggestedMinX]->width()+2*widgetHorizontalSpacing, labelForDetail[suggestedStepY]->pos().y() + labelForDetail[suggestedStepY]->height() + widgetVerticalSpacing);
261  labelForDetail[suggestedMinZ]->show();
262  lineEditForDetail[suggestedMinZ]->show();
263 
264  labelForDetail[suggestedMaxZ]->move(0, labelForDetail[suggestedMinZ]->pos().y() + labelForDetail[suggestedMinZ]->height() + widgetVerticalSpacing);
265  lineEditForDetail[suggestedMaxZ]->move(labelForDetail[suggestedMinX]->pos().x()+labelForDetail[suggestedMinX]->width()+2*widgetHorizontalSpacing, labelForDetail[suggestedMinZ]->pos().y() + labelForDetail[suggestedMinZ]->height() + widgetVerticalSpacing);
266  labelForDetail[suggestedMaxZ]->show();
267  lineEditForDetail[suggestedMaxZ]->show();
268 
269  labelForDetail[suggestedStepZ]->move(0, labelForDetail[suggestedMaxZ]->pos().y() + labelForDetail[suggestedMaxZ]->height() + widgetVerticalSpacing);
270  lineEditForDetail[suggestedStepZ]->move(labelForDetail[suggestedMinX]->pos().x()+labelForDetail[suggestedMinX]->width()+2*widgetHorizontalSpacing, labelForDetail[suggestedMaxZ]->pos().y() + labelForDetail[suggestedMaxZ]->height() + widgetVerticalSpacing);
271  labelForDetail[suggestedStepZ]->show();
272  lineEditForDetail[suggestedStepZ]->show();
273 
274  if (this->type->getModuleKey() == "VuoPoint4d")
275  {
276  // Layout of W fields
277  labelForDetail[suggestedMinW]->move(0, labelForDetail[suggestedStepZ]->pos().y() + labelForDetail[suggestedStepZ]->height() + widgetVerticalSpacing);
278  lineEditForDetail[suggestedMinW]->move(labelForDetail[suggestedMinX]->pos().x()+labelForDetail[suggestedMinX]->width()+2*widgetHorizontalSpacing, labelForDetail[suggestedStepZ]->pos().y() + labelForDetail[suggestedStepZ]->height() + widgetVerticalSpacing);
279  labelForDetail[suggestedMinW]->show();
280  lineEditForDetail[suggestedMinW]->show();
281 
282  labelForDetail[suggestedMaxW]->move(0, labelForDetail[suggestedMinW]->pos().y() + labelForDetail[suggestedMinW]->height() + widgetVerticalSpacing);
283  lineEditForDetail[suggestedMaxW]->move(labelForDetail[suggestedMinX]->pos().x()+labelForDetail[suggestedMinX]->width()+2*widgetHorizontalSpacing, labelForDetail[suggestedMinW]->pos().y() + labelForDetail[suggestedMinW]->height() + widgetVerticalSpacing);
284  labelForDetail[suggestedMaxW]->show();
285  lineEditForDetail[suggestedMaxW]->show();
286 
287  labelForDetail[suggestedStepW]->move(0, labelForDetail[suggestedMaxW]->pos().y() + labelForDetail[suggestedMaxW]->height() + widgetVerticalSpacing);
288  lineEditForDetail[suggestedStepW]->move(labelForDetail[suggestedMinX]->pos().x()+labelForDetail[suggestedMinX]->width()+2*widgetHorizontalSpacing, labelForDetail[suggestedMaxW]->pos().y() + labelForDetail[suggestedMaxW]->height() + widgetVerticalSpacing);
289  labelForDetail[suggestedStepW]->show();
290  lineEditForDetail[suggestedStepW]->show();
291  }
292  }
293 
294  dialog.adjustSize();
295 
296  // Return focus to the topmost line edit.
297  lineEditForDetail[suggestedMinX]->setFocus();
298  lineEditForDetail[suggestedMinX]->selectAll();
299 }
300 
308 void VuoDetailsEditorPoint::setUpLineEdit(QLineEdit *lineEdit, double originalValue, bool populateText)
309 {
310  lineEdit->setText(populateText? convertToLineEditFormat(originalValue) : "");
311  lineEdit->setFocus();
312  lineEdit->selectAll();
313 
314  lineEdit->adjustSize();
315 }
316 
321 {
322  return convertFromLineEditsFormat(lineEditForDetail[suggestedMinX]->text(),
323  lineEditForDetail[suggestedMaxX]->text(),
324  lineEditForDetail[suggestedStepX]->text(),
325  lineEditForDetail[suggestedMinY]->text(),
326  lineEditForDetail[suggestedMaxY]->text(),
327  lineEditForDetail[suggestedStepY]->text(),
328  lineEditForDetail[suggestedMinZ]->text(),
329  lineEditForDetail[suggestedMaxZ]->text(),
330  lineEditForDetail[suggestedStepZ]->text(),
331  lineEditForDetail[suggestedMinW]->text(),
332  lineEditForDetail[suggestedMaxW]->text(),
333  lineEditForDetail[suggestedStepW]->text()
334  );
335 }
336 
341 {
342  QString valueAsStringInUserLocale = QLocale::system().toString(value);
343 
344  if (qAbs(value) >= 1000.0)
345  valueAsStringInUserLocale.remove(QLocale::system().groupSeparator());
346 
347  return valueAsStringInUserLocale;
348 }
349 
353 json_object * VuoDetailsEditorPoint::convertFromLineEditsFormat(const QString &suggestedMinXValueAsString,
354  const QString &suggestedMaxXValueAsString,
355  const QString &suggestedStepXValueAsString,
356  const QString &suggestedMinYValueAsString,
357  const QString &suggestedMaxYValueAsString,
358  const QString &suggestedStepYValueAsString,
359  const QString &suggestedMinZValueAsString,
360  const QString &suggestedMaxZValueAsString,
361  const QString &suggestedStepZValueAsString,
362  const QString &suggestedMinWValueAsString,
363  const QString &suggestedMaxWValueAsString,
364  const QString &suggestedStepWValueAsString
365  )
366 {
367  // suggestedMin value
368  QString suggestedMinXValueJSON = formatDoubleForJSON(suggestedMinXValueAsString);
369  QString suggestedMinYValueJSON = formatDoubleForJSON(suggestedMinYValueAsString);
370  QString suggestedMinZValueJSON = formatDoubleForJSON(suggestedMinZValueAsString);
371  QString suggestedMinWValueJSON = formatDoubleForJSON(suggestedMinWValueAsString);
372 
373  // suggestedMax value
374  QString suggestedMaxXValueJSON = formatDoubleForJSON(suggestedMaxXValueAsString);
375  QString suggestedMaxYValueJSON = formatDoubleForJSON(suggestedMaxYValueAsString);
376  QString suggestedMaxZValueJSON = formatDoubleForJSON(suggestedMaxZValueAsString);
377  QString suggestedMaxWValueJSON = formatDoubleForJSON(suggestedMaxWValueAsString);
378 
379  // suggestedStep value
380  QString suggestedStepXValueJSON = formatDoubleForJSON(suggestedStepXValueAsString);
381  QString suggestedStepYValueJSON = formatDoubleForJSON(suggestedStepYValueAsString);
382  QString suggestedStepZValueJSON = formatDoubleForJSON(suggestedStepZValueAsString);
383  QString suggestedStepWValueJSON = formatDoubleForJSON(suggestedStepWValueAsString);
384 
385  // details
386  struct json_object *details = json_object_new_object();
387 
388  if (this->type->getModuleKey() == "VuoPoint2d")
389  {
390  if (!suggestedMinXValueAsString.isEmpty() || !suggestedMinYValueAsString.isEmpty())
391  {
392  VuoPoint2d point;
393  point.x = VuoReal_makeFromString(suggestedMinXValueJSON.toUtf8().constData());
394  point.y = VuoReal_makeFromString(suggestedMinYValueJSON.toUtf8().constData());
395  json_object_object_add(details, "suggestedMin", VuoPoint2d_getJson(point));
396  }
397  if (!suggestedMaxXValueAsString.isEmpty() || !suggestedMaxYValueAsString.isEmpty())
398  {
399  VuoPoint2d point;
400  point.x = VuoReal_makeFromString(suggestedMaxXValueJSON.toUtf8().constData());
401  point.y = VuoReal_makeFromString(suggestedMaxYValueJSON.toUtf8().constData());
402  json_object_object_add(details, "suggestedMax", VuoPoint2d_getJson(point));
403  }
404  if (!suggestedStepXValueAsString.isEmpty() || !suggestedStepYValueAsString.isEmpty())
405  {
406  VuoPoint2d point;
407  point.x = VuoReal_makeFromString(suggestedStepXValueJSON.toUtf8().constData());
408  point.y = VuoReal_makeFromString(suggestedStepYValueJSON.toUtf8().constData());
409  json_object_object_add(details, "suggestedStep", VuoPoint2d_getJson(point));
410  }
411  }
412 
413  else if (this->type->getModuleKey() == "VuoPoint3d")
414  {
415  if (!suggestedMinXValueAsString.isEmpty() || !suggestedMinYValueAsString.isEmpty() ||
416  !suggestedMinZValueAsString.isEmpty())
417  {
418  VuoPoint3d point;
419  point.x = VuoReal_makeFromString(suggestedMinXValueJSON.toUtf8().constData());
420  point.y = VuoReal_makeFromString(suggestedMinYValueJSON.toUtf8().constData());
421  point.z = VuoReal_makeFromString(suggestedMinZValueJSON.toUtf8().constData());
422  json_object_object_add(details, "suggestedMin", VuoPoint3d_getJson(point));
423  }
424  if (!suggestedMaxXValueAsString.isEmpty() || !suggestedMaxYValueAsString.isEmpty() ||
425  !suggestedMaxZValueAsString.isEmpty())
426  {
427  VuoPoint3d point;
428  point.x = VuoReal_makeFromString(suggestedMaxXValueJSON.toUtf8().constData());
429  point.y = VuoReal_makeFromString(suggestedMaxYValueJSON.toUtf8().constData());
430  point.z = VuoReal_makeFromString(suggestedMaxZValueJSON.toUtf8().constData());
431  json_object_object_add(details, "suggestedMax", VuoPoint3d_getJson(point));
432  }
433  if (!suggestedStepXValueAsString.isEmpty() || !suggestedStepYValueAsString.isEmpty() ||
434  !suggestedStepZValueAsString.isEmpty())
435  {
436  VuoPoint3d point;
437  point.x = VuoReal_makeFromString(suggestedStepXValueJSON.toUtf8().constData());
438  point.y = VuoReal_makeFromString(suggestedStepYValueJSON.toUtf8().constData());
439  point.z = VuoReal_makeFromString(suggestedStepZValueJSON.toUtf8().constData());
440  json_object_object_add(details, "suggestedStep", VuoPoint3d_getJson(point));
441  }
442  }
443 
444  else if (this->type->getModuleKey() == "VuoPoint4d")
445  {
446  if (!suggestedMinXValueAsString.isEmpty() || !suggestedMinYValueAsString.isEmpty() ||
447  !suggestedMinZValueAsString.isEmpty() || !suggestedMinWValueAsString.isEmpty())
448  {
449  VuoPoint4d point;
450  point.x = VuoReal_makeFromString(suggestedMinXValueJSON.toUtf8().constData());
451  point.y = VuoReal_makeFromString(suggestedMinYValueJSON.toUtf8().constData());
452  point.z = VuoReal_makeFromString(suggestedMinZValueJSON.toUtf8().constData());
453  point.w = VuoReal_makeFromString(suggestedMinWValueJSON.toUtf8().constData());
454  json_object_object_add(details, "suggestedMin", VuoPoint4d_getJson(point));
455  }
456  if (!suggestedMaxXValueAsString.isEmpty() || !suggestedMaxYValueAsString.isEmpty() ||
457  !suggestedMaxZValueAsString.isEmpty() || !suggestedMaxWValueAsString.isEmpty())
458  {
459  VuoPoint4d point;
460  point.x = VuoReal_makeFromString(suggestedMaxXValueJSON.toUtf8().constData());
461  point.y = VuoReal_makeFromString(suggestedMaxYValueJSON.toUtf8().constData());
462  point.z = VuoReal_makeFromString(suggestedMaxZValueJSON.toUtf8().constData());
463  point.w = VuoReal_makeFromString(suggestedMaxWValueJSON.toUtf8().constData());
464  json_object_object_add(details, "suggestedMax", VuoPoint4d_getJson(point));
465  }
466  if (!suggestedStepXValueAsString.isEmpty() || !suggestedStepYValueAsString.isEmpty() ||
467  !suggestedStepZValueAsString.isEmpty() || !suggestedStepWValueAsString.isEmpty())
468  {
469  VuoPoint4d point;
470  point.x = VuoReal_makeFromString(suggestedStepXValueJSON.toUtf8().constData());
471  point.y = VuoReal_makeFromString(suggestedStepYValueJSON.toUtf8().constData());
472  point.z = VuoReal_makeFromString(suggestedStepZValueJSON.toUtf8().constData());
473  point.w = VuoReal_makeFromString(suggestedStepWValueJSON.toUtf8().constData());
474  json_object_object_add(details, "suggestedStep", VuoPoint4d_getJson(point));
475  }
476  }
477 
478  return details;
479 }
480 
484 QString VuoDetailsEditorPoint::formatDoubleForJSON(QString doubleString)
485 {
486  double value = QLocale::system().toDouble(doubleString);
487  QString formattedDouble = QLocale(QLocale::C).toString(value);
488 
489  if (qAbs(value) >= 1000.0)
490  formattedDouble.remove(QLocale(QLocale::C).groupSeparator());
491 
492  if (! formattedDouble.isEmpty() && formattedDouble[0] == '.')
493  formattedDouble = "0" + formattedDouble;
494 
495  return formattedDouble;
496 }
497 
501 QFont VuoDetailsEditorPoint::getDefaultFont(void)
502 {
504  return fonts->dialogBodyFont();
505 }