Mercurial > hg > octave-lyh
changeset 13476:bf51c1bb7033
Changing background color is possible now.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Wed, 20 Apr 2011 12:35:21 +0200 |
parents | d65b8f5373b4 |
children | ca767e4055c5 |
files | gui/src/Plot2dWidget.cpp gui/src/Plot2dWidget.h |
diffstat | 2 files changed, 38 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/src/Plot2dWidget.cpp +++ b/gui/src/Plot2dWidget.cpp @@ -4,6 +4,7 @@ #include <QPushButton> #include <QTimer> #include <QLabel> +#include <QColorDialog> #include <math.h> Plot2dView::Plot2dView(QWidget *parent) @@ -20,9 +21,22 @@ 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); @@ -130,6 +144,14 @@ } } +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); @@ -142,15 +164,17 @@ m_generalTab = new QWidget(this); m_dataSourceTab = new QWidget(this); - m_verticalAxisTab = new QWidget(this); - m_horizontalAxisTab = 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_verticalAxisTab, tr("Vertical Axis")); - m_tabWidget->addTab(m_horizontalAxisTab, tr("Horizontal Axis")); + 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. @@ -204,4 +228,5 @@ setLayout(layout); connect(m_dataSourceTypeComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(dataSourceTypeChanged(QString))); + connect(m_backgroundColorSelectionButton, SIGNAL(clicked()), this, SLOT(selectBackgroundColor())); }
--- a/gui/src/Plot2dWidget.h +++ b/gui/src/Plot2dWidget.h @@ -10,11 +10,16 @@ #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(); @@ -37,6 +42,7 @@ double m_scrollY; double m_zoom; double m_zoomAcceleration; + QColor m_backgroundColor; }; class Plot2dWidget : public QWidget @@ -49,6 +55,7 @@ public slots: void dataSourceTypeChanged(QString type); + void selectBackgroundColor(); private: void construct(); @@ -57,8 +64,8 @@ QTabWidget *m_tabWidget; QWidget *m_generalTab; QWidget *m_dataSourceTab; - QWidget *m_verticalAxisTab; - QWidget *m_horizontalAxisTab; + QWidget *m_seriesTab; + QPushButton *m_backgroundColorSelectionButton; QComboBox *m_dataSourceTypeComboBox; QStackedWidget *m_dataSourceStackedWidget; QLineEdit *m_sampledFromLineEdit;