#ifndef TOPOLOGYDIMENSIONBAR_H
#define TOPOLOGYDIMENSIONBAR_H

#include <QtGui>
#include "OrderWidget.h"

class SliderPopup;
class ValuePopupSlider;

/**
  creates a button bar for topologies with more than tree dimensions
  view1: create ValuePopSlider widgets to select the dimensions to display
  view2: for topologies with 4-6 dimensions: merge 2 dimensions into one
  */
class TopologyDimensionBar : public QWidget
{
   Q_OBJECT
public:
   explicit TopologyDimensionBar(const std::vector<long> &dims, const std::vector<std::string> &dimnames, QWidget *parent = 0);

public slots:
   void selectedDimensionsChanged();

signals:
   void foldingDimensionsChanged(std::vector<std::vector<int> >);
   void selectedDimensionsChanged(std::vector<long>);

private slots:
   void foldingDimensionsChanged();
   void toggleMode();

private:
   std::vector<long> getValues();
   std::vector<long> dims_;
   std::vector<ValuePopupSlider *> sliders; // used for view 1
   OrderWidget *select; // view2 : merge
   QStackedLayout *modeSelection; // for > 3 dimensions: select view
};

/**
  creates a widget which displays an integer value or the text "all" if value < 0
  if the widget is clicked, a slider widget appears to change the value
  */
class ValuePopupSlider : public QWidget
{
   Q_OBJECT
public:
   /**
      @param label describes the value
      @param value the displayed value
      @param maximum the maximum value of the widget/slider
     */
   ValuePopupSlider(int value, int max);
   int value() const;

private slots:
   void showSlider();
   void setValue(int);

signals:
   void valueChanged(int);

private:
   int value_;
   int max_;
   QPushButton *push;
   SliderPopup *win;
   friend class TopologyDimensionBar;
};

/**
  part of ValuePopupSlider: a pop widget which contains a slider
  */
class SliderPopup : public QWidget
{
   Q_OBJECT
public:
   explicit SliderPopup(int min, int max, int value);
private:
   QSlider *slider_;
   friend class ValuePopupSlider;
};


#endif // TOPOLOGYDIMENSIONBAR_H
