Fraxinus  22.04-rc3
An IGT application
cxTransferFunction2DOpacityWidget.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 
13 #include "cxDoubleWidgets.h"
14 #include "cxImageLUT2D.h"
15 #include "cxActiveData.h"
16 
17 namespace cx
18 {
19 
21  BaseWidget(parent, "transfer_function_2d_opacity_widget", "2D Opacity"),
22  mActiveData(activeData)
23 {
24  this->setToolTip("Set a 2D opacity transfer function");
25  QVBoxLayout* layout = new QVBoxLayout(this);
26 
29 
32 
34  connect(mActiveImageProxy.get(), &ActiveImageProxy::transferFunctionsChanged, this, &TransferFunction2DOpacityWidget::activeImageChangedSlot);
35  connect(mActiveData.get(), &ActiveData::activeDataChanged, this, &TransferFunction2DOpacityWidget::activeImageChangedSlot);
36 
37  mTransferFunctionAlphaWidget->setSizePolicy(QSizePolicy::MinimumExpanding,
38  QSizePolicy::MinimumExpanding);
39 
40  layout->addWidget(mTransferFunctionAlphaWidget);
41 
42  QGridLayout* gridLayout = new QGridLayout;
43  layout->addLayout(gridLayout);
44  new SliderGroupWidget(this, mDataAlpha, gridLayout, 2);
45  new SliderGroupWidget(this, mDataLLR, gridLayout, 3);
46 
47  this->setLayout(layout);
48  this->activeImageChangedSlot();
49 }
50 
52 {
53  disconnect(mActiveData.get(), &ActiveData::activeDataChanged, this, &TransferFunction2DOpacityWidget::activeImageChangedSlot);
54 }
55 
56 void TransferFunction2DOpacityWidget::activeImageChangedSlot()
57 {
58  ImagePtr image = mActiveData->getDerivedActiveImage();
59  ImageTFDataPtr tf;
60  if (image)
61  tf = image->getLookupTable2D();
62  else
63  image.reset();
64 
66 
67  mDataAlpha->setImageTFData(tf, image);
68  mDataLLR->setImageTFData(tf, image);
69 }
70 
71 
72 }//end namespace cx
Composite widget for scalar data manipulation.
TransferFunction2DOpacityWidget(ActiveDataPtr activeData, QWidget *parent)
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
void setData(ImagePtr image, ImageTFDataPtr tfData)
boost::shared_ptr< class ActiveData > ActiveDataPtr
Definition: cxColorWidget.h:21
void transferFunctionsChanged()
static ActiveImageProxyPtr New(ActiveDataPtr activeData)
void activeDataChanged(const QString &uId)
void setReadOnly(bool readOnly)
Set class readonly: Disable mouse interaction.
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:88
TransferFunctionAlphaWidget * mTransferFunctionAlphaWidget
boost::shared_ptr< class ImageTFData > ImageTFDataPtr
Namespace for all CustusX production code.