NorMIT-nav  18.04
An IGT application
cxVector3DWidget.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 #include <cxVector3DWidget.h>
12 
13 #include <QTextEdit>
14 #include <QLayout>
15 #include <QLabel>
16 #include <QFontMetrics>
17 
18 #include "cxTypeConversions.h"
19 
21 #include "cxDoubleWidgets.h"
22 
23 namespace cx
24 {
25 
27  QWidget(parent), mData(data)
28 {
29  this->setToolTip(data->getHelp());
30 }
31 
33 {
34  Vector3DWidget* retval = new Vector3DWidget(parent, data);
35 
36  QHBoxLayout* aLayout = new QHBoxLayout(retval);
37  aLayout->setMargin(0);
38  aLayout->addWidget(new QLabel(data->getDisplayName(), retval), 0);
39  retval->addSmallControlsForIndex("x", "X", 0, aLayout);
40  retval->addSmallControlsForIndex("y", "Y", 1, aLayout);
41  retval->addSmallControlsForIndex("z", "Z", 2, aLayout);
42 
43  return retval;
44 }
45 
47 {
48  Vector3DWidget* retval = new Vector3DWidget(parent, data);
49 
50  QVBoxLayout* aLayout = new QVBoxLayout(retval);
51  aLayout->setMargin(0);
52  retval->addSliderControlsForIndex("x", "X", 0, aLayout);
53  retval->addSliderControlsForIndex("y", "Y", 1, aLayout);
54  retval->addSliderControlsForIndex("z", "Z", 2, aLayout);
55 
56  return retval;
57 }
58 
59 void Vector3DWidget::showDim(int dim, bool visible)
60 {
61  mWidgets[dim]->setVisible(visible);
62 }
63 
67 void Vector3DWidget::addSliderControlsForIndex(QString name, QString help, int index, QBoxLayout* layout)
68 {
69  Vector3DComponentPropertyPtr component(new Vector3DComponentProperty(mData, index, name, help));
70  mWidgets[index] = new SpinBoxInfiniteSliderGroupWidget(this, component);
71  layout->addWidget(mWidgets[index]);
72 
73  mDoubleAdapter[index] = component;
74 }
75 
79 void Vector3DWidget::addSmallControlsForIndex(QString name, QString help, int index, QBoxLayout* layout)
80 {
81  Vector3DComponentPropertyPtr component(new Vector3DComponentProperty(mData, index, name, help));
82 
83  ScalarInteractionWidget* widget = new ScalarInteractionWidget(this, component);
84  widget->enableSpinBox();
85  widget->build();
86  mWidgets[index] = widget;
87  layout->addWidget(mWidgets[index], 1);
88 
89  mDoubleAdapter[index] = component;
90 }
91 
92 }
void build(QGridLayout *gridLayout=0, int row=0)
Widget for displaying a Vector3D.
void showDim(int dim, bool visible)
Composite widget for scalar data manipulation.
Vector3DWidget(QWidget *parent, Vector3DPropertyBasePtr data)
static Vector3DWidget * createSmallHorizontal(QWidget *parent, Vector3DPropertyBasePtr data)
boost::shared_ptr< Vector3DPropertyBase > Vector3DPropertyBasePtr
boost::shared_ptr< Vector3DComponentProperty > Vector3DComponentPropertyPtr
static Vector3DWidget * createVerticalWithSliders(QWidget *parent, Vector3DPropertyBasePtr data)
Composite widget for scalar data manipulation.
Namespace for all CustusX production code.