Esempio n. 1
0
 def readFromTextFile(self, inputFile):
     inputLine = ""
     varName = ""
     varValue = ""
     
     while not UNRESOLVED.eof(inputFile):
         # plant reads start line; just continue from there
         UNRESOLVED.readln(inputFile, inputLine)
         if (trim(inputLine) == ""):
             continue
         varName = usupport.stringUpTo(inputLine, "=")
         varValue = usupport.stringBeyond(inputLine, "=")
         if not self.setField(varName, varValue):
             break
     if UNRESOLVED.pos(uppercase(kEndAmendmentString), uppercase(inputLine)) <= 0:
         raise GeneralException.create("Problem: Expected end of posing change.")
Esempio n. 2
0
    def readFromTextFile(self, inputFile):
        inputLine = ""
        varName = ""
        varValue = ""

        inputLine = inputFile.readln()
        while inputLine != None:
            # plant reads start line; just continue from there
            if inputLine.strip() == "":
                continue
            varName = usupport.stringUpTo(inputLine, "=")
            varValue = usupport.stringBeyond(inputLine, "=")
            if not self.setField(varName, varValue):
                break
            inputLine = inputFile.readln()
        if not string_match(kEndAmendmentString, inputLine):
            raise GeneralException.create("Problem: Expected end of posing change.")
Esempio n. 3
0
    def readFromMemo(self, aMemo, readingMemoLine):
        inputLine = ""
        varName = ""
        varValue = ""

        while readingMemoLine <= len(aMemo.Lines) - 1:
            # plant reads start line; just continue from there
            inputLine = aMemo.Lines.Strings[readingMemoLine]
            if inputLine.strip() == "":
                continue
            varName = usupport.stringUpTo(inputLine, "=")
            varValue = usupport.stringBeyond(inputLine, "=")
            if not self.setField(varName, varValue):
                break
            readingMemoLine += 1
        if not string_match(kEndAmendmentString, inputLine):
            raise GeneralException.create("Problem: Expected end of posing change.")
        return readingMemoLine
Esempio n. 4
0
 def readFromMemo(self, aMemo, readingMemoLine):
     inputLine = ""
     varName = ""
     varValue = ""
     
     while readingMemoLine <= aMemo.Lines.Count - 1:
         # plant reads start line; just continue from there
         inputLine = aMemo.Lines.Strings[readingMemoLine]
         if (trim(inputLine) == ""):
             continue
         varName = usupport.stringUpTo(inputLine, "=")
         varValue = usupport.stringBeyond(inputLine, "=")
         if not self.setField(varName, varValue):
             break
         readingMemoLine += 1
     if UNRESOLVED.pos(uppercase(kEndAmendmentString), uppercase(inputLine)) <= 0:
         raise GeneralException.create("Problem: Expected end of posing change.")
     return readingMemoLine
Esempio n. 5
0
    def readFromTextFile(self, inputFile):
        inputLine = ""
        varName = ""
        varValue = ""

        inputLine = readln(inputFile)
        while inputLine != None:
            # plant reads start line; just continue from there
            if (trim(inputLine) == ""):
                continue
            varName = usupport.stringUpTo(inputLine, "=")
            varValue = usupport.stringBeyond(inputLine, "=")
            if not self.setField(varName, varValue):
                break
            inputLine = readln(inputFile)
        if not string_match(kEndAmendmentString, inputLine):
            raise GeneralException.create(
                "Problem: Expected end of posing change.")
