9 #include "ControlHealthMonitorWidget.h"
12 #include "ControlNet.h"
19 #include <QApplication>
23 #include <QPushButton>
24 #include <QProgressBar>
27 #include <QTableWidgetItem>
30 #include <QHeaderView>
31 #include <QDesktopWidget>
32 #include <QGridLayout>
33 #include <QWidgetAction>
35 #include <ControlNet.h>
36 #include <ControlNetVitals.h>
37 #include <ControlPoint.h>
54 connect (m_vitals, SIGNAL(networkChanged()),
57 connect (m_vitals, SIGNAL(
historyEntry(QString, QString, QVariant, QVariant, QString)),
58 this, SLOT (
historyEntry(QString, QString, QVariant, QVariant, QString)));
74 m_netLabel->setText(
"Control Network: " + m_vitals->
getNetworkId());
75 m_statusLabel->setText(m_vitals->
getStatus());
87 freePercent = ( (int) (freePercent * 100) ) / 100.0;
89 m_pointsFreeProgressbar->setValue(freePercent);
90 m_pointsFreeProgressbar->setFormat(freeFormat);
94 constrainedPercent = ( (int) (constrainedPercent * 100) ) / 100.0;
96 m_pointsConstrainedProgressbar->setValue(constrainedPercent);
97 m_pointsConstrainedProgressbar->setFormat(constrainedFormat);
100 fixedPercent = ( (int) (fixedPercent * 100) ) / 100.0;
102 m_pointsFixedProgressbar->setValue(fixedPercent);
103 m_pointsFixedProgressbar->setFormat(fixedFormat);
107 if (m_vitals->
getStatus() ==
"Broken!") updateStatus(0);
108 else if (m_vitals->
getStatus() ==
"Weak!") updateStatus(1);
109 else if (m_vitals->
getStatus() ==
"Healthy!") updateStatus(2);
149 void ControlHealthMonitorWidget::updateStatus(
int code) {
150 QPalette p = m_statusBar->palette();
153 p.setColor(QPalette::Highlight, Qt::red);
154 p.setColor(QPalette::Text, Qt::black);
157 p.setColor(QPalette::Highlight, Qt::yellow);
158 p.setColor(QPalette::Text, Qt::black);
161 p.setColor(QPalette::Highlight, Qt::green);
162 p.setColor(QPalette::Text, Qt::white);
165 m_statusBar->setPalette(p);
175 setWindowTitle(
"Control Net Health Monitor");
178 QFont fontBig(
"Arial", 18, QFont::Bold);
179 QFont fontNormal(
"Arial", 14);
180 QFont searchFont(
"Seqoe UI Symbol", 12);
183 QVBoxLayout *gridLayout =
new QVBoxLayout;
184 gridLayout->setAlignment(Qt::AlignTop);
185 gridLayout->setSpacing(5);
186 setLayout(gridLayout);
189 QLabel *titleLabel =
new QLabel(
"Control Net Health Monitor");
190 titleLabel->setFont(fontBig);
191 titleLabel->setAlignment(Qt::AlignTop);
194 QHBoxLayout *netLayout =
new QHBoxLayout;
195 netLayout->setAlignment(Qt::AlignLeft);
197 m_netLabel =
new QLabel(
"Control Network:");
198 m_netLabel->setFont(fontNormal);
199 m_netLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
200 gridLayout->addWidget(titleLabel);
202 netLayout->addWidget(m_netLabel);
203 netWidget->setLayout(netLayout);
205 gridLayout->addWidget(netWidget);
209 QHBoxLayout *netStatsLayout =
new QHBoxLayout;
210 netStatsLayout->setAlignment(Qt::AlignLeft);
211 netStatsLayout->setSpacing(25);
212 m_numImagesLabel =
new QLabel(
"Images:");
213 m_numPointsLabel =
new QLabel(
"Points:");
214 m_numMeasuresLabel =
new QLabel(
"Measures:");
216 netStatsLayout->addWidget(m_numImagesLabel);
217 netStatsLayout->addWidget(m_numPointsLabel);
218 netStatsLayout->addWidget(m_numMeasuresLabel);
220 stats->setLayout(netStatsLayout);
221 gridLayout->addWidget(stats);
225 QPalette p = m_statusBar->palette();
226 p.setColor(QPalette::Highlight, Qt::green);
227 p.setColor(QPalette::Text, Qt::red);
228 m_statusBar->setPalette(p);
229 m_statusBar->setRange(0, 0);
231 m_statusBar->setFormat(
"Loading...");
232 gridLayout->addWidget(m_statusBar);
234 m_lastModLabel =
new QLabel(
"Last Modification:");
235 gridLayout->addWidget(m_lastModLabel);
238 line->setFrameShape(QFrame::HLine);
239 line->setFrameShadow(QFrame::Sunken);
240 gridLayout->addSpacing(15);
242 gridLayout->addWidget(line);
243 gridLayout->addSpacing(15);
246 QTabWidget *tabs =
new QTabWidget();
248 QWidget *overviewTab = createOverviewTab();
249 QWidget *imagesTab = createImagesTab();
250 QWidget *pointsTab = createPointsTab();
253 tabs->insertTab(0, overviewTab,
"Overview");
254 tabs->insertTab(1, imagesTab,
"Images");
255 tabs->insertTab(2, pointsTab,
"Points");
258 gridLayout->addWidget(tabs);
267 m_historyTable = NULL;
268 m_imagesHullValue = NULL;
269 m_imagesMeasuresValue = NULL;
270 m_imagesShowingLabel = NULL;
271 m_imagesTable = NULL;
272 m_lastModLabel = NULL;
273 m_numImagesLabel = NULL;
274 m_numMeasuresLabel = NULL;
275 m_numPointsLabel = NULL;
277 m_pointsEditLockedLabel = NULL;
278 m_pointsFewMeasuresLabel = NULL;
279 m_pointsIgnoredLabel = NULL;
280 m_pointsShowingLabel = NULL;
281 m_pointsTable = NULL;
283 m_statusDetails = NULL;
284 m_statusLabel = NULL;
293 QWidget* ControlHealthMonitorWidget::createOverviewTab() {
297 QVBoxLayout *overviewLayout =
new QVBoxLayout;
298 overviewLayout->setAlignment(Qt::AlignTop);
299 overviewLayout->setSpacing(5);
301 QFont fontBig(
"Arial", 16, QFont::Bold);
302 QFont fontNormal(
"Arial", 14);
303 QFont fontSmall(
"Arial", 12);
305 m_statusLabel =
new QLabel(
"Healthy!");
306 m_statusLabel->setFont(fontBig);
307 m_statusLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
309 m_statusDetails =
new QLabel(
"Your network is healthy.");
310 m_statusDetails->setFont(fontNormal);
311 m_statusDetails->setAlignment(Qt::AlignTop | Qt::AlignLeft);
313 m_statusDetails->setFont(fontNormal);
314 m_statusDetails->setAlignment(Qt::AlignTop | Qt::AlignLeft);
316 overviewLayout->addWidget(m_statusLabel);
317 overviewLayout->addWidget(m_statusDetails);
318 overviewLayout->addSpacing(50);
320 QLabel *modLabel =
new QLabel(
"Modification History");
321 modLabel->setFont(fontSmall);
322 overviewLayout->addWidget(modLabel);
325 headers.append(
"Action");
326 headers.append(
"Id");
327 headers.append(
"Old Value");
328 headers.append(
"New Value");
329 headers.append(
"Timestamp");
331 m_historyTable =
new QTableWidget();
332 m_historyTable->setColumnCount(5);
333 m_historyTable->setHorizontalHeaderLabels(headers);
334 m_historyTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
335 m_historyTable->horizontalHeader()->setStretchLastSection(
true);
336 m_historyTable->verticalHeader()->setVisible(
false);
337 m_historyTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
338 m_historyTable->setSelectionBehavior(QAbstractItemView::SelectRows);
339 m_historyTable->setSelectionMode(QAbstractItemView::SingleSelection);
340 m_historyTable->setGeometry(QApplication::desktop()->screenGeometry());
342 overviewLayout->addWidget(m_historyTable);
343 overview->setLayout(overviewLayout);
353 QWidget* ControlHealthMonitorWidget::createImagesTab() {
354 QFont fontSmall(
"Arial", 12);
355 QFont fontMedium(
"Arial", 14);
359 QVBoxLayout *imagesLayout =
new QVBoxLayout;
360 imagesLayout->setAlignment(Qt::AlignTop);
361 imagesLayout->setSpacing(15);
362 imagesLayout->addSpacing(10);
365 QGridLayout *tempLayout =
new QGridLayout;
368 QLabel *threeMeasure =
new QLabel(
"Less than 3 valid Measures:");
369 m_imagesMeasuresValue =
new QLabel(
"");
371 QLabel *withoutMeasures =
new QLabel(
"Exceeding convex hull tolerance:");
372 m_imagesHullValue =
new QLabel(
"");
375 m_imagesMeasuresValue->setFont(fontSmall);
376 threeMeasure->setFont(fontSmall);
377 withoutMeasures->setFont(fontSmall);
378 m_imagesHullValue->setFont(fontSmall);
381 QPushButton *button =
new QPushButton(
"View");
382 QPushButton *button2 =
new QPushButton(
"View");
384 connect(button, SIGNAL(clicked()),
this, SLOT(viewImageFewMeasures()));
385 connect(button2, SIGNAL(clicked()),
this, SLOT(viewImageHullTolerance()));
388 tempLayout->addWidget(threeMeasure, 0, 0);
389 tempLayout->addWidget(m_imagesMeasuresValue, 0, 1);
390 tempLayout->addWidget(button, 0, 2);
392 tempLayout->addWidget(withoutMeasures, 1, 0);
393 tempLayout->addWidget(m_imagesHullValue, 1, 1);
394 tempLayout->addWidget(button2, 1, 2);
396 temp->setLayout(tempLayout);
397 imagesLayout->addWidget(temp);
400 m_imagesTable =
new QTableWidget();
402 connect(m_imagesTable, SIGNAL(itemDoubleClicked(QTableWidgetItem *)),
407 headers.append(
"Cube Serial");
409 m_imagesTable->setColumnCount(2);
410 m_imagesTable->setHorizontalHeaderLabels(headers);
411 m_imagesTable->horizontalHeader()->setStretchLastSection(
true);
412 m_imagesTable->verticalHeader()->setVisible(
false);
413 m_imagesTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
414 m_imagesTable->setSelectionBehavior(QAbstractItemView::SelectRows);
415 m_imagesTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
417 m_imagesTable->setShowGrid(
true);
418 m_imagesTable->setGeometry(QApplication::desktop()->screenGeometry());
419 m_imagesTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
421 imagesLayout->addSpacing(30);
423 m_imagesShowingLabel =
new QLabel(
"");
424 m_imagesShowingLabel->setFont(fontMedium);
426 QPushButton *viewAllButton =
new QPushButton(
"View All");
427 connect(viewAllButton, SIGNAL(clicked()),
428 this, SLOT(viewImageAll()));
430 QGridLayout *showingLayout =
new QGridLayout;
433 showingLayout->addWidget(m_imagesShowingLabel, 0, 0, 1, 2);
434 showingLayout->addWidget(viewAllButton, 0, 2);
435 showingWidget->setLayout(showingLayout);
437 imagesLayout->addWidget(showingWidget);
438 imagesLayout->addWidget(m_imagesTable);
440 imagesTab->setLayout(imagesLayout);
449 QWidget* ControlHealthMonitorWidget::createPointsTab() {
451 QFont fontSmall(
"Arial", 12);
452 QFont fontMedium(
"Arial", 14);
453 QFont searchFont(
"Seqoe UI Symbol", 12);
457 QVBoxLayout *pointsLayout =
new QVBoxLayout;
458 pointsLayout->setAlignment(Qt::AlignTop);
459 pointsLayout->setSpacing(15);
460 pointsLayout->addSpacing(10);
463 QGridLayout *viewLayout =
new QGridLayout;
466 QLabel *pointsIgnored =
new QLabel(
"Points Ignored:");
467 m_pointsIgnoredLabel =
new QLabel(
"");
469 QLabel *freePoints =
new QLabel(
"Points Free:");
470 m_pointsFreeLabel =
new QLabel(
"");
472 QPalette p = m_pointsFreeProgressbar->palette();
473 p.setColor(QPalette::Highlight, Qt::blue);
474 p.setColor(QPalette::Text, Qt::black);
475 m_pointsFreeProgressbar->setPalette(p);
476 m_pointsFreeProgressbar->setRange(0, 100);
478 QLabel *constrainedPoints =
new QLabel(
"Points Constrained:");
479 m_pointsConstrainedLabel =
new QLabel(
"");
481 m_pointsConstrainedProgressbar->setPalette(p);
482 m_pointsConstrainedProgressbar->setRange(0, 100);
484 QLabel *fixedPoints =
new QLabel(
"Points Fixed:");
485 m_pointsFixedLabel =
new QLabel(
"");
487 m_pointsFixedProgressbar->setPalette(p);
488 m_pointsFixedProgressbar->setRange(0, 100);
490 QLabel *pointsLocked =
new QLabel(
"Points Edit Locked:");
491 m_pointsEditLockedLabel =
new QLabel(
"");
493 QLabel *pointsMeasure =
new QLabel(
"Less than 3 valid Measures:");
494 m_pointsFewMeasuresLabel =
new QLabel(
"");
497 pointsLocked->setFont(fontSmall);
498 m_pointsEditLockedLabel->setFont(fontSmall);
499 pointsMeasure->setFont(fontSmall);
500 m_pointsFewMeasuresLabel->setFont(fontSmall);
501 freePoints->setFont(fontSmall);
502 m_pointsFreeLabel->setFont(fontSmall);
503 fixedPoints->setFont(fontSmall);
504 constrainedPoints->setFont(fontSmall);
505 pointsIgnored->setFont(fontSmall);
506 m_pointsFixedLabel->setFont(fontSmall);
507 m_pointsConstrainedLabel->setFont(fontSmall);
508 m_pointsIgnoredLabel->setFont(fontSmall);
511 QPushButton *viewIgnoredButton =
new QPushButton(
"View");
512 QPushButton *viewLockedButton =
new QPushButton(
"View");
513 QPushButton *viewMeasureButton =
new QPushButton(
"View");
514 QPushButton *viewFreePoints =
new QPushButton(
"View");
515 QPushButton *viewFixedPoints =
new QPushButton(
"View");
516 QPushButton *viewConstrainedPoints =
new QPushButton(
"View");
519 connect(viewIgnoredButton, SIGNAL(clicked()),
this, SLOT(viewPointIgnored()));
520 connect(viewLockedButton, SIGNAL(clicked()),
this, SLOT(viewPointEditLocked()));
521 connect(viewMeasureButton, SIGNAL(clicked()),
this, SLOT(viewPointFewMeasures()));
522 connect(viewFreePoints, SIGNAL(clicked()),
this, SLOT(viewPointFree()));
523 connect(viewFixedPoints, SIGNAL(clicked()),
this, SLOT(viewPointFixed()));
524 connect(viewConstrainedPoints, SIGNAL(clicked()),
this, SLOT(viewPointConstrained()));
527 viewLayout->addWidget(freePoints, 0, 0);
528 viewLayout->addWidget(m_pointsFreeProgressbar, 0, 1);
529 viewLayout->addWidget(viewFreePoints, 0, 2);
531 viewLayout->addWidget(fixedPoints, 1, 0);
532 viewLayout->addWidget(m_pointsFixedProgressbar, 1, 1);
533 viewLayout->addWidget(viewFixedPoints, 1, 2);
535 viewLayout->addWidget(constrainedPoints, 2, 0);
536 viewLayout->addWidget(m_pointsConstrainedProgressbar, 2, 1);
537 viewLayout->addWidget(viewConstrainedPoints, 2, 2);
539 viewLayout->addWidget(pointsIgnored, 3, 0);
540 viewLayout->addWidget(m_pointsIgnoredLabel, 3, 1);
541 viewLayout->addWidget(viewIgnoredButton, 3, 2);
543 viewLayout->addWidget(pointsLocked, 4, 0);
544 viewLayout->addWidget(m_pointsEditLockedLabel, 4, 1);
545 viewLayout->addWidget(viewLockedButton, 4, 2);
547 viewLayout->addWidget(pointsMeasure, 5, 0);
548 viewLayout->addWidget(m_pointsFewMeasuresLabel, 5, 1);
549 viewLayout->addWidget(viewMeasureButton, 5, 2);
551 viewWidget->setLayout(viewLayout);
552 pointsLayout->addWidget(viewWidget);
555 m_pointsTable =
new QTableWidget();
558 headers.append(
"Point ID");
559 headers.append(
"Type");
560 headers.append(
"Ignored");
561 headers.append(
"Rejected");
562 headers.append(
"Edit Locked");
564 m_pointsTable->setColumnCount(6);
565 m_pointsTable->setHorizontalHeaderLabels(headers);
566 m_pointsTable->horizontalHeader()->setStretchLastSection(
true);
567 m_pointsTable->verticalHeader()->setVisible(
false);
568 m_pointsTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
569 m_pointsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
570 m_pointsTable->setSelectionMode(QAbstractItemView::SingleSelection);
571 m_pointsTable->setShowGrid(
true);
572 m_pointsTable->setGeometry(QApplication::desktop()->screenGeometry());
573 m_pointsTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
575 connect(m_pointsTable, SIGNAL(itemDoubleClicked(QTableWidgetItem *)),
578 m_pointsShowingLabel =
new QLabel(
"");
579 m_pointsShowingLabel->setFont(fontMedium);
580 QPushButton *showAllButton =
new QPushButton(
"View All");
582 QGridLayout *showLayout =
new QGridLayout;
585 connect(showAllButton, SIGNAL(clicked()),
586 this, SLOT(viewPointAll()));
588 showLayout->addWidget(m_pointsShowingLabel, 0, 0, 1, 2);
589 showLayout->addWidget(showAllButton, 0, 2);
590 showWidget->setLayout(showLayout);
592 pointsLayout->addSpacing(30);
593 pointsLayout->addWidget(showWidget);
594 pointsLayout->addWidget(m_pointsTable);
596 pointsTab->setLayout(pointsLayout);
611 QModelIndexList rows = m_imagesTable->selectionModel()->selectedRows(1);
612 foreach (QModelIndex index, rows) {
613 serials.append(index.data().toString());
615 emit openImageEditor(serials);
629 QModelIndex pointId = m_pointsTable->selectionModel()->selectedIndexes()[1];
631 emit openPointEditor(point);
648 QVariant oldValue, QVariant newValue,
651 m_lastModLabel->setText(
"Last Modification: " + timeStamp);
653 m_historyTable->insertRow(0);
654 m_historyTable->setItem(0, 0,
new QTableWidgetItem(entry));
655 m_historyTable->setItem(0, 1,
new QTableWidgetItem(
id));
656 m_historyTable->setItem(0, 2,
new QTableWidgetItem(oldValue.toString()));
657 m_historyTable->setItem(0, 3,
new QTableWidgetItem(newValue.toString()));
658 m_historyTable->setItem(0, 4,
new QTableWidgetItem(timeStamp));
666 QWidget* ControlHealthMonitorWidget::createGraphTab() {
669 QVBoxLayout *graphLayout =
new QVBoxLayout;
670 graphLayout->setAlignment(Qt::AlignTop);
671 graphLayout->setSpacing(5);
684 graph->setLayout(graphLayout);
694 void ControlHealthMonitorWidget::updateImageTable(
QList<QString> serials) {
695 m_imagesTable->setRowCount(0);
696 for (
int i = 0; i < serials.size(); i++) {
697 m_imagesTable->insertRow(i);
698 m_imagesTable->setItem(i, 0,
new QTableWidgetItem(
toString(i + 1)));
699 m_imagesTable->setItem(i, 1,
new QTableWidgetItem(serials.at(i)));
709 m_pointsTable->setRowCount(0);
710 for (
int i = 0; i < points.size(); i++) {
711 ControlPoint *point = points.at(i);
712 m_pointsTable->insertRow(i);
713 m_pointsTable->setItem(i, 0,
new QTableWidgetItem(
toString(i + 1)));
714 m_pointsTable->setItem(i, 1,
new QTableWidgetItem(point->GetId()));
715 m_pointsTable->setItem(i, 2,
new QTableWidgetItem(point->GetPointTypeString()));
716 m_pointsTable->setItem(i, 3,
new QTableWidgetItem(
toString(point->IsIgnored())));
717 m_pointsTable->setItem(i, 4,
new QTableWidgetItem(
toString(point->IsRejected())));
718 m_pointsTable->setItem(i, 5,
new QTableWidgetItem(
toString(point->IsEditLocked())));
727 void ControlHealthMonitorWidget::viewPointAll() {
729 m_pointsShowingLabel->setText(
"Showing: All Points <sup>" +
739 void ControlHealthMonitorWidget::viewPointIgnored() {
741 m_pointsShowingLabel->setText(
"Showing: Ignored Points <sup>" +
751 void ControlHealthMonitorWidget::viewPointFree() {
753 m_pointsShowingLabel->setText(
"Showing: Free Points <sup>" +
763 void ControlHealthMonitorWidget::viewPointFixed() {
765 m_pointsShowingLabel->setText(
"Showing: Fixed Points <sup>" +
775 void ControlHealthMonitorWidget::viewPointConstrained() {
777 m_pointsShowingLabel->setText(
"Showing: Constrained Points <sup>" +
787 void ControlHealthMonitorWidget::viewPointEditLocked() {
789 m_pointsShowingLabel->setText(
"Showing: Locked Points <sup>" +
800 void ControlHealthMonitorWidget::viewPointFewMeasures() {
802 m_pointsShowingLabel->setText(
"Showing: Points with less than 3 Measures <sup>" +
812 void ControlHealthMonitorWidget::viewImageAll() {
814 m_imagesShowingLabel->setText(
"Showing: All Images <sup>" +
824 void ControlHealthMonitorWidget::viewImageFewMeasures() {
826 m_imagesShowingLabel->setText(
"Showing: Images with less than 3 Measures <sup>" +
836 void ControlHealthMonitorWidget::viewImageHullTolerance() {
838 m_imagesShowingLabel->setText(
"Showing: Images below a hull tolerance of 75% <sup>" +
849 delete m_historyTable;
850 delete m_imagesHullValue;
851 delete m_imagesMeasuresValue;
852 delete m_imagesShowingLabel;
853 delete m_imagesTable;
854 delete m_lastModLabel;
855 delete m_numImagesLabel;
856 delete m_numMeasuresLabel;
857 delete m_numPointsLabel;
859 delete m_pointsEditLockedLabel;
860 delete m_pointsFewMeasuresLabel;
861 delete m_pointsIgnoredLabel;
862 delete m_pointsShowingLabel;
863 delete m_pointsTable;
865 delete m_statusDetails;
866 delete m_statusLabel;
869 m_historyTable = NULL;
870 m_imagesHullValue = NULL;
871 m_imagesMeasuresValue = NULL;
872 m_imagesShowingLabel = NULL;
873 m_imagesTable = NULL;
874 m_lastModLabel = NULL;
875 m_numImagesLabel = NULL;
876 m_numMeasuresLabel = NULL;
877 m_numPointsLabel = NULL;
879 m_pointsEditLockedLabel = NULL;
880 m_pointsFewMeasuresLabel = NULL;
881 m_pointsIgnoredLabel = NULL;
882 m_pointsShowingLabel = NULL;
883 m_pointsTable = NULL;
885 m_statusDetails = NULL;
886 m_statusLabel = NULL;