Fraxinus  17.12
An IGT application
cxLayoutEditorWidget.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 #ifndef CXLAYOUTEDITORWIDGET_H_
33 #define CXLAYOUTEDITORWIDGET_H_
34 
35 #include "cxGuiExport.h"
36 
37 #include <map>
38 #include <set>
39 #include <QWidget>
40 #include <QLineEdit>
41 class QFrame;
42 class QSpinBox;
43 class QLabel;
44 class QBoxLayout;
45 class QGridLayout;
46 class QLineEdit;
47 #include "cxLayoutData.h"
48 
49 namespace cx
50 {
51 
52 
56 class cxGui_EXPORT SmallLineEdit : public QLineEdit
57 {
58 public:
59  SmallLineEdit(QWidget* parent = 0) : QLineEdit(parent) {}
60  virtual QSize sizeHint() const
61  {
62  QSize size = QLineEdit::minimumSizeHint();
63  size.setWidth(size.height()*2);
64  return size;
65  }
66 };
67 
72 class cxGui_EXPORT LayoutEditorWidget : public QWidget
73 {
74  Q_OBJECT
75 public:
76  struct GridElement
77  {
78  QFrame* mFrame;
79  QLabel* mLabel;
80  };
81 
82  LayoutEditorWidget(cx::ViewServicePtr viewService, QWidget* parent);
83  void setLayoutData(const LayoutData& data);
84  LayoutData getLayoutData() const;
85 
86 private slots:
87  void rowsColumnsChangedSlot();
88  void contextMenuSlot(const QPoint& point);
89  void splitActionSlot();
90  void mergeActionSlot();
91  void groupActionSlot();
92  void typeActionSlot();
93  void nameChanged();
94 
95 private:
96  void initCache();
97  void clearDisplay();
98  void updateGrid();
99  LayoutViewData getViewData(QPoint pt);
100  void colorRegion(LayoutRegion region, QString selectColor, QString backColor);
101  std::set<LayoutData::iterator> getSelectedViews();
102  void updateSelection(QPoint pos);
103  void setSaneGroupIDs();
104  QString getViewName(LayoutViewData data) const;
105  virtual void mouseMoveEvent(QMouseEvent* event);
106  virtual void mousePressEvent(QMouseEvent* event);
107  void onOffScreenRenderingChanged();
108 
109  QBoxLayout* mTopLayout;
110  QBoxLayout* mRCLayout;
111  QGridLayout* mLayout;
112  QSpinBox* mRowsEdit;
113  QSpinBox* mColsEdit;
114  QLineEdit* mNameEdit;
115  BoolPropertyPtr mOffScreenRendering;
116 
117  std::vector<std::vector<GridElement> > mViewDataCache;
118  LayoutData mViewData;
119  std::map<PLANE_TYPE, QString> mPlaneNames;
120  QPoint mClickPos;
121  LayoutRegion mSelection;
122  ViewServicePtr mViewService;
123 
124  struct ViewNamesType
125  {
126  ViewNamesType() {}
127  ViewNamesType(PLANE_TYPE plane, View::Type view, QString name) : mPlane(plane), mView(view), mName(name) {}
128  PLANE_TYPE mPlane;
129  View::Type mView;
130  QString mName;
131  };
132  std::vector<ViewNamesType> mViewNames;
133 
134 };
135 
136 
137 } // namespace cx
138 
139 #endif /* CXLAYOUTEDITORWIDGET_H_ */
virtual QSize sizeHint() const
boost::shared_ptr< class ViewService > ViewServicePtr
SmallLineEdit(QWidget *parent=0)
boost::shared_ptr< class BoolProperty > BoolPropertyPtr
Namespace for all CustusX production code.