Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

# 

# LSST Data Management System 

# Copyright 2008, 2009, 2010, 2015 LSST Corporation. 

# 

# This product includes software developed by the 

# LSST Project (http://www.lsst.org/). 

# 

# This program is free software: you can redistribute it and/or modify 

# it under the terms of the GNU General Public License as published by 

# the Free Software Foundation, either version 3 of the License, or 

# (at your option) any later version. 

# 

# This program is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

# GNU General Public License for more details. 

# 

# You should have received a copy of the LSST License Statement and 

# the GNU General Public License along with this program. If not, 

# see <http://www.lsstcorp.org/LegalNotices/>. 

# 

 

## 

# @file 

# @brief A dummy image display 

 

 

class DisplayImpl: 

def __init__(self, display, verbose=False): 

"""! Initialise the display 

@param display The display object that we're providing the implementation for 

@param verbose be chatty? 

""" 

self.display = display 

self.verbose = verbose 

 

def __del__(self): 

self._close() 

 

def _close(self): 

"""!Close the display, cleaning up any allocated resources""" 

if hasattr(self, "verbose") and self.verbose and hasattr(self, "display"): 

print("virtual[%s]._close()" % (self.frame)) 

 

def _buffer(self, enable=True): 

"""!Enable or disable buffering of writes to the display 

@param enable True or False, as appropriate 

""" 

49 ↛ exitline 49 didn't return from function '_buffer', because the condition on line 49 was never false if self.verbose: 

print("virtual[%s]._buffer(%s)" % (self.frame, enable)) 

 

def _dot(self, symb, c, r, size, ctype, *args, **kwargs): 

"""!Draw symbol a symbol at (c, r) 

@param symb The desired symbol. See dot() for details 

@param c (x) column position 

@param r (y) row position 

@param size Size of symbol, in pixels 

@param ctype The desired colour, either e.g. afw.display.RED or a colour name known to X11 

@param args Extra arguments 

@param kwargs Extra keyword arguments 

""" 

if self.verbose: 

print("virtual[%s]._dot('%s', %.2f, %.2f, size=%g, ctype=%s, %s, %s)" % 

(self.frame, symb, c, r, size, ctype, args, kwargs)) 

 

def _drawLines(self, points, ctype): 

"""!Draw line defined by the list points 

@param points A list of 0-indexed positions [(x, y), (x, y), ...] 

@param ctype The desired colour, either e.g. afw.display.RED or a colour name known to X11 

""" 

71 ↛ exitline 71 didn't return from function '_drawLines', because the condition on line 71 was never false if self.verbose: 

print("virtual[%s]._drawLines(%s, ctype=%s)" % 

(self.frame, points, ctype)) 

 

def _erase(self): 

"""!Erase all glyphs drawn on display 

""" 

if self.verbose: 

print("virtual[%s]._erase()" % (self.frame)) 

 

def _flush(self): 

"""!Flush any I/O buffers 

""" 

84 ↛ exitline 84 didn't return from function '_flush', because the condition on line 84 was never false if self.verbose: 

print("virtual[%s]._flush()" % self.frame) 

 

def _setCallback(self, what, func): 

88 ↛ 89line 88 didn't jump to line 89, because the condition on line 88 was never true if self.verbose > 1: 

print("setCallback %s -> %s" % (what, func)) 

 

def _getEvent(self): 

"""Return an event generated by a keypress or mouse click 

""" 

from .interface import Event 

ev = Event("q") 

 

97 ↛ 100line 97 didn't jump to line 100, because the condition on line 97 was never false if self.verbose: 

print("virtual[%s]._getEvent() -> %s" % (self.frame, ev)) 

 

return ev 

 

def _getMaskTransparency(self): 

"""Return the mask transparency for a display 

""" 

if self.verbose: 

print("virtual[%s]._getMaskTransparency()" % self.frame) 

 

def _mtv(self, image, wcs=None, mask=None, title=""): 

"""Display an image and maybe a mask overlay on a display 

@param image afwImage.Image to display 

@param mask afwImage.Mask to display 

@param wcs A Wcs to associate with data 

@param title Name to display with the data 

""" 

if self.verbose: 

print("virtual[%s]._mtv(image=%s, mask=%s, wcs=%s, title=\"%s\")" % 

(self.frame, "Image" if image else None, 

"Mask" if mask else None, "Wcs" if wcs else None, title)) 

 

def _setImageColormap(self, cmap): 

"""Set the desired colourmap 

 

@param the name of a colourmap (e.g. "gray") or a backend-specific object 

""" 

if self.verbose: 

print("virtual[%s]._setImageColormap(cmap=\"%s\")" % (self.frame, cmap)) 

 

def _setMaskTransparency(self, transparency, maskplane): 

"""Set the transparency of a maskplane 

@param transparency The desired transparency, in the range [0, 100] 

@param maskplane The maskplane to set (None: all) 

""" 

if self.verbose: 

print("virtual[%s]._setMaskTransparency(%g, maskplane=\"%s\")" % 

(self.frame, transparency, maskplane)) 

 

def _scale(self, algorithm, min, max, unit=None, *args, **kwargs): 

"""Set the scaling from DN to displayed pixels 

@param algorithm Scaling algorithm (e.g. linear) 

@param min The minimum value of the stretch (or "zscale" or "minmax") 

@param max The maximum value of the stretch 

@param unit Units for min and max (e.g. Percent, Absolute, Sigma) 

@param *args Optional arguments 

@param **kwargs Optional keyword arguments 

""" 

146 ↛ exitline 146 didn't return from function '_scale', because the condition on line 146 was never false if self.verbose: 

print("virtual[%s]._scale(%s, %s, %s, %s, %s, %s)" % (self.frame, algorithm, 

min, max, unit, args, kwargs)) 

 

def _show(self): 

"""Show the requested display 

""" 

153 ↛ exitline 153 didn't return from function '_show', because the condition on line 153 was never false if self.verbose: 

print("virtual[%s]._show()" % self.frame) 

 

def _pan(self, r, c): 

"""Pan to (colc, rowc) 

@param c Desired column (x) position 

@param r Desired row (y) position 

""" 

if self.verbose: 

print("virtual[%s]._pan(%.2f, %.2f)" % (self.frame, r, c)) 

 

def _zoom(self, zoomfac): 

"""Set the zoom 

@param zoomfac Zoom factor to use 

""" 

if self.verbose: 

print("virtual[%s]._zoom(%g)" % (self.frame, zoomfac))