Fraxinus  17.12-rc3
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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 #include <cxVector3DWidget.h>
33 
34 #include <QTextEdit>
35 #include <QLayout>
36 #include <QLabel>
37 #include <QFontMetrics>
38 
39 #include "cxTypeConversions.h"
40 
42 #include "cxDoubleWidgets.h"
43 
44 namespace cx
45 {
46 
48  QWidget(parent), mData(data)
49 {
50  this->setToolTip(data->getHelp());
51 }
52 
54 {
55  Vector3DWidget* retval = new Vector3DWidget(parent, data);
56 
57  QHBoxLayout* aLayout = new QHBoxLayout(retval);
58  aLayout->setMargin(0);
59  aLayout->addWidget(new QLabel(data->getDisplayName(), retval), 0);
60  retval->addSmallControlsForIndex("x", "X", 0, aLayout);
61  retval->addSmallControlsForIndex("y", "Y", 1, aLayout);
62  retval->addSmallControlsForIndex("z", "Z", 2, aLayout);
63 
64  return retval;
65 }
66 
68 {
69  Vector3DWidget* retval = new Vector3DWidget(parent, data);
70 
71  QVBoxLayout* aLayout = new QVBoxLayout(retval);
72  aLayout->setMargin(0);
73  retval->addSliderControlsForIndex("x", "X", 0, aLayout);
74  retval->addSliderControlsForIndex("y", "Y", 1, aLayout);
75  retval->addSliderControlsForIndex("z", "Z", 2, aLayout);
76 
77  return retval;
78 }
79 
80 void Vector3DWidget::showDim(int dim, bool visible)
81 {
82  mWidgets[dim]->setVisible(visible);
83 }
84 
88 void Vector3DWidget::addSliderControlsForIndex(QString name, QString help, int index, QBoxLayout* layout)
89 {
90  Vector3DComponentPropertyPtr component(new Vector3DComponentProperty(mData, index, name, help));
91  mWidgets[index] = new SpinBoxInfiniteSliderGroupWidget(this, component);
92  layout->addWidget(mWidgets[index]);
93 
94  mDoubleAdapter[index] = component;
95 }
96 
100 void Vector3DWidget::addSmallControlsForIndex(QString name, QString help, int index, QBoxLayout* layout)
101 {
102  Vector3DComponentPropertyPtr component(new Vector3DComponentProperty(mData, index, name, help));
103 
104  ScalarInteractionWidget* widget = new ScalarInteractionWidget(this, component);
105  widget->enableSpinBox();
106  widget->build();
107  mWidgets[index] = widget;
108  layout->addWidget(mWidgets[index], 1);
109 
110  mDoubleAdapter[index] = component;
111 }
112 
113 }
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.