Ejemplo n.º 1
0
 def paintEvent(self, e):
     painter = QPainter(self.viewport())
     pen = painter.pen()
     pen.setCosmetic(True)
     pen.setWidth(0.0)
     painter.setPen(pen)
     painter.setRenderHint(QPainter.Antialiasing, False)
     groups = self.document().rootFrame().childFrames()
     for group in groups:
         h = QtReduceRowFormat().leftMargin()
         hoff = int(0.4 * h)
         self.__drawFrameBracket(painter,
                                 group,
                                 hoff,
                                 QColor(qRgb(0x80, 0x80, 0x80)),
                                 xt=2)
         childFrames = group.childFrames()
         hoff = int(0.7 * h)
         self.__drawFrameBracket(painter,
                                 childFrames[0],
                                 hoff,
                                 QColor(qRgb(0xb0, 0x70, 0x70)),
                                 xt=2)
         self.__drawFrameBracket(painter,
                                 childFrames[1],
                                 hoff,
                                 QColor(qRgb(0x70, 0x70, 0xb0)),
                                 xt=2)
     painter.end()
     super(QtReduceFrameView, self).paintEvent(e)
Ejemplo n.º 2
0
 def __init__(self):
     """
     Initialize queue with segments
     """
     self.data = []
     self.pos = 0
     self.force = False
     self.baseColor = qRgb(0, 0, 0)
     self.updateColor = qRgb(255, 0, 0)
Ejemplo n.º 3
0
 def __do_draw(self, canvas, p, p1, p2, p3, p4, k, color):
     #print(">    ",p,p1,p2,p3,p4)
     canvas.drawLine(p1,p2, color)
     canvas.drawLine(p3,p4, color)
     if p:
         canvas.drawCross(p, kind=k, color=qRgb(0, 0, 255))
         pass
Ejemplo n.º 4
0
 def create(color1, color2, color3, n=256):
     '''creates a new colortable for three given colors.
     
     Arguments
     ---------
     color1 : tuple
         color in the beginning
     color2 : tuple
         color in the middle
     color3 : tuple
         color in the end
     n : int
         length of the colortable
     '''
     
     colortable = []
     for index in xrange(n):
         color = [0, 0, 0]
         for k in xrange(3):
             if index < n/2:
                 color[k] = color1[k] + 2.0*index/n * (color2[k] - color1[k])
             else:
                 color[k] = color2[k] + (2.0*index/n-1) * (color3[k] - color2[k])
         colortable.append(qRgb(color[0], color[1], color[2]))
     return colortable
Ejemplo n.º 5
0
    def saveBMC(self):
        """
        .. TODO:: Save a Brother PEL image (An 8bpp, 130x113 pixel monochromatic? bitmap image) Why 8bpp when only 1bpp is needed?

        .. TODO:: Should BMC be limited to ~32KB or is this a mix up with Bitmap Cache?
        .. TODO:: Is there/should there be other embedded data in the bitmap besides the image itself?
        .. NOTE:: Can save a Singer BMC image (An 8bpp, 130x113 pixel colored bitmap image)
        """
        # TODO: figure out how to center the image, right now it just plops it to the left side.
        img = QImage(150, 150, QImage.Format_ARGB32_Premultiplied)
        img.fill(qRgb(255, 255, 255))
        extents = self.gscene.itemsBoundingRect()  # QRectF

        painter = QPainter(img)
        targetRect = QRectF(0, 0, 150, 150)
        if self.mainWin.getSettingsPrintingDisableBG():  # TODO: Make BMC background into it's own setting?
            brush = self.gscene.backgroundBrush()  # QBrush
            self.gscene.setBackgroundBrush(Qt.NoBrush)
            self.gscene.update()
            self.gscene.render(painter, targetRect, extents, Qt.KeepAspectRatio)
            self.gscene.setBackgroundBrush(brush)

        else:
            self.gscene.update()
            self.gscene.render(painter, targetRect, extents, Qt.KeepAspectRatio)

        img.convertToFormat(QImage.Format_Indexed8, Qt.ThresholdDither | Qt.AvoidDither).save("test.bmc", "BMP")
Ejemplo n.º 6
0
class QtReduceFormat(object):
    GRAY = QColor(qRgb(235,235,238))
    #    red = QColor(qRgb(250,220,220))
    RED = QColor(qRgb(250,230,230))
    DARKRED = QColor(qRgb(0xb0,0,0))
    DARKBLUE = QColor(qRgb(0,0,0xb0))
    DARKGRAY = QColor(qRgb(0xa0,0xa0,0xa0))

    def __init__(self):
        self.blockFormat = QTextBlockFormat()
        self.blockFormat.setAlignment(Qt.AlignLeft)
        self.charFormat = QTextCharFormat()
        self.frameFormat = QTextFrameFormat()
        self.frameFormat.setTopMargin(0)
        self.frameFormat.setBottomMargin(0)
        self.frameFormat.setLeftMargin(0)
        self.frameFormat.setPosition(QTextFrameFormat.InFlow)
Ejemplo n.º 7
0
    def resizeImage(self, image, newSize):
        if image.size() == newSize:
            return
        newImage = QImage(newSize, QImage.Format_RGB32)
        newImage.fill(qRgb(255, 255, 255))
        painter = QPainter(newImage)
        painter.drawImage(QtCore.QPoint(0, 0), image)

        self.image = newImage
Ejemplo n.º 8
0
 def paintEvent(self,e):
     painter = QPainter(self.viewport())
     pen = painter.pen()
     pen.setCosmetic(True)
     pen.setWidth(0.0)
     painter.setPen(pen)
     painter.setRenderHint(QPainter.Antialiasing, False)
     groups = self.document().rootFrame().childFrames()
     for group in groups:
         h = QtReduceRowFormat().leftMargin()
         hoff = int(0.4*h)
         self.__drawFrameBracket(painter,group,hoff,
                                 QColor(qRgb(0x80,0x80,0x80)),xt=2)
         childFrames = group.childFrames()
         hoff = int(0.7*h)
         self.__drawFrameBracket(painter,childFrames[0],hoff,
                                 QColor(qRgb(0xb0,0x70,0x70)),xt=2)
         self.__drawFrameBracket(painter,childFrames[1],hoff,
                                 QColor(qRgb(0x70,0x70,0xb0)),xt=2)
     painter.end()
     super(QtReduceFrameView,self).paintEvent(e)
    def __toQImage(self, im):
        gray_color_table = [qRgb(i, i, i) for i in range(256)]
        if im is None:
            return QImage()

        if im.dtype == numpy.uint8:
            if len(im.shape) == 2:
                qim = QImage(im.data, im.shape[1], im.shape[0], im.strides[0], QImage.Format_Indexed8)
                qim.setColorTable(gray_color_table)
                return qim

            elif len(im.shape) == 3:
                if im.shape[2] == 3:
                    qim = QImage(im.data, im.shape[1], im.shape[0], im.strides[0], QImage.Format_RGB888)
                    return qim
                elif im.shape[2] == 4:
                    qim = QImage(im.data, im.shape[1], im.shape[0], im.strides[0], QImage.Format_ARGB32)
                    return qim
Ejemplo n.º 10
0
Archivo: imagen.py Proyecto: zikofv/pdi
 def putpixel(self, xy, value):
   self.img.setPixel(xy[0], xy[1], qRgb(value[0], value[1], value[2]))
Ejemplo n.º 11
0
Archivo: imagen.py Proyecto: zikofv/pdi
 def empty(self, size, mode=QImage.Format_RGB888):
   self.img = QImage(size[0], size[1], mode)
   self.img.fill(qRgb(0,0,0))#Rellenamos la imagen con negro
