rasdaman complete source
rviewDModes.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_DMODES_H_
44 #define _RVIEW_DMODES_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 #include "rviewDisplay.hh"
53 #include "rviewColMap.hh"
54 
55 #ifdef __VISUALC__
56 struct vertex;
57 struct vertex_fp;
58 struct graph_env;
59 struct tex_desc;
60 struct voxel_desc;
61 struct mesh_desc;
62 struct mdd_desc;
63 #else
64 typedef struct vertex;
65 typedef struct vertex_fp;
66 typedef struct graph_env;
67 typedef struct tex_desc;
68 typedef struct voxel_desc;
69 typedef struct mesh_desc;
70 typedef struct mdd_desc;
71 #endif
72 
73 class rviewImage;
74 class rviewRenderImage;
75 
76 
77 // Possible display formats
78 enum rviewImageMode
79 {
80  rim_none,
81  rim_surf,
82  rim_voxel
83 };
84 
85 
86 // Flags for light direction
87 #define RVIEW_LIGHTDIR_LEFT 1
88 #define RVIEW_LIGHTDIR_RIGHT 2
89 #define RVIEW_LIGHTDIR_DOWN 4
90 #define RVIEW_LIGHTDIR_UP 8
91 #define RVIEW_LIGHTDIR_FRONT 16
92 #define RVIEW_LIGHTDIR_BACK 32
93 
94 typedef struct rview_image_setup
95 {
96  unsigned long zpro, clipz;
97  double pixelThresholdLow, pixelThresholdHigh, weightThreshold;
98  int weightQuantisation;
99  bool useRgbBrightness;
100  bool useLights;
101  double lightsAmbient;
102  double lightsGain;
103  double lightsAngle;
104  double lightsScintAngle;
105  int lightsDir;
106  int lightsDist;
107  int kernelSize, kernelType;
108  bool useVoxCol;
109  double voxColour;
110  int gridSize;
111  double scaleHeight;
112 } rview_image_setup;
113 
114 
115 /*
116  * Image setup window for customizing the renderer.
117  */
118 class rviewImageSetup: public rviewFrame
119 {
120 public:
121 
122  rviewImageSetup(rview_image_setup *ris, rviewRenderImage *parentWin);
123  ~rviewImageSetup(void);
124 
125  void unlinkParent(void);
126 
127  void OnSize(int w, int h);
128 
129  void label(void);
130  int process(wxObject &obj, wxEvent &evt);
131 
132  void updateSettings(const rview_image_setup &ris);
133  void readNewSetup(void);
134 
135  virtual const char *getFrameName(void) const;
136  virtual rviewFrameType getFrameType(void) const;
137 
138  static int parseLightDirection(const char *dir);
139 
140  // constants
141  // Borders used in setup window
142  static const int imgset_border;
143  // Height of text widgets in setup window
144  static const int imgset_theight;
145  // Height of checkboxes in setup window
146  static const int imgset_chkheight;
147  // Height of group boxes in setup window
148  static const int imgset_renheight;
149  static const int imgset_voxheight;
150  static const int imgset_hgtheight;
151  // Dimensions of buttons in setup window
152  static const int imgset_bwidth;
153  static const int imgset_bheight;
154  // Dimensions of checkboxes in setup window
155  static const int imgset_chowidth;
156  static const int imgset_choheight;
157  // Setup window dimensions
158  static const int imgset_width;
159  static const int imgset_height;
160 
161 
162 protected:
163 
164  rviewRenderImage *parent;
165  wxPanel *panel;
166  wxGroupBox *renderGroup, *voxelGroup, *heightGroup;
167  rviewText *zproWidget, *clipzWidget;
168  rviewText *pixThreshLowWidget, *pixThreshHighWidget, *wgtThreshWidget, *wgtQuantWidget;
169  rviewCheckBox *useRgbBrightness;
170  rviewCheckBox *useLights;
171  rviewChoice *kernelSize, *kernelType;
172  rviewText *lightsAmbient, *lightsGain, *lightsAngle, *lightsScintAngle;
173  rviewText *lightsDir, *lightsDist;
174  rviewCheckBox *useVoxCol;
175  rviewText *voxColour;
176  rviewText *gridSize, *scaleHeight;
177  rviewButton *okBut, *cancelBut;
178  rview_image_setup oldSetup, *imgSetup;
179 
180  static const char *normalKernelSizes[];
181  static const keyword_to_ident_c normalKernelTypes[];
182 };
183 
184 
185 
186 /*
187  * Renderer playback control window
188  */
189 class rendererControl: public rviewFrame
190 {
191 public:
192 
193  rendererControl(float drx, float dry, float drz, int mode, rviewRenderImage *parentWin);
194  ~rendererControl(void);
195 
196  void unlinkParent(void);
197  void setActiveMode(int mode);
198 
199  void OnSize(int w, int h);
200 
201  void label(void);
202  int process(wxObject &obj, wxEvent &evt);
203 
204  virtual const char *getFrameName(void) const;
205  virtual rviewFrameType getFrameType(void) const;
206 
207  // constants
208  // Borders used in renderer control window
209  static const int rctrl_border;
210  // Button dimensions
211  static const int rctrl_bwidth;
212  static const int rctrl_bheight;
213  // Reset button dimensions
214  static const int rctrl_rwidth;
215  static const int rctrl_rheight;
216  // Slider height
217  static const int rctrl_sheight;
218  // Window dimensions
219  static const int rctrl_width;
220  static const int rctrl_height;
221 
222 
223 protected:
224 
225  void updateParameters(void);
226 
227  wxPanel *panel;
228  rviewSlider *rotx, *roty, *rotz;
229  rviewButton *resetX, *resetY, *resetZ;
230  rviewButton *actionBut, *closeBut;
231  rviewRenderImage *parent;
232  int active;
233 };
234 
235 
236 /*
237  * Renderer current view window (rotation, offset, scale)
238  */
239 class rendererCurrentView: public rviewFrame
240 {
241 public:
242 
243  rendererCurrentView(const vertex_fp &angles, long off, double scale, rviewRenderImage *parentWin);
244  ~rendererCurrentView(void);
245 
246  void unlinkParent(void);
247 
248  void OnSize(int w, int h);
249 
250  void label(void);
251  int process(wxObject &obj, wxEvent &evt);
252 
253  virtual const char *getFrameName(void) const;
254  virtual rviewFrameType getFrameType(void) const;
255 
256  void updateView(const vertex_fp &angles, long off, double scale);
257 
258  // constants
259  // Borders used in renderer view window
260  static const int rcview_border;
261  // Button dimensions
262  static const int rcview_bwidth;
263  static const int rcview_bheight;
264  // Text widget height
265  static const int rcview_theight;
266  // Window dimensions
267  static const int rcview_width;
268  static const int rcview_height;
269 
270 
271 protected:
272 
273  void updateParameters(void);
274 
275  wxPanel *panel;
276  rviewButton *applyButton, *closeButton;
277  rviewText *rotx, *roty, *rotz;
278  rviewText *zoff;
279  rviewText *cubeScale;
280  rviewRenderImage *parent;
281 };
282 
283 
284 
285 class wxPixmap;
286 
287 /*
288  * Container class for wxPixmap.
289  */
290 class pixmapCanvas: public wxCanvas
291 {
292 public:
293 
294  pixmapCanvas(rviewImage *parent, int x, int y, int w, int h, long style=0);
295  ~pixmapCanvas(void);
296 
297  void setPixmap(wxPixmap *pmap);
298  void updateDisplay(bool borders=FALSE);
299 
300  void OnPaint(void);
301  void OnEvent(wxMouseEvent &mevt);
302 
303  void SetAspectRatio(double ratio); // 0 for none
304  void ToggleDragBox(bool clearMode);
305  void SetDragBox(int x0, int y0, int x1, int y1);
306  bool HasDragBox(void) const;
307  bool GetDragBox(int &x0, int &y0, int &x1, int &y1) const;
308  void UpdateDragBox(int x1, int y1);
309  void AdjustDragBox(int x1, int y1);
310 
311 
312 protected:
313 
314  void paintCore(int x, int y);
315  void adjustBoxToRatio(void);
316 
317  wxPixmap *pixmap;
318  wxDC *myDC;
319  wxBrush brush;
320  wxBrush border;
321  wxBrush textBack;
322  wxPen bpen;
323  wxPen fpen;
324  wxFont *font;
325  rviewImage *parentWin;
326  int pixWidth, pixHeight;
327  int offX, offY;
328  int rect_x0, rect_y0, rect_x1, rect_y1;
329  double aspectRatio;
330  wxRect textBBox;
331 };
332 
333 
334 // Flags used when settings are updated
335 #define RVIEW_IFLAG_VOXEL 1
336 #define RVIEW_IFLAG_LIGHT 2
337 #define RVIEW_IFLAG_HEIGHT 4
338 
339 /*
340  * Abstract base class for all windows containing an image + controls
341  */
342 class rviewImage: public rviewDisplay
343 {
344 public:
345 
346  rviewImage(mdd_frame *mf, int es, unsigned int flags=0);
347  virtual ~rviewImage(void);
348 
349  virtual int openViewer(void);
350 
351  virtual void label(void);
352  virtual int process(wxObject &obj, wxEvent &evt);
353  virtual void processMouseEvent(wxMouseEvent &mevt);
354  virtual int userEvent(const user_event &ue);
355  virtual void prepareToDie(void);
356  virtual int newProjection(void)=0;
357  virtual int requestQuit(int level);
358 
359  virtual void OnSize(int w, int h);
360  virtual void OnMenuCommand(int id);
361  virtual bool OnClose(void); // overload from rviewFrame
362 
363  virtual const char *getFrameName(void) const;
364  virtual rviewFrameType getFrameType(void) const;
365 
366  // Default flags for wxPixmap class (dithering etc)
367  static int getPixmapFlags(void);
368 
369  // constants
370  // Slider dimensions
371  static const int image_swidth;
372  static const int image_sheight;
373  // Playback buttons dimensions
374  static const int image_pbwidth;
375  static const int image_pbheight;
376  // Minimum size of image
377  static const int image_minwidth;
378  static const int image_minheight;
379  // Checkbox dimensions
380  static const int image_chkwidth;
381  static const int image_chkheight;
382  // Bounding box checkbox dimensions
383  static const int image_bbwidth;
384  static const int image_bbheight;
385  // Text field dimensions
386  static const int image_twidth;
387  static const int image_theight;
388  // Button dimensions
389  static const int image_bwidth;
390  static const int image_bheight;
391  // Offsets of drag box in canvas
392  static const int image_dragtoff;
393  static const int image_dragtspace;
394  // Distance from the border at which to autoscroll
395  static const int image_draghotzone;
396  // Extra space reserved on control panel
397  static const int image_ctrly;
398  static const int image_totaly;
399 
400 
401 protected:
402 
403  void updatePixmap(char *oldData, char *newData);
404  void configureCspace(bool state);
405  void setCspaceProjMode(bool pmode);
406  void resizeImage(void);
407  void openViewerEpilogue(rviewFrameType ft);
408  int freeDimsFromProjection(int &dim1, int &dim2, r_Point *map);
409  void ensureViewCspace(void);
410  void deleteViewCspace(void);
411  virtual void projectObjectHook(void);
412  virtual void configureMode(void);
413  virtual char *initMode(void)=0;
414  virtual bool cspaceRangeHook(bool suggest);
415  virtual char *movieNewFrame(void);
416  virtual void rotateObject(wxMouseEvent &mevt);
417  virtual int fileMenuInitHook(wxMenu *menu);
418  virtual int configMenuInitHook(wxMenu *menu);
419  // Query viewer capabilities
420  virtual bool modeNeedsCspace(rviewBaseType bt) const;
421  virtual bool canRotateObject(void) const;
422  virtual bool moviePossible(void) const;
423  virtual bool showScaleSlider(void) const;
424  // view management
425  virtual int saveView(FILE *fp);
426  virtual int readView(const char *key, const char *value);
427  virtual void loadViewFinished(void);
428 
429  wxPixmap *pixmap;
430  pixmapCanvas *pcanv;
431  rviewSlider *scaleSlider;
432  int pixWidth, pixHeight, pixPitch, pixPad, pixDepth;
433  int virtualPitch;
434  char *imgData;
435  double scaleValue;
436  int scrollx, scrolly;
437  float mousex, mousey;
438  int mousebut;
439  unsigned int freeDims;
440  // For intensity to RGB translations (ushort)
441  colourspaceMapper *csmap;
442  bool doValToCspace;
443  bool doFullRangeCspace;
444  bool doProjRangeCspace;
445  // base type allows cspace mapping?
446  bool cspaceForType;
447  // image fully initialized?
448  bool initPhaseFinished;
449  r_Minterval *csInterv;
450  // shared by flat and height field which don't have a shared derivation path
451  rviewButton *playFwd, *playBack, *playStop;
452  int playDirection;
453  int lastMovieMode;
454  // colourspace parameters for view loading
455  colourspace_params *cspar;
456 
457  // view parameters
458  static const char *view_ScrollPos;
459  static const char *view_UseCspace;
460  static const char *view_CspaceFull;
461  static const char *view_CspaceProj;
462  static const char *view_CspaceMeans;
463  static const char *view_CspaceSigmas;
464  static const char *view_CspaceType;
465  static const char *view_CspaceRange;
466  static const char *view_ScaleValue;
467 };
468 
469 
470 /*
471  * Base class for flat images, i.e. 2D orthogonal projections
472  */
473 class rviewFlatBaseImage: public rviewImage
474 {
475 public:
476 
477  rviewFlatBaseImage(mdd_frame *mf, int es, unsigned int flags=0);
478  virtual ~rviewFlatBaseImage(void);
479 
480  virtual int newProjection(void);
481  virtual int openViewer(void);
482 
483  virtual const char *getFrameName(void) const;
484  virtual rviewFrameType getFrameType(void) const;
485 
486 
487 protected:
488 
489  virtual char *initMode(void);
490  char *projectImage(void);
491 };
492 
493 
494 /*
495  * Standard flat images
496  */
497 class rviewFlatImage: public rviewFlatBaseImage
498 {
499 public:
500 
501  rviewFlatImage(mdd_frame *mf, unsigned int flags=0);
502  ~rviewFlatImage(void);
503 
504  void OnSize(int w, int h);
505 
506  virtual int openViewer(void);
507  virtual void label(void);
508  virtual int process(wxObject &obj, wxEvent &evt);
509 
510  virtual const char *getFrameName(void) const;
511  virtual rviewFrameType getFrameType(void) const;
512  virtual int getViewerType(void) const;
513 
514 
515 protected:
516 
517  virtual char *initMode(void);
518  virtual bool moviePossible(void) const;
519  virtual char *movieNewFrame(void);
520 };
521 
522 
523 /*
524  * Abstract base class for all rendered images (voxel, height field, whatever...)
525  */
526 class rviewRenderImage: public rviewImage
527 {
528 public:
529 
530  rviewRenderImage(mdd_frame *mf, int es, unsigned int flags=0);
531  virtual ~rviewRenderImage(void);
532 
533  virtual void label(void);
534  virtual int process(wxObject &obj, wxEvent &evt);
535  virtual int newProjection(void);
536  virtual void prepareToDie(void);
537  virtual int requestQuit(int level);
538  virtual int userEvent(const user_event &ue);
539  virtual void OnSize(int w, int h);
540  virtual void OnMenuCommand(int id);
541  virtual bool OnClose(void);
542 
543  virtual const char *getFrameName(void) const;
544  virtual rviewFrameType getFrameType(void) const;
545 
546  void closeEditor(bool newSetup);
547  void updateSettings(int setFlags);
548 
549  void closeRendererControls(void);
550  void setAutoRotation(float rx, float ry, float rz);
551  void setCurrentView(const vertex_fp &angles, long off, double scale);
552 
553 
554 protected:
555 
556  virtual char *initMode(void);
557  virtual char *setupEnvironment(int w, int h)=0;
558  virtual void rotateObject(wxMouseEvent &mevt);
559  virtual bool doUpdate(int updateFlags)=0;
560  virtual void redrawSettingsChanged(void);
561  virtual void fillBuffer(void)=0;
562  virtual void fillBackgroundCore(rviewBaseType bt, double minVal);
563  virtual int configMenuInitHook(wxMenu *menu);
564  virtual int viewMenuInitHook(wxMenu *menu);
565  virtual bool canRotateObject(void) const;
566  virtual void updateCurrentView(void);
567 
568  int setupEnvBase(int w, int h, r_Ref<r_GMarray> &mdd, colourspaceMapper **csm, r_Minterval *csdom);
569  char *setupGraphEnv(void);
570  void fillBufferBackground(bool doCspace, bool &cspaceOK, r_Ref<r_GMarray>& obj, colourspaceMapper **csm, r_Minterval *csdom, rviewBaseType bt, bool fullRange, double *useMinVal=NULL);
571  void translateBufferToCspace(rviewBaseType bt, double *useMinVal=NULL, double *useMaxVal=NULL);
572  static void rotateCube(int axis, float angle, vertex_fp *matrix);
573  void rotateCube(int axis, float angle);
574  void getLightPos(vertex_fp *lpos);
575 
576  virtual int saveView(FILE *fp);
577  virtual int readView(const char *key, const char *value);
578  virtual void loadViewFinished(void);
579 
580  // convert rotation matrix to angles and back
581  void matrixToAngles(vertex_fp &angles) const;
582  void anglesToMatrix(const vertex_fp &angles);
583 
584  int rendererPlayback;
585  vertex_fp *geomData, *geomUse;
586  vertex_fp *rot;
587  graph_env *graphEnv;
588  union
589  {
590  unsigned long l;
591  float f;
592  double d;
593  } voxColour;
594  long zoff;
595  double cubeScale;
596  // Rotation angle increments for renderer playback
597  float drx, dry, drz;
598  // Setup options
599  rview_image_setup setup;
600  rviewImageSetup *setupWindow;
601  rendererControl *rcontrol;
602  rendererCurrentView *rcurview;
603 
604  // view keywords
605  static const char *view_ZProject;
606  static const char *view_ZClip;
607  static const char *view_PixThreshLow;
608  static const char *view_PixThreshHigh;
609  static const char *view_WeightThresh;
610  static const char *view_WeightQuant;
611  static const char *view_UseRGBBright;
612  static const char *view_UseLighting;
613  static const char *view_LightAmbient;
614  static const char *view_LightGain;
615  static const char *view_LightAngle;
616  static const char *view_LightScint;
617  static const char *view_LightDir;
618  static const char *view_LightDist;
619  static const char *view_KernelSize;
620  static const char *view_KernelType;
621  static const char *view_UseVoxColour;
622  static const char *view_VoxColour;
623  static const char *view_GridSize;
624  static const char *view_ScaleHeight;
625  static const char *view_Rotation;
626  static const char *view_ZOffset;
627 };
628 
629 
630 /*
631  * Class for visualizations of volumetric images (3D texture mapper &
632  * voxel renderer).
633  */
634 class rviewVolumeImage: public rviewRenderImage
635 {
636 public:
637 
638  rviewVolumeImage(mdd_frame *mf, unsigned int flags=0);
639  virtual ~rviewVolumeImage(void);
640 
641  virtual void label(void);
642  virtual int process(wxObject &obj, wxEvent &evt);
643  virtual void OnSize(int w, int h);
644  virtual void OnMenuCommand(int id);
645  virtual int openViewer(void);
646 
647  virtual const char *getFrameName(void) const;
648  virtual rviewFrameType getFrameType(void) const;
649  virtual int getViewerType(void) const;
650 
651 
652 protected:
653 
654  virtual char *initMode(void);
655  virtual char *setupEnvironment(int w, int h);
656  virtual bool doUpdate(int updateFlags);
657  virtual void fillBuffer(void);
658 
659  virtual int saveView(FILE *fp);
660  virtual int readView(const char *key, const char *value);
661  virtual void loadViewFinished(void);
662 
663  rviewCheckBox *boundingBox;
664  rviewImageMode imode;
665  int lastMode;
666  tex_desc *texDesc;
667  voxel_desc *voxDesc;
668  bool initVoxParams;
669  bool doBoundingBox;
670 
671  static const char *view_VolumeMode;
672  static const char *view_UseBBox;
673 };
674 
675 
676 /*
677  * Class for visualizing data as heightfields.
678  */
679 class rviewHeightImage: public rviewRenderImage
680 {
681 public:
682 
683  rviewHeightImage(mdd_frame *mf, unsigned int flags=0);
684  virtual ~rviewHeightImage(void);
685 
686  virtual void label(void);
687  virtual int process(wxObject &obj, wxEvent &evt);
688  virtual int newProjection(void);
689  virtual void prepareToDie(void);
690  virtual int requestQuit(int level);
691  virtual int openViewer(void);
692 
693  virtual const char *getFrameName(void) const;
694  virtual rviewFrameType getFrameType(void) const;
695  virtual int getViewerType(void) const;
696 
697 
698 protected:
699 
700  int depthForHeightfield(void) const;
701  virtual char *initMode(void);
702  virtual char *setupEnvironment(int w, int h);
703  virtual char *movieNewFrame(void);
704  virtual bool doUpdate(int updateFlags);
705  virtual void redrawSettingsChanged(void);
706  virtual void fillBackgroundCore(rviewBaseType bt, double minVal);
707  virtual void fillBuffer(void);
708  virtual bool cspaceRangeHook(bool suggest);
709  virtual bool moviePossible(void) const;
710  virtual bool modeNeedsCspace(rviewBaseType bt) const;
711 
712  mdd_desc *mddDesc;
713  mesh_desc *meshDesc;
714  // for colourspace mapping of heightfields.
715  r_Ref<r_GMarray> dummyMDD;
716 };
717 
718 
719 
720 /*
721  * An image scaled by the DBMS
722  */
723 class r_Fast_Base_Scale;
724 
725 class rviewScaledImage: public rviewFlatBaseImage
726 {
727 public:
728 
729  rviewScaledImage(collection_desc *cd, r_Fast_Base_Scale *scaler, unsigned int flags=0);
730  ~rviewScaledImage(void);
731 
732  virtual void processMouseEvent(wxMouseEvent &mevt);
733  virtual void label(void);
734  virtual int process(wxObject &obj, wxEvent &evt);
735  virtual int openViewer(void);
736  virtual void OnSize(int w, int h);
737  virtual int newProjection(void);
738 
739  virtual const char *getFrameName(void) const;
740  virtual rviewFrameType getFrameType(void) const;
741  virtual int getViewerType(void) const;
742  virtual const r_Minterval &getVirtualDomain(void) const;
743 
744 
745 protected:
746 
747  virtual char *initMode(void);
748  virtual void projectObjectHook(void);
749 
750  char *projectImage(void);
751  bool showScaleSlider(void) const;
752  void scaleViewBy(double scale);
753  void newView(bool loadImage=TRUE);
754  void projectionStringForView(void);
755  double getLastScale(void) const;
756 
757  // view management
758  virtual int saveView(FILE *fp);
759  virtual int readView(const char *key, const char *value);
760  virtual void loadViewFinished(void);
761  void ensureLoadedView(void);
762 
763  rviewButton *zoomInBut;
764  rviewButton *zoomOutBut;
765  rviewButton *lastZoomBut;
766  rviewButton *zoomBoxBut;
767  rviewText *scaleString;
768 
769  bool boxState;
770 
771  typedef struct
772  {
773  double scale;
774  r_Point low, high;
775  int dim1, dim2;
776  } view_desc_t;
777 
778  bool compareViews(const view_desc_t &v1, const view_desc_t &v2);
779 
780  // The current view
781  view_desc_t thisView;
782  r_Minterval fullDomain;
783  bool dontLoad;
784  double initialScale;
785  view_desc_t *loadedView;
786 
787  DynamicStack<view_desc_t> viewHistory;
788 
789  r_Fast_Base_Scale *scaleObject;
790 
791  collection_desc *collDesc;
792 
793  static const double scaleStep;
794 
795  // view parameters
796  static const char *view_CurrentBox;
797  static const char *view_BoxScale;
798 };
799 
800 
801 // Structure for static conversion of MDD -> pixmap
802 typedef struct rviewFlatProjEnv
803 {
804  // initialized by caller
805  r_GMarray *mddPtr;
806  r_Point pt1, pt2;
807  int dim1, dim2;
808  rviewBaseType bt;
809  double scale;
810  bool doCspace;
811  colourspaceMapper *csmap;
812  int cspaceState;
813  // initialized by prepareFlatProjection()
814  int width, height;
815  int pitch, pad, depth;
816 } rviewFlatProjEnv;
817 
818 // Setup variables for projecting images
819 int rviewPrepareFlatProjection(rviewFlatProjEnv &penv);
820 // Project an MDD object into an image bitmap
821 int rviewPerformFlatProjection(rviewFlatProjEnv &env, char *data);
822 
823 
824 
825 
826 
827 
828 enum rviewChartMode
829 {
830  rcm_none,
831  rcm_bar,
832  rcm_line,
833  rcm_spline
834 };
835 
836 /*
837  * Canvas displaying a chart
838  */
839 
840 class chartCanvas: public wxCanvas
841 {
842 public:
843 
844  chartCanvas(wxWindow *parent, int x, int y, int w, int h, long style=0);
845  ~chartCanvas(void);
846 
847  void setData(mdd_frame *mf, rviewBaseType bt);
848  void setVars(int s, double cs, int ds, bool cy, rviewChartMode cm);
849  int setProjection(r_Point &p1, r_Point &p2);
850  void OnPaint(void);
851 
852  // constants
853  // Space reserved on top / bottom of chart
854  static const int chcanv_cospace;
855  // Length of a corrdinate axis marker line
856  static const int chcanv_colength;
857  // Start exponential axis numbering when |exponent| >= x
858  static const int chcanv_exponents;
859 
860 
861 protected:
862 
863  // Core-functionality of chart modes
864  void redrawBar(wxDC *cdc, int height, int dim, int startOff, int endOff, float scale, float posx, float stepx, float orgy);
865  void redrawLine(wxDC *cdc, int dim, int startOff, int endOff, float scale, float posx, float stepx, float orgy);
866  void redrawSpline(wxDC *cdc, int dim, int startOff, int endOff, float scale, float posx, float stepx, float orgy);
867 
868  r_Ref<r_GMarray> mddObj;
869  int step, dimMDD;
870  r_Point pt1, pt2;
871  double min, max, costep;
872  rviewBaseType baseType;
873  rviewChartMode cmode;
874  wxBrush brush, back;
875  wxBrush brush_r, brush_g, brush_b;
876  wxPen pen, pen_r, pen_g, pen_b;
877  wxFont *font;
878  bool cosys;
879  char format[10];
880  int coleft, datastep;
881  int scroll;
882 };
883 
884 
885 /*
886  * A class for drawing charts
887  */
888 
889 class rviewChart: public rviewDisplay
890 {
891 public:
892 
893  rviewChart(mdd_frame *mf, unsigned int flags=0);
894  ~rviewChart(void);
895 
896  void label(void);
897  int process(wxObject &obj, wxEvent &evt);
898  int newProjection(void);
899  virtual int openViewer(void);
900 
901  void OnSize(int w, int h);
902  void OnMenuCommand(int id);
903 
904  virtual const char *getFrameName(void) const;
905  virtual rviewFrameType getFrameType(void) const;
906  virtual int getViewerType(void) const;
907 
908  // constants
909  // Text widget dimensions (step)
910  static const int chart_twidth;
911  static const int chart_theight;
912  // checkbox dims
913  static const int chart_cwidth;
914  static const int chart_cheight;
915  // Minimum size of viewer
916  static const int chart_minwidth;
917  static const int chart_minheight;
918  static const int chart_ctrly;
919  static const int chart_totaly;
920 
921 
922 protected:
923 
924  virtual int saveView(FILE *fp);
925  virtual int readView(const char *key, const char *value);
926  virtual void loadViewFinished(void);
927 
928  void checkModeMenu(void);
929 
930  chartCanvas *canvas;
931  int step, datastep;
932  int lastMode;
933  double costep;
934  int scroll;
935  bool cosys;
936  rviewChartMode cmode;
937  rviewText *stText, *coText, *dataText;
938  rviewCheckBox *csBox;
939 
940  static const char *view_StepSize;
941  static const char *view_Markers;
942  static const char *view_ScrollPos;
943  static const char *view_CoSys;
944  static const char *view_ChartMode;
945 };
946 
947 
948 
949 /*
950  * Canvas for plotting text onto
951  */
952 
953 class textCanvas: public wxCanvas
954 {
955 public:
956 
957  textCanvas(wxWindow *parent, int x, int y, int w, int h, long style=0);
958  ~textCanvas(void);
959 
960  void setData(mdd_frame *mf, rviewBaseType bt, unsigned int bs);
961  void setStep(int sx, int sy);
962  void setCoSys(bool cs, int &cl, int &ct);
963  void setProjection(r_Point &pt1, r_Point &pt2, unsigned int fd, r_Point *mapIndex=NULL);
964  void setNumberBase(int newBase);
965  void OnPaint(void);
966  void CalcTextExtent(char *b, float &width, float &height);
967  void EstimateCellSize(int &width, int &height);
968 
969  // constants
970  // Space around coordinate system
971  static const int txcanv_cospace;
972  // Default space between columns
973  static const int txcanv_colspace;
974  // Border used in text canvas
975  static const int txcanv_border;
976 
977 
978 protected:
979 
980  r_Ref<r_GMarray> mddObj;
981  int stepx, stepy, dimMDD;
982  int scrollX, scrollY;
983  int coleft, cotop;
984  int dim1, dim2;
985  unsigned int freeDims;
986  r_Point pt1, pt2;
987  int numberBase;
988  bool cosys;
989  rviewBaseType baseType;
990  unsigned int baseSize;
991  wxBrush fore, back;
992  wxPen pen;
993  wxFont *font;
994 };
995 
996 
997 
998 /*
999  * Class for displaying tables
1000  */
1001 
1002 class rviewTable: public rviewDisplay
1003 {
1004 public:
1005 
1006  rviewTable(mdd_frame *mf, unsigned int flags=0);
1007  ~rviewTable(void);
1008 
1009  void label(void);
1010  int process(wxObject &obj, wxEvent &evt);
1011  int newProjection(void);
1012  void newTableSize(void);
1013  virtual int openViewer(void);
1014 
1015  virtual const char *getFrameName(void) const;
1016  virtual rviewFrameType getFrameType(void) const;
1017  virtual int getViewerType(void) const;
1018 
1019  void OnSize(int w, int h);
1020  void OnMenuCommand(int id);
1021 
1022  // constants
1023  // Dimensions of additional wxText items (configs)
1024  static const int table_twidth;
1025  static const int table_theight;
1026  // Dimensions of check box
1027  static const int table_cwidth;
1028  static const int table_cheight;
1029  // Minimum dimensions of table
1030  static const int table_minwidth;
1031  static const int table_minheight;
1032  static const int table_ctrly;
1033  static const int table_totaly;
1034 
1035 
1036 protected:
1037 
1038  void EstimateCellSize(int &width, int &height);
1039 
1040  virtual int saveView(FILE *fp);
1041  virtual int readView(const char *key, const char *value);
1042  virtual void loadViewFinished(void);
1043 
1044  void checkModeMenu(void);
1045 
1046  textCanvas *canvas;
1047  int stepx, stepy;
1048  int scrollx, scrolly;
1049  int fieldsx, fieldsy;
1050  int lastMode;
1051  unsigned int freeDims;
1052  bool cosys;
1053  rviewText *sxText, *syText;
1054  rviewCheckBox *csBox;
1055  int numberBase;
1056 
1057  static const char *view_StepSize;
1058  static const char *view_ScrollPos;
1059  static const char *view_CoSys;
1060  static const char *view_NumBase;
1061 };
1062 
1063 
1064 
1065 /*
1066  * Class for displaying strings
1067  */
1068 
1069 class rviewStringViewer: public rviewDisplay
1070 {
1071 public:
1072 
1073  rviewStringViewer(mdd_frame *mf, unsigned int flags=0);
1074  ~rviewStringViewer(void);
1075 
1076  int newProjection(void);
1077  virtual int openViewer(void);
1078 
1079  virtual const char *getFrameName(void) const;
1080  virtual rviewFrameType getFrameType(void) const;
1081  virtual int getViewerType(void) const;
1082 
1083  void OnSize(int w, int h);
1084 
1085  // constants
1086  static const int strview_msgheight;
1087  static const int strview_minwidth;
1088  static const int strview_minheight;
1089  static const int strview_ctrly;
1090  static const int strview_totaly;
1091 
1092 
1093 protected:
1094 
1095  unsigned int freeDims;
1096  wxMessage *msgString;
1097 };
1098 
1099 #endif
#define FALSE
Definition: defs.h:70
#define min(a, b)
Definition: defs.h:78
#define max(a, b)
Definition: defs.h:77
#define TRUE
Definition: defs.h:67