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 "rqt_multiplot/PlotAxesConfig.h" 00020 00021 namespace rqt_multiplot { 00022 00023 /*****************************************************************************/ 00024 /* Constructors and Destructor */ 00025 /*****************************************************************************/ 00026 00027 PlotAxesConfig::PlotAxesConfig(QObject* parent) : 00028 Config(parent) { 00029 axisConfig_[X] = new PlotAxisConfig(this); 00030 axisConfig_[Y] = new PlotAxisConfig(this); 00031 00032 connect(axisConfig_[X], SIGNAL(changed()), this, SLOT(axisConfigChanged())); 00033 connect(axisConfig_[Y], SIGNAL(changed()), this, SLOT(axisConfigChanged())); 00034 } 00035 00036 PlotAxesConfig::~PlotAxesConfig() { 00037 } 00038 00039 /*****************************************************************************/ 00040 /* Accessors */ 00041 /*****************************************************************************/ 00042 00043 PlotAxisConfig* PlotAxesConfig::getAxisConfig(Axis axis) const { 00044 QMap<Axis, PlotAxisConfig*>::const_iterator it = axisConfig_.find(axis); 00045 00046 if (it != axisConfig_.end()) 00047 return it.value(); 00048 else 00049 return 0; 00050 } 00051 00052 /*****************************************************************************/ 00053 /* Methods */ 00054 /*****************************************************************************/ 00055 00056 void PlotAxesConfig::save(QSettings& settings) const { 00057 settings.beginGroup("axes"); 00058 settings.beginGroup("x_axis"); 00059 axisConfig_[X]->save(settings); 00060 settings.endGroup(); 00061 settings.beginGroup("y_axis"); 00062 axisConfig_[Y]->save(settings); 00063 settings.endGroup(); 00064 settings.endGroup(); 00065 } 00066 00067 void PlotAxesConfig::load(QSettings& settings) { 00068 settings.beginGroup("axes"); 00069 settings.beginGroup("x_axis"); 00070 axisConfig_[X]->load(settings); 00071 settings.endGroup(); 00072 settings.beginGroup("y_axis"); 00073 axisConfig_[Y]->load(settings); 00074 settings.endGroup(); 00075 settings.endGroup(); 00076 } 00077 00078 void PlotAxesConfig::reset() { 00079 axisConfig_[X]->reset(); 00080 axisConfig_[Y]->reset(); 00081 } 00082 00083 void PlotAxesConfig::write(QDataStream& stream) const { 00084 axisConfig_[X]->write(stream); 00085 axisConfig_[Y]->write(stream); 00086 } 00087 00088 void PlotAxesConfig::read(QDataStream& stream) { 00089 axisConfig_[X]->read(stream); 00090 axisConfig_[Y]->read(stream); 00091 } 00092 00093 /*****************************************************************************/ 00094 /* Operators */ 00095 /*****************************************************************************/ 00096 00097 PlotAxesConfig& PlotAxesConfig::operator=(const PlotAxesConfig& src) { 00098 *axisConfig_[X] = *src.axisConfig_[X]; 00099 *axisConfig_[Y] = *src.axisConfig_[Y]; 00100 00101 return *this; 00102 } 00103 00104 /*****************************************************************************/ 00105 /* Slots */ 00106 /*****************************************************************************/ 00107 00108 void PlotAxesConfig::axisConfigChanged() { 00109 emit changed(); 00110 } 00111 00112 }