summaryrefslogtreecommitdiffstats
path: root/tksao/frame/frame3dbase.h
blob: 5b2f6142911293e3883067292f9702d2dddf9261 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
// Copyright (C) 1999-2018
// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
// For conditions of distribution and use, see copyright notice in "copyright"

#ifndef __frame3dbase_h__
#define __frame3dbase_h__

#include "base.h"
#include "raytrace.h"

class Grid3d;

class Frame3dBase : public Base {
  friend class Grid3d;

 public:
  enum RenderMethod {MIP,AIP};
  enum MotionType {NONE,AZIMUTH,ELEVATION};

 protected:
  int zdepth_;
  double zzoom_;
  double zscale_;
  Vector3d vp_;
  Vector viewCursor_;

  float az_;
  float el_;
  RenderMethod renderMethod_;

  List<RayTrace> cache_;
  List<RayTrace> pannerCache_;
  int preservecache_;
  
  MotionType render_;     // enable background rendering

  GC threedGC;

  int border_;
  char* borderColorName_;
  int compass_;
  char* compassColorName_;
  int highlite_;
  char* highliteColorName_;

  double cropsl_;

  Matrix3d refToUser3d;
  Matrix3d userToRef3d;
  Matrix3d refToWidget3d;
  Matrix3d widgetToRef3d;
  Matrix3d refToCanvas3d;
  Matrix3d canvasToRef3d;
  Matrix3d refToWindow3d;
  Matrix3d windowToRef3d;

  Matrix3d userToWidget3d;
  Matrix3d widgetToUser3d;
  Matrix3d userToCanvas3d;
  Matrix3d canvasToUser3d;
  Matrix3d userToWindow3d;
  Matrix3d windowToUser3d;

  Matrix3d widgetToCanvas3d;
  Matrix3d canvasToWidget3d;
  Matrix3d widgetToWindow3d;
  Matrix3d windowToWidget3d;

  Matrix3d canvasToWindow3d;
  Matrix3d windowToCanvas3d;

  Matrix3d refToMagnifier3d;
  Matrix3d magnifierToRef3d;
  Matrix3d userToMagnifier3d;
  Matrix3d magnifierToUser3d;
  Matrix3d widgetToMagnifier3d;
  Matrix3d magnifierToWidget3d;

  Matrix3d refToPanner3d;
  Matrix3d pannerToRef3d;
  Matrix3d userToPanner3d;
  Matrix3d pannerToUser3d;
  Matrix3d widgetToPanner3d;
  Matrix3d pannerToWidget3d;

 private:
  void calcBorder(Coord::InternalSystem, FrScale::SecMode mode,
		  Vector3d* vv, int* dd);
  void calcHighlite(Coord::InternalSystem, Vector*, int*);
  void coordToTclArray(FitsImage*, const Vector3d&, Coord::CoordSystem, 
		       const char*, const char*);

  void getInfoWCS(char*, Vector3d&, FitsImage*, FitsImage*);

 protected:
  double calcZoomPanner();
  double calcZoom3d(Vector3d, Vector);
  virtual void cancelDetach() =0;
  void centerImage();


  int isAzElZero() {return !az_ && !el_;}

  Vector3d imageCenter3d(FrScale::SecMode);
  Vector3d imageSize3d(FrScale::SecMode);

  void psColor(PSColorSpace, const char*);
  void psLine(Vector&, Vector&, int);
  void psWidth(int);
  void psGraphics(PSColorSpace mode);
  void psBorder(PSColorSpace mode);
  void psCompass(PSColorSpace mode);
  void psHighlite(PSColorSpace mode);
  Matrix3d psMatrix(float scale, int width, int height);

  void setBinCursor() {}

  void updateBin(const Matrix&);
  void updateBlock(const Vector&);
  void updateGCs();
  void updateMagnifierMatrices();
  void updatePannerMatrices();
  void updateMatrices();
  void updatePanner();

  void x11Line(Vector, Vector, int, GC, Pixmap);
  void x11Graphics();
  void x11Border(Coord::InternalSystem, FrScale::SecMode, GC, Pixmap);
  void x11Compass();
  void x11Highlite();
  void ximageToPixmapMagnifier();

