Exemplo n.º 1
0
    def gki_text(self, arg):

        self.wcs.commit()
        x = gki.ndc(arg[0])
        y = gki.ndc(arg[1])
        text = arg[3:].astype(Numeric.Int8).tostring()
        self._tkplotAppend(self.tkplot_text, x, y, text)
Exemplo n.º 2
0
    def gki_text(self, arg):

        self.wcs.commit()
        x = gki.ndc(arg[0])
        y = gki.ndc(arg[1])
        text = ndarr2str(arg[3:].astype(numpy.int8))
        self._tkplotAppend(self.tkplot_text, x, y, text)
Exemplo n.º 3
0
    def gki_text(self, arg):

        self.wcs.commit()
        x = gki.ndc(arg[0])
        y = gki.ndc(arg[1])
        text = ndarr2str(arg[3:].astype(numpy.int8))
        self._tkplotAppend(self.tkplot_text, x, y, text)
Exemplo n.º 4
0
    def gki_text(self, arg):

        """ Instructed to draw some GKI text """
        # record this operation as a tuple in the draw buffer
        self._plotAppend(self.gki_text, arg)

        # commit pending WCS changes
        self.wcs.commit()

        # add the text
        x = gki.ndc(arg[0])
        y = gki.ndc(arg[1])
        text = ndarr2str(arg[3:].astype(numpy.int8))
        ta = self.textAttributes

        # For now, force this to be non-bold for decent looking plots.  It
        # seems (oddly) that IRAF/GKI tends to overuse boldness in graphics.
        # A fix to mpl (near 0.91.2) makes bold text show as reeeeally bold.
        # However, assume the user knows what they are doing with their
        # settings if they have set a non-standard (1.0) charSize.
        weight = 'normal'
        if (MPL_MAJ_MIN < 0.91) or (abs(ta.charSize - 1.0) > .0001):
           # only on these cases do we pay attention to 'bold' in textFont
           if ta.textFont.find('bold') >= 0: weight = 'bold'

        style = 'italic'
        if ta.textFont.find('italic') < 0: style = 'normal'
        # Calculate initial fontsize
        fsz = self.getTextPointSize(ta.charSize, self.__xsz, self.__ysz)
        # figure rotation angle
        rot = self.calculateMplTextAngle(ta.charUp, ta.textPath)
        # Kludge alert - only use the GKI_TEXT_Y_OFFSET in cases where
        # we know the text is a simple level label (not in a contour, etc)
        yOffset = 0.0
        if abs(rot) < .0001 and ta.textHorizontalJust=='center':
           yOffset = GKI_TEXT_Y_OFFSET
        # Note that we add the text here in NDC (0.0-1.0) x,y and that
        # the fig takes care of resizing for us.
        t = self.__fig.text(x, y-yOffset, text, \
             color=ta.textColor,
             rotation=rot,
             horizontalalignment=ta.textHorizontalJust,
             verticalalignment=ta.textVerticalJust,
             fontweight=weight, # [ 'normal' | 'bold' | ... ]
             fontstyle=style,   # [ 'normal' | 'italic' | 'oblique']
             fontsize=fsz)
        # To this Text object just created, we need to attach the GKI charSize
        # scale factor, since we will need it later during a resize.  Mpl
        # knows nothing about this, but we support it for GKI.
        t.gkiTextSzFactor = ta.charSize # add attribute
Exemplo n.º 5
0
    def gki_text(self, arg):
        """ Instructed to draw some GKI text """
        # record this operation as a tuple in the draw buffer
        self._plotAppend(self.gki_text, arg)

        # commit pending WCS changes
        self.wcs.commit()

        # add the text
        x = gki.ndc(arg[0])
        y = gki.ndc(arg[1])
        text = ndarr2str(arg[3:].astype(numpy.int8))
        ta = self.textAttributes

        # For now, force this to be non-bold for decent looking plots.  It
        # seems (oddly) that IRAF/GKI tends to overuse boldness in graphics.
        # A fix to mpl (near 0.91.2) makes bold text show as reeeeally bold.
        # However, assume the user knows what they are doing with their
        # settings if they have set a non-standard (1.0) charSize.
        weight = 'normal'
        if (MPL_MAJ_MIN < 0.91) or (abs(ta.charSize - 1.0) > .0001):
            # only on these cases do we pay attention to 'bold' in textFont
            if ta.textFont.find('bold') >= 0: weight = 'bold'

        style = 'italic'
        if ta.textFont.find('italic') < 0: style = 'normal'
        # Calculate initial fontsize
        fsz = self.getTextPointSize(ta.charSize, self.__xsz, self.__ysz)
        # figure rotation angle
        rot = self.calculateMplTextAngle(ta.charUp, ta.textPath)
        # Kludge alert - only use the GKI_TEXT_Y_OFFSET in cases where
        # we know the text is a simple level label (not in a contour, etc)
        yOffset = 0.0
        if abs(rot) < .0001 and ta.textHorizontalJust == 'center':
            yOffset = GKI_TEXT_Y_OFFSET
        # Note that we add the text here in NDC (0.0-1.0) x,y and that
        # the fig takes care of resizing for us.
        t = self.__fig.text(x, y-yOffset, text, \
             color=ta.textColor,
             rotation=rot,
             horizontalalignment=ta.textHorizontalJust,
             verticalalignment=ta.textVerticalJust,
             fontweight=weight, # [ 'normal' | 'bold' | ... ]
             fontstyle=style,   # [ 'normal' | 'italic' | 'oblique']
             fontsize=fsz)
        # To this Text object just created, we need to attach the GKI charSize
        # scale factor, since we will need it later during a resize.  Mpl
        # knows nothing about this, but we support it for GKI.
        t.gkiTextSzFactor = ta.charSize  # add attribute
