File: ParallelCoordsAxisSliders.h

package info (click to toggle)
tulip 6.0.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 196,224 kB
  • sloc: cpp: 571,851; ansic: 13,983; python: 4,105; sh: 1,555; yacc: 522; xml: 484; makefile: 168; pascal: 148; lex: 55
file content (123 lines) | stat: -rw-r--r-- 3,678 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
 *
 * This file is part of Tulip (https://tulip.labri.fr)
 *
 * Authors: David Auber and the Tulip development Team
 * from LaBRI, University of Bordeaux
 *
 * Tulip 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.
 *
 * Tulip 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.
 *
 */

#ifndef PARALLELCOORDSAXISSLIDERS_H_
#define PARALLELCOORDSAXISSLIDERS_H_

#include <tulip/GlSimpleEntity.h>
#include <tulip/GLInteractor.h>
#include <tulip/GlLabel.h>
#include <tulip/GlPolygon.h>

#include "ParallelCoordinatesDrawing.h"

namespace tlp {

class GlQuad;
class ParallelCoordinatesView;

enum sliderType { TOP_SLIDER = 0, BOTTOM_SLIDER = 1 };

class AxisSlider : public GlSimpleEntity {

public:
  AxisSlider(const sliderType type, const Coord &sliderCoord, const float halfWidth,
             const float halfHeight, const Color &sliderColor, const Color &labelColor,
             const float rotationAngle = 0);
  ~AxisSlider() override;

  void setSliderFillColor(const Color &color);
  void setSliderOutlineColor(const Color &color);
  void setSliderLabel(const std::string &label) {
    sliderLabel->setText(label);
  }
  void setRotationAngle(const float rotationAngle) {
    this->rotationAngle = rotationAngle;
  }

  void draw(float lod, Camera *camera) override;
  BoundingBox getBoundingBox() override;
  Coord getSliderCoord() const {
    return sliderCoord;
  }
  void translate(const Coord &move) override;
  void moveToCoord(const Coord &coord) {
    translate(coord - sliderCoord);
  }
  sliderType getSliderType() const {
    return type;
  }
  Color getColor() {
    return arrowPolygon->getFillColor(0);
  }

  void getXML(std::string &) override {}
  void setWithXML(const std::string &, unsigned int &) override {}

private:
  sliderType type;

  GlComposite *sliderComposite;
  GlQuad *sliderQuad;
  GlPolygon *sliderPolygon;
  GlPolygon *arrowPolygon;
  GlLabel *sliderLabel;
  Coord sliderCoord;
  float rotationAngle;
};

class ParallelCoordsAxisSliders : public GLInteractorComponent {

public:
  ParallelCoordsAxisSliders();
  ~ParallelCoordsAxisSliders() override;
  bool eventFilter(QObject *, QEvent *) override;
  bool draw(GlMainWidget *glMainWidget) override;
  bool compute(GlMainWidget *glMainWidget) override;
  void viewChanged(View *view) override;

private:
  void initOrUpdateSliders();
  AxisSlider *getSliderUnderPointer(GlMainWidget *glWidget, ParallelAxis *axis, int x, int y);
  void updateOtherAxisSliders();
  void buildGlSliders(const std::vector<ParallelAxis *> &axis);
  void deleteGlSliders();
  void setSlidersColor(const Color &color);
  void updateSlidersYBoundaries();

  ParallelCoordinatesView *parallelView;
  Graph *currentGraph;
  std::map<ParallelAxis *, std::vector<AxisSlider *>> axisSlidersMap;
  ParallelAxis *selectedAxis;
  std::vector<ParallelAxis *> lastSelectedAxis;
  AxisSlider *selectedSlider;
  bool axisSliderDragStarted;
  bool pointerBetweenSliders;
  bool slidersRangeDragStarted;
  int slidersRangeLength;
  int xClick, yClick;
  float lastAxisHeight;
  unsigned int lastNbAxis;
  ParallelCoordinatesDrawing::HighlightedEltsSetOp highlightedEltsSetOperation;
  std::map<ParallelAxis *, std::pair<float, float>> slidersYBoundaries;
  GlLayer *selectionLayer;
};
} // namespace tlp

#endif /* PARALLELCOORDSAXISSLIDERS_H_ */