Esempio n. 1
0
void BodeWidget::selectionChanged(){

    QList<QCPAbstractLegendItem*> selectedLegendItems = dbPlot->legend->selectedItems();
    if(selectedLegendItems.length() > 0){
        QCPPlottableLegendItem* plottableLegendItem = dynamic_cast<QCPPlottableLegendItem*>(selectedLegendItems.at(0));
        if(plottableLegendItem){
            plottableLegendItem->plottable()->setSelected(true);
        }
    }

    QList<QCPGraph*> selectedGraphs = dbPlot->selectedGraphs();

    if(selectedGraphs.length() > 0){

        if(currentSelection != 0){
            paGraphMap[currentSelection]->setVisible(false);
        }

        currentSelection = selectedGraphs.at(0);
        paGraphMap[currentSelection]->setVisible(true);

        setWindowTitle(currentSelection->name());

        QCPPlottableLegendItem *lip = dbPlot->legend->itemWithPlottable(currentSelection);
        lip->setSelected(true);
    }

    else {
        setWindowTitle(" ");
    }

    this->replot();
}
Esempio n. 2
0
void LogsDialog::legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item)
{
  // Rename a graph by double clicking on its legend item
  if (item) {
    // only react if item was clicked (user could have clicked on border padding of legend where there is no item, then item is 0)
    QCPPlottableLegendItem *plItem = qobject_cast<QCPPlottableLegendItem*>(item);
    bool ok;
    QString newName = QInputDialog::getText(this, tr("Graph Name Change"), tr("New graph name:"), QLineEdit::Normal, plItem->plottable()->name(), &ok);
    if (ok) {
      plItem->plottable()->setName(newName);
      ui->customPlot->replot();
    }
  }
}
Esempio n. 3
0
void BandwidthGui::handleClickedLegend(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
{
	QCPPlottableLegendItem* graphItem = dynamic_cast<QCPPlottableLegendItem*>(item);
	if(!graphItem)
		return;

	auto color = graphItem->plottable()->brush().color();
	auto hue = color.hue() + 180 % 360;
	auto sat = color.saturation();
	auto val = color.value();

	if(sat == BRUSH_SATURATION)
	{
		sat = 255;
		val = 255;
	}
	else
	{
		sat = BRUSH_SATURATION;
		val = BRUSH_VALUE;
	}
	color.setHsv(hue, sat, val);
	graphItem->plottable()->setBrush(QBrush(color));
}