Exemplo n.º 6
0
    def gki_pmset(self, arg):

        marktype = arg[0]
        #XXX Is this scaling for marksize correct?
        marksize = gki.ndc(arg[1])
        color = arg[2]
        self._tkplotAppend(self.tkplot_pmset, marktype, marksize, color)
Exemplo n.º 7
0
    def gki_fillarea(self, arg):

        """ Instructed to draw a GKI fillarea """
        # record this operation as a tuple in the draw buffer
        self._plotAppend(self.gki_fillarea, arg)

        # commit pending WCS changes
        self.wcs.commit()

        # plot the fillarea
        fa = self.fillAttributes
        verts = gki.ndc(arg[1:])
        # fillstyle 0=clear,  1=hollow,  2=solid,  3-6=hatch
        # default case is 'solid' (fully filled solid color)
        # 'hatch' case seems to be unused
        ec = fa.color
        fc = fa.color
        fll = 1
        if fa.fillstyle == 0: # 'clear' (fully filled with black)
            ec = self.colorManager.setDrawingColor(0)
            fc = ec
            fll = 1
        if fa.fillstyle == 1: # 'hollow' (just the rectangle line, empty)
            ec = fa.color
            fc = None
            fll = 0
        lowerleft = (verts[0], verts[1])
        width  = verts[4]-verts[0]
        height = verts[5]-verts[1]
        rr = Rectangle(lowerleft, width, height,
                       edgecolor=ec, facecolor=fc, fill=fll)
        self.__normPatches.append(rr)
Exemplo n.º 8
0
    def gki_pmset(self, arg):

        marktype = arg[0]
        #XXX Is this scaling for marksize correct?
        marksize = gki.ndc(arg[1])
        color = arg[2]
        self._tkplotAppend(self.tkplot_pmset, marktype, marksize, color)
Exemplo n.º 9
0
    def gki_polymarker(self, arg):

        """ Instructed to draw a GKI polymarker.  IRAF only implements
        points for polymarker, so that makes it simple. """
        # record this operation as a tuple in the draw buffer
        self._plotAppend(self.gki_polymarker, arg)

        # commit pending WCS changes when draw is found
        self.wcs.commit()

        # Reshape to get x's and y's
        # arg[0] is the num pairs, so: len(arg)-1 == 2*arg[0]
        verts = gki.ndc(arg[1:])
        rshpd = verts.reshape(arg[0],2)
        xs = rshpd[:,0]
        ys = rshpd[:,1]

        # put the normalized data into a Line2D object, append to our list
        # later we will scale it and append it to the fig.  See performance
        # note in gki_polyline()
        ll=Line2D(xs, ys, linestyle='', marker='.',
                  markersize=3.0, markeredgewidth=0.0,
                  markerfacecolor=self.markerAttributes.color,
                  color=self.markerAttributes.color)
        self.__normLines.append(ll)
Exemplo n.º 10
0
    def gki_fillarea(self, arg):
        """ Instructed to draw a GKI fillarea """
        # record this operation as a tuple in the draw buffer
        self._plotAppend(self.gki_fillarea, arg)

        # commit pending WCS changes
        self.wcs.commit()

        # plot the fillarea
        fa = self.fillAttributes
        verts = gki.ndc(arg[1:])
        # fillstyle 0=clear,  1=hollow,  2=solid,  3-6=hatch
        # default case is 'solid' (fully filled solid color)
        # 'hatch' case seems to be unused
        ec = fa.color
        fc = fa.color
        fll = 1
        if fa.fillstyle == 0:  # 'clear' (fully filled with black)
            ec = self.colorManager.setDrawingColor(0)
            fc = ec
            fll = 1
        if fa.fillstyle == 1:  # 'hollow' (just the rectangle line, empty)
            ec = fa.color
            fc = None
            fll = 0
        lowerleft = (verts[0], verts[1])
        width = verts[4] - verts[0]
        height = verts[5] - verts[1]
        rr = Rectangle(lowerleft,
                       width,
                       height,
                       edgecolor=ec,
                       facecolor=fc,
                       fill=fll)
        self.__normPatches.append(rr)
