rasdaman complete source
rviewUtils.hh
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 /
23 
56 #ifndef _RVIEW_UTILS_H_
57 #define _RVIEW_UTILS_H_
58 
59 
60 #include <sstream>
61 
62 #include "rasodmg/ref.hh"
63 #include "rasodmg/marray.hh"
64 #include "rasodmg/gmarray.hh"
65 #include "rasodmg/database.hh"
66 
67 #include "labelManager.hh"
68 
69 // #include "wx_scrol.h"
70 #include "wx/xrc/xh_scrol.h"
71 #include "wx/msgout.h"
72 
73 // #define wxUSE_GLCANVAS 1 // need this? -- PB 2006-jan-01
74 #include <wx/glcanvas.h>
75 
76 
77 #ifdef __VISUALC__
78 #define DIR_SEPARATOR "\\"
79 #define DIR_SEPARATORC '\\'
80 #else
81 #define DIR_SEPARATOR "/"
82 #define DIR_SEPARATORC '/'
83 #endif
84 
85 extern const int rview_window_extra_height;
86 extern const int rview_choice_sub_width;
87 
88 
89 
90 #define STRINGSIZE 256
91 
92 
93 
94 // base type to name translations
95 
96 // Identifiers for base types
97 enum rviewBaseType
98 {
99  rbt_none,
100  rbt_bool,
101  rbt_char,
102  rbt_uchar,
103  rbt_short,
104  rbt_ushort,
105  rbt_long,
106  rbt_ulong,
107  rbt_rgb,
108  rbt_float,
109  rbt_double
110 };
111 
112 // Maximum dimension of data rview can deal with
113 #define MAXIMUM_DIMENSIONS 4
114 
115 // String names for objects / sets over the various basetypes.
116 extern char *rviewBaseTypes[];
117 extern char *rviewTypeNames[][MAXIMUM_DIMENSIONS];
118 extern char *rviewSetNames[][MAXIMUM_DIMENSIONS];
119 
120 // Base type to image type mapping
121 extern int rviewImageTypes[];
122 // Possible types:
123 enum rview_image_types
124 {
125  RVIEW_IMGTYPE_NONE,
126  RVIEW_IMGTYPE_MONO,
127  RVIEW_IMGTYPE_GREY,
128  RVIEW_IMGTYPE_HIGH,
129  RVIEW_IMGTYPE_GREY12,
130  RVIEW_IMGTYPE_TRUE24,
131  RVIEW_IMGTYPE_TRUE32
132 };
133 
134 
135 
136 // Mouse buttons
137 #define MOUSE_LEFT 1
138 #define MOUSE_MIDDLE 2
139 #define MOUSE_RIGHT 4
140 // Ctrl pressed while mouse event?
141 #define MOUSE_CONTROL 8
142 // Maximum distance of mouse pointer to an object for manipulating / dragging
143 #define MOUSE_HOTZONE 8
144 
145 
146 
147 // Menu items
148 
149 enum rview_menu_ident
150 {
151  MENU_DUMMY_IDENT, // 0 is illegal for a menu id
152 
153  // First the ones for the main window
154  MENU_MAIN_FILE_QUERY,
155  MENU_MAIN_FILE_PREFS,
156  MENU_MAIN_FILE_EXIT,
157 
158  MENU_MAIN_VIEW_OPEN,
159  MENU_MAIN_VIEW_CLOSE,
160 
161  MENU_MAIN_COLL_LOOK,
162  MENU_MAIN_COLL_LKSCL,
163  MENU_MAIN_COLL_LKORTH,
164  MENU_MAIN_COLL_CREATE,
165  MENU_MAIN_COLL_DELETE,
166 
167  MENU_MAIN_HELP_ABOUT,
168 
169  // Now the menu items for the results window
170  MENU_RSLT_ITEM_OPENALL,
171  MENU_RSLT_ITEM_THUMBALL,
172  MENU_RSLT_ITEM_CLOSE,
173 
174  MENU_RSLT_SLCT_SLCTALL,
175  MENU_RSLT_SLCT_CLEAR,
176  MENU_RSLT_SLCT_OPEN,
177  MENU_RSLT_SLCT_THUMB,
178  MENU_RSLT_SLCT_DELETE,
179  MENU_RSLT_SLCT_ENDIAN,
180  MENU_RSLT_SLCT_TYPEMAN,
181  MENU_RSLT_SLCT_INFO,
182 
183  // Now the menu items for the display windows
184  MENU_DISP_DATA_INSERT,
185  MENU_DISP_DATA_INSERTPRO,
186  MENU_DISP_DATA_SAVE,
187  MENU_DISP_DATA_CLOSE,
188  MENU_DISP_DATA_SAVETIFF,
189  MENU_DISP_VIEW_SAVE,
190  MENU_DISP_VIEW_LOAD,
191  MENU_DISP_VIEW_SHOW,
192  // Additional menus in charts
193  MENU_CHART_MODE_BAR,
194  MENU_CHART_MODE_LINE,
195  MENU_CHART_MODE_SPLINE,
196  // Additional menus in images
197  MENU_IMAGE_MODE_FLAT,
198  MENU_IMAGE_MODE_SURF,
199  MENU_IMAGE_MODE_VOXEL,
200  MENU_IMAGE_MODE_HEIGHT,
201  MENU_IMAGE_SETUP_RENDER,
202  MENU_IMAGE_SETUP_RCONTROL,
203  MENU_IMAGE_SETUP_CSPACE,
204  MENU_IMAGE_SETUP_MOVIE,
205  MENU_IMAGE_MOVIE_ONCE,
206  MENU_IMAGE_MOVIE_START,
207  MENU_IMAGE_MOVIE_SWITCH,
208  MENU_IMAGE_CSPACE_ON,
209  MENU_IMAGE_CSPACE_FULL,
210  MENU_IMAGE_CSPACE_PROJ,
211  MENU_IMAGE_CSPACE_EDIT,
212  // Additional menus in tables
213  MENU_TABLE_MODE_DECIMAL,
214  MENU_TABLE_MODE_OCTAL,
215  MENU_TABLE_MODE_HEX,
216 
217  // Thumbnail window
218  MENU_THUMB_DATA_CLOSE,
219  MENU_THUMB_SETUP_CSPACE,
220  MENU_THUMB_CSPACE_ON,
221  MENU_THUMB_CSPACE_FULL,
222  MENU_THUMB_CSPACE_EDIT,
223 
224  // Now the menu items for the query window
225  MENU_QUERY_FILE_OPEN,
226  MENU_QUERY_FILE_SAVE,
227  MENU_QUERY_FILE_EXIT,
228  MENU_QUERY_EDIT_CUT,
229  MENU_QUERY_EDIT_COPY,
230  MENU_QUERY_EDIT_PASTE,
231  MENU_QUERY_HELP_HELP,
232 
233  // Total number of menus = first free menu ID for dynamic menus:
234  MENU_TOTAL_NUMBER
235 };
236 
237 // Hotlist menu has no fixed length. Set upper limit with MENU_QUERY_HOTRANGE, however
238 #define MENU_QUERY_HOTLIST MENU_TOTAL_NUMBER
239 // upper limit for queries in hotlist
240 #define MENU_QUERY_HOTRANGE 64
241 
242 
243 
244 // Number of display modes
245 #define RVIEW_RESDISP_NUMBER 8
246 // Flags for each MDD object saying whether it's opened in a display mode
247 #define RVIEW_RESDISP_CHART 1
248 #define RVIEW_RESDISP_TABLE 2
249 #define RVIEW_RESDISP_SOUND 4
250 #define RVIEW_RESDISP_IMGFLAT 8
251 #define RVIEW_RESDISP_IMGVOLM 16
252 #define RVIEW_RESDISP_IMGHGHT 32
253 #define RVIEW_RESDISP_IMGOSECT 64
254 #define RVIEW_RESDISP_STRVIEW 128
255 // this one is special because it can't be used from the results window
256 #define RVIEW_RESDISP_IMGSCLD 256
257 
258 
259 
260 
261 
262 // For frame_list type. Full declaration below.
263 class rviewFrame;
264 class rviewFrameMgr;
265 
266 
267 
268 
269 /*
270  * Types and structures.
271  */
272 
273 // User events
275 {
277  usr_child_closed, // data = rviewFrame *
278  usr_mdd_dying, // data = r_Ref<r_GMarray>*
281  usr_update_closed, // data = r_Ref<r_GMarray>*
282  usr_viewer_closed, // data = mdd_frame *
283  usr_cspace_changed, // data = colourspaceMapper*
284  usr_typeman_convert, // data = rviewTypeMan *
286 };
287 
288 
289 // The frame list item used but the frameManager.
290 typedef struct frame_list
291 {
294 } frame_list;
295 
296 // An MDD object and some flags
297 typedef struct mdd_frame
298 {
300  unsigned int flags;
301 } mdd_frame;
302 
303 // Collection descriptor (for lookup / query exection)
304 // mddObjs != NULL ==> collection of marrays
305 // strObjs != NULL ==> collection of strings
306 typedef struct collection_desc
307 {
308  char *collName;
309  char *collType;
310  char *collInfo;
311  int number;
313  char **strObjs;
315 
316 // User event used in rviewFrames / frameManager
317 typedef struct user_event
318 {
320  void *data;
321 } user_event;
322 
323 // Keyword to identifier lookup structure
324 typedef struct keyword_to_ident
325 {
326  int ident;
327  char *keyword;
329 
330 // same with a const char *
331 typedef struct keyword_to_ident_c
332 {
333  int ident;
334  const char *keyword;
336 
337 
338 
339 
340 /*
341  * Global functions
342  */
343 
344 // Free all memory allocated by a filled collection descriptor
346 
347 // Generic event handler. Calls the frame manager:
348 void rviewEventHandler(wxObject &obj, wxEvent &evt);
349 
350 // Parse a projection string and return its dimensionality
351 extern int rviewParseProjection(const r_Minterval &interv, r_Point &pt1, r_Point &pt2, const char *projString, unsigned int *freeDims=NULL, r_Point *mapIndex=NULL);
352 
353 // Return an object's base type as integer identifier
355 
356 // Prints the contents of a cell with a given RasDaMan base type into the buffer, returns number
357 // of characters written.
358 extern int rviewPrintTypedCell(const r_Type *baseType, char *buffer, char *data, int numberBase);
359 
360 // Quicksorts a char *[]
361 extern void rviewQuicksortStrings(char *array[], int from, int to);
362 
363 // Init character lookup tables
364 extern void rviewInitCharacterTables(void);
365 
366 // Look up a keyword in a sorted (!) keyword_to_ident array
367 extern int rviewLookupKeyword(const char *key, const keyword_to_ident_c *kti, int tabsize, bool caseSensitive);
368 
369 // Checks if colourspace mapping is possible for a given base type
370 // and sets up some variables if so.
371 class colourspaceMapper;
372 struct colourspace_params_s;
373 extern int rviewCheckInitCspace(rviewBaseType baseType, colourspaceMapper **csmap, r_Ref<r_GMarray> &mddObj, bool fullRange=FALSE, r_Minterval *domain=NULL, int w=0, int *newPitch=NULL, int *newDepth=NULL, int *newPad=NULL, int *virtualPitch=NULL, const struct colourspace_params_s *cp=NULL);
374 
375 // Smart number conversions: also understand 0x prefix
376 extern long asctol(const char *str);
377 extern int asctoi(const char *str);
378 extern double asctof(const char *str);
379 extern long stringtol(const char *str, char **endptr=NULL);
380 extern double stringtof(const char *str, char **endptr=NULL);
381 
382 
383 
384 
385 // Dynamic string class
387 {
388 public:
389 
390  DynamicString(void);
391  DynamicString(const DynamicString &ds);
392  DynamicString(const char *str);
393  ~DynamicString(void);
394 
395  DynamicString &first(const char *str, unsigned int num);
397  DynamicString &operator=(const char *str);
398  bool operator==(const DynamicString &ds) const;
399  bool operator==(const char *str) const;
400 
401  const char *ptr(void) const;
402  operator const char*(void) const;
403 
404 
405 private:
406 
407  char *myString;
408 
409  static const char emptyString[];
410 };
411 
412 
413 
414 // A stack template class
415 template<class T>
417 {
418 public:
419 
420  DynamicStack(unsigned int gran=8);
421  DynamicStack(const DynamicStack<T> &src);
422  ~DynamicStack(void);
423 
424  int push(const T &item);
425  int pop(T &item);
426  int peek(T &item) const;
427  unsigned int getNumber(void) const;
428 
429 
430 protected:
431 
432  int ensureFree(void);
433 
434  unsigned int number, max, granularity;
435  T *stack;
436 };
437 
438 
439 
440 
441 
442 // Frame types
444 {
474 };
475 
476 
477 /*
478  * The base class for all frames. This makes managing open frames
479  * in a uniform way possible. Include after wx.h !
480  */
481 
482 class rviewFrame: public wxFrame
483 {
484 public:
485 
486  rviewFrame(wxFrame *parent, char *title, int x, int y, int w, int h);
487  virtual ~rviewFrame(void);
488 
489  // When the checkobj(...) method is called the frame checks whether
490  // it knows obj (e.g. it's a button contained in the frame) and claims
491  // the broadcast by returning a value != 0. This is used in frame manager
492  // broadcasts. You should not try to get involved with derived classes
493  // at this point.
494  int checkobj(wxObject &obj);
495 
496  // When the label() method is called the derived frame class
497  // has to relabel all its widgets
498  virtual void label(void) = 0;
499 
500  // The process() method is called for the object that claimed the
501  // checkobj() function. It has to process the event and return a value
502  // != 0 if it did anything, 0 if the event was ignored. The two
503  // functions are separated because the Frame manager broadcast call
504  // has to be re-entrant and we'll get huge problems if the frame
505  // list changes during the loop.
506  virtual int process(wxObject &obj, wxEvent &evt) = 0;
507 
508  // The userEvent method is called to notify frames of events like
509  // the mdd object a frame displays being deleted.
510  virtual int userEvent(const user_event &ue);
511 
512  // Called when the frame is to be killed. May be overloaded, but normally
513  // doesn't have to be.
514  virtual int requestQuit(int level);
515 
516  // Called for mouse events of some logical child. Normally ignored.
517  virtual void childMouseEvent(wxWindow *child, wxMouseEvent &mevt);
518 
519  // The setParent(parent) function makes this frame a (logical) child
520  // of parent. This will remove the frame from the parent's child frame
521  // list when it's deleted.
522  void setParent(rviewFrame *parent);
523  void registerChild(rviewFrame *child);
524  void deregisterChild(rviewFrame *child);
525 
526  // Returns the name of this class
527  virtual const char *getFrameName(void) const;
528 
529  // Returns the identifier of this frame
530  virtual rviewFrameType getFrameType(void) const;
531 
532  // By default each frame is closed by returning TRUE from this wxWindows
533  // function. If you wish to override this behaviour for certain frames,
534  // override the frame's virtual function OnClose().
535  virtual bool OnClose(void);
536 
537 
538 protected:
539 
540  // For keeping track of child frames
544 
545 
546 
547 private:
548 
549  // Used internally by the checkobj() member function.
550  int checkobj_rec(wxWindow *whence, wxObject &obj);
551 };
552 
553 
554 
555 
556 /*
557  * The frame manager. Provides central access to frames and
558  * offers functions like automatically re-labeling all existing
559  * frames. Each object of class rviewFrame registers itself here
560  * in the constructor and deregisters itself in the destructor.
561  */
562 
564 {
565 public:
566 
567  rviewFrameMgr(void);
568  rviewFrameMgr(bool delChild);
569  ~rviewFrameMgr(void);
570 
571  void registerFrame(rviewFrame *client);
572  void deregisterFrame(rviewFrame *client);
573  int numberOfFrames(void) const;
574  void setDeleteMode(bool delChild);
575 
576  // The following functions cause the frame manager to iterate over
577  // all frames and call specific member functions. Some of these
578  // member functions (e.g. process) can stop the iteration by
579  // claiming the call.
580  void labelAll(void);
581  void broadcastEvent(wxObject &obj, wxEvent &evt);
582  int broadcastQuit(int level);
583  int broadcastUserEvent(const user_event &ue);
584 
585 
586 protected:
587 
592 };
593 
594 
595 
596 
597 
598 /*
599  * A continuous text displayed in multiple lines
600  */
601 
603 {
604 public:
605 
606  rviewMultiline(wxPanel *Panel, int X, int Y, int H, int Lines);
607  rviewMultiline(wxPanel *Panel, const char *Message, int X, int Y, int W, int H, int Lines);
608  ~rviewMultiline(void);
609 
610  // Returns the height used by the messages
611  int getMessageHeight(void) const;
612 
613  void rebuild(const char *Message, int W);
614 
615  // 10 * number of pixels used per character
616  static const int multiline_ppc10;
617 
618 
619 protected:
620 
621  void setupVariables(wxPanel *Panel, int X, int Y, int H, int Lines);
622 
623  wxPanel *parent;
624  wxMessageOutput **msg;
625  int lines;
626  int x, y, lHeight;
627 };
628 
629 
630 
631 /*
632  * Convenient interface to standard widgets
633  */
634 #include <wx/univ/textctrl.h>
635 
636 class rviewText : public wxTextCtrl
637 {
638 public:
639 
640  rviewText(wxPanel *parent, const char *value=NULL, char *label="", int x=-1, int y=-1, int w=-1, int h=-1);
641  rviewText(long style, wxPanel *parent, const char *value=NULL, char *label="", int x=-1, int y=-1, int w=-1, int h=-1);
642  rviewText(wxPanel *parent, const DynamicString &value, char *label="", int x=-1, int y=-1, int w=-1, int h=-1);
643  rviewText(wxPanel *parent, int value, char *label="", int x=-1, int y=-1, int w=-1, int h=-1);
644  rviewText(wxPanel *parent, long value, char *label="", int x=-1, int y=-1, int w=-1, int h=-1);
645  rviewText(wxPanel *parent, double value, bool sciForm=FALSE, char *label="", int x=-1, int y=-1, int w=-1, int h=-1);
646 
647  void SetValue(char *value);
648  void SetValue(const char *value);
649  void SetValue(const DynamicString &value);
650  void SetValue(int value);
651  void SetValue(unsigned int value);
652  void SetValue(long value);
653  void SetValue(double value, bool sciFrom=FALSE);
654 
655  char *GetValue(void);
656  void GetValue(DynamicString &value);
657  void GetValue(int &value);
658  void GetValue(long &value);
659  void GetValue(float &value);
660  void GetValue(double &value);
661 };
662 
663 class rviewButton : public wxButton
664 {
665 public:
666 
667  rviewButton(wxPanel *parent, char *label="", int x=-1, int y=-1, int w=-1, int h=-1, long style=0);
668 };
669 
670 // BUG IN wxCoice: NEVER CREATE A (wx|rview)Choice ITEM WITH AN EMPTY LABEL!
671 class rviewChoice : public wxChoice
672 {
673 public:
674 
675  rviewChoice(wxPanel *parent, int n, char *choices[], char *label="X", int x=-1, int y=-1, int w=-1, int h=-1, long style=0);
676  // this is kind of a hack to fix wxWindows' lack of const
677  rviewChoice(wxPanel *parent, int n, const char *choices[], char *label="X", int x=-1, int y=-1, int w=-1, int h=-1, long style=0);
678 };
679 
680 class rviewCheckBox : public wxCheckBox
681 {
682 public:
683 
684  rviewCheckBox(wxPanel *parent, char *label="", int x=-1, int y=-1, int w=-1, int h=-1);
685 };
686 
687 class rviewRadioButton : public wxRadioButton
688 {
689 public:
690 
691  rviewRadioButton(wxPanel *parent, char *label="", bool value=FALSE, int x=-1, int y=-1, int w=-1, int h=-1);
692 };
693 
694 class rviewScrollBar : public wxScrollBar
695 {
696 public:
697 
698  rviewScrollBar(wxPanel *parent, int x=-1, int y=-1, int w=-1, int h=-1, long style=wxHORIZONTAL);
699 };
700 
701 class rviewSlider : public wxSlider
702 {
703 public:
704 
705  rviewSlider(wxPanel *parent, int value, int min_val, int max_val, int width, char *label="", int x=-1, int y=-1, long style=wxHORIZONTAL);
706 };
707 
708 
709 /*
710  * The original slider class didn't allow me to pass on arbitrary mouse events
711  * to the (logical) parent which was needed in the orthosection viewer for
712  * automatically loading the data on a button up event. This slider class fixes
713  * this problem and has the same functionality as the original one. Use it
714  * whenever arbitrary mouse events are important.
715  */
716 
717 class rviewSpecialSlider : public wxGLCanvas
718 {
719 public:
720  rviewSpecialSlider(rviewFrame *logParent, wxPanel *parent, int val, int min, int max, int width=-1, const char *label=NULL);
721  ~rviewSpecialSlider(void);
722 
723  int GetMax(void) const;
724  int GetMin(void) const;
725  int GetValue(void) const;
726  void SetRange(int min, int max);
727  void SetValue(int val);
728  bool PositionInWell(float posx, float posy);
729 
730  virtual void SetLabel(const char *label);
731  virtual void OnPaint(void);
732  virtual void OnEvent(wxMouseEvent &mevt);
733 
734 
735 protected:
736  void getWellVert(int &y0, int &y1);
737  void getBarParams(float &posx, float &posy, float &height);
738  int calcNewValue(float posx, float posy, int &val, bool checky=FALSE);
739  void redrawCore(float x, float y, float bheight);
740  void getUpdateInterval(float oldx, float newx, float &clipx, float &clipw);
741  void updateWell(float oldx, float newx, float posy, float bheight);
742  wxColour background;
743  wxColour foreground;
744  wxColour wellground;
745  wxColour outline;
746  wxColour labelColour;
747  wxBrush bback;
748  wxBrush bfore;
749  wxBrush bwell;
750  wxPen outlinePen;
751  wxFont labelFont;
753  int value, vmin, vmax;
755  float textx, texty;
758  static const int dflt_width;
759  static const int dflt_height;
760  static const int dflt_border;
761  static const int dflt_barwidth;
762  static const int dflt_barheight;
763 };
764 
765 
766 
767 
768 /*
769  * Dialog box, containing a message and some buttons.
770  */
771 class rviewDialog: public rviewFrame
772 {
773 public:
774 
775  rviewDialog(const char *title, const char *message, int buttonNo, const char *buttons[]);
776  virtual ~rviewDialog(void);
777  void OnSize(int w, int h);
778 
779  int GetButton(void);
780 
781  // implementations of the rviewFrame virtual functions
782  void label(void);
783  int process(wxObject &obj, wxEvent &evt);
784 
785  virtual const char *getFrameName(void) const;
786  virtual rviewFrameType getFrameType(void) const;
787 
788  // constants
789  // Width and height of the dialog box
790  static const int dialog_width;
791  static const int dialog_height;
792  // Borders used in the dialog box
793  static const int dialog_border;
794  // Width and height of the buttons
795  static const int dialog_buttonsx;
796  static const int dialog_buttonsy;
797  // Height reserved at the bottom for the buttons
798  static const int dialog_bheight;
799  // Number of text lines
800  static const int dialog_lines;
801  // Height of each of these lines
802  static const int dialog_lheight;
803 
804 
805 protected:
806 
807  wxPanel *panel;
808  char **buttonText;
809  //wxTextWindow *msg;
814 };
815 
816 
817 
818 /*
819  * An error box.
820  */
821 
823 {
824 public:
825 
826  // Default error-box: a message and an OK button.
827  rviewErrorbox(const char *message);
828  rviewErrorbox(const char *title, const char *message, int buttonNo, const char *buttons[]);
829  ~rviewErrorbox(void);
830  int activate(void);
831 
832  virtual const char *getFrameName(void) const;
833  virtual rviewFrameType getFrameType(void) const;
834 
835  // creating errorboxes with formatted text
836  static rviewErrorbox *newErrorbox(const char *message, const char *classname=NULL, const char *funcname=NULL);
837  static rviewErrorbox *newErrorbox(const char *title, const char *message, int buttonNo, const char *buttons[], const char *classname=NULL, const char *funcname=NULL);
838  static int reportError(const char *message, const char *classname=NULL, const char *funcname=NULL);
839  static int reportError(const char *title, const char *message, int buttonNo, const char *buttons[], const char *classname=NULL, const char *funcname=NULL);
840 
841 private:
842 
843  static char *buildErrorMessage(const char *message, const char *classname, const char *funcname);
844 };
845 
846 
847 
848 /*
849  * Progress reports
850  */
851 
853 {
854 public:
855 
856  // Progress reporter (mostly used by database)
857  rviewProgress(const char *message);
858  ~rviewProgress(void);
859 
860  int process(wxObject &obj, wxEvent &evt);
861 
862  virtual const char *getFrameName(void) const;
863  virtual rviewFrameType getFrameType(void) const;
864 };
865 
866 
867 
868 /*
869  * Window holding MDD results
870  */
871 
872 class rviewTypeMan;
873 
874 class rviewResult: public rviewFrame
875 {
876 public:
877 
878  rviewResult(void);
879  rviewResult(collection_desc *collection);
880  ~rviewResult(void);
881  void setCollection(collection_desc *collection);
882 
883  void label(void);
884  int process(wxObject &obj, wxEvent &evt);
885  int userEvent(const user_event &ue);
886 
887  void OnSize(int w, int h);
888  void OnMenuCommand(int id);
889 
890  virtual const char *getFrameName(void) const;
891  virtual rviewFrameType getFrameType(void) const;
892 
893  // constants
894  // X and Y position of result box
895  static const int result_x;
896  static const int result_y;
897  // Width and height of result box
898  static const int result_width;
899  static const int result_height;
900  // Borders used in results box
901  static const int result_border;
902  // Height of a line (collection info)
903  static const int result_lheight;
904  // Space reserved for header (collection info)
905  static const int result_header;
906  // Width of choice item
907  static const int result_cwidth;
908  // Width and height of resample group
909  static const int result_twidth;
910  static const int result_theight;
911  // Width and height of button
912  static const int result_bwidth;
913  static const int result_bheight;
914 
915 
916 protected:
917 
918  void setupVariables(void);
919  void openViewer(int item);
920  int updateSelection(void);
921  void configureGrey(void);
922  int parseResampleString(const char *resStr, double *values);
923  int resampleSelection(void);
924  char *mddDescriptorString(std::ostream &memstr, int number);
925  void convertSelectedItems(void);
926  // for printing information on time-consuming operations like scaling.
927  void operationPrologue(void);
928  void operationEpilogue(const char *opname);
929 
931 
932  char *selectedItems; // bitfield
934  int cbfactor; // number of units a checkbox is bigger than the size set
935 
936  wxGroupBox *group;
937  wxMessage *collName, *collType, *collInfo;
939  wxPanel *panel;
940  wxListBox *list;
941  wxMenuBar *mBar;
945 
947 };
948 
949 
950 
951 
952 /*
953  * About rView window
954  */
955 class rviewAbout: public rviewFrame
956 {
957 public:
958 
959  rviewAbout(void);
960  ~rviewAbout(void);
961 
962  void label(void);
963  int process(wxObject &obj, wxEvent &evt);
964 
965  void OnSize(int w, int h);
966 
967  virtual const char *getFrameName(void) const;
968  virtual rviewFrameType getFrameType(void) const;
969 
970  // constants
971  // Width and height of About window
972  static const int about_width;
973  static const int about_height;
974  // Borders in About window
975  static const int about_border;
976  // Height of panel
977  static const int about_pheight;
978  // Width and height of buttons in About window
979  static const int about_bwidth;
980  static const int about_bheight;
981  // Height of message item
982  static const int about_mheight;
983 
984 
985 protected:
986 
987  void deleteLabels(void);
988 
989  wxPanel *panel;
991  wxMessage **labels;
992  int numlines;
993 };
994 
995 
996 
997 /*
998  * rviewStringSet window
999  */
1001 {
1002 public:
1003 
1005  ~rviewStringSet(void);
1006 
1007  void label(void);
1008  int process(wxObject &obj, wxEvent &evt);
1009  void OnSize(int w, int h);
1010 
1011  int getNumItems(void);
1012  void addItem(const char *string);
1013  char *getItem(int number);
1014 
1015  virtual const char *getFrameName(void) const;
1016  virtual rviewFrameType getFrameType(void) const;
1017 
1018  // constants
1019  // Width and height of the string set window
1020  static const int strset_width;
1021  static const int strset_height;
1022  // Borders in string set window
1023  static const int strset_border;
1024  // Reserve space at the bottom for the dismiss button
1025  static const int strset_reserve;
1026  // Width and height of the dismiss button
1027  static const int strset_bwidth;
1028  static const int strset_bheight;
1029  // Height of message fields
1030  static const int strset_mheight;
1031 
1032 
1033 protected:
1034 
1035  wxPanel *panel;
1036  wxListBox *list;
1038  wxMessage *collName, *collType, *collInfo;
1039 };
1040 
1041 
1042 
1043 
1044 
1045 
1046 
1047 /*
1048  * Global variables
1049  */
1050 
1051 extern labelManager *lman;
1052 extern rviewFrameMgr *frameManager;
1053 extern unsigned char lowerCaseTable[256];
1054 
1055 
1056 #if (defined(EARLY_TEMPLATE) && defined(__EXECUTABLE__))
1057 #include "rviewUtils.cpp"
1058 #endif
1059 
1060 #endif
virtual rviewFrameType getFrameType(void) const
int GetButton(void)
long stringtol(const char *str, char **endptr=NULL)
void label(void)
char * collType
Definition: rviewUtils.hh:309
static const int about_border
Definition: rviewUtils.hh:975
Definition: rviewUtils.hh:279
static const int dialog_width
Definition: rviewUtils.hh:790
Definition: rviewUtils.hh:852
double stringtof(const char *str, char **endptr=NULL)
static const int strset_reserve
Definition: rviewUtils.hh:1025
virtual void OnPaint(void)
Definition: rviewUtils.hh:461
~rviewProgress(void)
~DynamicStack(void)
virtual const char * getFrameName(void) const
void SetValue(int val)
Definition: rviewUtils.hh:276
void OnSize(int w, int h)
Definition: rviewUtils.hh:416
Definition: rviewUtils.hh:280
rviewMultiline(wxPanel *Panel, int X, int Y, int H, int Lines)
int process(wxObject &obj, wxEvent &evt)
Definition: rviewUtils.hh:445
wxColour foreground
Definition: rviewUtils.hh:743
void setCollection(collection_desc *collection)
Definition: rviewUtils.hh:471
unsigned int max
Definition: rviewUtils.hh:434
virtual rviewFrameType getFrameType(void) const
Definition: rviewUtils.hh:457
static const int result_bheight
Definition: rviewUtils.hh:913
void setParent(rviewFrame *parent)
virtual rviewFrameType getFrameType(void) const
int frameHeight
Definition: rviewUtils.hh:543
int border
Definition: rviewUtils.hh:752
Definition: rviewUtils.hh:563
int getMessageHeight(void) const
Definition: rviewUtils.hh:281
wxListBox * list
Definition: rviewUtils.hh:940
virtual const char * getFrameName(void) const
rviewRadioButton(wxPanel *parent, char *label="", bool value=FALSE, int x=-1, int y=-1, int w=-1, int h=-1)
rviewScrollBar(wxPanel *parent, int x=-1, int y=-1, int w=-1, int h=-1, long style=wxHORIZONTAL)
int value
Definition: rviewUtils.hh:753
int16Row max
Definition: int16.hh:200
int ident
Definition: rviewUtils.hh:326
Definition: rviewUtils.hh:1000
Definition: point.hh:59
rviewFrame * logicalParent
Definition: rviewUtils.hh:757
Definition: rviewUtils.hh:468
~rviewResult(void)
rviewSpecialSlider(rviewFrame *logParent, wxPanel *parent, int val, int min, int max, int width=-1, const char *label=NULL)
struct keyword_to_ident_c keyword_to_ident_c
void openViewer(int item)
void * data
Definition: rviewUtils.hh:320
int pop(T &item)
Definition: rviewUtils.hh:306
Definition: rviewUtils.hh:449
int barheight
Definition: rviewUtils.hh:752
virtual const char * getFrameName(void) const
int process(wxObject &obj, wxEvent &evt)
void setDeleteMode(bool delChild)
long asctol(const char *str)
wxPanel * panel
Definition: rviewUtils.hh:989
static const int dflt_barwidth
Definition: rviewUtils.hh:761
static const int dialog_lheight
Definition: rviewUtils.hh:802
~rviewAbout(void)
void label(void)
static const int result_bwidth
Definition: rviewUtils.hh:912
void label(void)
int vmin
Definition: rviewUtils.hh:753
Definition: rviewUtils.hh:277
static const int strset_height
Definition: rviewUtils.hh:1021
Definition: raslib/type.hh:56
void getBarParams(float &posx, float &posy, float &height)
int userEvent(const user_event &ue)
static const int strset_border
Definition: rviewUtils.hh:1023
static const int dialog_buttonsy
Definition: rviewUtils.hh:796
rviewText * resampText
Definition: rviewUtils.hh:942
rviewText(wxPanel *parent, const char *value=NULL, char *label="", int x=-1, int y=-1, int w=-1, int h=-1)
wxMessage * collType
Definition: rviewUtils.hh:937
DynamicStack(unsigned int gran=8)
char ** strObjs
Definition: rviewUtils.hh:313
void rebuild(const char *Message, int W)
static const int result_cwidth
Definition: rviewUtils.hh:907
rviewSlider(wxPanel *parent, int value, int min_val, int max_val, int width, char *label="", int x=-1, int y=-1, long style=wxHORIZONTAL)
struct collection_desc collection_desc
virtual const char * getFrameName(void) const
int frameWidth
Definition: rviewUtils.hh:543
rviewAbout(void)
rviewButton(wxPanel *parent, char *label="", int x=-1, int y=-1, int w=-1, int h=-1, long style=0)
void OnSize(int w, int h)
wxColour background
Definition: rviewUtils.hh:742
rviewChoice(wxPanel *parent, int n, char *choices[], char *label="X", int x=-1, int y=-1, int w=-1, int h=-1, long style=0)
static const int dialog_bheight
Definition: rviewUtils.hh:798
unsigned char lowerCaseTable[256]
int broadcastQuit(int level)
int calcNewValue(float posx, float posy, int &val, bool checky=FALSE)
Definition: rviewUtils.hh:482
static const int result_theight
Definition: rviewUtils.hh:910
static const int dialog_height
Definition: rviewUtils.hh:791
int process(wxObject &obj, wxEvent &evt)
Definition: rviewUtils.hh:450
int ident
Definition: rviewUtils.hh:333
static const int dflt_height
Definition: rviewUtils.hh:759
wxPen outlinePen
Definition: rviewUtils.hh:750
char * collName
Definition: rviewUtils.hh:308
struct user_event user_event
unsigned int number
Definition: rviewUtils.hh:434
Definition: rviewUtils.hh:460
rviewButton * dismiss
Definition: rviewUtils.hh:1037
static const int multiline_ppc10
Definition: rviewUtils.hh:616
static const int result_border
Definition: rviewUtils.hh:901
wxBrush bwell
Definition: rviewUtils.hh:749
wxColour outline
Definition: rviewUtils.hh:745
int vmax
Definition: rviewUtils.hh:753
Definition: rviewUtils.hh:874
int checkobj(wxObject &obj)
rviewCheckBox(wxPanel *parent, char *label="", int x=-1, int y=-1, int w=-1, int h=-1)
wxMessage * collType
Definition: rviewUtils.hh:1038
int parseResampleString(const char *resStr, double *values)
#define FALSE
Definition: defs.h:70
rviewUserEvent
Definition: rviewUtils.hh:274
int GetMin(void) const
wxPanel * parent
Definition: rviewUtils.hh:623
void labelAll(void)
void rviewQuicksortStrings(char *array[], int from, int to)
void getWellVert(int &y0, int &y1)
Definition: rviewUtils.hh:463
frame_list * next
Definition: rviewUtils.hh:293
Definition: rviewUtils.hh:636
static const int strset_mheight
Definition: rviewUtils.hh:1030
static const int about_mheight
Definition: rviewUtils.hh:982
int broadcastUserEvent(const user_event &ue)
rviewFrameMgr * frameManager
int cbfactor
Definition: rviewUtils.hh:934
Definition: rviewUtils.hh:694
rviewChoice * scaleMode
Definition: rviewUtils.hh:943
char ** buttonText
Definition: rviewUtils.hh:808
rviewFrameMgr * frames
Definition: rviewUtils.hh:541
Definition: rviewUtils.hh:671
int numlines
Definition: rviewUtils.hh:992
struct mdd_frame mdd_frame
rviewUserEvent type
Definition: rviewUtils.hh:319
Definition: rviewUtils.hh:717
static const int result_twidth
Definition: rviewUtils.hh:909
Definition: rviewUtils.hh:453
Definition: rviewUtils.hh:701
int resampleSelection(void)
Definition: rviewColMap.hh:193
int updateSelection(void)
Definition: rviewUtils.hh:470
void addItem(const char *string)
virtual rviewFrameType getFrameType(void) const
static const int dialog_lines
Definition: rviewUtils.hh:800
void registerFrame(rviewFrame *client)
char * collInfo
Definition: rviewUtils.hh:310
wxMessage * collInfo
Definition: rviewUtils.hh:937
int activate(void)
~DynamicString(void)
Definition: rviewUtils.hh:466
virtual rviewFrameType getFrameType(void) const
float texty
Definition: rviewUtils.hh:755
r_Ref< r_GMarray > mdd
Definition: rviewUtils.hh:299
frame_list * tailList
Definition: rviewUtils.hh:589
Definition: rviewUtils.hh:454
rviewDialog(const char *title, const char *message, int buttonNo, const char *buttons[])
rviewChoice * choice
Definition: rviewUtils.hh:938
rviewFrameMgr(void)
bool operator==(const DynamicString &ds) const
int lHeight
Definition: rviewUtils.hh:626
Definition: object.hh:64
Definition: rviewUtils.hh:473
bool deleteChildren
Definition: rviewUtils.hh:591
void rviewInitCharacterTables(void)
void updateWell(float oldx, float newx, float posy, float bheight)
void deregisterFrame(rviewFrame *client)
int y
Definition: rviewUtils.hh:626
~rviewFrameMgr(void)
wxColour wellground
Definition: rviewUtils.hh:744
Definition: rviewUtils.hh:462
char * mddDescriptorString(std::ostream &memstr, int number)
T * stack
Definition: rviewUtils.hh:435
Definition: rviewUtils.hh:284
Definition: rviewUtils.hh:452
Definition: rviewUtils.hh:469
~rviewMultiline(void)
int rviewCheckInitCspace(rviewBaseType baseType, colourspaceMapper **csmap, r_Ref< r_GMarray > &mddObj, bool fullRange=FALSE, r_Minterval *domain=NULL, int w=0, int *newPitch=NULL, int *newDepth=NULL, int *newPad=NULL, int *virtualPitch=NULL, const struct colourspace_params_s *cp=NULL)
static const int dialog_buttonsx
Definition: rviewUtils.hh:795
Definition: rviewUtils.hh:290
rviewFrameType
Definition: rviewUtils.hh:443
void operationPrologue(void)
static const int dflt_barheight
Definition: rviewUtils.hh:762
virtual ~rviewFrame(void)
void redrawCore(float x, float y, float bheight)
Definition: rviewUtils.hh:278
bool PositionInWell(float posx, float posy)
DynamicString(void)
void setupVariables(wxPanel *Panel, int X, int Y, int H, int Lines)
int rviewLookupKeyword(const char *key, const keyword_to_ident_c *kti, int tabsize, bool caseSensitive)
void rviewEventHandler(wxObject &obj, wxEvent &evt)
rviewFrame * parentFrame
Definition: rviewUtils.hh:542
static const int result_x
Definition: rviewUtils.hh:895
virtual rviewFrameType getFrameType(void) const
Definition: rviewUtils.hh:459
Definition: rviewUtils.hh:324
struct frame_list frame_list
Definition: rviewUtils.hh:458
wxMessage * collName
Definition: rviewUtils.hh:1038
void configureGrey(void)
char * getItem(int number)
rviewFrame(wxFrame *parent, char *title, int x, int y, int w, int h)
int number
Definition: rviewUtils.hh:311
static const int result_height
Definition: rviewUtils.hh:899
rviewErrorbox(const char *message)
int GetMax(void) const
Definition: rviewUtils.hh:283
Definition: rviewUtils.hh:955
wxFont labelFont
Definition: rviewUtils.hh:751
rviewButton ** but
Definition: rviewUtils.hh:811
rviewProgress(const char *message)
int cheight
Definition: rviewUtils.hh:754
labelManager * lman
collection_desc * coll
Definition: rviewUtils.hh:930
~rviewStringSet(void)
void convertSelectedItems(void)
Definition: rviewUtils.hh:317
int process(wxObject &obj, wxEvent &evt)
int x
Definition: rviewUtils.hh:626
int process(wxObject &obj, wxEvent &evt)
Definition: rviewUtils.hh:386
virtual void label(void)=0
void rviewDeleteCollection(collection_desc *coll)
wxMessage ** labels
Definition: rviewUtils.hh:991
Definition: rviewUtils.hh:771
unsigned int granularity
Definition: rviewUtils.hh:434
void OnSize(int w, int h)
char * selectedItems
Definition: rviewUtils.hh:932
struct keyword_to_ident keyword_to_ident
wxColour labelColour
Definition: rviewUtils.hh:746
rviewStringSet(collection_desc *desc)
void registerChild(rviewFrame *child)
rviewBaseType
Definition: rviewUtils.hh:97
static const int result_lheight
Definition: rviewUtils.hh:903
Definition: rviewUtils.hh:602
static const int strset_bheight
Definition: rviewUtils.hh:1028
virtual int requestQuit(int level)
Definition: rviewTypeMan.hh:49
static const int about_bwidth
Definition: rviewUtils.hh:979
virtual ~rviewDialog(void)
int16Row min
Definition: int16.hh:200
int ensureFree(void)
void operationEpilogue(const char *opname)
DynamicString & first(const char *str, unsigned int num)
Definition: rviewUtils.hh:464
Definition: rviewUtils.hh:822
DynamicString & operator=(const DynamicString &ds)
DynamicString myLabel
Definition: rviewUtils.hh:756
void getUpdateInterval(float oldx, float newx, float &clipx, float &clipw)
virtual void OnEvent(wxMouseEvent &mevt)
Definition: rviewUtils.hh:331
Definition: rviewUtils.hh:448
static const int dialog_border
Definition: rviewUtils.hh:793
virtual void SetLabel(const char *label)
const char * ptr(void) const
Definition: rviewUtils.hh:465
Definition: rviewUtils.hh:447
int lines
Definition: rviewUtils.hh:625
void OnSize(int w, int h)
wxMessage * collInfo
Definition: rviewUtils.hh:1038
Definition: rviewColMap.hh:54
wxMenuBar * mBar
Definition: rviewUtils.hh:941
static const int about_bheight
Definition: rviewUtils.hh:980
rviewResult(void)
virtual const char * getFrameName(void) const
wxBrush bfore
Definition: rviewUtils.hh:748
void OnMenuCommand(int id)
mdd_frame * mddObjs
Definition: rviewUtils.hh:312
Definition: rviewUtils.hh:456
void SetValue(char *value)
int buttonNumber
Definition: rviewUtils.hh:812
Definition: labelManager.hh:51
int listLength
Definition: rviewUtils.hh:590
virtual bool OnClose(void)
const char * keyword
Definition: rviewUtils.hh:334
Definition: rviewUtils.hh:282
Definition: rviewUtils.hh:467
int push(const T &item)
wxPanel * panel
Definition: rviewUtils.hh:807
int cwidth
Definition: rviewUtils.hh:754
virtual const char * getFrameName(void) const
static const int result_header
Definition: rviewUtils.hh:905
Definition: rviewUtils.hh:285
int GetValue(void) const
wxGroupBox * group
Definition: rviewUtils.hh:936
void deregisterChild(rviewFrame *child)
rviewBaseType rviewGetBasetype(r_Object *obj)
rviewTypeMan * typeManager
Definition: rviewUtils.hh:946
static const int dflt_border
Definition: rviewUtils.hh:760
static const int about_pheight
Definition: rviewUtils.hh:977
Definition: rviewUtils.hh:451
static const int about_height
Definition: rviewUtils.hh:973
int numberOfFrames(void) const
Definition: rviewUtils.hh:663
Definition: rviewUtils.hh:455
int peek(T &item) const
int lastSelected
Definition: rviewUtils.hh:933
static const int strset_bwidth
Definition: rviewUtils.hh:1027
Definition: rviewUtils.hh:472
virtual int process(wxObject &obj, wxEvent &evt)=0
virtual int userEvent(const user_event &ue)
Definition: rviewUtils.hh:297
Definition: rviewUtils.hh:680
float textx
Definition: rviewUtils.hh:755
Definition: rviewUtils.hh:446
wxMessageOutput ** msg
Definition: rviewUtils.hh:624
virtual const char * getFrameName(void) const
static const int strset_width
Definition: rviewUtils.hh:1020
void deleteLabels(void)
char * keyword
Definition: rviewUtils.hh:327
Definition: rviewUtils.hh:687
frame_list * frameList
Definition: rviewUtils.hh:588
~rviewErrorbox(void)
int asctoi(const char *str)
static const int result_width
Definition: rviewUtils.hh:898
wxBrush bback
Definition: rviewUtils.hh:747
wxMessage * collName
Definition: rviewUtils.hh:937
double asctof(const char *str)
virtual rviewFrameType getFrameType(void) const
int getNumItems(void)
unsigned int getNumber(void) const
int buttonPressed
Definition: rviewUtils.hh:813
static int reportError(const char *message, const char *classname=NULL, const char *funcname=NULL)
wxListBox * list
Definition: rviewUtils.hh:1036
rviewButton * resampBut
Definition: rviewUtils.hh:944
void broadcastEvent(wxObject &obj, wxEvent &evt)
static const int about_width
Definition: rviewUtils.hh:972
rviewButton * okBut
Definition: rviewUtils.hh:990
static const int result_y
Definition: rviewUtils.hh:896
wxPanel * panel
Definition: rviewUtils.hh:939
int rviewPrintTypedCell(const r_Type *baseType, char *buffer, char *data, int numberBase)
void SetRange(int min, int max)
Definition: minterval.hh:249
int rviewParseProjection(const r_Minterval &interv, r_Point &pt1, r_Point &pt2, const char *projString, unsigned int *freeDims=NULL, r_Point *mapIndex=NULL)
rviewMultiline * msg
Definition: rviewUtils.hh:810
char * GetValue(void)
void setupVariables(void)
rviewFrame * frame
Definition: rviewUtils.hh:292
virtual void childMouseEvent(wxWindow *child, wxMouseEvent &mevt)
int barwidth
Definition: rviewUtils.hh:752
void label(void)
static rviewErrorbox * newErrorbox(const char *message, const char *classname=NULL, const char *funcname=NULL)
static const int dflt_width
Definition: rviewUtils.hh:758
unsigned int flags
Definition: rviewUtils.hh:300
wxPanel * panel
Definition: rviewUtils.hh:1035