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 168 169 170 171
|
/**
*
* 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 THRESHOLDINTERACTOR_H_
#define THRESHOLDINTERACTOR_H_
#if defined(_MSC_VER)
#include <Windows.h>
#endif
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
//#include <tulip/GLInteractor.h>
#include "EditColorScaleInteractor.h"
#include <tulip/GlComposite.h>
#include <tulip/Observable.h>
#include <tulip/Size.h>
#include <tulip/Color.h>
#include <tulip/Coord.h>
//#include <tulip/GlQuad.h>
//#include <tulip/GlPolygon.h>
//#include <tulip/GlLabel.h>
//#include <tulip/GlRect.h>
//#include <tulip/DoubleProperty.h>
//#include "SOMView.h"
#include <QMutex>
namespace tlp {
class GlLabelledColorScale;
class GlPolygon;
class GlQuad;
class GlLabel;
class Slider {
public:
virtual ~Slider() {
}
virtual float getLeftBound() = 0;
virtual float getRightBound() = 0;
virtual void beginShift() = 0;
virtual void shift(float shift)=0;
virtual void endShift() = 0;
};
class ColorScaleSlider: public Slider, public GlComposite, public Observable {
public:
enum SliderWay {
ToLeft, ToRight
};
ColorScaleSlider(SliderWay way, Size size, GlLabelledColorScale *colorScale,const std::string& textureName);
~ColorScaleSlider();
void draw(float lod, tlp::Camera *camera);
void setColor(Color c);
Coord getBasePosition() {
return position;
}
Size getSize() {
return size;
}
SliderWay getWay() {
return way;
}
void setLinkedSlider(ColorScaleSlider* linkedSlider);
ColorScaleSlider* getLinkedSlider() {
return linkedSlider;
}
float getLeftBound();
float getRightBound();
void beginShift();
void shift(float shift);
void endShift();
double getValue();
float getCurrentShift() const {
return currentShift;
}
void setValue(double value);
void update(std::set<Observable *>::iterator begin,
std::set<Observable *>::iterator end);
void observableDestroyed(Observable *);
protected:
void buildComposite(const std::string& textureName);
void updatePosition();
void computeBoundingBox();
SliderWay way;
Coord position;
Size size;
GlPolygon *arrow;
GlQuad *rect;
GlLabel *label;
ColorScaleSlider* linkedSlider;
GlLabelledColorScale *linkedScale;
float currentShift;
};
class SliderBar: public Slider, public tlp::GlSimpleEntity {
public:
SliderBar(ColorScaleSlider* left, ColorScaleSlider* right,const std::string& textureName);
~SliderBar();
float getLeftBound();
float getRightBound();
void beginShift();
void shift(float shift);
void endShift();
void draw(float lod, tlp::Camera *camera);
void getXML(std::string &) {}
void setWithXML(const std::string &, unsigned int &) {}
protected:
ColorScaleSlider* left;
ColorScaleSlider* right;
std::string texture;
bool isVisible;
};
class ThresholdInteractor: public EditColorScaleInteractor {
public:
ThresholdInteractor();
virtual ~ThresholdInteractor();
bool draw(tlp::GlMainWidget *glMainWidget);
bool eventFilter(QObject *, QEvent *);
void setView(View *view);
protected:
void screenSizeChanged(SOMView* somView);
void propertyChanged(SOMView* somView,const std::string& propertyName, tlp::NumericProperty *newProperty);
void performSelection(SOMView *somView, Iterator<node> *it);
void buildSliders(SOMView* somView);
void clearSliders();
void generateSliderTexture(tlp::GlMainWidget* widget);
tlp::GlLayer *layer;
Slider *mouvingSlider;
ColorScaleSlider *rSlider;
ColorScaleSlider *lSlider;
SliderBar* bar;
bool startDrag;
int XPosCursor;
QMutex lock;
std::string textureName;
GLuint textureId;
};
}
#endif /* THRESHOLDINTERACTOR_H_ */
|