/***************************************************************************
**
**  This file is part of SciFigs.
**
**  This library is free software; you can redistribute it and/or
**  modify it under the terms of the GNU Lesser General Public
**  License as published by the Free Software Foundation; either
**  version 2.1 of the License, or (at your option) any later version.
**
**  This file is distributed in the hope that it will be useful, but WITHOUT
**  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
**  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
**  License for more details.
**
**  You should have received a copy of the GNU Lesser General Public
**  License along with this library; if not, write to the Free Software
**  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
**
**  See http://www.geopsy.org for more information.
**
**  Created: 2005-11-08
**  Copyright: 2005-2019
**    Marc Wathelet
**    Marc Wathelet (LGIT, Grenoble, France)
**
***************************************************************************/

#ifndef XYVALUEPLOT_H
#define XYVALUEPLOT_H

#include "XYPlot.h"

namespace SciFigs {

class PaletteEditor;

class SCIFIGS_EXPORT XYValuePlot : public XYPlot
{
  Q_OBJECT
public:
  XYValuePlot(AxisWindow * parent=nullptr);
  ~XYValuePlot();

  virtual const QString& xml_tagName() const {return xmlXYValuePlotTag;}
  static const QString xmlXYValuePlotTag;

  const ColorMap& colorMap() const {return _colorMap;}
  void setLinearColorMap(double minVal, double maxVal);
  void setLogColorMap(double minVal, double maxVal);

  void setValues(QVector<double> * val);
  void valueRange(double& min, double& max) const;

  virtual bool hasProperties() {return true;}
  virtual void addProperties(PropertyProxy * pp);
  virtual void removeProperties(PropertyProxy * pp);
  virtual void properties(PropertyWidget * w) const;
  virtual void setProperty(uint wid, int pid, QVariant val);
public slots:
  void setColorMap(const ColorMap& pal);
signals:
  void colorMapChanged(const ColorMap& pal);
protected:
  QVector<double> * _values;
  ColorMap _colorMap;
  static uint _tabColorMap;

  virtual void paintData(const LayerPainterRequest& lp, QPainter& p, double dotpercm) const;
  virtual void xml_writeChildren(XML_WRITECHILDREN_ARGS) const;
  virtual XMLMember xml_member(XML_MEMBER_ARGS);
  virtual void xml_polishChild(XML_POLISHCHILD_ARGS);
  virtual void xml_writeBinaryData(XML_WRITEBINARYDATA_ARGS) const;
  virtual bool xml_setBinaryData(XML_SETBINARYDATA_ARGS);
};

} // namespace SciFigs

#endif // XYVALUEPLOT_H