Ejemplo n.º 12
0
from PySide.QtGui import QImage, qRgb
import numpy as np


class NotImplementedException:
    pass


gray_color_table = [qRgb(i, i, i) for i in range(256)]


def toQImage(im, copy=False):
    if im is None:
        return QImage()

    if im.dtype == np.uint8:
        if len(im.shape) == 2:
            qim = QImage(im.data, im.shape[1], im.shape[0], im.strides[0],
                         QImage.Format_Indexed8)
            qim.setColorTable(gray_color_table)
            return qim.copy() if copy else qim

        elif len(im.shape) == 3:
            if im.shape[2] == 3:
                qim = QImage(im.data, im.shape[1], im.shape[0], im.strides[0],
                             QImage.Format_RGB888)
                return qim.copy() if copy else qim
            elif im.shape[2] == 4:
                qim = QImage(im.data, im.shape[1], im.shape[0], im.strides[0],
                             QImage.Format_ARGB32)
                return qim.copy() if copy else qim
Ejemplo n.º 13
0
def rgb(r, g, b):
    return qRgb(r, g, b)
Ejemplo n.º 14
0
 def clearImage(self):
     self.image.fill(qRgb(255, 255, 255))
     self.modified = True
     self.update()
Ejemplo n.º 15
0
    def loadFile(self, fileName):
        """
        TOWRITE

        :param `fileName`: TOWRITE
        :type `fileName`: QString
        :rtype: bool
        """
        qDebug("MdiWindow loadFile()")

        tmpColor = self.getCurrentColor()  # QRgb

        file = QFile(fileName)
        if not file.open(QFile.ReadOnly | QFile.Text):
            QMessageBox.warning(
                self,
                self.tr("Error reading file"),
                self.tr("Cannot read file %s:\n%s." % (fileName, file.errorString()))
                )
            return False

        QApplication.setOverrideCursor(Qt.WaitCursor)

        ext = self.fileExtension(fileName)  # QString
        qDebug("ext: %s" % qPrintable(ext))

        # Read
        p = embPattern_create()  # EmbPattern*
        if not p:
            print("Could not allocate memory for embroidery pattern\n")
            exit(1)
        readSuccessful = 0  # int
        ## QString readError
        reader = embReaderWriter_getByFileName(qPrintable(fileName))  # EmbReaderWriter*
        if not reader:
            readSuccessful = 0
            readError = "Unsupported read file type: " + fileName
            qDebug("Unsupported read file type: %s\n" % qPrintable(fileName))
        else:
            readSuccessful = reader.reader(p, qPrintable(fileName))
            if not readSuccessful:
                readError = "Reading file was unsuccessful: " + fileName
                qDebug("Reading file was unsuccessful: %s\n" % qPrintable(fileName))

        ## free(reader)  #TODO/REMOVE# not needed in python
        if not readSuccessful:
            QMessageBox.warning(self, self.tr("Error reading pattern"), self.tr(qPrintable(readError)))

        if readSuccessful:
            embPattern_moveStitchListToPolylines(p)  # TODO: Test more
            stitchCount = embStitchList_count(p.stitchList)  # int
            path = QPainterPath()

            if p.circleObjList:
                curCircleObj = p.circleObjList  # EmbCircleObjectList*
                while curCircleObj:
                    c = curCircleObj.circleObj.circle  # EmbCircle
                    thisColor = curCircleObj.circleObj.color  # EmbColor
                    self.setCurrentColor(qRgb(thisColor.r, thisColor.g, thisColor.b))
                    # NOTE: With natives, the Y+ is up and libembroidery Y+ is up, so inverting the Y is NOT needed.
                    self.mainWin.nativeAddCircle(embCircle_centerX(c), embCircle_centerY(c), embCircle_radius(c), False, OBJ_RUBBER_OFF)  # TODO: fill
                    curCircleObj = curCircleObj.next

            if p.ellipseObjList:
                curEllipseObj = p.ellipseObjList  # EmbEllipseObjectList*
                while curEllipseObj:
                    e = curEllipseObj.ellipseObj.ellipse  # EmbEllipse
                    thisColor = curEllipseObj.ellipseObj.color  # EmbColor
                    self.setCurrentColor(qRgb(thisColor.r, thisColor.g, thisColor.b))
                    # NOTE: With natives, the Y+ is up and libembroidery Y+ is up, so inverting the Y is NOT needed.
                    self.mainWin.nativeAddEllipse(embEllipse_centerX(e), embEllipse_centerY(e), embEllipse_width(e), embEllipse_height(e), 0, False, OBJ_RUBBER_OFF)  # TODO: rotation and fill
                    curEllipseObj = curEllipseObj.next

            if p.lineObjList:
                curLineObj = p.lineObjList  # EmbLineObjectList*
                while curLineObj:
                    li = curLineObj.lineObj.line  # EmbLine
                    thisColor = curLineObj.lineObj.color  # EmbColor
                    self.setCurrentColor(qRgb(thisColor.r, thisColor.g, thisColor.b))
                    # NOTE: With natives, the Y+ is up and libembroidery Y+ is up, so inverting the Y is NOT needed.
                    self.mainWin.nativeAddLine(embLine_x1(li), embLine_y1(li), embLine_x2(li), embLine_y2(li), 0, OBJ_RUBBER_OFF)  # TODO: rotation
                    curLineObj = curLineObj.next

            if p.pathObjList:
                # TODO: This is unfinished. It needs more work
                curPathObjList = p.pathObjList  # EmbPathObjectList*
                while curPathObjList:
                    pathPath = QPainterPath()
                    curPointList = curPathObjList.pathObj.pointList  # EmbPointList*
                    thisColor = curPathObjList.pathObj.color  # EmbColor
                    if curPointList:
                        pp = curPointList.point  # EmbPoint
                        pathPath.moveTo(embPoint_x(pp), -embPoint_y(pp))  # NOTE: Qt Y+ is down and libembroidery Y+ is up, so inverting the Y is needed.
                        curPointList = curPointList.next

                    while curPointList:
                        pp = curPointList.point  # EmbPoint
                        pathPath.lineTo(embPoint_x(pp), -embPoint_y(pp))  # NOTE: Qt Y+ is down and libembroidery Y+ is up, so inverting the Y is needed.
                        curPointList = curPointList.next

                    loadPen = QPen(qRgb(thisColor.r, thisColor.g, thisColor.b))
                    loadPen.setWidthF(0.35)
                    loadPen.setCapStyle(Qt.RoundCap)
                    loadPen.setJoinStyle(Qt.RoundJoin)

                    obj = PathObject(0, 0, pathPath, loadPen.color().rgb())  # PathObject*
                    obj.setObjectRubberMode(OBJ_RUBBER_OFF)
                    self.gscene.addItem(obj)

                    curPathObjList = curPathObjList.next

            if p.pointObjList:
                curPointObj = p.pointObjList  # EmbPointObjectList*
                while curPointObj:
                    po = curPointObj.pointObj.point  # EmbPoint
                    thisColor = curPointObj.pointObj.color  # EmbColor
                    self.setCurrentColor(qRgb(thisColor.r, thisColor.g, thisColor.b))
                    # NOTE: With natives, the Y+ is up and libembroidery Y+ is up, so inverting the Y is NOT needed.
                    self.mainWin.nativeAddPoint(embPoint_x(po), embPoint_y(po))
                    curPointObj = curPointObj.next

            if p.polygonObjList:
                curPolygonObjList = p.polygonObjList  # EmbPolygonObjectList*
                while curPolygonObjList:
                    polygonPath = QPainterPath()
                    firstPoint = False  # bool
                    startX = 0; startY = 0  # qreal
                    x = 0; y = 0  # qreal
                    curPointList = curPolygonObjList.polygonObj.pointList  # EmbPointList*
                    thisColor = curPolygonObjList.polygonObj.color  # EmbColor
                    self.setCurrentColor(qRgb(thisColor.r, thisColor.g, thisColor.b))
                    while curPointList:
                        pp = curPointList.point  # EmbPoint
                        x = embPoint_x(pp)
                        y = -embPoint_y(pp)  # NOTE: Qt Y+ is down and libembroidery Y+ is up, so inverting the Y is needed.

                        if firstPoint:
                            polygonPath.lineTo(x,y)
                        else:
                            polygonPath.moveTo(x,y)
                            firstPoint = True
                            startX = x
                            startY = y

                        curPointList = curPointList.next

                    polygonPath.translate(-startX, -startY)
                    self.mainWin.nativeAddPolygon(startX, startY, polygonPath, OBJ_RUBBER_OFF)

                    curPolygonObjList = curPolygonObjList.next

            # NOTE: Polylines should only contain NORMAL stitches.
            if p.polylineObjList:
                curPolylineObjList = p.polylineObjList  # EmbPolylineObjectList*
                while curPolylineObjList:
                    polylinePath = QPainterPath()
                    firstPoint = False  # bool
                    startX = 0; startY = 0  # qreal
                    x = 0; y = 0  # qreal
                    curPointList = curPolylineObjList.polylineObj.pointList  # EmbPointList*
                    thisColor = curPolylineObjList.polylineObj.color  # EmbColor
                    self.setCurrentColor(qRgb(thisColor.r, thisColor.g, thisColor.b))
                    while curPointList:
                        pp = curPointList.point  # EmbPoint
                        x = embPoint_x(pp)
                        y = -embPoint_y(pp) # NOTE: Qt Y+ is down and libembroidery Y+ is up, so inverting the Y is needed.

                        if firstPoint:
                            polylinePath.lineTo(x,y)
                        else:
                            polylinePath.moveTo(x,y)
                            firstPoint = True
                            startX = x
                            startY = y

                        curPointList = curPointList.next

                    polylinePath.translate(-startX, -startY)
                    self.mainWin.nativeAddPolyline(startX, startY, polylinePath, OBJ_RUBBER_OFF)

                    curPolylineObjList = curPolylineObjList.next


            if p.rectObjList:
                curRectObj = p.rectObjList  # EmbRectObjectList*
                while curRectObj:
                    r = curRectObj.rectObj.rect  # EmbRect
                    thisColor = curRectObj.rectObj.color  # EmbColor
                    self.setCurrentColor(qRgb(thisColor.r, thisColor.g, thisColor.b))
                    # NOTE: With natives, the Y+ is up and libembroidery Y+ is up, so inverting the Y is NOT needed.
                    self.mainWin.nativeAddRectangle(embRect_x(r), embRect_y(r), embRect_width(r), embRect_height(r), 0, False, OBJ_RUBBER_OFF)  # TODO: rotation and fill
                    curRectObj = curRectObj.next

            self.setCurrentFile(fileName)
            self.mainWin.statusbar.showMessage("File loaded.")
            stitches = str(stitchCount)  # QString: stitches.setNum(stitchCount)

            if self.mainWin.getSettingsGridLoadFromFile():
                # TODO: Josh, provide me a hoop size and/or grid spacing from the pattern.
                pass

            QApplication.restoreOverrideCursor()

        else:  #TODO/PORT# warning shown twice?! redundant ?!
            QApplication.restoreOverrideCursor()
            QMessageBox.warning(self, self.tr("Error reading pattern"), self.tr("Cannot read pattern"))

        ## embPattern_free(p)  #TODO/REMOVE# not needed in python

        # Clear the undo stack so it is not possible to undo past this point.
        self.gview.getUndoStack().clear()

        self.setCurrentColor(tmpColor)

        fileWasLoaded = True
        self.mainWin.setUndoCleanIcon(fileWasLoaded)
        return fileWasLoaded
