16 #include <QGridLayout> 22 : QWidget(aParent, aFlags)
23 , m_SelectedChannel(NULL)
24 , m_Initialized(false)
30 QGridLayout* grid =
new QGridLayout(
this);
33 QLabel* uninitializedLabel =
new QLabel(tr(
"Tool state display is unavailable until connected to a device set."),
this);
34 uninitializedLabel->setWordWrap(
true);
35 grid->addWidget(uninitializedLabel);
37 this->setLayout(grid);
52 LOG_TRACE(
"QPlusToolStateDisplayWidget::InitializeTools");
57 delete this->layout();
71 if (!aConnectionSuccessful)
73 QGridLayout* grid =
new QGridLayout(
this);
76 QLabel* uninitializedLabel =
new QLabel(tr(
"Tool state display is unavailable until connected to a device set."),
this);
77 uninitializedLabel->setWordWrap(
true);
78 grid->addWidget(uninitializedLabel);
80 this->setLayout(grid);
92 LOG_ERROR(
"Data source is missing!");
97 std::vector<igsioTransformName> transformNames;
98 igsioTrackedFrame trackedFrame;
100 trackedFrame.GetFrameTransformNameList(transformNames);
103 QGridLayout* grid =
new QGridLayout(
this);
104 grid->setColumnStretch(transformNames.size(), 1);
106 grid->setVerticalSpacing(4);
107 grid->setContentsMargins(4, 4, 4, 4);
112 std::vector<igsioTransformName>::iterator it;
113 for (it = transformNames.begin(),
i = 0; it != transformNames.end(); ++it, ++
i)
116 QString toolNameString = QString(
"%1: %2").arg(
i).arg(it->GetTransformName().c_str());
118 QLabel* toolNameLabel =
new QLabel(
this);
119 toolNameLabel->setText(toolNameString);
120 toolNameLabel->setToolTip(toolNameString);
121 QSizePolicy sizePolicyNameLabel(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
122 sizePolicyNameLabel.setHorizontalStretch(2);
123 toolNameLabel->setSizePolicy(sizePolicyNameLabel);
124 toolNameLabel->setMinimumHeight(24);
125 grid->addWidget(toolNameLabel,
i, 0, Qt::AlignLeft);
129 QTextEdit* toolStateLabel =
new QTextEdit(
"N/A",
this);
130 toolStateLabel->setTextColor(QColor::fromRgb(96, 96, 96));
131 toolStateLabel->setMaximumHeight(18);
132 toolStateLabel->setLineWrapMode(QTextEdit::NoWrap);
133 toolStateLabel->setReadOnly(
true);
134 toolStateLabel->setFrameShape(QFrame::NoFrame);
135 toolStateLabel->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
136 toolStateLabel->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
137 toolStateLabel->setAlignment(Qt::AlignRight);
138 toolStateLabel->setMinimumHeight(24);
139 QSizePolicy sizePolicyStateLabel(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
140 sizePolicyStateLabel.setHorizontalStretch(1);
141 toolStateLabel->setSizePolicy(sizePolicyStateLabel);
142 grid->addWidget(toolStateLabel,
i, 1, Qt::AlignRight);
146 this->setLayout(grid);
164 LOG_ERROR(
"Widget is not inialized!");
169 int numberOfDisplayedTools = 0;
172 std::vector<igsioTransformName> transformNames;
173 igsioTrackedFrame trackedFrame;
175 trackedFrame.GetFrameTransformNameList(transformNames);
179 LOG_WARNING(
"Tool number inconsistency!");
183 LOG_ERROR(
"Re-initializing tool state widget failed");
188 std::vector<igsioTransformName>::iterator transformIt;
189 std::vector<QTextEdit*>::iterator labelIt;
190 for (transformIt = transformNames.begin(), labelIt =
m_ToolStateLabels.begin(); transformIt != transformNames.end() && labelIt !=
m_ToolStateLabels.end(); ++transformIt, ++labelIt)
192 QTextEdit* label = (*labelIt);
196 LOG_WARNING(
"Invalid tool state label");
200 ToolStatus status(TOOL_INVALID);
201 if (trackedFrame.GetFrameTransformStatus(*transformIt, status) !=
PLUS_SUCCESS)
203 std::string transformNameStr;
204 transformIt->GetTransformName(transformNameStr);
205 LOG_WARNING(
"Unable to get transform status for transform" << transformNameStr);
206 label->setText(
"STATUS ERROR");
207 label->setTextColor(QColor::fromRgb(223, 0, 0));
211 label->setText(igsioCommon::ConvertToolStatusToString(status).c_str());
215 label->setTextColor(Qt::green);
218 label->setTextColor(QColor::fromRgb(223, 0, 0));
virtual PlusStatus GetTrackedFrame(double timestamp, igsioTrackedFrame &trackedFrame, bool enableImageData=true)
Contains an optional timestamped circular buffer containing the video images and a number of timestam...