CustusX  22.04
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) 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 #ifndef CXVIEWIMPLSERVICE_H_
13 #define CXVIEWIMPLSERVICE_H_
14 
15 #include "cxViewService.h"
16 #include "org_custusx_core_view_Export.h"
17 class ctkPluginContext;
18 class QDomElement;
19 
20 namespace cx
21 {
22 class ViewCollectionWidget;
23 typedef boost::shared_ptr<class SessionStorageService> SessionStorageServicePtr;
24 typedef boost::shared_ptr<class SyncedValue> SyncedValuePtr;
25 typedef boost::shared_ptr<class RenderLoop> RenderLoopPtr;
26 typedef boost::shared_ptr<class CameraStyleInteractor> CameraStyleInteractorPtr;
27 
28 
83 class org_custusx_core_view_EXPORT ViewImplService : public ViewService
84 {
85  Q_OBJECT
86  Q_INTERFACES(cx::ViewService)
87 public:
88  ViewImplService(ctkPluginContext* context);
89  virtual ~ViewImplService();
90 
91  virtual ViewPtr get3DView(int group = 0, int index = 0);
92 
93  virtual int getActiveGroupId() const;
94  virtual ViewGroupDataPtr getGroup(int groupIdx) const;
95  virtual void setRegistrationMode(REGISTRATION_STATUS mode);
96 
97  virtual void autoShowData(DataPtr data);
98  virtual void enableRender(bool val);
99  virtual bool renderingIsEnabled() const;
100 
101  virtual QWidget* createLayoutWidget(QWidget* parent, int index);
102  virtual QWidget* getLayoutWidget(int index);
103  virtual QString getActiveLayout(int widgetIndex = 0) const;
104  virtual void setActiveLayout(const QString& uid, int widgetIndex);
105  virtual ClippersPtr getClippers();
106  virtual InteractiveCropperPtr getCropper();
107  virtual CyclicActionLoggerPtr getRenderTimer();
108  virtual NavigationPtr getNavigation(int group = 0);
109  virtual LayoutRepositoryPtr getLayoutRepository();
110  virtual CameraControlPtr getCameraControl();
111  virtual QActionGroup* getInteractorStyleActionGroup();
112  virtual void centerToImageCenterInActiveViewGroup();
113  virtual void addDefaultLayout(LayoutData layoutData);
114  virtual void enableContextMenuForViews(bool enable=true);
115 
116  virtual bool isNull();
117 
118  virtual void setCameraStyle(CAMERA_STYLE_TYPE style, int groupIdx);
119  virtual void zoomCamera3D(int viewGroup3DNumber, int zoomFactor);
120 
121 public slots:
122  virtual void aboutToStop();
123 
124 protected slots:
125  void layoutWidgetDestroyed(QObject *object);
126 
127 private slots:
128  void onSessionChanged();
129  void onSessionCleared();
130  void onSessionLoad(QDomElement& node);
131  void onSessionSave(QDomElement& node);
132 
133  void updateViews();
134  void updateCameraStyleActions();
135  void onLayoutRepositoryChanged(QString uid);
136  void setActiveView(QString viewUid);
137  void settingsChangedSlot(QString key);
138 
139 protected:
140  void rebuildLayouts();
141  QList<unsigned> getViewGroupsToAutoShowIn();
142 
144  std::vector<QPointer<ViewCollectionWidget> > mLayoutWidgets;
146  RenderLoopPtr mRenderLoop;
147 
148 private:
149  void init();
150  void loadGlobalSettings();
151  void saveGlobalSettings();
152  void initializeGlobal2DZoom();
153  void initializeActiveView();
154  std::vector<ViewGroupPtr> getViewGroups();
155  QString getActiveView() const;
156 
157  //Interface for saving/loading
158  void addXml(QDomNode& parentNode);
159  void parseXml(QDomNode viewmanagerNode);
160  void clear();
161  void deactivateCurrentLayout();
162  unsigned viewGroupCount() const;
163  void activateViews(ViewCollectionWidget *widget, LayoutData next);
164  void activateView(ViewCollectionWidget* widget, LayoutViewData viewData);
165  void setSlicePlanesProxyInViewsUpTo2DViewgroup();
166  void setRenderingInterval(int interval);
167  ViewWrapperPtr createViewWrapper(ViewPtr view, LayoutViewData viewData);
168  int findGroupContaining3DViewGivenGuess(int preferredGroup);
169  void autoShowInViewGroups(DataPtr data);
170  void autoResetCameraToSuperiorView();
171  void autoCenterToImageCenter();
172  void centerToImageCenterInViewGroup(unsigned groupNr);
173 
174  ctkPluginContext *mContext;
175  SessionStorageServicePtr mSession;
176  ClippersPtr mClippers;
177 
178  //From old ViewManager
179  LayoutRepositoryPtr mLayoutRepository;
180  QStringList mActiveLayout;
181  SyncedValuePtr mActiveView;
182  std::vector<ViewGroupPtr> mViewGroups;
183  CameraControlPtr mCameraControl;
184 
185  bool mGlobalObliqueOrientation;
186  SyncedValuePtr mGlobal2DZoomVal;
187 
188  InteractiveCropperPtr mInteractiveCropper;
189  SlicePlanesProxyPtr mSlicePlanesProxy;
190 
191  CameraStyleInteractorPtr mCameraStyleInteractor;
192 
193 };
194 typedef boost::shared_ptr<ViewImplService> ViewImplServicePtr;
195 
196 } /* namespace cx */
197 
198 #endif /* CXVIEWIMPLSERVICE_H_ */
199 
boost::shared_ptr< class CyclicActionLogger > CyclicActionLoggerPtr
boost::shared_ptr< class LayoutRepository > LayoutRepositoryPtr
RenderLoopPtr mRenderLoop
boost::shared_ptr< class ViewGroupData > ViewGroupDataPtr
Definition: cxViewGroup.h:29
Visualization services.
Definition: cxViewService.h:50
RenderWindowFactoryPtr mRenderWindowFactory
boost::shared_ptr< class SlicePlanesProxy > SlicePlanesProxyPtr
boost::shared_ptr< class CameraControl > CameraControlPtr
boost::shared_ptr< class VisServices > VisServicesPtr
Definition: cxMainWindow.h:40
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:87
boost::shared_ptr< class SyncedValue > SyncedValuePtr
Definition: cxViewGroup.h:30
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.