def createPropertiesToolbar(self):
    """
    TOWRITE
    """
    toolbarProperties = self.toolbarProperties
    prompt = self.prompt
    colorSelector = self.colorSelector
    linetypeSelector = self.linetypeSelector
    lineweightSelector = self.lineweightSelector
    tr = self.tr
    qDebug("MainWindow createPropertiesToolbar()")

    toolbarProperties.setObjectName("toolbarProperties")

    icontheme = self.getSettingsGeneralIconTheme()  # QString

    colorSelector.setFocusProxy(prompt)
    # NOTE: Qt4.7 wont load icons without an extension...
    colorSelector.addItem(QIcon("icons/" + icontheme + "/" + "colorbylayer" + ".png"), "ByLayer")
    colorSelector.addItem(QIcon("icons/" + icontheme + "/" + "colorbyblock" + ".png"), "ByBlock")
    colorSelector.addItem(QIcon("icons/" + icontheme + "/" + "colorred"     + ".png"), tr("Red"),     qRgb(255,   0,   0))
    colorSelector.addItem(QIcon("icons/" + icontheme + "/" + "coloryellow"  + ".png"), tr("Yellow"),  qRgb(255, 255,   0))
    colorSelector.addItem(QIcon("icons/" + icontheme + "/" + "colorgreen"   + ".png"), tr("Green"),   qRgb(  0, 255,   0))
    colorSelector.addItem(QIcon("icons/" + icontheme + "/" + "colorcyan"    + ".png"), tr("Cyan"),    qRgb(  0, 255, 255))
    colorSelector.addItem(QIcon("icons/" + icontheme + "/" + "colorblue"    + ".png"), tr("Blue"),    qRgb(  0,   0, 255))
    colorSelector.addItem(QIcon("icons/" + icontheme + "/" + "colormagenta" + ".png"), tr("Magenta"), qRgb(255,   0, 255))
    colorSelector.addItem(QIcon("icons/" + icontheme + "/" + "colorwhite"   + ".png"), tr("White"),   qRgb(255, 255, 255))
    colorSelector.addItem(QIcon("icons/" + icontheme + "/" + "colorother"   + ".png"), tr("Other..."))
    toolbarProperties.addWidget(colorSelector)
    self.connect(colorSelector, SIGNAL("currentIndexChanged(int)"), self, SLOT("colorSelectorIndexChanged(int)"))

    toolbarProperties.addSeparator()
    linetypeSelector.setFocusProxy(prompt)
    # NOTE: Qt4.7 wont load icons without an extension...
    linetypeSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer"    + ".png"), "ByLayer")
    linetypeSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebyblock"    + ".png"), "ByBlock")
    linetypeSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypecontinuous" + ".png"), "Continuous")
    linetypeSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypehidden"     + ".png"), "Hidden")
    linetypeSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypecenter"     + ".png"), "Center")
    linetypeSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypeother"      + ".png"), "Other...")
    toolbarProperties.addWidget(linetypeSelector)
    self.connect(linetypeSelector, SIGNAL("currentIndexChanged(int)"), self, SLOT("linetypeSelectorIndexChanged(int)"))

    toolbarProperties.addSeparator()
    lineweightSelector.setFocusProxy(prompt)
    # NOTE: Qt4.7 wont load icons without an extension...
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweightbylayer" + ".png"), "ByLayer", -2.00)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweightbyblock" + ".png"), "ByBlock", -1.00)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweightdefault" + ".png"), "Default",  0.00)
    # TODO: Thread weight is weird. See http://en.wikipedia.org/wiki/Thread_(yarn)#Weight
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight01" + ".png"), "0.00 mm", 0.00)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight02" + ".png"), "0.05 mm", 0.05)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight03" + ".png"), "0.15 mm", 0.15)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight04" + ".png"), "0.20 mm", 0.20)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight05" + ".png"), "0.25 mm", 0.25)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight06" + ".png"), "0.30 mm", 0.30)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight07" + ".png"), "0.35 mm", 0.35)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight08" + ".png"), "0.40 mm", 0.40)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight09" + ".png"), "0.45 mm", 0.45)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight10" + ".png"), "0.50 mm", 0.50)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight11" + ".png"), "0.55 mm", 0.55)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight12" + ".png"), "0.60 mm", 0.60)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight13" + ".png"), "0.65 mm", 0.65)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight14" + ".png"), "0.70 mm", 0.70)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight15" + ".png"), "0.75 mm", 0.75)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight16" + ".png"), "0.80 mm", 0.80)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight17" + ".png"), "0.85 mm", 0.85)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight18" + ".png"), "0.90 mm", 0.90)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight19" + ".png"), "0.95 mm", 0.95)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight20" + ".png"), "1.00 mm", 1.00)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight21" + ".png"), "1.05 mm", 1.05)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight22" + ".png"), "1.10 mm", 1.10)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight23" + ".png"), "1.15 mm", 1.15)
    lineweightSelector.addItem(QIcon("icons/" + icontheme + "/" + "lineweight24" + ".png"), "1.20 mm", 1.20)
    lineweightSelector.setMinimumContentsLength(8)  # Prevent dropdown text readability being squish...d.
    toolbarProperties.addWidget(lineweightSelector)
    self.connect(lineweightSelector, SIGNAL("currentIndexChanged(int)"), self, SLOT("lineweightSelectorIndexChanged(int)"))

    self.connect(toolbarProperties, SIGNAL("topLevelChanged(bool)"), self, SLOT("floatingChangedToolBar(bool)"))
