コード例 #1
0
 def draw(self, context, width, height):
     turtle = uturtle.KfTurtle()
     turtle.drawingSurface = gtkdrawingsurface.GTKDrawingSurface()
     turtle.drawingSurface.setDrawingContext(context)
     turtle.drawOptions.drawStems = True
     turtle.drawOptions.draw3DObjects = True
     self.drawPlants(turtle, width, height)
コード例 #2
0
ファイル: viewer.py プロジェクト: overdhose/PlantStudio
 def draw(self, context, width, height):    
     turtle = uturtle.KfTurtle()
     turtle.drawingSurface = gtkdrawingsurface.GTKDrawingSurface()
     turtle.drawingSurface.setDrawingContext(context)
     turtle.drawOptions.drawStems = True
     turtle.drawOptions.draw3DObjects = True
     #self.testSimple(turtle)
     #self.testPolygon(turtle)
     #self.testTDO(turtle)
     prof.runcall(self.testPlant, turtle, width, height)
コード例 #3
0
ファイル: Utdo.pas.py プロジェクト: overdhose/PlantStudio
    def overlayBoundsRect(self, turtleProxy, scale):
        i = 0L
        turtle = KfTurtle()
        oldSetting = false

        turtle = uturtle.KfTurtle(turtleProxy)
        oldSetting = turtle.drawingSurface.fillingTriangles
        turtle.drawingSurface.fillingTriangles = false
        turtle.drawTrianglesFromBoundsRect(self.boundsRect)
        turtle.drawingSurface.fillingTriangles = oldSetting
コード例 #4
0
ファイル: Utdo.pas.py プロジェクト: overdhose/PlantStudio
    def draw(self, turtleProxy, scale, longName, shortName, dxfIndex, partID):
        result = TRect()
        i = 0L
        triangle = KfIndexTriangle()
        realTriangle = KfTriangle()
        turtle = KfTurtle()
        minZ = 0.0

        result = Rect(0, 0, 0, 0)
        minZ = 0
        self.zForSorting = 0
        turtle = uturtle.KfTurtle(turtleProxy)
        if turtle.ifExporting_exclude3DObject(scale):
            return result
        turtle.clearRecording()
        self.boundsRect = Rect(0, 0, 0, 0)
        if self.pointsInUse > 0:
            for i in range(0, self.pointsInUse):
                KfPoint3D_addPointToBoundsRect(
                    self.boundsRect,
                    turtle.transformAndRecord(self.points[i], scale))
        result = self.boundsRect
        if not turtle.drawOptions.draw3DObjects:
            return result
        if turtle.drawOptions.draw3DObjectsAsRects:
            turtle.drawTrianglesFromBoundsRect(self.boundsRect)
            return result
        # prepare
        turtle.ifExporting_start3DObject(longName + " 3D object", shortName,
                                         turtle.drawingSurface.foreColor,
                                         dxfIndex)
        if turtle.exportingToFile():
            # draw
            self.write3DExportElements(turtle, scale, partID)
        elif self.triangles.Count > 0:
            for i in range(1, self.triangles.Count + 1):
                triangle = self.triangleForIndex(i)
                realTriangle = turtle.drawTriangleFromIndexes(
                    triangle.pointIndexes[0], triangle.pointIndexes[1],
                    triangle.pointIndexes[2], partID)
                if (turtle.drawOptions.sortPolygons) and (
                        turtle.drawOptions.sortTdosAsOneItem) and (realTriangle
                                                                   != None):
                    if i == 1:
                        minZ = realTriangle.zForSorting
                    elif realTriangle.zForSorting < minZ:
                        minZ = realTriangle.zForSorting
                    realTriangle.tdo = self
        self.zForSorting = minZ
        turtle.ifExporting_end3DObject()
        return result
