PeriDyno 1.0.0
Loading...
Searching...
No Matches
QStateFieldWidget.cpp
Go to the documentation of this file.
1#include "QStateFieldWidget.h"
2#include "qmainwindow.h"
3
4#include <QHBoxLayout>
5#include <QCheckBox>
6
7#include "Field.h"
8#include "Node.h"
9#include <QMenu>
10
12#include "Format.h"
13
14
15
16namespace dyno
17{
20 {
21 mfield = field;
22 //this->setStyleSheet("border:none");
23 QHBoxLayout* layout = new QHBoxLayout;
24 layout->setContentsMargins(0, 0, 0, 0);
25 layout->setSpacing(0);
26
27 this->setLayout(layout);
28
29 QLabel* name = new QLabel();
30 name->setFixedHeight(24);
31 name->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
32 name->setText(FormatFieldWidgetName(field->getObjectName()));
33 layout->addWidget(name, 0);
34 layout->addStretch(1);
35
36 QCheckBox* checkbox = new QCheckBox();
37 checkbox->setFixedWidth(20);
38 layout->addWidget(checkbox, 0);
39
40 if (field->parent()->findOutputField(field))
41 {
42 checkbox->setChecked(true);
43 }
44 else
45 {
46 checkbox->setChecked(false);
47 }
48
49 //TODO: use another way
50 connect(checkbox, SIGNAL(stateChanged(int)), this, SLOT(tagAsOuput(int)));
51
52 //Disable the callback function for state fields
53 this->clearCallBackFunc();
54 }
55
57 {
58 emit stateUpdated(field(), status);
59 }
60
62 {
63 auto menu = new QMenu;
64 menu->setStyleSheet("QMenu{color:white;border: 1px solid black;} ");
65
66 auto showDataAct = new QAction("Show Data", this);
67
68 menu->addAction(showDataAct);
69
70 menu->addSeparator();
71
72 connect(showDataAct, &QAction::triggered, this, [&]()
73 {
75 }
76 );
77
78 menu->move(QCursor().pos().x() + 4, QCursor().pos().y() + 4);
79 menu->show();
80
81 }
82
83
84 void QStateFieldWidget::mousePressEvent(QMouseEvent* event)
85 {
86 if (event->button() == Qt::RightButton)
87 {
88 showMenu();
89 }
90 }
91
92}
93
QFieldWidget(FBase *field)
void mousePressEvent(QMouseEvent *event) override
void stateUpdated(FBase *field, int status)
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
QString FormatFieldWidgetName(std::string name)
Definition Format.cpp:9