.Simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Graph.h
1 // Graph.h - Graph extension template class implementation.
2 // Written By Jesse Z. Zhong
3 #ifndef __Graph_H__
4 #define __Graph_H__
5 #pragma region Includes
6 #include "stdafx.h"
7 
8 #include <QRubberBand>
9 #include "QCPExtended.h"
10 
11 #include "DataFile.h"
12 #include "PlotData.h"
13 #include "QCPAxisExtended.h"
14 #include "ColorPicker.h"
15 #include "Utilities.h"
16 
17 using namespace std;
18 namespace Util = Utilities;
19 #pragma endregion
20 namespace DataVisualizerGUI {
21 
26  template<class T = DataFile>
27  class Graph : public QCPExtended {
28  #pragma region Constants
29  static const float ScatterDotSize;
31 
33  static const float BoldPenWidth;
34  #pragma endregion
35  public:
43  Graph(QWidget* parent);
44 
50  ~Graph();
51 
55  void InitializeGraph(const QRect& rect,
56  string xAxisLabel, string yAxisLabel);
57 
68  void AddPlot(T& data, int upper = 0);
69 
75  void RemovePlot(PlotData* dataSet);
76 
77  #pragma region Draw Methods
78 
81  void Refresh();
82 
86  void replot();
87 
91  void ResetView();
92 
96  bool IsZoomed() const;
97 
101  void AdjustRange();
102 
106  void Clear();
107 
111  void ClearFullViewport();
112  #pragma endregion
113  #pragma region Accessors
114 
120  list<PlotData*>* GetData();
121 
125  double GetXLower() const;
126 
130  double GetXUpper() const;
131 
135  double GetYLower() const;
136 
140  double GetYUpper() const;
141 
147  void SetXLower(double val);
148 
154  void SetXUpper(double val);
155 
161  void SetYLower(double val);
162 
168  void SetYUpper(double val);
169 
173  double GetFullXLower() const;
174 
178  double GetFullXUpper() const;
179 
183  double GetFullYLower() const;
184 
188  double GetFullYUpper() const;
189 
193  void SetFullXLower(double val);
194 
198  void SetFullXUpper(double val);
199 
203  void SetFullYLower(double val);
204 
208  void SetFullYUpper(double val);
209 
213  void SetXAxis(double lower, double upper);
214 
218  void SetYAxis(double lower, double upper);
219 
223  void SetXLabel(string label);
224 
228  void SetYLabel(string label);
229 
234  void SetAutomaticResize(bool automaticallyResizes);
235 
239  void SetBoldfacedSelect(bool isBold);
240  #pragma endregion
241  #pragma region Plot Data and Drawing: Methods
242 
251  virtual void ProcessPoints(T& data, int upper = 0) = 0;
252 
256  void RegisterPlot(PlotData* plotData);
257 
261  void AddPlots();
262 
263  #pragma endregion
264  #pragma region User Events: Methods
265 
268  void mousePressEvent(QMouseEvent *event);
269 
273  void mouseMoveEvent(QMouseEvent *event);
274 
278  void mouseReleaseEvent(QMouseEvent* event);
279 
283  void wheelEvent(QWheelEvent *event);
284 
288  void keyPressEvent(QKeyEvent* event);
289 
293  void keyReleaseEvent(QKeyEvent* event);
294 
298  QRect BoundingArea() const;
299  #pragma endregion
300  #pragma region Plot Data and Drawing: Members
301  list<PlotData*>* Data_;
302  map<QCPAbstractPlottable*, PlotData*> PlottableList_;
306  #pragma endregion
307  #pragma region Zooming with Mouse Selection: Members
308  QRubberBand* SelectionBox_;
309  QPoint Origin_;
311  #pragma endregion
312  #pragma region Plot Axises: Members
315  string XAxisLabel_;
316  string YAxisLabel_;
317  #pragma endregion
318  #pragma region User Events: Members
324  #pragma endregion
325  };
326 
327  template<class T>
328  const float Graph<T>::ScatterDotSize = 0.1f;
329 
330  template<class T>
331  const float Graph<T>::BoldPenWidth = 1.5f;
332 
333  template<class T>
334  Graph<T>::Graph(QWidget* parent)
335  : QCPExtended(parent) {
336 
337  // Initialize graphing data.
338  this->Data_ = new list<PlotData*>();
339  this->XLower_ = 0;
340  this->XUpper_ = 0;
341  this->YLower_ = 0;
342  this->YUpper_ = 0;
343  this->RescaleAxis_ = false;
344  this->IsScatterPlot_ = false;
345  this->PlottableList_ = map<QCPAbstractPlottable*, PlotData*>();
346 
347  // Initialize event handling members.
348  this->Origin_ = QPoint();
349  this->FullXLower_ = 0;
350  this->FullXUpper_ = 0;
351  this->FullYLower_ = 0;
352  this->FullYUpper_ = 0;
353  this->IsMouseZooming_ = false;
354  this->IsPlotGrabbed_ = false;
355  this->SelectionBox_ = new QRubberBand(QRubberBand::Rectangle, this);
356  this->SelectedPlot_ = NULL;
357  this->SelectedPlotData_ = NULL;
358  this->DefaultPenWidth_ = QPen().widthF();
359  this->IsSelectBoldfaced_ = false;
360 
361  // Assign new axis extension type.
362  delete this->xAxis;
363  delete this->yAxis;
364  this->xAxis = this->xAxisEX_ = new QCPAxisExtended(this, QCPAxis::atBottom);
365  this->yAxis = this->yAxisEX_ = new QCPAxisExtended(this, QCPAxis::atLeft);
366 
367  // Set focus level for handling keyboard input.
368  this->setFocusPolicy(Qt::FocusPolicy::StrongFocus);
369 
370  // Connect the scroll bar of the x axis to the viewport moving event.
371  connect(this->xAxisEX_->GetScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(ShiftViewport(int)));
372  }
373 
374  template<class T>
376 
377  // Delete the data for plots and curves.
378  for(auto i = this->Data_->begin(),
379  j = this->Data_->end(); i != j; i++) {
380  delete (*i);
381  *i = NULL;
382  }
383  this->Data_->clear();
384  delete this->Data_;
385  this->Data_ = NULL;
386 
387  // Delete the curves and plots.
388  // NOTE: Allow QCustomPlot to handle plottable deletion.
389  // NOTE: The value is assumed to already
390  // be deleted at this point. Refer to above.
391  // for(auto i = this->PlottableList_.begin(),
392  // j = this->PlottableList_.end(); i != j; i++) {
393  // if((*i).first != NULL) {
394  // delete (*i).first;
395  // }
396  // }
397  this->PlottableList_.clear();
398 
399  // Delete the selection box.
400  if(this->SelectionBox_ != NULL) {
401  delete this->SelectionBox_;
402  this->SelectionBox_ = NULL;
403  }
404  }
405 
406  template<class T>
407  void Graph<T>::InitializeGraph(const QRect& rect,
408  string xAxisLabel, string yAxisLabel) {
409 
410  // Adjust the geometry.
411  this->setGeometry(rect);
412 
413  // Set graph labels.
414  this->SetXLabel(xAxisLabel);
415  this->SetYLabel(yAxisLabel);
416 
417  // Redraw the graph.
418  this->Refresh();
419  }
420 
421  template<class T>
422  void Graph<T>::AddPlot(T& data, int upper) {
423 
424  // Reset the full view port bounds.
425  this->ClearFullViewport();
426 
427  // Processes data and stores them as data points.
428  this->ProcessPoints(data, upper);
429  }
430 
431  template<class T>
433 
434  // Remove the data from the list.
435  this->Data_->remove(dataSet);
436 
437  // Refresh the graph.
438  this->Refresh();
439  }
440 
441  template<class T>
443 
444  // Clears old plots and curves.
445  this->clearPlottables();
446  this->clearGraphs();
447  this->clearItems();
448  this->PlottableList_.clear();
449 
450  // Sets the user interaction level.
451  this->setInteraction(QCustomPlot::iSelectPlottables);
452 
453  // Add plots to the graph.
454  this->AddPlots();
455 
456  // Set label names into the graph.
457  this->xAxis->setLabel(this->XAxisLabel_.c_str());
458  this->yAxis->setLabel(this->YAxisLabel_.c_str());
459 
460  // Set the graphs drawable ranges.
461  this->xAxis->setRange(this->XLower_, this->XUpper_);
462  this->yAxis->setRange(this->YLower_, this->YUpper_);
463 
464  // Set other graph settings.
465  if(this->RescaleAxis_)
466  this->rescaleAxes();
467 
468  // Redraw the graph.
469  this->replot();
470  }
471 
472  template<class T>
474 
475  // Changes the state of the axis.
476  bool isZoomed;
477  this->xAxisEX_->SetIsZoomed(isZoomed = this->IsZoomed());
478 
479  // Check if the viewport is zoomed in.
480  if(isZoomed) {
481 
482  // Localize the scroll bar.
483  QScrollBar* scrollBar = this->xAxisEX_->GetScrollBar();
484 
485  // Calculate the ranges.
486  double viewRange = (this->XUpper_ - this->XLower_);
487  double fullRange = (this->FullXUpper_ - this->FullXLower_);
488 
489  // Set the bounds of the scroll bar.
490  scrollBar->setRange(0, (int)ceil(this->xAxis->coordToPixel(fullRange - viewRange)));
491 
492  // Calculate the current slider position in
493  // terms of the lower bound of the viewport.
494  int sliderPos = (int)ceil(this->xAxis->coordToPixel(this->XLower_ - this->FullXLower_));
495 
496  // Corrects the position on the scroll bar.
497  if((sliderPos <= scrollBar->maximum())
498  && (sliderPos >= scrollBar->minimum()))
499  scrollBar->setSliderPosition(sliderPos);
500  }
501 
502  // Call the base draw method.
503  QCustomPlot::replot();
504  }
505 
506  template<class T>
508 
509  // Reset the viewable range to the original.
510  this->xAxis->setRange(this->XLower_ = this->FullXLower_,
511  this->XUpper_ = this->FullXUpper_);
512  this->yAxis->setRange(this->YLower_ = this->FullYLower_,
513  this->YUpper_ = this->FullYUpper_);
514 
515  // Redraw the plot.
516  // NOTE: Replot is called instead of reloading all of the data.
517  this->replot();
518  }
519 
520  template<class T>
522 
523  // Iterate through the list of data.
524  for(auto i = this->Data_->begin(),
525  j = this->Data_->end(); i != j; i++) {
526 
527  // Delete the plot data.
528  delete *i;
529  *i = NULL;
530  }
531 
532  // Clear all the items from the data list.
533  this->Data_->clear();
534  }
535 
536  template<class T>
538  this->FullXLower_ = 0;
539  this->FullXUpper_ = 0;
540  this->FullYLower_ = 0;
541  this->FullYUpper_ = 0;
542  }
543 
544  template<class T>
545  bool Graph<T>::IsZoomed() const {
546  if((this->FullXLower_ != this->XLower_)
547  || (this->FullXUpper_ != this->XUpper_)
548  || (this->FullYLower_ != this->YLower_)
549  || (this->FullYUpper_ != this->YUpper_))
550  return true;
551  return false;
552  }
553 
554  template<class T>
556 
557  // Declare intermediate variables.
558  // NOTE: The initialization values are 0.
559  // This means no min should be above 0 and no
560  // max should be below 0. i.e. There is a purpose.
561  double xLower(0), xUpper(0), yLower(0), yUpper(0);
562 
563  // Iterate through and rejudge maximums and minimums.
564  for(auto i = this->Data_->begin(),
565  j = this->Data_->end(); i != j; i++) {
566 
567  // Localize for consistency purposes.
568  double iXLower = (*i)->GetXLower();
569  double iXUpper = (*i)->GetXUpper();
570  double iYLower = (*i)->GetYLower();
571  double iYUpper = (*i)->GetYUpper();
572 
573  // Perform comparisons.
574  xLower = (xLower > iXLower) ? iXLower : xLower;
575  xUpper = (xUpper < iXUpper) ? iXUpper : xUpper;
576  yLower = (yLower > iYLower) ? iYLower : yLower;
577  yUpper = (yUpper < iYUpper) ? iYUpper : yUpper;
578  }
579 
580  // Reassign the maximums and minimums.
581  this->FullXLower_ = xLower;
582  this->FullXUpper_ = xUpper;
583  this->FullYLower_ = yLower;
584  this->FullYUpper_ = yUpper;
585  }
586 
587  template<class T>
588  list<PlotData*>* Graph<T>::GetData() {
589  return this->Data_;
590  }
591 
592  template<class T>
593  double Graph<T>::GetXLower() const {
594  return this->XLower_;
595  }
596 
597  template<class T>
598  double Graph<T>::GetXUpper() const {
599  return this->XUpper_;
600  }
601 
602  template<class T>
603  double Graph<T>::GetYLower() const {
604  return this->YLower_;
605  }
606 
607  template<class T>
608  double Graph<T>::GetYUpper() const {
609  return this->YUpper_;
610  }
611 
612  template<class T>
613  void Graph<T>::SetXLower(double val) {
614  this->XLower_ = val;
615  }
616 
617  template<class T>
618  void Graph<T>::SetXUpper(double val) {
619  this->XUpper_ = val;
620  }
621 
622  template<class T>
623  void Graph<T>::SetYLower(double val) {
624  this->YLower_ = val;
625  }
626 
627  template<class T>
628  void Graph<T>::SetYUpper(double val) {
629  this->YUpper_ = val;
630  }
631 
632  template<class T>
633  double Graph<T>::GetFullXLower() const {
634  return this->FullXLower_;
635  }
636 
637  template<class T>
638  double Graph<T>::GetFullXUpper() const {
639  return this->FullXUpper_;
640  }
641 
642  template<class T>
643  double Graph<T>::GetFullYLower() const {
644  return this->FullYLower_;
645  }
646 
647  template<class T>
648  double Graph<T>::GetFullYUpper() const {
649  return this->FullYUpper_;
650  }
651 
652  template<class T>
653  void Graph<T>::SetFullXLower(double val) {
654  this->FullXLower_ = val;
655  }
656 
657  template<class T>
658  void Graph<T>::SetFullXUpper(double val) {
659  this->FullXUpper_ = val;
660  }
661 
662  template<class T>
663  void Graph<T>::SetFullYLower(double val) {
664  this->FullYLower_ = val;
665  }
666 
667  template<class T>
668  void Graph<T>::SetFullYUpper(double val) {
669  this->FullYUpper_ = val;
670  }
671 
672  template<class T>
673  void Graph<T>::SetXAxis(double lower, double upper) {
674  this->xAxis->setRange(lower, upper);
675  this->FullXLower_ = lower;
676  this->FullXUpper_ = upper;
677  }
678 
679  template<class T>
680  void Graph<T>::SetYAxis(double lower, double upper) {
681  this->yAxis->setRange(lower, upper);
682  this->FullYLower_ = lower;
683  this->FullYUpper_ = upper;
684  }
685 
686  template<class T>
687  void Graph<T>::SetXLabel(string label) {
688  this->XAxisLabel_ = label;
689  }
690 
691  template<class T>
692  void Graph<T>::SetYLabel(string label) {
693  this->YAxisLabel_ = label;
694  }
695 
696  template<class T>
697  void Graph<T>::SetAutomaticResize(bool automaticallyResizes) {
698  this->RescaleAxis_ = automaticallyResizes;
699  }
700 
701  template<class T>
703 
704  // Store the data into the data list.
705  this->GetData()->push_back(plotData);
706 
707  // Recalculate the view port ranges.
708  this->AdjustRange();
709 
710  // Reset the view port with the new max and min.
711  this->ResetView();
712  }
713 
714  template<class T>
716 
717  // Reset the list of the colors.
718  this->ColorPicker_.Reset();
719 
720  // Keep track of the number of plots that have names.
721  int numOfNamedPlots = 0;
722 
723  // Iterate through list to add plots.
724  for(auto i = this->Data_->begin(),
725  j = this->Data_->end(); i != j; i++) {
726 
727  // Create an abstract plot used for
728  // storing and adding new plots and curves.
729  QCPAbstractPlottable* tempPlottable;
730 
731  // Pick a color for the pen used in drawing the
732  // plot and the text for the plot's legend entry.
733  QColor plotColor = this->ColorPicker_.Draw(ColorPicker::Preset);
734  QPen drawPen = QPen(plotColor);
735 
736  // Check if the graph type is a scatter plot.
737  if(this->IsScatterPlot_) {
738 
739  // Create a new scatter plot.
740  QCPGraph *ScatterGraph = new QCPGraph(this->xAxis,
741  this->yAxis);
742 
743  // Add the new plot as a new entry in the graph.
744  this->addPlottable(ScatterGraph);
745  ScatterGraph->setData((*i)->X, (*i)->Y);
746 
747  // Adjust the colors of the new plot.
748  drawPen.setWidthF(((*i)->GetSelected()) ? BoldPenWidth : this->DefaultPenWidth_);
749  ScatterGraph->setPen(drawPen);
750  ScatterGraph->setScatterStyle(QCP::ssDisc);
751  ScatterGraph->setScatterSize(ScatterDotSize);
752  ScatterGraph->setLineStyle(QCPGraph::lsNone);
753 
754  // Reference the new plot to be
755  // stored in the list of graphs later.
756  tempPlottable = ScatterGraph;
757 
758  } else {
759 
760  // Create a new curve.
761  QCPCurve *CurveGraph = new QCPCurve(this->xAxis,
762  this->yAxis);
763 
764  // Add the new curve as a new entry in the graph.
765  this->addPlottable(CurveGraph);
766  CurveGraph->setData((*i)->X, (*i)->Y);
767 
768  // Adjust the colors of the new curve.
769  drawPen.setWidthF(((*i)->GetSelected()) ? BoldPenWidth : this->DefaultPenWidth_);
770  CurveGraph->setPen(drawPen);
771 
772  // Reference the new curve to be
773  // stored in the list of graphs later.
774  tempPlottable = CurveGraph;
775  }
776 
777  // Check if the plot data has a name for the plot.
778  if((*i)->Name != "") {
779 
780  // Set the name of the plottable.
781  tempPlottable->setName((*i)->Name);
782 
783  // Increment the number of plots if this plot has a name.
784  numOfNamedPlots++;
785  }
786 
787  // Add new curve or plot to the list of plots.
788  this->PlottableList_.insert(pair<QCPAbstractPlottable*,
789  PlotData*>(tempPlottable, (*i)));
790  }
791 
792  // If there are named plots, show the legend.
793  this->legend->setVisible((numOfNamedPlots > 0) ? true : false);
794  }
795 
796  template<class T>
797  void Graph<T>::SetBoldfacedSelect(bool isBold) {
798  this->IsSelectBoldfaced_ = isBold;
799  }
800 
801  template<class T>
802  QRect Graph<T>::BoundingArea() const {
803 
804  // Create a bounding area out of the graph margins.
805  QRect plotGeo = this->geometry();
806  return QRect(this->marginLeft(), this->marginTop(),
807  (plotGeo.width()/* - this->marginLeft() - this->marginRight()*/),
808  (plotGeo.height() - this->marginTop() - this->marginBottom()));
809  }
810 
811  template<class T>
812  void Graph<T>::mousePressEvent(QMouseEvent *event) {
813  // Plot Selection Zooming
814  // Check if the button pressed is the left mouse button.
815  if(event->button() == Qt::MouseButton::LeftButton) {
816 
817  // Pull the starting position of the mouse.
818  this->Origin_ = event->pos();
819 
820  // Change the dimensions of the selection box.
821  if(Util::CheckBoundaries(this->Origin_, this->BoundingArea())) {
822  this->SelectionBox_->setGeometry(QRect(this->Origin_, QSize()));
823  this->SelectionBox_->show();
824 
825  // Change the state.
826  this->IsMouseZooming_ = true;
827  }
828 
829  // Set the mouse dragging flag to true.
830  this->mDragging = true;
831  }
832 
833  // Reset the Viewport to Full View
834  // Check if right mouse button was pressed.
835  if(event->button() == Qt::MouseButton::RightButton) {
836 
837  // Resets the viewport to full view.
838  this->ResetView();
839  }
840 
841  // Call base event.
842  QWidget::mousePressEvent(event);
843  }
844 
845  template<class T>
846  void Graph<T>::mouseMoveEvent(QMouseEvent *event) {
847 
848  // Emit the mouse move event.
849  emit mouseMove(event);
850 
851  // Check if the mouse is clicked and dragging.
852  if(this->mDragging) {
853  // Controls the Viewport Zooming
854  // Check if the mouse is invoking the zoom state.
855  if(this->IsMouseZooming_) {
856 
857  // Localize the position.
858  QPoint currPos = event->pos();
859 
860  // Localize the bounding area of the plot.
861  QRect boundingArea = this->BoundingArea();
862 
863  // Update the dimensions of the selection box.
864  this->SelectionBox_->setGeometry(QRect(this->Origin_,
865  Util::CheckPoint(currPos, boundingArea)).normalized());
866 
867  } else {
868 
869  // Controls Plot Selection and Moving
870  // Check if a plot is currently selected.
871  if(this->IsPlotGrabbed_ && this->SelectedPlotData_) {
872 
873  // Localize the position of the mouse.
874  QPoint mp = event->pos();
875 
876  // Calculate the offsets.
877  double xOffset = this->xAxis->pixelToCoord(mp.x())
878  - this->xAxis->pixelToCoord(this->Origin_.x());
879  double yOffset = this->yAxis->pixelToCoord(mp.y())
880  - this->yAxis->pixelToCoord(this->Origin_.y());
881 
882  // Offset the data.
883  this->SelectedPlotData_->SetXYOffset(this->SelectedPlotData_->GetXOffset()
884  + xOffset, this->SelectedPlotData_->GetYOffset() + yOffset);
885 
886  // Set the new lower and upper bounds.
887  this->AdjustRange();
888 
889  // Redraw the plots.
890  this->Refresh();
891  }
892 
893  // Save the current position of the mouse.
894  this->Origin_ = event->pos();
895  }
896  }
897 
898  // Call base widget event handler.
899  QWidget::mouseMoveEvent(event);
900  }
901 
902  template<class T>
903  void Graph<T>::mouseReleaseEvent(QMouseEvent* event) {
904 
905  // Check if the button released was the left mouse button.
906  if(event->button() == Qt::MouseButton::LeftButton) {
907 
908  // Check if the mouse has invoked zooming.
909  if(this->IsMouseZooming_) {
910 
911  // Localize the geometry of the selection box.
912  QRect selectArea = this->SelectionBox_->geometry();
913 
914  // Set the view range for the x axis.
915  this->XLower_ = this->xAxis->pixelToCoord(selectArea.x());
916  this->XUpper_ = this->xAxis->pixelToCoord(selectArea.x() + selectArea.width());
917 
918  // Set the view range for the y axis.
919  this->YLower_ = this->yAxis->pixelToCoord(selectArea.y());
920  this->YUpper_ = this->yAxis->pixelToCoord(selectArea.y() + selectArea.height());
921 
922  // Adjust the viewport and replot.
923  this->SetBounds();
924 
925  // Stop drawing the selection box.
926  this->SelectionBox_->hide();
927 
928  // Clear the state.
929  this->IsMouseZooming_ = false;
930  }
931 
932  // Set the selectable state to false.
933  this->IsPlotGrabbed_ = false;
934 
935  // Set the mouse dragging flag to false.
936  this->mDragging = false;
937 
938  this->replot();
939  }
940 
941  // Call base event handler.
942  QWidget::mouseReleaseEvent(event);
943  }
944 
945  template<class T>
946  void Graph<T>::wheelEvent(QWheelEvent *event) {
947  emit mouseWheel(event);
948 
949  // Call base event handler.
950  QWidget::wheelEvent(event);
951  }
952 
953  template<class T>
954  void Graph<T>::keyPressEvent(QKeyEvent* event) {
955 
956  // Call base event handler.
957  QWidget::keyPressEvent(event);
958  }
959 
960  template<class T>
961  void Graph<T>::keyReleaseEvent(QKeyEvent* event) {
962 
963  // Call base event handler.
964  QWidget::keyReleaseEvent(event);
965  }
966 }
967 #endif // !__Graph_H__
QCPAbstractPlottable * SelectedPlot_
Pointer to a previously selected plot.
Definition: Graph.h:319
string XAxisLabel_
The label used to identify values on the x-axis.
Definition: Graph.h:315
Colors are picked from a special list of colors.
Definition: ColorPicker.h:31
ColorPicker ColorPicker_
Object used to choose plot colors from a preset list of colors.
Definition: Graph.h:303
bool IsSelectBoldfaced_
Indicates if selected plots should be drawn with boldface.
Definition: Graph.h:323
void mouseReleaseEvent(QMouseEvent *event)
Override the mouse release event to incorporate extra behavior.
Definition: Graph.h:903
list< PlotData * > * GetData()
Returns the pointer to the plot data.
Definition: Graph.h:588
The abstract base class for all data representing objects in a plot.
Definition: qcustomplot.h:357
map< QCPAbstractPlottable *, PlotData * > PlottableList_
List of the plots mapped with their data.
Definition: Graph.h:302
void Clear()
Safely clears all the data from the graph.
Definition: Graph.h:521
Extends the axis class to allow scrolling when zoomed.
Definition: QCPAxisExtended.h:16
void Refresh()
Clears and redraws the graph.
Definition: Graph.h:442
void SetAutomaticResize(bool automaticallyResizes)
Set or get the ability for the graph to resize itself along with changes in data. ...
Definition: Graph.h:697
bool IsPlotGrabbed_
Indicates that a plot is currently being selected.
Definition: Graph.h:321
void ShiftViewport(int value)
Shifts the viewport of the graph along the x axis.
Definition: QCPExtended.cpp:14
bool IsScatterPlot_
Changes the style of plot between curve and scatter.
Definition: Graph.h:305
void setData(QCPDataMap *data, bool copy=false)
Replaces the current data with the provided data.
Definition: qcustomplot.cpp:378
void AdjustRange()
Calculates the new bounds after a plot has been changed.
Definition: Graph.h:555
void setData(QCPCurveDataMap *data, bool copy=false)
Replaces the current data with the provided data.
Definition: qcustomplot.cpp:9250
void keyPressEvent(QKeyEvent *event)
Override the key press event to handle special behavior.
Definition: Graph.h:954
QRubberBand * SelectionBox_
Object used to visually identify the area the user selects.
Definition: Graph.h:308
double GetXLower() const
Returns the lower bound on the x-axis.
Definition: Graph.h:593
void setScatterSize(double size)
This defines how big (in pixels) single scatters are drawn, if scatter style (setScatterStyle) isn&#39;t ...
Definition: qcustomplot.cpp:607
QCPAxisExtended * xAxisEX_
Extended x-axis object with scrollbar.
Definition: Graph.h:313
QCPAxisExtended * yAxisEX_
Extended y-axis object with scrollbar.
Definition: Graph.h:314
void setLineStyle(LineStyle ls)
Sets how the single data points are connected in the plot or how they are represented visually apart ...
Definition: qcustomplot.cpp:584
double GetYLower() const
Returns the lower bound on the y-axis.
Definition: Graph.h:603
list< PlotData * > * Data_
List of data sets for individual plots.
Definition: Graph.h:301
void AddPlot(T &data, int upper=0)
Processes and stores points when called.
Definition: Graph.h:422
bool RescaleAxis_
Flag for indicating if the graph can resize with the change in data points.
Definition: Graph.h:304
string YAxisLabel_
The label used to identify values on the y-axis.
Definition: Graph.h:316
void SetYUpper(double val)
Assigns the y-axis&#39; upper bound with a new value.
Definition: Graph.h:628
void setScatterStyle(QCP::ScatterStyle ss)
Sets the visual appearance of single data points in the plot.
Definition: qcustomplot.cpp:595
void InitializeGraph(const QRect &rect, string xAxisLabel, string yAxisLabel)
Sets up the dimensions and labels for graph.
Definition: Graph.h:407
void SetYLabel(string label)
Sets the labels for the y-axis.
Definition: Graph.h:692
void ResetView()
Resets the view port to the maximum viewable range.
Definition: Graph.h:507
QRect BoundingArea() const
Returns the bounding area of plot view area.
Definition: Graph.h:802
A plottable representing a parametric curve in a plot.
Definition: qcustomplot.h:580
double GetYUpper() const
Returns the upper bound on the y-axis.
Definition: Graph.h:608
bool IsMouseZooming_
Indicates if the user is making an area selection.
Definition: Graph.h:310
~Graph()
Destructor.
Definition: Graph.h:375
void SetYAxis(double lower, double upper)
Sets the full y-axis range that can be returned to at any time.
Definition: Graph.h:680
void RemovePlot(PlotData *dataSet)
Removes a specific data set from the graph.
Definition: Graph.h:432
void mousePressEvent(QMouseEvent *event)
Override the mouse press event to incorporate extra behavior.
Definition: Graph.h:812
QScrollBar * GetScrollBar()
Returns the reference to the scroll bar.
Definition: QCPAxisExtended.cpp:25
Extension of the QCustomPlot class that allows an implementation of the class with different event ha...
Definition: QCPExtended.h:17
void SetXUpper(double val)
Assigns the x-axis&#39; upper bound with a new value.
Definition: Graph.h:618
void SetXLabel(string label)
Sets the labels for the x-axis.
Definition: Graph.h:687
void mouseMoveEvent(QMouseEvent *event)
Override the original mouse event to handle a different behavior.
Definition: Graph.h:846
void setPen(const QPen &pen)
The pen is used to draw basic lines that make up the plottable representation in the plot...
Definition: qcustomplot.cpp:8430
Structure for storing data for individual curves.
Definition: PlotData.h:15
void ClearFullViewport()
Wipes the full view port bounds.
Definition: Graph.h:537
A plottable representing a graph in a plot.
Definition: qcustomplot.h:447
void SetYLower(double val)
Assigns the y-axis&#39; lower bound with a new value.
Definition: Graph.h:623
PlotData * SelectedPlotData_
Pointer to the plot data of a selected plot.
Definition: Graph.h:320
void wheelEvent(QWheelEvent *event)
Override the scroll wheel event.
Definition: Graph.h:946
void SetBoldfacedSelect(bool isBold)
Set if a plot will be boldfaced when selected.
Definition: Graph.h:797
Allows the drawing of a color from a list of presets.
Definition: ColorPicker.h:12
double GetXUpper() const
Returns the upper bound on the x-axis.
Definition: Graph.h:598
void replot()
Replot the graph area taking into account user interactions, such as zooming.
Definition: Graph.h:473
void SetXAxis(double lower, double upper)
Sets the full x-axis range that can be returned to at any time.
Definition: Graph.h:673
void AddPlots()
Adds a new graph item to the graph list.
Definition: Graph.h:715
void RegisterPlot(PlotData *plotData)
Stores new ranges, resets the plots, and stores new data into graph list.
Definition: Graph.h:702
QPoint Origin_
Point in the viewport that the user first clicks.
Definition: Graph.h:309
void keyReleaseEvent(QKeyEvent *event)
Override the key release event to handle special behavior.
Definition: Graph.h:961
a circle which is filled with the color of the pen (not the brush!)
Definition: qcustomplot.h:86
Handles the basic requirements for handling data and drawing said data to plots and curves...
Definition: Graph.h:27
void setName(const QString &name)
The name is the textual representation of this plottable as it is displayed in the QCPLegend of the p...
Definition: qcustomplot.cpp:8382
float DefaultPenWidth_
Stores the default pen width.
Definition: Graph.h:322
void SetXLower(double val)
Assigns the x-axis&#39; lower bound with a new value.
Definition: Graph.h:613
bool IsZoomed() const
Returns a state indicating if the viewport is zoomed or not.
Definition: Graph.h:545