Esempio n. 1
0
def sortCatalog(gui, sortField):
    """
    Sorts the currently loaded catalog in ascending or descending
    order depending upon the sort checkbox in the GUI.

    :param tkwidget gui: GUI object from which the request came
    :param CatalogSortFiedl sortField      which field to sort on.
    """
    prt = gui.getPrtInstance()
    sortOrder = gui.getSortOrderChkbox()

    if (not ASTCatalog.isCatalogLoaded()):
        ASTMsg.errMsg("No catalog is currently loaded.", "No Catalog Loaded")
        return

    prt.clearTextArea()
    prt.printnoln("You have elected to sort the catalog in ")
    if (sortOrder == ASCENDING_ORDER):
        prt.printnoln("ascending")
    else:
        prt.printnoln("descending")
    prt.println(" order by " + sortField.toStr() + " ... ")
    prt.println()

    ASTCatalog.sortStarCatalog(sortField, sortOrder)
    prt.println("The catalog has now been sorted ...")
    prt.resetCursor()
Esempio n. 2
0
def listAllObjsByConst(gui):
    """
    Shows all space objects within a given constellation.
    
    :param tkwidget gui: GUI object from which the request came
    """
    prt = gui.getPrtInstance()

    if (not ASTCatalog.isCatalogLoaded()):
        ASTMsg.errMsg("No catalog is currently loaded.", "No Catalog Loaded")
        return

    if (ASTQuery.showQueryForm([
            "Enter Constellation's 3 Character Abbreviated Name"
    ]) != ASTQuery.QUERY_OK):
        return

    constAbbrevName = ASTQuery.getData(1)
    if ((constAbbrevName == None) or (len(constAbbrevName) <= 0)):
        return

    prt.clearTextArea()

    idx = ASTConstellation.findConstellationByAbbrvName(
        constAbbrevName.strip())
    if (idx < 0):
        prt.println("No Constellation whose abbreviated name is '" +
                    constAbbrevName + "' was found")
    else:
        prt.setFixedWidthFont()
        ASTCatalog.displayAllObjsByConstellation(idx, gui.getSortOrderChkbox())
        prt.setProportionalFont()

    prt.resetCursor()
Esempio n. 3
0
def listObjByName(gui):
    """
    Displays all catalog information about an object given its name.
    
    :param tkwidget gui: GUI object from which the request came
    """
    prt = gui.getPrtInstance()

    if (not ASTCatalog.isCatalogLoaded()):
        ASTMsg.errMsg("No catalog is currently loaded.", "No Catalog Loaded")
        return

    if (ASTQuery.showQueryForm(["Enter the Object's Name"]) !=
            ASTQuery.QUERY_OK):
        return

    searchStr = ASTQuery.getData(1)
    if ((searchStr == None) or (len(searchStr) <= 0)):
        return

    prt.clearTextArea()
    idx = ASTCatalog.findObjByName(searchStr.strip())
    if (idx < 0):
        prt.println("No object named '" + searchStr +
                    "' was found in the catalog")
    else:
        ASTCatalog.displayFullObjInfo(idx)

    prt.resetCursor()
Esempio n. 4
0
def clearCatalog(gui):
    """
    Clears all catalog data currently loaded.
    
    :param tkwidget gui: GUI object from which the request came
    """
    prt = gui.getPrtInstance()

    if (not ASTCatalog.isCatalogLoaded()):
        ASTMsg.errMsg(
            "No catalog is currently loaded, so there is nothing to clear.",
            "No Catalog Loaded")
        return

    prt.clearTextArea()

    if (ASTMsg.pleaseConfirm(
            "Are you sure you want to clear all\ncurrently loaded catalog data?",
            "Clear Catalog Data")):
        ASTCatalog.clearCatalogAndSpaceObjects()
        gui.setFilename("")
        gui.setCatalogType("")
        gui.setEpoch(DEFAULT_EPOCH)
        prt.println("All currently loaded catalog data was cleared ...")
    else:
        prt.println("Catalog data was not cleared ...")

    prt.resetCursor()
