Fraxinus  18.10
An IGT application
cxLayoutData.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 CXLAYOUTDATA_H_
13 #define CXLAYOUTDATA_H_
14 
15 #include "cxResourceVisualizationExport.h"
16 
17 #include <vector>
18 class QDomNode;
19 #include <QString>
20 #include "cxDefinitions.h"
21 #include "cxForwardDeclarations.h"
22 #include "cxView.h"
23 
24 namespace cx
25 {
32 struct cxResourceVisualization_EXPORT LayoutPosition
33 {
34  LayoutPosition() : row(0), col(0) {}
35  LayoutPosition(int r, int c) : row(r), col(c) {}
36  int row;
37  int col;
38 };
39 
40 struct cxResourceVisualization_EXPORT LayoutRegion
41 {
43  LayoutRegion(int r, int c, int rSpan = 1, int cSpan = 1) :
44  pos(r, c), span(rSpan, cSpan) {}
47 
48  bool contains(LayoutPosition p) const
49  {
50  return pos.row <= p.row && p.row < pos.row + span.row && pos.col <= p.col && p.col < pos.col + span.col;
51  }
52 };
53 
54 cxResourceVisualization_EXPORT LayoutRegion merge(LayoutRegion a, LayoutRegion b);
55 
59 {
60  LayoutViewData() : mGroup(-1), mPlane(ptCOUNT), mType(View::VIEW), mRegion(-1, -1, 1, 1) {}
61  LayoutViewData(int row, int col, int rowSpan = 1, int colSpan = 1) :
62  mGroup(-1), mPlane(ptCOUNT), mType(View::VIEW), mRegion(row, col, rowSpan, colSpan) {}
63  int mGroup;
64  PLANE_TYPE mPlane;
67 
68  void addXml(QDomNode node) const;
69  void parseXml(QDomNode node);
70  bool isValid() const { return (( mGroup>=0 )&&( mPlane!=ptCOUNT )); }
71 };
72 
76 class cxResourceVisualization_EXPORT LayoutData
77 {
78 public:
79  typedef std::vector<LayoutViewData> ViewDataContainer;
80  typedef ViewDataContainer::iterator iterator;
81  typedef ViewDataContainer::const_iterator const_iterator;
82  static const int MaxGridSize = 20;
83 
84 public:
85  static LayoutData createHeader(QString uid, QString name);
86  static LayoutData create(QString uid, QString name, int rows, int cols);
87  LayoutData();
88  QString getUid() const { return mUid; }
89  QString getName() const { return mName; }
90  bool getOffScreenRendering() const { return mOffScreenRendering; }
91  void setOffScreenRendering(bool val) { mOffScreenRendering = val; }
92  void setName(const QString& name) { mName = name; }
93  void resetUid(const QString& uid);
94  void setView(int group, PLANE_TYPE type, LayoutRegion region);
95  void setView(int group, View::Type type, LayoutRegion region);
97  iterator begin() { return mView.begin(); }
98  iterator end() { return mView.end(); }
99  const_iterator begin() const { return mView.begin(); }
100  const_iterator end() const { return mView.end(); }
101  iterator find(LayoutPosition pos);
102  bool isEmpty() const { return mSize.col == 0 || mSize.row == 0; }
103 
104  void split(iterator iter);
105  void split(LayoutRegion region);
106  bool merge(LayoutRegion region);
107  void resize(int rows, int cols);
108  LayoutPosition size() const { return mSize; }
109 
110  void addXml(QDomNode node) const;
111  void parseXml(QDomNode node);
112 
113 private:
114  QString mUid;
115  QString mName;
116  LayoutPosition mSize;
117  std::vector<LayoutViewData> mView;
118  bool mOffScreenRendering;
119 };
120 
124 } // namespace cx
125 
126 #endif /* CXLAYOUTDATA_H_ */
int mGroup
what group to connect to. -1 means not set.
Definition: cxLayoutData.h:63
LayoutPosition(int r, int c)
Definition: cxLayoutData.h:35
std::vector< LayoutViewData > ViewDataContainer
Definition: cxLayoutData.h:79
ViewDataContainer::iterator iterator
Definition: cxLayoutData.h:80
bool contains(LayoutPosition p) const
Definition: cxLayoutData.h:48
LayoutRegion(int r, int c, int rSpan=1, int cSpan=1)
Definition: cxLayoutData.h:43
LayoutPosition span
size of region
Definition: cxLayoutData.h:46
QString getUid() const
Definition: cxLayoutData.h:88
iterator begin()
Definition: cxLayoutData.h:97
bool isValid() const
Definition: cxLayoutData.h:70
void setName(const QString &name)
Definition: cxLayoutData.h:92
LayoutViewData(int row, int col, int rowSpan=1, int colSpan=1)
Definition: cxLayoutData.h:61
PLANE_TYPE mPlane
ptNOPLANE means 3D
Definition: cxLayoutData.h:64
LayoutRegion mRegion
Definition: cxLayoutData.h:66
const_iterator begin() const
Definition: cxLayoutData.h:99
LayoutPosition size() const
Definition: cxLayoutData.h:108
QString getName() const
Definition: cxLayoutData.h:89
LayoutPosition pos
start position of region
Definition: cxLayoutData.h:45
ViewDataContainer::const_iterator const_iterator
Definition: cxLayoutData.h:81
const_iterator end() const
Definition: cxLayoutData.h:100
iterator end()
Definition: cxLayoutData.h:98
View::Type mType
Definition: cxLayoutData.h:65
void setOffScreenRendering(bool val)
Definition: cxLayoutData.h:91
LayoutRegion merge(LayoutRegion a, LayoutRegion b)
bool isEmpty() const
Definition: cxLayoutData.h:102
bool getOffScreenRendering() const
Definition: cxLayoutData.h:90
Namespace for all CustusX production code.