Exemplo n.º 11
0
    def gki_polymarker(self, arg):
        """ Instructed to draw a GKI polymarker.  IRAF only implements
        points for polymarker, so that makes it simple. """
        # record this operation as a tuple in the draw buffer
        self._plotAppend(self.gki_polymarker, arg)

        # commit pending WCS changes when draw is found
        self.wcs.commit()

        # Reshape to get x's and y's
        # arg[0] is the num pairs, so: len(arg)-1 == 2*arg[0]
        verts = gki.ndc(arg[1:])
        rshpd = verts.reshape(arg[0], 2)
        xs = rshpd[:, 0]
        ys = rshpd[:, 1]

        # put the normalized data into a Line2D object, append to our list
        # later we will scale it and append it to the fig.  See performance
        # note in gki_polyline()
        ll = Line2D(xs,
                    ys,
                    linestyle='',
                    marker='.',
                    markersize=3.0,
                    markeredgewidth=0.0,
                    markerfacecolor=self.markerAttributes.color,
                    color=self.markerAttributes.color)
        self.__normLines.append(ll)
Exemplo n.º 12
0
    def gki_setcursor(self, arg):

        # record this operation as a tuple in the draw buffer
        self._plotAppend(self.gki_setcursor, arg)

        # get x and y
        cursorNumber = arg[0]
        x = gki.ndc(arg[1])
        y = gki.ndc(arg[2])
        # Update the sw cursor object (A clear example of why this update
        # is needed is how 'apall' re-centers the cursor w/out changing y, when
        # the user types 'r'; without this update, the two cursors separate.)
        swCurObj = self.__mca.getSWCursor()
        if swCurObj: swCurObj.moveTo(x, y, SWmove=1)
        # wutil.moveCursorTo uses 0,0 <--> upper left, need to convert
        sx = int(x * self.gwidget.winfo_width())
        sy = int((1 - y) * self.gwidget.winfo_height())
        rx = self.gwidget.winfo_rootx()
        ry = self.gwidget.winfo_rooty()
        # call the wutil version to move the cursor
        moveCursorTo(self.gwidget.winfo_id(), rx, ry, sx, sy)
Exemplo n.º 13
0
    def gki_setcursor(self, arg):

        # record this operation as a tuple in the draw buffer
        self._plotAppend(self.gki_setcursor, arg)

        # get x and y
        cursorNumber = arg[0]
        x = gki.ndc(arg[1])
        y = gki.ndc(arg[2])
        # Update the sw cursor object (A clear example of why this update
        # is needed is how 'apall' re-centers the cursor w/out changing y, when
        # the user types 'r'; without this update, the two cursors separate.)
        swCurObj = self.__mca.getSWCursor()
        if swCurObj: swCurObj.moveTo(x, y, SWmove=1)
        # wutil.moveCursorTo uses 0,0 <--> upper left, need to convert
        sx = int(  x   * self.gwidget.winfo_width())
        sy = int((1-y) * self.gwidget.winfo_height())
        rx = self.gwidget.winfo_rootx()
        ry = self.gwidget.winfo_rooty()
        # call the wutil version to move the cursor
        moveCursorTo(self.gwidget.winfo_id(), rx, ry, sx, sy)
Exemplo n.º 14
0
    def gki_polyline(self, arg):
        """ Instructed to draw a GKI polyline """
        # record this operation as a tuple in the draw buffer
        self._plotAppend(self.gki_polyline, arg)

        # commit pending WCS changes when draw is found
        self.wcs.commit()

        # Reshape to get x's and y's
        # arg[0] is the num pairs, so: len(arg)-1 == 2*arg[0]
        verts = gki.ndc(arg[1:])
        rshpd = verts.reshape(arg[0], 2)
        xs = rshpd[:, 0]
        ys = rshpd[:, 1]

        # Put the normalized data into a Line2D object, append to our list.
        # Later we will scale it and append it to the fig.  For the sake of
        # performance, don't draw now, it slows things down.
        # Note that for each object we make and store here (which is
        # normalized), there will be a second (sized) copy of the same object
        # created in resizeGraphics().  We could consider storing this data
        # in some other way for speed, but perf. tests for #122 showed
        # that this use of multiple object creation wasn't a big hit at all.
        ll = Line2D(xs,
                    ys,
                    linestyle=self.lineAttributes.linestyle,
                    linewidth=GKI_TO_MPL_LINEWIDTH *
                    self.lineAttributes.linewidth,
                    color=self.lineAttributes.color)
        self.__normLines.append(ll)

        # While we are here and obviously getting drawing commands from the
        # task, set our draw-saving flag.  This covers the case of the
        # interactive task during a redraw from a user-typed 'r'.  That entire
        # case goes: 1) no drawing during initial plot creation, 2) task is
        # done giving us gki commands when gcur() seen, so drawing is allowed
        # 3) user types 'r' or similar to cause a redraw so this turns off
        # drawing again (to speed it up) until the next gcur() is seen.
        self.__allowDrawing = False
