Fraxinus  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
boost::shared_ptr< class CyclicActionLogger > CyclicActionLoggerPtr
boost::shared_ptr< class LayoutRepository > LayoutRepositoryPtr
boost::shared_ptr< class ViewGroupData > ViewGroupDataPtr
Definition: cxViewGroup.h:29
virtual QWidget * getLayoutWidget(int index)
Get the specified layout widget, NULL if not created.
Visualization services.
Definition: cxViewService.h:50
virtual void setCameraStyle(CAMERA_STYLE_TYPE style, int groupIdx)
virtual QWidget * createLayoutWidget(QWidget *parent, int index)
Get the specified layout widget, create if necessary.
boost::shared_ptr< class CameraControl > CameraControlPtr
virtual void setRegistrationMode(REGISTRATION_STATUS mode)
virtual CameraControlPtr getCameraControl()
ViewServiceProxy(ctkPluginContext *pluginContext)
virtual LayoutRepositoryPtr getLayoutRepository()
void fps(int number)
Emits number of frames per second.
virtual ViewGroupDataPtr getGroup(int groupIdx) const
virtual CyclicActionLoggerPtr getRenderTimer()
boost::shared_ptr< class ViewService > ViewServicePtr
boost::shared_ptr< class InteractiveCropper > InteractiveCropperPtr
virtual InteractiveCropperPtr getCropper()
virtual int getActiveGroupId() const
boost::shared_ptr< class View > ViewPtr
boost::shared_ptr< class Clippers > ClippersPtr
virtual void centerToImageCenterInActiveViewGroup()
virtual ClippersPtr getClippers()
void pointSampled(Vector3D p_r)
void renderingEnabledChanged()
emitted then rendering is enabled/disabled
boost::shared_ptr< class Data > DataPtr
virtual QString getActiveLayout(int widgetIndex=0) const
virtual void enableRender(bool val)
void renderFinished()
virtual void autoShowData(DataPtr data)
virtual ViewPtr get3DView(int group=0, int index=0)
void activeViewChanged()
emitted when the active view changes
virtual void addDefaultLayout(LayoutData layoutData)
static ViewServicePtr getNullObject()
void activeLayoutChanged()
emitted when the active layout changes
Helper class for listening to services being added, modified and removed.
virtual QActionGroup * getInteractorStyleActionGroup()
virtual NavigationPtr getNavigation(int group=0)
virtual bool renderingIsEnabled() const
virtual void zoomCamera3D(int viewGroup3DNumber, int zoomFactor)
static ViewServicePtr create(ctkPluginContext *pluginContext)
boost::shared_ptr< class Navigation > NavigationPtr
virtual void enableContextMenuForViews(bool enable=true)
virtual void setActiveLayout(const QString &uid, int widgetIndex)
Namespace for all CustusX production code.