plotwidget_base.cpp
Go to the documentation of this file.
1 /*
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5  */
6 
8 #include "timeseries_qwt.h"
9 
10 #include "plotmagnifier.h"
11 #include "plotzoomer.h"
12 #include "plotlegend.h"
13 
14 #include "qwt_axis.h"
15 #include "qwt_legend.h"
16 #include "qwt_plot.h"
17 #include "qwt_plot_curve.h"
18 #include "qwt_plot_grid.h"
19 #include "qwt_plot_canvas.h"
20 #include "qwt_plot_curve.h"
21 #include "qwt_plot_opengl_canvas.h"
22 #include "qwt_plot_rescaler.h"
23 #include "qwt_plot_legenditem.h"
24 #include "qwt_plot_marker.h"
25 #include "qwt_plot_layout.h"
26 #include "qwt_scale_engine.h"
27 #include "qwt_scale_map.h"
28 #include "qwt_scale_draw.h"
29 #include "qwt_scale_widget.h"
30 #include "qwt_symbol.h"
31 #include "qwt_text.h"
32 
33 #include <QBoxLayout>
34 #include <QMessageBox>
35 #include <QSettings>
36 #include <QDebug>
37 #include <QDragEnterEvent>
38 #include <QDropEvent>
39 #include <QHBoxLayout>
40 
41 #include "plotpanner.h"
42 
43 static int _global_color_index_ = 0;
44 
46 {
47 public:
53  std::function<void(const QRectF&)> resized_callback;
54  std::function<void(QEvent*)> event_callback;
56 
57  QwtPlotPimpl(PlotWidgetBase* parentObject, QWidget* canvas,
58  std::function<void(const QRectF&)> resizedViewCallback,
59  std::function<void(QEvent*)> eventCallback)
60  : QwtPlot(nullptr)
61  , resized_callback(resizedViewCallback)
62  , event_callback(eventCallback)
63  , parent(parentObject)
64  {
65  this->setCanvas(canvas);
66 
67  legend = new PlotLegend(this);
68  magnifier = new PlotMagnifier(this->canvas());
69  panner1 = new PlotPanner(this->canvas());
70  panner2 = new PlotPanner(this->canvas());
71  zoomer = new PlotZoomer(this->canvas());
72 
73  zoomer->setRubberBandPen(QColor(Qt::red, 1, Qt::DotLine));
74  zoomer->setTrackerPen(QColor(Qt::green, 1, Qt::DotLine));
75  zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton,
76  Qt::NoModifier);
77 
78  magnifier->setAxisEnabled(QwtPlot::xTop, false);
79  magnifier->setAxisEnabled(QwtPlot::yRight, false);
80 
81  magnifier->setZoomInKey(Qt::Key_Plus, Qt::ControlModifier);
82  magnifier->setZoomOutKey(Qt::Key_Minus, Qt::ControlModifier);
83 
84  // disable right button. keep mouse wheel
85  magnifier->setMouseButton(Qt::NoButton);
86 
87  panner1->setMouseButton(Qt::LeftButton, Qt::ControlModifier);
88  panner2->setMouseButton(Qt::MiddleButton, Qt::NoModifier);
89 
90  connect(zoomer, &PlotZoomer::zoomed, this,
91  [this](const QRectF& r) {
93  });
94 
95  connect(magnifier, &PlotMagnifier::rescaled, this,
96  [this](const QRectF& r) {
98  replot();
99  });
100 
101  connect(panner1, &PlotPanner::rescaled, this,
102  [this](QRectF r) {
103  resized_callback(r);
104  });
105 
106  connect(panner2, &PlotPanner::rescaled, this,
107  [this](QRectF r) {
108  resized_callback(r);
109  });
110 
113 
114  bottomAxis->installEventFilter(parent);
115  leftAxis->installEventFilter(parent);
116  this->canvas()->installEventFilter(parent);
117  }
118 
119  ~QwtPlotPimpl() override
120  {
123 
124  bottomAxis->installEventFilter(parent);
125  leftAxis->removeEventFilter(parent);
126  canvas()->removeEventFilter(parent);
127 
128  setCanvas(nullptr);
129  }
130 
131  QRectF canvasBoundingRect() const
132  {
133  QRectF rect;
134  rect.setBottom(canvasMap(QwtPlot::yLeft).s1());
135  rect.setTop(canvasMap(QwtPlot::yLeft).s2());
136  rect.setLeft(canvasMap(QwtPlot::xBottom).s1());
137  rect.setRight(canvasMap(QwtPlot::xBottom).s2());
138  return rect;
139  }
140 
141  virtual void resizeEvent(QResizeEvent* ev) override
142  {
145  emit parent->widgetResized();
146  }
147 
148  std::list<CurveInfo> curve_list;
149 
150  CurveStyle curve_style = LINES;
151 
152  bool zoom_enabled = true;
153 
154  void dragEnterEvent(QDragEnterEvent* event) override
155  {
156  event_callback(event);
157  }
158 
159  void dragLeaveEvent(QDragLeaveEvent* event) override
160  {
161  event_callback(event);
162  }
163 
164  void dropEvent(QDropEvent* event) override
165  {
166  event_callback(event);
167  }
168 };
169 
170 namespace PJ
171 {
172 QwtPlot* PlotWidgetBase::qwtPlot()
173 {
174  return p;
175 }
176 
177 const QwtPlot* PlotWidgetBase::qwtPlot() const
178 {
179  return p;
180 }
181 
182 void PlotWidgetBase::resetZoom()
183 {
184  updateMaximumZoomArea();
185  QRectF rect = maxZoomRect();
186 
187  qwtPlot()->setAxisScale(QwtPlot::yLeft, std::min(rect.bottom(), rect.top()),
188  std::max(rect.bottom(), rect.top()));
189  qwtPlot()->setAxisScale(QwtPlot::xBottom, std::min(rect.left(), rect.right()),
190  std::max(rect.left(), rect.right()));
191  qwtPlot()->updateAxes();
192 
193  replot();
194 }
195 
196 Range PlotWidgetBase::getVisualizationRangeX() const
197 {
198  double left = std::numeric_limits<double>::max();
199  double right = std::numeric_limits<double>::lowest();
200 
201  for (auto& it : curveList())
202  {
203  if (!it.curve->isVisible())
204  {
205  continue;
206  }
207 
208  auto series = dynamic_cast<QwtSeriesWrapper*>(it.curve->data());
209  const auto max_range_X = series->getVisualizationRangeX();
210  if (!max_range_X)
211  {
212  continue;
213  }
214 
215  left = std::min(max_range_X->min, left);
216  right = std::max(max_range_X->max, right);
217  }
218 
219  if (left > right)
220  {
221  left = 0;
222  right = 0;
223  }
224 
225  double margin = 0.0;
226  if (fabs(right - left) > std::numeric_limits<double>::epsilon())
227  {
228  margin = isXYPlot() ? ((right - left) * 0.025) : 0.0;
229  }
230  right = right + margin;
231  left = left - margin;
232 
233  return Range({ left, right });
234 }
235 
236 Range PlotWidgetBase::getVisualizationRangeY(Range range_X) const
237 {
238  double top = std::numeric_limits<double>::lowest();
239  double bottom = std::numeric_limits<double>::max();
240 
241  for (auto& it : curveList())
242  {
243  if (!it.curve->isVisible())
244  {
245  continue;
246  }
247 
248  auto series = dynamic_cast<QwtSeriesWrapper*>(it.curve->data());
249 
250  auto max_range_X = series->getVisualizationRangeX();
251  if (!max_range_X)
252  {
253  continue;
254  }
255 
256  double left = std::max(max_range_X->min, range_X.min);
257  double right = std::min(max_range_X->max, range_X.max);
258  left = std::nextafter(left, right);
259  right = std::nextafter(right, left);
260 
261  auto range_Y = series->getVisualizationRangeY({ left, right });
262  if (!range_Y)
263  {
264  qDebug() << " invalid range_Y in PlotWidget::maximumRangeY";
265  continue;
266  }
267  if (top < range_Y->max)
268  {
269  top = range_Y->max;
270  }
271  if (bottom > range_Y->min)
272  {
273  bottom = range_Y->min;
274  }
275  }
276 
277  double margin = 0.1;
278 
279  if (bottom > top)
280  {
281  bottom = 0;
282  top = 0;
283  }
284 
285  if (top - bottom > std::numeric_limits<double>::epsilon())
286  {
287  margin = (top - bottom) * 0.025;
288  }
289 
290  top += margin;
291  bottom -= margin;
292 
293  return Range({ bottom, top });
294 }
295 
296 bool PlotWidgetBase::isXYPlot() const
297 {
298  return _xy_mode;
299 }
300 
301 QRectF PlotWidgetBase::currentBoundingRect() const
302 {
303  return p->canvasBoundingRect();
304 }
305 
306 QRectF PlotWidgetBase::maxZoomRect() const
307 {
308  return _max_zoom_rect;
309 }
310 
311 void PlotWidgetBase::setModeXY(bool enable)
312 {
313  _xy_mode = enable;
314 }
315 
316 PlotWidgetBase::PlotWidgetBase(QWidget* parent)
317  : _xy_mode(false), _keep_aspect_ratio(false)
318 {
319  auto onViewResized = [this](const QRectF& r) {
320  emit viewResized(r);
321  };
322 
323  auto onEvent = [this](QEvent* event) {
324  if (auto ev = dynamic_cast<QDragEnterEvent*>(event))
325  {
326  emit dragEnterSignal(ev);
327  }
328  else if(auto ev = dynamic_cast<QDragLeaveEvent*>(event))
329  {
330  emit dragLeaveSignal(ev);
331  }
332  else if (auto ev = dynamic_cast<QDropEvent*>(event))
333  {
334  emit dropSignal(ev);
335  }
336  };
337 
338  QSettings settings;
339  bool use_opengl = settings.value("Preferences::use_opengl", true).toBool();
340 
341  QWidget* abs_canvas;
342  if (use_opengl)
343  {
344  auto canvas = new QwtPlotOpenGLCanvas();
345  canvas->setFrameStyle(QFrame::NoFrame);
346  canvas->setFrameStyle(QFrame::Box | QFrame::Plain);
347  canvas->setLineWidth(1);
348  canvas->setPalette(Qt::white);
349  abs_canvas = canvas;
350  }
351  else
352  {
353  auto canvas = new QwtPlotCanvas();
354  canvas->setFrameStyle(QFrame::NoFrame);
355  canvas->setFrameStyle(QFrame::Box | QFrame::Plain);
356  canvas->setLineWidth(1);
357  canvas->setPalette(Qt::white);
358  canvas->setPaintAttribute(QwtPlotCanvas::BackingStore, true);
359  abs_canvas = canvas;
360  }
361  abs_canvas->setObjectName("qwtCanvas");
362 
363  p = new QwtPlotPimpl(this, abs_canvas, onViewResized, onEvent);
364 
365  auto layout = new QHBoxLayout(this);
366  layout->setMargin(0);
367  this->setLayout(layout);
368  layout->addWidget(p);
369 
370  qwtPlot()->setMinimumWidth(100);
371  qwtPlot()->setMinimumHeight(100);
372 
373  qwtPlot()->sizePolicy().setHorizontalPolicy(QSizePolicy::Expanding);
374  qwtPlot()->sizePolicy().setVerticalPolicy(QSizePolicy::Expanding);
375 
376  qwtPlot()->canvas()->setMouseTracking(true);
377 
378  qwtPlot()->setCanvasBackground(Qt::white);
381 
382  qwtPlot()
386 
387  qwtPlot()->setAxisScale(QwtPlot::xBottom, 0.0, 1.0);
388  qwtPlot()->setAxisScale(QwtPlot::yLeft, 0.0, 1.0);
389 }
390 
392 {
393  if (p)
394  {
395  delete p;
396  p = nullptr;
397  }
398 }
399 
401  PlotDataXY& data, QColor color)
402 {
403  const auto qname = QString::fromStdString(name);
404 
405  // title is the same of src_name, unless a transform was applied
406  auto curve_it = curveFromTitle(qname);
407  if (curve_it)
408  {
409  return nullptr; // TODO FIXME
410  }
411 
412  auto curve = new QwtPlotCurve(qname);
413  try
414  {
415  QwtSeriesWrapper* plot_qwt = nullptr;
416  if (auto ts_data = dynamic_cast<const PlotData*>(&data))
417  {
418  plot_qwt = createTimeSeries(ts_data);
419  }
420  else
421  {
422  plot_qwt = new QwtSeriesWrapper(&data);
423  }
424 
425  curve->setPaintAttribute(QwtPlotCurve::ClipPolygons, true);
426  curve->setPaintAttribute(QwtPlotCurve::FilterPointsAggressive, true);
427  curve->setData(plot_qwt);
428  }
429  catch (std::exception& ex)
430  {
431  QMessageBox::warning(qwtPlot(), "Exception!", ex.what());
432  return nullptr;
433  }
434 
435  if (color == Qt::transparent)
436  {
437  color = getColorHint(&data);
438  }
439 
440  curve->setPen(color);
441  setStyle(curve, p->curve_style);
442 
443  curve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
444 
445  curve->attach(qwtPlot());
446 
447  auto marker = new QwtPlotMarker;
448  marker->attach(qwtPlot());
449  marker->setVisible(false);
450 
451  QwtSymbol* sym =
452  new QwtSymbol(QwtSymbol::Ellipse, Qt::red, QPen(Qt::black), QSize(8, 8));
453  marker->setSymbol(sym);
454 
455  CurveInfo curve_info;
456  curve_info.curve = curve;
457  curve_info.marker = marker;
458  curve_info.src_name = name;
459 
460  p->curve_list.push_back(curve_info);
461 
462  return &(p->curve_list.back());
463 }
464 
466 {
467  return p->curve_list.empty();
468 }
469 
470 void PlotWidgetBase::removeCurve(const QString& title)
471 {
472  auto it = std::find_if(p->curve_list.begin(), p->curve_list.end(),
473  [&title](const PlotWidgetBase::CurveInfo& info) {
474  return info.curve->title() == title;
475  });
476 
477  if (it != p->curve_list.end())
478  {
479  it->curve->detach();
480  delete it->curve;
481  it->marker->detach();
482  delete it->marker;
483  p->curve_list.erase(it);
484 
485  emit curveListChanged();
486  }
487 }
488 
489 const std::list<PlotWidgetBase::CurveInfo>& PlotWidgetBase::curveList() const
490 {
491  return p->curve_list;
492 }
493 
494 std::list<PlotWidgetBase::CurveInfo>& PlotWidgetBase::curveList()
495 {
496  return p->curve_list;
497 }
498 
500  const QString& transform_ID)
501 {
503  output->setTransform(transform_ID);
504  output->updateCache(true);
505  return output;
506 }
507 
509 {
510  return p->curve_style;
511 }
512 
514 {
515  return _keep_aspect_ratio;
516 }
517 
519 {
520  _keep_aspect_ratio = active;
521  if (isXYPlot() && active)
522  {
523  zoomer()->keepAspectRatio(true);
524  }
525  else
526  {
527  zoomer()->keepAspectRatio(false);
528  }
529 }
530 
532 {
533  qwtPlot()->setAcceptDrops(accept);
534 }
535 
536 bool PlotWidgetBase::eventFilter(QObject* obj, QEvent* event)
537 {
538  if (event->type() == QEvent::Destroy)
539  {
540  return false;
541  }
542 
545 
546  if (magnifier() && (obj == bottomAxis || obj == leftAxis) &&
547  !(isXYPlot() && keepRatioXY()))
548  {
549  if (event->type() == QEvent::Wheel)
550  {
551  auto wheel_event = dynamic_cast<QWheelEvent*>(event);
552  if (obj == bottomAxis)
553  {
555  }
556  else
557  {
559  }
560  magnifier()->widgetWheelEvent(wheel_event);
561  }
562  }
563  if (obj == qwtPlot()->canvas())
564  {
565  if (magnifier())
566  {
568  }
569  switch (event->type())
570  {
571  case QEvent::Wheel: {
572  auto mouse_event = dynamic_cast<QWheelEvent*>(event);
573 
574  bool ctrl_modifier = mouse_event->modifiers() == Qt::ControlModifier;
575  auto legend_rect = legend()->geometry(qwtPlot()->canvas()->rect());
576 
577  if (ctrl_modifier)
578  {
579  if (legend_rect.contains(mouse_event->pos()) && legend()->isVisible())
580  {
581  int prev_size = legend()->font().pointSize();
582  int new_size = prev_size;
583  if (mouse_event->angleDelta().y() > 0)
584  {
585  new_size = std::min(13, prev_size + 1);
586  }
587  if (mouse_event->angleDelta().y() < 0)
588  {
589  new_size = std::max(7, prev_size - 1);
590  }
591  if (new_size != prev_size)
592  {
593  setLegendSize(new_size);
594  emit legendSizeChanged(new_size);
595  }
596  return true;
597  }
598  }
599  return false;
600  }
601  //-------------------
602  case QEvent::MouseButtonPress: {
603  QMouseEvent* mouse_event = static_cast<QMouseEvent*>(event);
604  if (mouse_event->button() == Qt::LeftButton &&
605  mouse_event->modifiers() == Qt::NoModifier)
606  {
607  auto clicked_item = legend()->processMousePressEvent(mouse_event);
608  if (clicked_item)
609  {
610  for (auto& it : curveList())
611  {
612  QSettings settings;
613  bool autozoom_visibility = settings.value("Preferences::autozoom_visibility",true).toBool();
614  if (clicked_item == it.curve)
615  {
616  it.curve->setVisible(!it.curve->isVisible());
617  //_tracker->redraw();
618 
619  if(autozoom_visibility)
620  {
621  resetZoom();
622  }
623  replot();
624  return true;
625  }
626  }
627  }
628  }
629  }
630  }
631  }
632  return false;
633 }
634 
636 {
637  QSettings settings;
638  bool remember_color = settings.value("Preferences::remember_color", true).toBool();
639 
640  if (data)
641  {
642  auto colorHint = data->attribute(COLOR_HINT);
643  if (remember_color && colorHint.isValid())
644  {
645  return colorHint.value<QColor>();
646  }
647  }
648  QColor color;
649  bool use_plot_color_index =
650  settings.value("Preferences::use_plot_color_index", false).toBool();
651  int index = p->curve_list.size();
652 
653  if (!use_plot_color_index)
654  {
655  index = (_global_color_index_++);
656  }
657 
658  // https://matplotlib.org/3.1.1/users/dflt_style_changes.html
659  switch (index % 8)
660  {
661  case 0:
662  color = QColor("#1f77b4");
663  break;
664  case 1:
665  color = QColor("#d62728");
666  break;
667  case 2:
668  color = QColor("#1ac938");
669  break;
670  case 3:
671  color = QColor("#ff7f0e");
672  break;
673 
674  case 4:
675  color = QColor("#f14cc1");
676  break;
677  case 5:
678  color = QColor("#9467bd");
679  break;
680  case 6:
681  color = QColor("#17becf");
682  break;
683  case 7:
684  color = QColor("#bcbd22");
685  break;
686  }
687  if (data)
688  {
689  data->setAttribute(COLOR_HINT, color);
690  }
691 
692  return color;
693 }
694 
695 std::map<QString, QColor> PlotWidgetBase::getCurveColors() const
696 {
697  std::map<QString, QColor> color_by_name;
698 
699  for (auto& it : p->curve_list)
700  {
701  color_by_name.insert({ it.curve->title().text(), it.curve->pen().color() });
702  }
703  return color_by_name;
704 }
705 
707 {
708  curve->setPen(curve->pen().color(), (style == DOTS) ? 4.0 : 1.3);
709 
710  switch (style)
711  {
712  case LINES:
714  break;
715  case LINES_AND_DOTS:
717  break;
718  case DOTS:
720  break;
721  case STICKS:
723  }
724 }
725 
727 {
728  p->curve_style = style;
729  for (auto& it : p->curve_list)
730  {
731  setStyle(it.curve, style);
732  }
733  replot();
734 }
735 
737 {
738  for (auto& info : p->curve_list)
739  {
740  if (info.curve->title() == title)
741  {
742  return &info;
743  }
744  if (info.src_name == title.toStdString())
745  {
746  return &info;
747  }
748  }
749  return nullptr;
750 }
751 
753 {
754  auto font = p->legend->font();
755  font.setPointSize(size);
756  p->legend->setFont(font);
757  replot();
758 }
759 
760 void PlotWidgetBase::setLegendAlignment(Qt::Alignment alignment)
761 {
762  p->legend->setAlignmentInCanvas(Qt::Alignment(Qt::AlignTop | alignment));
763 }
764 
766 {
767  p->zoom_enabled = enabled;
768  p->zoomer->setEnabled(enabled);
769  p->magnifier->setEnabled(enabled);
770  p->panner1->setEnabled(enabled);
771  p->panner2->setEnabled(enabled);
772 }
773 
775 {
776  return p->zoom_enabled;
777 }
778 
780 {
781  if (p->zoomer)
782  {
783  p->zoomer->setZoomBase(false);
784  }
785  qwtPlot()->replot();
786 }
787 
789 {
790  for (auto& it : curveList())
791  {
792  it.curve->detach();
793  delete it.curve;
794  it.marker->detach();
795  delete it.marker;
796  }
797 
798  curveList().clear();
799  emit curveListChanged();
800  replot();
801 }
802 
804 {
805  return p->legend;
806 }
808 {
809  return p->zoomer;
810 }
811 
813 {
814  return p->magnifier;
815 }
816 
818 {
819  QRectF max_rect;
820  auto rangeX = getVisualizationRangeX();
821  max_rect.setLeft(rangeX.min);
822  max_rect.setRight(rangeX.max);
823 
824  rangeX.min = std::numeric_limits<double>::lowest();
825  rangeX.max = std::numeric_limits<double>::max();
826  auto rangeY = getVisualizationRangeY(rangeX);
827  max_rect.setBottom(rangeY.min);
828  max_rect.setTop(rangeY.max);
829 
830  if (isXYPlot() && _keep_aspect_ratio)
831  {
832  const QRectF canvas_rect = p->canvas()->contentsRect();
833  const double canvas_ratio = fabs(canvas_rect.width() / canvas_rect.height());
834  const double data_ratio = fabs(max_rect.width() / max_rect.height());
835  if (data_ratio < canvas_ratio)
836  {
837  // height is negative!!!!
838  double new_width = fabs(max_rect.height() * canvas_ratio);
839  double increment = new_width - max_rect.width();
840  max_rect.setWidth(new_width);
841  max_rect.moveLeft(max_rect.left() - 0.5 * increment);
842  }
843  else
844  {
845  // height must be negative!!!!
846  double new_height = -(max_rect.width() / canvas_ratio);
847  double increment = fabs(new_height - max_rect.height());
848  max_rect.setHeight(new_height);
849  max_rect.moveTop(max_rect.top() + 0.5 * increment);
850  }
851  magnifier()->setAxisLimits(QwtPlot::xBottom, max_rect.left(), max_rect.right());
852  magnifier()->setAxisLimits(QwtPlot::yLeft, max_rect.bottom(), max_rect.top());
853  zoomer()->keepAspectRatio(true);
854  }
855  else
856  {
857  magnifier()->setAxisLimits(QwtPlot::xBottom, max_rect.left(), max_rect.right());
858  magnifier()->setAxisLimits(QwtPlot::yLeft, max_rect.bottom(), max_rect.top());
859  zoomer()->keepAspectRatio(false);
860  }
861  _max_zoom_rect = max_rect;
862 }
863 
864 } // namespace PJ
const QPen & pen() const
virtual RangeOpt getVisualizationRangeX()
bool isZoomEnabled() const
const QwtPlotItem * processMousePressEvent(QMouseEvent *mouse_event)
Definition: plotlegend.cpp:142
PlotLegend * legend()
void setStyle(CurveStyle style)
PlotZoomer * zoomer()
Enable antialiasing.
double max
Definition: plotdatabase.h:32
A plot item, that represents a series of points.
QwtPlotPimpl * p
std::list< CurveInfo > curve_list
#define nullptr
Definition: backward.hpp:386
void setCanvasBackground(const QBrush &)
Change the background of the plotting area.
Definition: qwt_plot.cpp:873
QwtPlotPimpl(PlotWidgetBase *parentObject, QWidget *canvas, std::function< void(const QRectF &)> resizedViewCallback, std::function< void(QEvent *)> eventCallback)
lu_byte right
Definition: lparser.c:1227
static int _global_color_index_
void setAcceptDrops(bool accept)
virtual void removeCurve(const QString &title)
lu_byte left
Definition: lparser.c:1226
virtual PJ::Range getVisualizationRangeY(PJ::Range range_X) const
void setCanvas(QWidget *)
Set the drawing canvas of the plot widget.
Definition: qwt_plot.cpp:213
virtual PJ::Range getVisualizationRangeX() const
virtual void replot()
Redraw the plot.
Definition: qwt_plot.cpp:545
void setZoomEnabled(bool enabled)
bool isVisible() const
Canvas of a QwtPlot.
A 2-D plotting widget.
Definition: qwt_plot.h:78
virtual void removeAllCurves()
A class for drawing symbols.
Definition: qwt_symbol.h:31
void dragLeaveSignal(QDragLeaveEvent *event)
void changeCurvesStyle(CurveStyle style)
void viewResized(const QRectF &)
std::function< void(QEvent *)> event_callback
bool eventFilter(QObject *obj, QEvent *event)
virtual void widgetWheelEvent(QWheelEvent *event) override
PlotMagnifier * magnifier()
void setAxisAutoScale(QwtAxisId, bool on=true)
Enable autoscaling for a specified axis.
const std::list< CurveInfo > & curveList() const
void dragLeaveEvent(QDragLeaveEvent *event) override
void dragEnterSignal(QDragEnterEvent *event)
void keepAspectRatio(bool doKeep)
Definition: plotzoomer.h:24
A Widget which contains a scale.
void setLegendAlignment(Qt::Alignment alignment)
void setDefaultMode(AxisMode mode)
Definition: plotmagnifier.h:38
Ellipse or circle.
Definition: qwt_symbol.h:44
static void setStyle(QwtPlotCurve *curve, CurveStyle style)
virtual CurveInfo * addCurve(const std::string &name, PlotDataXY &src_data, QColor color=Qt::transparent)
virtual QwtSeriesWrapper * createTimeSeries(const PlotData *data, const QString &transform_ID={})
virtual void updateCache(bool reset_old_data) override
void setZoomInKey(int key, Qt::KeyboardModifiers=Qt::NoModifier)
void setAxisEnabled(QwtAxisId, bool on)
En/Disable an axis.
void setAlignCanvasToScales(bool)
Set the align-canvas-to-axis-scales flag for all axes.
void legendSizeChanged(int new_size)
void rescaled(QRectF new_size)
void rescaled(QRectF new_size)
void dropEvent(QDropEvent *event) override
virtual void resizeEvent(QResizeEvent *ev) override
QVariant attribute(PlotAttribute id) const
Definition: plotdatabase.h:238
CurveStyle curveStyle() const
void setPen(const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
std::function< void(const QRectF &)> resized_callback
void setZoomOutKey(int key, Qt::KeyboardModifiers=Qt::NoModifier)
color
Definition: color.h:23
bool keepRatioXY() const
int top(lua_State *L)
Definition: sol.hpp:11684
virtual void setVisible(bool)
void setTransform(QString transform_ID)
QWidget * canvas()
Definition: qwt_plot.cpp:463
CurveInfo * curveFromTitle(const QString &title)
void attach(QwtPlot *plot)
Attach the item to a plot.
void setAxisLimits(int axis, double lower, double upper)
virtual bool event(QEvent *) QWT_OVERRIDE
Adds handling of layout requests.
Definition: qwt_plot.cpp:237
std::enable_if_t< all< Args... >::value, enable_t > enable
Definition: sol.hpp:2244
virtual void resizeEvent(QResizeEvent *) QWT_OVERRIDE
Definition: qwt_plot.cpp:530
virtual QRect geometry(const QRectF &canvasRect) const
void setAttribute(PlotAttribute id, const QVariant &value)
Definition: plotdatabase.h:229
void setLegendSize(int size)
void setAxisScale(QwtAxisId, double min, double max, double stepSize=0)
Disable autoscaling and specify a fixed scale for a selected axis.
double min
Definition: plotdatabase.h:31
virtual QwtScaleMap canvasMap(QwtAxisId) const
Definition: qwt_plot.cpp:800
void setMousePattern(MousePatternCode, Qt::MouseButton button, Qt::KeyboardModifiers=Qt::NoModifier)
const QwtScaleWidget * axisWidget(QwtAxisId) const
An alternative canvas for a QwtPlot derived from QOpenGLWidget.
span_constexpr std::size_t size(span< T, Extent > const &spn)
Definition: span.hpp:1485
void setKeepRatioXY(bool active)
static const char * output
Definition: luac.c:38
void setMouseButton(Qt::MouseButton, Qt::KeyboardModifiers=Qt::NoModifier)
Definition: qwt_panner.cpp:110
QColor getColorHint(PlotDataXY *data)
virtual void resetZoom()
void setRubberBandPen(const QPen &)
Definition: qwt_picker.cpp:459
void dragEnterEvent(QDragEnterEvent *event) override
void setMouseButton(Qt::MouseButton, Qt::KeyboardModifiers=Qt::NoModifier)
void setAttribute(Attribute, bool on=true)
void zoomed(const QRectF &rect)
void dropSignal(QDropEvent *event)
QwtScaleEngine * axisScaleEngine(QwtAxisId)
std::map< QString, QColor > getCurveColors() const
Definition: format.h:895
void setTrackerPen(const QPen &)
Definition: qwt_picker.cpp:435
QwtPlotLayout * plotLayout()
Definition: qwt_plot.cpp:430
A class for drawing markers.
Paint double buffered reusing the content of the pixmap buffer when possible.


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Jun 19 2023 03:01:38