title_ = title;
tabwidget_ = tabwidget;
menu_ = menu;
//QScopedPointer<QwtPlot> axes_(new QwtPlot(title_));
axes_
= new QwtPlot(title_
);
// This is the pointer i cannot delete
graphdialog_ = new GraphDialog(title_);
xpicker_
= new QwtPicker(static_cast<QWidget
*>
(axes_
->axisWidget
(2)));
ypicker_
= new QwtPicker(static_cast<QWidget
*>
(axes_
->axisWidget
(0)));
windowaction_
= new QAction(title_,
this);
autoscaleaction_
= new QAction("Autoscale",
this);
gridaction_
= new QAction("Show grid",
this);
xaxislimitsaction_
= new QAction("Set x scale",
this);
yaxislimitsaction_
= new QAction("Set y scale",
this);
grid_->hide();
grid_->show();
tabwidget_->addTab(axes_, title_);
menu_->insertAction(0,autoscaleaction_);
menu_->insertAction(0,gridaction_);
graphdialog_->menu()->insertAction(0,autoscaleaction_);
graphdialog_->menu()->insertAction(0,gridaction_);
xpicker_->setStateMachine(pickermachine_);
xpicker_
->setTrackerMode
(QwtPicker::ActiveOnly);
ypicker_->setStateMachine(pickermachine_);
ypicker_
->setTrackerMode
(QwtPicker::ActiveOnly);
canvaspicker_->setStateMachine(pickermachine_);
canvaspicker_
->setTrackerMode
(QwtPicker::ActiveOnly);
graphsNum_ = 0;
QFont font
= axes_
->axisFont
(0);
font.setPointSize(8);
axes_->setAxisFont(0,font);
axes_->setAxisFont(1,font);
axes_->setAxisFont(2,font);
axes_->setAxisFont(3,font);
axes_->legend()->setFont(font);
font = axes_->titleLabel()->font();
font.setPointSize(12);
axes_->titleLabel()->setFont(font);
axes_->setAutoFillBackground(true);
axes_->setAutoDelete(false);
grid_
->setMajorPen
(QColor(Qt
::black),
0.5,Qt
::DashLine);
grid_->attach(axes_);
autoscaleaction_->setCheckable(true);
autoscaleaction_->setChecked(false);
gridaction_->setCheckable(true);
gridaction_->setChecked(true);
windowaction_->setCheckable(true);
windowaction_->setChecked(true);
connect(xpicker_,
SIGNAL(selected
(const QPolygon &)),
this,
SLOT(xAxisClicked
(QPolygon)));
connect(ypicker_,
SIGNAL(selected
(const QPolygon &)),
this,
SLOT(yAxisClicked
(QPolygon)));
connect(canvaspicker_,
SIGNAL(selected
(const QPolygon &)),
this,
SLOT(canvasClicked
(QPolygon)));
connect(windowaction_, SIGNAL(toggled(bool)), this, SLOT(setDocked(bool)));
connect(autoscaleaction_, SIGNAL(toggled(bool)), this, SLOT(setAutoscale(bool)));
connect(gridaction_, SIGNAL(toggled(bool)), this, SLOT(showGrid(bool)));
connect(xaxislimitsaction_, SIGNAL(triggered()), this, SLOT(xAxisClicked()));
connect(yaxislimitsaction_, SIGNAL(triggered()), this, SLOT(yAxisClicked()));
axes_
->axisWidget
(QwtPlot::xBottom)->setMinBorderDist
(0,
20);
axes_->plotLayout()->setAlignCanvasToScales(true);
xhistory_ = 30;
xmax_ = 0;
ymin_ = 1e10;
ymax_ = -1e10;
axes_->setContextMenuPolicy(Qt::CustomContextMenu);
connect(axes_,
SIGNAL(customContextMenuRequested
(QPoint)),
this,
SLOT(customContextMenuRequested
(QPoint)));
}
Axes::Axes(const QString& title, QTabWidget* tabwidget, QMenu* menu){
title_ = title;
tabwidget_ = tabwidget;
menu_ = menu;
//QScopedPointer<QwtPlot> axes_(new QwtPlot(title_));
axes_ = new QwtPlot(title_); // This is the pointer i cannot delete
graphdialog_ = new GraphDialog(title_);
xpicker_ = new QwtPicker(static_cast<QWidget*>(axes_->axisWidget(2)));
ypicker_ = new QwtPicker(static_cast<QWidget*>(axes_->axisWidget(0)));
canvaspicker_ = new QwtPlotPicker(axes_->canvas());
axes_->insertLegend(new QwtLegend());
windowaction_ = new QAction(title_, this);
autoscaleaction_ = new QAction("Autoscale", this);
gridaction_ = new QAction("Show grid", this);
xaxislimitsaction_ = new QAction("Set x scale", this);
yaxislimitsaction_ = new QAction("Set y scale", this);
grid_ = new QwtPlotGrid();
grid_->hide();
grid_->show();
tabwidget_->addTab(axes_, title_);
menu_->insertAction(0,autoscaleaction_);
menu_->insertAction(0,gridaction_);
graphdialog_->menu()->insertAction(0,autoscaleaction_);
graphdialog_->menu()->insertAction(0,gridaction_);
pickermachine_ = new QwtPickerClickPointMachine();
xpicker_->setStateMachine(pickermachine_);
xpicker_->setTrackerMode(QwtPicker::ActiveOnly);
ypicker_->setStateMachine(pickermachine_);
ypicker_->setTrackerMode(QwtPicker::ActiveOnly);
canvaspicker_->setStateMachine(pickermachine_);
canvaspicker_->setTrackerMode(QwtPicker::ActiveOnly);
graphsNum_ = 0;
QFont font = axes_->axisFont(0);
font.setPointSize(8);
axes_->setAxisFont(0,font);
axes_->setAxisFont(1,font);
axes_->setAxisFont(2,font);
axes_->setAxisFont(3,font);
axes_->legend()->setFont(font);
font = axes_->titleLabel()->font();
font.setPointSize(12);
axes_->titleLabel()->setFont(font);
axes_->setAutoFillBackground(true);
axes_->setAutoDelete(false);
grid_->setMajorPen(QColor(Qt::black),0.5,Qt::DashLine);
grid_->attach(axes_);
autoscaleaction_->setCheckable(true);
autoscaleaction_->setChecked(false);
gridaction_->setCheckable(true);
gridaction_->setChecked(true);
windowaction_->setCheckable(true);
windowaction_->setChecked(true);
connect(xpicker_, SIGNAL(selected(const QPolygon &)), this, SLOT(xAxisClicked(QPolygon)));
connect(ypicker_, SIGNAL(selected(const QPolygon &)), this, SLOT(yAxisClicked(QPolygon)));
connect(canvaspicker_, SIGNAL(selected(const QPolygon &)), this, SLOT(canvasClicked(QPolygon)));
connect(windowaction_, SIGNAL(toggled(bool)), this, SLOT(setDocked(bool)));
connect(autoscaleaction_, SIGNAL(toggled(bool)), this, SLOT(setAutoscale(bool)));
connect(gridaction_, SIGNAL(toggled(bool)), this, SLOT(showGrid(bool)));
connect(xaxislimitsaction_, SIGNAL(triggered()), this, SLOT(xAxisClicked()));
connect(yaxislimitsaction_, SIGNAL(triggered()), this, SLOT(yAxisClicked()));
axes_->axisWidget(QwtPlot::xBottom)->setMinBorderDist(0,20);
axes_->plotLayout()->setAlignCanvasToScales(true);
xhistory_ = 30;
xmax_ = 0;
ymin_ = 1e10;
ymax_ = -1e10;
axes_->setContextMenuPolicy(Qt::CustomContextMenu);
connect(axes_, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenuRequested(QPoint)));
}
To copy to clipboard, switch view to plain text mode
Bookmarks