Fraxinus  18.10
An IGT application
cxBoundingBoxWidget.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 
12 #include <cxBoundingBoxWidget.h>
13 #include "cxBoundingBox3D.h"
14 #include "cxDoubleSpanSlider.h"
15 #include "cxDoublePairProperty.h"
16 
17 namespace cx
18 {
19 
20 BoundingBoxWidget::BoundingBoxWidget(QWidget* parent, QStringList captions) :
21  QWidget(parent)
22 {
23  QVBoxLayout* layout = new QVBoxLayout(this);
24  layout->setMargin(0);
25 
26  if(captions.isEmpty())
27  captions = QStringList() << "X (mm)" << "Y (mm)" << "Z (mm)";
28 
29  for (int i=0; i<captions.size(); ++i)
30  {
31  DoublePairPropertyPtr property = DoublePairProperty::initialize(captions[i], captions[i], captions[i], DoubleRange(-2000, 2000, 1), 0);
32  mRange.push_back(new SliderRangeGroupWidget(this, property));
34  layout->addWidget(mRange[i]);
35  if(i >= captions.size())
36  mRange[i]->setVisible(false);
37  }
38 }
39 
40 void BoundingBoxWidget::showDim(int dim, bool visible)
41 {
42  mRange[dim]->setVisible(visible);
43 }
44 
46 {
47  for (int i=0; i<mRange.size(); ++i)
48  {
49  mRange[i]->blockSignals(true);
50  mRange[i]->setRange(DoubleRange(range.begin()[2*i], range.begin()[2*i+1], 1));
51  mRange[i]->setValue(value.begin()[2*i], value.begin()[2*i+1]);
52  mRange[i]->blockSignals(false);
53  }
54 }
55 
57 {
58  //Init with zeroes
59  std::vector< std::pair<double, double> > values;
60  for(unsigned i = 0; i < 3; ++i)
61  values.push_back(std::make_pair(0, 0));
62 
63  //Overwrite the zeroes with values (depends on the dim we are using)
64  for(unsigned i = 0; i < mRange.size(); ++i)
65  values[i] = mRange[i]->getValue();
66 
68  values[0].first, values[0].second,
69  values[1].first, values[1].second,
70  values[2].first, values[2].second);
71 
72 // std::pair<double, double> x = mRange[0]->getValue();
73 // std::pair<double, double> y = mRange[1]->getValue();
74 // std::pair<double, double> z = mRange[2]->getValue();
75 // DoubleBoundingBox3D box(x.first, x.second, y.first, y.second, z.first, z.second);
76 
77  return box;
78 }
79 
80 }
Utility class for describing a bounded numeric range.
Definition: cxDoubleRange.h:32
DoubleBoundingBox3D getValue() const
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
CompositeGenerator< T > values(T val1, T val2)
Definition: catch.hpp:3128
boost::shared_ptr< class DoublePairProperty > DoublePairPropertyPtr
void valueChanged(double lower, double upper)
void setValue(const DoubleBoundingBox3D &value, const DoubleBoundingBox3D &range)
void showDim(int dim, bool visible)
static DoublePairPropertyPtr initialize(const QString &uid, QString name, QString help, DoubleRange range, int decimals, QDomNode root=QDomNode())
BoundingBoxWidget(QWidget *parent=NULL, QStringList inCaptions=QStringList())
Namespace for all CustusX production code.