Ejemplo n.º 17
0
 def empty(self, size, mode=QImage.Format_RGB888):
     self.img = QImage(size[0], size[1], mode)
     self.img.fill(qRgb(0, 0, 0))  #Rellenamos la imagen con negro
Ejemplo n.º 18
0
 def putpixel(self, xy, value):
     self.img.setPixel(xy[0], xy[1], qRgb(value[0], value[1], value[2]))
Ejemplo n.º 19
0
def DoReadSettings(self): # void MainWindow::

    qDebug("Reading Settings...")
    theSettingsIniPath = self.gAppDir + os.sep + "settings-py.ini"

    self.gSettings = gSettings = QSettings(theSettingsIniPath, QSettings.IniFormat)
    pos = gSettings.value("Window/Position", QPoint(0, 0))#.toPoint()
    size = gSettings.value("Window/Size", QSize(800, 600))#.toSize()

    self.layoutState = gSettings.value("LayoutState")#.toByteArray()
    if not self.layoutState: # None
        qDebug("LayoutState NOT restored! Setting Default Layout...")
        # someToolBar.setVisible(True)
    else:
        self.restoreState(self.layoutState)

    # General
    self.settings_general_language               = gSettings.value("Language",                            "default")#.toString()
    self.settings_general_icon_theme             = gSettings.value("IconTheme",                           "default")#.toString()
    self.settings_general_icon_size              = gSettings.value("IconSize",                                   16)#.toInt()
    self.settings_general_mdi_bg_use_logo        = gSettings.value("MdiBGUseLogo",                             True)#.toBool()
    self.settings_general_mdi_bg_use_texture     = gSettings.value("MdiBGUseTexture",                          True)#.toBool()
    self.settings_general_mdi_bg_use_color       = gSettings.value("MdiBGUseColor",                            True)#.toBool()
    self.settings_general_mdi_bg_logo            = gSettings.value("MdiBGLogo",           "images/logo-spirals.png")#.toString()
    self.settings_general_mdi_bg_texture         = gSettings.value("MdiBGTexture",     "images/texture-spirals.png")#.toString()
    self.settings_general_mdi_bg_color           = gSettings.value("MdiBGColor",                  qRgb(192,192,192))#.toInt()
    self.settings_general_tip_of_the_day         = gSettings.value("TipOfTheDay",                                 1)#.toBool()
    self.settings_general_current_tip            = gSettings.value("CurrentTip",                                  0)#.toInt()
    # Display
    self.settings_display_use_opengl             = gSettings.value("Display/UseOpenGL",                       False)#.toBool()
    self.settings_display_renderhint_aa          = gSettings.value("Display/RenderHintAntiAlias",             False)#.toBool()
    self.settings_display_renderhint_text_aa     = gSettings.value("Display/RenderHintTextAntiAlias",         False)#.toBool()
    self.settings_display_renderhint_smooth_pix  = gSettings.value("Display/RenderHintSmoothPixmap",          False)#.toBool()
    self.settings_display_renderhint_high_aa     = gSettings.value("Display/RenderHintHighQualityAntiAlias",  False)#.toBool()
    self.settings_display_renderhint_noncosmetic = gSettings.value("Display/RenderHintNonCosmetic",           False)#.toBool()
    self.settings_display_show_scrollbars        = gSettings.value("Display/ShowScrollBars",                   True)#.toBool()
    self.settings_display_scrollbar_widget_num   = gSettings.value("Display/ScrollBarWidgetNum",                  0)#.toInt()
    self.settings_display_crosshair_color        = gSettings.value("Display/CrossHairColor",      qRgb(  0,  0,  0))#.toInt()
    self.settings_display_bg_color               = gSettings.value("Display/BackgroundColor",     qRgb(235,235,235))#.toInt()
    self.settings_display_selectbox_left_color   = gSettings.value("Display/SelectBoxLeftColor",  qRgb(  0,128,  0))#.toInt()
    self.settings_display_selectbox_left_fill    = gSettings.value("Display/SelectBoxLeftFill",   qRgb(  0,255,  0))#.toInt()
    self.settings_display_selectbox_right_color  = gSettings.value("Display/SelectBoxRightColor", qRgb(  0,  0,128))#.toInt()
    self.settings_display_selectbox_right_fill   = gSettings.value("Display/SelectBoxRightFill",  qRgb(  0,  0,255))#.toInt()
    self.settings_display_selectbox_alpha        = gSettings.value("Display/SelectBoxAlpha",                     32)#.toInt()
    self.settings_display_zoomscale_in           = gSettings.value("Display/ZoomScaleIn",                       2.0)#.toFloat()
    self.settings_display_zoomscale_out          = gSettings.value("Display/ZoomScaleOut",                      0.5)#.toFloat()
    self.settings_display_crosshair_percent      = gSettings.value("Display/CrossHairPercent",                    5)#.toInt()
    self.settings_display_units                  = gSettings.value("Display/Units",                            "mm")#.toString()
    # Prompt
    self.settings_prompt_text_color              = gSettings.value("Prompt/TextColor",            qRgb(  0,  0,  0))#.toInt()
    self.settings_prompt_bg_color                = gSettings.value("Prompt/BackgroundColor",      qRgb(255,255,255))#.toInt()
    self.settings_prompt_font_family             = gSettings.value("Prompt/FontFamily",                 "Monospace")#.toString()
    self.settings_prompt_font_style              = gSettings.value("Prompt/FontStyle",                     "normal")#.toString()
    self.settings_prompt_font_size               = gSettings.value("Prompt/FontSize",                            12)#.toInt()
    self.settings_prompt_save_history            = gSettings.value("Prompt/SaveHistory",                       True)#.toBool()
    self.settings_prompt_save_history_as_html    = gSettings.value("Prompt/SaveHistoryAsHtml",                False)#.toBool()
    self.settings_prompt_save_history_filename   = gSettings.value("Prompt/SaveHistoryFilename",       "prompt.log")#.toString()
    # OpenSave
    self.settings_opensave_custom_filter         = gSettings.value("OpenSave/CustomFilter",             "supported")#.toString()
    self.settings_opensave_open_format           = gSettings.value("OpenSave/OpenFormat",                     "*.*")#.toString()
    self.settings_opensave_open_thumbnail        = gSettings.value("OpenSave/OpenThumbnail",                  False)#.toBool()
    self.settings_opensave_save_format           = gSettings.value("OpenSave/SaveFormat",                     "*.*")#.toString()
    self.settings_opensave_save_thumbnail        = gSettings.value("OpenSave/SaveThumbnail",                  False)#.toBool()
    # Recent
    self.settings_opensave_recent_max_files      = gSettings.value("OpenSave/RecentMax",                         10)#.toInt()
    self.settings_opensave_recent_list_of_files  = gSettings.value("OpenSave/RecentFiles")                          #.toStringList()
    self.settings_opensave_recent_directory      = gSettings.value("OpenSave/RecentDirectory")                      #.toString()
    # Trimming
    self.settings_opensave_trim_dst_num_jumps    = gSettings.value("OpenSave/TrimDstNumJumps",                    5)#.toInt()
    # Printing
    self.settings_printing_default_device        = gSettings.value("Printing/DefaultDevice",                     "")#.toString()
    self.settings_printing_use_last_device       = gSettings.value("Printing/UseLastDevice",                  False)#.toBool()
    self.settings_printing_disable_bg            = gSettings.value("Printing/DisableBG",                       True)#.toBool()
    # Grid
    self.settings_grid_show_on_load              = gSettings.value("Grid/ShowOnLoad",                          True)#.toBool()
    self.settings_grid_show_origin               = gSettings.value("Grid/ShowOrigin",                          True)#.toBool()
    self.settings_grid_color_match_crosshair     = gSettings.value("Grid/ColorMatchCrossHair",                 True)#.toBool()
    self.settings_grid_color                     = gSettings.value("Grid/Color",                  qRgb(  0,  0,  0))#.toInt()
    self.settings_grid_load_from_file            = gSettings.value("Grid/LoadFromFile",                        True)#.toBool()
    self.settings_grid_type                      = gSettings.value("Grid/Type",                       "Rectangular")#.toString()
    self.settings_grid_center_on_origin          = gSettings.value("Grid/CenterOnOrigin",                      True)#.toBool()
    self.settings_grid_center_x                  = gSettings.value("Grid/CenterX",                              0.0)#.toFloat()
    self.settings_grid_center_y                  = gSettings.value("Grid/CenterY",                              0.0)#.toFloat()
    self.settings_grid_size_x                    = gSettings.value("Grid/SizeX",                              100.0)#.toFloat()
    self.settings_grid_size_y                    = gSettings.value("Grid/SizeY",                              100.0)#.toFloat()
    self.settings_grid_spacing_x                 = gSettings.value("Grid/SpacingX",                            25.0)#.toFloat()
    self.settings_grid_spacing_y                 = gSettings.value("Grid/SpacingY",                            25.0)#.toFloat()
    self.settings_grid_size_radius               = gSettings.value("Grid/SizeRadius",                          50.0)#.toFloat()
    self.settings_grid_spacing_radius            = gSettings.value("Grid/SpacingRadius",                       25.0)#.toFloat()
    self.settings_grid_spacing_angle             = gSettings.value("Grid/SpacingAngle",                        45.0)#.toFloat()
    # Ruler
    self.settings_ruler_show_on_load             = gSettings.value("Ruler/ShowOnLoad",                         True)#.toBool()
    self.settings_ruler_metric                   = gSettings.value("Ruler/Metric",                             True)#.toBool()
    self.settings_ruler_color                    = gSettings.value("Ruler/Color",                 qRgb(210,210, 50))#.toInt()
    self.settings_ruler_pixel_size               = gSettings.value("Ruler/PixelSize",                            20)#.toInt()
    # Quick Snap
    self.settings_qsnap_enabled                  = gSettings.value("QuickSnap/Enabled",                        True)#.toBool()
    self.settings_qsnap_locator_color            = gSettings.value("QuickSnap/LocatorColor",      qRgb(255,255,  0))#.toInt()
    self.settings_qsnap_locator_size             = gSettings.value("QuickSnap/LocatorSize",                       4)#.toInt()
    self.settings_qsnap_aperture_size            = gSettings.value("QuickSnap/ApertureSize",                     10)#.toInt()
    self.settings_qsnap_endpoint                 = gSettings.value("QuickSnap/EndPoint",                       True)#.toBool()
    self.settings_qsnap_midpoint                 = gSettings.value("QuickSnap/MidPoint",                       True)#.toBool()
    self.settings_qsnap_center                   = gSettings.value("QuickSnap/Center",                         True)#.toBool()
    self.settings_qsnap_node                     = gSettings.value("QuickSnap/Node",                           True)#.toBool()
    self.settings_qsnap_quadrant                 = gSettings.value("QuickSnap/Quadrant",                       True)#.toBool()
    self.settings_qsnap_intersection             = gSettings.value("QuickSnap/Intersection",                   True)#.toBool()
    self.settings_qsnap_extension                = gSettings.value("QuickSnap/Extension",                      True)#.toBool()
    self.settings_qsnap_insertion                = gSettings.value("QuickSnap/Insertion",                     False)#.toBool()
    self.settings_qsnap_perpendicular            = gSettings.value("QuickSnap/Perpendicular",                  True)#.toBool()
    self.settings_qsnap_tangent                  = gSettings.value("QuickSnap/Tangent",                        True)#.toBool()
    self.settings_qsnap_nearest                  = gSettings.value("QuickSnap/Nearest",                       False)#.toBool()
    self.settings_qsnap_apparent                 = gSettings.value("QuickSnap/Apparent",                      False)#.toBool()
    self.settings_qsnap_parallel                 = gSettings.value("QuickSnap/Parallel",                      False)#.toBool()
    # LineWeight
    self.settings_lwt_show_lwt                   = gSettings.value("LineWeight/ShowLineWeight",               False)#.toBool()
    self.settings_lwt_real_render                = gSettings.value("LineWeight/RealRender",                    True)#.toBool()
    self.settings_lwt_default_lwt                = gSettings.value("LineWeight/DefaultLineWeight",                0)#.toReal()
    # Selection
    self.settings_selection_mode_pickfirst       = gSettings.value("Selection/PickFirst",                      True)#.toBool()
    self.settings_selection_mode_pickadd         = gSettings.value("Selection/PickAdd",                        True)#.toBool()
    self.settings_selection_mode_pickdrag        = gSettings.value("Selection/PickDrag",                      False)#.toBool()
    self.settings_selection_coolgrip_color       = gSettings.value("Selection/CoolGripColor",     qRgb(  0,  0,255))#.toInt()
    self.settings_selection_hotgrip_color        = gSettings.value("Selection/HotGripColor",      qRgb(255,  0,  0))#.toInt()
    self.settings_selection_grip_size            = gSettings.value("Selection/GripSize",                          4)#.toInt()
    self.settings_selection_pickbox_size         = gSettings.value("Selection/PickBoxSize",                       4)#.toInt()
    # Text
    self.settings_text_font                      = gSettings.value("Text/Font",                             "Arial")#.toString()
    self.settings_text_size                      = gSettings.value("Text/Size",                                  12)#.toReal()
    self.settings_text_angle                     = gSettings.value("Text/Angle",                                  0)#.toReal()
    self.settings_text_style_bold                = gSettings.value("Text/StyleBold",                          False)#.toBool()
    self.settings_text_style_italic              = gSettings.value("Text/StyleItalic",                        False)#.toBool()
    self.settings_text_style_underline           = gSettings.value("Text/StyleUnderline",                     False)#.toBool()
    self.settings_text_style_strikeout           = gSettings.value("Text/StyleStrikeOut",                     False)#.toBool()
    self.settings_text_style_overline            = gSettings.value("Text/StyleOverline",                      False)#.toBool()

    self.move(pos.x(), pos.y())
    self.resize(size.width(), size.height())
Ejemplo n.º 20
0
    def __init__(self, mw, parent=None):
        """
        Default class constructor.

        :param `mw`: The application's MainWindow instance.
        :type `mw`: `QMainWindow`_
        :param `parent`: Pointer to a parent widget instance.
        :type `parent`: `QWidget`_
        """
        super(LayerManager, self).__init__(parent)

        tr = self.tr

        self.layerModel = layerModel = QStandardItemModel(0, 8, self)

        self.layerModelSorted = layerModelSorted = QSortFilterProxyModel()
        layerModelSorted.setDynamicSortFilter(True)
        layerModelSorted.setSourceModel(layerModel)

        self.treeView = treeView = QTreeView()
        treeView.setRootIsDecorated(False)
        treeView.setAlternatingRowColors(True)
        treeView.setModel(layerModelSorted)
        treeView.setSortingEnabled(True)
        treeView.sortByColumn(0, Qt.AscendingOrder)

        mainLayout = QVBoxLayout()
        mainLayout.addWidget(treeView)
        self.setLayout(mainLayout)

        self.setWindowTitle(tr("Layer Manager"))
        self.setMinimumSize(750, 550)

        ## layerModel.setHeaderData(0, Qt.Horizontal, self.tr("Name"))
        ## layerModel.setHeaderData(1, Qt.Horizontal, self.tr("Visible"))
        ## layerModel.setHeaderData(2, Qt.Horizontal, self.tr("Frozen"))
        ## layerModel.setHeaderData(3, Qt.Horizontal, self.tr("Z Value"))
        ## layerModel.setHeaderData(4, Qt.Horizontal, self.tr("Color"))
        ## layerModel.setHeaderData(5, Qt.Horizontal, self.tr("Linetype"))
        ## layerModel.setHeaderData(6, Qt.Horizontal, self.tr("Lineweight"))
        ## layerModel.setHeaderData(7, Qt.Horizontal, self.tr("Print"))
        localMeth = layerModel.setHeaderData
        localQtHorizontal = Qt.Horizontal
        [
            localMeth(i, localQtHorizontal, tr(strng))
            for i, strng in ((0, "Name"), (1, "Visible"), (2, "Frozen"),
                             (3, "Z Value"), (4, "Color"), (5, "Linetype"),
                             (6, "Lineweight"), (7, "Print"))
        ]

        ## addLayer = self.addLayer  # local optimization
        ## addLayer("0", True, False, 0.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        ## addLayer("1", True, False, 1.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        ## addLayer("2", True, False, 2.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        ## addLayer("3", True, False, 3.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        ## addLayer("4", True, False, 4.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        ## addLayer("5", True, False, 5.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        ## addLayer("6", True, False, 6.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        ## addLayer("7", True, False, 7.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        ## addLayer("8", True, False, 8.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        ## addLayer("9", True, False, 9.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        addLayer = self.addLayer
        [
            addLayer("%s" % i, True, False, float(i), qRgb(0, 0, 0),
                     "Continuous", "Default", True) for i in range(0, 10)
        ]

        ## for i in range(0, layerModel.columnCount()):
        ##     treeView.resizeColumnToContents(i)
        localtreeViewMeth = treeView.resizeColumnToContents
        [localtreeViewMeth(i) for i in range(0, layerModel.columnCount())]

        QApplication.setOverrideCursor(Qt.ArrowCursor)
 def setUp(self):
     #Acquire resources
     super(SetPixelFloat, self).setUp()
     self.color = qRgb(255, 0, 0)
     self.image = QImage(200, 200, QImage.Format_RGB32)
Ejemplo n.º 22
0
 def insert(self, data, color=qRgb(0, 0, 0)):
     """
     Append
     """
     self.data += zip(data, [color]*len(data))
Ejemplo n.º 23
0
def DoReadSettings(self):  # void MainWindow::

    qDebug("Reading Settings...")
    theSettingsIniPath = self.gAppDir + os.sep + "settings-py.ini"

    self.gSettings = gSettings = QSettings(theSettingsIniPath,
                                           QSettings.IniFormat)
    pos = gSettings.value("Window/Position", QPoint(0, 0))  #.toPoint()
    size = gSettings.value("Window/Size", QSize(800, 600))  #.toSize()

    self.layoutState = gSettings.value("LayoutState")  #.toByteArray()
    if not self.layoutState:  # None
        qDebug("LayoutState NOT restored! Setting Default Layout...")
        # someToolBar.setVisible(True)
    else:
        self.restoreState(self.layoutState)

    # General
    self.settings_general_language = gSettings.value("Language",
                                                     "default")  #.toString()
    self.settings_general_icon_theme = gSettings.value("IconTheme",
                                                       "default")  #.toString()
    self.settings_general_icon_size = gSettings.value("IconSize",
                                                      16)  #.toInt()
    self.settings_general_mdi_bg_use_logo = gSettings.value(
        "MdiBGUseLogo", True)  #.toBool()
    self.settings_general_mdi_bg_use_texture = gSettings.value(
        "MdiBGUseTexture", True)  #.toBool()
    self.settings_general_mdi_bg_use_color = gSettings.value(
        "MdiBGUseColor", True)  #.toBool()
    self.settings_general_mdi_bg_logo = gSettings.value(
        "MdiBGLogo", "images/logo-spirals.png")  #.toString()
    self.settings_general_mdi_bg_texture = gSettings.value(
        "MdiBGTexture", "images/texture-spirals.png")  #.toString()
    self.settings_general_mdi_bg_color = gSettings.value(
        "MdiBGColor", qRgb(192, 192, 192))  #.toInt()
    self.settings_general_tip_of_the_day = gSettings.value("TipOfTheDay",
                                                           1)  #.toBool()
    self.settings_general_current_tip = gSettings.value("CurrentTip",
                                                        0)  #.toInt()
    # Display
    self.settings_display_use_opengl = gSettings.value("Display/UseOpenGL",
                                                       False)  #.toBool()
    self.settings_display_renderhint_aa = gSettings.value(
        "Display/RenderHintAntiAlias", False)  #.toBool()
    self.settings_display_renderhint_text_aa = gSettings.value(
        "Display/RenderHintTextAntiAlias", False)  #.toBool()
    self.settings_display_renderhint_smooth_pix = gSettings.value(
        "Display/RenderHintSmoothPixmap", False)  #.toBool()
    self.settings_display_renderhint_high_aa = gSettings.value(
        "Display/RenderHintHighQualityAntiAlias", False)  #.toBool()
    self.settings_display_renderhint_noncosmetic = gSettings.value(
        "Display/RenderHintNonCosmetic", False)  #.toBool()
    self.settings_display_show_scrollbars = gSettings.value(
        "Display/ShowScrollBars", True)  #.toBool()
    self.settings_display_scrollbar_widget_num = gSettings.value(
        "Display/ScrollBarWidgetNum", 0)  #.toInt()
    self.settings_display_crosshair_color = gSettings.value(
        "Display/CrossHairColor", qRgb(0, 0, 0))  #.toInt()
    self.settings_display_bg_color = gSettings.value("Display/BackgroundColor",
                                                     qRgb(235, 235,
                                                          235))  #.toInt()
    self.settings_display_selectbox_left_color = gSettings.value(
        "Display/SelectBoxLeftColor", qRgb(0, 128, 0))  #.toInt()
    self.settings_display_selectbox_left_fill = gSettings.value(
        "Display/SelectBoxLeftFill", qRgb(0, 255, 0))  #.toInt()
    self.settings_display_selectbox_right_color = gSettings.value(
        "Display/SelectBoxRightColor", qRgb(0, 0, 128))  #.toInt()
    self.settings_display_selectbox_right_fill = gSettings.value(
        "Display/SelectBoxRightFill", qRgb(0, 0, 255))  #.toInt()
    self.settings_display_selectbox_alpha = gSettings.value(
        "Display/SelectBoxAlpha", 32)  #.toInt()
    self.settings_display_zoomscale_in = gSettings.value(
        "Display/ZoomScaleIn", 2.0)  #.toFloat()
    self.settings_display_zoomscale_out = gSettings.value(
        "Display/ZoomScaleOut", 0.5)  #.toFloat()
    self.settings_display_crosshair_percent = gSettings.value(
        "Display/CrossHairPercent", 5)  #.toInt()
    self.settings_display_units = gSettings.value("Display/Units",
                                                  "mm")  #.toString()
    # Prompt
    self.settings_prompt_text_color = gSettings.value("Prompt/TextColor",
                                                      qRgb(0, 0, 0))  #.toInt()
    self.settings_prompt_bg_color = gSettings.value("Prompt/BackgroundColor",
                                                    qRgb(255, 255,
                                                         255))  #.toInt()
    self.settings_prompt_font_family = gSettings.value(
        "Prompt/FontFamily", "Monospace")  #.toString()
    self.settings_prompt_font_style = gSettings.value("Prompt/FontStyle",
                                                      "normal")  #.toString()
    self.settings_prompt_font_size = gSettings.value("Prompt/FontSize",
                                                     12)  #.toInt()
    self.settings_prompt_save_history = gSettings.value(
        "Prompt/SaveHistory", True)  #.toBool()
    self.settings_prompt_save_history_as_html = gSettings.value(
        "Prompt/SaveHistoryAsHtml", False)  #.toBool()
    self.settings_prompt_save_history_filename = gSettings.value(
        "Prompt/SaveHistoryFilename", "prompt.log")  #.toString()
    # OpenSave
    self.settings_opensave_custom_filter = gSettings.value(
        "OpenSave/CustomFilter", "supported")  #.toString()
    self.settings_opensave_open_format = gSettings.value(
        "OpenSave/OpenFormat", "*.*")  #.toString()
    self.settings_opensave_open_thumbnail = gSettings.value(
        "OpenSave/OpenThumbnail", False)  #.toBool()
    self.settings_opensave_save_format = gSettings.value(
        "OpenSave/SaveFormat", "*.*")  #.toString()
    self.settings_opensave_save_thumbnail = gSettings.value(
        "OpenSave/SaveThumbnail", False)  #.toBool()
    # Recent
    self.settings_opensave_recent_max_files = gSettings.value(
        "OpenSave/RecentMax", 10)  #.toInt()
    self.settings_opensave_recent_list_of_files = gSettings.value(
        "OpenSave/RecentFiles")  #.toStringList()
    self.settings_opensave_recent_directory = gSettings.value(
        "OpenSave/RecentDirectory")  #.toString()
    # Trimming
    self.settings_opensave_trim_dst_num_jumps = gSettings.value(
        "OpenSave/TrimDstNumJumps", 5)  #.toInt()
    # Printing
    self.settings_printing_default_device = gSettings.value(
        "Printing/DefaultDevice", "")  #.toString()
    self.settings_printing_use_last_device = gSettings.value(
        "Printing/UseLastDevice", False)  #.toBool()
    self.settings_printing_disable_bg = gSettings.value(
        "Printing/DisableBG", True)  #.toBool()
    # Grid
    self.settings_grid_show_on_load = gSettings.value("Grid/ShowOnLoad",
                                                      True)  #.toBool()
    self.settings_grid_show_origin = gSettings.value("Grid/ShowOrigin",
                                                     True)  #.toBool()
    self.settings_grid_color_match_crosshair = gSettings.value(
        "Grid/ColorMatchCrossHair", True)  #.toBool()
    self.settings_grid_color = gSettings.value("Grid/Color",
                                               qRgb(0, 0, 0))  #.toInt()
    self.settings_grid_load_from_file = gSettings.value(
        "Grid/LoadFromFile", True)  #.toBool()
    self.settings_grid_type = gSettings.value("Grid/Type",
                                              "Rectangular")  #.toString()
    self.settings_grid_center_on_origin = gSettings.value(
        "Grid/CenterOnOrigin", True)  #.toBool()
    self.settings_grid_center_x = gSettings.value("Grid/CenterX",
                                                  0.0)  #.toFloat()
    self.settings_grid_center_y = gSettings.value("Grid/CenterY",
                                                  0.0)  #.toFloat()
    self.settings_grid_size_x = gSettings.value("Grid/SizeX",
                                                100.0)  #.toFloat()
    self.settings_grid_size_y = gSettings.value("Grid/SizeY",
                                                100.0)  #.toFloat()
    self.settings_grid_spacing_x = gSettings.value("Grid/SpacingX",
                                                   25.0)  #.toFloat()
    self.settings_grid_spacing_y = gSettings.value("Grid/SpacingY",
                                                   25.0)  #.toFloat()
    self.settings_grid_size_radius = gSettings.value("Grid/SizeRadius",
                                                     50.0)  #.toFloat()
    self.settings_grid_spacing_radius = gSettings.value(
        "Grid/SpacingRadius", 25.0)  #.toFloat()
    self.settings_grid_spacing_angle = gSettings.value("Grid/SpacingAngle",
                                                       45.0)  #.toFloat()
    # Ruler
    self.settings_ruler_show_on_load = gSettings.value("Ruler/ShowOnLoad",
                                                       True)  #.toBool()
    self.settings_ruler_metric = gSettings.value("Ruler/Metric",
                                                 True)  #.toBool()
    self.settings_ruler_color = gSettings.value("Ruler/Color",
                                                qRgb(210, 210, 50))  #.toInt()
    self.settings_ruler_pixel_size = gSettings.value("Ruler/PixelSize",
                                                     20)  #.toInt()
    # Quick Snap
    self.settings_qsnap_enabled = gSettings.value("QuickSnap/Enabled",
                                                  True)  #.toBool()
    self.settings_qsnap_locator_color = gSettings.value(
        "QuickSnap/LocatorColor", qRgb(255, 255, 0))  #.toInt()
    self.settings_qsnap_locator_size = gSettings.value("QuickSnap/LocatorSize",
                                                       4)  #.toInt()
    self.settings_qsnap_aperture_size = gSettings.value(
        "QuickSnap/ApertureSize", 10)  #.toInt()
    self.settings_qsnap_endpoint = gSettings.value("QuickSnap/EndPoint",
                                                   True)  #.toBool()
    self.settings_qsnap_midpoint = gSettings.value("QuickSnap/MidPoint",
                                                   True)  #.toBool()
    self.settings_qsnap_center = gSettings.value("QuickSnap/Center",
                                                 True)  #.toBool()
    self.settings_qsnap_node = gSettings.value("QuickSnap/Node",
                                               True)  #.toBool()
    self.settings_qsnap_quadrant = gSettings.value("QuickSnap/Quadrant",
                                                   True)  #.toBool()
    self.settings_qsnap_intersection = gSettings.value(
        "QuickSnap/Intersection", True)  #.toBool()
    self.settings_qsnap_extension = gSettings.value("QuickSnap/Extension",
                                                    True)  #.toBool()
    self.settings_qsnap_insertion = gSettings.value("QuickSnap/Insertion",
                                                    False)  #.toBool()
    self.settings_qsnap_perpendicular = gSettings.value(
        "QuickSnap/Perpendicular", True)  #.toBool()
    self.settings_qsnap_tangent = gSettings.value("QuickSnap/Tangent",
                                                  True)  #.toBool()
    self.settings_qsnap_nearest = gSettings.value("QuickSnap/Nearest",
                                                  False)  #.toBool()
    self.settings_qsnap_apparent = gSettings.value("QuickSnap/Apparent",
                                                   False)  #.toBool()
    self.settings_qsnap_parallel = gSettings.value("QuickSnap/Parallel",
                                                   False)  #.toBool()
    # LineWeight
    self.settings_lwt_show_lwt = gSettings.value("LineWeight/ShowLineWeight",
                                                 False)  #.toBool()
    self.settings_lwt_real_render = gSettings.value("LineWeight/RealRender",
                                                    True)  #.toBool()
    self.settings_lwt_default_lwt = gSettings.value(
        "LineWeight/DefaultLineWeight", 0)  #.toReal()
    # Selection
    self.settings_selection_mode_pickfirst = gSettings.value(
        "Selection/PickFirst", True)  #.toBool()
    self.settings_selection_mode_pickadd = gSettings.value(
        "Selection/PickAdd", True)  #.toBool()
    self.settings_selection_mode_pickdrag = gSettings.value(
        "Selection/PickDrag", False)  #.toBool()
    self.settings_selection_coolgrip_color = gSettings.value(
        "Selection/CoolGripColor", qRgb(0, 0, 255))  #.toInt()
    self.settings_selection_hotgrip_color = gSettings.value(
        "Selection/HotGripColor", qRgb(255, 0, 0))  #.toInt()
    self.settings_selection_grip_size = gSettings.value(
        "Selection/GripSize", 4)  #.toInt()
    self.settings_selection_pickbox_size = gSettings.value(
        "Selection/PickBoxSize", 4)  #.toInt()
    # Text
    self.settings_text_font = gSettings.value("Text/Font",
                                              "Arial")  #.toString()
    self.settings_text_size = gSettings.value("Text/Size", 12)  #.toReal()
    self.settings_text_angle = gSettings.value("Text/Angle", 0)  #.toReal()
    self.settings_text_style_bold = gSettings.value("Text/StyleBold",
                                                    False)  #.toBool()
    self.settings_text_style_italic = gSettings.value("Text/StyleItalic",
                                                      False)  #.toBool()
    self.settings_text_style_underline = gSettings.value(
        "Text/StyleUnderline", False)  #.toBool()
    self.settings_text_style_strikeout = gSettings.value(
        "Text/StyleStrikeOut", False)  #.toBool()
    self.settings_text_style_overline = gSettings.value(
        "Text/StyleOverline", False)  #.toBool()

    self.move(pos.x(), pos.y())
    self.resize(size.width(), size.height())
