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/PlotLegendConfig.h" 00020 00021 namespace rqt_multiplot { 00022 00023 /*****************************************************************************/ 00024 /* Constructors and Destructor */ 00025 /*****************************************************************************/ 00026 00027 PlotLegendConfig::PlotLegendConfig(QObject* parent, bool visible) : 00028 Config(parent), 00029 visible_(visible) { 00030 } 00031 00032 PlotLegendConfig::~PlotLegendConfig() { 00033 } 00034 00035 /*****************************************************************************/ 00036 /* Accessors */ 00037 /*****************************************************************************/ 00038 00039 void PlotLegendConfig::setVisible(bool visible) { 00040 if (visible != visible_) { 00041 visible_ = visible; 00042 00043 emit visibleChanged(visible); 00044 emit changed(); 00045 } 00046 } 00047 00048 bool PlotLegendConfig::isVisible() const { 00049 return visible_; 00050 } 00051 00052 /*****************************************************************************/ 00053 /* Methods */ 00054 /*****************************************************************************/ 00055 00056 void PlotLegendConfig::save(QSettings& settings) const { 00057 settings.setValue("visible", visible_); 00058 } 00059 00060 void PlotLegendConfig::load(QSettings& settings) { 00061 setVisible(settings.value("visible", true).toBool()); 00062 } 00063 00064 void PlotLegendConfig::reset() { 00065 setVisible(true); 00066 } 00067 00068 void PlotLegendConfig::write(QDataStream& stream) const { 00069 stream << visible_; 00070 } 00071 00072 void PlotLegendConfig::read(QDataStream& stream) { 00073 bool visible; 00074 00075 stream >> visible; 00076 setVisible(visible); 00077 } 00078 00079 /*****************************************************************************/ 00080 /* Operators */ 00081 /*****************************************************************************/ 00082 00083 PlotLegendConfig& PlotLegendConfig::operator=(const PlotLegendConfig& src) { 00084 setVisible(src.visible_); 00085 00086 return *this; 00087 } 00088 00089 }