CustusX  15.8
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 #include "cxViewServiceProxy.h"
34 
35 #include <boost/bind.hpp>
36 #include <ctkPluginContext.h>
37 #include "cxNullDeleter.h"
38 
39 #include <QDomNode>
40 
41 namespace cx
42 {
43 
45 {
46  return VisualizationServicePtr(new VisualizationServiceProxy(pluginContext));
47 }
48 
49 VisualizationServiceProxy::VisualizationServiceProxy(ctkPluginContext *pluginContext) :
50  mPluginContext(pluginContext),
51  mVisualizationService(VisualizationService::getNullObject())
52 {
53  this->initServiceListener();
54 }
55 
57 {
58  return mVisualizationService->get3DView(group, index);
59 }
60 
62 {
63  return mVisualizationService->getActiveGroupId();
64 }
65 
67 {
68  return mVisualizationService->getGroup(groupIdx);
69 }
70 
71 void VisualizationServiceProxy::initServiceListener()
72 {
73  mServiceListener.reset(new ServiceTrackerListener<VisualizationService>(
74  mPluginContext,
75  boost::bind(&VisualizationServiceProxy::onServiceAdded, this, _1),
76  boost::function<void (VisualizationService*)>(),
77  boost::bind(&VisualizationServiceProxy::onServiceRemoved, this, _1)
78  ));
79  mServiceListener->open();
80 }
81 void VisualizationServiceProxy::onServiceAdded(VisualizationService* service)
82 {
83  mVisualizationService.reset(service, null_deleter());
84 
86  connect(service, &VisualizationService::fps, this, &VisualizationService::fps);
89 
90  emit activeLayoutChanged();
91  emit activeViewChanged();
93 }
94 
95 void VisualizationServiceProxy::onServiceRemoved(VisualizationService *service)
96 {
98  disconnect(service, &VisualizationService::fps, this, &VisualizationService::fps);
101 
102  mVisualizationService = VisualizationService::getNullObject();
103 
104  emit activeLayoutChanged();
105  emit activeViewChanged();
107 }
108 
110 {
111  return mVisualizationService->isNull();
112 }
113 
115 {
116  mVisualizationService->aboutToStop();
117 }
118 
120 {
121  mVisualizationService->autoShowData(data);
122 }
123 
125 {
126  mVisualizationService->enableRender(val);
127 }
128 
130 {
131  return mVisualizationService->renderingIsEnabled();
132 }
133 
134 QWidget* VisualizationServiceProxy::getLayoutWidget(QWidget* parent, int index)
135 {
136  return mVisualizationService->getLayoutWidget(parent, index);
137 }
138 
139 QString VisualizationServiceProxy::getActiveLayout(int widgetIndex) const
140 {
141  return mVisualizationService->getActiveLayout(widgetIndex);
142 }
143 
144 void VisualizationServiceProxy::setActiveLayout(const QString& uid, int widgetIndex)
145 {
146  mVisualizationService->setActiveLayout(uid, widgetIndex);
147 }
148 
150 {
151  return mVisualizationService->getClipper();
152 }
153 
155 {
156  return mVisualizationService->getCropper();
157 }
158 
160 {
161  return mVisualizationService->getRenderTimer();
162 }
163 
165 {
166  return mVisualizationService->getNavigation();
167 }
168 
170 {
171  return mVisualizationService->getLayoutRepository();
172 }
173 
175 {
176  return mVisualizationService->getCameraControl();
177 }
178 
180 {
181  return mVisualizationService->createInteractorStyleActionGroup();
182 }
183 
184 } //cx
boost::shared_ptr< class ViewGroupData > ViewGroupDataPtr
Definition: cxViewGroup.h:50
virtual CyclicActionLoggerPtr getRenderTimer()
virtual void autoShowData(DataPtr data)
virtual void enableRender(bool val)
VisualizationServiceProxy(ctkPluginContext *pluginContext)
boost::shared_ptr< class LayoutRepository > LayoutRepositoryPtr
void renderingEnabledChanged()
emitted then rendering is enabled/disabled
virtual int getActiveGroupId() const
void activeLayoutChanged()
emitted when the active layout changes
virtual LayoutRepositoryPtr getLayoutRepository()
void fps(int number)
Emits number of frames per second.
virtual QActionGroup * createInteractorStyleActionGroup()
boost::shared_ptr< class InteractiveClipper > InteractiveClipperPtr
virtual InteractiveClipperPtr getClipper()
static VisualizationServicePtr create(ctkPluginContext *pluginContext)
boost::shared_ptr< class View > ViewPtr
boost::shared_ptr< class Navigation > NavigationPtr
Definition: cxViewGroup.h:54
boost::shared_ptr< class Data > DataPtr
boost::shared_ptr< class VisualizationService > VisualizationServicePtr
Definition: cxRegServices.h:43
virtual NavigationPtr getNavigation()
virtual void setActiveLayout(const QString &uid, int widgetIndex)
static VisualizationServicePtr getNullObject()
boost::shared_ptr< class CyclicActionLogger > CyclicActionLoggerPtr
virtual InteractiveCropperPtr getCropper()
Visualization services.
Definition: cxViewService.h:68
virtual ViewGroupDataPtr getGroup(int groupIdx) const
boost::shared_ptr< class InteractiveCropper > InteractiveCropperPtr
virtual QWidget * getLayoutWidget(QWidget *parent, int index)
Helper class for listening to services being added, modified and removed.
boost::shared_ptr< class CameraControl > CameraControlPtr
Definition: cxMainWindow.h:58
void activeViewChanged()
emitted when the active view changes
virtual QString getActiveLayout(int widgetIndex=0) const
virtual bool renderingIsEnabled() const
virtual ViewPtr get3DView(int group=0, int index=0)
virtual CameraControlPtr getCameraControl()