Beispiel #1
0
 def writeToTextFile(self, outputFile):
     writeln(outputFile, kStartAmendmentString)
     writeln(outputFile, "  part number =%d" % (self.partID))
     writeln(outputFile, "  part type =" + self.typeOfPart)
     writeln(outputFile, "  hide =" + usupport.boolToStr(self.hide))
     #
     #  writeln(outputFile, "  change colors =" + boolToStr(changeColors));
     #  writeln(outputFile, "  propagate colors up stem =" + boolToStr(propagateColors));
     #  writeln(outputFile, "  front face color =%d" % (faceColor));
     #  writeln(outputFile, "  back face color =%d" % (backfaceColor));
     #  writeln(outputFile, "  line color =%d" % (lineColor));
     #
     writeln(outputFile, "  rotate =" + usupport.boolToStr(self.addRotations))
     writeln(outputFile, "  x rotation =%d" % (int(self.xRotation)))
     writeln(outputFile, "  y rotation =%d" % (int(self.yRotation)))
     writeln(outputFile, "  z rotation =%d" % (int(self.zRotation)))
     writeln(outputFile, "  change scale =" + usupport.boolToStr(self.multiplyScale))
     writeln(outputFile, "  propagate scale change up stem =" + usupport.boolToStr(self.propagateScale))
     writeln(outputFile, "  3d object scale multiplier =%d" % (self.scaleMultiplier_pct))
     writeln(outputFile, "  line length multiplier =%d" % (self.lengthMultiplier_pct))
     writeln(outputFile, "  line width multiplier =%d" % (self.widthMultiplier_pct))
     #
     #  writeln(outputFile, "  apply at age =%d" % (applyAtAge))
     #
     writeln(outputFile, kEndAmendmentString)
Beispiel #2
0
 def writeToMemo(self, aMemo):
     aMemo.Lines.Add(kStartAmendmentString)
     aMemo.Lines.Add("  part number =%d" % (self.partID))
     aMemo.Lines.Add("  part type =" + self.typeOfPart)
     aMemo.Lines.Add("  hide =" + usupport.boolToStr(self.hide))
     #
     #  aMemo.lines.add('  change colors =' + boolToStr(changeColors));
     #  aMemo.lines.add('  propagate colors up stem =' + boolToStr(propagateColors));
     #  aMemo.lines.add("  front face color =%d" % (faceColor));
     #  aMemo.lines.add("  back face color =%d" % (backfaceColor));
     #  aMemo.lines.add("  line color =%d" % (lineColor));
     #
     aMemo.Lines.Add("  rotate =" + usupport.boolToStr(self.addRotations))
     aMemo.Lines.Add("  x rotation =%d" % (int(self.xRotation)))
     aMemo.Lines.Add("  y rotation =%d" % (int(self.yRotation)))
     aMemo.Lines.Add("  z rotation =%d" % (int(self.zRotation)))
     aMemo.Lines.Add("  change scale =" + usupport.boolToStr(self.multiplyScale))
     aMemo.Lines.Add("  propagate scale change up stem =" + usupport.boolToStr(self.propagateScale))
     aMemo.Lines.Add("  3d object scale multiplier =%d" % (self.scaleMultiplier_pct))
     aMemo.Lines.Add("  line length multiplier =%d" % (self.lengthMultiplier_pct))
     aMemo.Lines.Add("  line width multiplier =%d" % (self.widthMultiplier_pct))
     #
     #  aMemo.lines.add("  apply at age =%d" % (applyAtAge));
     #
     aMemo.Lines.Add(kEndAmendmentString)
Beispiel #3
0
    def writeToFile(self, aFileName):
        outputFile = TextFile()
        i = 0

        AssignFile(outputFile, aFileName)
        try:
            Rewrite(outputFile)
            writeln(outputFile, "[Breeding strategy]")
            write(outputFile, "Mutations=")
            for i in range(0, kMaxBreedingSections):
                write(outputFile, IntToStr(self.mutationStrengths[i]) + " ")
            writeln(outputFile)
            write(outputFile, "Weights=")
            for i in range(0, kMaxBreedingSections):
                write(outputFile, IntToStr(self.firstPlantWeights[i]) + " ")
            writeln(outputFile)
            writeln(
                outputFile,
                "Non-numeric=" + IntToStr(self.getNonNumericalParametersFrom))
            writeln(
                outputFile, "Vary colors=" +
                usupport.boolToStr(self.mutateAndBlendColorValues))
            writeln(
                outputFile, "Vary 3D objects=" +
                usupport.boolToStr(self.chooseTdosRandomlyFromCurrentLibrary))
        finally:
            CloseFile(outputFile)
