Skip to content

Commit

Permalink
Fix for Ginga upstream deprecation
Browse files Browse the repository at this point in the history
- the move_to(x, y) call on a canvas object has been redefined in terms
  of move_to_pt((x, y)) since Ginga v2.6.5.  move_to() has issued a
  DeprecationWarning since v4.0.0

- this fixes the plugins to use move_to_pt(). It is compatible with
  Ginga back to v2.6.5
  • Loading branch information
ejeschke committed Feb 22, 2024
1 parent 01e377c commit 4b62067
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions stginga/plugins/BackgroundSub.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def update(self, canvas, event, data_x, data_y, viewer):
self.xcen = data_x
self.ycen = data_y

bg_obj.move_to(data_x, data_y)
bg_obj.move_to_pt((data_x, data_y))
tag = canvas.add(bg_obj)
self.draw_cb(canvas, tag)
return True
Expand All @@ -325,7 +325,7 @@ def drag(self, canvas, event, data_x, data_y, viewer):
if bg_obj.kind not in ('compound', 'annulus', 'rectangle'):
return True

bg_obj.move_to(data_x, data_y)
bg_obj.move_to_pt((data_x, data_y))

if obj.kind == 'compound':
try:
Expand Down Expand Up @@ -522,7 +522,7 @@ def set_xcen(self):
y = c_obj.y
else:
y = c_obj.get_center_pt()[1]
c_obj.move_to(self.xcen, y)
c_obj.move_to_pt((self.xcen, y))

self.fitsimage.redraw(whence=3)
return self.redo()
Expand Down Expand Up @@ -552,7 +552,7 @@ def set_ycen(self):
y2 = self.ycen + 0.5 * self.boxheight

# Reposition background region
bg_obj.move_to(x, self.ycen)
bg_obj.move_to_pt((x, self.ycen))

# Reposition label to match
obj.objects[1].y = y2 + self._text_label_offset
Expand Down
10 changes: 5 additions & 5 deletions stginga/plugins/BadPixCorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def update(self, canvas, event, data_x, data_y, viewer):
self.xcen = data_x
self.ycen = data_y

bpx_obj.move_to(data_x, data_y)
bpx_obj.move_to_pt((data_x, data_y))
tag = canvas.add(bpx_obj)
self.draw_cb(canvas, tag)
return True
Expand All @@ -322,7 +322,7 @@ def drag(self, canvas, event, data_x, data_y, viewer):
if bpx_obj.kind not in ('circle', 'point'):
return True

bpx_obj.move_to(data_x, data_y)
bpx_obj.move_to_pt((data_x, data_y))

if obj.kind == 'compound':
try:
Expand All @@ -349,7 +349,7 @@ def draw_cb(self, canvas, tag):

# Round to nearest pixel
x, y = round(obj.x), round(obj.y)
obj.move_to(x, y)
obj.move_to_pt((x, y))

# Change bad pix region appearance
obj.color = self.bpixcorrcolor
Expand Down Expand Up @@ -607,7 +607,7 @@ def set_xcen(self):
y = c_obj.y
else:
y = c_obj.get_center_pt()[1]
c_obj.move_to(self.xcen, y)
c_obj.move_to_pt((self.xcen, y))

self.fitsimage.redraw(whence=3)
return self.redo()
Expand Down Expand Up @@ -638,7 +638,7 @@ def set_ycen(self):
if n_obj == 3:
# Also reposition annulus
ann_obj = obj.objects[1]
ann_obj.move_to(ann_obj.x, self.ycen)
ann_obj.move_to_pt((ann_obj.x, self.ycen))
c_obj.y = (self.ycen + ann_obj.radius + ann_obj.width +
self._text_label_offset)
elif bpx_obj.kind == 'circle': # circle without annulus
Expand Down
8 changes: 4 additions & 4 deletions stginga/plugins/DQInspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ def update(self, canvas, event, data_x, data_y, viewer):
self.xcen = data_x
self.ycen = data_y

