NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxViewServiceProxy.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 #include "cxViewServiceProxy.h"
13 
14 #include <boost/bind.hpp>
15 #include <ctkPluginContext.h>
16 #include "cxNullDeleter.h"
17 
18 #include <QDomNode>
19 
20 namespace cx
21 {
22 
23 ViewServicePtr ViewServiceProxy::create(ctkPluginContext *pluginContext)
24 {
25  return ViewServicePtr(new ViewServiceProxy(pluginContext));
26 }
27 
28 ViewServiceProxy::ViewServiceProxy(ctkPluginContext *pluginContext) :
29  mPluginContext(pluginContext),
30  mViewService(ViewService::getNullObject())
31 {
32  this->initServiceListener();
33 }
34 
35 ViewPtr ViewServiceProxy::get3DView(int group, int index)
36 {
37  return mViewService->get3DView(group, index);
38 }
39 
41 {
42  return mViewService->getActiveGroupId();
43 }
44 
46 {
47  return mViewService->getGroup(groupIdx);
48 }
49 
50 void ViewServiceProxy::setRegistrationMode(REGISTRATION_STATUS mode)
51 {
52  mViewService->setRegistrationMode(mode);
53 }
54 
55 void ViewServiceProxy::initServiceListener()
56 {
57  mServiceListener.reset(new ServiceTrackerListener<ViewService>(
58  mPluginContext,
59  boost::bind(&ViewServiceProxy::onServiceAdded, this, _1),
60  boost::function<void (ViewService*)>(),
61  boost::bind(&ViewServiceProxy::onServiceRemoved, this, _1)
62  ));
63  mServiceListener->open();
64 }
65 void ViewServiceProxy::onServiceAdded(ViewService* service)
66 {
67  mViewService.reset(service, null_deleter());
68 
70  connect(service, &ViewService::fps, this, &ViewService::fps);
73  connect(service, &ViewService::pointSampled, this, &ViewService::pointSampled);
75 
76  emit activeLayoutChanged();
77  emit activeViewChanged();
79 }
80 
81 void ViewServiceProxy::onServiceRemoved(ViewService *service)
82 {
84  disconnect(service, &ViewService::fps, this, &ViewService::fps);
87  disconnect(service, &ViewService::pointSampled, this, &ViewService::pointSampled);
88  disconnect(service, &ViewService::renderFinished, this, &ViewService::renderFinished);
89 
90  mViewService = ViewService::getNullObject();
91 
92  emit activeLayoutChanged();
93  emit activeViewChanged();
95 }
96 
98 {
99  return mViewService->isNull();
100 }
101 
103 {
104  mViewService->aboutToStop();
105 }
106 
108 {
109  mViewService->autoShowData(data);
110 }
111 
113 {
114  mViewService->enableRender(val);
115 }
116 
118 {
119  return mViewService->renderingIsEnabled();
120 }
121 
122 QWidget* ViewServiceProxy::createLayoutWidget(QWidget* parent, int index)
123 {
124  return mViewService->createLayoutWidget(parent, index);
125 }
126 
128 {
129  return mViewService->getLayoutWidget(index);
130 }
131 
132 QString ViewServiceProxy::getActiveLayout(int widgetIndex) const
133 {
134  return mViewService->getActiveLayout(widgetIndex);
135 }
136 
137 void ViewServiceProxy::setActiveLayout(const QString& uid, int widgetIndex)
138 {
139  mViewService->setActiveLayout(uid, widgetIndex);
140 }
141 
143 {
144  return mViewService->getCropper();
145 }
146 
148 {
149  return mViewService->getRenderTimer();
150 }
151 
153 {
154  return mViewService->getNavigation();
155 }
156 
158 {
159  return mViewService->getLayoutRepository();
160 }
161 
163 {
164  return mViewService->getCameraControl();
165 }
166 
168 {
169  return mViewService->getInteractorStyleActionGroup();
170 }
171 
173 {
174  return mViewService->centerToImageCenterInActiveViewGroup();
175 }
176 
177 void ViewServiceProxy::setCameraStyle(CAMERA_STYLE_TYPE style, int groupIdx)
178 {
179  mViewService->setCameraStyle(style, groupIdx);
180 }
181 
182 void ViewServiceProxy::zoomCamera3D(int viewGroup3DNumber, int zoomFactor)
183 {
184  mViewService->zoomCamera3D(viewGroup3DNumber, zoomFactor);
185 }
186 
188 {
189  mViewService->addDefaultLayout(layoutData);
190 }
191 
193 {
194  mViewService->enableContextMenuForViews(enable);
195 }
196 
198 {
199  return mViewService->getClippers();
200 }
201 
202 } //cx
cx::ViewServiceProxy::getLayoutWidget
virtual QWidget * getLayoutWidget(int index)
Get the specified layout widget, NULL if not created.
Definition: cxViewServiceProxy.cpp:127
cx::ViewServiceProxy::setCameraStyle
virtual void setCameraStyle(CAMERA_STYLE_TYPE style, int groupIdx)
Definition: cxViewServiceProxy.cpp:177
cx::ViewServiceProxy::autoShowData
virtual void autoShowData(DataPtr data)
Definition: cxViewServiceProxy.cpp:107
cx::ViewGroupDataPtr
boost::shared_ptr< class ViewGroupData > ViewGroupDataPtr
Definition: cxViewGroup.h:29
cx::ViewServiceProxy::create
static ViewServicePtr create(ctkPluginContext *pluginContext)
Definition: cxViewServiceProxy.cpp:23
cx::ViewServiceProxy::enableContextMenuForViews
virtual void enableContextMenuForViews(bool enable=true)
Definition: cxViewServiceProxy.cpp:192
cx::ViewServiceProxy::getClippers
virtual ClippersPtr getClippers()
Definition: cxViewServiceProxy.cpp:197
cx::ViewServiceProxy::createLayoutWidget
virtual QWidget * createLayoutWidget(QWidget *parent, int index)
Get the specified layout widget, create if necessary.
Definition: cxViewServiceProxy.cpp:122
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::ViewServiceProxy::getCropper
virtual InteractiveCropperPtr getCropper()
Definition: cxViewServiceProxy.cpp:142
cx::ServiceTrackerListener
Helper class for listening to services being added, modified and removed.
Definition: cxServiceTrackerListener.h:53
cx::ViewServiceProxy::setRegistrationMode
virtual void setRegistrationMode(REGISTRATION_STATUS mode)
Definition: cxViewServiceProxy.cpp:50
cx::ViewServiceProxy::renderingIsEnabled
virtual bool renderingIsEnabled() const
Definition: cxViewServiceProxy.cpp:117
cx::ViewServiceProxy::getNavigation
virtual NavigationPtr getNavigation(int group=0)
Definition: cxViewServiceProxy.cpp:152
cx::ViewServiceProxy::enableRender
virtual void enableRender(bool val)
Definition: cxViewServiceProxy.cpp:112
cx::ViewServiceProxy::get3DView
virtual ViewPtr get3DView(int group=0, int index=0)
Definition: cxViewServiceProxy.cpp:35
cx::ClippersPtr
boost::shared_ptr< class Clippers > ClippersPtr
Definition: cxForwardDeclarations.h:153
cx::ViewServiceProxy::ViewServiceProxy
ViewServiceProxy(ctkPluginContext *pluginContext)
Definition: cxViewServiceProxy.cpp:28
cx::ViewServiceProxy::aboutToStop
virtual void aboutToStop()
Definition: cxViewServiceProxy.cpp:102
cx::ViewService::activeLayoutChanged
void activeLayoutChanged()
emitted when the active layout changes
cx::ViewServiceProxy::getActiveGroupId
virtual int getActiveGroupId() const
Definition: cxViewServiceProxy.cpp:40
cx::LayoutData
Definition: cxLayoutData.h:76
cx::NavigationPtr
boost::shared_ptr< class Navigation > NavigationPtr
Definition: cxForwardDeclarations.h:160
cx::ViewService::fps
void fps(int number)
Emits number of frames per second.
cxNullDeleter.h
cx::ViewServiceProxy::getCameraControl
virtual CameraControlPtr getCameraControl()
Definition: cxViewServiceProxy.cpp:162
cx::ViewServiceProxy::isNull
bool isNull()
Definition: cxViewServiceProxy.cpp:97
cx::ViewServiceProxy::setActiveLayout
virtual void setActiveLayout(const QString &uid, int widgetIndex)
Definition: cxViewServiceProxy.cpp:137
cx::ViewServicePtr
boost::shared_ptr< class ViewService > ViewServicePtr
Definition: cxLogicManager.h:28
cx::DataPtr
boost::shared_ptr< class Data > DataPtr
Definition: cxRegistrationApplicator.h:22
cx::ViewService::activeViewChanged
void activeViewChanged()
emitted when the active view changes
cx::ViewServiceProxy::zoomCamera3D
virtual void zoomCamera3D(int viewGroup3DNumber, int zoomFactor)
Definition: cxViewServiceProxy.cpp:182
cx::ViewServiceProxy::getRenderTimer
virtual CyclicActionLoggerPtr getRenderTimer()
Definition: cxViewServiceProxy.cpp:147
cx::ViewServiceProxy::getActiveLayout
virtual QString getActiveLayout(int widgetIndex=0) const
Definition: cxViewServiceProxy.cpp:132
cx::ViewService::getNullObject
static ViewServicePtr getNullObject()
Definition: cxViewService.cpp:31
cx::ViewServiceProxy::getGroup
virtual ViewGroupDataPtr getGroup(int groupIdx) const
Definition: cxViewServiceProxy.cpp:45
cx::ViewPtr
boost::shared_ptr< class View > ViewPtr
Definition: cxForwardDeclarations.h:110
cx::ViewServiceProxy::addDefaultLayout
virtual void addDefaultLayout(LayoutData layoutData)
Definition: cxViewServiceProxy.cpp:187
cx::ViewServiceProxy::getLayoutRepository
virtual LayoutRepositoryPtr getLayoutRepository()
Definition: cxViewServiceProxy.cpp:157
cx::CyclicActionLoggerPtr
boost::shared_ptr< class CyclicActionLogger > CyclicActionLoggerPtr
Definition: cxForwardDeclarations.h:154
cx::LayoutRepositoryPtr
boost::shared_ptr< class LayoutRepository > LayoutRepositoryPtr
Definition: cxForwardDeclarations.h:159
cx::ViewService::renderingEnabledChanged
void renderingEnabledChanged()
emitted then rendering is enabled/disabled
cx::CameraControlPtr
boost::shared_ptr< class CameraControl > CameraControlPtr
Definition: cxForwardDeclarations.h:152
cx::ViewService
Visualization services.
Definition: cxViewService.h:50
cx::ViewServiceProxy::centerToImageCenterInActiveViewGroup
virtual void centerToImageCenterInActiveViewGroup()
Definition: cxViewServiceProxy.cpp:172
cxViewServiceProxy.h
cx::InteractiveCropperPtr
boost::shared_ptr< class InteractiveCropper > InteractiveCropperPtr
Definition: cxForwardDeclarations.h:158
cx::ViewServiceProxy::getInteractorStyleActionGroup
virtual QActionGroup * getInteractorStyleActionGroup()
Definition: cxViewServiceProxy.cpp:167
cx::ViewService::pointSampled
void pointSampled(Vector3D p_r)
cx::ViewService::renderFinished
void renderFinished()