Beispiel #4
0
 def writeToMemo(self, aMemo):
     aMemo.Lines.Add(kStartAmendmentString)
     aMemo.Lines.Add("  part number =" + IntToStr(self.partID))
     aMemo.Lines.Add("  part type =" + self.typeOfPart)
     aMemo.Lines.Add("  hide =" + usupport.boolToStr(self.hide))
     #
     #  aMemo.lines.add('  change colors =' + boolToStr(changeColors));
     #  aMemo.lines.add('  propagate colors up stem =' + boolToStr(propagateColors));
     #  aMemo.lines.add('  front face color =' + intToStr(faceColor));
     #  aMemo.lines.add('  back face color =' + intToStr(backfaceColor));
     #  aMemo.lines.add('  line color =' + intToStr(lineColor));
     #  
     aMemo.Lines.Add("  rotate =" + usupport.boolToStr(self.addRotations))
     aMemo.Lines.Add("  x rotation =" + IntToStr(intround(self.xRotation)))
     aMemo.Lines.Add("  y rotation =" + IntToStr(intround(self.yRotation)))
     aMemo.Lines.Add("  z rotation =" + IntToStr(intround(self.zRotation)))
     aMemo.Lines.Add("  change scale =" + usupport.boolToStr(self.multiplyScale))
     aMemo.Lines.Add("  propagate scale change up stem =" + usupport.boolToStr(self.propagateScale))
     aMemo.Lines.Add("  3d object scale multiplier =" + IntToStr(self.scaleMultiplier_pct))
     aMemo.Lines.Add("  line length multiplier =" + IntToStr(self.lengthMultiplier_pct))
     aMemo.Lines.Add("  line width multiplier =" + IntToStr(self.widthMultiplier_pct))
     #
     #  aMemo.lines.add('  apply at age =' + intToStr(applyAtAge));
     #  
     aMemo.Lines.Add(kEndAmendmentString)
Beispiel #5
0
 def writeToTextFile(self, outputFile):
     writeln(outputFile, kStartAmendmentString)
     writeln(outputFile, "  part number =" + IntToStr(self.partID))
     writeln(outputFile, "  part type =" + self.typeOfPart)
     writeln(outputFile, "  hide =" + usupport.boolToStr(self.hide))
     #
     #  writeln(outputFile, '  change colors =' + boolToStr(changeColors));
     #  writeln(outputFile, '  propagate colors up stem =' + boolToStr(propagateColors));
     #  writeln(outputFile, '  front face color =' + intToStr(faceColor));
     #  writeln(outputFile, '  back face color =' + intToStr(backfaceColor));
     #  writeln(outputFile, '  line color =' + intToStr(lineColor));
     #  
     writeln(outputFile, "  rotate =" + usupport.boolToStr(self.addRotations))
     writeln(outputFile, "  x rotation =" + IntToStr(intround(self.xRotation)))
     writeln(outputFile, "  y rotation =" + IntToStr(intround(self.yRotation)))
     writeln(outputFile, "  z rotation =" + IntToStr(intround(self.zRotation)))
     writeln(outputFile, "  change scale =" + usupport.boolToStr(self.multiplyScale))
     writeln(outputFile, "  propagate scale change up stem =" + usupport.boolToStr(self.propagateScale))
     writeln(outputFile, "  3d object scale multiplier =" + IntToStr(self.scaleMultiplier_pct))
     writeln(outputFile, "  line length multiplier =" + IntToStr(self.lengthMultiplier_pct))
     writeln(outputFile, "  line width multiplier =" + IntToStr(self.widthMultiplier_pct))
     #
     #  writeln(outputFile, '  apply at age =' + intToStr(applyAtAge));
     #  
     writeln(outputFile, kEndAmendmentString)
Beispiel #6
0
 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("")
Beispiel #7
0
 def savePlantsToFile(self, fileName, inPlantMover):
     outputFile = TextFile()
     i = 0
     plant = PdPlant()
     
     if self.plants.Count <= 0:
         return
     AssignFile(outputFile, fileName)
     try:
         # v1.5
         usupport.setDecimalSeparator()
         if not inPlantMover:
             # update before writing out (keep as read in if in mover)
             # plantDrawOffset_mm is used from here
             # plantDrawScale_PixelsPerMm is used from here
             self.mainWindowViewMode = udomain.domain.options.mainWindowViewMode
             self.mainWindowOrientation = udomain.domain.options.mainWindowOrientation
             self.showBoundsRectangle = udomain.domain.options.showBoundsRectangle
         Rewrite(outputFile)
         # v2.0
         writeln(outputFile, "; PlantStudio version 2.0 plant file")
         writeln(outputFile, "offset=" + usupport.singlePointToString(self.plantDrawOffset_mm))
         writeln(outputFile, "scale=" + usupport.digitValueString(self.plantDrawScale_PixelsPerMm))
         if self.mainWindowViewMode == udomain.kViewPlantsInMainWindowOneAtATime:
             writeln(outputFile, "concentrated=true")
         else:
             writeln(outputFile, "concentrated=false")
         # v2.0
         writeln(outputFile, "orientation (top/side)=" + IntToStr(self.mainWindowOrientation))
         # v2.0
         writeln(outputFile, "boxes=" + usupport.boolToStr(self.showBoundsRectangle))
         writeln(outputFile)
         for i in range(0, self.plants.Count):
             plant = uplant.PdPlant(self.plants.Items[i])
             if plant == None:
                 continue
             plant.writeToPlantFile(outputFile)
     finally:
         CloseFile(outputFile)