Exemple #1
0
 def BreederMenuRandomizeClick(self, Sender):
     newCommand = PdCommand()
     randomizeList = TList()
     aGeneration = PdGeneration()
     i = 0
     plant = PdPlant()
     
     aGeneration = self.selectedGeneration()
     if aGeneration == None:
         return
     if aGeneration.selectedPlants.Count <= 0:
         return
     randomizeList = delphi_compatability.TList().Create()
     try:
         for i in range(0, aGeneration.selectedPlants.Count):
             plant = uplant.PdPlant(aGeneration.selectedPlants.Items[i])
             randomizeList.Add(plant)
         newCommand = updcom.PdRandomizeCommand().createWithListOfPlants(randomizeList)
         (newCommand as updcom.PdRandomizeCommand).isInBreeder = true
         ucursor.cursor_startWait()
         umain.MainForm.doCommand(newCommand)
     finally:
         #command has another list, so we must free this one
         randomizeList.free
         ucursor.cursor_stopWait()
Exemple #2
0
 def BreederMenuRandomizeAllClick(self, Sender):
     generation = PdGeneration()
     i = 0
     j = 0
     newCommand = PdCommand()
     randomizeList = TList()
     
     if self.generations.Count <= 0:
         return
     randomizeList = None
     try:
         ucursor.cursor_startWait()
         randomizeList = delphi_compatability.TList().Create()
         if self.generations.Count > 0:
             for i in range(0, self.generations.Count):
                 generation = ugener.PdGeneration(self.generations.Items[i])
                 if generation.plants.Count > 0:
                     for j in range(0, generation.plants.Count):
                         randomizeList.Add(uplant.PdPlant(generation.plants.Items[j]))
         newCommand = updcom.PdRandomizeCommand().createWithListOfPlants(randomizeList)
         (newCommand as updcom.PdRandomizeCommand).isInBreeder = true
         (newCommand as updcom.PdRandomizeCommand).isRandomizeAllInBreeder = true
         umain.MainForm.doCommand(newCommand)
     finally:
         randomizeList.free
         ucursor.cursor_stopWait()
Exemple #3
0
 def BreederMenuCopyClick(self, Sender):
     plant = PdPlant()
     copyList = TList()
     saveName = ""
     
     plant = self.primarySelectedPlant()
     if plant == None:
         return
     copyList = delphi_compatability.TList().Create()
     copyList.Add(plant)
     # temporarily change plant name to make copy, then put back 
     saveName = plant.getName()
     self.numBreederPlantsCopiedThisSession += 1
     plant.setName("Breeder plant " + IntToStr(self.numBreederPlantsCopiedThisSession))
     udomain.domain.plantManager.copyPlantsInListToPrivatePlantClipboard(copyList)
     plant.setName(saveName)
     #sets our paste menu also
     umain.MainForm.updatePasteMenuForClipboardContents()
Exemple #4
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
Exemple #5
0
 def gridEndDrag(self, Sender, Target, X, Y):
     plant = PdPlant()
     newCommand = PdCommand()
     newPlants = TList()
     newPlant = PdPlant()
     
     if delphi_compatability.Application.terminated:
         return
     if Target == None:
         return
     # get plant being dragged 
     plant = self.plantAtMouse(self.dragPlantStartPoint.X, self.dragPlantStartPoint.Y)
     if plant == None:
         return
     if Target == ubreedr.BreederForm.plantsDrawGrid:
         ubreedr.BreederForm.copyPlantToPoint(plant, X, Y)
     elif (Target == umain.MainForm.drawingPaintBox) or (Target == umain.MainForm.plantListDrawGrid):
         # make paste command - wants list of plants 
         newPlant = uplant.PdPlant().create()
         plant.copyTo(newPlant)
         self.numTimeSeriesPlantsCopiedThisSession += 1
         newPlant.setName("Time series plant " + IntToStr(self.numTimeSeriesPlantsCopiedThisSession))
         if Target == umain.MainForm.drawingPaintBox:
             newPlant.moveTo(Point(X, Y))
         else:
             newPlant.moveTo(umain.MainForm.standardPastePosition())
         if not udomain.domain.viewPlantsInMainWindowOnePlantAtATime():
             # v2.1
             newPlant.calculateDrawingScaleToLookTheSameWithDomainScale()
         #to save memory - don't need it in main window
         newPlant.shrinkPreviewCache()
         newPlants = delphi_compatability.TList().Create()
         newPlants.Add(newPlant)
         newCommand = updcom.PdPasteCommand().createWithListOfPlantsAndOldSelectedList(newPlants, umain.MainForm.selectedPlants)
         updcom.PdPasteCommand(newCommand).useSpecialPastePosition = true
         try:
             #command will free plant if paste is undone
             ucursor.cursor_startWait()
             umain.MainForm.doCommand(newCommand)
         finally:
             #command has another list, so we must free this one
             newPlants.free
             ucursor.cursor_stopWait()
