Пример #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();
}
Пример #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();
    }
  }
}
Пример #3
0
void PlotWidget::selectionChanged()
{
   /*
   normally, axis base line, axis tick labels and axis labels are selectable separately, but we want
   the user only to be able to select the axis as a whole, so we tie the selected states of the tick labels
   and the axis base line together. However, the axis label shall be selectable individually.

   The selection state of the left and right axes shall be synchronized as well as the state of the
   bottom and top axes.

   Further, we want to synchronize the selection of the graphs with the selection state of the respective
   legend item belonging to that graph. So the user can select a graph by either clicking on the graph itself
   or on its legend item.
   */

    // make top and bottom axes be selected synchronously, and handle axis and tick labels as one selectable object:
    if (ui->myPlot->xAxis->selectedParts().testFlag(QCPAxis::spAxis) || ui->myPlot->xAxis->selectedParts().testFlag(QCPAxis::spTickLabels) ||
            ui->myPlot->xAxis2->selectedParts().testFlag(QCPAxis::spAxis) || ui->myPlot->xAxis2->selectedParts().testFlag(QCPAxis::spTickLabels))
    {
        ui->myPlot->xAxis2->setSelectedParts(QCPAxis::spAxis|QCPAxis::spTickLabels);
        ui->myPlot->xAxis->setSelectedParts(QCPAxis::spAxis|QCPAxis::spTickLabels);
    }
    // make left and right axes be selected synchronously, and handle axis and tick labels as one selectable object:
    if (ui->myPlot->yAxis->selectedParts().testFlag(QCPAxis::spAxis) || ui->myPlot->yAxis->selectedParts().testFlag(QCPAxis::spTickLabels) ||
            ui->myPlot->yAxis2->selectedParts().testFlag(QCPAxis::spAxis) || ui->myPlot->yAxis2->selectedParts().testFlag(QCPAxis::spTickLabels))
    {
        ui->myPlot->yAxis2->setSelectedParts(QCPAxis::spAxis|QCPAxis::spTickLabels);
        ui->myPlot->yAxis->setSelectedParts(QCPAxis::spAxis|QCPAxis::spTickLabels);
    }

    // synchronize selection of graphs with selection of corresponding legend items:
    for (int i=0; i<ui->myPlot->graphCount(); ++i)
    {
        QCPGraph *graph = ui->myPlot->graph(i);
        QCPPlottableLegendItem *item = ui->myPlot->legend->itemWithPlottable(graph);
        if (item->selected() || graph->selected())
        {
            item->setSelected(true);
            graph->setSelected(true);
        }
    }
}
Пример #4
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));
}
Пример #5
0
void LogsDialog::selectionChanged()
{
  /*
   normally, axis base line, axis tick labels and axis labels are selectable separately, but we want
   the user only to be able to select the axis as a whole, so we tie the selected states of the tick labels
   and the axis base line together. However, the axis label shall be selectable individually.

   The selection state of the left and right axes shall be synchronized as well as the state of the
   bottom and top axes.

   Further, we want to synchronize the selection of the graphs with the selection state of the respective
   legend item belonging to that graph. So the user can select a graph by either clicking on the graph itself
   or on its legend item.
  */

  if (plotLock) return;

  // handle bottom axis and tick labels as one selectable object:
  if (axisRect->axis(QCPAxis::atBottom)->selectedParts().testFlag(QCPAxis::spAxis) ||
    axisRect->axis(QCPAxis::atBottom)->selectedParts().testFlag(QCPAxis::spTickLabels))
  {
    axisRect->axis(QCPAxis::atBottom)->setSelectedParts(QCPAxis::spAxis |
      QCPAxis::spTickLabels);
  }
  // make left and right axes be selected synchronously,
  // and handle axis and tick labels as one selectable object:
  if (axisRect->axis(QCPAxis::atLeft)->selectedParts().testFlag(QCPAxis::spAxis) ||
    axisRect->axis(QCPAxis::atLeft)->selectedParts().testFlag(QCPAxis::spTickLabels) ||
    (
      axisRect->axis(QCPAxis::atRight)->visible() &&
      (axisRect->axis(QCPAxis::atRight)->selectedParts().testFlag(QCPAxis::spAxis) ||
      axisRect->axis(QCPAxis::atRight)->selectedParts().testFlag(QCPAxis::spTickLabels))
    ) || (
      axisRect->axis(QCPAxis::atLeft, 1)->visible() &&
      (axisRect->axis(QCPAxis::atLeft, 1)->selectedParts().testFlag(QCPAxis::spAxis) ||
      axisRect->axis(QCPAxis::atLeft, 1)->selectedParts().testFlag(QCPAxis::spTickLabels))
    ) || (
      axisRect->axis(QCPAxis::atRight)->visible() &&
      (axisRect->axis(QCPAxis::atRight, 1)->selectedParts().testFlag(QCPAxis::spAxis) ||
      axisRect->axis(QCPAxis::atRight, 1)->selectedParts().testFlag(QCPAxis::spTickLabels))
    )
  ) {
    axisRect->axis(QCPAxis::atLeft)->setSelectedParts(QCPAxis::spAxis |
      QCPAxis::spTickLabels);
    if (axisRect->axis(QCPAxis::atRight)->visible()) {
      axisRect->axis(QCPAxis::atRight)->setSelectedParts(QCPAxis::spAxis |
        QCPAxis::spTickLabels);
      if (axisRect->axis(QCPAxis::atLeft, 1)->visible()) {
        axisRect->axis(QCPAxis::atLeft, 1)->setSelectedParts(QCPAxis::spAxis |
          QCPAxis::spTickLabels);
        if (axisRect->axis(QCPAxis::atRight, 1)->visible()) {
          axisRect->axis(QCPAxis::atRight, 1)->setSelectedParts(QCPAxis::spAxis |
            QCPAxis::spTickLabels);
        }
      }
    }
  }

  // synchronize selection of graphs with selection of corresponding legend items:
  for (int i=0; i<ui->customPlot->graphCount(); ++i) {
    QCPGraph *graph = ui->customPlot->graph(i);
    QCPPlottableLegendItem *item = ui->customPlot->legend->itemWithPlottable(graph);
    if (item == NULL) item = rightLegend->itemWithPlottable(graph);
    if (item->selected() || graph->selected()) {
      item->setSelected(true);
      graph->setSelected(true);
    }
  }
}