 public:
  Frame3dBase(Tcl_Interp*, Tk_Canvas, Tk_Item*);
  virtual ~Frame3dBase();

  FrameType frameType() {return F3D;}

  void setSlice(int,int);

  Vector mapFromRef(const Vector& vv, Coord::InternalSystem sys)
  {return mapFromRef3d(vv,sys);}
  Vector3d mapFromRef3d(const Vector&, Coord::InternalSystem);
  Vector3d mapFromRef3d(const Vector&, Coord::InternalSystem, double);
  Vector mapToRef(const Vector& vv, Coord::InternalSystem sys)
  {return mapToRef3d(vv,sys);}
  Vector3d mapToRef3d(const Vector&, Coord::InternalSystem);
  Vector3d mapToRef3d(const Vector&, Coord::InternalSystem, double);

  // Bin Commands
  void binToFitCmd();

  // Block Commands
  void blockToFitCmd();

  // Clip Commands
  void clipScopeCmd(FrScale::ClipScope) {} // scope is always GLOBAL

  // Info Commands
  void getInfoCmd(const Vector&, Coord::InternalSystem, char*);

  // Coordinate Commands
  void getCursorCmd(Coord::InternalSystem);
  void getCursorCmd(Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat);

  // Crop Commands
  void crop3dBeginCmd(const Vector&, int);
  void crop3dMotionCmd(const Vector&, int);
  void crop3dEndCmd(const Vector&, int);

  // Grid Commands
  void gridCmd(Coord::CoordSystem, Coord::SkyFrame, Coord::SkyFormat, 
	       Grid::GridType, const char*, const char*);

  // Pan Zoom Rotate Orient Commands
  void panCmd(const Vector&);
  void panCmd(const Vector&, const Vector&);
  void panCmd(const Vector&, Coord::CoordSystem, Coord::SkyFrame);
  void panToCmd(const Vector&);
  void panToCmd(const Vector&, Coord::CoordSystem, Coord::SkyFrame);
  void panBBoxCmd(const Vector&);
  void panEndCmd(const Vector&);
  void rotateBeginCmd();
  void rotateMotionCmd(double);
  void rotateEndCmd();
  void zoomAboutCmd(const Vector&, const Vector&);
  void zoomAboutCmd(const Vector&, const Vector&, Coord::CoordSystem, Coord::SkyFrame);
  void zoomToAboutCmd(const Vector&, const Vector&);
  void zoomToAboutCmd(const Vector&, const Vector&, Coord::CoordSystem, Coord::SkyFrame);
  void zoomToFitCmd(double);

  // 3d Commands
  void get3dBorderCmd();
  void get3dBorderColorCmd();
  void get3dCompassCmd();
  void get3dCompassColorCmd();
  void get3dHighliteCmd();
  void get3dHighliteColorCmd();
  void get3dRenderMethodCmd();
  void get3dRenderBackgroundCmd();
  void get3dScaleCmd();
  void get3dViewCmd();
  void get3dViewPointCmd();
  void set3dBorderCmd(int);
  void set3dBorderColorCmd(const char*);
  void set3dCompassCmd(int);
  void set3dCompassColorCmd(const char*);
  void set3dHighliteCmd(int);
  void set3dHighliteColorCmd(const char*);
  void set3dRenderMethodCmd(int);
  void set3dRenderBackgroundCmd(int);
  void set3dPreserveCmd();
  void set3dScaleCmd(double);
  void set3dViewCmd(float, float);
  void set3dViewPointCmd(const Vector3d&, const Vector&);

#ifdef MAC_OSX_TK
  void macosxLine(Vector&, Vector&, int);
  void macosxGraphics();
  void macosxBorder();
  void macosxCompass();
  void macosxHighlite();
#endif
#ifdef __WIN32
  void win32Line(Vector&, Vector&, int);
  void win32Graphics();
  void win32Border();
  void win32Compass();
  void win32Highlite();
#endif
};

#endif