CustusX  22.04-rc3
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) 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 #ifndef CXLAYOUTEDITORWIDGET_H_
12 #define CXLAYOUTEDITORWIDGET_H_
13 
14 #include "cxGuiExport.h"
15 
16 #include <map>
17 #include <set>
18 #include <QWidget>
19 #include <QLineEdit>
20 class QFrame;
21 class QSpinBox;
22 class QLabel;
23 class QBoxLayout;
24 class QGridLayout;
25 class QLineEdit;
26 #include "cxLayoutData.h"
27 
28 namespace cx
29 {
30 
31 
35 class cxGui_EXPORT SmallLineEdit : public QLineEdit
36 {
37 public:
38  SmallLineEdit(QWidget* parent = 0) : QLineEdit(parent) {}
39  virtual QSize sizeHint() const
40  {
41  QSize size = QLineEdit::minimumSizeHint();
42  size.setWidth(size.height()*2);
43  return size;
44  }
45 };
46 
51 class cxGui_EXPORT LayoutEditorWidget : public QWidget
52 {
53  Q_OBJECT
54 public:
55  struct GridElement
56  {
57  QFrame* mFrame;
58  QLabel* mLabel;
59  };
60 
61  LayoutEditorWidget(cx::ViewServicePtr viewService, QWidget* parent);
62  void setLayoutData(const LayoutData& data);
63  LayoutData getLayoutData() const;
64 
65 private slots:
66  void rowsColumnsChangedSlot();
67  void contextMenuSlot(const QPoint& point);
68  void splitActionSlot();
69  void mergeActionSlot();
70  void groupActionSlot();
71  void typeActionSlot();
72  void nameChanged();
73 
74 private:
75  void initCache();
76  void clearDisplay();
77  void updateGrid();
78  LayoutViewData getViewData(QPoint pt);
79  void colorRegion(LayoutRegion region, QString selectColor, QString backColor);
80  std::set<LayoutData::iterator> getSelectedViews();
81  void updateSelection(QPoint pos);
82  void setSaneGroupIDs();
83  QString getViewName(LayoutViewData data) const;
84  virtual void mouseMoveEvent(QMouseEvent* event);
85  virtual void mousePressEvent(QMouseEvent* event);
86  void onOffScreenRenderingChanged();
87 
88  QBoxLayout* mTopLayout;
89  QBoxLayout* mRCLayout;
90  QGridLayout* mLayout;
91  QSpinBox* mRowsEdit;
92  QSpinBox* mColsEdit;
93  QLineEdit* mNameEdit;
94  BoolPropertyPtr mOffScreenRendering;
95 
96  std::vector<std::vector<GridElement> > mViewDataCache;
97  LayoutData mViewData;
98  std::map<PLANE_TYPE, QString> mPlaneNames;
99  QPoint mClickPos;
100  LayoutRegion mSelection;
101  ViewServicePtr mViewService;
102 
103  struct ViewNamesType
104  {
105  ViewNamesType() {}
106  ViewNamesType(PLANE_TYPE plane, View::Type view, QString name) : mPlane(plane), mView(view), mName(name) {}
107  PLANE_TYPE mPlane;
108  View::Type mView;
109  QString mName;
110  };
111  std::vector<ViewNamesType> mViewNames;
112 
113 };
114 
115 
116 } // namespace cx
117 
118 #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.