コード例 #1
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()
コード例 #2
0
    def expose(self, widget, event):
        x, y, width, height = event.area
        gc = widget.window.new_gc()
        if self.outOfDate:
            ucursor.cursor_startWait()
            try:
                context = (self.backingPixmap, gc)
                if self.backgroundImage:
                    self.backingPixmap.draw_rectangle(
                        widget.get_style().white_gc, True, 0, 0, width, height)
                    self.backingPixmap.draw_pixbuf(gc, self.backgroundImage, 0,
                                                   0, 0, 0)
                else:
                    self.backingPixmap.draw_rectangle(
                        widget.get_style().white_gc, True, 0, 0, width, height)
                self.draw(context, width, height)
            finally:
                ucursor.cursor_stopWait()
                self.outOfDate = 0

        widget.window.draw_drawable(gc, self.backingPixmap, x, y, x, y, width,
                                    height)
        widget.window.draw_pixbuf(gc, self.glove.get_pixbuf(), 0, 0,
                                  self.gloveX - self.gloveOffsetX,
                                  self.gloveY - self.gloveOffsetY)
コード例 #3
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()
コード例 #4
0
 def grow(self, widget, days):
     ucursor.cursor_startWait()
     try:
         for plant in self.drawingArea.plants:
             if days == -1:
                 plant.reset()
             else:
                 for day in range(days):
                     plant.nextDay()
     finally:
         ucursor.cursor_stopWait()
     self.drawingArea.setOutOfDate()
コード例 #5
0
 def openLibrary(self, widget):
     fileName = ChooseFile(self.window, "Plant files", ["*.pla"])
     if fileName == None:
         return
     print "Opening", fileName
     ucursor.cursor_startWait()
     try:
         plants = uplant.PlantLoader().loadPlantsFromFile(fileName, inPlantMover=1, justLoad=1)
         self.fileName = fileName
         self.setPlantListContents(plants)
     finally:
         ucursor.cursor_stopWait()
コード例 #6
0
ファイル: gardener.py プロジェクト: Neon22/PlantStudio
 def grow(self, widget, days):
     ucursor.cursor_startWait()
     try:
         for plant in self.drawingArea.plants:
             if days == -1:
                 plant.reset()
             else:
                 for day in range(days):
                     plant.nextDay()
     finally:
         ucursor.cursor_stopWait()
     self.drawingArea.setOutOfDate()
コード例 #7
0
ファイル: viewer.py プロジェクト: overdhose/PlantStudio
 def _grow(self, widget, days):
     if not self.drawingArea.plant:
         return
     ucursor.cursor_startWait()
     try:
         if days == -1:
             self.drawingArea.plant.reset()
         else:
             for day in range(days):
                 self.drawingArea.plant.nextDay()
     finally:
         ucursor.cursor_stopWait()
     InvalidateWidget(self.drawingArea)
コード例 #8
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()
コード例 #9
0
ファイル: gardener.py プロジェクト: Neon22/PlantStudio
    def expose(self, widget, event):
        x , y, width, height = event.area
        gc = widget.window.new_gc()
        if self.outOfDate:
            ucursor.cursor_startWait()
            try:
                context = (self.backingPixmap, gc)
                if self.backgroundImage:
                     self.backingPixmap.draw_rectangle(widget.get_style().white_gc, True, 0, 0, width, height)
                     self.backingPixmap.draw_pixbuf(gc, self.backgroundImage, 0, 0, 0, 0)
                else:
                    self.backingPixmap.draw_rectangle(widget.get_style().white_gc, True, 0, 0, width, height)
                self.draw(context, width, height)
            finally:
                ucursor.cursor_stopWait()
                self.outOfDate = 0

        widget.window.draw_drawable(gc, self.backingPixmap, x, y, x, y, width, height)
        widget.window.draw_pixbuf(gc, self.glove.get_pixbuf(), 0, 0, self.gloveX - self.gloveOffsetX, self.gloveY - self.gloveOffsetY)