pix_obj.move_to(data_x, data_y)
pix_obj.move_to_pt((data_x, data_y))
tag = canvas.add(pix_obj)
self.draw_cb(canvas, tag)
return True
Expand All @@ -555,7 +555,7 @@ def drag(self, canvas, event, data_x, data_y, viewer):
if pix_obj.kind != 'point':
return True

pix_obj.move_to(data_x, data_y)
pix_obj.move_to_pt((data_x, data_y))

if obj.kind == 'compound':
try:
Expand All @@ -582,7 +582,7 @@ def draw_cb(self, canvas, tag):

# Round to nearest pixel
x, y = round(obj.x), round(obj.y)
obj.move_to(x, y)
obj.move_to_pt((x, y))

# Change bad pix region appearance
obj.radius = self._point_radius
Expand Down Expand Up @@ -627,7 +627,7 @@ def set_xcen(self):
# Reposition all elements to match
for c_obj in obj.objects:
if c_obj.kind != 'image':
c_obj.move_to(self.xcen, c_obj.y)
c_obj.move_to_pt((self.xcen, c_obj.y))

self.fitsimage.redraw(whence=3)
return self.redo()
Expand Down
16 changes: 8 additions & 8 deletions stginga/plugins/SNRCalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def update(self, canvas, event, data_x, data_y, viewer):
self.xcen = data_x
self.ycen = data_y

sig_obj.move_to(data_x, data_y)
sig_obj.move_to_pt((data_x, data_y))
tag = canvas.add(sig_obj)
self.draw_cb(canvas, tag)
return True
Expand All @@ -533,7 +533,7 @@ def drag(self, canvas, event, data_x, data_y, viewer):
if sig_obj.kind not in ('circle', 'polygon', 'rectangle'):
return True

sig_obj.move_to(data_x, data_y)
sig_obj.move_to_pt((data_x, data_y))

if obj.kind == 'compound':
try:
Expand Down Expand Up @@ -691,12 +691,12 @@ def align_centers(self):
self.w.bg_y.set_text(str(self.bgycen))

# Reposition annulus
obj.objects[1].move_to(self.bgxcen, self.bgycen)
obj.objects[1].move_to_pt((self.bgxcen, self.bgycen))

# Reposition label
yt = (self.bgycen + self.bgradius + self.annulus_width +
self._text_label_offset)
obj.objects[2].move_to(self.bgxcen, yt)
obj.objects[2].move_to_pt((self.bgxcen, yt))

self.fitsimage.redraw(whence=3)
return self.redo()
Expand All @@ -723,7 +723,7 @@ def set_xcen(self):

else: # polygon, rectangle
y = sig_obj.get_center_pt()[1]
sig_obj.move_to(self.xcen, y)
sig_obj.move_to_pt((self.xcen, y))

self.fitsimage.redraw(whence=3)
return self.redo()
Expand All @@ -750,7 +750,7 @@ def set_ycen(self):

else: # polygon, rectangle
x = sig_obj.get_center_pt()[0]
sig_obj.move_to(x, self.ycen)
sig_obj.move_to_pt((x, self.ycen))

self.fitsimage.redraw(whence=3)
return self.redo()
Expand Down Expand Up @@ -852,7 +852,7 @@ def set_bgxcen(self):
# Reposition annulus and label
for i in (1, 2):
cobj = obj.objects[i]
cobj.move_to(self.bgxcen, cobj.y)
cobj.move_to_pt((self.bgxcen, cobj.y))

self.fitsimage.redraw(whence=3)
return self.redo()
Expand All @@ -874,7 +874,7 @@ def set_bgycen(self):

# Reposition annulus
ann_obj = obj.objects[1]
ann_obj.move_to(ann_obj.x, self.bgycen)
ann_obj.move_to_pt((ann_obj.x, self.bgycen))

# Reposition label
obj.objects[2].y = (ann_obj.y + ann_obj.radius + ann_obj.width +
Expand Down

0 comments on commit 4b62067

Please sign in to comment.