Esempio n. 5
0
def showCatalogInfo(gui):
    """
    Shows the catalog information from the currently loaded catalog.
    
    :param tkwidget gui: GUI object from which the request came
    """
    prt = gui.getPrtInstance()

    if not (ASTCatalog.isCatalogLoaded()):
        ASTMsg.errMsg("No catalog is currently loaded.", "No Catalog Loaded")
    else:
        prt.clearTextArea()
        ASTCatalog.displayCatalogInfo()
        prt.resetCursor()
Esempio n. 6
0
def listObjByComments(gui):
    """
    Displays detailed information about catalog objects that
    contain a target substring in their "comments" field.

    :param tkwidget gui: GUI object from which the request came
    """
    prt = gui.getPrtInstance()

    if (not ASTCatalog.isCatalogLoaded()):
        ASTMsg.errMsg("No catalog is currently loaded.", "No Catalog Loaded")
        return

    if (ASTQuery.showQueryForm([
            "Enter Substring to Search for in the Object's 'Comments' Field"
    ]) != ASTQuery.QUERY_OK):
        return

    searchStr = ASTQuery.getData(1)
    if ((searchStr == None) or (len(searchStr) <= 0)):
        return

    prt.clearTextArea()

    iResult = ASTCatalog.findObjsByComments(searchStr.strip())

    n = len(iResult)

    if (n <= 0):
        prt.println("No Objects in the current Catalog have the substring '" +
                    searchStr + "' in their 'Comments' field")
    else:
        if (n == 1):
            prt.println("One Object has the substring '" + searchStr +
                        "' in it's 'Comments' field")
        else:
            prt.println(
                str(n) + " Objects have the substring '" + searchStr +
                "' in their 'Comments' field")

        for i in range(0, n):
            prt.println()
            prt.setFixedWidthFont()
            prt.println("*" * 80)
            prt.setProportionalFont()
            prt.println("Object # " + str(i + 1))
            ASTCatalog.displayFullObjInfo(iResult[i])

    prt.resetCursor()
Esempio n. 7
0
def listAllObjsInCatalog(gui):
    """
    Shows all catalog information, including space objects,
    in the currently loaded catalog.

    :param tkwidget gui: GUI object from which the request came
    """
    prt = gui.getPrtInstance()

    if (not ASTCatalog.isCatalogLoaded()):
        ASTMsg.errMsg("No catalog is currently loaded.", "No Catalog Loaded")
        return

    prt.clearTextArea()
    ASTCatalog.displayCatalogInfo()
    prt.setFixedWidthFont()
    prt.println("*" * 80)
    ASTCatalog.displayAllCatalogObjects()
    prt.setProportionalFont()
    prt.resetCursor()
Esempio n. 8
0
def listAllObjsByRange(gui):
    """
    Shows all space objects within a user specified index range.
    
    :param tkwidget gui: GUI object from which the request came
    """
    iMaxNum = 100  # default to 1st 100 entries

    prt = gui.getPrtInstance()

    if (not ASTCatalog.isCatalogLoaded()):
        ASTMsg.errMsg("No catalog is currently loaded.", "No Catalog Loaded")
        return

    if (ASTQuery.showQueryForm([
            "Enter index for 1st object to list\n(ex: 1 for 1st object in the catalog)",
            "Enter number of objects to list\n(ex: 10 for total of 10 objects)"
    ]) != ASTQuery.QUERY_OK):
        return

    prt.clearTextArea()

    n = ASTInt.isValidInt(ASTQuery.getData(1), HIDE_ERRORS)
    if (n.isValidIntObj()):
        iStart = n.getIntValue() - 1  # 0 base indexing assumed!
    else:
        iStart = 0

    n = ASTInt.isValidInt(ASTQuery.getData(2), HIDE_ERRORS)
    if (n.isValidIntObj()):
        iEnd = iStart + n.getIntValue() - 1
    else:
        iEnd = iStart + iMaxNum - 1

    prt.setFixedWidthFont()
    ASTCatalog.displayAllObjsByRange(iStart, iEnd)
    prt.setProportionalFont()
    prt.resetCursor()