ODIN
float2d.h
1 /***************************************************************************
2  float2d.h - description
3  -------------------
4  begin : Sun Aug 27 2000
5  copyright : (C) 2000-2021 by Thies Jochimsen
6  email : thies@jochimsen.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef FLOAT2D_H
19 #define FLOAT2D_H
20 
21 #include <qlabel.h>
22 
23 #include "odinqt.h"
24 #include "plot.h"
25 
26 
27 class QPixmap; // forward declaration
28 
32 class floatLabel2D : public QLabel {
33  Q_OBJECT
34 
35  public:
36  floatLabel2D(const float *data, float lowbound, float uppbound, unsigned int nx, unsigned int ny, bool disable_scale, unsigned int coarseFactor,
37  QWidget *parent, const char *name,
38  const float *overlay_map, float lowbound_map, float uppbound_map, unsigned int nx_map, unsigned int ny_map, bool map_firescale, float map_rectsize,
39  bool colormap);
40  ~floatLabel2D();
41 
42  int xpos2labelxpos(int pos);
43  int ypos2labelypos(int pos);
44  int labelxpos2xpos(int pos);
45  int labelypos2ypos(int pos);
46  int xypos2index(int xpos,int ypos);
47 
48  unsigned int get_nx() const {return nx_cache;}
49  unsigned int get_ny() const {return ny_cache;}
50 
51  void init_pixmap(bool clear=true);
52  void set_pixmap();
53 
54  void write_pixmap(const char* fname, const char* format) const;
55 
56  void write_legend(const char* fname, const char* format) const;
57 
58  QLabel* get_map_legend(QWidget *parent) const;
59  void write_map_legend(const char* fname, const char* format) const;
60 
61  QPixmap *pixmap;
62 
63 protected:
64 
65  void mousePressEvent (QMouseEvent *);
66  void mouseReleaseEvent (QMouseEvent *);
67  void mouseMoveEvent ( QMouseEvent * );
68 
69 
70 public slots:
71  void refresh(const float *data, float lowbound, float uppbound);
72  void refreshMap(const float *map, float map_lowbound, float map_uppbound, float rectsize);
73 
74 private slots:
75  void drawprofil(int position,int direction);
76  void drawcross(int xposition,int yposition);
77  void drawroi();
78 
79 signals:
80  void clicked(int xposition,int yposition);
81  void newProfile(const float *data, int npts, bool horizontal, int position);
82  void newMask(const float *data);
83 
84 private:
85 
86  static int scale_width(float lowbound, float uppbound);
87 
88  void draw_text(GuiPainter& gp, int xpos, int ypos, const char* txt) const;
89  void draw_scale_text(GuiPainter& gp, int xpos, int ypos, float val) const;
90 
91  static int check_range(int val, int min, int max);
92 
93  int get_map_hue(float relval) const;
94  int get_map_value(float relval) const;
95  int get_map_saturation(float relval) const;
96 
97  int get_scale_size() const; // takes disable_scale into account
98 
99  bool disable_scale_cache;
100 
101  GuiPainter* roi_painter;
102  mutable QPixmap* maplegend_pixmap;
103 
104  unsigned char* imagebuff;
105  unsigned int len;
106 
107  const float* data_cache;
108  unsigned int nx_cache;
109  unsigned int ny_cache;
110 
111  mutable int scale_size_cache;
112 
113  float lowbound_cache;
114  float uppbound_cache;
115 
116  unsigned int nx_map_cache;
117  unsigned int ny_map_cache;
118  float lowbound_map_cache;
119  float uppbound_map_cache;
120  bool fire_map_cache;
121 
122  float *profile_x;
123  float *profile_y;
124  unsigned int coarseFactor_cache;
125  bool colormap_cache;
126  long unsigned int i;
127 
128  STD_list<QPoint> roi_polygon;
129  float* roi_mask;
130 
131  bool mouse_moved;
132 };
133 
134 
135 
136 
137 #endif
direction
Definition: odinpara.h:41