Exemplo n.º 15
0
    def gki_polyline(self, arg):

        """ Instructed to draw a GKI polyline """
        # record this operation as a tuple in the draw buffer
        self._plotAppend(self.gki_polyline, arg)

        # commit pending WCS changes when draw is found
        self.wcs.commit()

        # Reshape to get x's and y's
        # arg[0] is the num pairs, so: len(arg)-1 == 2*arg[0]
        verts = gki.ndc(arg[1:])
        rshpd = verts.reshape(arg[0],2)
        xs = rshpd[:,0]
        ys = rshpd[:,1]

        # Put the normalized data into a Line2D object, append to our list.
        # Later we will scale it and append it to the fig.  For the sake of
        # performance, don't draw now, it slows things down.
        # Note that for each object we make and store here (which is
        # normalized), there will be a second (sized) copy of the same object
        # created in resizeGraphics().  We could consider storing this data
        # in some other way for speed, but perf. tests for #122 showed
        # that this use of multiple object creation wasn't a big hit at all.
        ll=Line2D(xs, ys,
                  linestyle=self.lineAttributes.linestyle,
                  linewidth=GKI_TO_MPL_LINEWIDTH*self.lineAttributes.linewidth,
                  color=self.lineAttributes.color)
        self.__normLines.append(ll)

        # While we are here and obviously getting drawing commands from the
        # task, set our draw-saving flag.  This covers the case of the
        # interactive task during a redraw from a user-typed 'r'.  That entire
        # case goes: 1) no drawing during initial plot creation, 2) task is
        # done giving us gki commands when gcur() seen, so drawing is allowed
        # 3) user types 'r' or similar to cause a redraw so this turns off
        # drawing again (to speed it up) until the next gcur() is seen.
        self.__allowDrawing = False
Exemplo n.º 16
0
    def gki_fillarea(self, arg):

        self.wcs.commit()
        self._tkplotAppend(self.tkplot_fillarea, gki.ndc(arg[1:]))
Exemplo n.º 17
0
    def gki_fillarea(self, arg):

        self.wcs.commit()
        self._tkplotAppend(self.tkplot_fillarea, gki.ndc(arg[1:]))
Exemplo n.º 18
0
    def gki_polymarker(self, arg):

        self.wcs.commit()
        self._tkplotAppend(self.tkplot_polymarker, gki.ndc(arg[1:]))
Exemplo n.º 19
0
    def gki_polyline(self, arg):

        # commit pending WCS changes when draw is found
        self.wcs.commit()
        self._tkplotAppend(self.tkplot_polyline, gki.ndc(arg[1:]))
Exemplo n.º 20
0
    def gki_fillarea(self, arg):

        self.wcs.commit()
        self._glAppend(self.gl_fillarea, gki.ndc(arg[1:]))
Exemplo n.º 21
0
    def gki_polymarker(self, arg):

        self.wcs.commit()
        self._tkplotAppend(self.tkplot_polymarker, gki.ndc(arg[1:]))
Exemplo n.º 22
0
    def gki_polymarker(self, arg):

        self.wcs.commit()
        self._glAppend(self.gl_polymarker, gki.ndc(arg[1:]))
Exemplo n.º 23
0
    def gki_setcursor(self, arg):

        cursorNumber = arg[0]
        x = gki.ndc(arg[1])
        y = gki.ndc(arg[2])
        self._tkplotAppend(self.tkplot_setcursor, cursorNumber, x, y)
Exemplo n.º 24
0
    def gki_setcursor(self, arg):

        cursorNumber = arg[0]
        x = gki.ndc(arg[1])
        y = gki.ndc(arg[2])
        self._tkplotAppend(self.tkplot_setcursor, cursorNumber, x, y)
Exemplo n.º 25
0
    def gki_polyline(self, arg):

        # commit pending WCS changes when draw is found
        self.wcs.commit()
        self._tkplotAppend(self.tkplot_polyline, gki.ndc(arg[1:]))
Exemplo n.º 26
0
    def gki_setcursor(self, arg):

        cursorNumber = arg[0]
        x = gki.ndc(arg[1])
        y = gki.ndc(arg[2])
        self._glAppend(self.gl_setcursor, cursorNumber, x, y)