Fraxinus  17.12
An IGT application
cxViewImplService.h
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 #ifndef CXVIEWIMPLSERVICE_H_
34 #define CXVIEWIMPLSERVICE_H_
35 
36 #include "cxViewService.h"
37 #include "org_custusx_core_view_Export.h"
38 class ctkPluginContext;
39 class QDomElement;
40 
41 namespace cx
42 {
43 class ViewCollectionWidget;
44 typedef boost::shared_ptr<class SessionStorageService> SessionStorageServicePtr;
45 typedef boost::shared_ptr<class SyncedValue> SyncedValuePtr;
46 typedef boost::shared_ptr<class RenderLoop> RenderLoopPtr;
47 typedef boost::shared_ptr<class CameraStyleInteractor> CameraStyleInteractorPtr;
48 
49 
104 class org_custusx_core_view_EXPORT ViewImplService : public ViewService
105 {
106  Q_OBJECT
107  Q_INTERFACES(cx::ViewService)
108 public:
109  ViewImplService(ctkPluginContext* context);
110  virtual ~ViewImplService();
111 
112  virtual ViewPtr get3DView(int group = 0, int index = 0);
113 
114  virtual int getActiveGroupId() const;
115  virtual ViewGroupDataPtr getGroup(int groupIdx) const;
116  virtual void setRegistrationMode(REGISTRATION_STATUS mode);
117 
118  virtual void autoShowData(DataPtr data);
119  virtual void enableRender(bool val);
120  virtual bool renderingIsEnabled() const;
121 
122  virtual QWidget* createLayoutWidget(QWidget* parent, int index);
123  virtual QWidget* getLayoutWidget(int index);
124  virtual QString getActiveLayout(int widgetIndex = 0) const;
125  virtual void setActiveLayout(const QString& uid, int widgetIndex);
126  virtual ClippersPtr getClippers();
127  virtual InteractiveCropperPtr getCropper();
128  virtual CyclicActionLoggerPtr getRenderTimer();
129  virtual NavigationPtr getNavigation(int group = 0);
130  virtual LayoutRepositoryPtr getLayoutRepository();
131  virtual CameraControlPtr getCameraControl();
132  virtual QActionGroup* getInteractorStyleActionGroup();
133  virtual void centerToImageCenterInActiveViewGroup();
134  virtual void addDefaultLayout(LayoutData layoutData);
135  virtual void enableContextMenuForViews(bool enable=true);
136 
137  virtual bool isNull();
138 
139  virtual void setCameraStyle(CAMERA_STYLE_TYPE style, int groupIdx);
140  virtual void zoomCamera3D(int viewGroup3DNumber, int zoomFactor);
141 
142 public slots:
143  virtual void aboutToStop();
144 
145 protected slots:
146  void layoutWidgetDestroyed(QObject *object);
147 
148 private slots:
149  void onSessionChanged();
150  void onSessionCleared();
151  void onSessionLoad(QDomElement& node);
152  void onSessionSave(QDomElement& node);
153 
154  void updateViews();
155  void updateCameraStyleActions();
156  void onLayoutRepositoryChanged(QString uid);
157  void setActiveView(QString viewUid);
158  void settingsChangedSlot(QString key);
159 
160 protected:
161  void rebuildLayouts();
162  QList<unsigned> getViewGroupsToAutoShowIn();
163 
165  std::vector<QPointer<ViewCollectionWidget> > mLayoutWidgets;
167  RenderLoopPtr mRenderLoop;
168 
169 private:
170  void init();
171  void loadGlobalSettings();
172  void saveGlobalSettings();
173  void initializeGlobal2DZoom();
174  void initializeActiveView();
175  std::vector<ViewGroupPtr> getViewGroups();
176  QString getActiveView() const;
177 
178  //Interface for saving/loading
179  void addXml(QDomNode& parentNode);
180  void parseXml(QDomNode viewmanagerNode);
181  void clear();
182  void deactivateCurrentLayout();
183  unsigned viewGroupCount() const;
184  void activateViews(ViewCollectionWidget *widget, LayoutData next);
185  void activateView(ViewCollectionWidget* widget, LayoutViewData viewData);
186  void setSlicePlanesProxyInViewsUpTo2DViewgroup();
187  void setRenderingInterval(int interval);
188  ViewWrapperPtr createViewWrapper(ViewPtr view, LayoutViewData viewData);
189  int findGroupContaining3DViewGivenGuess(int preferredGroup);
190  void autoShowInViewGroups(DataPtr data);
191  void autoResetCameraToSuperiorView();
192  void autoCenterToImageCenter();
193  void centerToImageCenterInViewGroup(unsigned groupNr);
194 
195  ctkPluginContext *mContext;
196  SessionStorageServicePtr mSession;
197  ClippersPtr mClippers;
198 
199  //From old ViewManager
200  LayoutRepositoryPtr mLayoutRepository;
201  QStringList mActiveLayout;
202  SyncedValuePtr mActiveView;
203  std::vector<ViewGroupPtr> mViewGroups;
204  CameraControlPtr mCameraControl;
205 
206  bool mGlobalObliqueOrientation;
207  SyncedValuePtr mGlobal2DZoomVal;
208 
209  InteractiveCropperPtr mInteractiveCropper;
210  SlicePlanesProxyPtr mSlicePlanesProxy;
211 
212  CameraStyleInteractorPtr mCameraStyleInteractor;
213 
214 };
215 typedef boost::shared_ptr<ViewImplService> ViewImplServicePtr;
216 
217 } /* namespace cx */
218 
219 #endif /* CXVIEWIMPLSERVICE_H_ */
220 
boost::shared_ptr< class CyclicActionLogger > CyclicActionLoggerPtr
boost::shared_ptr< class LayoutRepository > LayoutRepositoryPtr
RenderLoopPtr mRenderLoop
boost::shared_ptr< class ViewGroupData > ViewGroupDataPtr
Definition: cxViewGroup.h:50
Visualization services.
Definition: cxViewService.h:71
RenderWindowFactoryPtr mRenderWindowFactory
boost::shared_ptr< class SlicePlanesProxy > SlicePlanesProxyPtr
boost::shared_ptr< class CameraControl > CameraControlPtr
boost::shared_ptr< class VisServices > VisServicesPtr
Definition: cxMainWindow.h:61
VisServicesPtr mServices
boost::shared_ptr< class ViewWrapper > ViewWrapperPtr
boost::shared_ptr< class InteractiveCropper > InteractiveCropperPtr
boost::shared_ptr< class View > ViewPtr
boost::shared_ptr< class Clippers > ClippersPtr
std::vector< QPointer< ViewCollectionWidget > > mLayoutWidgets
boost::shared_ptr< class Data > DataPtr
Creates a pool of views and offers an interface to them, also handles layouts on a centralwidget...
boost::shared_ptr< RenderLoop > RenderLoopPtr
Definition: cxRenderLoop.h:108
boost::shared_ptr< class SyncedValue > SyncedValuePtr
Definition: cxViewGroup.h:51
boost::shared_ptr< class Navigation > NavigationPtr
boost::shared_ptr< class RenderWindowFactory > RenderWindowFactoryPtr
boost::shared_ptr< ViewImplService > ViewImplServicePtr
boost::shared_ptr< class CameraStyleInteractor > CameraStyleInteractorPtr
boost::shared_ptr< class SessionStorageService > SessionStorageServicePtr
Namespace for all CustusX production code.