Esempio n. 6
0
 def loadPlantsFromFile(self, fileName, inPlantMover):
     inputFile = TextFile()
     plant = PdPlant()
     aLine = ""
     plantName = ""
     concentratedInFile = false
     concentratedLastTimeSaved = false
     lineCount = 0
     
     AssignFile(inputFile, fileName)
     try:
         # v1.5
         usupport.setDecimalSeparator()
         Reset(inputFile)
         self.plants.clear()
         # defaults in case things are missing from file
         self.plantDrawOffset_mm = usupport.setSinglePoint(0, 0)
         self.plantDrawScale_PixelsPerMm = 1.0
         self.mainWindowViewMode = udomain.domain.options.mainWindowViewMode
         self.mainWindowOrientation = udomain.domain.options.mainWindowOrientation
         self.showBoundsRectangle = udomain.domain.options.showBoundsRectangle
         concentratedLastTimeSaved = false
         self.fitInVisibleAreaForConcentrationChange = false
         while not UNRESOLVED.eof(inputFile):
             # cfk testing
             aLine = usupport.tolerantReadln(inputFile, aLine)
             if (aLine == "") or (UNRESOLVED.pos(";", aLine) == 1):
                 continue
             if UNRESOLVED.pos("offset=", aLine) == 1:
                 self.plantDrawOffset_mm = usupport.stringToSinglePoint(usupport.stringBeyond(aLine, "="))
             elif UNRESOLVED.pos("scale=", aLine) == 1:
                 try:
                     self.plantDrawScale_PixelsPerMm = intround(StrToFloat(usupport.stringBeyond(aLine, "=")) * 100.0) / 100.0
                 except:
                     self.plantDrawScale_PixelsPerMm = 1.0
             elif UNRESOLVED.pos("concentrated=", aLine) == 1:
                 concentratedLastTimeSaved = udomain.domain.viewPlantsInMainWindowOnePlantAtATime()
                 if udomain.domain.options.ignoreWindowSettingsInFile:
                     # v2.1 if ignoring settings in file, use current settings, otherwise use what is in file
                     concentratedInFile = (self.mainWindowViewMode == udomain.kViewPlantsInMainWindowOneAtATime)
                 else:
                     concentratedInFile = usupport.strToBool(usupport.stringBeyond(aLine, "="))
                 if concentratedInFile:
                     self.mainWindowViewMode = udomain.kViewPlantsInMainWindowOneAtATime
                 else:
                     self.mainWindowViewMode = udomain.kViewPlantsInMainWindowFreeFloating
                 if not inPlantMover:
                     udomain.domain.options.mainWindowViewMode = self.mainWindowViewMode
                 self.fitInVisibleAreaForConcentrationChange = concentratedInFile and not concentratedLastTimeSaved
             elif UNRESOLVED.pos("orientation (top/side)=", aLine) == 1:
                 if not udomain.domain.options.ignoreWindowSettingsInFile:
                     # v2.1 only read if not ignoring settings in file
                     self.mainWindowOrientation = StrToInt(usupport.stringBeyond(aLine, "="))
             elif UNRESOLVED.pos("boxes=", aLine) == 1:
                 self.showBoundsRectangle = usupport.strToBool(usupport.stringBeyond(aLine, "="))
                 if not inPlantMover:
                     udomain.domain.options.showBoundsRectangle = self.showBoundsRectangle
                 if (umain.MainForm != None) and (not umain.MainForm.inFormCreation) and (not inPlantMover):
                     umain.MainForm.updateForChangeToDomainOptions()
                     umain.MainForm.copyDrawingBitmapToPaintBox()
             elif UNRESOLVED.pos("[", aLine) == 1:
                 # plant start line
                 checkVersionNumberInPlantNameLine(aLine)
                 plant = uplant.PdPlant().create()
                 plantName = usupport.stringBeyond(aLine, "[")
                 plantName = usupport.stringUpTo(plantName, "]")
                 plant.setName(plantName)
                 udomain.domain.parameterManager.setAllReadFlagsToFalse()
                 # cfk change v1.3
                 # changed reading end of plant to read "end PlantStudio plant" instead of empty line because
                 # sometimes text wrapping puts empty lines in, not a good measure of completion.
                 # now end of plant must be there to be read. could produce endless loop if no end
                 # of plant, so stop at absolute cutoff of 300 non-empty, non-comment lines (there are now 215 parameters).
                 # also stop reading if reach next plant square bracket or end of file.
                 # v2.0 increased number of params to 350 so 300 is problem, changed to 3000 to avoid this in future, oops
                 lineCount = 0
                 while (UNRESOLVED.pos(uplant.kPlantAsTextEndString, aLine) <= 0) and (lineCount <= 3000):
                     # aLine <> '' do
                     aLine = usupport.tolerantReadln(inputFile, aLine)
                     if (UNRESOLVED.pos("[", aLine) == 1) or (UNRESOLVED.eof(inputFile)):
                         # v1.60 reversed order of the next two lines -- fixes infinite loop when no end of plant
                         # v1.3 added check for next plant or eof
                         break
                     if (trim(aLine) == "") or (UNRESOLVED.pos(";", aLine) == 1):
                         # v1.3 added skip empty lines
                         continue
                     plant.readLineAndTdoFromPlantFile(aLine, inputFile)
                     lineCount = lineCount + 1
                 plant.finishLoadingOrDefaulting(uplant.kCheckForUnreadParams)
                 self.plants.Add(plant)
     finally:
         CloseFile(inputFile)