Fraxinus  17.12
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) 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 CXLAYOUTDATA_H_
34 #define CXLAYOUTDATA_H_
35 
36 #include "cxResourceVisualizationExport.h"
37 
38 #include <vector>
39 class QDomNode;
40 #include <QString>
41 #include "cxDefinitions.h"
42 #include "cxForwardDeclarations.h"
43 #include "cxView.h"
44 
45 namespace cx
46 {
53 struct cxResourceVisualization_EXPORT LayoutPosition
54 {
55  LayoutPosition() : row(0), col(0) {}
56  LayoutPosition(int r, int c) : row(r), col(c) {}
57  int row;
58  int col;
59 };
60 
61 struct cxResourceVisualization_EXPORT LayoutRegion
62 {
64  LayoutRegion(int r, int c, int rSpan = 1, int cSpan = 1) :
65  pos(r, c), span(rSpan, cSpan) {}
68 
69  bool contains(LayoutPosition p) const
70  {
71  return pos.row <= p.row && p.row < pos.row + span.row && pos.col <= p.col && p.col < pos.col + span.col;
72  }
73 };
74 
75 cxResourceVisualization_EXPORT LayoutRegion merge(LayoutRegion a, LayoutRegion b);
76 
80 {
81  LayoutViewData() : mGroup(-1), mPlane(ptCOUNT), mType(View::VIEW), mRegion(-1, -1, 1, 1) {}
82  LayoutViewData(int row, int col, int rowSpan = 1, int colSpan = 1) :
83  mGroup(-1), mPlane(ptCOUNT), mType(View::VIEW), mRegion(row, col, rowSpan, colSpan) {}
84  int mGroup;
85  PLANE_TYPE mPlane;
88 
89  void addXml(QDomNode node) const;
90  void parseXml(QDomNode node);
91  bool isValid() const { return (( mGroup>=0 )&&( mPlane!=ptCOUNT )); }
92 };
93 
97 class cxResourceVisualization_EXPORT LayoutData
98 {
99 public:
100  typedef std::vector<LayoutViewData> ViewDataContainer;
101  typedef ViewDataContainer::iterator iterator;
102  typedef ViewDataContainer::const_iterator const_iterator;
103  static const int MaxGridSize = 20;
104 
105 public:
106  static LayoutData createHeader(QString uid, QString name);
107  static LayoutData create(QString uid, QString name, int rows, int cols);
108  LayoutData();
109  QString getUid() const { return mUid; }
110  QString getName() const { return mName; }
111  bool getOffScreenRendering() const { return mOffScreenRendering; }
112  void setOffScreenRendering(bool val) { mOffScreenRendering = val; }
113  void setName(const QString& name) { mName = name; }
114  void resetUid(const QString& uid);
115  void setView(int group, PLANE_TYPE type, LayoutRegion region);
116  void setView(int group, View::Type type, LayoutRegion region);
117  LayoutViewData& get(LayoutPosition pos);
118  iterator begin() { return mView.begin(); }
119  iterator end() { return mView.end(); }
120  const_iterator begin() const { return mView.begin(); }
121  const_iterator end() const { return mView.end(); }
122  iterator find(LayoutPosition pos);
123  bool isEmpty() const { return mSize.col == 0 || mSize.row == 0; }
124 
125  void split(iterator iter);
126  void split(LayoutRegion region);
127  bool merge(LayoutRegion region);
128  void resize(int rows, int cols);
129  LayoutPosition size() const { return mSize; }
130 
131  void addXml(QDomNode node) const;
132  void parseXml(QDomNode node);
133 
134 private:
135  QString mUid;
136  QString mName;
137  LayoutPosition mSize;
138  std::vector<LayoutViewData> mView;
139  bool mOffScreenRendering;
140 };
141 
145 } // namespace cx
146 
147 #endif /* CXLAYOUTDATA_H_ */
int mGroup
what group to connect to. -1 means not set.
Definition: cxLayoutData.h:84
LayoutPosition(int r, int c)
Definition: cxLayoutData.h:56
std::vector< LayoutViewData > ViewDataContainer
Definition: cxLayoutData.h:100
ViewDataContainer::iterator iterator
Definition: cxLayoutData.h:101
bool contains(LayoutPosition p) const
Definition: cxLayoutData.h:69
LayoutRegion(int r, int c, int rSpan=1, int cSpan=1)
Definition: cxLayoutData.h:64
LayoutPosition span
size of region
Definition: cxLayoutData.h:67
QString getUid() const
Definition: cxLayoutData.h:109
iterator begin()
Definition: cxLayoutData.h:118
bool isValid() const
Definition: cxLayoutData.h:91
void setName(const QString &name)
Definition: cxLayoutData.h:113
LayoutViewData(int row, int col, int rowSpan=1, int colSpan=1)
Definition: cxLayoutData.h:82
PLANE_TYPE mPlane
ptNOPLANE means 3D
Definition: cxLayoutData.h:85
LayoutRegion mRegion
Definition: cxLayoutData.h:87
const_iterator begin() const
Definition: cxLayoutData.h:120
LayoutPosition size() const
Definition: cxLayoutData.h:129
QString getName() const
Definition: cxLayoutData.h:110
LayoutPosition pos
start position of region
Definition: cxLayoutData.h:66
ViewDataContainer::const_iterator const_iterator
Definition: cxLayoutData.h:102
const_iterator end() const
Definition: cxLayoutData.h:121
iterator end()
Definition: cxLayoutData.h:119
View::Type mType
Definition: cxLayoutData.h:86
void setOffScreenRendering(bool val)
Definition: cxLayoutData.h:112
LayoutRegion merge(LayoutRegion a, LayoutRegion b)
bool isEmpty() const
Definition: cxLayoutData.h:123
bool getOffScreenRendering() const
Definition: cxLayoutData.h:111
Namespace for all CustusX production code.