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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
/**
*
* This file is part of Tulip (www.tulip-software.org)
*
* 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 HISTOGRAMCOLORMAPPING_H_
#define HISTOGRAMCOLORMAPPING_H_
#include <QCursor>
#include <QEvent>
#include <tulip/tulipconf.h>
#include <tulip/GWInteractor.h>
#include <tulip/TlpTools.h>
#include <tulip/GWInteractor.h>
#include <tulip/GlSimpleEntity.h>
#include <tulip/GlCircle.h>
#include <tulip/GlPolyQuad.h>
#include <map>
namespace tlp {
struct ltCoord {
bool operator()(const Coord s1, const Coord s2) const {
return s1.getY() < s2.getY();
}
};
class GlEditableCurve: public GlSimpleEntity {
public:
GlEditableCurve(const Coord &startPoint, const Coord &endPoint,
const Color &curveColor);
GlEditableCurve(const GlEditableCurve &curve);
~GlEditableCurve() {
}
bool pointBelong(const Coord &point);
void addCurveAnchor(const Coord &point);
Coord *getCurveAnchorAtPointIfAny(const Coord &point);
void removeCurveAnchor(const Coord &curveAnchor);
Coord translateCurveAnchorToPoint(const Coord &curveAnchor,
const Coord &targetPoint);
float getYCoordForX(const float xCoord);
void updateSize(const Coord &newMinPoint, const Coord &newMaxPoint);
void draw(float lod, Camera* camera);
void getXML(xmlNodePtr rootNode) {
}
void setWithXML(xmlNodePtr rootNode) {
}
Coord getMinPoint() const {
return minPoint;
}
Coord getMaxPoint() const {
return maxPoint;
}
Coord getFirstCurvePoint() const {
return startPoint;
}
Coord getLastCurvePoint() const {
return endPoint;
}
std::vector<Coord> getCurvePoints() const {
return curvePoints;
}
Color getCurveColor() const {
return curveColor;
}
private:
void init();
Coord startPoint, endPoint;
Coord minPoint, maxPoint;
std::vector<Coord> curvePoints;
Color curveColor;
GlCircle basicCircle;
};
class ColorScale {
public:
ColorScale();
ColorScale(const ColorScale& scale);
virtual ~ColorScale();
virtual void setColorScale(const std::vector<Color>& colors);
void setColorScaleFromImage(const std::string &imageFile);
Color getColorAtLen(const float pos) const;
std::map<float, Color> getColorMap() const {
return colorMap;
}
protected:
std::map<float, Color> colorMap;
};
class GlColorScale: public GlSimpleEntity {
public:
enum Orientation {
Horizontal, Vertival
};
GlColorScale(const Coord &baseCoord, const float length,
const float thickness, Orientation orientation,ColorScale *colorScale=NULL);
GlColorScale(const GlColorScale &colorScale);
~GlColorScale();
//void setColorScale(const std::vector<Color> colors);
Color getColorAtPos(Coord pos);
void draw(float lod, Camera* camera);
void getXML(xmlNodePtr rootNode) {
}
void setWithXML(xmlNodePtr rootNode) {
}
Coord getBaseCoord() const {
return baseCoord;
}
float getThickness() const {
return thickness;
}
float getLength() const {
return length;
}
GlPolyQuad *getColorScalePolyQuad() const {
return colorScalePolyQuad;
}
void setColorScale(ColorScale * scale);
ColorScale *getColorScale() {
return scale;
}
private:
void updateDrawing();
ColorScale *scale;
Coord baseCoord;
float length, thickness;
GlPolyQuad *colorScalePolyQuad;
Orientation orientation;
};
}
#endif /* HISTOGRAMCOLORMAPPING_H_ */
|