NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxShadingWidget.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 /*
13  * cxShadingWidget.cpp
14  *
15  * \date Aug 20, 2010
16  * \author christiana
17  */
18 #include "cxShadingWidget.h"
19 
20 #include <QVBoxLayout>
21 #include <QComboBox>
22 #include <QStringList>
23 #include "cxImageTF3D.h"
26 #include "cxActiveData.h"
27 
28 namespace cx
29 {
30 
32  BaseWidget(parent, "ImagePropertiesWidget", "Image Properties"),
33  mImage(ImagePtr())
34 {
35  mInterpolationType = new QComboBox(this);
36  mInterpolationType->insertItem(0, "Nearest");
37  mInterpolationType->insertItem(1, "Linear");
38  mInterpolationType->insertItem(2, "Cubic");
39  mInterpolationType->setToolTip("Change VTK interpolation type");
40 
41  connect(mInterpolationType, SIGNAL(currentIndexChanged(int)), this, SLOT(interpolationTypeChanged(int)));
42 
43  QLabel* interpolationTypeLabel = new QLabel("Volume interpolation type", this);
44 
45  QHBoxLayout* layout = new QHBoxLayout(this);
46  layout->addWidget(interpolationTypeLabel);
47  layout->addWidget(mInterpolationType);
48 }
49 
50 void ImageRenderPropertiesWidget::interpolationTypeChanged(int index)
51 {
52  if (mImage)
53  mImage->setInterpolationType(index);
54 }
55 
57 {
58  mImage = image;
59  if (mImage)
60  mInterpolationType->setCurrentIndex(mImage->getInterpolationType());
61 }
62 
63 //---------------------------------------------------------
64 //---------------------------------------------------------
65 //---------------------------------------------------------
66 
67 ShadingWidget::ShadingWidget(ActiveDataPtr activeData, QWidget* parent, bool connectToActiveImage) :
68  BaseWidget(parent, "shading_widget", "Shading"),
69  mLayout(new QVBoxLayout(this)),
70  mActiveData(activeData),
71  mActiveImageProxy(ActiveImageProxyPtr()),
72  mImage(ImagePtr()),
73  mImagePropertiesWidget(ImageRenderPropertiesWidgetPtr())
74 {
75  this->init(connectToActiveImage);
76 }
77 
79 {}
80 
81 void ShadingWidget::init(bool connectToActiveImage)
82 {
83  mShadingCheckBox = new QCheckBox("Shading", this);
84  this->setToolTip("Volume shading properties");
85 
86  connect(mShadingCheckBox, &QCheckBox::toggled, this, &ShadingWidget::shadingToggledSlot);
87 
88  QGridLayout* shadingLayput = new QGridLayout();
89  shadingLayput->addWidget(mShadingCheckBox, 0,0);
90  SliderGroupWidget* shadingAmbientWidget = new SliderGroupWidget(this, DoublePropertyBasePtr(new DoublePropertyShadingAmbient(mActiveData)), shadingLayput, 1);
91  SliderGroupWidget* shadingDiffuseWidget = new SliderGroupWidget(this, DoublePropertyBasePtr(new DoublePropertyShadingDiffuse(mActiveData)), shadingLayput, 2);
92  SliderGroupWidget* shadingSpecularWidget = new SliderGroupWidget(this, DoublePropertyBasePtr(new DoublePropertyShadingSpecular(mActiveData)), shadingLayput, 3);
93  SliderGroupWidget* shadingSpecularPowerWidget = new SliderGroupWidget(this, DoublePropertyBasePtr(new DoublePropertyShadingSpecularPower(mActiveData)), shadingLayput, 4);
94 
95  shadingAmbientWidget->setEnabled(false);
96  shadingDiffuseWidget->setEnabled(false);
97  shadingSpecularWidget->setEnabled(false);
98  shadingSpecularPowerWidget->setEnabled(false);
99 
100  if (connectToActiveImage)
101  {
105  }
106 
108  shadingLayput->addWidget(mImagePropertiesWidget.get(), 5, 0, 1, 2);
109  mLayout->addLayout(shadingLayput);
110  mLayout->addStretch(1);
111  this->activeImageChangedSlot();
112 }
113 
115 {
116  if (mImage)
117  mImage->setShadingOn(val);
118 }
119 
121 {
122  ImagePtr activeImage = mActiveData->getActive<Image>();
123  this->imageChangedSlot(activeImage);
124 }
125 
127 {
128  mImage = image;
129  if (mImage)
130  {
131  mShadingCheckBox->setChecked(mImage->getShadingOn());
132  mImagePropertiesWidget->imageChanged(image);
133  }
134 }
135 
136 }//namespace cx
cx::ShadingWidget::init
void init(bool connectToActiveImage)
Initialize TransferFunctionWidget. Create members.
Definition: cxShadingWidget.cpp:81
cx::ImageRenderPropertiesWidget
Definition: cxShadingWidget.h:40
cx::ShadingWidget::mImage
ImagePtr mImage
Definition: cxShadingWidget.h:81
cxShadingParamsInterfaces.h
cxActiveData.h
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::ActiveImageProxy::activeImageChanged
void activeImageChanged(const QString &uid)
The original image changed signal from DataManager.
cx::BaseWidget
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:88
cxImagePropertiesWidget.h
cx::ActiveImageProxy::New
static ActiveImageProxyPtr New(ActiveDataPtr activeData)
Definition: cxActiveImageProxy.h:44
cx::DoublePropertyShadingDiffuse
Definition: cxShadingParamsInterfaces.h:63
cx::DoublePropertyShadingAmbient
Definition: cxShadingParamsInterfaces.h:49
cx::ActiveImageProxy::transferFunctionsChanged
void transferFunctionsChanged()
cx::ActiveImageProxyPtr
boost::shared_ptr< class ActiveImageProxy > ActiveImageProxyPtr
Definition: cxDataInterface.h:29
cx::ImageRenderPropertiesWidget::imageChanged
void imageChanged(ImagePtr image)
Definition: cxShadingWidget.cpp:56
cx::ShadingWidget::mImagePropertiesWidget
ImageRenderPropertiesWidgetPtr mImagePropertiesWidget
Definition: cxShadingWidget.h:82
cx::ImageRenderPropertiesWidgetPtr
boost::shared_ptr< class ImageRenderPropertiesWidget > ImageRenderPropertiesWidgetPtr
Definition: cxShadingWidget.h:38
cx::ShadingWidget::mLayout
QVBoxLayout * mLayout
Definition: cxShadingWidget.h:75
cx::ImagePtr
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
cx::DoublePropertyShadingSpecular
Definition: cxShadingParamsInterfaces.h:77
cx::ShadingWidget::~ShadingWidget
~ShadingWidget()
Definition: cxShadingWidget.cpp:78
cx::ShadingWidget::mActiveData
ActiveDataPtr mActiveData
Definition: cxShadingWidget.h:79
cx::ImageRenderPropertiesWidget::ImageRenderPropertiesWidget
ImageRenderPropertiesWidget(QWidget *parent)
Definition: cxShadingWidget.cpp:31
cx::DoublePropertyBasePtr
boost::shared_ptr< class DoublePropertyBase > DoublePropertyBasePtr
Definition: cxIGTLinkStreamerService.h:21
cx::Image
A volumetric data set.
Definition: cxImage.h:45
cx::SliderGroupWidget
Composite widget for scalar data manipulation.
Definition: cxDoubleWidgets.h:173
cx::ShadingWidget::activeImageChangedSlot
void activeImageChangedSlot()
listens to the contextdockwidget for when the current image is changed
Definition: cxShadingWidget.cpp:120
cx::DoublePropertyShadingSpecularPower
Definition: cxShadingParamsInterfaces.h:91
cx::ShadingWidget::ShadingWidget
ShadingWidget(ActiveDataPtr activeData, QWidget *parent, bool connectToActiveImage=true)
Definition: cxShadingWidget.cpp:67
cx::ActiveDataPtr
boost::shared_ptr< class ActiveData > ActiveDataPtr
Definition: cxColorWidget.h:21
cxImageTF3D.h
cxShadingWidget.h
cx::ShadingWidget::imageChangedSlot
void imageChangedSlot(ImagePtr image)
Definition: cxShadingWidget.cpp:126
cx::ShadingWidget::mActiveImageProxy
ActiveImageProxyPtr mActiveImageProxy
Definition: cxShadingWidget.h:80
cx::ShadingWidget::mShadingCheckBox
QCheckBox * mShadingCheckBox
Definition: cxShadingWidget.h:76
cx::ShadingWidget::shadingToggledSlot
void shadingToggledSlot(bool val)
Definition: cxShadingWidget.cpp:114