Exemple #6
0
 def plantsDrawGridEndDrag(self, Sender, Target, X, Y):
     col = 0L
     row = 0L
     plant = PdPlant()
     plantToReplace = PdPlant()
     newCommand = PdCommand()
     newPlants = TList()
     newPlant = PdPlant()
     
     if delphi_compatability.Application.terminated:
         return
     # remove lightup on cell before resetting cell
     self.invalidateGridCell(self.lightUpCell.X, self.lightUpCell.Y)
     self.lightUpCell = Point(-1, -1)
     if Target == None:
         return
     # get plant being dragged 
     plant = self.plantAtMouse(self.dragPlantStartPoint.X, self.dragPlantStartPoint.Y)
     if plant == None:
         return
     if (Target == umain.MainForm.drawingPaintBox) or (Target == umain.MainForm.plantListDrawGrid):
         # make paste command - wants list of plants 
         newPlant = uplant.PdPlant().create()
         plant.copyTo(newPlant)
         self.numBreederPlantsCopiedThisSession += 1
         newPlant.setName("Breeder plant " + IntToStr(self.numBreederPlantsCopiedThisSession))
         if (Target == umain.MainForm.drawingPaintBox):
             newPlant.moveTo(Point(X, Y))
         else:
             newPlant.moveTo(umain.MainForm.standardPastePosition())
         if not udomain.domain.viewPlantsInMainWindowOnePlantAtATime():
             # v2.1
             newPlant.calculateDrawingScaleToLookTheSameWithDomainScale()
         #to save memory - don't need it in main window
         newPlant.shrinkPreviewCache()
         newPlants = delphi_compatability.TList().Create()
         newPlants.Add(newPlant)
         newCommand = updcom.PdPasteCommand().createWithListOfPlantsAndOldSelectedList(newPlants, umain.MainForm.selectedPlants)
         updcom.PdPasteCommand(newCommand).useSpecialPastePosition = true
         try:
             ucursor.cursor_startWait()
             umain.MainForm.doCommand(newCommand)
         finally:
             #command has another list, so we must free this one
             newPlants.free
             ucursor.cursor_stopWait()
         #command will free plant if paste is undone
     elif Target == utimeser.TimeSeriesForm.grid:
         utimeser.TimeSeriesForm.copyPlantToPoint(plant, X, Y)
     elif Target == Sender:
         # get plant being replaced 
         col, row = self.plantsDrawGrid.MouseToCell(X, Y, col, row)
         if not self.inGrid(row, col):
             return
         plantToReplace = self.plantForRowAndColumn(row, col)
         if plantToReplace == None:
             return
         if plantToReplace == plant:
             return
         # make replace command 
         newCommand = updcom.PdReplaceBreederPlant().createWithPlantRowAndColumn(plant, row, col)
         try:
             ucursor.cursor_startWait()
             umain.MainForm.doCommand(newCommand)
         finally:
             ucursor.cursor_stopWait()
Exemple #7
0
 def create(self):
     TObject.create(self)
     self.plants = ucollect.TListCollection().Create()
     self.selectedPlants = delphi_compatability.TList().Create()
     return self