CustusX  16.12
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 #include "cxViewService.h"
47 
48 class QActionGroup;
49 class QAction;
50 class QGridLayout;
51 class QWidget;
52 class QTime;
53 
54 namespace cx
55 {
56 class LayoutData;
57 struct LayoutViewData;
58 struct LayoutRegion;
59 class ViewCollectionWidget;
60 class ViewWrapper;
61 typedef boost::shared_ptr<class SyncedValue> SyncedValuePtr;
62 typedef boost::shared_ptr<class InteractiveCropper> InteractiveCropperPtr;
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> ViewManagerPtr;
72 
129 class org_custusx_core_view_EXPORT ViewManager: public QObject
130 {
131 Q_OBJECT
132 public:
133  static ViewManagerPtr 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* getInteractorStyleActionGroup();
151  NavigationPtr getNavigation(int group = 0);
152 
156 // void initialize();
157  QWidget* createLayoutWidget(QWidget* parent, int index);
158  QWidget* getLayoutWidget(int index);
159 
160  void enableRender(bool val);
161  bool renderingIsEnabled() const;
162 
163  QString getActiveLayout(int widgetIndex=0) const;
164  void setActiveLayout(const QString& uid, int widgetIndex=0);
165 
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  void centerToImageCenterInViewGroup(unsigned groupNr);
179  void setCameraStyle(CAMERA_STYLE_TYPE style, int groupIdx);
180  void addDefaultLayout(LayoutData layoutData);
181 
182  void enableContextMenuForViews(bool enable=true);
183 signals:
184  void fps(int number);
185  void activeLayoutChanged();
186  void activeViewChanged();
187  void renderingEnabledChanged();
188  void pointSampled(Vector3D p_r);
189  void renderFinished();
190 
191 
192 protected slots:
193  void settingsChangedSlot(QString key);
194  void onLayoutRepositoryChanged(QString uid);
195 
196  void updateViews();
197  void updateCameraStyleActions();
198  void setActiveView(QString viewUid);
199  void layoutWidgetDestroyed(QObject *object);
200 
201 protected:
202  ViewManager(VisServicesPtr backend);
203  std::vector<ViewGroupPtr> getViewGroups() { return mViewGroups; }
204 
205  void activateView(ViewCollectionWidget* widget, LayoutViewData viewData);
206  ViewWrapperPtr createViewWrapper(ViewPtr view, LayoutViewData viewData);
207  int findGroupContaining3DViewGivenGuess(int preferredGroup);
208  QString getActiveView() const;
209 
210  void setRenderingInterval(int interval);
211  void setSlicePlanesProxyInViewsUpTo2DViewgroup();
212 
213  void loadGlobalSettings();
214  void saveGlobalSettings();
215  void activateViews(ViewCollectionWidget *widget, LayoutData next);
216  void rebuildLayouts();
217  void initializeGlobal2DZoom();
218  void initializeActiveView();
219 
221  std::vector<QPointer<ViewCollectionWidget> > mLayoutWidgets;
222  QStringList mActiveLayout;
225  std::vector<ViewGroupPtr> mViewGroups;
227 
230 
233 
236 
237 private:
238  ViewManager(ViewManager const&);
239  ViewManager& operator=(ViewManager const&);
240 protected:
241  void autoShowInViewGroups(DataPtr data);
242  void autoResetCameraToSuperiorView();
243  void autoCenterToImageCenter();
244  QList<unsigned> getViewGroupsToAutoShowIn();
245 };
246 
250 } //namespace
251 
252 #endif /* CXVIEWMANAGER_H_ */
std::vector< ViewGroupPtr > getViewGroups()
std::vector< QPointer< ViewCollectionWidget > > mLayoutWidgets
SlicePlanesProxyPtr mSlicePlanesProxy
boost::shared_ptr< class ViewManager > ViewManagerPtr
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 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:109
boost::shared_ptr< class InteractiveCropper > InteractiveCropperPtr
CameraStyleInteractorPtr mCameraStyleInteractor
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:63
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