rasdaman complete source
rviewDisplay.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 
43 #ifndef _RVIEW_DISPLAY_H_
44 #define _RVIEW_DISPLAY_H_
45 
46 #include "rasodmg/ref.hh"
47 #include "rasodmg/marray.hh"
48 #include "rasodmg/gmarray.hh"
49 
50 #include "labelManager.hh"
51 #include "rviewUtils.hh"
52 
53 /*
54  * A window containing an display mode + controls
55  */
56 class rviewDisplay: public rviewFrame
57 {
58 public:
59 
60  rviewDisplay(mdd_frame *mf, int es, unsigned int flags=0);
61  virtual ~rviewDisplay(void);
62 
63  // must use separate call because no virtual functions beyond level i can
64  // be called in a constructor of level i. This became necessary when the
65  // rviewImage class was split up. Returns 0 for OK, -1 for error.
66  virtual int openViewer(void);
67  // Same reason for virtual calls (getViewerType()) in the destructor; this
68  // functions is called from a viewer's destructor to notify its parent of the
69  // close event.
70  void closeViewer(void);
71 
72  virtual void label();
73  virtual int process(wxObject &obj, wxEvent &evt);
74 
75  virtual void OnSize(int w, int h);
76  virtual void OnMenuCommand(int id);
77 
78  virtual const char *getFrameName(void) const;
79  virtual rviewFrameType getFrameType(void) const;
80  virtual int getViewerType(void) const = 0;
81 
82  // Needs to process user events
83  virtual int userEvent(const user_event &ue);
84  // Notify derived classes that they should get ready to die. This is needed
85  // for stuff like images with movie-playback running.
86  virtual void prepareToDie(void);
87  // Notify derived classes that the projection has changed
88  virtual int newProjection(void);
89  // get the minterval to use with the projection string
90  virtual const r_Minterval &getVirtualDomain(void) const;
91 
92  // Called when an update object has been replaced with a new one
93  void noLongerUpdate(void);
94  // Returns the display ID (used in for update displays)
95  int getIdentifier(void) const;
96  int getDisplayCounter(void) const;
97  // sets the ID of the query window in case it's an update object
98  void setQueryWindow(int qwindowID);
99 
100  // viewer-related constants
101  // Default width and height of display window
102  static const int display_width;
103  static const int display_height;
104  // Space reserved around the canvas
105  static const int display_cnvborder;
106  // Borders used in display window
107  static const int display_border;
108  // Scrollbar steps
109  static const int display_scrstep;
110  // Page stepping
111  static const int display_pgstep;
112  // Height of control area
113  static const int display_cheight;
114  // Height of projection widget
115  static const int display_pjheight;
116  // Maximum width of projection widget
117  static const int display_pjwidth;
118  // Projection OK-button dimensions
119  static const int display_pbwidth;
120  static const int display_pbheight;
121  // Minimum display window size (to avoid X errors)
122  static const int display_minwidth;
123 
124  // Display flags
125  static const int display_flag_standalone;
126  static const int display_flag_update;
127 
128  // modes for advanceProjection()
130  {
134  };
135 
136 
137 protected:
138 
139  // to allow derived functions to add stuff to the file menu before the quit item
140  virtual int fileMenuInitHook(wxMenu *menu);
141  // to allow derived functions to add stuff to the view menu
142  virtual int viewMenuInitHook(wxMenu *menu);
143  // for appending menus to the menu bar
144  virtual int menuBarInitHook(void);
145 
146  // Called by the derived classes to (un)grey certain widgets
147  void setModeDimension(int dim);
148  // Called by derived classes to set minimum size of viewer window
149  void setMinimumViewerSize(int w, int h);
150  // Advances projection (+/- buttons)
151  const char *skipIndexMapping(const char *s);
152  int advanceProjection(int direction, int advmode=display_advmode_relative);
153  void newDBState(bool dbstate);
154  void setDisplayTitle(const char *title=NULL);
155  // view management
156  int doSaveView(void);
157  int doLoadView(void);
158  int parseViewFile(FILE *fp);
159  static void writeViewKey(FILE *fp, const char *key);
160  static void writeViewParam(FILE *fp, const char *key, const char *value);
161  static void writeViewParam(FILE *fp, const char *key, long value);
162  static void writeViewParam(FILE *fp, const char *key, double value);
163  static void writeViewParam(FILE *fp, const char *key, unsigned int num, const long *values);
164  static void writeViewParam(FILE *fp, const char *key, unsigned int num, const double *values);
165  static int readVector(const char *value, unsigned int num, long *values);
166  static int readVector(const char *value, unsigned int num, double *values);
167 
168  // save the current view to a file descriptor
169  virtual int saveView(FILE *fp);
170  // read a parameter from a view file line; returns 0 if unknown key, 1 otherwise
171  virtual int readView(const char *key, const char *value);
172  // loading a new view is finished, allow updating of displays before the redraw
173  virtual void loadViewFinished(void);
174 
175  unsigned int displayFlags;
181  wxMenuBar *mBar;
182  wxPanel *ctrlPanel;
184  wxMessage *typeMsg;
186  char projString[STRINGSIZE];
187  char rootTitle[STRINGSIZE];
195  // number of menus that are always on the menu bar
196  static const int fixedNumberOfMenus;
197 
198 
199 private:
200 
201  // This variable avoids closeViewer() being called more than once
202  // in case there are viewer classes derived from a common, non-
203  // abstract base class.
204  bool closeViewerCalled;
205 
206  // This global variable is incremented every time a display window is
207  // opened. It is used to init the displayID member to identify display
208  // windows by a number.
209  static int displayCounter;
210 
211  // file extension of view file
212  static const char *viewFileExtension;
213 
214  // size of buffer for view loading
215  static const unsigned int viewBuffSize;
216 
217  // view parameter keywords
218  static const char *view_HeaderLine;
219  static const char *view_ViewerType;
220  static const char *view_ProjString;
221  static const char *view_WindowSize;
222 };
223 
224 #endif
int doSaveView(void)
static const int display_minwidth
Definition: rviewDisplay.hh:122
unsigned int displayFlags
Definition: rviewDisplay.hh:175
static int readVector(const char *value, unsigned int num, long *values)
static const int display_scrstep
Definition: rviewDisplay.hh:109
virtual void OnSize(int w, int h)
virtual ~rviewDisplay(void)
static const int fixedNumberOfMenus
Definition: rviewDisplay.hh:196
static const int display_pjheight
Definition: rviewDisplay.hh:115
static const int display_width
Definition: rviewDisplay.hh:102
int qwindowID
Definition: rviewDisplay.hh:191
int getIdentifier(void) const
static const int display_cnvborder
Definition: rviewDisplay.hh:105
Definition: point.hh:59
int doLoadView(void)
virtual void OnMenuCommand(int id)
int dimMode
Definition: rviewDisplay.hh:179
display_advmode_e
Definition: rviewDisplay.hh:129
virtual int process(wxObject &obj, wxEvent &evt)
static const int display_flag_update
Definition: rviewDisplay.hh:126
int extraSpace
Definition: rviewDisplay.hh:188
static void writeViewKey(FILE *fp, const char *key)
virtual int readView(const char *key, const char *value)
static const int display_cheight
Definition: rviewDisplay.hh:113
virtual int getViewerType(void) const =0
Definition: rviewUtils.hh:482
void setDisplayTitle(const char *title=NULL)
virtual void loadViewFinished(void)
void newDBState(bool dbstate)
int dimMDD
Definition: rviewDisplay.hh:179
void setMinimumViewerSize(int w, int h)
static const int display_pgstep
Definition: rviewDisplay.hh:111
Definition: rviewUtils.hh:636
Definition: rviewDisplay.hh:131
void noLongerUpdate(void)
Definition: rviewDisplay.hh:56
void closeViewer(void)
int parseViewFile(FILE *fp)
int mbarHeight
Definition: rviewDisplay.hh:192
int minViewX
Definition: rviewDisplay.hh:192
wxPanel * ctrlPanel
Definition: rviewDisplay.hh:182
bool displayOperation
Definition: rviewDisplay.hh:193
virtual int menuBarInitHook(void)
virtual int viewMenuInitHook(wxMenu *menu)
Definition: rviewDisplay.hh:133
virtual int openViewer(void)
virtual rviewFrameType getFrameType(void) const
rviewButton * projMinus
Definition: rviewDisplay.hh:185
r_Ref< r_GMarray > mddObj
Definition: rviewDisplay.hh:176
rviewText * project
Definition: rviewDisplay.hh:183
bool objectInitializedOK
Definition: rviewDisplay.hh:194
void setModeDimension(int dim)
rviewBaseType baseType
Definition: rviewDisplay.hh:180
r_Point mapIndex
Definition: rviewDisplay.hh:178
virtual void label()
rviewFrameType
Definition: rviewUtils.hh:443
int getDisplayCounter(void) const
wxMessage * typeMsg
Definition: rviewDisplay.hh:184
int baseSize
Definition: rviewDisplay.hh:179
wxMenuBar * mBar
Definition: rviewDisplay.hh:181
static const int display_height
Definition: rviewDisplay.hh:103
char rootTitle[STRINGSIZE]
Definition: rviewDisplay.hh:187
virtual int userEvent(const user_event &ue)
Definition: rviewDisplay.hh:132
const char * skipIndexMapping(const char *s)
int displayID
Definition: rviewDisplay.hh:190
static const int display_pjwidth
Definition: rviewDisplay.hh:117
static const int display_pbwidth
Definition: rviewDisplay.hh:119
Definition: rviewUtils.hh:317
int advanceProjection(int direction, int advmode=display_advmode_relative)
rviewButton * projPlus
Definition: rviewDisplay.hh:185
static void writeViewParam(FILE *fp, const char *key, const char *value)
virtual const char * getFrameName(void) const
rviewBaseType
Definition: rviewUtils.hh:97
virtual int saveView(FILE *fp)
virtual int newProjection(void)
r_Point pt2
Definition: rviewDisplay.hh:178
char projString[STRINGSIZE]
Definition: rviewDisplay.hh:186
r_Minterval interv
Definition: rviewDisplay.hh:177
static const int display_pbheight
Definition: rviewDisplay.hh:120
int totalCtrlHeight
Definition: rviewDisplay.hh:189
static const int display_border
Definition: rviewDisplay.hh:107
rviewButton * projBut
Definition: rviewDisplay.hh:185
virtual const r_Minterval & getVirtualDomain(void) const
Definition: rviewUtils.hh:663
virtual void prepareToDie(void)
Definition: rviewUtils.hh:297
virtual int fileMenuInitHook(wxMenu *menu)
int minViewY
Definition: rviewDisplay.hh:192
r_Point pt1
Definition: rviewDisplay.hh:178
static const int display_flag_standalone
Definition: rviewDisplay.hh:125
void setQueryWindow(int qwindowID)
Definition: minterval.hh:249
rviewText * advance
Definition: rviewDisplay.hh:183
rviewDisplay(mdd_frame *mf, int es, unsigned int flags=0)