///GraphWidget.cpp
#include "GraphWidget.hpp"
#include <qwt_legend.h>
#include <qwt_plot_layout.h>
GraphWidget
::GraphWidget(QWidget *parent
): dataPicker_(canvas())
{
//Setup data picker (polygon data filter)
dataPicker_.
setTrackerMode(QwtPicker::ActiveOnly);
dataPicker_.
setSelectionFlags(QwtPicker::PolygonSelection|QwtPicker
::CornerToCorner);
//| QwtPicker::DragSelection);//ClickSelection); dataPicker_.
setRubberBand(QwtPicker::PolygonRubberBand);
dataPicker_.
setRubberBandPen(QPen(QColor(255,
0,
0),
1, Qt
::DashLine));
}
GraphWidget::~GraphWidget()
{
}
///GraphWidget.hpp
#ifndef __GRAPHWIDGET_H__
#define __GRAPHWIDGET_H__
#include <qwt_plot.h>
#include <qwt_plot_grid.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_magnifier.h>
#include <qwt_plot_panner.h>
#include <qwt_symbol.h>
#include <qwt_plot_zoomer.h>
#include <qwt_plot_picker.h>
#include <qwt_polygon.h>
{
Q_OBJECT
public:
~GraphWidget();
private:
static const int penWidth = 0.5;
private:
};
#endif // GRAPHWIDGET_H
//MainWindow.cpp
#include "MainWindow.hpp"
#include <QFileDialog>
MainWindow
::MainWindow(QWidget *parent
):{
ui_.setupUi(this);
setWindowState(Qt::WindowMaximized);
setCentralWidget(&graph_);
}
MainWindow::~MainWindow()
{
}
//MainWindow.hpp
#ifndef __MAINWINDOW_HPP__
#define __MAINWINDOW_HPP__
#include "GraphWidget.hpp"
#include <QMainWindow>
#include <QButtonGroup>
#include <QVector>
#include <QPointF>
#include <QSettings>
#include "ui_MainWindow.h"
{
Q_OBJECT
public:
~MainWindow();
private:
Ui::MainWindowClass ui_;
GraphWidget graph_;
};
#endif // __MAINWINDOW_HPP__
//Main.cpp
#include <QMainWindow>
#include <QApplication>
#include <QSettings>
#include "windows.h"
#include "MainWindow.hpp"
void MessageHandler(QtMsgType type, const char *msg) {
DWORD dw;
LPVOID lpMsgBuf;
switch (type)
{
case QtFatalMsg:
fprintf(stderr, "Fatal: %s\n", msg);
dw = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
break;
}
}
int main(int argc, char** argv)
{
qInstallMsgHandler(MessageHandler);
MainWindow mainWindow;
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
mainWindow.show();
return app.exec();
}
///GraphWidget.cpp
#include "GraphWidget.hpp"
#include <qwt_legend.h>
#include <qwt_plot_layout.h>
GraphWidget::GraphWidget(QWidget *parent):
QwtPlot(parent),
dataPicker_(canvas())
{
//Setup data picker (polygon data filter)
dataPicker_.setTrackerMode(QwtPicker::ActiveOnly);
dataPicker_.setSelectionFlags(QwtPicker::PolygonSelection|QwtPicker::CornerToCorner);//| QwtPicker::DragSelection);//ClickSelection);
dataPicker_.setRubberBand(QwtPicker::PolygonRubberBand);
dataPicker_.setRubberBandPen(QPen(QColor(255, 0, 0), 1, Qt::DashLine));
}
GraphWidget::~GraphWidget()
{
}
///GraphWidget.hpp
#ifndef __GRAPHWIDGET_H__
#define __GRAPHWIDGET_H__
#include <qwt_plot.h>
#include <qwt_plot_grid.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_magnifier.h>
#include <qwt_plot_panner.h>
#include <qwt_symbol.h>
#include <qwt_plot_zoomer.h>
#include <qwt_plot_picker.h>
#include <qwt_polygon.h>
class GraphWidget : public QwtPlot
{
Q_OBJECT
public:
GraphWidget(QWidget *parent = 0);
~GraphWidget();
private:
static const int penWidth = 0.5;
private:
QwtPlotPicker dataPicker_;
};
#endif // GRAPHWIDGET_H
//MainWindow.cpp
#include "MainWindow.hpp"
#include <QFileDialog>
MainWindow::MainWindow(QWidget *parent):
QMainWindow(parent)
{
ui_.setupUi(this);
setWindowState(Qt::WindowMaximized);
setCentralWidget(&graph_);
}
MainWindow::~MainWindow()
{
}
//MainWindow.hpp
#ifndef __MAINWINDOW_HPP__
#define __MAINWINDOW_HPP__
#include "GraphWidget.hpp"
#include <QMainWindow>
#include <QButtonGroup>
#include <QVector>
#include <QPointF>
#include <QSettings>
#include "ui_MainWindow.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindowClass ui_;
GraphWidget graph_;
};
#endif // __MAINWINDOW_HPP__
//Main.cpp
#include <QMainWindow>
#include <QApplication>
#include <QSettings>
#include "windows.h"
#include "MainWindow.hpp"
void MessageHandler(QtMsgType type, const char *msg) {
DWORD dw;
LPVOID lpMsgBuf;
switch (type)
{
case QtFatalMsg:
fprintf(stderr, "Fatal: %s\n", msg);
dw = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
break;
}
}
int main(int argc, char** argv)
{
qInstallMsgHandler(MessageHandler);
QApplication app(argc, argv);
MainWindow mainWindow;
QCoreApplication::setOrganizationName("CEA");
QCoreApplication::setOrganizationDomain("cea.com.au");
QCoreApplication::setApplicationName("TVE Analysis Program");
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
mainWindow.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks