# HG changeset patch # User Jacob Dawid # Date 1303295721 -7200 # Node ID bf51c1bb70330adfafc0f5b33c8bac6ce7ab4795 # Parent d65b8f5373b4617568e2c9f65d14ed068590a6f3 Changing background color is possible now. diff --git a/gui/src/Plot2dWidget.cpp b/gui/src/Plot2dWidget.cpp --- a/gui/src/Plot2dWidget.cpp +++ b/gui/src/Plot2dWidget.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include 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())); } diff --git a/gui/src/Plot2dWidget.h b/gui/src/Plot2dWidget.h --- a/gui/src/Plot2dWidget.h +++ b/gui/src/Plot2dWidget.h @@ -10,11 +10,16 @@ #include #include #include +#include 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;