コード例 #10
0
ファイル: gardener.py プロジェクト: Neon22/PlantStudio
 def mouseDown(self, widget, event):
     # GTK BUG __ SEEMS TO CALL THREE TIMES IF DOUBLE CLICK 9only last is double click)
     isDoubleClick = event.type == gtk.gdk._2BUTTON_PRESS
     if isDoubleClick:
         self.mouseDoubleClick(event)
         return
     x = event.x
     y = event.y
     if self.drawingArea.selectedCultivar:
         ucursor.cursor_startWait()
         try:
             newPlant = self.drawingArea.selectedCultivar.makeCopy()
             newPlant.x = x
             newPlant.y = y
             newPlant.setAge(1)
             newPlant.randomize()
             self.drawingArea.plants.append(newPlant)
             self.drawingArea.setOutOfDate()
         finally:
             ucursor.cursor_stopWait()
コード例 #11
0
 def mouseDown(self, widget, event):
     # GTK BUG __ SEEMS TO CALL THREE TIMES IF DOUBLE CLICK 9only last is double click)
     isDoubleClick = event.type == gtk.gdk._2BUTTON_PRESS
     if isDoubleClick:
         self.mouseDoubleClick(event)
         return
     x = event.x
     y = event.y
     if self.drawingArea.selectedCultivar:
         ucursor.cursor_startWait()
         try:
             newPlant = self.drawingArea.selectedCultivar.makeCopy()
             newPlant.x = x
             newPlant.y = y
             newPlant.setAge(1)
             newPlant.randomize()
             self.drawingArea.plants.append(newPlant)
             self.drawingArea.setOutOfDate()
         finally:
             ucursor.cursor_stopWait()
コード例 #12
0
def loadPlantFileAtStartup():
    ucursor.cursor_startWait()
    try:
        if udomain.domain.plantFileLoaded:
            # if file loaded at startup, update for it, else act as if they picked new
            uwait.startWaitMessage("Drawing...")
            try:
                umain.MainForm.updateForPlantFile()
            finally:
                uwait.stopWaitMessage()
        else:
            umain.MainForm.MenuFileNewClick(umain.MainForm)
        if usplash.splashForm != None:
            usplash.splashForm.Hide()
        umain.MainForm.updateForChangeToDomainOptions()
        umain.MainForm.updateFileMenuForOtherRecentFiles()
        umain.MainForm.selectedPlantPartID = -1
        umain.MainForm.inFormCreation = false
    finally:
        ucursor.cursor_stopWait()
コード例 #13
0
def loadPlantFileAtStartup():
    ucursor.cursor_startWait()
    try:
        if udomain.domain.plantFileLoaded:
            # if file loaded at startup, update for it, else act as if they picked new 
            uwait.startWaitMessage("Drawing...")
            try:
                umain.MainForm.updateForPlantFile()
            finally:
                uwait.stopWaitMessage()
        else:
            umain.MainForm.MenuFileNewClick(umain.MainForm)
        if usplash.splashForm != None:
            usplash.splashForm.Hide()
        umain.MainForm.updateForChangeToDomainOptions()
        umain.MainForm.updateFileMenuForOtherRecentFiles()
        umain.MainForm.selectedPlantPartID = -1
        umain.MainForm.inFormCreation = false
    finally:
        ucursor.cursor_stopWait()
コード例 #14
0
 def initializeWithPlant(self, aPlant, drawNow):
     newPlant = PdPlant()
     i = 0
     
     if aPlant == None:
         return
     if not self.Visible:
         self.Show()
     self.BringToFront()
     self.plants.clear()
     self.parentPlant = aPlant
     ucursor.cursor_startWait()
     try:
         for i in range(0, self.numStages):
             newPlant = uplant.PdPlant().create()
             self.parentPlant.copyTo(newPlant)
             self.ages[i] = intround(umath.max(0.0, umath.min(1.0, self.percentsOfMaxAge[i] / 100.0)) * newPlant.pGeneral.ageAtMaturity)
             newPlant.setAge(self.ages[i])
             self.plants.Add(newPlant)
     finally:
         ucursor.cursor_stopWait()
     if drawNow:
         self.redrawPlants()
コード例 #15
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()
コード例 #16
0
def Cursor_StartWait():
    ucursor.cursor_startWait()
