Scratchpad.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "pch.h"
  2. #include "Scratchpad.h"
  3. #include "HoverButton.h"
  4. #include <QAction>
  5. Scratchpad::Scratchpad(QWidget *parent)
  6. : BitInspectorPanel(parent)
  7. {
  8. HoverButton* rubbishButton = new HoverButton();
  9. rubbishButton->setMinimumSize(20, 20);
  10. rubbishButton->setMaximumSize(20, 20);
  11. rubbishButton->setIcon(QIcon(":/metavis/Resources/rubbish.svg"));
  12. rubbishButton->setHoveredIcon(QIcon(":/metavis/Resources/rubbish_hovered.svg"));
  13. rubbishButton->setAttribute(Qt::WA_TranslucentBackground);
  14. rubbishButton->setStyleSheet(rubbishButton->styleSheet() + "border: none;");
  15. rubbishButton->setToolTip("Clear scratchpad");
  16. qDebug() << topPanel->count();
  17. topPanel->insertWidget(topPanel->count()-1, rubbishButton);
  18. connect(rubbishButton, &QPushButton::released, this, &Scratchpad::clear);
  19. QAction* clearAction = new QAction("Clear");
  20. this->contextMenu->addAction(clearAction);
  21. connect(clearAction, &QAction::triggered, this, &Scratchpad::clear);
  22. popupWidget->setInformation("<h3><u>Scratchpad</u></h3> Shows selected solution from search space visualizations or metrics. Each solution gets displayed in a row. To add solutions go in an different visualization and drag over the points you want to add while hold the RMB(Right-Mouse-Button).<br><b>Clear button:</b> Removes all solutions from this pad.<br> Alternative is press RMB and \"Clear\" in the scratchpad. <br><b>Iteration:</b> Shows the iteratioon in which the solution is generated.<br><b>Number:</b> Shows which individual in the population is represented.<br><b>Objective Function:</b> Describes how good the solution is, it depends on the problem if a low or high value is desired.<br><b>Binary:</b> Shows the bitstring of the solution. White rectangle represents the bit is <i>false<i> and black <i>true<i>.");
  23. }
  24. Scratchpad::~Scratchpad()
  25. {
  26. }
  27. void Scratchpad::addPoint(const SolutionPointData& point)
  28. {
  29. inspector->clear();
  30. points.push_back(point);
  31. inspector->updateData(points.begin(), points.end());
  32. }
  33. void Scratchpad::clear()
  34. {
  35. inspector->clear();
  36. points.clear();
  37. }
  38. void Scratchpad::contextMenuEvent(QContextMenuEvent* event)
  39. {
  40. contextMenu->exec(event->globalPos());
  41. }