CustusX  15.8
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxViewManager.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 CXVIEWMANAGER_H_
34 #define CXVIEWMANAGER_H_
35 
36 #include "org_custusx_core_view_Export.h"
37 
38 #include <map>
39 #include <vector>
40 #include <QObject>
41 
42 #include "cxData.h"
43 #include "cxDefinitions.h"
44 #include "cxForwardDeclarations.h"
45 //#include "cxLayoutData.h"
46 
47 class QActionGroup;
48 class QAction;
49 class QGridLayout;
50 class QWidget;
51 class QTime;
52 
53 namespace cx
54 {
55 class LayoutData;
56 struct LayoutViewData;
57 struct LayoutRegion;
58 class ViewCollectionWidget;
59 class ViewWrapper;
60 typedef boost::shared_ptr<class SyncedValue> SyncedValuePtr;
61 typedef boost::shared_ptr<class InteractiveCropper> InteractiveCropperPtr;
62 typedef boost::shared_ptr<class InteractiveClipper> InteractiveClipperPtr;
63 typedef boost::shared_ptr<class CyclicActionLogger> CyclicActionLoggerPtr;
64 typedef boost::shared_ptr<class CameraStyleInteractor> CameraStyleInteractorPtr;
65 typedef boost::shared_ptr<class RenderLoop> RenderLoopPtr;
66 typedef boost::shared_ptr<class LayoutRepository> LayoutRepositoryPtr;
67 typedef boost::shared_ptr<class VisServices> VisServicesPtr;
68 typedef boost::shared_ptr<class Navigation> NavigationPtr;
69 typedef boost::shared_ptr<class CameraControl> CameraControlPtr;
70 
71 typedef boost::shared_ptr<class ViewManager> VisualizationServiceOldPtr;
72 
129 class org_custusx_core_view_EXPORT ViewManager: public QObject
130 {
131 Q_OBJECT
132 public:
133  static VisualizationServiceOldPtr create(VisServicesPtr backend);
134  virtual ~ViewManager();
135 
136  ViewPtr get3DView(int group = 0, int index = 0);
137 
138  virtual ViewGroupDataPtr getViewGroup(int groupIdx) const;
139  unsigned viewGroupCount() const
140  {
141  int count = 0;
142  while(this->getViewGroup(count))
143  ++count;
144  return count;
145  }
146  virtual int getActiveViewGroup() const;
147 
148  LayoutRepositoryPtr getLayoutRepository();
149 
150  QActionGroup* createInteractorStyleActionGroup();
151  NavigationPtr getNavigation();
152 
156 // void initialize();
157  QWidget* getLayoutWidget(QWidget* parent, int index);
158 
159  void enableRender(bool val);
160  bool renderingIsEnabled() const;
161 
162  QString getActiveLayout(int widgetIndex=0) const;
163  void setActiveLayout(const QString& uid, int widgetIndex=0);
164 
165  InteractiveClipperPtr getClipper();
166  InteractiveCropperPtr getCropper();
167 
168  CyclicActionLoggerPtr getRenderTimer();
169 
170  void deactivateCurrentLayout();
171  void autoShowData(DataPtr data);
172  CameraControlPtr getCameraControl() { return mCameraControl; }
173  void clear();
174  //Interface for saving/loading
175  void addXml(QDomNode& parentNode);
176  void parseXml(QDomNode viewmanagerNode);
177 
178 signals:
179  void fps(int number);
180  void activeLayoutChanged();
181  void activeViewChanged();
182  void renderingEnabledChanged();
183 
184 protected slots:
185  void settingsChangedSlot(QString key);
186  void onLayoutRepositoryChanged(QString uid);
187 
188  void updateViews();
189  void updateCameraStyleActions();
190  void setActiveView(QString viewUid);
191 
192 protected:
193  ViewManager(VisServicesPtr backend);
194 
195  void syncOrientationMode(SyncedValuePtr val);
196 // void storeLayoutData(const LayoutData& data);
197  std::vector<ViewGroupPtr> getViewGroups() { return mViewGroups; }
198 
199  void activateView(ViewCollectionWidget* widget, LayoutViewData viewData);
200  ViewWrapperPtr createViewWrapper(ViewPtr view, LayoutViewData viewData);
201  int findGroupContaining3DViewGivenGuess(int preferredGroup);
202  QString getActiveView() const;
203 
204  void setRenderingInterval(int interval);
205  void setSlicePlanesProxyInViewsUpTo2DViewgroup();
206 
207  void loadGlobalSettings();
208  void saveGlobalSettings();
209  void activateViews(ViewCollectionWidget *widget, LayoutData next);
210  void rebuildLayouts();
211  void initializeGlobal2DZoom();
212  void initializeActiveView();
213  void layoutWidgetDestroyed(QObject *object);
214 
216  std::vector<QPointer<ViewCollectionWidget> > mLayoutWidgets;
217  QStringList mActiveLayout;
220  std::vector<ViewGroupPtr> mViewGroups;
222 
225 
229 
232 
233 private:
234  ViewManager(ViewManager const&);
235  ViewManager& operator=(ViewManager const&);
236 };
237 
241 } //namespace
242 
243 #endif /* CXVIEWMANAGER_H_ */
std::vector< ViewGroupPtr > getViewGroups()
std::vector< QPointer< ViewCollectionWidget > > mLayoutWidgets
SlicePlanesProxyPtr mSlicePlanesProxy
boost::shared_ptr< class ViewGroupData > ViewGroupDataPtr
Definition: cxViewGroup.h:50
boost::shared_ptr< class LayoutRepository > LayoutRepositoryPtr
boost::shared_ptr< class SlicePlanesProxy > SlicePlanesProxyPtr
boost::shared_ptr< class VisServices > VisServicesPtr
Definition: cxMainWindow.h:62
boost::shared_ptr< class ViewWrapper > ViewWrapperPtr
CameraControlPtr getCameraControl()
CameraControlPtr mCameraControl
unsigned viewGroupCount() const
boost::shared_ptr< class ViewManager > VisualizationServiceOldPtr
boost::shared_ptr< class InteractiveClipper > InteractiveClipperPtr
boost::shared_ptr< class View > ViewPtr
boost::shared_ptr< class Navigation > NavigationPtr
Definition: cxViewGroup.h:54
SyncedValuePtr mGlobal2DZoomVal
boost::shared_ptr< class Data > DataPtr
SyncedValuePtr mActiveView
boost::shared_ptr< class CyclicActionLogger > CyclicActionLoggerPtr
boost::shared_ptr< RenderLoop > RenderLoopPtr
Definition: cxRenderLoop.h:108
boost::shared_ptr< class InteractiveCropper > InteractiveCropperPtr
CameraStyleInteractorPtr mCameraStyleInteractor
boost::shared_ptr< class CameraControl > CameraControlPtr
Definition: cxMainWindow.h:58
QStringList mActiveLayout
the active layout (type)
LayoutRepositoryPtr mLayoutRepository
bool mGlobalObliqueOrientation
controlling whether or not all 2d views should be oblique or orthogonal
Creates a pool of views and offers an interface to them, also handles layouts on a centralwidget...
boost::shared_ptr< class SyncedValue > SyncedValuePtr
Definition: cxViewGroup.h:51
std::vector< ViewGroupPtr > mViewGroups
VisServicesPtr mBackend
RenderLoopPtr mRenderLoop
boost::shared_ptr< class CameraStyleInteractor > CameraStyleInteractorPtr
InteractiveCropperPtr mInteractiveCropper
InteractiveClipperPtr mInteractiveClipper