Mercurial > octave-libtiff
changeset 13469:a20f8763105f
Added some OpenGL plotting.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Mon, 18 Apr 2011 22:58:41 +0200 |
parents | 519ae5ea6bd4 |
children | f7356554594c |
files | gui//Quint.pro gui//src/MainWindow.cpp gui//src/MainWindow.h gui/src/Plot2dWidget.cpp gui/src/Plot2dWidget.h gui/src/PlotterWidget.cpp gui/src/PlotterWidget.h |
diffstat | 7 files changed, 188 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/gui//Quint.pro Mon Apr 18 00:14:40 2011 +0200 +++ b/gui//Quint.pro Mon Apr 18 22:58:41 2011 +0200 @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += core gui webkit xml +QT += core gui webkit xml opengl UI_DIR = ui-files MOC_DIR = moc-files OBJECTS_DIR = object-files @@ -45,7 +45,9 @@ src/BrowserWidget.cpp \ src/NumberedCodeEdit.cpp \ src/SimpleEditor.cpp \ - src/ImageViewerMdiSubWindow.cpp + src/ImageViewerMdiSubWindow.cpp \ + src/PlotterWidget.cpp \ + src/Plot2dWidget.cpp HEADERS += \ src/TerminalCharacterDecoder.h \ @@ -84,7 +86,9 @@ src/BrowserWidget.h \ src/NumberedCodeEdit.h \ src/SimpleEditor.h \ - src/ImageViewerMdiSubWindow.h + src/ImageViewerMdiSubWindow.h \ + src/PlotterWidget.h \ + src/Plot2dWidget.h INCFLAGS = -g3 $$system(mkoctfile -p INCFLAGS) LFLAGS = $$system(mkoctfile -p LFLAGS) \
--- a/gui//src/MainWindow.cpp Mon Apr 18 00:14:40 2011 +0200 +++ b/gui//src/MainWindow.cpp Mon Apr 18 22:58:41 2011 +0200 @@ -86,6 +86,7 @@ void MainWindow::handleCommandDoubleClicked(QString command) { m_octaveTerminal->sendText(command); + m_centralTabWidget->setCurrentWidget(m_octaveTerminal); m_octaveTerminal->setFocus(); } @@ -124,9 +125,11 @@ m_statusBar = new QStatusBar(this); m_browserWidget = new BrowserWidget(this); m_serviceWidget = new BrowserWidget(this); + m_plotterWidget = new PlotterWidget(this); m_centralTabWidget = new QTabWidget(this); m_centralTabWidget->addTab(m_octaveTerminal, tr("Command Window")); m_centralTabWidget->addTab(m_openedFiles, tr("File Editor")); + m_centralTabWidget->addTab(m_plotterWidget, tr("Plotter")); m_centralTabWidget->addTab(m_browserWidget, tr("Documentation")); m_centralTabWidget->addTab(m_serviceWidget, tr("Service"));
--- a/gui//src/MainWindow.h Mon Apr 18 00:14:40 2011 +0200 +++ b/gui//src/MainWindow.h Mon Apr 18 22:58:41 2011 +0200 @@ -32,6 +32,7 @@ #include "FilesDockWidget.h" #include "SimpleEditor.h" #include "BrowserWidget.h" +#include "PlotterWidget.h" // Octave includes #undef PACKAGE_BUGREPORT @@ -123,6 +124,7 @@ QToolBar *m_generalPurposeToolbar; BrowserWidget *m_browserWidget; BrowserWidget *m_serviceWidget; + PlotterWidget *m_plotterWidget; QString m_settingsFile; // Threads for running octave and managing the data interaction.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/Plot2dWidget.cpp Mon Apr 18 22:58:41 2011 +0200 @@ -0,0 +1,79 @@ +#include "Plot2dWidget.h" +#include <QVBoxLayout> +#include <QHBoxLayout> +#include <QPushButton> + +Plot2dView::Plot2dView(QWidget *parent) + : QGLWidget(parent) { + construct(); +} + +void Plot2dView::construct() { +} + +void Plot2dView::initializeGL() { + glClearColor(0.9, 0.9, 0.9, 0.0); + glEnable(GL_POINT_SMOOTH); + // glEnable(GL_LINE_SMOOTH); + glEnable(GL_POLYGON_SMOOTH); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); +} + +void Plot2dView::paintGL() { + glClear(GL_COLOR_BUFFER_BIT); + glBegin(GL_LINES); + glColor3d(0.0, 0.0, 0.0); + glVertex2d(0.1, 0.1); + glVertex2d(0.9, 0.1); + glVertex2d(0.1, 0.1); + glVertex2d(0.1, 0.9); + glEnd(); + + glBegin(GL_POLYGON); + glVertex2d(0.092, 0.9); + glVertex2d(0.108, 0.9); + glVertex2d(0.1, 0.93); + glEnd(); + glBegin(GL_POLYGON); + glVertex2d(0.9, 0.092); + glVertex2d(0.9, 0.108); + glVertex2d(0.93, 0.1); + glEnd(); + + renderText(0.8, 0.05, 0.0, "axis"); +} + +void Plot2dView::resizeGL(int w, int h) { + glViewport(0, 0, w, h); + glMatrixMode(GL_MODELVIEW_MATRIX); + glLoadIdentity(); + + glMatrixMode(GL_PROJECTION_MATRIX); + glLoadIdentity(); + glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 100.0); +} + +Plot2dWidget::Plot2dWidget(QWidget *parent) : + QWidget(parent) { + construct(); +} + +void Plot2dWidget::construct() { + QVBoxLayout *layout = new QVBoxLayout(); + m_plot2dView = new Plot2dView(this); + m_plot2dView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + layout->addWidget(m_plot2dView); + QWidget *buttonBar = new QWidget(this); + QHBoxLayout *buttonBarLayout = new QHBoxLayout(this); + QPushButton *exportButton = new QPushButton(tr("Export"), this); + exportButton->setEnabled(false); + buttonBarLayout->addWidget(exportButton); + buttonBarLayout->addStretch(); + buttonBarLayout->setMargin(1); + buttonBar->setLayout(buttonBarLayout); + buttonBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); + layout->addWidget(buttonBar); + layout->setMargin(0); + setLayout(layout); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/Plot2dWidget.h Mon Apr 18 22:58:41 2011 +0200 @@ -0,0 +1,36 @@ +#ifndef PLOT2DWIDGET_H +#define PLOT2DWIDGET_H + +#include <QWidget> +#include <QGLWidget> + +class Plot2dView : public QGLWidget { +public: + explicit Plot2dView(QWidget *parent = 0); + +protected: + void initializeGL(); + void paintGL(); + void resizeGL(int w, int h); + +private: + void construct(); +}; + +class Plot2dWidget : public QWidget +{ + Q_OBJECT +public: + explicit Plot2dWidget(QWidget *parent = 0); + +signals: + +public slots: + +private: + void construct(); + + Plot2dView *m_plot2dView; +}; + +#endif // PLOT2DWIDGET_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/PlotterWidget.cpp Mon Apr 18 22:58:41 2011 +0200 @@ -0,0 +1,41 @@ +#include "PlotterWidget.h" +#include "Plot2dWidget.h" +#include <QVBoxLayout> +#include <QHBoxLayout> +#include <QPushButton> +#include <QMdiSubWindow> + +PlotterWidget::PlotterWidget(QWidget *parent) + : QWidget(parent) { + construct(); +} + +void PlotterWidget::addNew2dPlot() { + QMdiSubWindow *mdiSubWindow = new QMdiSubWindow(this); + mdiSubWindow->setWidget(new Plot2dWidget(this)); + mdiSubWindow->setWindowTitle("2d Plot"); + m_mdiArea->addSubWindow(mdiSubWindow); + mdiSubWindow->resize(400, 300); + mdiSubWindow->showMaximized(); +} + +void PlotterWidget::construct() { + QVBoxLayout *layout = new QVBoxLayout(); + m_mdiArea = new QMdiArea(this); + layout->addWidget(m_mdiArea); + QWidget *buttonBar = new QWidget(this); + QHBoxLayout *buttonBarLayout = new QHBoxLayout(this); + QPushButton *createPlot2dButton = new QPushButton(tr("Create 2d Plot"), this); + QPushButton *createPlot3dButton = new QPushButton(tr("Create 3d Plot"), this); + createPlot3dButton->setEnabled(false); + buttonBarLayout->addWidget(createPlot2dButton); + buttonBarLayout->addWidget(createPlot3dButton); + buttonBarLayout->addStretch(); + buttonBarLayout->setMargin(1); + buttonBar->setLayout(buttonBarLayout); + layout->addWidget(buttonBar); + layout->setMargin(0); + setLayout(layout); + + connect(createPlot2dButton, SIGNAL(clicked()), this, SLOT(addNew2dPlot())); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/PlotterWidget.h Mon Apr 18 22:58:41 2011 +0200 @@ -0,0 +1,20 @@ +#ifndef PLOTTERWIDGET_H +#define PLOTTERWIDGET_H + +#include <QWidget> +#include <QMdiArea> + +class PlotterWidget : public QWidget { + Q_OBJECT +public: + PlotterWidget(QWidget *parent = 0); + +public slots: + void addNew2dPlot(); + +private: + void construct(); + QMdiArea *m_mdiArea; +}; + +#endif // PLOTTERWIDGET_H