Fraxinus  16.5.0-fx-rc8
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 signals:
182  void fps(int number);
183  void activeLayoutChanged();
184  void activeViewChanged();
185  void renderingEnabledChanged();
186  void pointSampled(Vector3D p_r);
187  void renderFinished();
188 
189 protected slots:
190  void settingsChangedSlot(QString key);
191  void onLayoutRepositoryChanged(QString uid);
192 
193  void updateViews();
194  void updateCameraStyleActions();
195  void setActiveView(QString viewUid);
196 
197 protected:
198  ViewManager(VisServicesPtr backend);
199  std::vector<ViewGroupPtr> getViewGroups() { return mViewGroups; }
200 
201  void activateView(ViewCollectionWidget* widget, LayoutViewData viewData);
202  ViewWrapperPtr createViewWrapper(ViewPtr view, LayoutViewData viewData);
203  int findGroupContaining3DViewGivenGuess(int preferredGroup);
204  QString getActiveView() const;
205 
206  void setRenderingInterval(int interval);
207  void setSlicePlanesProxyInViewsUpTo2DViewgroup();
208 
209  void loadGlobalSettings();
210  void saveGlobalSettings();
211  void activateViews(ViewCollectionWidget *widget, LayoutData next);
212  void rebuildLayouts();
213  void initializeGlobal2DZoom();
214  void initializeActiveView();
215  void layoutWidgetDestroyed(QObject *object);
216 
218  std::vector<QPointer<ViewCollectionWidget> > mLayoutWidgets;
219  QStringList mActiveLayout;
222  std::vector<ViewGroupPtr> mViewGroups;
224 
227 
230 
233 
234 private:
235  ViewManager(ViewManager const&);
236  ViewManager& operator=(ViewManager const&);
237 protected:
238  void autoShowInViewGroups(DataPtr data);
239  void autoResetCameraToSuperiorView();
240  void autoCenterToImageCenter();
241  QList<unsigned> getViewGroupsToAutoShowIn();
242 };
243 
247 } //namespace
248 
249 #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