CustusX  18.04-rc1
An IGT application
cxBaseWidget.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 CXBASEWIDGET_H_
13 #define CXBASEWIDGET_H_
14 
15 #include "cxResourceWidgetsExport.h"
16 #include <QFrame>
17 #include <QToolButton>
18 #include <QAction>
19 #include <QLayout>
20 #include <iostream>
21 #include <boost/shared_ptr.hpp>
23 #include "boost/function.hpp"
24 
25 class QWidget;
26 class QGroupBox;
27 class QCheckBox;
28 class QLabel;
29 
41 class cxResourceWidgets_EXPORT CXFrame : public QFrame
42 {
43  Q_OBJECT
44 public:
45  CXFrame(QWidget* parent) : QFrame(parent) {}
46  virtual ~CXFrame() {}
47 };
48 
54 class cxResourceWidgets_EXPORT CXToolButton : public QToolButton
55 {
56  Q_OBJECT
57 public:
58  CXToolButton(QWidget* parent=0) : QToolButton(parent) {}
59 };
60 
66 class cxResourceWidgets_EXPORT CXSmallToolButton : public CXToolButton
67 {
68  Q_OBJECT
69 public:
70  CXSmallToolButton(QWidget* parent=0) : CXToolButton(parent) {}
71 };
72 
73 
74 namespace cx
75 {
76 typedef boost::shared_ptr<class PatientModelService> PatientModelServicePtr;
77 typedef boost::shared_ptr<class ViewService> ViewServicePtr;
78 typedef boost::shared_ptr<class TrackingService> TrackingServicePtr;
88 class cxResourceWidgets_EXPORT BaseWidget: public OptimizedUpdateWidget
89 {
90  Q_OBJECT
91 
92 public:
93  BaseWidget(QWidget* parent, QString objectName, QString windowTitle);
94  virtual ~BaseWidget() {}
95 
96  QWidget* createMethodWidget(QWidget* inputWidget, QWidget* outputWidget, QString methodname,
97  bool inputChecked = false, bool outputVisible = true);
98 
99  QGroupBox* createGroupbox(QWidget* widget, QString boxname);
100  static QFrame* createHorizontalLine();
101  QGroupBox* wrapInGroupBox(QWidget* base, QString name);
102  CXFrame* wrapInFrame(QWidget* base);
103 
108  QAction* createAction2(QObject* parent, QIcon iconName, QString text, QString tip, QLayout* layout=NULL, QToolButton* button = new QToolButton())
109  {
110  if (tip.isEmpty())
111  tip = text;
112  QAction* action = new QAction(iconName, text, parent);
113  action->setStatusTip(tip);
114  action->setWhatsThis(tip);
115  action->setToolTip(tip);
116  if (layout)
117  {
118  button->setDefaultAction(action);
119  layout->addWidget(button);
120  }
121  return action;
122  }
123 
128  template<class T>
129  QAction* createAction(QObject* parent, QIcon iconName, QString text, QString tip, T slot, QLayout* layout=NULL, QToolButton* button = new QToolButton())
130  {
131  QAction* action = createAction2(parent, iconName, text, tip, layout, button);
132  connect(action, SIGNAL(triggered()), this, slot);
133  return action;
134  }
135 
136 
137 public slots:
138  void adjustSizeSlot();
139 
140 protected:
141  virtual void showEvent(QShowEvent* event);
142 
143 private:
144  QString mObjectName;
145  QString mWindowTitle;
146 };
147 
148 }
149 
154 #endif /* CXBASEWIDGET_H_ */
CXFrame(QWidget *parent)
Definition: cxBaseWidget.h:45
boost::shared_ptr< class TrackingService > TrackingServicePtr
boost::shared_ptr< class ViewService > ViewServicePtr
virtual ~CXFrame()
Definition: cxBaseWidget.h:46
CXSmallToolButton(QWidget *parent=0)
Definition: cxBaseWidget.h:70
QAction * createAction(QObject *parent, QIcon iconName, QString text, QString tip, T slot, QLayout *layout=NULL, QToolButton *button=new QToolButton())
Definition: cxBaseWidget.h:129
virtual ~BaseWidget()
Definition: cxBaseWidget.h:94
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:88
Interface for all classes following the modified/prepaint paradigm.
CXToolButton(QWidget *parent=0)
Definition: cxBaseWidget.h:58
QAction * createAction2(QObject *parent, QIcon iconName, QString text, QString tip, QLayout *layout=NULL, QToolButton *button=new QToolButton())
Definition: cxBaseWidget.h:108
Namespace for all CustusX production code.