Fraxinus  18.10
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
boost::shared_ptr< class TransferFunction3DWidget > TransferFunction3DWidgetPtr
StreamPropertiesWidget(PatientModelServicePtr patientModelService, ViewServicePtr viewService, QWidget *parent)
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
void streaming(bool on)
emitted when streaming started/stopped
boost::shared_ptr< class ActiveData > ActiveDataPtr
Definition: cxColorWidget.h:21
boost::shared_ptr< class ViewService > ViewServicePtr
void insertWidgetAtTop(QWidget *newWidget)
boost::shared_ptr< class ShadingWidget > ShadingWidgetPtr
void addTab(BaseWidget *newTab, QString newTabName)
Interface for making widgets with a hierarchy of tabs.
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
void changed()
emit when the underlying data value is changed: The user interface will be updated.
Namespace for all CustusX production code.