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
274 enum rviewUserEvent
275 {
276  usr_none,
277  usr_child_closed, // data = rviewFrame *
278  usr_mdd_dying, // data = r_Ref<r_GMarray>*
279  usr_db_opened,
280  usr_db_closed,
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 *
285  usr_close_viewers
286 };
287 
288 
289 // The frame list item used but the frameManager.
290 typedef struct frame_list
291 {
292  rviewFrame *frame;
293  frame_list *next;
294 } frame_list;
295 
296 // An MDD object and some flags
297 typedef struct mdd_frame
298 {
299  r_Ref < r_GMarray > mdd;
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;
312  mdd_frame *mddObjs;
313  char **strObjs;
314 } collection_desc;
315 
316 // User event used in rviewFrames / frameManager
317 typedef struct user_event
318 {
319  rviewUserEvent type;
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;
328 } keyword_to_ident;
329 
330 // same with a const char *
331 typedef struct keyword_to_ident_c
332 {
333  int ident;
334  const char *keyword;
335 } keyword_to_ident_c;
336 
337 
338 
339 
340 /*
341  * Global functions
342  */
343 
344 // Free all memory allocated by a filled collection descriptor
345 void rviewDeleteCollection(collection_desc *coll);
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
354 extern rviewBaseType rviewGetBasetype(r_Object *obj);
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
386 class DynamicString
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);
396  DynamicString &operator=(const DynamicString &ds);
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>
416 class DynamicStack
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
443 enum rviewFrameType
444 {
445  rviewFrameTypeGeneric,
446  rviewFrameTypeMain,
447  rviewFrameTypeQuery,
448  rviewFrameTypePrefs,
449  rviewFrameTypeAbout,
450  rviewFrameTypeDialog,
451  rviewFrameTypeErrorbox,
452  rviewFrameTypeProgress,
453  rviewFrameTypeStrSet,
454  rviewFrameTypeCspace,
455  rviewFrameTypeImgSet,
456  rviewFrameTypeRenCtrl,
457  rviewFrameTypeResult,
458  rviewFrameTypeThumb,
459  rviewFrameTypeDisplay,
460  rviewFrameTypeImage,
461  rviewFrameTypeFltBsImage,
462  rviewFrameTypeFlatImage,
463  rviewFrameTypeRndImage,
464  rviewFrameTypeVolImage,
465  rviewFrameTypeHghtImage,
466  rviewFrameTypeScaledImage,
467  rviewFrameTypeOSectionImage,
468  rviewFrameTypeChart,
469  rviewFrameTypeTable,
470  rviewFrameTypeSound,
471  rviewFrameTypeStringViewer,
472  rviewFrameTypeRenView,
473  rviewFrameTypeNumberOfTypes
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
541  rviewFrameMgr *frames;
542  rviewFrame *parentFrame;
543  int frameWidth, frameHeight;
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 
563 class rviewFrameMgr
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 
588  frame_list *frameList;
589  frame_list *tailList;
590  int listLength;
591  bool deleteChildren;
592 };
593 
594 
595 
596 
597 
598 /*
599  * A continuous text displayed in multiple lines
600  */
601 
602 class rviewMultiline
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;
752  int border, barwidth, barheight;
753  int value, vmin, vmax;
754  int cwidth, cheight;
755  float textx, texty;
756  DynamicString myLabel;
757  rviewFrame *logicalParent;
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;
810  rviewMultiline *msg;
811  rviewButton **but;
812  int buttonNumber;
813  int buttonPressed;
814 };
815 
816 
817 
818 /*
819  * An error box.
820  */
821 
822 class rviewErrorbox: public rviewDialog
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 
852 class rviewProgress: public rviewDialog
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 
930  collection_desc *coll;
931 
932  char *selectedItems; // bitfield
933  int lastSelected;
934  int cbfactor; // number of units a checkbox is bigger than the size set
935 
936  wxGroupBox *group;
937  wxMessage *collName, *collType, *collInfo;
938  rviewChoice *choice;
939  wxPanel *panel;
940  wxListBox *list;
941  wxMenuBar *mBar;
942  rviewText *resampText;
943  rviewChoice *scaleMode;
944  rviewButton *resampBut;
945 
946  rviewTypeMan *typeManager;
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;
990  rviewButton *okBut;
991  wxMessage **labels;
992  int numlines;
993 };
994 
995 
996 
997 /*
998  * rviewStringSet window
999  */
1000 class rviewStringSet: public rviewFrame
1001 {
1002 public:
1003 
1004  rviewStringSet(collection_desc *desc);
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;
1037  rviewButton *dismiss;
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
Definition: raslib/type.hh:56
#define FALSE
Definition: defs.h:70
#define min(a, b)
Definition: defs.h:78
#define max(a, b)
Definition: defs.h:77
bool operator==(const OId::OIdPrimitive one, const OId &two)