コード例 #17
0
 def reconcileFileWithTdoLibrary(self, plantFileName, tdoLibrary):
     result = 0
     plantFileTdos = TListCollection()
     libraryFileTdos = TListCollection()
     plantFile = TextFile()
     tdoFile = TextFile()
     outputTdoFile = TextFile()
     i = 0
     j = 0
     tdo = KfObject3d()
     plantFileTdo = KfObject3d()
     libraryTdo = KfObject3d()
     matchInLibrary = false
     aLine = ""
     fileInfo = SaveFileNamesStructure()
     
     result = 0
     if not FileExists(plantFileName):
         # check that files exist
         plantFileName = usupport.getFileOpenInfo(usupport.kFileTypePlant, plantFileName, "Choose a plant file")
         if plantFileName == "":
             return result
     if not FileExists(tdoLibrary):
         tdoLibrary = usupport.getFileOpenInfo(usupport.kFileTypeTdo, tdoLibrary, "Choose a 3D object library (tdo) file")
         if tdoLibrary == "":
             return result
     plantFileTdos = ucollect.TListCollection().Create()
     libraryFileTdos = ucollect.TListCollection().Create()
     try:
         ucursor.cursor_startWait()
         # read tdos from plants
         AssignFile(plantFile, plantFileName)
         try:
             # v1.5
             usupport.setDecimalSeparator()
             Reset(plantFile)
             while not UNRESOLVED.eof(plantFile):
                 UNRESOLVED.readln(plantFile, aLine)
                 if UNRESOLVED.pos(utdo.kStartTdoString, aLine) > 0:
                     tdo = utdo.KfObject3D().create()
                     tdo.readFromFileStream(plantFile, utdo.kInTdoLibrary)
                     plantFileTdos.Add(tdo)
         finally:
             CloseFile(plantFile)
         # read tdos from library
         AssignFile(tdoFile, tdoLibrary)
         try:
             # v1.5
             usupport.setDecimalSeparator()
             Reset(tdoFile)
             while not UNRESOLVED.eof(tdoFile):
                 tdo = utdo.KfObject3D().create()
                 tdo.readFromFileStream(tdoFile, utdo.kInTdoLibrary)
                 libraryFileTdos.Add(tdo)
         finally:
             CloseFile(tdoFile)
         if plantFileTdos.Count > 0:
             for i in range(0, plantFileTdos.Count):
                 # add plant tdos not in library list to library list
                 plantFileTdo = utdo.KfObject3D(plantFileTdos.Items[i])
                 matchInLibrary = false
                 if libraryFileTdos.Count > 0:
                     for j in range(0, libraryFileTdos.Count):
                         libraryTdo = utdo.KfObject3D(libraryFileTdos.Items[j])
                         if plantFileTdo.isSameAs(libraryTdo):
                             matchInLibrary = true
                             break
                 if not matchInLibrary:
                     tdo = utdo.KfObject3D().create()
                     tdo.copyFrom(plantFileTdo)
                     libraryFileTdos.Add(tdo)
                     result += 1
         if result > 0:
             if usupport.getFileSaveInfo(usupport.kFileTypeTdo, usupport.kDontAskForFileName, tdoLibrary, fileInfo):
                 # if any tdos in plant file but not in library, rewrite library
                 AssignFile(outputTdoFile, fileInfo.tempFile)
                 try:
                     # v1.5
                     usupport.setDecimalSeparator()
                     Rewrite(outputTdoFile)
                     usupport.startFileSave(fileInfo)
                     if libraryFileTdos.Count > 0:
                         for i in range(0, libraryFileTdos.Count):
                             tdo = UNRESOLVED.TObject(libraryFileTdos.Items[i]) as utdo.KfObject3D
                             if tdo == None:
                                 continue
                             tdo.writeToFileStream(outputTdoFile, utdo.kInTdoLibrary)
                     fileInfo.writingWasSuccessful = true
                 finally:
                     CloseFile(outputTdoFile)
                     usupport.cleanUpAfterFileSave(fileInfo)
     finally:
         plantFileTdos.free
         libraryFileTdos.free
         ucursor.cursor_stopWait()
     return result
コード例 #18
0
def Cursor_StartWait():
    ucursor.cursor_startWait()
コード例 #19
0
ファイル: usupport.pas.py プロジェクト: Neon22/PlantStudio
def startFileSave(fileInfo):
    ucursor.cursor_startWait()