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()
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()
def listConstByName(gui): """ Displays detailed information about a constellation when given its name. :param tkwidget gui: GUI object from which the request came """ prt = gui.getPrtInstance() if (ASTQuery.showQueryForm(["Enter Constellation Name to Display"]) != ASTQuery.QUERY_OK): return sConstName = ASTQuery.getData(1) if ((sConstName == None) or (len(sConstName) <= 0)): return prt.clearTextArea() idx = ASTConstellation.findConstellationByName(sConstName.strip()) if (idx < 0): prt.println("There is no Constellation with the name '" + sConstName + "'") else: ASTConstellation.displayConstellation(idx) prt.resetCursor()
def listConstByAbbrevName(gui): """ Displays detailed information about a constellation when given its abbreviated name. :param tkwidget gui: GUI object from which the request came """ prt = gui.getPrtInstance() if (ASTQuery.showQueryForm([ "Enter Constellation's 3 Character\nAbbreviated Name" ]) != ASTQuery.QUERY_OK): return sAbbrevName = ASTQuery.getData(1) if ((sAbbrevName == None) or (len(sAbbrevName) <= 0)): return prt.clearTextArea() idx = ASTConstellation.findConstellationByAbbrvName(sAbbrevName.strip()) if (idx < 0): prt.println("No Constellation whose abbreviated name is '" + sAbbrevName + "' was found") else: ASTConstellation.displayConstellation(idx) prt.resetCursor()
def findConstellationForRA_Decl(gui): """ Finds the constellation that a given RA/Decl falls within. :param tkwidget gui: GUI object from which the request came """ prt = gui.getPrtInstance() # Get RA & Decl if (ASTQuery.showQueryForm([ "Enter Right Ascension (hh:mm:ss.ss) for Epoch 2000.0", "Enter Declination (xxxd yym zz.zzs) for Epoch 2000.0" ]) != ASTQuery.QUERY_OK): return strTmp = ASTQuery.getData(1) # RA if ((strTmp == None) or (len(strTmp) <= 0)): return raObj = ASTTime.isValidTime(strTmp, HIDE_ERRORS) if not (raObj.isValidTimeObj()): ASTMsg.errMsg("The RA entered is invalid - try again.", "Invalid RA") return strTmp = ASTQuery.getData(2) # Decl if ((strTmp == None) or (len(strTmp) <= 0)): return declObj = ASTAngle.isValidAngle(strTmp, HIDE_ERRORS) if not (declObj.isValidAngleObj()): ASTMsg.errMsg("The Declination entered is invalid - try again.", "Invalid Decl") return prt.clearTextArea() idx = ASTConstellation.findConstellationFromCoord(raObj.getDecTime(), declObj.getDecAngle(), DEFAULT_EPOCH) if (idx < 0): ASTMsg.criticalErrMsg( "Could not determine a constellation for the data entered.") else: prt.println("The location " + ASTTime.timeToStr_obj(raObj, HMSFORMAT) + " RA, " + ASTAngle.angleToStr_obj(declObj, DMSFORMAT) + " Decl " + "is in the " + ASTConstellation.getConstName(idx) + " (" + ASTConstellation.getConstAbbrevName(idx) + ") constellation") prt.resetCursor()
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()
def listConstsByMeaning(gui): """ Displays detailed information about the constellations that contain a target substring in their "meaning" field. :param tkwidget gui: GUI object from which the request came """ prt = gui.getPrtInstance() if (ASTQuery.showQueryForm([ "Enter Substring to Search for in the\n" + "Constellation's 'Meaning' field" ]) != ASTQuery.QUERY_OK): return targ = ASTQuery.getData(1) if ((targ == None) or (len(targ) <= 0)): return prt.clearTextArea() iResult = ASTConstellation.findConstellationsByMeaning(targ.strip()) n = len(iResult) if (n <= 0): prt.println( "No Constellation(s) found with a 'Meaning' field containing the substring '" + targ + "'") else: # There is at least one constellation to display if (n == 1): prt.println("One Constellation has the substring '" + targ + "' in it's 'Meaning' field") else: prt.println( str(n) + " Constellations have the substring '" + targ + "' in their 'Meaning' field") for i in range(0, n): prt.println() prt.setFixedWidthFont() prt.println("*" * 80) prt.setProportionalFont() prt.println("Constellation # " + str(i + 1)) ASTConstellation.displayConstellation(iResult[i]) prt.resetCursor()
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()