def draw_cardinal(self, S, W, E, N, D, EE, F, G):

        self.drawlines = list()

        gc = gic.GraphicsCollection()

        points = [QtCore.QPointF(x, y) for x, y in [S, N]]
        gc.Polyline(QtGui.QPolygonF(points), '')
        gc.pen.setColor(QtGui.QColor(255, 0, 0, 255))
        gc.pen.setWidthF(3.0)
        gc.pen.setCosmetic(True)
        gc.brush.setStyle(QtCore.Qt.NoBrush)
        meshline = GraphicsItem.GraphicsItem(gc)
        self.drawlines.append(meshline)

        gc = gic.GraphicsCollection()
        points = [QtCore.QPointF(x, y) for x, y in [E, W]]
        gc.Polyline(QtGui.QPolygonF(points), '')
        gc.pen.setColor(QtGui.QColor(0, 255, 0, 255))
        gc.pen.setWidthF(3.0)
        gc.pen.setCosmetic(True)
        gc.brush.setStyle(QtCore.Qt.NoBrush)
        meshline = GraphicsItem.GraphicsItem(gc)
        self.drawlines.append(meshline)

        gc = gic.GraphicsCollection()
        points = [QtCore.QPointF(x, y) for x, y in [D, EE, F, G, D]]
        gc.Polyline(QtGui.QPolygonF(points), '')
        gc.pen.setColor(QtGui.QColor(0, 0, 255, 255))
        gc.pen.setWidthF(5.0)
        gc.pen.setCosmetic(True)
        gc.brush.setStyle(QtCore.Qt.NoBrush)
        meshline = GraphicsItem.GraphicsItem(gc)
        self.drawlines.append(meshline)
        '''
Exemple #2
0
    def makeLeCircle(self, rc, xc, yc, xle, yle):

        # delete exitsing LE circle ItemGroup from scene
        if hasattr(self.mainwindow.airfoil, 'le_circle'):
            self.mainwindow.scene.removeItem(self.mainwindow.airfoil.le_circle)
            del self.mainwindow.airfoil.le_circle

        # put LE circle, center and tangent point in a list
        circles = list()

        circle = gic.GraphicsCollection()
        circle.pen.setColor(QtGui.QColor(0, 150, 0, 255))
        circle.pen.setWidthF(0.3)
        # no pen thickness change when zoomed
        circle.pen.setCosmetic(True)
        circle.brush.setColor(QtGui.QColor(10, 200, 10, 150))
        circle.Circle(xc, yc, rc)

        circle = GraphicsItem.GraphicsItem(circle)
        circles.append(circle)

        circle = gic.GraphicsCollection()
        circle.pen.setColor(QtGui.QColor(255, 0, 0, 255))
        circle.pen.setWidthF(0.3)
        # no pen thickness change when zoomed
        circle.pen.setCosmetic(True)
        circle.brush.setColor(QtGui.QColor(255, 0, 0, 255))
        circle.Circle(xc, yc, 0.0002)

        circle = GraphicsItem.GraphicsItem(circle)
        circles.append(circle)

        circle = gic.GraphicsCollection()
        circle.pen.setColor(QtGui.QColor(255, 0, 0, 255))
        circle.pen.setWidthF(1.6)
        # no pen thickness change when zoomed
        circle.pen.setCosmetic(True)
        circle.brush.setColor(QtGui.QColor(255, 0, 0, 255))
        circle.Circle(xle, yle, 0.0002)

        circle = GraphicsItem.GraphicsItem(circle)
        circles.append(circle)

        self.mainwindow.airfoil.le_circle = \
            self.mainwindow.scene.createItemGroup(circles)
        self.mainwindow.airfoil.le_circle.setZValue(110)

        self.mainwindow.centralwidget.cb7.setChecked(True)
        self.mainwindow.centralwidget.cb7.setEnabled(True)
Exemple #3
0
    def makePolygonMarkers(self):
        """Create marker for polygon contour"""

        self.polygonMarkers = list()

        for x, y in zip(*self.raw_coordinates):

            marker = gic.GraphicsCollection()
            marker.pen.setColor(QtGui.QColor(60, 60, 80, 255))
            marker.pen.setWidthF(1.6)
            # no pen thickness change when zoomed
            marker.pen.setCosmetic(True)
            marker.brush.setColor(QtGui.QColor(217, 63, 122, 150))
            # circle size doesn't do anything here
            # this is indirectly deactivated because we don't want to change
            # marker size during zoom
            # the sizing is thus handled in graphicsview adjustMarkerSize
            # there a fixed markersize in pixels is taken from settings which
            # can be configured by the user

            # FIXME
            # FIXME this size still affects the items size for the scene.itemsBoundingRect()
            # FIXME this is affecting slots.onViewAll()
            # FIXME there it is not directly visible as adjustMarkerSize is called
            # FIXME the fit acts to the size that shows up when adjustMarkerSize
            # FIXME would not be called
            # FIXME
            marker.Circle(x, y, 0.004)

            markerItem = GraphicsItem.GraphicsItem(marker)

            self.polygonMarkers.append(markerItem)
Exemple #4
0
    def drawCamber(self, camber):

        self.pencolor = QtGui.QColor(220, 80, 80, 255)
        self.penwidth = 3.5

        # instantiate a graphics item
        camberline = gic.GraphicsCollection()
        # make it polygon type and populate its points
        points = [QtCore.QPointF(x, y) for x, y in zip(*camber)]
        camberline.Polyline(QtGui.QPolygonF(points))
        # set its properties
        camberline.pen.setColor(self.pencolor)
        camberline.pen.setWidthF(self.penwidth)
        # camberline.pen.setStyle(QtCore.Qt.DashLine)
        camberline.pen.setStyle(QtCore.Qt.DotLine)
        # no pen thickness change when zoomed
        camberline.pen.setCosmetic(True)
        camberline.brush.setColor(self.brushcolor)
        # add the spline polygon without filling
        camberline.brush.setStyle(QtCore.Qt.NoBrush)

        # remove items from iterated uses of spline/refine and trailing edge
        if hasattr(self, 'camberline'):
            self.mainwindow.scene.removeItem(self.camberline)
        self.camberline = GraphicsItem.GraphicsItem(camberline)
        self.camberline.setAcceptHoverEvents(False)
        self.camberline.setZValue(99)
        self.mainwindow.scene.addItem(self.camberline)
        self.mainwindow.centralwidget.cb9.setChecked(True)
        self.mainwindow.centralwidget.cb9.setEnabled(True)
Exemple #5
0
    def makeChord(self):
        line = gic.GraphicsCollection()
        color = QtGui.QColor(52, 235, 122, 255)
        line.pen.setColor(color)
        line.pen.setWidthF(2.5)
        # no pen thickness change when zoomed
        line.pen.setCosmetic(True)
        # setting CustomDashLine not needed as it will be set
        # implicitely by Qt when CustomDashLine is applied
        # put it just for completeness
        line.pen.setStyle(QtCore.Qt.CustomDashLine)
        stroke = 10
        dot = 1
        space = 5
        line.pen.setDashPattern([stroke, space, dot, space])
        index_min = np.argmin(self.raw_coordinates[0])
        index_max = np.argmax(self.raw_coordinates[0])
        x1 = self.raw_coordinates[0][index_min]
        y1 = self.raw_coordinates[1][index_min]
        x2 = self.raw_coordinates[0][index_max]
        y2 = self.raw_coordinates[1][index_max]
        line.Line(x1, y1, x2, y2)

        self.chord = GraphicsItem.GraphicsItem(line)
        self.chord.setZValue(99)
        self.chord.setAcceptHoverEvents(False)
Exemple #6
0
    def makeContourSpline(self):
        """Add splined and refined airfoil points as GraphicsItem to
        the scene
        """
        self.pencolor = QtGui.QColor(80, 80, 220, 255)
        self.penwidth = 3.5

        # instantiate a graphics item
        splinecontour = gic.GraphicsCollection()
        # make it polygon type and populate its points
        points = [QtCore.QPointF(x, y) for x, y in zip(*self.spline_data[0])]
        splinecontour.Polygon(QtGui.QPolygonF(points), self.name)
        # set its properties
        splinecontour.pen.setColor(self.pencolor)
        splinecontour.pen.setWidthF(self.penwidth)
        # no pen thickness change when zoomed
        splinecontour.pen.setCosmetic(True)
        splinecontour.brush.setColor(self.brushcolor)
        # add the pline polygon without filling
        splinecontour.brush.setStyle(QtCore.Qt.NoBrush)

        # remove items from iterated uses of spline/refine and trailing edge
        if hasattr(self, 'contourSpline'):
            self.mainwindow.scene.removeItem(self.contourSpline)
        self.contourSpline = GraphicsItem.GraphicsItem(splinecontour)
        self.mainwindow.scene.addItem(self.contourSpline)

        # remove items from iterated uses of spline/refine and trailing edge
        if hasattr(self, 'splineMarkersGroup'):
            self.mainwindow.scene.removeItem(self.splineMarkersGroup)
        self.makeSplineMarkers()
        self.splineMarkersGroup = self.mainwindow.scene. \
            createItemGroup(self.splineMarkers)

        self.mainwindow.airfoil.contourSpline.brush. \
            setStyle(QtCore.Qt.SolidPattern)
        color = QtGui.QColor()
        color.setNamedColor('#7c8696')
        self.contourSpline.brush.setColor(color)
        self.polygonMarkersGroup.setZValue(100)
        self.chord.setZValue(99)

        # switch off raw contour and toogle corresponding checkbox
        if self.polygonMarkersGroup.isVisible():
            self.mainwindow.centralwidget.cb2.click()

        # activate ckeck boxes for contour points and chord in viewing options
        self.mainwindow.centralwidget.cb3.setChecked(True)
        self.mainwindow.centralwidget.cb3.setEnabled(True)
        self.mainwindow.centralwidget.cb4.setChecked(True)
        self.mainwindow.centralwidget.cb4.setEnabled(True)

        self.contourPolygon.brush.setStyle(QtCore.Qt.NoBrush)
        self.contourPolygon.pen.setStyle(QtCore.Qt.NoPen)
        self.mainwindow.view.adjustMarkerSize()
Exemple #7
0
    def makeContourPolygon(self, coordinates):
        """Add airfoil points as GraphicsItem to the scene"""

        # instantiate a graphics item
        contour = gic.GraphicsCollection()
        # make it polygon type and populate its points
        points = [QtCore.QPointF(x, y) for x, y in zip(*coordinates)]
        contour.Polygon(QtGui.QPolygonF(points), self.name)
        # set its properties
        contour.pen.setColor(self.pencolor)
        contour.pen.setWidthF(self.penwidth)
        # no pen thickness change when zoomed
        contour.pen.setCosmetic(True)
        contour.brush.setColor(self.brushcolor)

        self.contourPolygon = GraphicsItem.GraphicsItem(contour)
Exemple #8
0
    def makeSplineMarkers(self):
        """Create marker for polygon contour"""

        self.splineMarkers = list()

        for x, y in zip(*self.spline_data[0]):

            # put airfoil contour points as graphicsitem
            splinemarker = gic.GraphicsCollection()
            splinemarker.pen.setColor(QtGui.QColor(60, 60, 80, 255))
            splinemarker.brush.setColor(QtGui.QColor(180, 180, 50, 230))
            splinemarker.pen.setWidthF(1.6)
            # no pen thickness change when zoomed
            splinemarker.pen.setCosmetic(True)

            splinemarker.Circle(x, y, 0.004)

            splineMarkerItem = GraphicsItem.GraphicsItem(splinemarker)

            self.splineMarkers.append(splineMarkerItem)
Exemple #9
0
    def draw_connectivity(self, vertices, deleted_nodes):

        self.connections = list()

        # instantiate a graphics item
        marker = gic.GraphicsCollection()
         # set its properties
        marker.pen.setColor(QtGui.QColor(60, 60, 255, 255))
        marker.brush.setColor(QtGui.QColor(255, 50, 50, 230))
        marker.pen.setWidthF(1.6)
        # no pen thickness change when zoomed
        marker.pen.setCosmetic(True)

        for node in deleted_nodes:
            marker.Circle(vertices[node][0], vertices[node][1], 0.003)
            marker_item = GraphicsItem.GraphicsItem(marker)
            self.connections.append(marker_item)
            
        # add to the scene
        self.connections = self.mainwindow.scene. \
            createItemGroup(self.connections)
Exemple #10
0
    def drawMesh(self, airfoil):

        # toggle spline points
        self.mainwindow.centralwidget.cb3.click()

        # delete old mesh if existing
        if hasattr(airfoil, 'mesh'):
            logger.debug('MESH item type: {}'.format(type(airfoil.mesh)))
            self.mainwindow.scene.removeItem(airfoil.mesh)

        mesh = list()

        for block in self.blocks:
            for lines in [block.getULines(), block.getVLines()]:
                for line in lines:

                    # instantiate a graphics item
                    contour = gic.GraphicsCollection()
                    # make it polygon type and populate its points
                    points = [QtCore.QPointF(x, y) for x, y in line]
                    contour.Polyline(QtGui.QPolygonF(points), '')
                    # set its properties
                    contour.pen.setColor(QtGui.QColor(0, 0, 0, 255))
                    contour.pen.setWidthF(0.8)
                    contour.pen.setCosmetic(True)
                    contour.brush.setStyle(QtCore.Qt.NoBrush)

                    # add contour as a GraphicsItem to the scene
                    # these are the objects which are drawn in the GraphicsView
                    meshline = GraphicsItem.GraphicsItem(contour)

                    mesh.append(meshline)
        airfoil.mesh = self.mainwindow.scene.createItemGroup(mesh)

        # activate viewing options if mesh is created and displayed
        self.mainwindow.centralwidget.cb6.setChecked(True)
        self.mainwindow.centralwidget.cb6.setEnabled(True)
Exemple #11
0
def addTestItems(scene):

    # add items to the scene
    circle1 = gic.GraphicsCollection()
    circle1.Circle(0., 0., 0.1)
    circle1.pen.setWidthF(0.2)
    circle1.pen.setColor(QtGui.QColor(0, 0, 0, 255))
    circle1.brush.setColor(QtGui.QColor(255, 255, 0, 255))

    circle2 = gic.GraphicsCollection()
    circle2.Circle(-0.3, -0.3, 0.3)
    circle2.pen.setWidthF(0.02)
    circle2.pen.setColor(QtGui.QColor(0, 0, 0, 255))
    circle2.brush.setColor(QtGui.QColor(255, 0, 0, 255))

    circle3 = gic.GraphicsCollection()
    circle3.Circle(0.5, 0.5, 0.2)
    circle3.pen.setWidthF(0.02)
    circle3.pen.setColor(QtGui.QColor(0, 255, 0, 255))
    circle3.brush.setColor(QtGui.QColor(30, 30, 255, 100))

    circle4 = gic.GraphicsCollection()
    circle4.Circle(-0.1, 0.4, 0.2)
    circle4.pen.setWidthF(0.02)
    circle4.pen.setColor(QtGui.QColor(0, 0, 255, 255))
    circle4.brush.setColor(QtGui.QColor(30, 30, 30, 255))

    rectangle1 = gic.GraphicsCollection()
    rectangle1.Rectangle(-0.20, 0.10, 0.70, 0.35)
    rectangle1.pen.setWidthF(0.02)
    rectangle1.pen.setColor(QtGui.QColor(0, 0, 255, 255))
    rectangle1.brush.setColor(QtGui.QColor(0, 255, 0, 180))

    text1 = gic.GraphicsCollection()
    font = QtGui.QFont('Arial', 20)
    font.setBold(True)
    text1.Text(0, 0.90, 'This is a text', font)
    text1.pen.setColor(QtGui.QColor(50, 30, 200, 255))

    point1 = gic.GraphicsCollection()
    point1.Point(0, 0)
    point1.pen.setColor(QtGui.QColor(255, 0, 0, 255))
    point1.pen.setWidthF(0.02)

    polygon1 = gic.GraphicsCollection()
    polygon = QtGui.QPolygonF()
    polygon.append(QtCore.QPointF(0.20, 0.10))
    polygon.append(QtCore.QPointF(0.45, 0.10))
    polygon.append(QtCore.QPointF(0.45, -0.40))
    polygon.append(QtCore.QPointF(0.15, -0.40))
    polygon.append(QtCore.QPointF(0.0, 0.0))
    polygon1.pen.setWidthF(0.02)
    polygon1.pen.setColor(QtGui.QColor(0, 0, 0, 255))
    polygon1.brush.setColor(QtGui.QColor(0, 0, 255, 150))
    polygon1.Polygon(polygon)

    # create on the fly scene attributes which can be accessed deleteTestItems
    scene.itemc1 = GraphicsItem.GraphicsItem(circle1)
    scene.itemc2 = GraphicsItem.GraphicsItem(circle2)
    scene.itemc3 = GraphicsItem.GraphicsItem(circle3)
    scene.itemc4 = GraphicsItem.GraphicsItem(circle4)
    scene.itemr1 = GraphicsItem.GraphicsItem(rectangle1)

    # add test items to the scene
    scene.addItem(scene.itemc1)
    scene.addItem(scene.itemc2)
    scene.addItem(scene.itemc3)
    scene.addItem(scene.itemc4)
    scene.addItem(scene.itemr1)