13#define TREEMODE_WARN 2
21 header()->setDefaultSectionSize(150);
26 m_okIcon(
":/apply.svg"),
27 m_warningIcon(
":/warning.svg")
31 m_tabs->addTab(m_list,
"List");
32 m_tabs->setMaximumWidth(m_list->maximumWidth());
36 m_widgetLayout->setAlignment(Qt::AlignLeft | Qt::AlignTop);
38 widgetContainer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
41 scroll->setWidgetResizable(
true);
44 m_tabs->addTab(
scroll,
"Widgets");
53 addRobotInList(robotName);
54 addRobotInWidget(robotName);
59 m_indexToPartMap[
partIndex].partItem = part;
60 addRobotPartInList(robotName, partName,
partIndex, part);
61 addRobotPartInWidget(robotName, partName,
partIndex, part);
67 updateRobotPartInList(index,
modes);
68 updateRobotPartInWidget(index,
modes);
71void ModesTreeManager::onTabChanged(
int index)
73 m_tabs->setMaximumWidth(m_tabs->widget(index)->maximumWidth());
76void ModesTreeManager::onJointClicked(
int partIndex,
int jointIndex)
81void ModesTreeManager::onJointHomeFromTree(
int partIndex,
int jointIndex)
83 m_indexToPartMap[
partIndex].partItem->getJointWidget(jointIndex)->home();
86void ModesTreeManager::onJointRunFromTree(
int partIndex,
int jointIndex)
88 m_indexToPartMap[
partIndex].partItem->getJointWidget(jointIndex)->run();
91void ModesTreeManager::onJointIdleFromTree(
int partIndex,
int jointIndex)
93 m_indexToPartMap[
partIndex].partItem->getJointWidget(jointIndex)->idle();
96void ModesTreeManager::onJointPIDFromTree(
int partIndex,
int jointIndex)
98 m_indexToPartMap[
partIndex].partItem->getJointWidget(jointIndex)->showPID();
101void ModesTreeManager::onPartDoubleClicked(
int partIndex)
106void ModesTreeManager::addRobotInList(
const std::string &robotName)
109 robot_top->setText(0, robotName.c_str());
115void ModesTreeManager::addRobotInWidget(
const std::string &robotName)
118 newRobot->setTitle(robotName.c_str());
119 m_widgetLayout->addWidget(
newRobot);
121 newRobot->enableCollapseAllContextMenu(
true);
122 newRobot->setIcons(m_okIcon, m_warningIcon);
124 m_robotMapWidget[robotName] =
newRobot;
129void ModesTreeManager::addRobotPartInList(
const std::string &robotName,
const std::string &partName,
int partIndex,
PartItem *part)
131 auto* partItem =
new QTreeWidgetItem();
132 partItem->setText(0, partName.c_str());
133 QTreeWidgetItem *
tp = m_robotMapList[robotName];
134 tp->addChild(partItem);
135 partItem->setExpanded(
false);
136 m_indexToPartMap[
partIndex].listWidget = partItem;
140 auto*
jointNode =
new QTreeWidgetItem(partItem);
151void ModesTreeManager::addRobotPartInWidget(
const std::string &robotName,
const std::string &partName,
int partIndex,
PartItem *part)
166 connect(partWidget,
SIGNAL(sig_homeClicked(
int,
int)),
this,
SLOT(onJointHomeFromTree(
int,
int)));
167 connect(partWidget,
SIGNAL(sig_runClicked(
int,
int)),
this,
SLOT(onJointRunFromTree(
int,
int)));
168 connect(partWidget,
SIGNAL(sig_idleClicked(
int,
int)),
this,
SLOT(onJointIdleFromTree(
int,
int)));
169 connect(partWidget,
SIGNAL(sig_PIDClicked(
int,
int)),
this,
SLOT(onJointPIDFromTree(
int,
int)));
171 m_indexToPartMap[
partIndex].robotWidget = robotWidget;
176 QTreeWidgetItem *
parentNode = m_indexToPartMap[index].listWidget;
184 for(
int i = 0; i <
parentNode->childCount(); i++){
193 item->setIcon(0,m_warningIcon);
202 if(
item->text(1) != mode){
203 item->setText(1,mode);
205 if(
item->background(0) !=
c){
206 item->setBackground(0,
c);
207 item->setBackground(1,
c);
208 item->setForeground(0, Qt::black);
209 item->setForeground(1, Qt::black);
231 m_indexToPartMap[index].robotWidget->updateRobotPart(index,
modes);
int SIGNAL(int pid, int signum)
static QColor GetModeColor(JointState mode)
static QString GetModeString(JointState mode)
void sig_jointClicked(int partIndex, int jointIndex)
void updateRobotPart(int index)
void addRobotPart(const std::string &robotName, const std::string &partName, int partIndex, PartItem *part)
void addRobot(const std::string &robotName)
void sig_partDoubleClicked(int index)
ModesTreeManager(QHBoxLayout *layout, QWidget *parent=nullptr)
JointItemTree * addJoint()
QString getJointName(int joint)
A mini-server for performing network communication in the background.
const QColor hwFaultColor