MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / updateGraphView

Method updateGraphView

tools/monitor/Viewer.cpp:429–492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

427 }
428
429 void
430 Viewer::updateGraphView(bool honorDisplayFlag)
431 {
432 try {
433 // invalid QModelIndex signifies the root.
434 GraphGenerator g(this->dataSource_->modelRoot(), gvOpt, honorDisplayFlag);
435
436 // this creates dot file and png file
437 g.draw();
438
439 std::stringstream msg;
440
441 if (image != 0) {
442 delete image;
443 image = 0;
444 }
445
446 image = new QImage(gvOpt.getPng().c_str());
447
448 if (image != 0) {
449 // setWidget calls delete on old graphview. no need to delete.
450 graphView = new QLabel();
451
452 graphView->setBackgroundRole(QPalette::Base);
453 graphView->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
454 graphView->setScaledContents(true);
455
456 QPixmap pixmap = QPixmap::fromImage(*image);
457
458 // scale image by amount on slider
459 double factor = (100.0 - this->ui.horizontalSlider->value()) / 100.0;
460
461 graphView->setPixmap(pixmap);
462
463 graphView->resize(factor * graphView->pixmap()->size());
464
465 QScrollBar* scrollBar = this->ui.scrollArea->horizontalScrollBar();
466
467 scrollBar->setValue(int(factor * scrollBar->value()
468 + ((factor - 1) * scrollBar->pageStep()/2)));
469
470 scrollBar = this->ui.scrollArea->verticalScrollBar();
471
472 scrollBar->setValue(int(factor * scrollBar->value()
473 + ((factor - 1) * scrollBar->pageStep()/2)));
474
475 this->ui.scrollArea->setBackgroundRole(QPalette::Dark);
476 this->ui.scrollArea->setWidget(graphView);
477 this->ui.scrollArea->show();
478
479 msg << "Graph View Updated " << image->size().width() << "x" << image->size().height();
480
481 this->ui.statusbar->showMessage( tr(msg.str().c_str()));
482 }
483 else {
484 msg << "Error loading image file";
485 this->ui.statusbar->showMessage( tr(msg.str().c_str()));
486 }

Callers

nothing calls this directly

Calls 9

modelRootMethod · 0.80
getPngMethod · 0.80
showMethod · 0.80
widthMethod · 0.80
drawMethod · 0.45
valueMethod · 0.45
sizeMethod · 0.45
setValueMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected