CustusX  22.04-rc5
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
void imageChangedSlot(ImagePtr image)
Composite widget for scalar data manipulation.
void activeImageChangedSlot()
listens to the contextdockwidget for when the current image is changed
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
ActiveDataPtr mActiveData
boost::shared_ptr< class ActiveImageProxy > ActiveImageProxyPtr
boost::shared_ptr< class ActiveData > ActiveDataPtr
Definition: cxColorWidget.h:21
void transferFunctionsChanged()
QCheckBox * mShadingCheckBox
ImageRenderPropertiesWidget(QWidget *parent)
static ActiveImageProxyPtr New(ActiveDataPtr activeData)
A volumetric data set.
Definition: cxImage.h:45
void imageChanged(ImagePtr image)
boost::shared_ptr< class DoublePropertyBase > DoublePropertyBasePtr
boost::shared_ptr< class ImageRenderPropertiesWidget > ImageRenderPropertiesWidgetPtr
QVBoxLayout * mLayout
void shadingToggledSlot(bool val)
void init(bool connectToActiveImage)
Initialize TransferFunctionWidget. Create members.
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:88
ImageRenderPropertiesWidgetPtr mImagePropertiesWidget
ActiveImageProxyPtr mActiveImageProxy
void activeImageChanged(const QString &uid)
The original image changed signal from DataManager.
ShadingWidget(ActiveDataPtr activeData, QWidget *parent, bool connectToActiveImage=true)
Namespace for all CustusX production code.