File: ColorMapTest.h

package info (click to toggle)
witty 3.3.3%2Bdfsg-4.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 28,228 kB
  • ctags: 26,694
  • sloc: cpp: 147,809; ansic: 77,999; xml: 16,331; sh: 1,303; makefile: 198; java: 86; sql: 14
file content (55 lines) | stat: -rw-r--r-- 1,395 bytes parent folder | download | duplicates (2)
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
// This may look like C code, but it's really -*- C++ -*-
#include <Wt/WContainerWidget>
#include <Wt/WPaintDevice>
#include <Wt/WPaintedWidget>
#include <Wt/WPainter>
#include <Wt/WColor>
#include <Wt/WFont>
#include <Wt/WRectF>
#include <Wt/Chart/WStandardColorMap>

#include <map>

using namespace Wt;
using namespace Wt::Chart;

class ColorMapTest : public Wt::WPaintedWidget
{
public:
  ColorMapTest(Wt::WContainerWidget *parent = 0)
    : Wt::WPaintedWidget(parent)
  {
    resize(500, 300);
    std::vector<WStandardColorMap::Pair> colormap;
    colormap.push_back(WStandardColorMap::Pair(0,WColor(darkRed)));
    colormap.push_back(WStandardColorMap::Pair(1,WColor(red)));
    colormap.push_back(WStandardColorMap::Pair(2,WColor(gray)));
    colormap_ = new WStandardColorMap(0,3,colormap, false);
    colormap2_ = new WStandardColorMap(0,2,colormap, true);
  }

  ~ColorMapTest()
  {
    delete colormap_;
    delete colormap2_;
  }
  
protected:
  void paintEvent(Wt::WPaintDevice *paintDevice) {
    WPainter painter(paintDevice);

    painter.translate(50,0);
    colormap_->paintLegend(&painter);
    
    painter.translate(150,0);
    colormap2_->paintLegend(&painter);
    
    painter.translate(150,0);
    colormap2_->discretise(5);
    colormap2_->paintLegend(&painter);
  }
  
private:
  Wt::Chart::WStandardColorMap *colormap_;
  Wt::Chart::WStandardColorMap *colormap2_;
};