Fraxinus  2023.01.05-dev+develop.0da12
An IGT application
cxBaseWidget.cpp
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 #include "cxBaseWidget.h"
13 #include "cxTypeConversions.h"
14 
15 #include <QVBoxLayout>
16 #include <QGroupBox>
17 #include <QCheckBox>
18 #include <QLabel>
19 
20 namespace cx
21 {
22 
23 BaseWidget::BaseWidget(QWidget* parent, QString objectName, QString windowTitle) :
24  OptimizedUpdateWidget(parent), mObjectName(objectName), mWindowTitle(windowTitle)
25 {
26  this->setFocusPolicy(Qt::StrongFocus); // needed for help system: focus is used to display help text
27  this->setObjectName(mObjectName);
28  this->setWindowTitle(mWindowTitle);
29 }
30 
31 QWidget* BaseWidget::createMethodWidget(QWidget* inputWidget, QWidget* outputWidget, QString methodname, bool inputChecked, bool outputVisible)
32 {
33  QWidget* retval = new QWidget(this);
34  QVBoxLayout* toplayout = new QVBoxLayout(retval);
35  QGridLayout* layout = new QGridLayout();
36  toplayout->addLayout(layout);
37  toplayout->addStretch();
38 
39  QLabel* methodLabel = new QLabel("<b>" + methodname + "</b>");
40  QCheckBox* checkBox = new QCheckBox("generate");
41 
42  inputWidget->setVisible(inputChecked);
43  outputWidget->setVisible(outputVisible);
44  connect(checkBox, SIGNAL(clicked(bool)), inputWidget, SLOT(setVisible(bool)));
45 
46  layout->addWidget(methodLabel, 0, 0);
47  layout->addWidget(checkBox, 0, 1);
48  layout->addWidget(inputWidget, 1, 0, 1, 2);
49  layout->addWidget(outputWidget, 2, 0, 1, 2);
50 
51  return retval;
52 }
53 
54 QGroupBox* BaseWidget::createGroupbox(QWidget* widget, QString boxname)
55 {
56  QGroupBox* retval = new QGroupBox(this);
57  QVBoxLayout* toplayout = new QVBoxLayout(retval);
58 
59  QLabel* nameLabel = new QLabel(boxname);
60  toplayout->addWidget(nameLabel);
61  toplayout->addWidget(widget);
62 
63  return retval;
64 }
65 
67 {
68  QFrame* retval = new QFrame();
69  retval->setFrameStyle(QFrame::Sunken + QFrame::HLine);
70  return retval;
71 }
72 
74 {
75  CXFrame* frame = new CXFrame(NULL);
76  QVBoxLayout* layout = new QVBoxLayout(frame);
77  layout->setMargin(0);
78  layout->addWidget(base);
79  return frame;
80 }
81 
82 QGroupBox* BaseWidget::wrapInGroupBox(QWidget* base, QString name)
83 {
84  QGroupBox* groupBox = new QGroupBox(name);
85  QVBoxLayout* layout = new QVBoxLayout(groupBox);
86  layout->setMargin(2);
87  layout->addWidget(base);
88  return groupBox;
89 }
90 
92 {
93  this->parentWidget()->adjustSize();
94  this->adjustSize();
95 }
96 
97 void BaseWidget::showEvent(QShowEvent* event)
98 {
99  QWidget::showEvent(event);
100 }
101 
102 }
103 
QGroupBox * createGroupbox(QWidget *widget, QString boxname)
Create a group box with a given name.
QGroupBox * wrapInGroupBox(QWidget *base, QString name)
void adjustSizeSlot()
virtual void showEvent(QShowEvent *event)
QWidget * createMethodWidget(QWidget *inputWidget, QWidget *outputWidget, QString methodname, bool inputChecked=false, bool outputVisible=true)
Create a specialized widget for filters, with input/ouput, enable and options.
static QFrame * createHorizontalLine()
Creates a horizontal line which can be inserted into widgets.
CXFrame * wrapInFrame(QWidget *base)
BaseWidget(QWidget *parent, QString objectName, QString windowTitle)
Interface for all classes following the modified/prepaint paradigm.
Namespace for all CustusX production code.