コード例 #5
0
 def write3DOutputFileToFileName(self, selectedPlants, excludeInvisiblePlants, excludeNonSelectedPlants, fileName, outputType):
     plant = PdPlant()
     i = 0
     includePlant = false
     includeRect = TRect()
     includedPlants = TList()
     translatePlants = false
     turtle = KfTurtle()
     
     usupport.setDecimalSeparator()
     includedPlants = None
     includeRect = self.combinedPlantBoundsRects(selectedPlants, excludeInvisiblePlants, excludeNonSelectedPlants)
     if (usupport.rWidth(includeRect) <= 0) or (usupport.rHeight(includeRect) <= 0):
         return
     includedPlants = delphi_compatability.TList().Create()
     turtle = uturtle.KfTurtle().createFor3DOutput(outputType, fileName)
     try:
         turtle.start3DExportFile()
         if self.plants.Count > 0:
             for i in range(0, self.plants.Count):
                 # count the plants to be drawn so we know if there is more than one
                 plant = uplant.PdPlant(self.plants.Items[i])
                 includePlant = true
                 if excludeInvisiblePlants:
                     includePlant = includePlant and not plant.hidden
                 if excludeNonSelectedPlants:
                     includePlant = includePlant and (selectedPlants.IndexOf(plant) >= 0)
                 if includePlant:
                     includedPlants.Add(plant)
         if includedPlants.Count <= 1:
             # if only one plant, don't translate or scale
             translatePlants = false
         else:
             translatePlants = udomain.domain.exportOptionsFor3D[outputType].translatePlantsToWindowPositions
         if includedPlants.Count > 0:
             for i in range(0, includedPlants.Count):
                 # iterate over included plants
                 uplant.PdPlant(includedPlants.Items[i]).saveToGlobal3DOutputFile(i, translatePlants, includeRect, outputType, turtle)
     finally:
         turtle.end3DExportFile()
         turtle.free
         turtle = None
         includedPlants.free
         includedPlants = None
コード例 #6
0
ファイル: Utdo.pas.py プロジェクト: overdhose/PlantStudio
    def bestPointForDrawingAtScale(self, turtleProxy, origin, bitmapSize,
                                   scale):
        result = TPoint()
        i = 0L
        turtle = KfTurtle()

        turtle = uturtle.KfTurtle(turtleProxy)
        self.boundsRect = Rect(0, 0, 0, 0)
        turtle.reset()
        if self.pointsInUse > 0:
            for i in range(0, self.pointsInUse):
                KfPoint3D_addPointToBoundsRect(
                    self.boundsRect,
                    turtle.transformAndRecord(self.points[i], scale))
        result.X = origin.X + bitmapSize.X / 2 - usupport.rWidth(
            self.boundsRect) / 2 - self.boundsRect.Left
        result.Y = origin.Y + bitmapSize.Y / 2 - usupport.rHeight(
            self.boundsRect) / 2 - self.boundsRect.Top
        return result
