//    tonalisa - software to look at overtone-structures
//    Copyright (C) 2016  Dominik Schmidt-Philipp
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program 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 General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
//
#ifndef SPIRAL_H
#define SPIRAL_H

#include <QtQuick/QQuickPaintedItem>
#include <QColor>
#include "frequencyview.h"

class Spiral : public FrequencyView
{
  Q_OBJECT
  Q_PROPERTY(float fBase READ fBase WRITE setFBase NOTIFY fBaseChanged)
  Q_PROPERTY(float octaves READ octaves WRITE setOctaves NOTIFY zoomChanged)
  
 public:
  Spiral(QQuickItem *parent = 0);

  float fBase() const;
  void setFBase(const float &fBase);

  float octaves() const;
  void setOctaves(const float &octaves);  
  virtual void setPointerFreq(const double &pointerFreq);
  virtual void setPointerAmp(const double &pointerAmp);
  void setGrid(const QList<double> &grid);
    
  void paint(QPainter *painter);

 signals:
  void fBaseChanged();
  void zoomChanged();
  
 private:
  void updatePointerPos();
  QList<double>m_partials;
  QList<double>m_grid; 

  double f_base;
  float m_octaves;

  virtual void calculateGrid();
  QList<double>m_gridData;
 
  void oscSendPeaks();
  
  void printSpiral(QPainter *painter);
  void printGrid(QPainter *painter);
  void printFFT(QPainter *painter);
  void printPeaks(QPainter *painter);
  QPointF freq2spiral(double freq, double amp=0.0);
  double scale();

};

#endif // SPIRALVIEW_H
