NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxStreamPropertiesWidget.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 =========================================================================*/
12 
14 #include "cxDataSelectWidget.h"
15 #include "cxTrackedStream.h"
17 #include "cxShadingWidget.h"
18 #include "cxActiveData.h"
19 #include "cxPatientModelService.h"
20 
21 namespace cx
22 {
23 
24 StreamPropertiesWidget::StreamPropertiesWidget(PatientModelServicePtr patientModelService, ViewServicePtr viewService, QWidget *parent) :
25  TabbedWidget(parent, "StreamPropertiesWidget", "Stream Properties"),
26  mSelectStream(StringPropertySelectTrackedStream::New(patientModelService))
27 {
28  this->setToolTip("Set properties on a tracked 2D/3D stream");
29  bool connectToActiveImage = false;
30  ActiveDataPtr activeData = patientModelService->getActiveData();
31  mTransferFunctionWidget = TransferFunction3DWidgetPtr(new TransferFunction3DWidget(activeData, this, connectToActiveImage));
32  mShadingWidget = ShadingWidgetPtr(new ShadingWidget(activeData, this, connectToActiveImage));
33 
34  this->insertWidgetAtTop(new DataSelectWidget(viewService, patientModelService, this, mSelectStream));
35  this->addTab(mTransferFunctionWidget.get(), QString("Transfer Functions"));
36  this->addTab(mShadingWidget.get(), "Shading");
37 
38  connect(mSelectStream.get(), &Property::changed, this, &StreamPropertiesWidget::streamSelectedSlot);
39 }
40 
41 void StreamPropertiesWidget::streamSelectedSlot()
42 {
43  if(mTrackedStream)
44  disconnect(mTrackedStream.get(), &TrackedStream::streaming, this, &StreamPropertiesWidget::streamingSlot);
45 
46  mTrackedStream = mSelectStream->getTrackedStream();
47 
48  if(mTrackedStream)
49  {
50  connect(mTrackedStream.get(), &TrackedStream::streaming, this, &StreamPropertiesWidget::streamingSlot);
51  streamingSlot(true);
52  }
53  else
54  streamingSlot(false);
55 }
56 
57 void StreamPropertiesWidget::streamingSlot(bool isStreaming)
58 {
59  ImagePtr image = ImagePtr();
60  mTransferFunctionWidget->imageChangedSlot(image);
61  mShadingWidget->imageChangedSlot(image);
62 
63  if(isStreaming && mTrackedStream)
64  connect(mTrackedStream.get(), &TrackedStream::newFrame, this, &StreamPropertiesWidget::firstFrame);
65 }
66 
67 void StreamPropertiesWidget::firstFrame()
68 {
69  ImagePtr image = mTrackedStream->getChangingImage();
70  if(image)
71  {
72  disconnect(mTrackedStream.get(), &TrackedStream::newFrame, this, &StreamPropertiesWidget::firstFrame);
73  mTransferFunctionWidget->imageChangedSlot(image);
74  mShadingWidget->imageChangedSlot(image);
75  }
76 }
77 
78 } //cx
cxTransferFunctionWidget.h
cxActiveData.h
cx::TabbedWidget::addTab
void addTab(BaseWidget *newTab, QString newTabName)
Definition: cxTabbedWidget.cpp:37
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::Property::changed
void changed()
emit when the underlying data value is changed: The user interface will be updated.
cx::StreamPropertiesWidget::StreamPropertiesWidget
StreamPropertiesWidget(PatientModelServicePtr patientModelService, ViewServicePtr viewService, QWidget *parent)
Definition: cxStreamPropertiesWidget.cpp:24
cx::ShadingWidgetPtr
boost::shared_ptr< class ShadingWidget > ShadingWidgetPtr
Definition: cxStreamPropertiesWidget.h:21
cx::TabbedWidget
Interface for making widgets with a hierarchy of tabs.
Definition: cxTabbedWidget.h:34
cx::StringPropertySelectTrackedStream
Definition: cxSelectDataStringProperty.h:152
cx::TrackedStream::newFrame
void newFrame()
cx::PatientModelServicePtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Definition: cxLogicManager.h:25
cx::ViewServicePtr
boost::shared_ptr< class ViewService > ViewServicePtr
Definition: cxLogicManager.h:28
cxPatientModelService.h
cx::ImagePtr
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
cx::TabbedWidget::insertWidgetAtTop
void insertWidgetAtTop(QWidget *newWidget)
Definition: cxTabbedWidget.cpp:44
cx::ShadingWidget
Definition: cxShadingWidget.h:59
cxDataSelectWidget.h
cx::TrackedStream::streaming
void streaming(bool on)
emitted when streaming started/stopped
cxStreamPropertiesWidget.h
cxSelectDataStringProperty.h
cx::DataSelectWidget
Definition: cxDataSelectWidget.h:38
cx::ActiveDataPtr
boost::shared_ptr< class ActiveData > ActiveDataPtr
Definition: cxColorWidget.h:21
cx::TransferFunction3DWidgetPtr
boost::shared_ptr< class TransferFunction3DWidget > TransferFunction3DWidgetPtr
Definition: cxStreamPropertiesWidget.h:20
cxShadingWidget.h
cx::TransferFunction3DWidget
Definition: cxTransferFunctionWidget.h:116
cxTrackedStream.h