summaryrefslogtreecommitdiffstats
path: root/applications/rview/rviewThumb.hh
blob: dc30c24c958ed40976eb7bd182b6bb159aec4dea (plain)
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*
* This file is part of rasdaman community.
*
* Rasdaman community is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Rasdaman community 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.
*
* You should have received a copy of the GNU General Public License
* along with rasdaman community.  If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
rasdaman GmbH.
*
* For more information please see <http://www.rasdaman.org>
* or contact Peter Baumann via <baumann@rasdaman.com>.
/

/**
 *  PURPOSE:
 *
 *  rView thumbnail viewer class. Unlike the regular MDD viewers (e.g.
 *  rviewImage) this is not derived from rviewDisplay because it can
 *  display any number of MDD objects in contrast to regular viewers
 *  which manage exactly one object.
 *
 *	COMMENTS:
 *		None
 */



#ifndef _RVIEW_THUMB_H_
#define _RVIEW_THUMB_H_




#include "rasodmg/ref.hh"
#include "rasodmg/marray.hh"
#include "rasodmg/gmarray.hh"

#include "labelManager.hh"
#include "rviewUtils.hh"
#include "rviewDisplay.hh"
#include "rviewDModes.hh"




class wxPixmap;
class rviewThumb;


// List holding all the pixmap items for one mddObject.
// This chain is 1 item long for 2D data, but can be any length
// for higher dimensions
typedef struct rviewThumbPixList {
  wxPixmap *pixmap;
  int dimproj, projval;
  rviewThumbPixList *next;
} rviewThumbPixList;

// List holding mdd/pixmap items
typedef struct rviewThumbList {
  r_Ref<r_GMarray> mdd;
  rviewBaseType baseType;
  int numPix;
  rviewThumbPixList *pixmaps;
  rviewThumbList *next;
} rviewThumbList;




/*
 *  The canvas displaying the thumbnails
 */
class thumbCanvas: public wxCanvas
{
  public:

  thumbCanvas(rviewThumb *par, int x, int y, int width, int height);
  ~thumbCanvas(void);

  void OnPaint(void);
  void updateDisplay(void);


  protected:

  wxBrush brush;
  rviewThumb *parent;
};



/*
 *  A window containing small versions of images
 */
class rviewThumb: public rviewFrame
{
  public:

  rviewThumb(void);
  ~rviewThumb(void);

  int addMDD(r_Ref<r_GMarray> &newMdd);
  int deleteMDD(r_Ref<r_GMarray> &obsMdd);
  void setLayout(int width, int npl);
  void newThumbWidth(int newWidth);

  void label(void);
  int process(wxObject &obj, wxEvent &evt);
  virtual const char *getFrameName(void) const;
  virtual rviewFrameType getFrameType(void) const;

  void OnSize(int w, int h);
  void OnMenuCommand(int id);

  int userEvent(const user_event &ue);

  // Used by canvas to get data
  wxPixmap *getPixmapNumber(int no, char *caption);
  void getThumbInfo(int &num, int &npl);
  void getGridInfo(int &gx, int &gy);

  // constants
  // Initial dimensions of window
  static const int thumb_width;
  static const int thumb_height;
  // Default width of thumbnail images
  static const int thumb_imgwidth;
  // Default number of thumbnails per line
  static const int thumb_perline;
  // Space between thumbnails
  static const int thumb_space;
  // Borders used in thumbnail window
  static const int thumb_border;
  // Scrolling values
  static const int thumb_scrstep;
  static const int thumb_pgstep;
  // Dimensions of checkboxs
  static const int thumb_chkwidth;
  static const int thumb_chkheight;
  // Minimum / maximum width of thumbnails
  static const int thumb_minwidth;
  static const int thumb_maxwidth;
  // Minimum / maximum number of thumbnails per line
  static const int thumb_mincols;
  static const int thumb_maxcols;
  // Height of control panel at the top
  static const int thumb_cheight;
  // Height of text items
  static const int thumb_twidth;
  static const int thumb_theight;
  // Width of projDim / step widgets
  static const int thumb_prjwidth;


  protected:

  void deletePixmapChain(rviewThumbList *tlst);
  int pixmapsFromMDD(rviewThumbList *tlst);
  wxPixmap *buildThumbnail(r_Ref<r_GMarray> &mddObj, rviewBaseType baseType, int dimproject, int projval);
  void updateCanvasSize(void);
  void rebuildThumbnails(bool fromScratch);
  void initForObject(r_Ref<r_GMarray> &mddObj);
  int parseProjection(r_Ref<r_GMarray> &mddObj);
  void configureCspace(bool mode);

  char projString[STRINGSIZE];
  r_Point pt1, pt2, mapIndex;
  int thumbs, thumbsperline, numPixmaps;
  int maxHeight;
  int gridX, gridY;
  int imgWidth;
  int dimMDD;		// should be constant for all objects!
  int dim1, dim2;	// dimensions to iterate over
  int dimproj;		// projection dim for 3+D objects
  int projstep;		// stepping value in dimproj
  unsigned int freeDims;
  rviewThumbList *listHead;
  thumbCanvas *canvas;
  wxMenuBar *mbar;
  wxPanel *panel;
  rviewText *thumbWidth;
  rviewText *thumbCols;
  rviewText *project;
  rviewText *thumbProj, *thumbStep;
  wxFont *font;
  colourspaceMapper *csmap;
  bool doValToCspace;
  bool doFullRangeCspace;
  bool canDoCspace;
};

#endif