CurveStyleConfigWidget.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002  * Copyright (C) 2015 by Ralf Kaestner                                        *
00003  * ralf.kaestner@gmail.com                                                    *
00004  *                                                                            *
00005  * This program is free software; you can redistribute it and/or modify       *
00006  * it under the terms of the Lesser GNU General Public License as published by*
00007  * the Free Software Foundation; either version 3 of the License, or          *
00008  * (at your option) any later version.                                        *
00009  *                                                                            *
00010  * This program is distributed in the hope that it will be useful,            *
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the               *
00013  * Lesser GNU General Public License for more details.                        *
00014  *                                                                            *
00015  * You should have received a copy of the Lesser GNU General Public License   *
00016  * along with this program. If not, see <http://www.gnu.org/licenses/>.       *
00017  ******************************************************************************/
00018 
00019 #include <QDoubleValidator>
00020 
00021 #include <ui_CurveStyleConfigWidget.h>
00022 
00023 #include "rqt_multiplot/CurveStyleConfigWidget.h"
00024 
00025 namespace rqt_multiplot {
00026 
00027 /*****************************************************************************/
00028 /* Constructors and Destructor                                               */
00029 /*****************************************************************************/
00030 
00031 CurveStyleConfigWidget::CurveStyleConfigWidget(QWidget* parent) :
00032   QWidget(parent),
00033   ui_(new Ui::CurveStyleConfigWidget()),
00034   buttonGroupSticksOrientation_(new QButtonGroup(this)),
00035   config_(0) {
00036   ui_->setupUi(this);
00037   
00038   ui_->lineEditSticksBaseline->setValidator(new QDoubleValidator(
00039     ui_->lineEditSticksBaseline));
00040   
00041   ui_->checkBoxLinesInterpolate->setEnabled(false);
00042   ui_->radioButtonSticksOrientationHorizontal->setEnabled(false);
00043   ui_->radioButtonSticksOrientationVertical->setEnabled(false);
00044   ui_->labelSticksBaseline->setEnabled(false);
00045   ui_->lineEditSticksBaseline->setEnabled(false);
00046   ui_->checkBoxStepsInvert->setEnabled(false);
00047   
00048   buttonGroupSticksOrientation_->addButton(
00049     ui_->radioButtonSticksOrientationHorizontal);
00050   buttonGroupSticksOrientation_->addButton(
00051     ui_->radioButtonSticksOrientationVertical);
00052   
00053   connect(ui_->radioButtonLines, SIGNAL(toggled(bool)), this,
00054     SLOT(radioButtonLinesToggled(bool)));
00055   connect(ui_->radioButtonSticks, SIGNAL(toggled(bool)), this,
00056     SLOT(radioButtonSticksToggled(bool)));
00057   connect(ui_->radioButtonSteps, SIGNAL(toggled(bool)), this,
00058     SLOT(radioButtonStepsToggled(bool)));
00059   connect(ui_->radioButtonPoints, SIGNAL(toggled(bool)), this,
00060     SLOT(radioButtonPointsToggled(bool)));
00061   
00062   connect(ui_->checkBoxLinesInterpolate, SIGNAL(stateChanged(int)),
00063     this, SLOT(checkBoxLinesInterpolateStateChanged(int)));
00064   connect(ui_->radioButtonSticksOrientationHorizontal, SIGNAL(toggled(bool)),
00065     this, SLOT(radioButtonSticksOrientationHorizontalToggled(bool)));
00066   connect(ui_->radioButtonSticksOrientationVertical, SIGNAL(toggled(bool)),
00067     this, SLOT(radioButtonSticksOrientationVerticalToggled(bool)));
00068   connect(ui_->lineEditSticksBaseline, SIGNAL(editingFinished()),
00069     this, SLOT(lineEditSticksBaselineEditingFinished()));  
00070   connect(ui_->checkBoxStepsInvert, SIGNAL(stateChanged(int)),
00071     this, SLOT(checkBoxStepsInvertStateChanged(int)));
00072   
00073   connect(ui_->spinBoxPenWidth, SIGNAL(valueChanged(int)),
00074     this, SLOT(spinBoxPenWidthValueChanged(int)));
00075   connect(ui_->comboBoxPenStyle, SIGNAL(currentStyleChanged(int)),
00076     this, SLOT(comboBoxPenStyleCurrentStyleChanged(int)));
00077   connect(ui_->checkBoxRenderAntialias, SIGNAL(stateChanged(int)),
00078     this, SLOT(checkBoxRenderAntialiasStateChanged(int)));
00079 }
00080 
00081 CurveStyleConfigWidget::~CurveStyleConfigWidget() {
00082   delete ui_;
00083 }
00084 
00085 /*****************************************************************************/
00086 /* Accessors                                                                 */
00087 /*****************************************************************************/
00088 
00089 void CurveStyleConfigWidget::setConfig(CurveStyleConfig* config) {
00090   if (config != config_) {
00091     if (config_) {
00092       disconnect(config_, SIGNAL(typeChanged(int)), this,
00093         SLOT(styleTypeChanged(int)));
00094       
00095       disconnect(config_, SIGNAL(linesInterpolateChanged(bool)),
00096         this, SLOT(configLinesInterpolateChanged(bool)));
00097       disconnect(config_, SIGNAL(sticksOrientationChanged(int)),
00098         this, SLOT(configSticksOrientationChanged(int)));
00099       disconnect(config_, SIGNAL(sticksBaselineChanged(double)),
00100         this, SLOT(configSticksBaselineChanged(double)));
00101       disconnect(config_, SIGNAL(stepsInvertChanged(bool)),
00102         this, SLOT(configStepsInvertChanged(bool)));
00103       
00104       disconnect(config_, SIGNAL(penWidthChanged(size_t)),
00105         this, SLOT(configPenWidthChanged(size_t)));
00106       disconnect(config_, SIGNAL(penStyleChanged(int)),
00107         this, SLOT(configPenStyleChanged(int)));
00108       disconnect(config_, SIGNAL(renderAntialiasChanged(bool)),
00109         this, SLOT(configRenderAntialiasChanged(bool)));
00110     }
00111     
00112     config_ = config;
00113     
00114     if (config) {
00115       connect(config, SIGNAL(typeChanged(int)), this,
00116         SLOT(configTypeChanged(int)));
00117       
00118       connect(config, SIGNAL(linesInterpolateChanged(bool)),
00119         this, SLOT(configLinesInterpolateChanged(bool)));
00120       connect(config, SIGNAL(sticksOrientationChanged(int)),
00121         this, SLOT(configSticksOrientationChanged(int)));
00122       connect(config, SIGNAL(sticksBaselineChanged(double)),
00123         this, SLOT(configSticksBaselineChanged(double)));
00124       connect(config, SIGNAL(stepsInvertChanged(bool)),
00125         this, SLOT(configStepsInvertChanged(bool)));
00126       
00127       connect(config, SIGNAL(penWidthChanged(size_t)),
00128         this, SLOT(configPenWidthChanged(size_t)));
00129       connect(config, SIGNAL(penStyleChanged(int)),
00130         this, SLOT(configPenStyleChanged(int)));
00131       connect(config, SIGNAL(renderAntialiasChanged(bool)),
00132         this, SLOT(configRenderAntialiasChanged(bool)));
00133       
00134       configTypeChanged(config->getType());
00135       
00136       configLinesInterpolateChanged(config->areLinesInterpolated());
00137       configSticksOrientationChanged(config->getSticksOrientation());
00138       configSticksBaselineChanged(config->getSticksBaseline());
00139       configStepsInvertChanged(config->areStepsInverted());
00140       
00141       configPenWidthChanged(config->getPenWidth());
00142       configPenStyleChanged(config->getPenStyle());
00143       configRenderAntialiasChanged(config->isRenderAntialiased());
00144     }
00145   }
00146 }
00147 
00148 CurveStyleConfig* CurveStyleConfigWidget::getConfig() const {
00149   return config_;
00150 }
00151  
00152 /*****************************************************************************/
00153 /* Slots                                                                     */
00154 /*****************************************************************************/
00155 
00156 void CurveStyleConfigWidget::configTypeChanged(int type) {
00157   if (type == CurveStyleConfig::Sticks)
00158     ui_->radioButtonSticks->setChecked(true);
00159   else if (type == CurveStyleConfig::Steps)
00160     ui_->radioButtonSteps->setChecked(true);
00161   else if (type == CurveStyleConfig::Points)
00162     ui_->radioButtonPoints->setChecked(true);
00163   else
00164     ui_->radioButtonLines->setChecked(true);
00165 }
00166 
00167 void CurveStyleConfigWidget::configLinesInterpolateChanged(bool interpolate) {
00168   ui_->checkBoxLinesInterpolate->setCheckState(interpolate ? Qt::Checked :
00169     Qt::Unchecked);
00170 }
00171 
00172 void CurveStyleConfigWidget::configSticksOrientationChanged(int orientation) {
00173   ui_->radioButtonSticksOrientationHorizontal->setChecked(
00174     orientation == Qt::Horizontal);
00175   ui_->radioButtonSticksOrientationVertical->setChecked(
00176     orientation == Qt::Vertical);
00177 }
00178 
00179 void CurveStyleConfigWidget::configSticksBaselineChanged(double baseline) {
00180   ui_->lineEditSticksBaseline->setText(QString::number(baseline));
00181 }
00182 
00183 void CurveStyleConfigWidget::configStepsInvertChanged(bool invert) {
00184   ui_->checkBoxStepsInvert->setCheckState(invert ? Qt::Checked :
00185     Qt::Unchecked);
00186 }
00187 
00188 void CurveStyleConfigWidget::configPenWidthChanged(size_t width) {
00189   ui_->spinBoxPenWidth->setValue(width);
00190 }
00191 
00192 void CurveStyleConfigWidget::configPenStyleChanged(int style) {
00193   ui_->comboBoxPenStyle->setCurrentStyle(static_cast<Qt::PenStyle>(style));
00194 }
00195 
00196 void CurveStyleConfigWidget::configRenderAntialiasChanged(bool antialias) {
00197   ui_->checkBoxRenderAntialias->setCheckState(antialias ? Qt::Checked :
00198     Qt::Unchecked);
00199 }
00200 
00201 void CurveStyleConfigWidget::radioButtonLinesToggled(bool checked) {
00202   ui_->checkBoxLinesInterpolate->setEnabled(checked);
00203   
00204   if (config_ && checked)
00205     config_->setType(CurveStyleConfig::Lines);
00206 }
00207 
00208 void CurveStyleConfigWidget::radioButtonSticksToggled(bool checked) {
00209   ui_->radioButtonSticksOrientationHorizontal->setEnabled(checked);
00210   ui_->radioButtonSticksOrientationVertical->setEnabled(checked);
00211   ui_->labelSticksBaseline->setEnabled(checked);
00212   ui_->lineEditSticksBaseline->setEnabled(checked);
00213   
00214   if (config_ && checked)
00215     config_->setType(CurveStyleConfig::Sticks);
00216 }
00217 
00218 void CurveStyleConfigWidget::radioButtonStepsToggled(bool checked) {
00219   ui_->checkBoxStepsInvert->setEnabled(checked);
00220   
00221   if (config_ && checked)
00222     config_->setType(CurveStyleConfig::Steps);
00223 }
00224 
00225 void CurveStyleConfigWidget::radioButtonPointsToggled(bool checked) {
00226   if (config_ && checked)
00227     config_->setType(CurveStyleConfig::Points);
00228 }
00229 
00230 void CurveStyleConfigWidget::checkBoxLinesInterpolateStateChanged(int state) {
00231   if (config_)
00232     config_->setLinesInterpolate(state == Qt::Checked);
00233 }
00234 
00235 void CurveStyleConfigWidget::radioButtonSticksOrientationHorizontalToggled(
00236     bool checked) {
00237   if (config_ && checked)
00238     config_->setSticksOrientation(Qt::Horizontal);
00239 }
00240 
00241 void CurveStyleConfigWidget::radioButtonSticksOrientationVerticalToggled(
00242     bool checked) {
00243   if (config_ && checked)
00244     config_->setSticksOrientation(Qt::Vertical);
00245 }
00246 
00247 void CurveStyleConfigWidget::lineEditSticksBaselineEditingFinished() {
00248   if (config_)
00249     config_->setSticksBaseline(ui_->lineEditSticksBaseline->text().
00250       toDouble());
00251 }
00252 
00253 void CurveStyleConfigWidget::checkBoxStepsInvertStateChanged(int state) {
00254   if (config_)
00255     config_->setStepsInvert(state == Qt::Checked);
00256 }
00257 
00258 void CurveStyleConfigWidget::spinBoxPenWidthValueChanged(int value) {
00259   if (config_)
00260     config_->setPenWidth(value);
00261 }
00262 
00263 void CurveStyleConfigWidget::comboBoxPenStyleCurrentStyleChanged(int style) {
00264   if (config_)
00265     config_->setPenStyle(static_cast<Qt::PenStyle>(style));
00266 }
00267 
00268 void CurveStyleConfigWidget::checkBoxRenderAntialiasStateChanged(int state) {
00269   if (config_)
00270     config_->setRenderAntialias(state == Qt::Checked);
00271 }
00272 
00273 }


rqt_multiplot
Author(s): Ralf Kaestner
autogenerated on Tue May 9 2017 02:16:02