/*
    Copyright (C) 2012 Bartosz Broda, Jacek Bochenek, Łukasz Biłeńkij, 
    Damian Jaworski, Wojciech Mazur, Dominik Piasecki, Maciej Piasecki, 
    Radosław Ramocki
    
    This program 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 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 LICENSE and COPYING files for more details.
*/

#ifndef DENDROGRAMSCENE_H
#define DENDROGRAMSCENE_H

#include <QGraphicsScene>
#include "ui_mainwindow.h"
#include "node.h"

/**
  QGraphicsScene used to drawing dendrogram
  */
class DendrogramScene : public QGraphicsScene
{
    Q_OBJECT

public:
    DendrogramScene(Ui::MainWindow *ui, QObject *parent = 0);

    /**
      Draw tree on the scene using recursive traversing (DrawCluster method)
      */
    void DrawTree(size_t maxWidth);

    /**
      Set the root of current tree
      */
    void SetRoot(Node * root);

    /**
      Set min and max similarities
      */
    void SetSims(double min, double max);

private:

    /**
      Recursive function. Draws current node on the scene
      */
    void DrawCluster(Node * node);

    Ui::MainWindow *ui;

    /**
      Root of displayed tree
      */
    Node * root;

    /**
      Offset from the top of the scene, used by displaying leaves
      */
    size_t yoffset;

    /**
      Max width of the scene provided by QGraphicsView
      */
    size_t maxWidth;

    double minSim, maxSim;
};

#endif // DENDROGRAMSCENE_H
