Mercurial > hg > octave-lyh
changeset 13485:59d266f7ed89
Removed plotter tab.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Wed, 27 Apr 2011 14:21:28 +0200 |
parents | 3bfe83d853ca |
children | 68a13d4f6e15 |
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, 2 insertions(+), 382 deletions(-) [+] |
line wrap: on
line diff
--- a/gui//Quint.pro +++ b/gui//Quint.pro @@ -71,9 +71,7 @@ src/BrowserWidget.cpp \ src/NumberedCodeEdit.cpp \ src/SimpleEditor.cpp \ - src/ImageViewerMdiSubWindow.cpp \ - src/PlotterWidget.cpp \ - src/Plot2dWidget.cpp + src/ImageViewerMdiSubWindow.cpp HEADERS += \ src/TerminalCharacterDecoder.h \ @@ -112,7 +110,4 @@ src/BrowserWidget.h \ src/NumberedCodeEdit.h \ src/SimpleEditor.h \ - src/ImageViewerMdiSubWindow.h \ - src/PlotterWidget.h \ - src/Plot2dWidget.h - + src/ImageViewerMdiSubWindow.h
--- a/gui//src/MainWindow.cpp +++ b/gui//src/MainWindow.cpp @@ -125,11 +125,9 @@ 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 +++ b/gui//src/MainWindow.h @@ -32,7 +32,6 @@ #include "FilesDockWidget.h" #include "SimpleEditor.h" #include "BrowserWidget.h" -#include "PlotterWidget.h" // Octave includes #undef PACKAGE_BUGREPORT @@ -124,7 +123,6 @@ QToolBar *m_generalPurposeToolbar; BrowserWidget *m_browserWidget; BrowserWidget *m_serviceWidget; - PlotterWidget *m_plotterWidget; QString m_settingsFile; // Threads for running octave and managing the data interaction.
deleted file mode 100644 --- a/gui/src/Plot2dWidget.cpp +++ /dev/null @@ -1,232 +0,0 @@ -#include "Plot2dWidget.h" -#include <QVBoxLayout> -#include <QHBoxLayout> -#include <QPushButton> -#include <QTimer> -#include <QLabel> -#include <QColorDialog> -#include <math.h> - -Plot2dView::Plot2dView(QWidget *parent) - : QGLWidget(parent) { - construct(); -} - -void Plot2dView::construct() { - QTimer *animationTimer = new QTimer(this); - animationTimer->setInterval(20); - animationTimer->start(); - m_zoom = 1.0; - m_zoomAcceleration = 0.0; - m_scrollX = 0.0; - m_scrollY = 0.0; - m_leftMouseButtonDown = false; - setBackgroundColor(QColor(0, 0, 0)); - connect(animationTimer, SIGNAL(timeout()), this, SLOT(animate())); -} - -QColor Plot2dView::backgroundColor() { - return m_backgroundColor; -} - -void Plot2dView::setBackgroundColor(QColor color) { - m_backgroundColor = color; - glClearColor((double)color.red() / 255.0, - (double)color.green() / 255.0, - (double)color.blue() / 255.0, 0.0); - updateGL(); -} - -void Plot2dView::initializeGL() { - glClearColor(0.0,0.0, 0.0, 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() { - glMatrixMode(GL_MODELVIEW_MATRIX); - glLoadIdentity(); - glScaled(m_zoom * 1.5, m_zoom * 1.5, 0.0); - glTranslated(-0.5 - m_scrollX, -0.5 - m_scrollY, 0.0); - - glClear(GL_COLOR_BUFFER_BIT); - glBegin(GL_LINES); - glColor3d(1.0, 1.0, 1.0); - glVertex2d(0.0, 0.0); - glVertex2d(1.0, 0.0); - glVertex2d(0.0, 0.0); - glVertex2d(0.0, 1.0); - glEnd(); - - for(double phi = 0.0; phi < 2*3.141; phi += 2*3.141 / 3) { - glBegin(GL_LINES); - glColor3d(phi / (2 * 3.141), 1.0, 1.0 - phi / (2 * 3.141)); - for(double d = 0.0; d < 1.0; d +=0.01) - glVertex2d(d, sin(d*2*3.141 + phi) / 2 + 0.5); - glEnd(); - } - - glMatrixMode(GL_MODELVIEW_MATRIX); - glLoadIdentity(); - - glColor3d(1.0, 1.0, 1.0); - renderText(-0.9, -0.9, 0.0, QString("Scaling: %1%, Translation: (%2/%3)") - .arg(m_zoom * 100) - .arg(m_scrollX) - .arg(m_scrollY)); -} - -void Plot2dView::resizeGL(int w, int h) { - glViewport(0, 0, w, h); - glMatrixMode(GL_MODELVIEW_MATRIX); - glLoadIdentity(); - - glMatrixMode(GL_PROJECTION_MATRIX); - glLoadIdentity(); - glOrtho(-1.0, 1.0, -1.0, 1.0, 0.0, 100.0); -} - -void Plot2dView::wheelEvent(QWheelEvent *wheelEvent) { - m_zoomAcceleration += ((double)wheelEvent->delta()) / 1000; - wheelEvent->accept(); - updateGL(); -} - -void Plot2dView::mousePressEvent(QMouseEvent *mouseEvent) { - if(mouseEvent->button() == Qt::LeftButton) { - m_leftMouseButtonDown = true; - m_lastMouseButtonDownX = mouseEvent->x(); - m_lastMouseButtonDownY = mouseEvent->y(); - mouseEvent->accept(); - } -} - -void Plot2dView::mouseReleaseEvent(QMouseEvent *mouseEvent) { - if(mouseEvent->button() == Qt::LeftButton) { - m_leftMouseButtonDown = false; - mouseEvent->accept(); - } -} - -void Plot2dView::mouseMoveEvent(QMouseEvent *mouseEvent) { - if(m_leftMouseButtonDown) { - m_scrollX -= ((double)mouseEvent->x() - m_lastMouseButtonDownX) / (100 * m_zoom); - m_scrollY += ((double)mouseEvent->y() - m_lastMouseButtonDownY) / (100 * m_zoom); - m_lastMouseButtonDownX = (double)mouseEvent->x(); - m_lastMouseButtonDownY = (double)mouseEvent->y(); - } - updateGL(); -} - -void Plot2dView::animate() { - m_zoom += m_zoomAcceleration; - if(m_zoom < 0) - m_zoom = 0; - m_zoomAcceleration *= 0.5; - //if(abs(m_zoomAcceleration) < 0.001) - // m_zoomAcceleration = 0; - updateGL(); -} - -Plot2dWidget::Plot2dWidget(QWidget *parent) - : QWidget(parent) { - construct(); -} - -void Plot2dWidget::dataSourceTypeChanged(QString type) { - if(type == "Sampled") { - m_dataSourceStackedWidget->setCurrentIndex(0); - } else if(type == "Parameterized") { - m_dataSourceStackedWidget->setCurrentIndex(1); - } -} - -void Plot2dWidget::selectBackgroundColor() { - QColorDialog dialog(this); - dialog.setCurrentColor(m_plot2dView->backgroundColor()); - dialog.setOption(QColorDialog::NoButtons); - connect(&dialog, SIGNAL(currentColorChanged(QColor)), m_plot2dView, SLOT(setBackgroundColor(QColor))); - dialog.exec(); -} - -void Plot2dWidget::construct() { - QVBoxLayout *layout = new QVBoxLayout(); - m_plot2dView = new Plot2dView(this); - m_plot2dView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - layout->addWidget(m_plot2dView); - - m_tabWidget = new QTabWidget(this); - m_tabWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); - layout->addWidget(m_tabWidget); - - m_generalTab = new QWidget(this); - m_dataSourceTab = new QWidget(this); - m_seriesTab = new QWidget(this); - m_tabWidget->addTab(m_generalTab, tr("General")); - m_tabWidget->addTab(m_dataSourceTab, tr("Data Source")); - m_tabWidget->addTab(m_seriesTab, tr("Series")); - - // Build general tab. - QHBoxLayout *generalTabLayout = new QHBoxLayout(); - m_backgroundColorSelectionButton = new QPushButton(tr("Change"), this); - generalTabLayout->addWidget(new QLabel(tr("Background Color:"), this)); - generalTabLayout->addWidget(m_backgroundColorSelectionButton); - generalTabLayout->addStretch(); - m_generalTab->setLayout(generalTabLayout); - - // Build data source tab. - QHBoxLayout *dataSourceTabLayout = new QHBoxLayout(); - m_dataSourceTypeComboBox = new QComboBox(this); - m_dataSourceTypeComboBox->addItem(tr("Sampled")); - m_dataSourceTypeComboBox->addItem(tr("Parameterized")); - - m_dataSourceStackedWidget = new QStackedWidget(this); - m_sampledFromLineEdit = new QLineEdit("0", this); - m_sampledToLineEdit = new QLineEdit("4096", this); - m_parameterizedFromLineEdit = new QLineEdit("0.0", this); - m_parameterizedToLineEdit = new QLineEdit("1.0", this); - - m_sampledFromLineEdit->setAlignment(Qt::AlignRight); - m_sampledToLineEdit->setAlignment(Qt::AlignRight); - m_parameterizedFromLineEdit->setAlignment(Qt::AlignRight); - m_parameterizedToLineEdit->setAlignment(Qt::AlignRight); - - QWidget *sampledDataSourceRange = new QWidget(this); - QHBoxLayout *sampledDataSourceLayout = new QHBoxLayout(); - sampledDataSourceLayout->addWidget(new QLabel(tr("From sample"), this)); - sampledDataSourceLayout->addWidget(m_sampledFromLineEdit); - sampledDataSourceLayout->addWidget(new QLabel(tr("to sample"), this)); - sampledDataSourceLayout->addWidget(m_sampledToLineEdit); - sampledDataSourceLayout->addWidget(new QLabel(".", this)); - sampledDataSourceLayout->setMargin(0); - sampledDataSourceRange->setLayout(sampledDataSourceLayout); - - QWidget *parameterizedDataSourceRange = new QWidget(this); - QHBoxLayout *parameterizedDataSourceLayout = new QHBoxLayout(); - parameterizedDataSourceLayout->addWidget(new QLabel(tr("From value"), this)); - parameterizedDataSourceLayout->addWidget(m_parameterizedFromLineEdit); - parameterizedDataSourceLayout->addWidget(new QLabel(tr("to value"), this)); - parameterizedDataSourceLayout->addWidget(m_parameterizedToLineEdit); - parameterizedDataSourceLayout->addWidget(new QLabel(".", this)); - parameterizedDataSourceLayout->setMargin(0); - parameterizedDataSourceRange->setLayout(parameterizedDataSourceLayout); - - m_dataSourceStackedWidget->addWidget(sampledDataSourceRange); - m_dataSourceStackedWidget->addWidget(parameterizedDataSourceRange); - - m_refreshDataRangeButton = new QPushButton(tr("Refresh"), this); - dataSourceTabLayout->addWidget(new QLabel(tr("Type:"), this)); - dataSourceTabLayout->addWidget(m_dataSourceTypeComboBox); - dataSourceTabLayout->addWidget(m_dataSourceStackedWidget); - dataSourceTabLayout->addWidget(m_refreshDataRangeButton); - m_dataSourceTab->setLayout(dataSourceTabLayout); - - layout->setMargin(0); - setLayout(layout); - - connect(m_dataSourceTypeComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(dataSourceTypeChanged(QString))); - connect(m_backgroundColorSelectionButton, SIGNAL(clicked()), this, SLOT(selectBackgroundColor())); -}
deleted file mode 100644 --- a/gui/src/Plot2dWidget.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef PLOT2DWIDGET_H -#define PLOT2DWIDGET_H - -#include <QWidget> -#include <QGLWidget> -#include <QTabWidget> -#include <QStackedWidget> -#include <QComboBox> -#include <QWheelEvent> -#include <QMouseEvent> -#include <QLineEdit> -#include <QPushButton> -#include <QColor> - -class Plot2dView : public QGLWidget { - Q_OBJECT -public: - explicit Plot2dView(QWidget *parent = 0); - QColor backgroundColor(); - -public slots: - void setBackgroundColor(QColor color); - -protected: - void initializeGL(); - void paintGL(); - void resizeGL(int w, int h); - void wheelEvent(QWheelEvent *wheelEvent); - void mousePressEvent(QMouseEvent *mouseEvent); - void mouseReleaseEvent(QMouseEvent *mouseEvent); - void mouseMoveEvent(QMouseEvent *mouseEvent); - -private slots: - void animate(); - -private: - void construct(); - bool m_leftMouseButtonDown; - double m_lastMouseButtonDownX; - double m_lastMouseButtonDownY; - double m_scrollX; - double m_scrollY; - double m_zoom; - double m_zoomAcceleration; - QColor m_backgroundColor; -}; - -class Plot2dWidget : public QWidget -{ - Q_OBJECT -public: - explicit Plot2dWidget(QWidget *parent = 0); - -signals: - -public slots: - void dataSourceTypeChanged(QString type); - void selectBackgroundColor(); - -private: - void construct(); - - Plot2dView *m_plot2dView; - QTabWidget *m_tabWidget; - QWidget *m_generalTab; - QWidget *m_dataSourceTab; - QWidget *m_seriesTab; - QPushButton *m_backgroundColorSelectionButton; - QComboBox *m_dataSourceTypeComboBox; - QStackedWidget *m_dataSourceStackedWidget; - QLineEdit *m_sampledFromLineEdit; - QLineEdit *m_sampledToLineEdit; - QLineEdit *m_parameterizedFromLineEdit; - QLineEdit *m_parameterizedToLineEdit; - QPushButton *m_refreshDataRangeButton; -}; - -#endif // PLOT2DWIDGET_H
deleted file mode 100644 --- a/gui/src/PlotterWidget.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#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())); -}
deleted file mode 100644 --- a/gui/src/PlotterWidget.h +++ /dev/null @@ -1,20 +0,0 @@ -#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