def calculateNumberOfFrames(self): scaleMultiplier = 0.0 if self.options.animateBy == udomain.kAnimateByAge: self.plantMaxAgeLabel.Caption = "Maximum age = " + IntToStr(self.plant.pGeneral.ageAtMaturity) self.plantMaxAgeLabel.Visible = true self.options.frameCount = self.plant.pGeneral.ageAtMaturity / self.options.ageIncrement + 1 elif self.options.animateBy == udomain.kAnimateByXRotation: self.plantMaxAgeLabel.Visible = false self.options.frameCount = 360 / abs(self.options.xRotationIncrement) self.fileNumberLabel.Caption = "Number of files: " + IntToStr(self.options.frameCount) scaleMultiplier = umath.safedivExcept(1.0 * self.options.resolution_pixelsPerInch, 1.0 * delphi_compatability.Screen.PixelsPerInch, 1.0) self.options.scaledSize = Point(intround(usupport.rWidth(self.plant.boundsRect_pixels()) * scaleMultiplier), intround(usupport.rHeight(self.plant.boundsRect_pixels()) * scaleMultiplier)) self.animationSizeLabel.Caption = "Animation size: " + IntToStr(self.options.scaledSize.X) + " x " + IntToStr(self.options.scaledSize.Y) self.options.fileSize = intround(self.options.frameCount * self.options.scaledSize.X * self.options.scaledSize.Y * usupport.bitsPerPixelForColorType(self.options.colorType) / 8.0) + FIX_sizeof(delphi_compatability.TBitmapInfo) if self.options.fileSize < 1024: self.fileSizeLabel.Caption = "Estimated total size: " + IntToStr(self.options.fileSize) + " bytes" elif self.options.fileSize < 1024 * 1024: self.fileSizeLabel.Caption = "Estimated total size: " + IntToStr(self.options.fileSize / 1024) + " KB" else: self.fileSizeLabel.Caption = "Estimated total size: " + FloatToStrF(self.options.fileSize / (1024 * 1024), UNRESOLVED.ffFixed, 7, 1) + " MB" if self.options.fileSize >= 10.0 * 1024 * 1024: self.fileSizeLabel.Font.Style = [UNRESOLVED.fsBold, ] else: self.fileSizeLabel.Font.Style = []
def updateCellSizeAndCountForSelection(self): excludeInvisiblePlants = false excludeNonSelectedPlants = false cellRect = TRect() scaleMultiplier = 0.0 fileSize = 0L excludeInvisiblePlants = not self.useAllPlants.Checked excludeNonSelectedPlants = self.useSelectedPlants.Checked cellRect = udomain.domain.plantManager.largestPlantBoundsRect(umain.MainForm.selectedPlants, excludeInvisiblePlants, excludeNonSelectedPlants) scaleMultiplier = umath.safedivExcept(1.0 * self.options.resolution_pixelsPerInch, 1.0 * delphi_compatability.Screen.PixelsPerInch, 1.0) self.options.cellSize = Point(intround(usupport.rWidth(cellRect) * scaleMultiplier), intround(usupport.rHeight(cellRect) * scaleMultiplier)) if self.useAllPlants.Checked: self.options.cellCount = udomain.domain.plantManager.plants.Count elif self.useVisiblePlants.Checked: self.options.cellCount = udomain.domain.plantManager.visiblePlantCount() elif self.useSelectedPlants.Checked: self.options.cellCount = umain.MainForm.selectedPlants.Count self.cellSizeLabel.Caption = "Nozzle/tube cell width: " + IntToStr(self.options.cellSize.X) + " height: " + IntToStr(self.options.cellSize.Y) self.cellCountLabel.Caption = "Number of items: " + IntToStr(self.options.cellCount) fileSize = intround(self.options.cellCount * self.options.cellSize.X * self.options.cellSize.Y * usupport.bitsPerPixelForColorType(self.options.colorType) / 8.0) + FIX_sizeof(delphi_compatability.TBitmapInfo) if fileSize < 1024: self.fileSizeLabel.Caption = "Estimated file size: " + IntToStr(fileSize) + " bytes" elif fileSize < 1024 * 1024: self.fileSizeLabel.Caption = "Estimated file size: " + IntToStr(fileSize / 1024) + " KB" else: self.fileSizeLabel.Caption = "Estimated file size: " + FloatToStrF(fileSize / (1024 * 1024), UNRESOLVED.ffFixed, 7, 1) + " MB" if fileSize >= 10.0 * 1024 * 1024: self.fileSizeLabel.Font.Style = [UNRESOLVED.fsBold, ] else: self.fileSizeLabel.Font.Style = []
def updateForImageSelection(self): pixelWidth = 0 pixelHeight = 0 screenColorBits = 0 screenColors = 0L inchWidth = 0.0 inchHeight = 0.0 screenDC = HDC() megabytesNeeded = 0.0 self.updateSelectionRectFromMainWindow() # fill in labels pixelWidth = usupport.rWidth(self.selectionRectFromMainWindow) pixelHeight = usupport.rHeight(self.selectionRectFromMainWindow) inchWidth = umath.safedivExcept(pixelWidth, delphi_compatability.Screen.PixelsPerInch, 0) inchHeight = umath.safedivExcept(pixelHeight, delphi_compatability.Screen.PixelsPerInch, 0) self.selectedImageInfoLabel.Caption = "Selection: " + IntToStr(pixelWidth) + " x " + IntToStr(pixelHeight) + " pixels, " + floatStr(inchWidth) + " x " + floatStr(inchHeight) + " inches" screenDC = UNRESOLVED.GetDC(0) try: screenColorBits = (UNRESOLVED.GetDeviceCaps(screenDC, delphi_compatability.BITSPIXEL) * UNRESOLVED.GetDeviceCaps(screenDC, delphi_compatability.PLANES)) finally: UNRESOLVED.ReleaseDC(0, screenDC) if screenColorBits != 32: screenColors = 1 << screenColorBits self.screenInfoLabel.Caption = "Screen: " + IntToStr(delphi_compatability.Screen.PixelsPerInch) + " pixels/inch, " + IntToStr(screenColors) + " colors (" + IntToStr(screenColorBits) + " bits)" else: self.screenInfoLabel.Caption = "Screen: " + IntToStr(delphi_compatability.Screen.PixelsPerInch) + " pixels/inch, " + "true color (" + IntToStr(screenColorBits) + " bits)" # used to be only in suggest size button, now doing automatically self.setValue(self.inchWidthEdit, inchWidth) self.setValue(self.inchHeightEdit, inchHeight) self.calculatePixelsFromResolutionAndInches() if self.copySavePrintType == kPrintingDrawing: self.suggestPrintSizeClick(self) self.updatePrintPreview() self.reportOnMemoryNeeded()
def gridDrawCell(self, Sender, Col, Row, Rect, State): plant = PdPlant() textDrawRect = TRect() textToDraw = "" self.grid.Canvas.Brush.Color = delphi_compatability.clWhite self.grid.Canvas.Pen.Width = 1 if (self.plants.Count > 0) and (Row == 0): self.grid.Canvas.Pen.Color = delphi_compatability.clSilver else: self.grid.Canvas.Pen.Color = delphi_compatability.clWhite self.grid.Canvas.Rectangle(Rect.left, Rect.top, Rect.right, Rect.bottom) if Row == 1: if self.plants.Count <= 0: return textToDraw = IntToStr(self.ages[Col]) if usupport.rWidth(Rect) > 50: # 50 is fixed size textToDraw = textToDraw + " days" textDrawRect.Left = Rect.left + usupport.rWidth(Rect) / 2 - self.grid.Canvas.TextWidth(textToDraw) / 2 textDrawRect.Top = Rect.top + usupport.rHeight(Rect) / 2 - self.grid.Canvas.TextHeight("0") / 2 self.grid.Canvas.TextOut(textDrawRect.Left, textDrawRect.Top, textToDraw) return plant = None plant = self.plantForIndex(Col) if plant == None: return if not plant.previewCacheUpToDate: # draw plant # draw gray solid box to show delay for drawing plant cache self.grid.Canvas.Brush.Style = delphi_compatability.TFPBrushStyle.bsSolid self.grid.Canvas.Brush.Color = delphi_compatability.clSilver self.grid.Canvas.Pen.Color = delphi_compatability.clSilver # FIX unresolved WITH expression: Rect self.grid.Canvas.Rectangle(self.Left + 1, self.Top + 1, UNRESOLVED.right, UNRESOLVED.bottom) plant.drawPreviewIntoCache(Point(self.grid.DefaultColWidth, self.grid.DefaultRowHeight), uplant.kDontConsiderDomainScale, umain.kDrawNow) plant.previewCache.Transparent = false ubmpsupport.copyBitmapToCanvasWithGlobalPalette(plant.previewCache, self.grid.Canvas, Rect) # draw selection rectangle self.grid.Canvas.Brush.Style = delphi_compatability.TFPBrushStyle.bsClear self.grid.Canvas.Pen.Width = 2 if plant == self.selectedPlant: self.grid.Canvas.Pen.Color = udomain.domain.options.firstSelectionRectangleColor else: self.grid.Canvas.Pen.Color = delphi_compatability.clSilver # FIX unresolved WITH expression: Rect self.grid.Canvas.Rectangle(self.Left + 1, self.Top + 1, UNRESOLVED.right, UNRESOLVED.bottom)
def recalculateCommonDrawingScaleAndPosition(self): plant = PdPlant() i = 0 minScale = 0.0 plantPartsToDraw = 0L partsDrawn = 0L bestPosition = TPoint() widestWidth = 0L tallestHeight = 0L if self.plants == None: return if self.plants.Count <= 0: return # find smallest scale minScale = 0.0 for i in range(0, self.plants.Count): plant = uplant.PdPlant(self.plants.Items[i]) plant.fixedPreviewScale = false plant.fixedDrawPosition = false plant.drawPreviewIntoCache(Point(self.grid.DefaultColWidth, self.grid.DefaultRowHeight), uplant.kDontConsiderDomainScale, uplant.kDontDrawNow) if (i == 0) or (plant.drawingScale_PixelsPerMm < minScale): minScale = plant.drawingScale_PixelsPerMm # find common draw position widestWidth = 0 tallestHeight = 0 for i in range(0, self.plants.Count): plant = uplant.PdPlant(self.plants.Items[i]) plant.fixedPreviewScale = true plant.drawingScale_PixelsPerMm = minScale plant.fixedDrawPosition = false plant.drawPreviewIntoCache(Point(self.grid.DefaultColWidth, self.grid.DefaultRowHeight), uplant.kDontConsiderDomainScale, uplant.kDontDrawNow) if (i == 0) or (usupport.rWidth(plant.boundsRect_pixels()) > widestWidth): widestWidth = usupport.rWidth(plant.boundsRect_pixels()) bestPosition.X = plant.drawPositionIfFixed.X if (i == 0) or (usupport.rHeight(plant.boundsRect_pixels()) > tallestHeight): tallestHeight = usupport.rHeight(plant.boundsRect_pixels()) bestPosition.Y = plant.drawPositionIfFixed.Y for i in range(0, self.plants.Count): # set draw position to use when repaint - don't draw now plant = uplant.PdPlant(self.plants.Items[i]) plant.fixedPreviewScale = true plant.drawingScale_PixelsPerMm = minScale plant.fixedDrawPosition = true plant.drawPositionIfFixed = bestPosition plant.previewCacheUpToDate = false
def updateSelectionRectFromMainWindow(self): excludeInvisiblePlants = false excludeNonSelectedPlants = false excludeInvisiblePlants = not self.useAllPlants.Checked excludeNonSelectedPlants = self.useSelectedPlants.Checked if self.useDrawingAreaContents.Checked: self.selectionRectFromMainWindow = Rect(0, 0, umain.MainForm.drawingPaintBox.Width, umain.MainForm.drawingPaintBox.Height) else: self.selectionRectFromMainWindow = udomain.domain.plantManager.combinedPlantBoundsRects(umain.MainForm.selectedPlants, excludeInvisiblePlants, excludeNonSelectedPlants) self.aspectRatio = umath.safedivExcept(usupport.rWidth(self.selectionRectFromMainWindow), usupport.rHeight(self.selectionRectFromMainWindow), 1.0)
def largestPlantBoundsRect(self, selectedPlants, excludeInvisiblePlants, excludeNonSelectedPlants): result = TRect() plant = PdPlant() plantIndex = 0 includePlant = false plantRect = TRect() result = delphi_compatability.Bounds(0, 0, 0, 0) if self.plants.Count > 0: for plantIndex in range(0, self.plants.Count): plant = uplant.PdPlant(self.plants.Items[plantIndex]) includePlant = true if excludeInvisiblePlants: includePlant = includePlant and not plant.hidden if excludeNonSelectedPlants: includePlant = includePlant and (selectedPlants.IndexOf(plant) >= 0) if includePlant: plantRect = plant.boundsRect_pixels() if usupport.rWidth(plantRect) > result.Right: result.Right = usupport.rWidth(plantRect) if usupport.rHeight(plantRect) > result.Bottom: result.Bottom = usupport.rHeight(plantRect) return result
def updateCellSizeAndCountForSelection(self): excludeInvisiblePlants = false excludeNonSelectedPlants = false cellRect = TRect() scaleMultiplier = 0.0 fileSize = 0L excludeInvisiblePlants = not self.useAllPlants.Checked excludeNonSelectedPlants = self.useSelectedPlants.Checked cellRect = udomain.domain.plantManager.largestPlantBoundsRect( umain.MainForm.selectedPlants, excludeInvisiblePlants, excludeNonSelectedPlants) scaleMultiplier = umath.safedivExcept( 1.0 * self.options.resolution_pixelsPerInch, 1.0 * delphi_compatability.Screen.PixelsPerInch, 1.0) self.options.cellSize = Point( intround(usupport.rWidth(cellRect) * scaleMultiplier), intround(usupport.rHeight(cellRect) * scaleMultiplier)) if self.useAllPlants.Checked: self.options.cellCount = udomain.domain.plantManager.plants.Count elif self.useVisiblePlants.Checked: self.options.cellCount = udomain.domain.plantManager.visiblePlantCount( ) elif self.useSelectedPlants.Checked: self.options.cellCount = umain.MainForm.selectedPlants.Count self.cellSizeLabel.Caption = "Nozzle/tube cell width: " + IntToStr( self.options.cellSize.X) + " height: " + IntToStr( self.options.cellSize.Y) self.cellCountLabel.Caption = "Number of items: " + IntToStr( self.options.cellCount) fileSize = intround( self.options.cellCount * self.options.cellSize.X * self.options.cellSize.Y * usupport.bitsPerPixelForColorType(self.options.colorType) / 8.0) + FIX_sizeof(delphi_compatability.TBitmapInfo) if fileSize < 1024: self.fileSizeLabel.Caption = "Estimated file size: " + IntToStr( fileSize) + " bytes" elif fileSize < 1024 * 1024: self.fileSizeLabel.Caption = "Estimated file size: " + IntToStr( fileSize / 1024) + " KB" else: self.fileSizeLabel.Caption = "Estimated file size: " + FloatToStrF( fileSize / (1024 * 1024), UNRESOLVED.ffFixed, 7, 1) + " MB" if fileSize >= 10.0 * 1024 * 1024: self.fileSizeLabel.Font.Style = [ UNRESOLVED.fsBold, ] else: self.fileSizeLabel.Font.Style = []
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
def calculateNumberOfFrames(self): scaleMultiplier = 0.0 if self.options.animateBy == udomain.kAnimateByAge: self.plantMaxAgeLabel.Caption = "Maximum age = " + IntToStr( self.plant.pGeneral.ageAtMaturity) self.plantMaxAgeLabel.Visible = true self.options.frameCount = self.plant.pGeneral.ageAtMaturity / self.options.ageIncrement + 1 elif self.options.animateBy == udomain.kAnimateByXRotation: self.plantMaxAgeLabel.Visible = false self.options.frameCount = 360 / abs( self.options.xRotationIncrement) self.fileNumberLabel.Caption = "Number of files: " + IntToStr( self.options.frameCount) scaleMultiplier = umath.safedivExcept( 1.0 * self.options.resolution_pixelsPerInch, 1.0 * delphi_compatability.Screen.PixelsPerInch, 1.0) self.options.scaledSize = Point( intround( usupport.rWidth(self.plant.boundsRect_pixels()) * scaleMultiplier), intround( usupport.rHeight(self.plant.boundsRect_pixels()) * scaleMultiplier)) self.animationSizeLabel.Caption = "Animation size: " + IntToStr( self.options.scaledSize.X) + " x " + IntToStr( self.options.scaledSize.Y) self.options.fileSize = intround( self.options.frameCount * self.options.scaledSize.X * self.options.scaledSize.Y * usupport.bitsPerPixelForColorType(self.options.colorType) / 8.0) + FIX_sizeof(delphi_compatability.TBitmapInfo) if self.options.fileSize < 1024: self.fileSizeLabel.Caption = "Estimated total size: " + IntToStr( self.options.fileSize) + " bytes" elif self.options.fileSize < 1024 * 1024: self.fileSizeLabel.Caption = "Estimated total size: " + IntToStr( self.options.fileSize / 1024) + " KB" else: self.fileSizeLabel.Caption = "Estimated total size: " + FloatToStrF( self.options.fileSize / (1024 * 1024), UNRESOLVED.ffFixed, 7, 1) + " MB" if self.options.fileSize >= 10.0 * 1024 * 1024: self.fileSizeLabel.Font.Style = [ UNRESOLVED.fsBold, ] else: self.fileSizeLabel.Font.Style = []
def fillRectWithColor(self, aRect, aColor): bitmap = TBitmap() bitmap = delphi_compatability.TBitmap().Create() try: try: bitmap.Width = usupport.rWidth(aRect) bitmap.Height = usupport.rHeight(aRect) except: bitmap.Width = 1 bitmap.Height = 1 ubmpsupport.setPixelFormatBasedOnScreenForBitmap(bitmap) bitmap.Canvas.Brush.Color = aColor bitmap.Canvas.FillRect(Rect(0, 0, bitmap.Width, bitmap.Height)) ubmpsupport.copyBitmapToCanvasWithGlobalPalette(bitmap, self.Canvas, aRect) finally: bitmap.free
def resizeElements(self): fullRect = TRect() if self.textHeight == 0: self.calculateTextDimensions() if self.maxLabelWidth == 0: self.paint() fullRect = Rect(0, 0, kMinGraphWidth + self.maxLabelWidth + uppanel.kLeftRightGap * 2 + uppanel.kBetweenGap, (self.numNonZeroPlantParts() + 2) * self.textHeight + uppanel.kTopBottomGap * 2 + uppanel.kBetweenGap * 2) self.ClientHeight = umath.intMax(0, umath.intMax(usupport.rHeight(fullRect), self.Parent.ClientHeight)) self.ClientWidth = umath.intMax(0, umath.intMax(usupport.rWidth(fullRect), self.Parent.ClientWidth)) try: self.drawBitmap.Width = self.ClientWidth self.drawBitmap.Height = self.ClientHeight except: self.drawBitmap.Width = 1 self.drawBitmap.Height = 1 self.updateDisplay()
def fillRectWithColor(self, aRect, aColor): bitmap = TBitmap() bitmap = delphi_compatability.TBitmap().Create() try: try: bitmap.Width = usupport.rWidth(aRect) bitmap.Height = usupport.rHeight(aRect) except: bitmap.Width = 1 bitmap.Height = 1 ubmpsupport.setPixelFormatBasedOnScreenForBitmap(bitmap) bitmap.Canvas.Brush.Color = aColor bitmap.Canvas.FillRect(Rect(0, 0, bitmap.Width, bitmap.Height)) ubmpsupport.copyBitmapToCanvasWithGlobalPalette( bitmap, self.Canvas, aRect) finally: bitmap.free
def drawExtraValueCaptionWithString(self, valueString, unitString): rect = TRect() collapsedExtraRect = TRect() stringToDisplay = "" if (self.wrappedLabelHeight > self.textHeight): return stringToDisplay = ": " + valueString if unitString != "(no unit)": stringToDisplay = stringToDisplay + " " + unitString Rect = self.GetClientRect() collapsedExtraRect.Left = Rect.left + kLeftRightGap + kArrowPictureSize + kOverridePictureSize + kBetweenGap + self.Canvas.TextWidth(self.Caption) collapsedExtraRect.Right = Rect.right collapsedExtraRect.Top = Rect.top + 2 collapsedExtraRect.Bottom = collapsedExtraRect.Top + self.textHeight if usupport.rWidth(collapsedExtraRect) <= self.Canvas.TextWidth(stringToDisplay): return self.drawText(stringToDisplay, collapsedExtraRect, false, false, false)
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
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
def describePlant(self, describeString, plantProxy): plant = PdPlant() theRect = TRect() totalMemUse = 0.0 baseMemUse = 0.0 hangingMemUse = 0.0 tdoMemUse = 0.0 cacheMemUse = 0.0 partsMemUse = 0.0 if plantProxy == None: return plant = plantProxy as uplant.PdPlant plant.countPlantParts() self.infoList.Lines.Add(describeString + " plant: " + plant.name) # memory totalMemUse = plant.calculateTotalMemorySize() baseMemUse = plant.instanceSize / 1024.0 hangingMemUse = plant.hangingObjectsMemoryUse_K() tdoMemUse = plant.tdoMemoryUse_K() if plant.previewCache != None: cacheMemUse = ubitmap.BitmapMemorySize(plant.previewCache) / 1024.0 else: cacheMemUse = 0 partsMemUse = totalMemUse - baseMemUse - hangingMemUse - tdoMemUse - cacheMemUse self.infoList.Lines.Add(" total memory use " + self.stringForMemoryInK(totalMemUse)) self.infoList.Lines.Add(" base memory with parameters " + self.stringForMemoryInK(baseMemUse)) self.infoList.Lines.Add(" posing and random number generators " + self.stringForMemoryInK(hangingMemUse)) self.infoList.Lines.Add(" memory for 3D objects " + self.stringForMemoryInK(tdoMemUse)) self.infoList.Lines.Add(" memory for drawing cache " + self.stringForMemoryInK(cacheMemUse)) self.infoList.Lines.Add(" memory for plant parts " + self.stringForMemoryInK(partsMemUse)) # status self.infoList.Lines.Add(" age " + IntToStr(plant.age)) self.infoList.Lines.Add(" maturity " + IntToStr(plant.pGeneral.ageAtMaturity)) self.infoList.Lines.Add(" scale " + usupport.digitValueString(plant.drawingScale_PixelsPerMm)) if plant.previewCache != None: self.infoList.Lines.Add(" cache " + IntToStr(plant.previewCache.Width) + "x" + IntToStr(plant.previewCache.Height)) else: self.infoList.Lines.Add(" no cache") self.infoList.Lines.Add(" base " + usupport.digitValueString(plant.basePoint_mm.x) + "x" + usupport.digitValueString(plant.basePoint_mm.y)) self.infoList.Lines.Add(" hidden " + usupport.boolToStr(plant.hidden)) self.infoList.Lines.Add(" random number seed " + IntToStr(plant.pGeneral.startingSeedForRandomNumberGenerator)) theRect = plant.boundsRect_pixels() self.infoList.Lines.Add(" bounds " + IntToStr(theRect.Left) + "x" + IntToStr(theRect.Top) + "x" + IntToStr(theRect.Right) + "x" + IntToStr(theRect.Bottom) + " (" + IntToStr(usupport.rWidth(theRect)) + "x" + IntToStr(usupport.rHeight(theRect)) + ")") self.infoList.Lines.Add(" parts " + IntToStr(plant.totalPlantParts)) self.infoList.Lines.Add("")
def plantsDrawGridDrawCell(self, Sender, Col, Row, Rect, State): generation = PdGeneration() plant = PdPlant() textDrawRect = TRect() try: self.plantsDrawGrid.Canvas.Font = self.plantsDrawGrid.Font self.plantsDrawGrid.Canvas.Font.Color = delphi_compatability.clBlack if Col == 0: #if (row = selectedRow) and (generations.count > 0) then #plantsDrawGrid.canvas.brush.color := clBlue #else self.plantsDrawGrid.Canvas.Brush.Color = delphi_compatability.clWhite self.plantsDrawGrid.Canvas.Pen.Color = self.plantsDrawGrid.Canvas.Brush.Color self.plantsDrawGrid.Canvas.Rectangle(Rect.left, Rect.top, Rect.right, Rect.bottom) if Row > self.generations.Count - 1: return #if row = selectedRow then #plantsDrawGrid.canvas.font.color := clWhite; textDrawRect.Left = Rect.left + usupport.rWidth(Rect) / 2 - self.plantsDrawGrid.Canvas.TextWidth(IntToStr(Row + 1)) / 2 textDrawRect.Top = Rect.top + usupport.rHeight(Rect) / 2 - self.plantsDrawGrid.Canvas.TextHeight("0") / 2 self.plantsDrawGrid.Canvas.TextOut(textDrawRect.Left, textDrawRect.Top, IntToStr(Row + 1)) return else: self.plantsDrawGrid.Canvas.Brush.Color = delphi_compatability.clWhite self.plantsDrawGrid.Canvas.Pen.Width = 1 self.plantsDrawGrid.Canvas.Pen.Color = delphi_compatability.clWhite self.plantsDrawGrid.Canvas.Rectangle(Rect.left, Rect.top, Rect.right, Rect.bottom) generation = None generation = self.generationForIndex(Row) if generation == None: return plant = None plant = generation.plantForIndex(Col - 1) if plant == None: return if not plant.previewCacheUpToDate: # draw plant # draw gray solid box to show delay for drawing plant cache self.plantsDrawGrid.Canvas.Brush.Style = delphi_compatability.TFPBrushStyle.bsSolid self.plantsDrawGrid.Canvas.Brush.Color = delphi_compatability.clSilver self.plantsDrawGrid.Canvas.Pen.Color = delphi_compatability.clSilver # FIX unresolved WITH expression: Rect self.plantsDrawGrid.Canvas.Rectangle(self.Left + 1, self.Top + 1, UNRESOLVED.right, UNRESOLVED.bottom) # draw plant preview cache plant.fixedPreviewScale = false plant.fixedDrawPosition = false plant.drawPreviewIntoCache(Point(self.plantsDrawGrid.DefaultColWidth, self.plantsDrawGrid.DefaultRowHeight), uplant.kDontConsiderDomainScale, umain.kDrawNow) plant.previewCache.Transparent = false ubmpsupport.copyBitmapToCanvasWithGlobalPalette(plant.previewCache, self.plantsDrawGrid.Canvas, Rect) # draw selection rectangle self.plantsDrawGrid.Canvas.Brush.Style = delphi_compatability.TFPBrushStyle.bsClear self.plantsDrawGrid.Canvas.Pen.Width = 2 if (Col == self.lightUpCell.X) and (Row == self.lightUpCell.Y): self.plantsDrawGrid.Canvas.Pen.Color = delphi_compatability.clAqua elif Row == self.selectedRow: if plant == generation.firstSelectedPlant(): self.plantsDrawGrid.Canvas.Pen.Color = udomain.domain.options.firstSelectionRectangleColor elif plant == generation.secondSelectedPlant(): self.plantsDrawGrid.Canvas.Pen.Color = udomain.domain.options.multiSelectionRectangleColor else: self.plantsDrawGrid.Canvas.Pen.Color = delphi_compatability.clSilver else: self.plantsDrawGrid.Canvas.Pen.Color = delphi_compatability.clSilver # FIX unresolved WITH expression: Rect self.plantsDrawGrid.Canvas.Rectangle(self.Left + 1, self.Top + 1, UNRESOLVED.right, UNRESOLVED.bottom) if plant == generation.firstParent: # draw parent indicator self.plantsDrawGrid.Canvas.TextOut(Rect.left + 4, Rect.top + 2, "p1") elif plant == generation.secondParent: self.plantsDrawGrid.Canvas.TextOut(Rect.left + 4, Rect.top + 2, "p2") finally: ucursor.cursor_stopWait()
def suggestCopySizeClick(self, Sender): self.updateSelectionRectFromMainWindow() self.setValue(self.pixelWidthEdit, usupport.rWidth(self.selectionRectFromMainWindow)) self.setValue(self.pixelHeightEdit, usupport.rHeight(self.selectionRectFromMainWindow)) self.calculateInchesFromResolutionAndPixels()