Ejemplo n.º 24
0
    def __init__(self, mw, parent=None):
        """
        Default class constructor.

        :param `mw`: The application's MainWindow instance.
        :type `mw`: `QMainWindow`_
        :param `parent`: Pointer to a parent widget instance.
        :type `parent`: `QWidget`_
        """
        super(LayerManager, self).__init__(parent)

        tr = self.tr

        self.layerModel = layerModel = QStandardItemModel(0, 8, self)

        self.layerModelSorted = layerModelSorted = QSortFilterProxyModel()
        layerModelSorted.setDynamicSortFilter(True)
        layerModelSorted.setSourceModel(layerModel)

        self.treeView = treeView = QTreeView()
        treeView.setRootIsDecorated(False)
        treeView.setAlternatingRowColors(True)
        treeView.setModel(layerModelSorted)
        treeView.setSortingEnabled(True)
        treeView.sortByColumn(0, Qt.AscendingOrder)

        mainLayout = QVBoxLayout()
        mainLayout.addWidget(treeView)
        self.setLayout(mainLayout)

        self.setWindowTitle(tr("Layer Manager"))
        self.setMinimumSize(750, 550)

        ## layerModel.setHeaderData(0, Qt.Horizontal, self.tr("Name"))
        ## layerModel.setHeaderData(1, Qt.Horizontal, self.tr("Visible"))
        ## layerModel.setHeaderData(2, Qt.Horizontal, self.tr("Frozen"))
        ## layerModel.setHeaderData(3, Qt.Horizontal, self.tr("Z Value"))
        ## layerModel.setHeaderData(4, Qt.Horizontal, self.tr("Color"))
        ## layerModel.setHeaderData(5, Qt.Horizontal, self.tr("Linetype"))
        ## layerModel.setHeaderData(6, Qt.Horizontal, self.tr("Lineweight"))
        ## layerModel.setHeaderData(7, Qt.Horizontal, self.tr("Print"))
        localMeth = layerModel.setHeaderData
        localQtHorizontal = Qt.Horizontal
        [localMeth(i, localQtHorizontal, tr(strng))
            for i, strng in ((0, "Name"),
                             (1, "Visible"),
                             (2, "Frozen"),
                             (3, "Z Value"),
                             (4, "Color"),
                             (5, "Linetype"),
                             (6, "Lineweight"),
                             (7, "Print")
                             )]

        ## addLayer = self.addLayer  # local optimization
        ## addLayer("0", True, False, 0.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        ## addLayer("1", True, False, 1.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        ## addLayer("2", True, False, 2.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        ## addLayer("3", True, False, 3.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        ## addLayer("4", True, False, 4.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        ## addLayer("5", True, False, 5.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        ## addLayer("6", True, False, 6.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        ## addLayer("7", True, False, 7.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        ## addLayer("8", True, False, 8.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        ## addLayer("9", True, False, 9.0, qRgb(0, 0, 0), "Continuous", "Default", True)
        addLayer = self.addLayer
        [addLayer("%s" % i, True, False, float(i), qRgb(0, 0, 0), "Continuous", "Default", True)
            for i in range(0, 10)]

        ## for i in range(0, layerModel.columnCount()):
        ##     treeView.resizeColumnToContents(i)
        localtreeViewMeth = treeView.resizeColumnToContents
        [localtreeViewMeth(i)
            for i in range(0, layerModel.columnCount())]

        QApplication.setOverrideCursor(Qt.ArrowCursor)