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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
// Copyright (C) 1999-2017
// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
// For conditions of distribution and use, see copyright notice in "copyright"
#include <tk.h>
#include "composite.h"
#include "fitsimage.h"
Composite::Composite(const Composite& a) : Marker(a)
{
members = a.members;
global = a.global;
}
Composite::Composite(Base* p, const Vector& ctr,
double ang, int gl,
const char* clr, int* dsh,
int wth, const char* fnt, const char* txt,
unsigned short prop, const char* cmt,
const List<Tag>& tg, const List<CallBack>& cb)
: Marker(p, ctr, ang, clr, dsh, wth, fnt, txt, prop, cmt, tg, cb)
{
strcpy(type_, "composite");
global = gl;
handle = new Vector[4];
numHandle = 4;
updateBBox();
}
void Composite::x11(Drawable drawable, Coord::InternalSystem sys,
int tt, RenderMode mode, HandleMode hh)
{
if (properties & HIDDEN)
return;
if (hh==HANDLES)
renderXHandles(drawable);
if (tt)
renderXText(drawable, sys, mode);
Marker* mk=members.head();
while (mk) {
Marker* m = mk->dup();
m->setComposite(fwdMatrix(), angle);
if (global)
m->setComposite(colorName, lineWidth, highlited);
m->x11(drawable, sys, tt, mode, hh);
delete m;
mk=mk->next();
}
}
void Composite::ps(int mode, int tt)
{
if (tt)
renderPSText(mode);
Marker* mk=members.head();
while (mk) {
Marker* m = mk->dup();
m->setComposite(fwdMatrix(), angle);
if (global)
m->setComposite(colorName, lineWidth, highlited);
m->ps(mode,tt);
delete m;
mk=mk->next();
}
}
#ifdef MAC_OSX_TK
void Composite::macosx(int tt)
{
if (tt)
renderMACOSXText();
Marker* mk=members.head();
while (mk) {
Marker* m = mk->dup();
m->setComposite(fwdMatrix(), angle);
if (global)
m->setComposite(colorName, lineWidth, highlited);
m->macosx(tt);
delete m;
mk=mk->next();
}
}
#endif
#ifdef __WIN32
void Composite::win32(int tt)
{
if (tt)
renderWIN32Text();
Marker* mk=members.head();
while (mk) {
Marker* m = mk->dup();
m->setComposite(fwdMatrix(), angle);
if (global)
m->setComposite(colorName, lineWidth, highlited);
m->win32(tt);
delete m;
mk=mk->next();
}
}
#endif
// Support
void Composite::updateHandles()
{
BBox bb(center * bckMatrix());
Marker* mk=members.head();
while (mk) {
Marker* m = mk->dup();
m->setComposite(fwdMatrix(), angle);
for(int ii=0; ii<m->getNumHandle(); ii++)
bb.bound(bckMap(m->getHandle(ii),Coord::CANVAS));
delete m;
mk=mk->next();
}
bb.expand(3); // a little more room around the edges
handle[0] = fwdMap(bb.ll,Coord::CANVAS);
handle[1] = fwdMap(bb.lr(),Coord::CANVAS);
handle[2] = fwdMap(bb.ur,Coord::CANVAS);
handle[3] = fwdMap(bb.ul(),Coord::CANVAS);
}
void Composite::updateCoords(const Matrix& mx)
{
Marker* mk=members.head();
while (mk) {
Vector cc = center;
mk->setComposite(fwdMatrix(), angle);
mk->updateCoords(mx);
center = cc*mx;
mk->setComposite(bckMatrix(), -angle);
center = cc;
mk=mk->next();
}
Marker::updateCoords(mx);
}
int Composite::isIn(const Vector& v)
{
if (!bbox.isIn(v))
return 0;
Marker* mk=members.head();
while (mk) {
Marker* m = mk->dup();
m->setComposite(fwdMatrix(), angle);
if (m->isIn(v)) {
delete m;
return 1;
}
delete m;
mk=mk->next();
}
return 0;
}
void Composite::append(Marker* m)
{
m->setComposite(bckMatrix(), -angle);
members.append(m);
}
Marker* Composite::extract()
{
Marker* mk=members.head();
if (mk) {
members.extractNext(mk);
mk->setComposite(fwdMatrix(), angle);
}
return mk;
}
// list
void Composite::list(ostream& str, Coord::CoordSystem sys, Coord::SkyFrame sky,
Coord::SkyFormat format, int conj, int strip)
{
if (!strip) {
FitsImage* ptr = parent->findFits(sys,center);
listPre(str, sys, sky, ptr, strip, 1);
switch (sys) {
case Coord::IMAGE:
case Coord::PHYSICAL:
case Coord::DETECTOR:
case Coord::AMPLIFIER:
{
Vector vv = ptr->mapFromRef(center,sys);
str << type_ << '(' << setprecision(8) << vv << ','
<< radToDeg(parent->mapAngleFromRef(angle,sys)) << ')';
}
break;
default:
if (ptr->hasWCSCel(sys)) {
switch (format) {
case Coord::DEGREES:
{
Vector vv = ptr->mapFromRef(center,sys,sky);
str << type_ << '(' << setprecision(10) << vv << ','
<< setprecision(8)
<< radToDeg(parent->mapAngleFromRef(angle,sys,sky)) << ')';
}
break;
case Coord::SEXAGESIMAL:
listRADEC(ptr,center,sys,sky,format);
str << type_ << '(' << ra << ',' << dec << ','
<< setprecision(8)
<< radToDeg(parent->mapAngleFromRef(angle,sys,sky)) << ')';
break;
}
}
else {
Vector vv = ptr->mapFromRef(center,sys);
str << type_ << '(' << setprecision(8) << vv << ','
<< radToDeg(parent->mapAngleFromRef(angle,sys)) << ')';
}
}
str << " ||";
str << " composite=" << global;
listProperties(str, 0);
}
Marker* mk=members.head();
while (mk) {
Marker* m = mk->dup();
mk=mk->next();
m->setComposite(fwdMatrix(), angle);
m->list(str, sys, sky, format, (mk?1:0), strip);
delete m;
}
}
void Composite::listCiao(ostream& str, Coord::CoordSystem sys, int strip)
{
Marker* mk=members.head();
while (mk) {
Marker* m = mk->dup();
mk=mk->next();
m->setComposite(fwdMatrix(), angle);
m->listCiao(str, sys, strip);
delete m;
}
}
void Composite::listPros(ostream& str, Coord::CoordSystem sys,
Coord::SkyFrame sky, Coord::SkyFormat format,
int strip)
{
Marker* mk=members.head();
while (mk) {
Marker* m = mk->dup();
m->setComposite(fwdMatrix(), angle);
m->listPros(str, sys, sky, format, strip);
delete m;
mk=mk->next();
}
}
void Composite::listSAOtng(ostream& str, Coord::CoordSystem sys,
Coord::SkyFrame sky, Coord::SkyFormat format,
int strip)
{
Marker* mk=members.head();
while (mk) {
Marker* m = mk->dup();
m->setComposite(fwdMatrix(), angle);
m->listSAOtng(str, sys, sky, format, strip);
delete m;
mk=mk->next();
}
}
void Composite::listSAOimage(ostream& str, int strip)
{
Marker* mk=members.head();
while (mk) {
Marker* m = mk->dup();
m->setComposite(fwdMatrix(), angle);
m->listSAOimage(str, strip);
delete m;
mk=mk->next();
}
}
void Composite::listXY(ostream& str, Coord::CoordSystem sys,
Coord::SkyFrame sky, Coord::SkyFormat format,
int strip)
{
Marker* mk=members.head();
while (mk) {
Marker* m = mk->dup();
m->setComposite(fwdMatrix(), angle);
m->listXY(str, sys, sky, format, strip);
delete m;
mk=mk->next();
}
}
|