Ejemplo n.º 1
0
    def saveSnapshot(self):
        formats=""
        for format in HutchMenuBrick.SNAPSHOT_FORMATS:
            formats+="*.%s " % format
        formats=formats.strip()

        current_filename=os.path.join(self.directory, self.prefix)
        current_filename=current_filename + '_%d%s%s' % (self.fileIndex, os.path.extsep, self.formatType)
        filename=str(QFileDialog.getSaveFileName(current_filename,"Images (%s)" % formats,\
            self,None,"Choose a filename to save under",None,False))
        if len(filename):
            image_type=os.path.splitext(filename)[1].strip('.').upper()
            try:
                matrix = self.__drawing.matrix()
                zoom = 1
                if matrix is not None:
                    zoom = matrix.m11()
                img = self.__drawing.getPPP()
                logging.getLogger().info("Saving snapshot : %s", filename)
                QubImageSave.save(filename, img, self.__drawing.canvas(), zoom, image_type)
            except:
                logging.getLogger().exception("HutchMenuBrick: error saving snapshot!")
                logging.getLogger().error("HutchMenuBrick: error saving snapshot!")
            else:
                self.formatType=image_type.lower()
                self.fileIndex+=1
Ejemplo n.º 2
0
    def saveSnapshot(self):
        formats = ""
        for format in SoleilHutchMenuBrick.SNAPSHOT_FORMATS:
            formats += "*.%s " % format
        formats = formats.strip()

        current_filename = os.path.join(self.directory, self.prefix)
        current_filename = current_filename + \
            '_%d%s%s' % (self.fileIndex, os.path.extsep, self.formatType)
        filename = str(QFileDialog.getSaveFileName(current_filename, "Images (%s)" % formats,
                                                   self, None, "Choose a filename to save under", None, False))
        if len(filename):
            image_type = os.path.splitext(filename)[1].strip('.').upper()
            try:
                matrix = self.__drawing.matrix()
                zoom = 1
                if matrix is not None:
                    zoom = matrix.m11()
                img = self.__drawing.getPPP()
                logging.getLogger().info("Saving snapshot : %s", filename)
                QubImageSave.save(
                    filename,
                    img,
                    self.__drawing.canvas(),
                    zoom,
                    image_type)
            except BaseException:
                logging.getLogger().exception("HutchMenuBrick: error saving snapshot!")
                logging.getLogger().error("HutchMenuBrick: error saving snapshot!")
            else:
                self.formatType = image_type.lower()
                self.fileIndex += 1
Ejemplo n.º 3
0
 def _showDialog(self):
     if self._dialog.exec_loop() == qt.QDialog.Accepted:
         file_path = self._dialog.selectedFile().ascii()
         dirName, file_name = os.path.split(file_path)
         base, ext = os.path.splitext(file_name)
         QubImageSave.save(
             os.path.join(dirName, '%s.svg' % base), None,
             self.__canvas, 1, 'svg', True)
Ejemplo n.º 4
0
 def __init__(self, drawing):
     self.drawing = drawing
     matrix = self.drawing.matrix()
     self.zoom = 1
     if matrix is not None:
         self.zoom = matrix.m11()
     self.img = self.drawing.getPPP()
     fd, name = tempfile.mkstemp()
     os.close(fd)
     QubImageSave.save(name, self.img, self.drawing.canvas(), self.zoom, "JPEG")
     f = open(name, "r")
     self.imgcopy = f.read()
     f.close()
     os.unlink(name)
Ejemplo n.º 5
0
 def __init__(self, drawing):
     self.drawing = drawing
     matrix = self.drawing.matrix()
     self.zoom = 1
     if matrix is not None:
         self.zoom = matrix.m11()
     self.img = self.drawing.getPPP()
     fd, name = tempfile.mkstemp()
     os.close(fd)
     QubImageSave.save(name, self.img, self.drawing.canvas(), self.zoom,
                       "JPEG")
     f = open(name, "r")
     self.imgcopy = f.read()
     f.close()
     os.unlink(name)
 def _showDialog(self):
     if self._dialog.exec_loop() == qt.QDialog.Accepted:
         file_path = self._dialog.selectedFile().ascii()
         dirName, file_name = os.path.split(file_path)
         base, ext = os.path.splitext(file_name)
         QubImageSave.save(
             os.path.join(
                 dirName,
                 '%s.svg' %
                 base),
             None,
             self.__canvas,
             1,
             'svg',
             True)
Ejemplo n.º 7
0
    def save(self, filename=None):
        self.img = self.drawing.getPPP()

        if filename is None:
          fd, name = tempfile.mkstemp()
          os.close(fd)
        else:
          name = filename

        QubImageSave.save(name, self.img, self.drawing.canvas(), self.zoom, "JPEG")

        if filename is None:
          f = open(name, "r")
          self.imgcopy = f.read()
          f.close()
          os.unlink(name)
Ejemplo n.º 8
0
    def save(self, filename=None):
        self.img = self.drawing.getPPP()

        if filename is None:
          fd, name = tempfile.mkstemp()
          os.close(fd)
        else:
          name = filename

        QubImageSave.save(name, self.img, self.drawing.canvas(), self.zoom, "JPEG")

        if filename is None:
          f = open(name, "r")
          self.imgcopy = f.read()
          f.close()
          os.unlink(name)
Ejemplo n.º 9
0
    def centredPositionSnapshot(self):
        matrix = self.__drawing.matrix()

        zoom = 1
        if matrix is not None:
            zoom = matrix.m11()

        img = self.__drawing.getPPP()
        fd, name = tempfile.mkstemp()
        os.close(fd)

        QubImageSave.save(name, img, self.__drawing.canvas(), zoom, "JPEG")

        f = open(name, "r")
        imgcopy = f.read()
        f.close()
        os.unlink(name)

        return imgcopy
Ejemplo n.º 10
0
    def centredPositionSnapshot(self):
        matrix = self.__drawing.matrix()

        zoom = 1
        if matrix is not None:
            zoom = matrix.m11()

        img = self.__drawing.getPPP()
        fd, name = tempfile.mkstemp()
        os.close(fd)

        QubImageSave.save(name, img, self.__drawing.canvas(), zoom, "JPEG")

        f = open(name, "r")
        imgcopy = f.read()
        f.close()
        os.unlink(name)

        return imgcopy