-
Notifications
You must be signed in to change notification settings - Fork 2
/
PProjImage.h
86 lines (71 loc) · 3.54 KB
/
PProjImage.h
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
//==============================================================================
// File: PProjImage.h
//
// Copyright (c) 2017, Phil Harvey, Queen's University
//==============================================================================
#ifndef __PProjImage_h__
#define __PProjImage_h__
#include <Xm/Xm.h>
#include "PImageCanvas.h"
#include "matrix.h"
#define THIN_LINE_WIDTH 0.15
#define THICK_LINE_WIDTH 0.5
// default event mask for projection images
const EventMask kProjImageEvents = PointerMotionMask | ButtonPressMask |
ButtonReleaseMask | LeaveWindowMask;
enum EAngleFlags {
kAngleTheta = 0x01,
kAnglePhi = 0x02,
kAngleGamma = 0x04,
kAngleAll = kAngleTheta | kAnglePhi | kAngleGamma
};
struct Projection {
Matrix3 rot; /* rotation matrix */
Matrix3 inv; /* inverse rotation matrix */
Vector3 pt; /* projection point */
int xscl; /* pixel radius of unit sphere (x) */
int yscl; /* pixel radius of unit sphere (y) */
float mag; /* magnification factor for image */
int xcen,ycen; /* center of image in window coordinates */
int xsiz,ysiz; /* width and height of drawing window */
float proj_min; /* minimum z position of projection point */
float proj_max; /* maximum z position of projection point */
float proj_screen; /* z position of projection screen */
int proj_type; /* integer specifying type of projection */
float theta; /* projection theta rotation (optional) */
float phi; /* projection phi rotation (optional) */
float gamma; /* projection gamma rotation (optional) */
};
struct Node;
/* class definition */
class PProjImage : public PImageCanvas {
public:
PProjImage(PImageWindow *owner, Widget canvas, EventMask eventMask=kProjImageEvents);
virtual ~PProjImage();
virtual void Resize();
virtual void HandleEvents(XEvent *event);
virtual void Transform(Node *node, int num_nodes) { }
virtual void TransformHits();
virtual void SetScrolls();
virtual void ScrollValueChanged(EScrollBar bar, int value);
virtual void SetToHome(int n=0);
virtual void DrawAngles(int horiz=0, int angleFlags=kAngleTheta|kAnglePhi);
virtual void Listen(int message, void *data);
Projection * GetProj() { return &mProj; }
static int IsButtonDown() { return sButtonDown; }
virtual int FindNearestHit();
long HiddenHitMask();
protected:
int HandleButton3(XEvent *event);
static int sButtonDown;
Projection mProj; /* projection */
float mImageSizeX; /* half width of image (user units) */
float mImageSizeY; /* half height of image (user units) */
int mScaleProportional; /* non-zero if scale must be the same in X and Y */
int mMarginPix; /* pixel margin outside image */
float mMarginFactor; /* factor to be applied to image size for additional margin */
float mMinMagAtan; /* atan() of minimum magnification */
float mDiffMagAtan; /* atan(max_mag) - atan(min_mag) */
int mInvisibleHits; /* mask for hit types not displayed */
};
#endif // __PProjImage_h__