NorMIT-nav  22.09
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_ */
cx::LayoutRegion::LayoutRegion
LayoutRegion()
Definition: cxLayoutData.h:42
cx::LayoutViewData::mPlane
PLANE_TYPE mPlane
ptNOPLANE means 3D
Definition: cxLayoutData.h:64
cx::LayoutViewData::isValid
bool isValid() const
Definition: cxLayoutData.h:70
cx::LayoutRegion::span
LayoutPosition span
size of region
Definition: cxLayoutData.h:46
cx::LayoutViewData::parseXml
void parseXml(QDomNode node)
load state from xml
Definition: cxLayoutData.cpp:48
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::LayoutData::iterator
ViewDataContainer::iterator iterator
Definition: cxLayoutData.h:80
cx::LayoutPosition::LayoutPosition
LayoutPosition()
Definition: cxLayoutData.h:34
cx::LayoutData::getName
QString getName() const
Definition: cxLayoutData.h:89
cxForwardDeclarations.h
cx::LayoutData::setOffScreenRendering
void setOffScreenRendering(bool val)
Definition: cxLayoutData.h:91
cxDefinitions.h
cx::LayoutViewData::mType
View::Type mType
Definition: cxLayoutData.h:65
cx::LayoutViewData::mGroup
int mGroup
what group to connect to. -1 means not set.
Definition: cxLayoutData.h:63
cx::LayoutData::ViewDataContainer
std::vector< LayoutViewData > ViewDataContainer
Definition: cxLayoutData.h:79
cx::LayoutData::size
LayoutPosition size() const
Definition: cxLayoutData.h:108
cx::LayoutData::getUid
QString getUid() const
Definition: cxLayoutData.h:88
cx::LayoutPosition::col
int col
column
Definition: cxLayoutData.h:37
cx::merge
LayoutRegion merge(LayoutRegion a, LayoutRegion b)
Definition: cxLayoutData.cpp:22
cx::LayoutData::begin
const_iterator begin() const
Definition: cxLayoutData.h:99
cx::LayoutPosition
Definition: cxLayoutData.h:32
cx::LayoutData
Definition: cxLayoutData.h:76
cx::LayoutData::getOffScreenRendering
bool getOffScreenRendering() const
Definition: cxLayoutData.h:90
cx::LayoutViewData
Definition: cxLayoutData.h:58
cx::LayoutData::end
const_iterator end() const
Definition: cxLayoutData.h:100
cxView.h
cx::LayoutRegion::LayoutRegion
LayoutRegion(int r, int c, int rSpan=1, int cSpan=1)
Definition: cxLayoutData.h:43
cx::LayoutRegion
Definition: cxLayoutData.h:40
cx::LayoutViewData::LayoutViewData
LayoutViewData(int row, int col, int rowSpan=1, int colSpan=1)
Definition: cxLayoutData.h:61
cx::LayoutViewData::mRegion
LayoutRegion mRegion
Definition: cxLayoutData.h:66
cx::LayoutRegion::contains
bool contains(LayoutPosition p) const
Definition: cxLayoutData.h:48
cx::LayoutData::isEmpty
bool isEmpty() const
Definition: cxLayoutData.h:102
cx::LayoutViewData::LayoutViewData
LayoutViewData()
Definition: cxLayoutData.h:60
cx::LayoutViewData::addXml
void addXml(QDomNode node) const
save state to xml
Definition: cxLayoutData.cpp:36
cx::View
Definition: cxView.h:48
cx::LayoutPosition::row
int row
row
Definition: cxLayoutData.h:36
cx::LayoutData::begin
iterator begin()
Definition: cxLayoutData.h:97
cx::LayoutPosition::LayoutPosition
LayoutPosition(int r, int c)
Definition: cxLayoutData.h:35
cx::LayoutRegion::pos
LayoutPosition pos
start position of region
Definition: cxLayoutData.h:45
cx::LayoutData::setName
void setName(const QString &name)
Definition: cxLayoutData.h:92
cx::LayoutData::const_iterator
ViewDataContainer::const_iterator const_iterator
Definition: cxLayoutData.h:81
cx::View::Type
Type
Definition: cxView.h:52
cx::LayoutData::end
iterator end()
Definition: cxLayoutData.h:98