File indexing completed on 2024-03-24 15:13:32

0001 
0002 /*************************************************************************************
0003  *  Copyright (C) 2007-2011 by Aleix Pol <aleixpol@kde.org>                          *
0004  *  Copyright (C) 2010-2012 by Percy Camilo T. Aucahuasi <percy.camilo.ta@gmail.com> *
0005  *                                                                                   *
0006  *  This program is free software; you can redistribute it and/or                    *
0007  *  modify it under the terms of the GNU General Public License                      *
0008  *  as published by the Free Software Foundation; either version 2                   *
0009  *  of the License, or (at your option) any later version.                           *
0010  *                                                                                   *
0011  *  This program is distributed in the hope that it will be useful,                  *
0012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   *
0013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    *
0014  *  GNU General Public License for more details.                                     *
0015  *                                                                                   *
0016  *  You should have received a copy of the GNU General Public License                *
0017  *  along with this program; if not, write to the Free Software                      *
0018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   *
0019  *************************************************************************************/
0020 
0021 #include "plotitem.h"
0022 #include "plotsmodel.h"
0023 
0024 using namespace Analitza;
0025 
0026 PlotItem::PlotItem(const QString &n, const QColor& col)
0027     : m_name(n)
0028     , m_color(col)
0029     , m_graphVisible(true)
0030     , m_model(nullptr)
0031 {}
0032 
0033 PlotItem::~PlotItem()
0034 {}
0035 
0036 void PlotItem::emitDataChanged()
0037 {
0038     if (m_model) {
0039         m_model->emitChanged(this);
0040     }
0041 }
0042 
0043 void PlotItem::setModel(PlotsModel* m)
0044 {
0045     Q_ASSERT(m);
0046     Q_ASSERT(m != m_model);
0047     
0048     m_model = m;
0049 }
0050 
0051 void PlotItem::setColor(const QColor& newColor)
0052 { 
0053     m_color = newColor; 
0054     emitDataChanged(); 
0055 }
0056 
0057 void PlotItem::setName(const QString& newName)
0058 {
0059     m_name = newName;
0060     emitDataChanged();
0061 }
0062 
0063 void PlotItem::setVisible(bool v)
0064 {
0065     m_graphVisible = v;
0066     emitDataChanged();
0067 }
0068 
0069 void PlotItem::addTags(const QSet<QString>& tag)
0070 {
0071     m_tags += tag;
0072 }
0073 
0074 void PlotItem::clearTags()
0075 {
0076     m_tags.clear();
0077 }
0078 
0079 QSet<QString> PlotItem::tags() const
0080 {
0081     return m_tags;
0082 }