コード例 #7
0
ファイル: Utdo.pas.py プロジェクト: overdhose/PlantStudio
    def write3DExportElements(self, turtleProxy, scale, partID):
        fileExportSurface = KfFileExportSurface()
        i = 0
        turtle = KfTurtle()
        triangle = KfIndexTriangle()
        firstPtIndex = 0L

        # do NOT pass the array on because a tdo could be really big
        # some write out lists of points then triangles; some draw each triangle
        turtle = uturtle.KfTurtle(turtleProxy)
        fileExportSurface = turtle.fileExportSurface()
        if fileExportSurface == None:
            raise GeneralException.create(
                "Problem: No 3D drawing surface in method KfObject3D.write3DExportElements."
            )
        if turtle.writingTo == u3dexport.k3DS:
            fileExportSurface.startVerticesAndTriangles()
            if turtle.writingToLWO():
                firstPtIndex = fileExportSurface.numPoints
            else:
                firstPtIndex = 0
            if self.pointsInUse > 0:
                for i in range(0, self.pointsInUse):
                    fileExportSurface.addPoint(
                        turtle.transformAndRecord(self.points[i], scale))
            for i in range(1, self.triangles.Count + 1):
                triangle = self.triangleForIndex(i)
                fileExportSurface.addTriangle(
                    firstPtIndex + triangle.pointIndexes[0] - 1,
                    firstPtIndex + triangle.pointIndexes[1] - 1,
                    firstPtIndex + triangle.pointIndexes[2] - 1)
                if fileExportSurface.options.makeTrianglesDoubleSided:
                    fileExportSurface.addTriangle(
                        firstPtIndex + triangle.pointIndexes[0] - 1,
                        firstPtIndex + triangle.pointIndexes[2] - 1,
                        firstPtIndex + triangle.pointIndexes[1] - 1)
            fileExportSurface.endVerticesAndTriangles()
            # PDF PORT -- added semicolon
        elif turtle.writingTo == u3dexport.kOBJ:
            fileExportSurface.startVerticesAndTriangles()
            if turtle.writingToLWO():
                firstPtIndex = fileExportSurface.numPoints
            else:
                firstPtIndex = 0
            if self.pointsInUse > 0:
                for i in range(0, self.pointsInUse):
                    fileExportSurface.addPoint(
                        turtle.transformAndRecord(self.points[i], scale))
            for i in range(1, self.triangles.Count + 1):
                triangle = self.triangleForIndex(i)
                fileExportSurface.addTriangle(
                    firstPtIndex + triangle.pointIndexes[0] - 1,
                    firstPtIndex + triangle.pointIndexes[1] - 1,
                    firstPtIndex + triangle.pointIndexes[2] - 1)
                if fileExportSurface.options.makeTrianglesDoubleSided:
                    fileExportSurface.addTriangle(
                        firstPtIndex + triangle.pointIndexes[0] - 1,
                        firstPtIndex + triangle.pointIndexes[2] - 1,
                        firstPtIndex + triangle.pointIndexes[1] - 1)
            fileExportSurface.endVerticesAndTriangles()
            # PDF PORT -- added semicolon
        elif turtle.writingTo == u3dexport.kVRML:
            fileExportSurface.startVerticesAndTriangles()
            if turtle.writingToLWO():
                firstPtIndex = fileExportSurface.numPoints
            else:
                firstPtIndex = 0
            if self.pointsInUse > 0:
                for i in range(0, self.pointsInUse):
                    fileExportSurface.addPoint(
                        turtle.transformAndRecord(self.points[i], scale))
            for i in range(1, self.triangles.Count + 1):
                triangle = self.triangleForIndex(i)
                fileExportSurface.addTriangle(
                    firstPtIndex + triangle.pointIndexes[0] - 1,
                    firstPtIndex + triangle.pointIndexes[1] - 1,
                    firstPtIndex + triangle.pointIndexes[2] - 1)
                if fileExportSurface.options.makeTrianglesDoubleSided:
                    fileExportSurface.addTriangle(
                        firstPtIndex + triangle.pointIndexes[0] - 1,
                        firstPtIndex + triangle.pointIndexes[2] - 1,
                        firstPtIndex + triangle.pointIndexes[1] - 1)
            fileExportSurface.endVerticesAndTriangles()
            # PDF PORT -- added semicolon
        elif turtle.writingTo == u3dexport.kLWO:
            fileExportSurface.startVerticesAndTriangles()
            if turtle.writingToLWO():
                firstPtIndex = fileExportSurface.numPoints
            else:
                firstPtIndex = 0
            if self.pointsInUse > 0:
                for i in range(0, self.pointsInUse):
                    fileExportSurface.addPoint(
                        turtle.transformAndRecord(self.points[i], scale))
            for i in range(1, self.triangles.Count + 1):
                triangle = self.triangleForIndex(i)
                fileExportSurface.addTriangle(
                    firstPtIndex + triangle.pointIndexes[0] - 1,
                    firstPtIndex + triangle.pointIndexes[1] - 1,
                    firstPtIndex + triangle.pointIndexes[2] - 1)
                if fileExportSurface.options.makeTrianglesDoubleSided:
                    fileExportSurface.addTriangle(
                        firstPtIndex + triangle.pointIndexes[0] - 1,
                        firstPtIndex + triangle.pointIndexes[2] - 1,
                        firstPtIndex + triangle.pointIndexes[1] - 1)
            fileExportSurface.endVerticesAndTriangles()
            # PDF PORT -- added semicolon
        else:
            for i in range(1, self.triangles.Count + 1):
                triangle = self.triangleForIndex(i)
                turtle.drawTriangleFromIndexes(triangle.pointIndexes[0],
                                               triangle.pointIndexes[1],
                                               triangle.pointIndexes[2],
                                               partID)
                if fileExportSurface.options.makeTrianglesDoubleSided:
                    turtle.drawTriangleFromIndexes(triangle.pointIndexes[0],
                                                   triangle.pointIndexes[2],
                                                   triangle.pointIndexes[1],
                                                   partID)