index
int64 | repo_name
string | branch_name
string | path
string | content
string | import_graph
string |
|---|---|---|---|---|---|
11,503
|
inzaghian/anzhu
|
refs/heads/master
|
/testform.py
|
#coding:utf-8
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import pyqtSignal,QTimer,Qt
from PyQt5.QtGui import QIcon,QImage,QPixmap
from ui.test import Ui_TestForm
import cv2
from MyQR import myqr
import numpy as np
class Testwindow(QtWidgets.QWidget):
_signal = pyqtSignal(bytes)
def __init__(self):
super(Testwindow,self).__init__()
self.new=Ui_TestForm()
self.new.setupUi(self)
self.new.btn_generate.clicked.connect(self.QrImageCvt)
self.new.btn_start_captrue.clicked.connect(self.startCapture)
#self.startCapture()
#self.QrImageCvt()
def QrImageCvt(self):
head = 'DQY'
model = '19016'
date = '1908'
factory = '01'
pin=self.new.lineEdit.text()
cnt = self.new.lineEditCnt.text()
cnt = int(cnt)
pin = int(pin)
for i in range(0, cnt):
serial = str("%04d"%(pin+i))
name = head + model + date + factory + serial
myqr.run(words=name,save_name='./Icon/qr.png')
p2 = cv2.imread('./Icon/qr.png')
p1 = cv2.imread('./Icon/pic.jpg')
image_height, image_width, image_depth = p1.shape
x = 65
y = 50
w = 175
p2 = cv2.resize(p2,(w,w))
p1[image_height-w-y:image_height-y,image_width-w-x:image_width-x] = p2
p1 = cv2.putText(p1, 'SN:'+name, (image_width-350,image_height-50), cv2.FONT_HERSHEY_COMPLEX_SMALL,1.0,(0,0,0),2)
QIm = cv2.cvtColor(p1, cv2.COLOR_BGR2RGB)
self.new.label.setGeometry(20, 10, image_width, image_height)
QIm = QImage(QIm.data, image_width, image_height, image_width * image_depth, QImage.Format_RGB888)
QPix = QPixmap.fromImage(QIm)
dx1 = 50
dx2 = dx1+10
dy1 = 90
dy2 = 40
cv2.imwrite('./Icon/temp/'+name+'.png',p1[dy1:image_height-dy2,dx1:image_width-dx2])
self.new.label.setPixmap(QPix)
def startCapture(self):
self.setWindowIcon(QIcon('./Icon/dqy.png'))
png=QtGui.QPixmap('./Icon/dqy.png')
self.timer = QTimer()
self.timer.setTimerType(Qt.TimerType.PreciseTimer)
self.timer.timeout.connect(self.update)
self.timer.start(10)
self.cap = cv2.VideoCapture(0)
self.image = QImage()
self.width = 640
self.height = 480
self.detector = cv2.CascadeClassifier('./haarcascade_frontalface_default.xml')
def update(self):
ret,frame = self.cap.read()
height,width,depth = frame.shape
gray = cv2.cvtColor(frame, code = cv2.COLOR_BGR2GRAY)
face_zone = self.detector.detectMultiScale(gray,scaleFactor=1.2,minNeighbors = 5)
for x,y,w,h in face_zone:
cv2.circle(frame,center = (x+w//2,y+h//2),radius = w//2, color = [0,0,255])
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
self.image = QImage(frame, width,height,3*width,QImage.Format_RGB888)
pixmap = QPixmap.fromImage(self.image)
self.new.label.setPixmap(pixmap)
if __name__ == '__main__':
import sys
from PyQt5 import QtWidgets
from uartform import Uartwindow
app = QtWidgets.QApplication(sys.argv)
uf = Testwindow()
uf.show()
sys.exit(app.exec_())
|
{"/testform.py": ["/uartform.py"], "/main.py": ["/uartform.py"], "/comsetform.py": ["/ui/comset.py", "/uartform.py"], "/pinsetform.py": ["/uartform.py"], "/uartform.py": ["/ui/uart.py", "/comsetform.py", "/pinsetform.py", "/testform.py", "/com.py", "/xmlreadandwrite.py"]}
|
11,504
|
inzaghian/anzhu
|
refs/heads/master
|
/com.py
|
#coding:utf-8
import serial
import serial.tools.list_ports
#this is modify by any one
class opencom():
def __init__(self):
self.com=serial.Serial()
def initcom(self,comname,bsp=115200,bs=8,s=1,p=serial.PARITY_NONE):
try:
self.com.port = comname
self.com.baudrate = bsp
self.com.bytesize = bs
self.com.stopbits = s
self.com.parity = p
except Exception as e:
print(e)
def isopen(self):
return self.com.isOpen()
def opencom(self):
try:
self.com.open()
except Exception as e:
print(e)
return self.com.isOpen()
def CloseCom(self):
if self.com.isOpen():
self.com.close()
print("串口关闭")
def Get_ports(self):
clist=[]
port_list = list(serial.tools.list_ports.comports())
if len(port_list)> 0:
clist=[]
for e in port_list:
port_list_0 =list(e)
port_serial = port_list_0[0]
clist.append(port_serial)
return clist
def Get_p(self,p):
pstate=serial.PARITY_NONE
if p=="ODD":
pstate=serial.PARITY_ODD
elif p=="EVEN":
pstate=serial.PARITY_EVEN
return pstate
def comwritebytes(self,b):
wlen=self.com.write(b)
return wlen
def comwritestring(self,b):
wlen=self.com.write(b.encode("utf-8"))
return wlen
def HexToString(self,b):
rdata=""
for e in b:
rdata+=hex(e)+" "
rdata=rdata[:-1]
return rdata
def comreadbytes(self):
slen=self.com.in_waiting
sdata=b''
if slen>0:
sdata = self.com.read(slen)
return sdata
"""
c1=opencom()
clist=c1.Get_ports()
if len(clist)>0:
comname=clist[0]
c1.initcom(comname)
if c1.opencom():
c1.CloseCom()
"""
|
{"/testform.py": ["/uartform.py"], "/main.py": ["/uartform.py"], "/comsetform.py": ["/ui/comset.py", "/uartform.py"], "/pinsetform.py": ["/uartform.py"], "/uartform.py": ["/ui/uart.py", "/comsetform.py", "/pinsetform.py", "/testform.py", "/com.py", "/xmlreadandwrite.py"]}
|
11,505
|
inzaghian/anzhu
|
refs/heads/master
|
/main.py
|
#coding:utf-8
from PyQt5 import QtWidgets
from uartform import Uartwindow
import sys
def main():
app = QtWidgets.QApplication(sys.argv)
uf = Uartwindow()
uf.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
|
{"/testform.py": ["/uartform.py"], "/main.py": ["/uartform.py"], "/comsetform.py": ["/ui/comset.py", "/uartform.py"], "/pinsetform.py": ["/uartform.py"], "/uartform.py": ["/ui/uart.py", "/comsetform.py", "/pinsetform.py", "/testform.py", "/com.py", "/xmlreadandwrite.py"]}
|
11,506
|
inzaghian/anzhu
|
refs/heads/master
|
/comsetform.py
|
#coding:utf-8
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtGui import QIcon
from ui.comset import Ui_comsetform
class Comsetwindow(QtWidgets.QWidget):
_signal = pyqtSignal(dict)
def __init__(self):
super(Comsetwindow, self).__init__()
self.new = Ui_comsetform()
self.new.setupUi(self)
self.new.btn_save.clicked.connect(self.Get_set)
def initcom(self, clist):
self.new.cb_com.clear()
self.new.cb_com.addItems(clist)
self.setWindowIcon(QIcon('./Icon/dqy.png'))
def Get_set(self):
sl = {}
com = self.new.cb_com.currentText()
bsp = self.new.cb_bsp.currentText()
d = self.new.cb_data.currentText()
p = self.new.cb_p.currentText()
s = self.new.cb_stop.currentText()
sl = {'com': com, 'bsp': bsp, 'd': d, 'p': p, 's': s}
self._signal.emit(sl)
self.close()
def set_com(self, msg):
try:
com = msg['com']
bsp = msg['bsp']
d = msg['d']
s = msg['s']
p = msg['p']
self.new.cb_com.setCurrentText(com)
bsp=self.new.cb_bsp.setCurrentText(bsp)
d=self.new.cb_data.setCurrentText(d)
p=self.new.cb_p.setCurrentText(s)
s=self.new.cb_stop.setCurrentText(p)
except Exception as e:
print(e)
if __name__ == '__main__':
import sys
from PyQt5 import QtWidgets
from uartform import Uartwindow
app = QtWidgets.QApplication(sys.argv)
uf = Comsetwindow()
uf.show()
sys.exit(app.exec_())
|
{"/testform.py": ["/uartform.py"], "/main.py": ["/uartform.py"], "/comsetform.py": ["/ui/comset.py", "/uartform.py"], "/pinsetform.py": ["/uartform.py"], "/uartform.py": ["/ui/uart.py", "/comsetform.py", "/pinsetform.py", "/testform.py", "/com.py", "/xmlreadandwrite.py"]}
|
11,507
|
inzaghian/anzhu
|
refs/heads/master
|
/pinsetform.py
|
#coding:utf-8
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtGui import QIcon
from ui.pinset import Ui_PinSetForm
class Pinsetwindow(QtWidgets.QWidget):
_signal = pyqtSignal(bytes)
def __init__(self):
super(Pinsetwindow,self).__init__()
self.new=Ui_PinSetForm()
self.new.setupUi(self)
self.new.lineEdit.returnPressed.connect(self.DataInput)
self.initcom()
def initcom(self):
self.setWindowIcon(QIcon('./Icon/dqy.png'))
png=QtGui.QPixmap('./Icon/dqy.png')
self.new.label.setPixmap(png)
def DataInput(self):
data=self.new.lineEdit.text()
print(data)
self._signal.emit(data.encode("utf-8"))
self.new.lineEdit.clear()
self.close()
if __name__ == '__main__':
import sys
from PyQt5 import QtWidgets
from uartform import Uartwindow
app = QtWidgets.QApplication(sys.argv)
uf = Pinsetwindow()
uf.show()
sys.exit(app.exec_())
|
{"/testform.py": ["/uartform.py"], "/main.py": ["/uartform.py"], "/comsetform.py": ["/ui/comset.py", "/uartform.py"], "/pinsetform.py": ["/uartform.py"], "/uartform.py": ["/ui/uart.py", "/comsetform.py", "/pinsetform.py", "/testform.py", "/com.py", "/xmlreadandwrite.py"]}
|
11,508
|
inzaghian/anzhu
|
refs/heads/master
|
/uartform.py
|
#coding:utf-8
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import pyqtSignal,QThread,QTimer,Qt
from PyQt5.QtWidgets import QMessageBox
from PyQt5.QtGui import QIcon
from ui.uart import Ui_uartform
from comsetform import Comsetwindow
from pinsetform import Pinsetwindow
from testform import Testwindow
from com import opencom
from xmlreadandwrite import WriteXml,ReadXml
import time
class Uthread(QThread):
_signal = pyqtSignal(bytes)
def __init__(self, parent=None):
super(Uthread, self).__init__()
def initcom(self,com):
self.com=com
def SetAlive(self,alive):
self.alive=alive
def run(self):
while self.alive:
try:
sdata=self.com.comreadbytes()
self._signal.emit(sdata)
except Exception as e:
print(e)
break
class Uartwindow(QtWidgets.QWidget):
def __init__(self):
super(Uartwindow,self).__init__()
self.new = Ui_uartform()
self.new.setupUi(self)
self.InitData()
def InitData(self):
self.cw=Comsetwindow()
self.PinWin=Pinsetwindow()
self.PinWin._signal.connect(self.PinSet)
self.com=opencom()
self.cw._signal.connect(self.callcw)
self.TestWin = Testwindow()
self.new.btn_setcom.clicked.connect(self.ShowCw)
self.new.btn_search.clicked.connect(self.searchcom)
#self.new.btn_open.clicked.connect(self.OpneCom)
self.new.btn_open.clicked.connect(self.btn_opencom)
self.new.btn_send.clicked.connect(self.WriteData)
self.new.btn_receive.clicked.connect(self.ReadData)
self.new.btn_clear.clicked.connect(self.ClearMsg)
self.searchcom()
#self.new.cb_receive.setChecked(False)
self.thread = None
self.rtim=QTimer()
self.rtim.setTimerType(Qt.TimerType.PreciseTimer)
self.rtim.timeout.connect(self.callrtim)
self.logpath="./log/" + str(time.strftime("%Y_%m_%d_%H_%M_%S", time.localtime())) + '_log.txt'
self.ShowLog(self.logpath)
self.svaedata=""
try:
self.sl=ReadXml('setmsg.xml')
self.callcw(self.sl,b=1)
except Exception as e:
self.ShowLog(str(e))
self.setWindowIcon(QIcon('./Icon/dqy.png'))
self.new.btn_help_cmd.clicked.connect(self.HelpCmd)
self.new.btn_reboot_cmd.clicked.connect(self.RebootCmd)
self.new.btn_dev_info_cmd.clicked.connect(self.DevInfoCmd)
self.new.btn_log_on_cmd.clicked.connect(self.LogOnCmd)
self.new.btn_log_off_cmd.clicked.connect(self.LogOffCmd)
self.new.btn_pin_cmd.clicked.connect(self.InputPinCmd)
self.new.btn_dev_reset_cmd.clicked.connect(self.DevResetCmd)
self.new.btn_test.clicked.connect(self.TestStart)
png=QtGui.QPixmap('./Icon/dqy.png')
self.new.l1.setPixmap(png)
def starttim(self):
self.rtim.start(10)
def stoptim(self):
self.rtim.stop()
def callrtim(self):
sdata=self.com.comreadbytes()
self.callbacklog(sdata)
#开始串口接收线程
def StartThread(self):
# 创建线程
self.thread = Uthread()
self.thread.initcom(self.com)
self.thread.SetAlive(True)
self.thread._signal.connect(self.callbacklog)
# 开始线程
self.thread.start()
#停止串口线程
def StopThread(self):
if self.thread is not None:
self.thread.SetAlive(False)
self.thread.quit()
self.thread.wait()
self.thread.exit()
self.thread = None
def callbacklog(self,msg):
if len(msg)>0:
cbcheck=self.new.cb_receive.checkState()
hdata=""
try:
if cbcheck:
hdata=self.com.HexToString(msg)
self.ShowMsg(hdata)
else:
hdata=msg.decode('utf-8','replace')
self.ShowMsg(hdata)
self.WriteLog(hdata+"\r\n")
except Exception as e:
self.ShowMsg(str(e))
def ShowCw(self):
self.searchcom()
self.cw.set_com(self.sl)
self.cw.show()
def callcw(self,msg,b=0):
if msg:
self.ShowLog(str(msg))
try:
com=msg['com']
bsp=msg['bsp']
d=msg['d']
s=msg['s']
p=msg['p']
rp=self.com.Get_p(p)
self.com.initcom(com,int(bsp),int(d),int(s),rp)
if b==0:
WriteXml(msg)
self.ShowLog("串口设置成功")
if self.com.isopen():
self.OpenCom("关闭")
self.btn_opencom()
except Exception as e:
self.ShowBox(str(e))
def WriteLog(self,sdata,b=0):
self.svaedata+=sdata
if len(self.svaedata)>=512 or b==1:
with open(self.logpath,'a',encoding='utf-8') as f:
f.write(self.svaedata)
f.close()
self.svaedata=""
def btn_opencom(self):
t=self.new.btn_open.text()
self.OpenCom(t)
def OpenCom(self,t):
try:
if t=="打开":
comname=self.new.cb_comname.currentText()
self.com.initcom(comname=comname)
if(self.com.opencom()):
self.new.btn_open.setText("关闭")
self.new.btn_open.setStyleSheet("background-color:gold")
self.ShowLog("串口打开")
#self.StartThread()
self.starttim()
else:
self.ShowLog("打开失败")
elif t=="关闭":
self.com.CloseCom()
if(self.com.isopen()):
self.ShowLog("关闭失败!")
else:
#self.StopThread()
self.stoptim()
self.ShowLog("串口关闭")
self.new.btn_open.setText("打开")
self.new.btn_open.setStyleSheet("")
except Exception as e:
self.ShowBox(str(e))
def searchcom(self):
clist=self.com.Get_ports()
self.new.cb_comname.clear()
self.new.cb_comname.addItems(clist)
self.cw.initcom(clist)
def ShowMsg(self, msg):
#self.new.txt_show.append(msg+"\r\n")
self.new.txt_show.append(msg)
self.new.txt_show.moveCursor(QtGui.QTextCursor.End)
def ShowLog(self, msg):
#self.new.log_show.append(msg+"\r\n")
self.new.log_show.append(msg)
self.new.log_show.moveCursor(QtGui.QTextCursor.End)
def ClearMsg(self):
self.new.txt_show.clear()
def ShowBox(self,msg,title="串口收发数据"):
QMessageBox.information(self,title, msg, QMessageBox.Ok)
def closeEvent(self, event):
try:
self.cw.close()
self.StopThread()
self.stoptim()
self.com.CloseCom()
self.WriteLog("",b=1)
except Exception as e:
self.ShowLog(str(e))
def HexToBytes(self): #11 22 33 44 55
bl=[]
try:
text=self.new.txt_send.text()
slist=text.split(" ")
for e in slist:
b=int(e,16)
bl.append(b)
except Exception as e:
self.ShowBox(str(e))
return bl
def WriteData(self):
try:
slen=0
msg=self.new.txt_send.text()
cbcheck=self.new.cb_send.checkState()
if cbcheck:
bl=self.HexToBytes()
slen=self.com.comwritebytes(bl)
else:
slen=self.com.comwritestring(msg)
self.ShowLog("发送数据长度"+str(slen))
except Exception as e:
self.ShowBox(str(e))
def ReadData(self):
sdata=self.com.comreadbytes()
if len(sdata)>0:
cbcheck=self.new.cb_receive.checkState()
try:
if cbcheck:
hdata=self.com.HexToString(sdata)
self.ShowMsg(hdata)
else:
hdata=sdata.decode('utf-8','replace')
self.ShowMsg(hdata)
except Exception as e:
self.ShowLog(str(e))
def CmdSend(self, cmd):
len = self.com.comwritestring(cmd)
self.ShowLog("发送数据长度"+str(len))
def HelpCmd(self):
self.CmdSend("HELP")
def RebootCmd(self):
self.CmdSend("REBOOT")
def DevInfoCmd(self):
self.CmdSend("DEV_INFO")
def LogOnCmd(self):
self.CmdSend("LOG:ON")
def LogOffCmd(self):
self.CmdSend("LOG:OFF")
def InputPinCmd(self):
self.PinWin.show()
def PinSet(self,msg):
self.CmdSend("PIN:"+ msg.decode("utf-8"))
self.ShowLog(msg.decode("utf-8"))
def DevResetCmd(self):
self.CmdSend("DEV_RESET")
def TestStart(self):
self.TestWin.show()
if __name__ == '__main__':
import sys
from PyQt5 import QtWidgets
from uartform import Uartwindow
app = QtWidgets.QApplication(sys.argv)
uf = Uartwindow()
uf.show()
sys.exit(app.exec_())
|
{"/testform.py": ["/uartform.py"], "/main.py": ["/uartform.py"], "/comsetform.py": ["/ui/comset.py", "/uartform.py"], "/pinsetform.py": ["/uartform.py"], "/uartform.py": ["/ui/uart.py", "/comsetform.py", "/pinsetform.py", "/testform.py", "/com.py", "/xmlreadandwrite.py"]}
|
11,509
|
inzaghian/anzhu
|
refs/heads/master
|
/ui/uart.py
|
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'uart.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_uartform(object):
def setupUi(self, uartform):
uartform.setObjectName("uartform")
uartform.resize(387, 303)
self.txt_show = QtWidgets.QTextEdit(uartform)
self.txt_show.setGeometry(QtCore.QRect(20, 130, 361, 131))
self.txt_show.setObjectName("txt_show")
self.layoutWidget = QtWidgets.QWidget(uartform)
self.layoutWidget.setGeometry(QtCore.QRect(21, 30, 314, 25))
self.layoutWidget.setObjectName("layoutWidget")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.layoutWidget)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout.setObjectName("horizontalLayout")
self.cb_comname = QtWidgets.QComboBox(self.layoutWidget)
self.cb_comname.setObjectName("cb_comname")
self.horizontalLayout.addWidget(self.cb_comname)
self.btn_search = QtWidgets.QPushButton(self.layoutWidget)
self.btn_search.setObjectName("btn_search")
self.horizontalLayout.addWidget(self.btn_search)
self.btn_open = QtWidgets.QPushButton(self.layoutWidget)
self.btn_open.setObjectName("btn_open")
self.horizontalLayout.addWidget(self.btn_open)
self.btn_setcom = QtWidgets.QPushButton(self.layoutWidget)
self.btn_setcom.setObjectName("btn_setcom")
self.horizontalLayout.addWidget(self.btn_setcom)
self.txt_send = QtWidgets.QLineEdit(uartform)
self.txt_send.setGeometry(QtCore.QRect(20, 70, 361, 20))
self.txt_send.setObjectName("txt_send")
self.widget = QtWidgets.QWidget(uartform)
self.widget.setGeometry(QtCore.QRect(20, 100, 207, 27))
self.widget.setObjectName("widget")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.widget)
self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.cb_send = QtWidgets.QCheckBox(self.widget)
self.cb_send.setObjectName("cb_send")
self.horizontalLayout_2.addWidget(self.cb_send)
self.btn_send = QtWidgets.QPushButton(self.widget)
self.btn_send.setObjectName("btn_send")
self.horizontalLayout_2.addWidget(self.btn_send)
self.horizontalLayout_3.addLayout(self.horizontalLayout_2)
self.btn_receive = QtWidgets.QPushButton(self.widget)
self.btn_receive.setObjectName("btn_receive")
self.horizontalLayout_3.addWidget(self.btn_receive)
self.widget1 = QtWidgets.QWidget(uartform)
self.widget1.setGeometry(QtCore.QRect(21, 271, 229, 25))
self.widget1.setObjectName("widget1")
self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self.widget1)
self.horizontalLayout_4.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.cb_receive = QtWidgets.QCheckBox(self.widget1)
self.cb_receive.setObjectName("cb_receive")
self.horizontalLayout_4.addWidget(self.cb_receive)
self.btn_clear = QtWidgets.QPushButton(self.widget1)
self.btn_clear.setObjectName("btn_clear")
self.horizontalLayout_4.addWidget(self.btn_clear)
self.btn_save = QtWidgets.QPushButton(self.widget1)
self.btn_save.setObjectName("btn_save")
self.horizontalLayout_4.addWidget(self.btn_save)
self.retranslateUi(uartform)
QtCore.QMetaObject.connectSlotsByName(uartform)
def retranslateUi(self, uartform):
_translate = QtCore.QCoreApplication.translate
uartform.setWindowTitle(_translate("uartform", "串口接收发送界面"))
self.btn_search.setText(_translate("uartform", "搜索"))
self.btn_open.setText(_translate("uartform", "打开"))
self.btn_setcom.setText(_translate("uartform", "设置串口"))
self.cb_send.setText(_translate("uartform", "hex"))
self.btn_send.setText(_translate("uartform", "发送"))
self.btn_receive.setText(_translate("uartform", "接收"))
self.cb_receive.setText(_translate("uartform", "hex显示"))
self.btn_clear.setText(_translate("uartform", "清除"))
self.btn_save.setText(_translate("uartform", "保存"))
|
{"/testform.py": ["/uartform.py"], "/main.py": ["/uartform.py"], "/comsetform.py": ["/ui/comset.py", "/uartform.py"], "/pinsetform.py": ["/uartform.py"], "/uartform.py": ["/ui/uart.py", "/comsetform.py", "/pinsetform.py", "/testform.py", "/com.py", "/xmlreadandwrite.py"]}
|
11,510
|
inzaghian/anzhu
|
refs/heads/master
|
/gps.py
|
#coding:utf-8
class gps():
def __init__(self):
self.realdata=b''
self.fb=False
def Get_gps_data(self,sdata):
sl=[]
for e in sdata:
if e==0x24 and self.fb==False:
self.fb=True
self.realdata+=bytes([e])
if self.fb and e==0x0a:
self.realdata+=bytes([e])
data=self.realdata.decode('utf-8','replace')
sl.append(data)
self.fb=False
self.realdata=b''
elif e!=0x24 and self.fb:
self.realdata+=bytes([e])
elif e==0x24 and self.fb and len(self.realdata)>5:
data=self.realdata.decode('utf-8','replace')
sl.append(data)
self.realdata=b''
self.realdata+=bytes([e])
print(sl)
return sl
def CheckGpsBuff(self,buff):
buff=buff.replace("\r","").replace("\n","")
isok = False
if len(buff)==(buff.find('*')+2):
pass
else:
crc=0
for ch in buff:
if ch=='$':
pass
elif ch=='*':
break
else:
if crc==0:
crc=ord(ch)
else:
crc=crc^ord(ch)
try:
if buff.find('*')+3==len(buff):
length=buff.find('*')
s=buff[length+1]+buff[length+2]
scode=(str(hex(crc))[2:]).upper()
if len(scode)==2:
pass
else:
scode="0"+scode
if s==scode:
isok=True
except Exception as e:
print("gpsErr:",str(e))
return isok
g=gps()
sdata="$GPRMC,121252.000,A,3958.3032,N,11629.6046,E,15.15,359.95,070306,,,A*54$GPRMC,121252.000,A,3958.3032,N,11629.6046,E,15.15,359.95,070306,,,A*54\r\n".encode('utf-8')
sl=g.Get_gps_data(sdata)
for e in sl:
print(g.CheckGpsBuff(e))
|
{"/testform.py": ["/uartform.py"], "/main.py": ["/uartform.py"], "/comsetform.py": ["/ui/comset.py", "/uartform.py"], "/pinsetform.py": ["/uartform.py"], "/uartform.py": ["/ui/uart.py", "/comsetform.py", "/pinsetform.py", "/testform.py", "/com.py", "/xmlreadandwrite.py"]}
|
11,516
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/renderer/OverlayManager.py
|
'''
// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-18
@author: Neil Borle
'''
import math
from OpenGL.GLU import gluOrtho2D
from RendererObjectManager import RendererObjectManager
from src.rendererUtil.ColoredQuad import ColoredQuad
from src.units.Vector3 import Vector3
from src.utils.VectorUtil import cross_product, normalized
from src.utils.Matrix4x4 import create_identity, create_rotation, multiply_MV
class OverlayManager(RendererObjectManager):
'''
Manages the various overlay classes.
'''
must_update_transformed_orientation = True
searching = False
def reload(self, gl, full_reload):
pass
#mSearchArrow.reloadTextures(gl, res, textureManager());
#mCrosshair.reloadTextures(gl, res, textureManager());
def resize(self, gl, screen_width, screen_height):
self.width = screen_width
self.height = screen_height
# If the search target is within this radius of the center of the screen, the user is
# considered to have "found" it.
#float searchTargetRadius = Math.min(screenWidth, screenHeight) - 20;
#mSearchHelper.setTargetFocusRadius(searchTargetRadius);
#mSearchHelper.resize(screenWidth, screenHeight);
#mSearchArrow.resize(gl, screenWidth, screenHeight, searchTargetRadius);
#mCrosshair.resize(gl, screenWidth, screenHeight);
self.dark_quad = ColoredQuad(0, 0, 0, 0.6,
0, 0, 0,
screen_width, 0, 0,
0, screen_height, 0)
def set_view_orientation(self, look_dir, up_dir):
self.look_dir = look_dir.copy()
self.up_dir = up_dir.copy()
self.must_update_transformed_orientation = True
def draw_internal(self, gl):
self.update_transformed_orientation_if_necessary()
self.set_up_matrices(gl)
if self.searching:
#mSearchHelper.setTransform(getRenderState().getTransformToDeviceMatrix());
#mSearchHelper.checkState();
#transitionFactor = mSearchHelper.getTransitionFactor();
# Darken the background.
self.dark_quad.draw(gl)
# Draw the crosshair.
#mCrosshair.draw(gl, mSearchHelper, getRenderState().getNightVisionMode());
# Draw the search arrow.
#mSearchArrow.draw(gl, mTransformedLookDir, mTransformedUpDir, mSearchHelper,
# getRenderState().getNightVisionMode())
self.restore_matrices(gl)
def set_view_up_direction(self, viewer_up):
if abs(viewer_up.y) < 0.999:
cp = cross_product(viewer_up, Vector3(0, 0, 0))
cp = normalized(cp)
self.geo_to_viewer_transform = create_rotation(math.acos(viewer_up.y), cp)
else:
self.geo_to_viewer_transform = create_identity()
self.must_update_transformed_orientation = True
def enable_search_overlay(self):
raise NotImplementedError("Not done yet")
def disable_search_overlay(self):
raise NotImplementedError("Not done yet")
def set_up_matrices(self, gl):
# Save the matrix values.
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glPushMatrix()
gl.glLoadIdentity()
gl.glMatrixMode(gl.GL_MODELVIEW);
gl.glPushMatrix()
left = self.width / 2.0
bottom = self.height / 2.0
gl.glLoadIdentity()
gluOrtho2D(left, -left, bottom, -bottom)
def restore_matrices(self, gl):
# Restore the matrices.
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glPopMatrix()
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glPopMatrix()
def update_transformed_orientation_if_necessary(self):
if self.must_update_transformed_orientation and self.searching:
self.transformed_look_dir = \
multiply_MV(self.geo_to_viewer_transform, self.look_dir)
self.transformed_up_dir = \
multiply_MV(self.geo_to_viewer_transform, self.up_dir)
self.must_update_transformed_orientation = False
def __init__(self, layer_id, new_texture_manager):
'''
Constructor
'''
RendererObjectManager.__init__(self, layer_id, new_texture_manager)
self.width = 2
self.height = 2
self.geo_to_viewer_transform = create_identity()
self.look_dir = Vector3(0, 0, 0)
self.up_dir = Vector3(0, 1, 0)
self.transformed_look_dir = Vector3(0, 0, 0)
self.transformed_up_dir = Vector3(0, 1, 0)
#search_helper = SearchHelper()
self.dark_quad = None
#self.search_arrow = SearchArrow()
#crosshair = CrosshairOverlay()
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,517
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/renderer/RendererControllerBase.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-28
@author: Neil Borle
'''
from src.utils.Enumeration import enum
from src.utils.Runnable import Runnable
class RenderManager(object):
'''
Manages render object managers by providing
methods that queue runnable events that change
the behaviour of the managers.
'''
def queue_enabled(self, enable_bool, controller):
def run_method():
self.manager.enabled = enable_bool
msg = "Enabling" if enable_bool else "Disabling" + " manager " + str(self.manager)
controller.queue_runnable(msg, command_type.DATA, Runnable(run_method))
def queue_max_field_of_view(self, fov, controller):
def run_method():
self.manager.max_radius_of_view = fov
msg = "Setting manager max field of view: " + str(fov)
controller.queueRunnable(msg, command_type.DATA, Runnable(run_method))
def queue_objects(self, sources, update_type, controller):
def run_method():
self.manager.update_objects(sources, update_type)
msg = "Setting source objects"
controller.queue_runnable(msg, command_type.DATA, Runnable(run_method))
def __init__(self, mgr):
'''
constructor
'''
# Render Object Manager
self.manager = mgr
command_type = enum(VIEW=0, DATA=1, SYNCHRONIZATION=3)
class RendererControllerBase(object):
'''
Base class in that it provides the basic functions
for dealing with object managers.
'''
def create_point_manager(self, layer_id):
manager = RenderManager(self.renderer.create_point_manager(layer_id))
self.queue_add_manager(manager)
return manager
def create_line_manager(self, layer_id):
manager = RenderManager(self.renderer.create_line_manager(layer_id))
self.queue_add_manager(manager)
return manager
def create_label_manager(self, layer_id):
manager = RenderManager(self.renderer.create_label_manager(layer_id))
self.queue_add_manager(manager)
return manager
def create_image_manager(self, layer_id):
manager = RenderManager(self.renderer.create_image_manager(layer_id))
self.queue_add_manager(manager)
return manager
def queue_night_vision_mode(self, enable_bool):
def run_method():
self.renderer.render_state.night_vision_mode = enable_bool
msg = "Setting night vision mode: " + str(enable_bool)
self.queue_runnable(msg, command_type.DATA, Runnable(run_method))
def queue_field_of_view(self, fov):
def run_method():
self.renderer.set_radius_of_view(fov)
msg = "Setting fov: " + str(fov)
self.queue_runnable(msg, command_type.DATA, Runnable(run_method))
def queue_text_angle(self, angle_in_radians):
def run_method():
self.renderer.set_text_angle(angle_in_radians)
msg = "Setting text angle: " + str(angle_in_radians)
self.queue_runnable(msg, command_type.DATA, Runnable(run_method))
def queue_viewer_up_direction(self, gc_up):
def run_method():
self.renderer.set_viewer_up_direction(gc_up)
msg = "Setting up direction: " + str(gc_up)
self.queue_runnable(msg, command_type.DATA, Runnable(run_method))
def queue_set_view_orientation(self, dirX, dirY, dirZ, upX, upY, upZ):
def run_method():
self.renderer.set_view_orientation(dirX, dirY, dirZ, upX, upY, upZ)
msg = "Setting view orientation"
self.queue_runnable(msg, command_type.DATA, Runnable(run_method))
def queue_enable_sky_gradient(self, sun_pos):
def run_method():
self.renderer.enable_sky_gradient(sun_pos)
msg = "Enabling sky gradient at: " + str(sun_pos)
self.queue_runnable(msg, command_type.DATA, Runnable(run_method))
def queue_disable_sky_gradient(self):
def run_method():
self.renderer.disable_sky_gradient()
msg = "Disabling sky gradient"
self.queue_runnable(msg, command_type.DATA, Runnable(run_method))
def queue_enable_search_overlay(self):
raise NotImplementedError("not done this class")
def queue_disable_search_overlay(self):
raise NotImplementedError("not done this class")
def add_update_closure(self, closure):
def run_method():
self.renderer.add_update_closure(closure)
msg = "Setting update callback"
self.queue_runnable(msg, command_type.DATA, Runnable(run_method))
def remove_update_callback(self, closure):
raise NotImplementedError("not done this class")
def queue_add_manager(self, render_manager):
def run_method():
self.renderer.add_object_manager(render_manager.manager)
msg = "Adding manager: " + str(render_manager)
self.queue_runnable(msg, command_type.DATA, Runnable(run_method))
def wait_until_finished(self):
raise NotImplementedError("not done this class")
def queue_runnable(self, msg, cmd_type, runnable, q=None):
if q == None:
q = self.queuer
q.put(runnable)
def __init__(self, skyrenderer):
'''
Constructor
'''
self.renderer = skyrenderer
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,518
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/layers/Layer.py
|
'''
// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor, Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-28
@author: Neil Borle
'''
import threading
from src.source.PointSource import PointSource
from src.source.LineSource import LineSource
from src.source.TextSource import TextSource
from src.source.ImageSource import ImageSource
class Layer(object):
'''
Base class for any layer (is a combination of layer.java
and AbstractLayer.java in the original code).
'''
reentrant_lock = threading.RLock()
def register_with_renderer(self, rend_controller):
self.render_map.clear()
self.render_controller = rend_controller
self.update_layer_for_controller_change()
def set_visible(self, visible_bool):
'''
Makes this layer visible or invisible based on user
selection with the preference buttons.
'''
with self.reentrant_lock:
atomic = self.render_controller.create_atomic()
for render_manager in self.render_map.values():
render_manager.queue_enabled(visible_bool, atomic)
self.render_controller.queue_atomic(atomic)
def add_update_closure(self, closure):
if self.render_controller != None:
self.render_controller.add_update_closure(closure)
def remove_update_callback(self, closure):
if self.render_controller != None:
self.render_controller.remove_update_callback(closure)
def redraw(self, points, lines, texts, images, update_type):
'''
Forces a redraw of the layer by removing all object managers.
Updates the renderer (using the given UpdateType), with then given set
of UI elements. Depending on the value of UpdateType, current sources
will either have their state updated, or will be overwritten by the
given set of UI elements.
'''
if self.render_controller == None:
return
with self.reentrant_lock:
atomic = self.render_controller.create_atomic()
self.set_sources(points, update_type, PointSource, atomic)
self.set_sources(lines, update_type, LineSource, atomic)
self.set_sources(texts, update_type, TextSource, atomic)
self.set_sources(images, update_type, ImageSource, atomic)
self.render_controller.queue_atomic(atomic)
def set_sources(self, sources, update_type, clazz, atomic):
'''
Given an input source (point/line/text/image) a corresponding
object manager is created and stored in the render_map dictionary.
'''
if sources == None:
return
manager = None
if clazz not in self.render_map.keys():
manager = self.create_render_manager(clazz, atomic)
self.render_map[clazz] = manager
else:
manager = self.render_map[clazz]
manager.queue_objects(sources, update_type, atomic)
def create_render_manager(self, clazz, controller):
if clazz is PointSource:
return controller.create_point_manager(self.get_layer_id())
elif clazz is LineSource:
return controller.create_line_manager(self.get_layer_id())
elif clazz is TextSource:
return controller.create_label_manager(self.get_layer_id())
elif clazz is ImageSource:
return controller.create_image_manager(self.get_layer_id())
else:
raise Exception("class is of unknown type")
def get_preference_id(self):
return "source_provider." + self.layerNameId()
def get_layer_name(self):
raise NotImplementedError("need strings.xml")
def __init__(self):
'''
Constructor
'''
self.render_map = {}
self.render_controller = None
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,519
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/testing/UtilsTesting.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-07-24
@author: Alyson Wu and Morgan Redshaw
'''
#VectorUtilTest
def Vector3Test():
'''
>>> from src.units.Vector3 import Vector3
>>> one = Vector3(1,2,3)
>>> two = Vector3(2,4,6)
>>> one.scale(2)
>>> one.equals(two)
True
>>> one == two
False
'''
pass
def assertVectorsEqual(v1,v2):
DELTA = 0.00001
same = True
same = abs(v1.x - v2.x) < DELTA & same
same = abs(v1.y - v2.y) < DELTA & same
same = abs(v1.z - v2.z) < DELTA &same
return same
def testDotProduct():
'''
>>> from src.units.Vector3 import Vector3
>>> from src.utils.VectorUtil import dot_product
>>> DELTA = 0.00005
>>> v1 = Vector3(1, 2, 3)
>>> v2 = Vector3(0.3, 0.4, 0.5)
>>> dp = float(dot_product(v1,v2))
>>> abs(2.6 - dp) < DELTA
True
'''
pass
# Matrix 4x4 Test
def assert_vectors_equal(v1, v2, delta):
'''
Is a needed function for testing Matrix4x4. This is the only place in the code base that this function occurs.
'''
equal = True
equal = (abs(v1.x - v2.x) < delta) & equal
equal = (abs(v1.y - v2.y) < delta) & equal
equal = (abs(v1.z - v2.z) < delta) & equal
return equal
def assert_mat_equal(mat1, mat2, delta):
'''
Is a needed function for testing Matrix4x4. This is the only place in the code base that this function occurs.
'''
m1 = mat1.values;
m2 = mat2.values;
equal = True
equal = (abs(m1[0] - m2[0]) < delta) & equal
equal = (abs(m1[1] - m2[1]) < delta) & equal
equal = (abs(m1[2] - m2[2]) < delta) & equal
equal = (abs(m1[3] - m2[3]) < delta) & equal
equal = (abs(m1[4] - m2[4]) < delta) & equal
equal = (abs(m1[5] - m2[5]) < delta) & equal
equal = (abs(m1[6] - m2[6]) < delta) & equal
equal = (abs(m1[7] - m2[7]) < delta) & equal
equal = (abs(m1[8] - m2[8]) < delta) & equal
equal = (abs(m1[9] - m2[9]) < delta) & equal
equal = (abs(m1[10] - m2[10]) < delta) & equal
equal = (abs(m1[11] - m2[11]) < delta) & equal
equal = (abs(m1[12] - m2[12]) < delta) & equal
equal = (abs(m1[13] - m2[13]) < delta) & equal
equal = (abs(m1[14] - m2[14]) < delta) & equal
equal = (abs(m1[15] - m2[15]) < delta) & equal
return equal
def Matrix4x4Testing():
'''
# Needed imports
>>> import src.utils.VectorUtil as VectorUtil
>>> from src.utils.Matrix4x4 import Matrix4x4, create_rotation, create_identity, create_scaling, create_translation,\
multiply_MM, multiply_MV
>>> from src.units.Vector3 import Vector3
# Test multiply by identity
>>> identity = create_identity()
>>> m = Matrix4x4([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] )
>>> assert_mat_equal(m, multiply_MM(identity, m), 0.00001)
True
>>> assert_mat_equal(m, multiply_MM(m, identity), 0.00001)
True
#Test multiply by scaling
>>> m = Matrix4x4([1, 2, 3, 0, 5, 6, 7, 0, 9, 10, 11, 0, 0, 0, 0, 0])
>>> scaling = create_scaling(2, 2, 2)
>>> expected = Matrix4x4([ 2, 4, 6, 0, 10, 12, 14, 0, 18, 20, 22, 0, 0, 0, 0, 0 ] )
>>> assert_mat_equal(expected, multiply_MM(scaling, m), 0.00001)
True
>>> assert_mat_equal(expected, multiply_MM(m, scaling), 0.00001)
True
# Test multiply by translation
>>> v = Vector3(1, 1, 1);
>>> trans = create_translation(1, 2, 3);
>>> expected = Vector3(2, 3, 4);
>>> assert_vectors_equal(expected, multiply_MV(trans, v), 0.00001);
True
# Test rotation 3x3 parallel rotation has no effect
>>> import math
>>> m = create_rotation(math.pi, Vector3(0, 1, 0))
>>> v = Vector3(0, 2, 0)
>>> assert_vectors_equal(v, multiply_MV(m, v), 0.00001)
True
# Test rotation 3x3 perpendicular rotation
>>> m = create_rotation(math.pi * 0.25, Vector3(0, -1, 0))
>>> v = Vector3(1, 0, 0)
>>> oneOverSqrt2 = 1.0 / math.sqrt(2.0)
>>> assert_vectors_equal(Vector3(oneOverSqrt2, 0, oneOverSqrt2), multiply_MV(m, v), 0.00001)
True
# Test rotation 3x3 Unaligned axis
>>> axis = Vector3(1, 1, 1)
>>> axis = VectorUtil.normalized(axis)
>>> numRotations = 5
>>> m = create_rotation(math.pi * 2 / numRotations, axis)
>>> start = Vector3(2.34, 3, -17.6)
>>> v = start
>>> for i in range(5):
... v = multiply_MV(m, v)
>>> assert_vectors_equal(start, v, 0.00001)
True
'''
pass
#Matrix 33 Test
def assert_matrices_equal(m1, m2, delta):
'''
This is a specialized test for Matrix33Tests
'''
correct = True
correct = (abs(m1.xx - m2.xx) < delta) & correct
correct = (abs(m1.xy - m2.xy) < delta) & correct
correct = (abs(m1.xz - m2.xz) < delta) & correct
correct = (abs(m1.yx - m2.yx) < delta) & correct
correct = (abs(m1.yy - m2.yy) < delta) & correct
correct = (abs(m1.yz - m2.yz) < delta) & correct
correct = (abs(m1.zx - m2.zx) < delta) & correct
correct = (abs(m1.zy - m2.zy) < delta) & correct
correct = (abs(m1.zz - m2.zz) < delta) & correct
return correct
# GeometryTest
def GeometryTests():
'''
# All imports needed
>>> import math
>>> from src.units.Matrix33 import Matrix33
>>> from src.utils.Geometry import calculate_rotation_matrix, matrix_multiply, matrix_vector_multiply,\
vector_product, scalar_product, getXYZ, degrees_to_radians
>>> from src.units.RaDec import RaDec
>>> from src.units.Vector3 import Vector3
>>> allTestValues = [[0, 0, 1, 0, 0],\
[90, 0, 0, 1, 0],\
[0, 90, 0, 0, 1],\
[180, 0, -1, 0, 0],\
[0, -90, 0, 0, -1],\
[270, 0, 0, -1, 0] ]
# Test speherical to cartesians. This will run through 6 times
>>> for testValues in allTestValues:
... ra = testValues[0];
... dec = testValues[1];
... x = testValues[2];
... y = testValues[3];
... z = testValues[4];
... result = getXYZ(RaDec(ra, dec));
... correct = True
... correct = (abs(x - result.x) < 0.00001) & correct
... correct = (abs(y - result.y) < 0.00001) & correct
... correct = (abs(z - result.z) < 0.00001) & correct
... correct
True
True
True
True
True
True
# Test vector product
>>> x = Vector3(1, 0, 0)
>>> y = Vector3(0, 1, 0)
>>> z = vector_product(x, y)
>>> assert_vectors_equal(z, Vector3(0, 0, 1), 0.00001)
True
# Check that a X b is perpendicular to a and b
>>> a = Vector3(1, -2, 3)
>>> b = Vector3(2, 0, -4)
>>> c = vector_product(a, b)
>>> aDotc = scalar_product(a, c)
>>> bDotc = scalar_product(b, c)
>>> abs(0 - aDotc) < 0.00001
True
>>> abs(0 - aDotc) < 0.00001
True
# Check that |a X b| is correct
>>> v = Vector3(1, 2, 0)
>>> ww = vector_product(x, v)
>>> wwDotww = scalar_product(ww, ww)
>>> abs( ( math.pow(1 * math.sqrt(5) * math.sin(math.atan(2)), 2) ) - wwDotww) < 0.00001
True
# Test matrix inversion.... This would just prints out information (which isnt very helpful for me)
>>> m = Matrix33 (1, 2, 0, 0, 1, 5, 0, 0, 1)
>>> inv = m.get_inverse();
>>> product = matrix_multiply(m, inv)
# Test Calculate Rotation Matrix
>>> noRotation = calculate_rotation_matrix(0, Vector3(1, 2, 3));
>>> identity = Matrix33(1, 0, 0, 0, 1, 0, 0, 0, 1);
>>> assert_matrices_equal(identity, noRotation, 0.00001);
True
>>> rotAboutZ = calculate_rotation_matrix(90, Vector3(0, 0, 1));
>>> assert_matrices_equal(Matrix33(0, 1, 0, -1, 0, 0, 0, 0, 1), rotAboutZ, 0.00001);
True
>>> axis = Vector3(2, -4, 1)
>>> axis.normalize()
>>> rotA = calculate_rotation_matrix(30, axis)
>>> rotB = calculate_rotation_matrix(-30, axis)
>>> shouldBeIdentity = matrix_multiply(rotA, rotB)
>>> assert_matrices_equal(identity, shouldBeIdentity, 0.00001);
True
>>> axisPerpendicular = Vector3(4, 2, 0);
>>> rotatedAxisPerpendicular = matrix_vector_multiply(rotA, axisPerpendicular);
# Should still be perpendicular
>>> abs(0 - scalar_product(axis, rotatedAxisPerpendicular)) < 0.00001
True
# And the angle between them should be 30 degrees
>>> axisPerpendicular.normalize();
>>> rotatedAxisPerpendicular.normalize();
>>> expectedValue = math.cos(degrees_to_radians(30.0))
>>> actualValue = scalar_product(axisPerpendicular, rotatedAxisPerpendicular)
>>> abs( expectedValue - actualValue) < 0.00001
True
# Test martix multiply
>>> m1 = Matrix33(1, 2, 4, -1, -3, 5, 3, 2, 6)
>>> m2 = Matrix33(3, -1, 4, 0, 2, 1, 2, -1, 2)
>>> v1 = Vector3(0, -1, 2)
>>> v2 = Vector3(2, -2, 3)
>>> assert_matrices_equal(Matrix33(11, -1, 14, 7, -10, 3, 21, -5, 26), matrix_multiply(m1, m2), 0.00001)
True
>>> assert_vectors_equal(Vector3(6, 13, 10), matrix_vector_multiply(m1, v1), 0.00001)
True
>>> assert_vectors_equal(Vector3(10, 19, 20), matrix_vector_multiply(m1, v2), 0.00001)
True
'''
pass
#TimeUtilTest
TOL = 0.0001 # Tolerance for Julian Date calculations
LMST_TOL = 0.15 # Tolerance for LMST calculation
HOURS_TO_DEGREES = 360.0/24.0 # Convert from hours to degrees
def testJulianDate2000AD():
'''
>>> import time
>>> import datetime as dt
>>> import calendar
>>> from src.utils.TimeUtil import calculate_julian_day
>>> unix2000 = 946684800
>>> setTime = dt.datetime(2000, 1, 1, 0, 0, 0).timetuple()
>>> GMT = calendar.timegm(setTime)
>>> print abs(unix2000 - GMT) < TOL
True
>>> abs(2451544.5 - calculate_julian_day(setTime)) < TOL
True
'''
# January 1, 2000 at midday corresponds to JD = 2451545.0, according to http://en.wikipedia.org/wiki/Julian_day#Gregorian_calendar_from_Julian_day_number.
# So midnight before is half a day earlier.
pass
def testJulianDate():
# Make sure that we correctly generate Julian dates. Standard values were obtained from the USNO web site: http://www.usno.navy.mil/USNO/astronomical-applications/data-services/jul-date
'''
>>> import time
>>> import datetime as dt
>>> import calendar
>>> from src.utils.TimeUtil import calculate_julian_day
# Jan 1, 2009, 12:00 UT1
>>> Time1 = dt.datetime(2009, 1, 1, 12, 0, 0).timetuple()
>>> abs(2454833.0 - calculate_julian_day(Time1)) < TOL
True
# Jul 4, 2009, 12:00 UT1
>>> Time2 = dt.datetime(2009, 7, 4, 12, 0, 0).timetuple()
>>> abs(2455017.0 - calculate_julian_day(Time2)) < TOL
True
# Sep 20, 2009, 12:00 UT1
>>> Time3 = dt.datetime(2009, 9, 20, 12, 0, 0).timetuple()
>>> abs(2455095.0 - calculate_julian_day(Time3)) < TOL
True
# Dec 25, 2010, 12:00 UT1
>>> Time4 = dt.datetime(2010, 12, 25, 12, 0, 0).timetuple()
>>> abs(2455556.0 - calculate_julian_day(Time4)) < TOL
True
'''
pass
def testJulianCenturies():
# Make sure that we correctly generate Julian dates. Standard values were obtained from the USNO web site. http://www.usno.navy.mil/USNO/astronomical-applications/data-services/jul-date
'''
>>> import time
>>> import datetime as dt
>>> import calendar
>>> from src.utils.TimeUtil import julian_centuries
# Jan 1, 2009, 12:00 UT1
>>> Time1 = dt.datetime(2009, 1, 1, 12, 0, 0).timetuple()
>>> abs(0.09002 - julian_centuries(Time1)) < TOL
True
# Jul 4, 2009, 12:00 UT1
>>> Time2 = dt.datetime(2009, 7, 4, 12, 0, 0).timetuple()
>>> abs(0.09506 - julian_centuries(Time2)) < TOL
True
# Sep 20, 2009, 12:00 UT1
>>> Time3 = dt.datetime(2009, 9, 20, 12, 0, 0).timetuple()
>>> abs(0.09719 - julian_centuries(Time3)) < TOL
True
# Dec 25, 2010, 12:00 UT1
>>> Time4 = dt.datetime(2010, 12, 25, 12, 0, 0).timetuple()
>>> abs(0.10982 - julian_centuries(Time4)) < TOL
True
'''
pass
def testMeanSiderealTime():
# Verify that we are calculating the correct local mean sidereal time.
'''
>>> import time
>>> import datetime as dt
>>> import calendar
>>> from src.utils.TimeUtil import mean_sidereal_time
# Longitude of selected cities
>>> pit = -79.97 # W 79 58'12.0"
>>> lon = -0.13 # W 00 07'41.0"
>>> tok = 139.77 # E139 46'00.0"
# A couple of select dates:
# Jan 1, 2009, 12:00 UT1
>>> Time1 = dt.datetime(2009, 1, 1, 12, 0, 0).timetuple()
>>> abs((13.42 * HOURS_TO_DEGREES) - mean_sidereal_time(Time1, pit)) < LMST_TOL
True
>>> abs((18.74 * HOURS_TO_DEGREES) - mean_sidereal_time(Time1, lon)) < LMST_TOL
True
>>> abs((4.07 * HOURS_TO_DEGREES) - mean_sidereal_time(Time1, tok)) < LMST_TOL
True
# Sep 20, 2009, 12:00 UT1
>>> Time2 = dt.datetime(2009, 9, 20, 12, 0, 0).timetuple()
>>> abs((6.64 * HOURS_TO_DEGREES) - mean_sidereal_time(Time2, pit)) < LMST_TOL
True
>>> abs((11.96 * HOURS_TO_DEGREES) - mean_sidereal_time(Time2, lon)) < LMST_TOL
True
>>> abs((21.29 * HOURS_TO_DEGREES) - mean_sidereal_time(Time2, tok)) < LMST_TOL
True
# Dec 25, 2010, 12:00 UT1
>>> Time3 = dt.datetime(2010, 12, 25, 12, 0, 0).timetuple()
>>> abs((12.92815 * HOURS_TO_DEGREES) - mean_sidereal_time(Time3, pit)) < LMST_TOL
True
>>> abs((18.25 * HOURS_TO_DEGREES) - mean_sidereal_time(Time3, lon)) < LMST_TOL
True
>>> abs((3.58 * HOURS_TO_DEGREES) - mean_sidereal_time(Time3, tok)) < LMST_TOL
True
'''
pass
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,520
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/utils/Geometry.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Kevin Serafini, Brent Bryan, Dominic Widdows, John Taylor
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-17
@author: Neil Borle
'''
import math
from src.units.GeocentricCoordinates import GeocentricCoordinates
from src.units.Matrix33 import Matrix33
from src.units.Vector3 import Vector3
from TimeUtil import mean_sidereal_time
def degrees_to_radians(val):
'''
Convert degrees to radians
'''
return val * (math.pi / 180.0)
def radians_to_degrees(val):
'''
Convert radians to degrees
'''
return val * (180.0 / math.pi)
def abs_floor(x):
'''
returns Integer value
'''
if x >= 0.0:
return math.floor(x)
else:
return math.ceil(x)
def mod_2_pi(x):
'''
Returns the modulo the given value by 2\pi. Returns an angle in the range 0
to 2\pi radians.
'''
factor = x / (2 * math.pi)
result = (2 * math.pi) * (factor - abs_floor(factor))
if result < 0.0:
return (2 * math.pi) + result
else:
return result
def scalar_product(v1, v2):
'''
given two vector3 objects perform the scalar product
'''
return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z)
def vector_product(v1, v2):
'''
given two vector3 objects perform the vector product
'''
term1 = v1.y * v2.z - v1.z * v2.y
term2 = -v1.x * v2.z + v1.z * v2.x
term3 = v1.x * v2.y - v1.y * v2.x
return Vector3(term1, term2, term3)
def scale_vector(v3, scale):
'''
return new scaled vector
'''
return Vector3(scale * v3.x, scale * v3.y, scale * v3.z)
def add_vectors(v1, v2):
'''
return a new vector whos coordinates are the sum of the
two input vectors
'''
return Vector3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z)
def cosine_similarity(v1, v2):
'''
perform cosine similarity
'''
demoninator = math.sqrt(scalar_product(v1, v1) * scalar_product(v2, v2))
return scalar_product(v1, v2) / demoninator
def getXYZ(ra_dec):
'''
Convert ra and dec to x,y,z where the point is place on the unit sphere.
'''
ra_radians = degrees_to_radians(ra_dec.ra)
dec_radians = degrees_to_radians(ra_dec.dec)
x = math.cos(ra_radians) * math.cos(dec_radians)
y = math.sin(ra_radians) * math.cos(dec_radians)
z = math.sin(dec_radians)
return GeocentricCoordinates(x, y, z)
def calculate_RADec_of_zenith(date_utc, lat_long_location):
'''
compute coordinates of the zenith
date_utc must be a time.gmtime() struct
'''
my_ra = mean_sidereal_time(date_utc, lat_long_location.longitude)
my_dec = lat_long_location.latitude
return my_ra, my_dec
def matrix_multiply(m1, m2):
'''
multiply m1 * m2 and return a new matrix
'''
return Matrix33(m1.xx*m2.xx + m1.xy*m2.yx + m1.xz*m2.zx,
m1.xx*m2.xy + m1.xy*m2.yy + m1.xz*m2.zy,
m1.xx*m2.xz + m1.xy*m2.yz + m1.xz*m2.zz,
m1.yx*m2.xx + m1.yy*m2.yx + m1.yz*m2.zx,
m1.yx*m2.xy + m1.yy*m2.yy + m1.yz*m2.zy,
m1.yx*m2.xz + m1.yy*m2.yz + m1.yz*m2.zz,
m1.zx*m2.xx + m1.zy*m2.yx + m1.zz*m2.zx,
m1.zx*m2.xy + m1.zy*m2.yy + m1.zz*m2.zy,
m1.zx*m2.xz + m1.zy*m2.yz + m1.zz*m2.zz)
def matrix_vector_multiply(m, v):
'''
multiply m * v where m is a matrix and v is a vector
'''
return Vector3(m.xx*v.x + m.xy*v.y + m.xz*v.z,
m.yx*v.x + m.yy*v.y + m.yz*v.z,
m.zx*v.x + m.zy*v.y + m.zz*v.z)
def calculate_rotation_matrix(degrees, axis):
'''
Calculate the rotation matrix for a certain number of degrees about the
give axis. Vector3 axis input must be a unit vector.
'''
cos_d = math.cos(degrees_to_radians(degrees))
sin_d = math.sin(degrees_to_radians(degrees))
one_minus_cos_d = 1.0 - cos_d
xs = axis.x * sin_d
ys = axis.y * sin_d
zs = axis.z * sin_d
xm = axis.x * one_minus_cos_d;
ym = axis.y * one_minus_cos_d;
zm = axis.z * one_minus_cos_d;
xym = axis.x * ym;
yzm = axis.y * zm;
zxm = axis.z * xm;
return Matrix33(axis.x * xm + cos_d, xym + zs, zxm - ys,
xym - zs, axis.y * ym + cos_d, yzm + xs,
zxm + ys, yzm - xs, axis.z * zm + cos_d)
if __name__ == "__main__":
'''
For debugging purposes
'''
import time
import units.LatLong as LL
from units.RaDec import RaDec
M = calculate_rotation_matrix(90, Vector3(1, 0, 0))
print M.xx, M.xy, M.xz
print M.yx, M.yy, M.yz
print M.zx, M.zy, M.zz
ra, dec = calculate_RADec_of_zenith(time.gmtime(), LL.LatLong(20, 16))
radec = RaDec(ra, dec)
print radec.ra, radec.dec
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,521
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/renderer/PointObjectManager.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not state
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-25
@author: Neil Borle
'''
import math
from src.units.Vector3 import Vector3
from RendererObjectManager import RendererObjectManager
from src.rendererUtil.SkyRegionMap import SkyRegionMap
from src.rendererUtil.IndexBuffer import IndexBuffer
from src.rendererUtil.VertexBuffer import VertexBuffer
from src.rendererUtil.NightVisionColorBuffer import NightVisionBuffer
from src.rendererUtil.TextCoordBuffer import TextCoordBuffer
from src.rendererUtil.TextureManager import TextureManager
from src.utils.VectorUtil import normalized, cross_product
from src.utils.DebugOptions import Debug
DRAWABLE_STARS_TEXTURE = int("0x7f02005d", 0)
class PointObjectManager(RendererObjectManager):
'''
Handles the management of points in the sky, points
are loaded into buffers to be rendered.
'''
class RegionData(object):
'''
classdocs
'''
def __init__(self):
'''
constructor
'''
self.sources = []
self.vertex_buffer = VertexBuffer(0, True)
self.index_buffer = IndexBuffer(0, True)
self.text_coord_buffer = TextCoordBuffer(0, True)
self.color_buffer = NightVisionBuffer(0, True)
# Following values chosen by the java authors
NUM_STARS_IN_TEXTURE = 2
MINIMUM_NUM_POINTS_FOR_REGIONS = 200
COMPUTE_REGIONS = True
texture_ref = None
def update_objects(self, points, update_type):
#only_update_points = True
# We only care about updates to positions, ignore any other updates.
if self.update_type.Reset in update_type:
#only_update_points = False
pass
elif self.update_type.UpdatePositions in update_type:
# Sanity check: make sure the number of points is unchanged.
if len(points) != self.num_points:
return
else:
return
self.num_points = len(points)
self.sky_regions.clear()
if Debug.ALLREGIONS == "YES": self.COMPUTE_REGIONS = False
region = SkyRegionMap.CATCHALL_REGION_ID
if self.COMPUTE_REGIONS:
# Find the region for each point, and put it in a separate list
# for that region.
for point in points:
if len(points) < self.MINIMUM_NUM_POINTS_FOR_REGIONS:
region = SkyRegionMap.CATCHALL_REGION_ID
else:
region = self.sky_regions.get_object_region(point.geocentric_coords)
# self.sky_regions.get_region_data(region) is a RegionData instance
data_for_region = self.sky_regions.get_region_data(region)
data_for_region.sources.append(point)
else:
self.sky_regions.get_region_data(region).sources = points
# Generate the resources for all of the regions.
for data in self.sky_regions.region_data.values():
num_vertices = 4 * len(data.sources)
num_indices = 6 * len(data.sources)
data.vertex_buffer.reset(num_vertices)
data.color_buffer.reset(num_vertices)
data.text_coord_buffer.reset(num_vertices)
data.index_buffer.reset(num_indices)
up = Vector3(0, 1, 0)
# By inspecting the perspective projection matrix, you can show that,
# to have a quad at the center of the screen to be of size k by k
# pixels, the width and height are both:
# k * tan(fovy / 2) / screenHeight
# This is not difficult to derive. Look at the transformation matrix
# in SkyRenderer if you're interested in seeing why this is true.
# I'm arbitrarily deciding that at a 60 degree field of view, and 480
# pixels high, a size of 1 means "1 pixel," so calculate size_factor
# based on this. These numbers mostly come from the fact that that's
# what I think looks reasonable.
fovy_in_radians = 60 * math.pi / 180.0
size_factor = math.tan(fovy_in_radians * 0.5) / 480
bottom_left_pos = Vector3(0, 0, 0)
top_left_pos = Vector3(0, 0, 0)
bottom_right_pos = Vector3(0, 0, 0)
top_right_pos = Vector3(0, 0, 0)
su = Vector3(0, 0, 0)
sv = Vector3(0, 0, 0)
index = 0
star_width_in_texels = 1.0 / self.NUM_STARS_IN_TEXTURE
for p_source in data.sources:
color = 0xFF000000 | int(p_source.color) # Force alpha to 0xff
if Debug.COLOR == "WHITE ONLY":
color = 0xFFFFFFFF
bottom_left = index
top_left = index + 1
bottom_right = index + 2
top_right = index + 3
index += 4
# First triangle
data.index_buffer.add_index(bottom_left)
data.index_buffer.add_index(top_left)
data.index_buffer.add_index(bottom_right)
# Second triangle
data.index_buffer.add_index(top_right);
data.index_buffer.add_index(bottom_right);
data.index_buffer.add_index(top_left);
# PointSource.getPointShape().getImageIndex(); is always 0
star_index = 0
tex_offset_u = star_width_in_texels * star_index
data.text_coord_buffer.add_text_coord(tex_offset_u, 1);
data.text_coord_buffer.add_text_coord(tex_offset_u, 0);
data.text_coord_buffer.add_text_coord(tex_offset_u + star_width_in_texels, 1);
data.text_coord_buffer.add_text_coord(tex_offset_u + star_width_in_texels, 0);
pos = p_source.geocentric_coords
u = normalized(cross_product(pos, up))
v = cross_product(u, pos)
s = p_source.size * size_factor
su.assign(s*u.x, s*u.y, s*u.z)
sv.assign(s*v.x, s*v.y, s*v.z)
bottom_left_pos.assign(pos.x - su.x - sv.x, pos.y - su.y - sv.y, pos.z - su.z - sv.z)
top_left_pos.assign(pos.x - su.x + sv.x, pos.y - su.y + sv.y, pos.z - su.z + sv.z)
bottom_right_pos.assign(pos.x + su.x - sv.x, pos.y + su.y - sv.y, pos.z + su.z - sv.z)
top_right_pos.assign(pos.x + su.x + sv.x, pos.y + su.y + sv.y, pos.z + su.z + sv.z)
# Add the vertices
data.vertex_buffer.add_point(bottom_left_pos)
data.color_buffer.add_color(color)
data.vertex_buffer.add_point(top_left_pos)
data.color_buffer.add_color(color)
data.vertex_buffer.add_point(bottom_right_pos)
data.color_buffer.add_color(color)
data.vertex_buffer.add_point(top_right_pos)
data.color_buffer.add_color(color)
data.sources = None
def reload(self, gl, bool_full_reload):
TM = TextureManager()
self.texture_ref = TM.get_texture_from_resource(gl, DRAWABLE_STARS_TEXTURE)
for data in self.sky_regions.region_data.values():
data.vertex_buffer.reload()
data.color_buffer.reload()
data.text_coord_buffer.reload()
data.index_buffer.reload()
def draw_internal(self, gl):
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
gl.glEnableClientState(gl.GL_COLOR_ARRAY)
gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY)
gl.glEnable(gl.GL_CULL_FACE)
gl.glFrontFace(gl.GL_CW)
gl.glCullFace(gl.GL_BACK)
gl.glEnable(gl.GL_ALPHA_TEST)
gl.glAlphaFunc(gl.GL_GREATER, 0.5)
gl.glEnable(gl.GL_TEXTURE_2D)
self.texture_ref.bind(gl)
gl.glTexEnvf(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_MODULATE)
# Render all of the active sky regions.
active_regions = self.render_state.active_sky_region_set
active_region_data = self.sky_regions.get_data_for_active_regions(active_regions)
for data in active_region_data:
if data.vertex_buffer.num_vertices == 0:
continue
data.vertex_buffer.set(gl)
data.color_buffer.set(gl, self.render_state.night_vision_mode)
data.text_coord_buffer.set(gl)
data.index_buffer.draw(gl, gl.GL_TRIANGLES)
gl.glDisableClientState(gl.GL_TEXTURE_COORD_ARRAY)
gl.glDisable(gl.GL_TEXTURE_2D)
gl.glDisable(gl.GL_ALPHA_TEST)
def __init__(self, new_layer, new_texture_manager):
'''
constructor
TODO: change inputs to not be default
'''
def construct_method():
return PointObjectManager.RegionData()
RendererObjectManager.__init__(self, new_layer, new_texture_manager)
self.sky_regions = SkyRegionMap()
self.sky_regions.region_data_factory = \
self.sky_regions.RegionDataFactory(construct_method)
self.num_points = 0
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,522
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/layers/NewConstellationsLayer.py
|
'''
// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor, Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-29
@author: Neil Borle
'''
from FileBasedLayer import FileBasedLayer
class NewConstellationsLayer(FileBasedLayer):
'''
Display constellations in the renderer
'''
def get_layer_id(self):
return -101
def get_layer_name_id(self):
raise NotImplementedError("not implemented yet")
def get_preference_id(self):
return "source_provider.1"
def __init__(self):
'''
Constructor
'''
FileBasedLayer.__init__(self, "assets/constellations.binary")
if __name__ == "__main__":
'''
Do nothing
'''
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,523
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/utils/VectorUtil.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-20
@author: Neil Borle
'''
import math
from src.units.Vector3 import Vector3
def zero():
return Vector3(0, 0, 0)
def dot_product(p1, p2):
return float(p1.x * p2.x + p1.y * p2.y + p1.z * p2.z)
def cross_product(p1, p2):
return Vector3(p1.y * p2.z - p1.z * p2.y,
-p1.x * p2.z + p1.z * p2.x,
p1.x * p2.y - p1.y * p2.x)
def angle_between(p1, p2):
return math.acos(dot_product(p1, p2) / float((length(p1) * length(p2))))
def length(v):
return math.sqrt(dot_product(v, v));
def normalized(v):
length_of_V = length(v);
if length_of_V < 0.000001:
return zero()
else:
return scale(v, (1.0 / float(length_of_V)))
def project(v, onto):
return scale(float(dot_product(v, onto) / length(onto)), onto)
def project_onto_unit(v, onto):
return scale(dot_product(v, onto), onto)
def project_onto_plane(v, unit_normal):
return difference(v, project_onto_unit(v, unit_normal))
def negate(v):
return Vector3(-v.x, -v.y, -v.z)
def sum_vectors(v1, v2):
return Vector3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z)
def difference(v1, v2):
'''
subtract v2 from v1
'''
return sum_vectors(v1, negate(v2))
def scale(v, factor):
return Vector3(v.x * factor, v.y * factor, v.z * factor)
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,524
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/control/ZoomController.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-09
@author: Neil Borle
'''
from Controller import Controller
class ZoomController(Controller):
'''
This controller is responsible for setting the
zoom factor for the night sky.
'''
ZOOM_FACTOR = pow(1.5, 0.0625)
MAX_ZOOM_OUT = 90.0
def zoom_in(self):
'''
Decreases the field of view by ZOOM_FACTOR
'''
self.zoom_by(1.0 / float(self.ZOOM_FACTOR))
def zoom_out(self):
'''
Increases the field of view by ZOOM_FACTOR
'''
self.zoom_by(self.ZOOM_FACTOR)
def __set_field_of_view(self, zoom_degrees):
if not self.enabled:
return
self.model.field_of_view = zoom_degrees
def start(self):
pass
def stop(self):
pass
def zoom_by(self, ratio):
zoom_degrees = self.model.field_of_view
zoom_degrees = min(zoom_degrees * ratio, self.MAX_ZOOM_OUT)
self.__set_field_of_view(zoom_degrees)
def __init__(self):
'''
Constructor
'''
Controller.__init__(self)
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,525
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/control/ControllerGroup.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-09
@author: Neil Borle
'''
from Controller import Controller
from LocationController import LocationController
from ManualOrientationController import ManualOrientationController
from ZoomController import ZoomController
def create_controller_group(prefs):
'''
Creates an instance of a controller group and provides it
with the necessary controllers to allow for manipulation
of the appearance of the sky. This class is both a factory
and a facade for the underlying controllers
'''
group = ControllerGroup()
group.add_controller(LocationController(prefs))
# group.sensorOrientationController = new SensorOrientationController(context);
# group.addController(group.sensorOrientationController);
group.manual_direction_controller = ManualOrientationController()
group.add_controller(group.manual_direction_controller)
group.zoom_controller = ZoomController()
group.add_controller(group.zoom_controller)
# group.teleportingController = new TeleportingController();
# group.addController(group.teleportingController);
group.set_auto_mode(True)
return group
class ControllerGroup(Controller):
'''
Class which holds all the controllers and provides
methods for using the controllers. This way there
is one collection of controllers that can be used
centrally.
'''
def set_enabled(self, enabled_bool):
'''
enables or disables all controllers
'''
for controller in self.controllers:
controller.enabled = enabled_bool
def set_model(self, m_model):
'''
Provides all controllers with access to the model.
'''
for controller in self.controllers:
controller.model = m_model
self.model = m_model
self.model.auto_update_pointing = self.using_auto_mode
#self.model.set_clock(transitioning_clock)
def go_time_travel(self, date):
'''
Switches to time-travel model and start with the supplied time.
'''
raise NotImplementedError("not finished time stuff")
#transitioningClock.goTimeTravel(d);
def get_current_speed_tag(self):
'''
Gets the id of the string used to display the current speed of time travel.
'''
#return timeTravelClock.getCurrentSpeedTag();
raise NotImplementedError("not finished time stuff")
def use_real_time(self):
'''
Sets the model back to using real time.
'''
#transitioningClock.returnToRealTime();
raise NotImplementedError("not finished time stuff")
def accelerate_time_travel(self):
'''
Increases the rate of time travel into the future (or decreases the rate of
time travel into the past) if in time travel mode.
'''
#timeTravelClock.accelerateTimeTravel();
raise NotImplementedError("not finished time stuff")
def decelerate_time_travel(self):
'''
Decreases the rate of time travel into the future (or increases the rate of
time travel into the past) if in time travel mode.
'''
#timeTravelClock.decelerateTimeTravel();
raise NotImplementedError("not finished time stuff")
def pause_time(self):
'''
Pauses time, if in time travel mode.
'''
#timeTravelClock.pauseTime();
raise NotImplementedError("not finished time stuff")
def set_auto_mode(self, enabled_bool):
'''
Sets auto mode (true) or manual mode (false).
'''
self.manual_direction_controller.enabled = (not enabled_bool)
#sensorOrientationController.setEnabled(enabled_bool)
if self.model != None:
self.model.auto_update_pointing = enabled_bool
self.using_auto_mode = enabled_bool
def start(self):
for controller in self.controllers:
controller.start()
def stop(self):
for controller in self.controllers:
controller.stop()
def change_right_left(self, radians):
'''
Moves the pointing right and left.
radians is the angular change in the pointing in radians (only
accurate in the limit as radians tends to 0.)
'''
self.manual_direction_controller.change_right_left(radians)
def change_up_down(self, radians):
'''
Moves the pointing up and down.
radians is the angular change in the pointing in radians (only
accurate in the limit as radians tends to 0.)
'''
self.manual_direction_controller.change_up_down(radians)
def rotate(self, degrees):
'''
Rotates the view about the current center point.
'''
self.manual_direction_controller.rotate(degrees)
def zoom_in(self):
'''
Zooms the user in.
'''
self.zoom_controller.zoom_in()
def zoom_out(self):
'''
Zooms the user out.
'''
self.zoom_controller.zoom_out()
def teleport(self, target):
'''
Sends the astronomer's pointing to the new target.
takes the target the destination
'''
#teleportingController.teleport(target)
raise NotImplementedError("Not done yet")
def add_controller(self, controller):
'''
Adds a new controller to this group.
'''
self.controllers.append(controller)
def zoom_by(self, ratio):
'''
Zoomz by a given ratio
'''
self.zoom_controller.zoom_by(ratio)
def __init__(self):
'''
Constructor
'''
Controller.__init__(self)
self.controllers = []
self.zoom_controller = None
self.manual_direction_controller = None
self.sensor_orientation_controller = None
#self.time_travel_clock = TimeTravelClock();
#self.transitioning_clock = TransitioningCompositeClock(timeTravelClock, RealClock())
self.teleporting_controller = None
self.using_auto_mode = True
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,526
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/layers/SourceLayer.py
|
'''
// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-22
@author: Neil Borle
'''
from Layer import Layer
from src.renderer.RendererObjectManager import RendererObjectManager
from src.search.SearchResult import SearchResult
class SourceLayer(Layer):
'''
An extention of Layer which has additional methods.
'''
class SourceUpdateClosure(object):
'''
Update closure that allows sources to be
updated for a given layer.
'''
source_layer = None
def run(self):
self.source_layer.refresh_sources()
def __init__(self, layer):
'''
constructor
'''
self.source_layer = layer
search_index = {}
# prefix_store = prefixstore class
def initialize(self):
self.astro_sources = []
self.initialize_astro_sources(self.astro_sources)
for astro_source in self.astro_sources:
source = astro_source.initialize()
self.image_sources += source.get_images()
self.line_sources += source.get_lines()
self.point_sources += source.get_points()
self.text_sources += source.get_labels()
if source.names != []:
gc_search_loaction = source.get_geo_coords()
for name in source.names:
self.search_index[str(name).lower()] = \
SearchResult(name, gc_search_loaction)
# prefix_store.add(str(name).lower())
self.update_layer_for_controller_change()
def update_layer_for_controller_change(self):
r = RendererObjectManager(0, None)
self.refresh_sources(set([r.update_type.Reset]))
if self.should_update:
if self.closure == None:
self.closure = self.SourceUpdateClosure(self)
self.add_update_closure(self.closure)
def refresh_sources(self, update_types=set()): # this needs to be synchronized!
#for astro_source in self.astro_sources:
# update_types = set(update_types + astro_source.update())
if len(update_types) != 0:
self.redraw(update_types)
def redraw(self, update_types=set()):
if len(update_types) == 0:
r = RendererObjectManager(0, None)
self.refresh_sources(set([r.update_type.Reset]))
else:
Layer.redraw(self, self.point_sources, self.line_sources, \
self.text_sources, self.image_sources, update_types)
def search_by_object_name(self):
raise NotImplementedError("haven't done searching yet")
def get_object_names_matching_prefix(self):
raise NotImplementedError("haven't done searching yet")
def __init__(self, boolean):
'''
Constructor
'''
Layer.__init__(self)
self.closure = None
self.should_update = boolean
self.text_sources = []
self.image_sources = []
self.point_sources = []
self.line_sources = []
self.astro_sources = []
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,527
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/source/ImageSource.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-16
@author: Neil Borle
'''
from PySide.QtGui import QPixmap
from Source import Source
from src.units.Vector3 import Vector3
from src.utils.Colors import colors
from src.utils.VectorUtil import negate, normalized, cross_product
class ImageSource(Source):
'''
A celestial object represented by an image, such as a planet or a galaxy.
// These two vectors, along with Source.xyz, determine the position of the
// image object. The corners are as follows
//
// xyz-u+v xyz+u+v
// +---------+ ^
// | xyz | | v
// | . | .
// | |
// +---------+
// xyz-u-v xyz+u-v
//
// .--->
// u
'''
image_scale = 1
def get_horizontal_corner(self):
return [self.ux, self.uy, self.uz]
def get_verical_corner(self):
return [self.vx, self.vy, self.vz]
def set_up_vector(self, up_v):
p = self.geocentric_coords
u = negate(normalized(cross_product(p, up_v)))
v = cross_product(u, p)
v.scale(self.image_scale)
u.scale(self.image_scale)
self.ux = u.x
self.uy = u.y
self.uz = u.z
self.vx = v.x
self.vy = v.y
self.vz = v.z
def set_image_id(self, input_id):
# hack bool to prevent blank meteors from rendering
self.is_blank = True if input_id == 'blank' else False
url = "assets/drawable/" + input_id + ".png"
self.pixmap_image = QPixmap()
if not self.pixmap_image.load(url):
raise RuntimeError("Could not load image resource")
def __init__(self, geo_coord, new_id, up_v=Vector3(0.0, 1.0, 0.0), im_scale=1):
'''
Constructor
'''
Source.__init__(self, colors.WHITE, geo_coord)
self.is_blank = False
self.requires_blending = False
self.pixmap_image = None
self.image_scale = im_scale
self.set_up_vector(up_v)
self.set_image_id(new_id)
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,528
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/rendererUtil/SkyRegionMap.py
|
'''
// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: James Powell
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-24
@author: Neil Borle
'''
import math
from src.utils.VectorUtil import dot_product
from src.utils.Geometry import degrees_to_radians
from src.units.GeocentricCoordinates import GeocentricCoordinates
class ActiveRegionData(object):
'''
This stores data that we only want to compute once per frame about
which regions are on the screen. We don't want to compute these
regions for every manager separately, since we can share them
between managers.
'''
def region_is_active(self, region_num, coverage_angle):
'''
Tests to see if a particular region is active.
'''
return self.region_center_dot_products[region_num] > \
math.cos(coverage_angle + self.screen_angle)
def __init__(self, dot_products, angles, active_regions):
'''
constructor
'''
self.region_center_dot_products = dot_products
self.screen_angle = angles #default at 45 degrees
self.active_standard_regions = active_regions
class SkyRegionMap(object):
'''
This is a utility class which divides the sky into a fixed set of regions
and maps each of the regions into a generic data object which contains the
data for rendering that region of the sky. For a given frame, this class
will determine which regions are on-screen and which are totally
off-screen, and will return only the on-screen ones (so we can avoid paying
the cost of rendering the ones that aren't on-screen). There should
typically be one of these objects per type of object being rendered: for
example, points and labels will each have their own SkyRegionMap.
Each region consists of a center (a point on the unit sphere) and an angle,
and should contain every object on the unit sphere within the specified
angle from the region's center.
This also allows for a special "catchall" region which is always rendered
and may contain objects from anywhere on the unit sphere. This is useful
because, for small layers, it is cheaper to just render the
whole layer than to break it up into smaller pieces.
The center of all regions is fixed for computational reasons. This allows
us to find the distance between each region and the current look direction
once per frame and share that between all SkyRegionMaps. For most types
of objects, they can also use regions with the same radius, which means
that they are the same exact part of the unit sphere. For these we can
compute the regions which are on screen ("active regions") once per frame,
and share that between all SkyRegionMaps. These are called "standard
regions", as opposed to "non-standard regions", where the region's angle
may be greater than that of the standard region. Non-standard regions
are necessary for some types of objects, such as lines, which may not be
fully contained within any standard region. For lines, we can find the
region center which is closest to fully containing the line, and simply
increase the angle until it does fully contain it.
'''
class ObjectRegionData(object):
'''
Data representing an individual object's position in a region.
We care about the region itself for obvious reasons, but we care about
the dot product with the center because it is a measure of how
close it is to the center of a region.
'''
def __init__(self):
'''
constructor
'''
self.region = SkyRegionMap().CATCHALL_REGION_ID
self.region_center_dot_product = -1
class RegionDataFactory(object):
'''
Factory class where the construct method is set during
instantiation to produce RegionData objects
'''
def construct(self):
raise Exception("This method must be overwritten")
def __init__(self, construct_method):
'''
constructor
'''
self.construct = construct_method
CATCHALL_REGION_ID = -1
REGION_COVERAGE_ANGLE_IN_RADIANS = 0.396023592
REGION_CENTERS32 = [ \
GeocentricCoordinates(-0.850649066269, 0.525733930059, -0.000001851469),
GeocentricCoordinates(-0.934170971625, 0.000004098751, -0.356825719588),
GeocentricCoordinates(0.577349931933, 0.577346773818, 0.577354100533),
GeocentricCoordinates(0.577350600623, -0.577350601554, -0.577349603176),
GeocentricCoordinates(-0.577354427427, -0.577349954285, 0.577346424572),
GeocentricCoordinates(-0.577346098609, 0.577353779227, -0.577350928448),
GeocentricCoordinates(-0.577349943109, -0.577346729115, -0.577354134060),
GeocentricCoordinates(-0.577350598760, 0.577350586653, 0.577349620871),
GeocentricCoordinates(0.577354458161, 0.577349932864, -0.577346415259),
GeocentricCoordinates(0.577346091159, -0.577353793196, 0.577350921929),
GeocentricCoordinates(-0.850652559660, -0.525728277862, -0.000004770234),
GeocentricCoordinates(-0.934173742309, 0.000002107583, 0.356818466447),
GeocentricCoordinates(0.525734450668, 0.000000594184, -0.850648744032),
GeocentricCoordinates(0.000002468936, -0.356819496490, -0.934173349291),
GeocentricCoordinates(0.525727798231, -0.000004087575, 0.850652855821),
GeocentricCoordinates(-0.000002444722, 0.356819517910, 0.934173340909),
GeocentricCoordinates(-0.525727787986, 0.000004113652, -0.850652862340),
GeocentricCoordinates(0.000004847534, 0.356824675575, -0.934171371162),
GeocentricCoordinates(-0.000004885718, -0.850652267225, 0.525728750974),
GeocentricCoordinates(-0.356825215742, -0.934171164408, -0.000003995374),
GeocentricCoordinates(0.000000767410, 0.850649364293, 0.525733447634),
GeocentricCoordinates(0.356825180352, 0.934171177447, 0.000003952533),
GeocentricCoordinates(-0.000000790693, -0.850649344735, -0.525733478367),
GeocentricCoordinates(0.356818960048, -0.934173554182, -0.000001195818),
GeocentricCoordinates(0.850652555004, 0.525728284381, 0.000004773028),
GeocentricCoordinates(0.934170960449, -0.000004090369, 0.356825748459),
GeocentricCoordinates(-0.525734410621, -0.000000609085, 0.850648769177),
GeocentricCoordinates(-0.000004815869, -0.356824668124, 0.934171373956),
GeocentricCoordinates(0.000004877336, 0.850652255118, -0.525728769600),
GeocentricCoordinates(-0.356819001026, 0.934173538350, 0.000001183711),
GeocentricCoordinates(0.850649050437, -0.525733955204, 0.000001879409),
GeocentricCoordinates(0.934173759073, -0.000002136454, -0.356818422675)]
def get_active_regions(self, look_dir, fovy_in_degrees, aspect):
'''
Computes the data necessary to determine which regions on the screen
are active. This should be produced once per frame and passed to
the getDataForActiveRegions method of all SkyRegionMap objects to
get the active regions for each map.
lookDir The direction the user is currently facing.
fovyInDegrees The field of view (in degrees).
aspect The aspect ratio of the screen.
Returns a data object containing data for quickly determining the
active regions.
'''
half_fovy = degrees_to_radians(fovy_in_degrees) / 2.0
screen_angle = math.asin(math.sin(half_fovy) * math.sqrt(1 + aspect * aspect))
angle_threshold = screen_angle + self.REGION_COVERAGE_ANGLE_IN_RADIANS
dot_product_threshold = math.cos(angle_threshold)
region_center_dot_products = [0] * len(self.REGION_CENTERS32)
active_standard_regions = []
i = 0
for i in range(len(self.REGION_CENTERS32)):
d_product = dot_product(look_dir, self.REGION_CENTERS32[i])
region_center_dot_products[i] = d_product
if d_product > dot_product_threshold:
active_standard_regions.append(i)
return ActiveRegionData(region_center_dot_products, \
screen_angle, active_standard_regions)
def get_object_region(self, gc_coords):
'''
returns to region that contains the coordinate
'''
return self.get_object_region_data(gc_coords).region
def get_object_region_data(self, gc_coords):
'''
returns the region a point belongs in, as well as the dot product of the
region center and the position. The latter is a measure of how close it
is to the center of the region (1 being a perfect match).
'''
data = self.ObjectRegionData()
i = 0
for i in range(len(self.REGION_CENTERS32)):
d_product = dot_product(self.REGION_CENTERS32[i], gc_coords)
if d_product > data.region_center_dot_product:
data.region_center_dot_product = d_product
data.region = i
return data
def clear(self):
self.region_data.clear()
self.region_coverage_angles = None
def set_region_data(self, r_id, data):
'''
sets generic RenderingRegionData as specified by ObjectManager
which instantiated this class
'''
self.region_data[r_id] = data
def get_region_coverage_angle(self, r_id):
if self.region_coverage_angles == None:
return self.REGION_COVERAGE_ANGLE_IN_RADIANS
else:
return self.region_coverage_angles[r_id]
def set_region_coverage_angle(self, r_id, angle_in_radians):
'''
Sets the coverage angle for a sky region. Needed for non-point objects.
'''
if self.region_coverage_angles == None:
self.region_coverage_angles = [self.REGION_COVERAGE_ANGLE_IN_RADIANS] * \
len(self.REGION_CENTERS32)
self.region_coverage_angles[r_id] = angle_in_radians
def get_region_data(self, r_id):
'''
Lookup the region data corresponding to a region ID. If none exists,
and a region data constructor has been set (see setRegionDataConstructor),
that will be used to create a new region - otherwise, this will return
None. This can be useful while building or updating a region, but to get
the region data when rendering a frame, use getDataForActiveRegions().
'''
data = None
if r_id in self.region_data.keys():
data = self.region_data[r_id]
elif self.region_data_factory != None:
data = self.region_data_factory.construct()
self.set_region_data(r_id, data)
return data
def get_data_for_active_regions(self, active_region_data):
'''
returns the rendering data for the active regions. When using a
SkyRegionMap for rendering, this is the function will return the
data for the regions you need to render.
'''
data = []
if self.CATCHALL_REGION_ID in self.region_data.keys():
data.append(self.region_data[self.CATCHALL_REGION_ID])
if self.region_coverage_angles == None:
for region in active_region_data.active_standard_regions:
if region in self.region_data.keys():
data.append(self.region_data[region])
return data
else:
for i in range(len(self.REGION_CENTERS32)):
if active_region_data.region_is_active(i, self.region_coverage_angles[i])\
and i in self.region_data.keys():
data.append(self.region_data[i])
return data
def __init__(self):
'''
Constructor
'''
self.region_coverage_angles = None
self.region_data = {}
self.region_data_factory = None
if __name__ == "__main__":
'''
For debugging purposes
Ready for testing
'''
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,529
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/units/LatLong.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-17
@author: Neil Borle
'''
import math
import GeocentricCoordinates as GC
from src.utils.Geometry import cosine_similarity, radians_to_degrees
class LatLong(object):
'''
Basic class that contains a latitude and a longitude
'''
latitude = None
longitude = None
def distance_from(self, lat_long):
other_point = GC.get_instance(lat_long.longitude, lat_long.latitude)
this_point = GC.get_instance(self.longitude, self.latitude)
cos_Theta = cosine_similarity(this_point, other_point)
return radians_to_degrees(math.acos(cos_Theta))
def __init__(self, new_lat, new_long):
'''
Constructor
'''
self.latitude = new_lat
self.longitude = new_long
if __name__ == "__main__":
'''
for debugging purposes
'''
A = LatLong(20, 4)
B = LatLong(16, 9)
print A.distance_from(B)
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,530
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/renderer/LabelOverlayManager.py
|
'''
// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: James Powell
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-07-26
@author: Neil Borle
'''
from src.rendererUtil.LabelMaker import LabelMaker
from src.rendererUtil.IndexBuffer import IndexBuffer
from src.rendererUtil.VertexBuffer import VertexBuffer
class LabelOverlayManager(object):
'''
Manages rendering of which appears at fixed points on the screen, rather
than text which appears at fixed points in the world.
'''
class Label(LabelMaker.LabelData):
'''
Holds state on a single label
'''
def __init__(self, text, color, size):
'''
constructor
'''
LabelMaker.LabelData.__init__(self, text, color, size)
self.enabled = True
self.x, self.y = 0, 0
self.alpha = 1.0
def initialize(self, gl, render_state, labels, texture_manager):
self.labels = labels[:] # deep copy
self.texture = self.label_maker.initialize(gl, render_state, self.labels, texture_manager)
def release_textures(self, gl):
if self.texture != None:
self.texture.shutdown(gl)
self.texture = None
def draw(self, gl, screen_width, screen_height):
if self.texture == None or self.labels == []:
return
gl.glEnable(gl.GL_TEXTURE_2D)
self.texture.bind(gl)
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glTexEnvx(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE,
gl.GL_MODULATE)
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY)
gl.glDisableClientState(gl.GL_COLOR_ARRAY)
# Change to orthographic projection, where the units in model view space
# are the same as in screen space.
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glPushMatrix()
gl.glLoadIdentity()
gl.glOrthof(0, screen_width, 0, screen_height, -100, 100)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glPushMatrix()
for label in self.labels:
if label.enabled:
x = label.x - label.width_in_pixels / 2
y = label.y
gl.glLoadIdentity()
# Move the label to the correct offset.
gl.glTranslatef(x, y, 0.0)
# Scale the label to the correct size.
gl.glScalef(label.width_in_pixels, label.height_in_pixels, 0.0)
# Set the alpha for the label.
gl.glColor4f(1, 1, 1, label.getAlpha())
# Draw the label.
self.vertex_buffer.set(gl)
gl.glTexCoordPointer(2, gl.GL_FIXED, 0, label.tex_coords)
self.index_buffer.draw(gl, gl.GL_TRIANGLES)
# Restore the old matrices.
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glPopMatrix()
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glPopMatrix()
gl.glTexEnvf(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_REPLACE)
gl.glDisable(gl.GL_BLEND)
gl.glDisableClientState(gl.GL_TEXTURE_COORD_ARRAY)
gl.glDisable(gl.GL_TEXTURE_2D)
def __init__(self):
'''
Constructor
'''
self.labels = []
self.label_maker = LabelMaker(True)
self.texture = None
self.vertex_buffer = VertexBuffer(4, False)
self.index_buffer = IndexBuffer(6)
#private Paint mLabelPaint = new Paint();
#mLabelPaint.setAntiAlias(true);
self.vertex_buffer.add_point(0, 0, 0) # Bottom left
self.vertex_buffer.add_point(0, 1, 0) # Top left
self.vertex_buffer.add_point(1, 0, 0) # Bottom right
self.vertex_buffer.add_point(1, 1, 0) # Top right
# Triangle one: bottom left, top left, bottom right.
self.index_buffer.add_index(0)
self.index_buffer.add_index(1)
self.index_buffer.add_index(2)
# Triangle two: bottom right, top left, top right.
self.index_buffer.add_index(2)
self.index_buffer.add_index(1)
self.index_buffer.add_index(3)
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,531
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/renderer/PolyLineObjectManager.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-06
@author: Neil Borle
'''
import math
from RendererObjectManager import RendererObjectManager
from src.rendererUtil.VertexBuffer import VertexBuffer
from src.rendererUtil.TextCoordBuffer import TextCoordBuffer
from src.rendererUtil.NightVisionColorBuffer import NightVisionBuffer
from src.rendererUtil.IndexBuffer import IndexBuffer
from src.rendererUtil.TextureManager import TextureManager
from src.utils.VectorUtil import difference, sum_vectors, normalized, cross_product
from src.utils.DebugOptions import Debug
DRAWABLE_LINE = int("0x7f02003a", 0)
class PolyLineObjectManager(RendererObjectManager):
'''
Manages the rendering of lines by loading points and lines
into glbuffers
'''
def update_objects(self, lines, update_type):
# We only care about updates to positions, ignore any other updates.
if not (self.update_type.Reset in update_type) and \
not (self.update_type.UpdatePositions in update_type):
return
num_line_segments = 0;
for l_source in lines:
num_line_segments += len(l_source.gc_vertices) - 1
# To render everything in one call, we render everything as a line list
# rather than a series of line strips.
num_vertices = 4 * num_line_segments
num_indices = 6 * num_line_segments
vb = self.vertex_buffer
vb.reset(4 * num_line_segments)
cb = self.color_buffer
cb.reset(4 * num_line_segments)
tb = self.text_coord_buffer
tb.reset(num_vertices)
ib = self.index_buffer
ib.reset(num_indices)
# See comment in PointObjectManager for justification of this calculation.
fovy_in_radians = 60 * math.pi / 180.0
size_factor = math.tan(fovy_in_radians * 0.5) / 480.0
bool_opaque = True
vertex_index = 0
for l_source in lines:
coords_list = l_source.gc_vertices
if len(coords_list) < 2:
continue
# If the color isn't fully opaque, set opaque to false.
color = l_source.color
bool_opaque &= int(color & 0xff000000) == 0xff000000
# Add the vertices.
for i in range(0, len(coords_list) - 1):
p1 = coords_list[i]
p2 = coords_list[i+1]
u = difference(p2, p1)
# The normal to the quad should face the origin at its midpoint.
avg = sum_vectors(p1, p2)
avg.scale(0.5)
# I'm assum_vectorsing that the points will already be on a unit sphere. If this is not the case,
# then we should normalize it here.
v = normalized(cross_product(u, avg))
v.scale(size_factor * l_source.line_width)
# Add the vertices
# Lower left corner
vb.add_point(difference(p1, v))
cb.add_color(color)
tb.add_text_coord(0, 1)
# Upper left corner
vb.add_point(sum_vectors(p1, v))
cb.add_color(color)
tb.add_text_coord(0, 0)
# Lower left corner
vb.add_point(difference(p2, v))
cb.add_color(color)
tb.add_text_coord(1, 1)
# Upper left corner
vb.add_point(sum_vectors(p2, v))
cb.add_color(color)
tb.add_text_coord(1, 0)
# Add the indices
bottom_left = vertex_index
top_left = vertex_index + 1
bottom_right = vertex_index +2
top_right = vertex_index + 3
vertex_index += 4
# First triangle
ib.add_index(bottom_left)
ib.add_index(top_left)
ib.add_index(bottom_right)
# Second triangle
ib.add_index(bottom_right)
ib.add_index(top_left)
ib.add_index(top_right)
self.opaque = bool_opaque
def reload(self, gl, full_reload=False):
TM = TextureManager()
self.texture_ref = TM.get_texture_from_resource(gl, DRAWABLE_LINE)
self.vertex_buffer.reload()
self.color_buffer.reload()
self.text_coord_buffer.reload()
self.index_buffer.reload()
def draw_internal(self, gl):
if Debug.DRAWING == "POINTS ONLY": return
if self.index_buffer.num_indices == 0:
return
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
gl.glEnableClientState(gl.GL_COLOR_ARRAY)
gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY)
gl.glEnable(gl.GL_TEXTURE_2D)
self.texture_ref.bind(gl)
gl.glEnable(gl.GL_CULL_FACE)
gl.glFrontFace(gl.GL_CW)
gl.glCullFace(gl.GL_BACK)
if not self.opaque:
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glTexEnvf(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_MODULATE);
self.vertex_buffer.set(gl)
self.color_buffer.set(gl, self.render_state.night_vision_mode)
self.text_coord_buffer.set(gl)
self.index_buffer.draw(gl, gl.GL_TRIANGLES)
if not self.opaque:
gl.glDisable(gl.GL_BLEND)
gl.glDisable(gl.GL_TEXTURE_2D)
gl.glDisableClientState(gl.GL_TEXTURE_COORD_ARRAY)
def __init__(self, new_layer, new_texture_manager):
'''
Constructor
'''
RendererObjectManager.__init__(self, new_layer, new_texture_manager)
self.vertex_buffer = VertexBuffer(True)
self.color_buffer = NightVisionBuffer(True)
self.text_coord_buffer = TextCoordBuffer(True)
self.index_buffer = IndexBuffer(True)
self.texture_ref = None
self.opaque = True
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,532
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/source/TextSource.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-16
@author: Neil Borle
'''
from Source import Source
from src.units.GeocentricCoordinates import get_instance
class TextSource(Source):
'''
A Source which consists of only a text label (no point will be drawn).
'''
def __init__(self, new_label, color, geo_coords=get_instance(0.0, 0.0), \
new_offset=0.02, new_fontsize=15):
'''
Constructor
'''
Source.__init__(self, color, geo_coords)
self.label = new_label
self.offset = new_offset
self.font_size = new_fontsize
if __name__ == "__main__":
'''
For debugging purposes
'''
T = TextSource("Sun", 0xFA783B90)
print T.geocentric_coords.z
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,533
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/base/Preconditions.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-20
@author: Neil Borle
Functions for asserting that parameters or other variables equal
specific values.
'''
def check(boolean_value):
'''
Ensures that the given boolean state is true. If false, throws a
PreconditionException with a generic error message.
'''
if not boolean_value:
raise Exception("Unexpected State Encountered")
def check_not_none(input_val):
'''
Ensures that the given reference is not None.
'''
if input_val == None:
raise Exception("Expected non-None, but got None.")
def check_not_empty(in_string):
'''
Ensures that the specified String is not None, or equal to the empty string
("") after all whitespace characters have been removed.
'''
if (in_string == None) or "".join(in_string.split()) == "":
raise Exception("Observed string was empty")
def check_equal(observed, expected):
'''
Ensures that the two specified objects are (object) equal. This will not
throw a Precondition check if two objects are ".equals", but not "==". If
you want to test "==" equals, use checkSame.
'''
if observed != expected:
raise Exception("inputs are not the same")
def check_not_equal(observed, expected):
'''
Ensures that the two specified objects are not equals (either "==" or
".equals").
'''
if observed == expected:
raise Exception("expected inputs to be different")
def check_between(value, minimum, maximum):
'''
Ensures that the given value is between the min and max values (inclusive).
That is, min <= value <= max
'''
if (value < minimum) or (value > maximum):
raise Exception("value is not in expected range")
if __name__ == "__main__":
'''
Run Checks
'''
check(False)
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,534
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/base/TimeConstants.py
|
'''
// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-20
@author: Neil Borle
These constants are used in calculations, ex. movement of planets.
'''
MILLISECONDS_PER_SECOND = 1000
MILLISECONDS_PER_MINUTE = 60000
MILLISECONDS_PER_HOUR = 3600000
MILLISECONDS_PER_DAY = 86400000
MILLISECONDS_PER_WEEK = 604800000
SECONDS_PER_SECOND = 1
SECONDS_PER_MINUTE = 60
SECONDS_PER_10MINUTE = 600
SECONDS_PER_HOUR = 3600
SECONDS_PER_DAY = 24 * SECONDS_PER_HOUR
SECONDS_PER_WEEK = 7 * SECONDS_PER_DAY
SECONDS_PER_SIDEREAL_DAY = 86164.0905
MILLISECONDS_PER_SIDEREAL_DAY = MILLISECONDS_PER_SECOND * SECONDS_PER_SIDEREAL_DAY
SECONDS_PER_SIDERIAL_WEEK = 7 * 86164.0905
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,535
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/layers/GridLayer.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor, Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-16
@author: Neil Borle
'''
from SourceLayer import SourceLayer
from src.source.AbstractAstronomicalSource import AbstractAstronomicalSource
from src.source.LineSource import LineSource
from src.source.TextSource import TextSource
from src.units.RaDec import RaDec
from src.units.GeocentricCoordinates import get_instance
class GridLayer(SourceLayer):
'''
creates a Layer which returns Sources which correspond to grid lines parallel
to the celestial equator and the hour angle. That is, returns a set of lines
with constant right ascension, and another set with constant declination.
'''
class GridSource(AbstractAstronomicalSource):
'''
Grid elements as astronomical sources so that they
can be rendered just like any other astronomical object.
'''
def create_ra_line(self, index, num_ra_sources):
'''
Constructs a single longitude line. These lines run from the north pole to
the south pole at fixed Right Ascensions.
'''
line = LineSource([], self.LINE_COLOR)
ra = index * 360.0 / num_ra_sources
for i in range(0, self.NUM_DEC_VERTICES - 1):
dec = 90.0 - i * 180.0 / (self.NUM_DEC_VERTICES - 1)
ra_dec = RaDec(ra, dec)
line.ra_decs.append(ra_dec)
line.gc_vertices.append(get_instance(ra, dec))
ra_dec = RaDec(0.0, -90.0)
line.ra_decs.append(ra_dec)
line.gc_vertices.append(get_instance(0.0, -90.0))
return line
def create_dec_line(self, index, num_dec_sources):
'''
Creates a single latitudinal line.
'''
line = LineSource([], self.LINE_COLOR)
dec = 90.0 - (index + 1.0) * 180.0 / (num_dec_sources + 1.0)
for i in range(0, self.NUM_RA_VERTICES):
ra = i * 360.0 / self.NUM_RA_VERTICES
ra_dec = RaDec(ra, dec)
line.ra_decs.append(ra_dec)
line.gc_vertices.append(get_instance(ra, dec))
ra_dec = RaDec(0.0, dec)
line.ra_decs.append(ra_dec)
line.gc_vertices.append(get_instance(0.0, dec))
return line
#override(AbstractAstronomicalSource)
def get_lines(self):
return self.line_sources
#override(AbstractAstronomicalSource)
def get_labels(self):
return self.text_sources
def __init__(self, num_RA_sources, num_De_sources):
'''
constructor
'''
AbstractAstronomicalSource.__init__(self)
self.LINE_COLOR = 0x14F8EFBC
# These are great (semi)circles, so only need 3 points.
self.NUM_DEC_VERTICES = 3
# every 10 degrees
self.NUM_RA_VERTICES = 36
self.line_sources = []
self.text_sources = []
for r in range(0, num_RA_sources):
self.line_sources.append(self.create_ra_line(r, num_RA_sources))
for d in range(0, num_De_sources):
self.line_sources.append(self.create_dec_line(d, num_De_sources))
# North & South pole, hour markers every 2hrs.
self.text_sources.append(TextSource("NP", self.LINE_COLOR,
get_instance(0.0, 90.0)))
self.text_sources.append(TextSource("SP", self.LINE_COLOR,
get_instance(0.0, -90.0)))
for index in range(0, 12):
ra = index * 30.0
title = str(index * 2) + "h"
self.text_sources.append(TextSource(title, self.LINE_COLOR,
get_instance(ra, 0.0)))
def initialize_astro_sources(self, sources):
sources.append(self.GridSource(self.num_RA_sources, self.num_De_sources))
def get_layer_id(self):
return -104
def get_layer_name_id(self):
raise NotImplementedError("not implemented yet")
def get_preference_id(self):
return "source_provider.4"
def __init__(self, num_right_asc_lines, num_dec_lines):
'''
Constructor
'''
SourceLayer.__init__(self, False)
self.num_RA_sources = num_right_asc_lines
self.num_De_sources = num_dec_lines
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,536
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/units/RaDec.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-17
@author: Neil Borle
'''
import math
from src.units.HeliocentricCoordinates import HeliocentricCoordinates, get_instance as hc_get_instance
from src.utils.Geometry import mod_2_pi, radians_to_degrees
from src.utils.Enumeration import enum
planet_enum = enum(MERCURY=0, VENUS=1, SUN=2, MARS=3,
JUPITER=4, SATURN=5, URANUS=6,
NEPTUNE=7, PLUTO=8, MOON=9)
def get_instance(geo_coord=None, earth_coord=None,
planet=None, time=None):
'''
Returns a RaDec instance given either geocentric coordinates
or heliocentric coordinates with a planet and the time.
'''
if geo_coord == None and earth_coord == None:
raise Exception("must provide geo_coords or helio_coords")
if geo_coord != None:
raRad = math.atan2(geo_coord.y, geo_coord.x)
if (raRad < 0): raRad += math.pi * 2.0
decRad = math.atan2(geo_coord.z,
math.sqrt(geo_coord.x * geo_coord.x + \
geo_coord.y * geo_coord.y));
return RaDec(radians_to_degrees(raRad), radians_to_degrees(decRad))
else:
if planet.id == planet_enum.MOON:
return planet.calculate_lunar_geocentric_location(time)
coords = None
if planet.id == planet_enum.SUN:
# Invert the view, since we want the Sun in earth coordinates, not the Earth in sun
# coordinates.
coords = HeliocentricCoordinates(earth_coord.radius, earth_coord.x * -1.0,
earth_coord.y * -1.0, earth_coord.z * -1.0)
else:
coords = hc_get_instance(None, planet, time)
coords.subtract(earth_coord)
equ = coords.calculate_equitorial_coords()
return calculate_ra_dec_dist(equ)
def calculate_ra_dec_dist(helio_coord):
ra = mod_2_pi(math.atan2(helio_coord.y, helio_coord.x)) * \
(180.0 / math.pi)
dec = math.atan(helio_coord.z / \
math.sqrt(helio_coord.x * helio_coord.x + \
helio_coord.y * helio_coord.y)) * \
(180.0 / math.pi)
return RaDec(ra, dec)
class RaDec(object):
'''
The radians and declination of a point in the sky
'''
ra = None
dec = None
def to_string(self):
return "RA: " + self.ra + " degrees\nDec: " + self.dec + " degrees\n"
def is_circumpolar_for(self, longlat):
'''
Return true if the given Ra/Dec is always above the horizon. Return
false otherwise.
In the northern hemisphere, objects never set if dec > 90 - lat.
In the southern hemisphere, objects never set if dec < -90 - lat.
'''
if longlat.latitude > 0.0:
return self.dec > (90.0 - longlat.latitude)
else:
return self.dec < (-90.0 - longlat.latitude)
def is_never_visible(self, longlat):
'''
Return true if the given Ra/Dec is always below the horizon. Return
false otherwise.
In the northern hemisphere, objects never rise if dec < lat - 90.
In the southern hemisphere, objects never rise if dec > 90 - lat.
'''
if longlat.latitude > 0.0:
return self.dec < (longlat.latitude - 90.0)
else:
return self.dec > (90.0 + longlat.latitude)
def __init__(self, new_ra, new_dec):
'''
Constructor
'''
self.ra = new_ra
self.dec = new_dec
if __name__ == "__main__":
'''
For debugging purposes
'''
from units.LatLong import LatLong
from units.GeocentricCoordinates import GeocentricCoordinates as GC
from units.HeliocentricCoordinates import HeliocentricCoordinates as HC
rd = get_instance(GC(1, 0, 0))
rd2 = rd.calculate_ra_dec_dist(HC(100, 1, 0, 0))
print rd2.is_circumpolar_for(LatLong(0, 0))
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,537
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/units/Matrix33.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Dominic Widdows
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-19
@author: Neil Borle
'''
def get_rowmatrix_from_vectors(v1, v2, v3):
return Matrix33(v1.x, v1.y, v1.z,
v2.x, v2.y, v2.z,
v3.x, v3.y, v3.z)
def get_colmatrix_from_vectors(v1, v2, v3):
return Matrix33(v1.x, v2.x, v3.x,
v1.y, v2.y, v3.y,
v1.z, v2.z, v3.z)
def get_identity_matrix():
return Matrix33(1, 0, 0, 0, 1, 0, 0, 0, 1)
class Matrix33(object):
'''
Represents a 3x3 matrix so that transformations
to objects in the sky can be performed
'''
def clone(self):
return Matrix33(self.xx, self.xy, self.xz,
self.yx, self.yy, self.yz,
self.zx, self.zy, self.zz)
def get_determinant(self):
return (self.xx * self.yy * self.zz) + \
(self.xy * self.yz * self.zx) + \
(self.xz * self.yx * self.zy) - \
(self.xx * self.yz * self.zy) - \
(self.yy * self.zx * self.xz) - \
(self.zz * self.xy * self.yx)
def get_inverse(self):
det = self.get_determinant()
if det == 0.0: return None
return Matrix33( (self.yy * self.zz - self.yz * self.zy) / det,
(self.xz * self.zy - self.xy * self.zz) / det,
(self.xy * self.yz - self.xz * self.yy) / det,
(self.yz * self.zx - self.yx * self.zz) / det,
(self.xx * self.zz - self.xz * self.zx) / det,
(self.xz * self.yx - self.xx * self.yz) / det,
(self.yx * self.zy - self.yy * self.zx) / det,
(self.xy * self.zx - self.xx * self.zy) / det,
(self.xx * self.yy - self.xy * self.yx) / det)
def transpose(self):
self.xy, self.yx = self.yx, self.xy
self.xz, self.zx = self.zx, self.xz
self.yz, self.zy = self.zy, self.yz
def __init__(self, new_xx, new_xy, new_xz,
new_yx, new_yy, new_yz,
new_zx, new_zy, new_zz):
'''
New Matrix
xx xy xz
yx yy yz
zx zy zz
'''
self.xx = float(new_xx)
self.xy = float(new_xy)
self.xz = float(new_xz)
self.yx = float(new_yx)
self.yy = float(new_yy)
self.yz = float(new_yz)
self.zx = float(new_zx)
self.zy = float(new_zy)
self.zz = float(new_zz)
if __name__ == "__main__":
'''
for debugging purposes
'''
M = get_identity_matrix()
print M.get_determinant()
M2 = Matrix33(3, 0, 4, 0, 1, 0, 1, 2, 1)
M2.transpose()
print M2.xx, M2.xy, M2.xz
print M2.yx, M2.yy, M2.yz
print M2.zx, M2.zy, M2.zz
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,538
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/units/Vector3.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-16
@author: Neil Borle
'''
import math
class Vector3(object):
'''
Basic Vector class in 3 dimensions. It is inherited by
[Geo/Helio]centric coordinates
'''
def assign(self, new_x=0.0, new_y=0.0, new_z=0.0, vector3=None):
if vector3 != None:
self.x = vector3.x
self.y = vector3.y
self.z = vector3.z
else:
self.x = float(new_x)
self.y = float(new_y)
self.z = float(new_z)
def copy(self):
return Vector3(self.x, self.y, self.z)
def length(self):
return math.sqrt(self.x * self.x + self.y * self.y + self.z * self.z)
def normalize(self):
norm = self.length()
self.x = self.x / norm
self.y = self.y / norm
self.z = self.z / norm
def scale(self, value):
self.x = self.x * float(value)
self.y = self.y * float(value)
self.z = self.z * float(value)
def to_float_array(self):
return [self.x, self.y, self.z]
def equals(self, v3_object):
try:
if v3_object.x == self.x and v3_object.y == self.y and v3_object.z == self.z:
return True
else:
return False
except:
return False
def hash_code(self):
raise NotImplemented("hash code not implemented")
def to_string(self):
return "x={0}, y={1}, z={2}".format(self.x, self.y, self.z)
def __init__(self, new_x=0.0, new_y=0.0, new_z=0.0, coord_list=None):
'''
Constructor
'''
if coord_list != None and len(coord_list) == 3:
self.x = float(coord_list[0])
self.y = float(coord_list[1])
self.z = float(coord_list[2])
else:
self.x = float(new_x)
self.y = float(new_y)
self.z = float(new_z)
if __name__ == "__main__":
'''
For Debugging purposes
'''
A = Vector3(1, 2, 3)
B = Vector3(9, 8, 7)
A.assign(vector3=B)
print A.x, A.y, A.z
A.assign(2, 4, 4)
print A.length()
print A.to_string()
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,539
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/provider/PlanetSource.py
|
'''
// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-26
@author: Neil Borle
'''
import time
from src.renderer.RendererObjectManager import RendererObjectManager
from Planet import Planet, planet_enum, res
from src.source.AbstractAstronomicalSource import AbstractAstronomicalSource
from src.source.PointSource import PointSource
from src.source.TextSource import TextSource
from src.source.ImageSource import ImageSource
from src.units.Vector3 import Vector3
from src.units.GeocentricCoordinates import GeocentricCoordinates
from src.units.HeliocentricCoordinates import get_instance
from src.units.RaDec import get_instance as radec_get_instance
USE_PLANETARY_IMAGES = True
class PlanetSource(AbstractAstronomicalSource):
'''
An extension of AstronomicalSource for planets so that
the elements of each planet can be rendered in a standard
way.
'''
PLANET_SIZE = 3
PLANET_COLOR = 0x14817EF6
# The G1 rendering bug does not appear in this python code.
PLANET_LABEL_COLOR = 0x817EF6
SHOW_PLANETARY_IMAGES = "show_planetary_images"
UP = Vector3(0.0, 1.0, 0.0)
def get_names(self):
return self.names.append(self.name)
def update_coords(self, t_struct):
self.last_update_time_Ms = time.mktime(t_struct)
p = Planet(planet_enum.SUN, res[planet_enum.SUN][0],
res[planet_enum.SUN][1], res[planet_enum.SUN][2])
self.sun_coords = get_instance(t_struct=t_struct, planet=p)
ra_dec = radec_get_instance(earth_coord=self.sun_coords, planet=self.planet, time=t_struct)
self.current_coords.update_from_ra_dec(ra_dec.ra, ra_dec.dec)
for imgsrc in self.image_sources:
imgsrc.set_up_vector(self.sun_coords)
def initialize(self):
time = self.model.get_time()
self.update_coords(time)
self.image_id = self.planet.get_image_resource_id(time)
if self.planet.id == planet_enum.MOON:
self.image_sources.append(ImageSource(self.current_coords, self.image_id, self.sun_coords,
self.planet.get_planetary_image_size()))
else:
if USE_PLANETARY_IMAGES or self.planet.id == planet_enum.SUN:
self.image_sources.append(ImageSource(self.current_coords, self.image_id, self.UP,
self.planet.get_planetary_image_size()))
else:
self.point_sources.append(PointSource(self.PLANET_COLOR, self.PLANET_SIZE,
self.current_coords))
self.label_sources.append(TextSource(self.name, self.PLANET_LABEL_COLOR, self.current_coords))
return self
#override(AbstractAstronomicalSource)
def update(self):
updates = set()
model_time = self.model.get_time()
if abs(time.mktime(model_time) - self.last_update_time_Ms) > self.planet.get_update_frequency_Ms:
updates = updates | set([RendererObjectManager().update_type.UpdatePositions])
# update location
self.update_coords(model_time)
# For moon only:
if self.planet.id == planet_enum.MOON and self.image_sources != []:
# Update up vector.
self.image_sources[0].set_up_vector(self.sun_coords)
# update image:
new_image_id = self.planet.get_image_resource_id(model_time)
if new_image_id != self.image_id:
self.image_id = new_image_id
self.image_sources[0].image_id = new_image_id
updates = updates | set([RendererObjectManager().update_type.UpdateImages])
return updates
#override(AbstractAstronomicalSource)
def get_points(self):
return self.point_sources
#override(AbstractAstronomicalSource)
def get_labels(self):
return self.label_sources
#override(AbstractAstronomicalSource)
def get_images(self):
return self.image_sources
def __init__(self, planet, model):
'''
Constructor
'''
AbstractAstronomicalSource.__init__(self)
self.point_sources = []
self.image_sources = []
self.label_sources = []
self.planet = planet
self.model = model
self.name = planet.name_resource_id
self.current_coords = GeocentricCoordinates(0, 0, 0)
self.sun_coords = None
self.image_id = -1
self.last_update_time_Ms = 0
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,540
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/rendererUtil/ColoredQuad.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-19
@author: Neil Borle
'''
from VertexBuffer import VertexBuffer
from src.units.Vector3 import Vector3
class ColoredQuad(object):
'''
Provides an abstraction so that colored rectangles
can be buffered and loaded into OpenGL
'''
def draw(self, gl):
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
gl.glDisableClientState(gl.GL_TEXTURE_COORD_ARRAY)
gl.glDisableClientState(gl.GL_COLOR_ARRAY)
# Enable blending if alpha != 1.
if self.a != 1:
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glDisable(gl.GL_TEXTURE_2D)
self.position.set(gl)
gl.glColor4f(self.r, self.g, self.b, self.a)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)
gl.glEnable(gl.GL_TEXTURE_2D)
# Disable blending if alpha != 1.
if self.a != 1:
gl.glDisable(gl.GL_BLEND)
def __init__(self, r, g, b, a,
px, py, pz,
ux, uy, uz,
vx, vy, vz):
'''
Constructor
'''
self.position = VertexBuffer(12)
# Upper left
self.position.add_point(Vector3(px - ux - vx, py - uy - vy, pz - uz - vz))
# upper left
self.position.add_point(Vector3(px - ux + vx, py - uy + vy, pz - uz + vz))
# lower right
self.position.add_point(Vector3(px + ux - vx, py + uy - vy, pz + uz - vz))
# upper right
self.position.add_point(Vector3(px + ux + vx, py + uy + vy, pz + uz + vz))
self.r = r
self.g = g
self.b = b
self.a = a
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,541
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/source/LineSource.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-16
@author: Neil Borle
'''
from Source import Source
from src.utils.Colors import colors
class LineSource(Source):
'''
Represents a single line with vertices,
Such as a constellation
'''
def __init__(self, gcvs, new_color=colors.WHITE, lw=1.5):
'''
Constructor
'''
Source.__init__(self, new_color)
self.ra_decs = []
self.line_width = lw
self.gc_vertices = gcvs
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,542
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/skypython/SkyPython.py
|
'''
// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-03
@author: Neil Borle and Morgan Redshaw
'''
import sys
import math
import time
from PySide import QtCore
from PySide.QtGui import QApplication
from PySide.QtGui import QMainWindow, QGraphicsView, QGraphicsScene
from SharedPreferences import SharedPreferences
from src.views.PreferencesButton import PreferencesButton
from src.views.ZoomButton import ZoomButton
from src.views.WidgetFader import WidgetFader
from src.touch.MapMover import MapMover
from src.touch.DragRotateZoomGestureDetector import DragRotateZoomGestureDetector as DRZDetector
from src.layers.LayerManager import instantiate_layer_manager
from src.control.AstronomerModel import AstronomerModel
from src.control.ControllerGroup import create_controller_group
from src.renderer.SkyRenderer import SkyRenderer
from src.renderer.RendererController import RendererController
from src.control.ZeroMagneticDeclinationCalculator import ZeroMagneticDeclinationCalculator as ZMDC
from src.control.MagneticDeclinationCalculatorSwitcher import MagneticDeclinationCalculatorSwitcher as MDCS
def start_application(mode=None):
'''
Either start the application normally or
start it in debug with images. The later causes
6 processes to be spawned with different camera
positions in the night sky.
'''
if mode == None:
worker()
else:
import multiprocessing
for i in range(0, 6):
p = multiprocessing.Process(target=worker, args=(i,))
p.start()
time.sleep(2)
def worker(index=None):
'''
Creates a single instance of the application.
'''
app = QApplication(sys.argv)
w = SkyPython(index)
w.show()
app.installEventFilter(w)
r = app.exec_()
sys.exit(r)
class SkyPython(QMainWindow):
'''
The central widget and heart of the application.
Performs all of the initialization of components
and contains updates and event handling.
'''
class RendererModelUpdateClosure():
'''
A runnable class that updates the state of the
model after a change has occurred. Is placed
on the event queue.
'''
def run(self):
pointing = self.model.get_pointing()
direction_x = pointing.gc_line_of_sight.x
direction_y = pointing.gc_line_of_sight.y
direction_z = pointing.gc_line_of_sight.z
up_x = pointing.gc_perpendicular.x
up_y = pointing.gc_perpendicular.y
up_z = pointing.gc_perpendicular.z
self.renderer_controller.queue_set_view_orientation(direction_x, direction_y, direction_z, \
up_x, up_y, up_z)
acceleration = self.model.acceleration
self.renderer_controller.queue_text_angle(math.atan2(-acceleration.x, -acceleration.y))
self.renderer_controller.queue_viewer_up_direction(self.model.get_zenith().copy())
field_of_view = self.model.field_of_view
self.renderer_controller.queue_field_of_view(field_of_view)
def __init__(self, m_model, controller):
'''
constructor
'''
self.model = m_model
self.renderer_controller = controller
layer_manager = None
model = None
controller = None
sky_renderer = None
renderer_controller = None
def pref_change(self, prefs, manager, layers, event):
'''
If a preference button has been pressed, change
the preferences according to the selection..
'''
for layer in layers:
prefs.PREFERENCES[layer] = not prefs.PREFERENCES[layer]
manager.on_shared_preference_change(prefs, layer)
return True
def eventFilter(self, source, event):
'''
Check if the event is a button press in the UI, if not
then check if it was a mouse or key press in DRZ_detector.
'''
pref_pressed = self.pref_buttons.checkForButtonPress(source, event)
zoom_pressed = self.zoom_button.checkForButtonPress(source, event, self.controller)
if pref_pressed or zoom_pressed:
self.show_menus_func()
if pref_pressed:
self.pref_change(self.shared_prefs, self.layer_manager,
pref_pressed, event)
else:
update = self.DRZ_detector.on_motion_event(event)
if pref_pressed or zoom_pressed or update:
self.update_rendering()
return True
return QMainWindow.eventFilter(self, source, event)
def initialize_model_view_controller(self):
'''
Set up the graphics view/scene and set the GLWidget.
Also sets up the the model and the controller for the model.
'''
self.model = AstronomerModel(ZMDC())
# There is no onResume in python so start the controller group here
self.controller = create_controller_group(self.shared_prefs)
self.controller.set_model(self.model)
self.controller.start()
self.layer_manager = instantiate_layer_manager(self.model, self.shared_prefs)
self.view = QGraphicsView()
self.scene = QGraphicsScene()
if self.DEBUG_MODE != None:
self.sky_renderer = SkyRenderer(self.DEBUG_MODE)
else:
self.sky_renderer = SkyRenderer()
self.sky_renderer.setAutoFillBackground(False)
# set up the view with the glwidget inside
self.view.setViewport(self.sky_renderer)
self.view.setScene(self.scene)
self.setCentralWidget(self.view)
self.renderer_controller = RendererController(self.sky_renderer, None)
self.renderer_controller.add_update_closure(\
self.RendererModelUpdateClosure(self.model, self.renderer_controller))
self.layer_manager.register_with_renderer(self.renderer_controller)
self.wire_up_screen_controls()
# NOTE: THIS BOOLEAN WILL NEED TO BE REMOVED EVENTUALLY
self.magnetic_switcher = MDCS(self.model, self.USE_AUTO_MODE)
self.run_queue()
def wire_up_screen_controls(self):
'''
Set up all of the screen controls, so that the user can zoom in/out
and select which layers they wish to view.
'''
screen_width = self.sky_renderer.render_state.screen_width
screen_height = self.sky_renderer.render_state.screen_height
self.pref_buttons = PreferencesButton(self.view)
self.zoom_button = ZoomButton(self.view)
position_y = ((screen_height - 336) / 2) + 1
self.pref_buttons.setGeometry(QtCore.QRect(1, position_y, 55, 336))
position_x = ((screen_width - 221) / 2) + 1
position_y = ((screen_height - 31) * 9/10) + 1
self.zoom_button.setGeometry(QtCore.QRect(position_x, position_y, 221, 31))
self.pref_buttons_fader = WidgetFader(self.pref_buttons, 2500)
self.zoom_button_fader = WidgetFader(self.zoom_button, 2500)
self.map_mover = MapMover(self.model, self.controller, self.shared_prefs,
screen_height)
self.DRZ_detector = DRZDetector(self.map_mover, self.show_menus_func)
def show_menus_func(self):
self.pref_buttons_fader.make_active()
self.zoom_button_fader.make_active()
def update_rendering(self):
'''
re-render the sky and run updates
'''
self.sky_renderer.updateGL()
self.run_queue()
self.sky_renderer.updateGL()
def run_queue(self):
'''
In the absence of another thread doing updates,
force the updates by running all the runnables on the queue
'''
num = len(list(self.renderer_controller.queuer.queue))
while num > 0:
runnable = self.renderer_controller.queuer.get()
runnable.run()
self.renderer_controller.queuer.task_done()
num -= 1
def __init__(self, debug_index=None):
'''
Set up all state and control that the application requires.
'''
QMainWindow.__init__(self)
self.setAttribute(QtCore.Qt.WA_AcceptTouchEvents)
self.DEBUG_MODE = debug_index
self.USE_AUTO_MODE = False
self.shared_prefs = SharedPreferences()
self.initialize_model_view_controller()
self.controller.set_auto_mode(self.USE_AUTO_MODE)
# put the window at the screen position (100, 30)
# with size 480 by 800
self.setGeometry(100, 30, 480, 800)
self.show()
# every 5 seconds re-render the sky and run updates
self.update_rendering()
self.timer = QtCore.QTimer(self)
self.timer.timeout.connect(self.update_rendering)
self.timer.setInterval(5000)
self.timer.start()
if __name__ == "__main__":
import os
os.chdir("../..")
start_application()
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,543
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/renderer/ImageObjectManager.py
|
'''
// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: James Powell
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-10
@author: Neil Borle
'''
from PySide.QtGui import QImage
from PySide.QtOpenGL import QGLWidget
from RendererObjectManager import RendererObjectManager
from src.rendererUtil.TextureManager import TextureManager
from src.rendererUtil.VertexBuffer import VertexBuffer
from src.rendererUtil.TextCoordBuffer import TextCoordBuffer
from src.units.Vector3 import Vector3
from src.utils.DebugOptions import Debug
class ImageObjectManager(RendererObjectManager):
'''
Manages the rendering of image objects, specifically
it takes in a list of image sources and fills several
buffers so that these images can be rendered.
'''
class Image():
def __init__(self):
self.name = None
self.pixmap = None
self.texture_id = None
self.use_blending = False
def update_objects(self, image_sources, update_types):
'''
takes a list of image sources and creates new buffers
for these sources.
'''
# hack to get rid of blank meteor showers.
image_sources = [img for img in image_sources if not img.is_blank]
if self.update_type.Reset not in update_types and \
len(image_sources) != len(self.images):
return
self.updates = self.updates | update_types # set union
num_vertices = len(image_sources) * 4
vb = self.vertex_buffer
vb.reset(num_vertices)
tcb = self.text_coord_buffer
tcb.reset(num_vertices)
images = []
reset = (self.update_type.Reset in update_types) or (self.update_type.UpdateImages in update_types)
if reset:
images = [None] * len(image_sources)
else:
images = self.images
if reset:
for i in range(0, len(image_sources)):
ims = image_sources[i]
images[i] = self.Image()
images[i].name = "no url"
images[i].use_blending = False
images[i].pixmap = ims.pixmap_image
# Update the positions in the position and tex coord buffers.
if reset or self.update_type.UpdatePositions in update_types:
for i in range(0, len(image_sources)):
ims = image_sources[i]
xyz = ims.geocentric_coords
px = xyz.x
py = xyz.y
pz = xyz.z
u = ims.get_horizontal_corner()
ux = u[0]
uy = u[1]
uz = u[2]
v = ims.get_verical_corner()
vx = v[0]
vy = v[1]
vz = v[2]
# lower left
vb.add_point(Vector3(px - ux - vx, py - uy - vy, pz - uz - vz))
tcb.add_text_coord(0, 1)
# upper left
vb.add_point(Vector3(px - ux + vx, py - uy + vy, pz - uz + vz))
tcb.add_text_coord(0, 0)
# lower right
vb.add_point(Vector3(px + ux - vx, py + uy - vy, pz + uz - vz))
tcb.add_text_coord(1, 1)
# upper right
vb.add_point(Vector3(px + ux + vx, py + uy + vy, pz + uz + vz))
tcb.add_text_coord(1, 0)
# We already set the image in reset, so only set them here if we're
# not doing a reset.
if self.update_type.UpdateImages in update_types:
for i in range(0, len(image_sources)):
ims = image_sources[i]
images[i].pixmap = ims.pixmap_image
self.images = images
self.queue_for_reload(False)
def reload(self, gl, full_reload):
imgs = self.images
reload_buffers = False
reload_images = False
if full_reload:
reload_buffers =True
reload_images = True
# If this is a full reload, all the textures were automatically deleted,
# so just create new arrays so we won't try to delete the old ones again.
self.textures = [None] * len(imgs)
self.red_textures = [None] * len(imgs)
else:
# Process any queued updates.
reset = self.update_type.Reset in self.updates
reload_buffers = reload_buffers or reset or self.update_type.UpdatePositions in self.updates
reload_images = reload_images or reset or self.update_type.UpdateImages in self.updates
self.updates = set()
if reload_buffers:
self.vertex_buffer.reload()
self.text_coord_buffer.reload()
if reload_images:
for i in range(0, len(self.textures)):
#If the image is already allocated, delete it.
if self.textures[i] != None:
self.textures[i].delete(gl)
self.red_textures[i].delete(gl)
bmp = self.images[i].pixmap
self.textures[i] = TextureManager().create_texture(gl)
self.textures[i].bind(gl)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE)
'''
IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
The image has to be mirrored for some reason
'''
q_img = QImage(bmp.toImage()).mirrored()
img = QGLWidget.convertToGLFormat(q_img)
gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, img.width(), img.height(), 0, gl.GL_RGBA,
gl.GL_UNSIGNED_BYTE, str(img.bits()))
self.red_textures[i] = TextureManager().create_texture(gl)
self.red_textures[i].bind(gl)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE)
red_pixels = self.create_red_image(q_img)
red_pixels = QGLWidget.convertToGLFormat(red_pixels)
gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGBA, red_pixels.width(), red_pixels.height(),
0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, str(red_pixels.bits()))
def draw_internal(self, gl):
if Debug.DRAWING == "POINTS ONLY" or Debug.DRAWING == "POINTS AND LINES": return
if self.vertex_buffer.num_vertices == 0:
return
gl.glEnable(gl.GL_TEXTURE_2D)
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY)
gl.glDisableClientState(gl.GL_COLOR_ARRAY)
self.vertex_buffer.set(gl)
self.text_coord_buffer.set(gl)
textures = self.textures
red_textures = self.red_textures
for i in range(0, len(textures)):
if self.images[i].use_blending:
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
else:
gl.glEnable(gl.GL_ALPHA_TEST)
gl.glAlphaFunc(gl.GL_GREATER, 0.5)
if self.render_state.night_vision_mode:
red_textures[i].bind(gl)
else:
textures[i].bind(gl)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 4 * i, 4)
if self.images[i].use_blending:
gl.glDisable(gl.GL_BLEND)
else:
gl.glDisable(gl.GL_ALPHA_TEST)
gl.glDisable(gl.GL_TEXTURE_2D)
def create_red_image(self, img):
new_img = QImage(img)
for x in range(0, img.width()):
for y in range(0, img.height()):
pix = img.pixel(x, y)
r = pix & 0xFF
g = (pix >> 8) & 0xFF
b = (pix >> 16) & 0xFF
alpha_mask = pix & 0xFF000000
new_img.setPixel(x, y, (alpha_mask | ((r + g + b) / 3)))
return new_img
def __init__(self, new_layer, new_texture_manager):
'''
Constructor
'''
RendererObjectManager.__init__(self, new_layer, new_texture_manager)
self.vertex_buffer = VertexBuffer()
self.text_coord_buffer = TextCoordBuffer()
self.images = []
self.textures = []
self.red_textures = []
self.updates = set()
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,544
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/utils/DebugOptions.py
|
'''
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-07-16
@author: Neil Borle
'''
debug_opts = {"No debug settings" : None,
"View only stars" : "STARS ONLY",
"Stars, Const, Mess" : "FIRST 3",
"View only points" : "POINTS ONLY",
"View points/lines" : "POINTS AND LINES",
"Draw all regions" : "YES",
"View white objects" : "WHITE ONLY",
"Capture screen" : "YES"}
class Debug(object):
'''
This class exists to make taking pictures of a subset of
objects easier at various location in the sky
'''
LAYER = debug_opts["No debug settings"]
DRAWING = debug_opts["No debug settings"]
ALLREGIONS = debug_opts["No debug settings"]
COLOR = debug_opts["No debug settings"]
RADIUSOFVIEW = 90.0
LOOKDIRVECTORS = [[1.0, 0.0, 0.0], [0.0, 0.0, 1.0], [-1.0, 0.0, 0.0], [0.0, 0.0, -1.0], [0.0, 1.0, 0.0], [0.0, -1.0, 0.0]]
UPDIRVECTORS = [[0.0, 1.0, 0.0], [0.0, 1.0, 0.0], [0.0, 1.0, 0.0], [0.0, 1.0, 0.0], [-1.0, 0.0, 0.0], [1.0, 0.0, 0.0]]
RIGHTVECTORS = [[0.0, 0.0, 1.0], [-1.0, 0.0, 0.0], [0.0, 0.0, -1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 1.0], [0.0, 0.0, 1.0]]
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,545
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/testing/ProviderTests.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-07-24
@author: Alyson Wu and Morgan Redshaw
'''
#PlanetTest
# The test for testCalcNextRiseSetTime is implemented because Planet.Rise_set_indicator is not yet implemented
# The Moon fails all instances of disableTestIllumination
# print abs(21.2 - Moon.calculate_percent_illuminated(Time1)) => 56.7279215736
# print abs(4.1 - Moon.calculate_percent_illuminated(Time2)) => 91.9681709016
# print abs(79.0 - Moon.calculate_percent_illuminated(Time3)) => 57.2619194768
POS_TOL = 0.2
PHASE_TOL = 1.0
HOURS_TO_DEGREES = 360.0/24.0
def testLunarGeocentricLocation():
'''
>>> import datetime as dt
>>> import src.units.RaDec
>>> import src.provider.Planet as Planet
>>> tempPlanet = Planet.Planet(0, 0, 0, 0)
#2009 Jan 1, 12:00 UT1: RA = 22h 27m 20.423s, Dec = - 7d 9m 49.94s
>>> Time1 = dt.datetime(2009, 1, 1, 12, 0, 0).timetuple()
>>> lunarPos = tempPlanet.calculate_lunar_geocentric_location(Time1)
>>> abs((22.456 * HOURS_TO_DEGREES) - lunarPos.ra) < POS_TOL
True
>>> abs(-7.164 - lunarPos.dec) < POS_TOL
True
#2009 Sep 20, 12:00 UT1: RA = 13h 7m 23.974s, Dec = -12d 36m 6.15s
>>> Time2 = dt.datetime(2009, 9, 20, 12, 0, 0).timetuple()
>>> lunarPos = tempPlanet.calculate_lunar_geocentric_location(Time2)
>>> abs((13.123 * HOURS_TO_DEGREES) - lunarPos.ra) < POS_TOL
True
>>> abs(-12.602 - lunarPos.dec) < POS_TOL
True
# 2010 Dec 25, 12:00 UT1: RA = 9h 54m 53.914s, Dec = +8d 3m 22.00s
>>> Time3 = dt.datetime(2010, 12, 25, 12, 0, 0).timetuple()
>>> lunarPos = tempPlanet.calculate_lunar_geocentric_location(Time3)
>>> abs((9.915 * HOURS_TO_DEGREES) - lunarPos.ra) < POS_TOL
True
>>> abs(8.056 - lunarPos.dec) < POS_TOL
True
'''
pass
def disableTestIllumination():
# This test is disabled in the original Stardroid code base.
return
'''
>>> import datetime as dt
>>> import src.units.RaDec
>>> import src.provider.Planet as Planet
>>> res = Planet.res
>>> Mercury = Planet.Planet(Planet.planet_enum.MERCURY, res[0][0], res[0][1], res[0][2])
>>> Venus = Planet.Planet(Planet.planet_enum.VENUS, res[1][0], res[1][1], res[1][2])
>>> Mars = Planet.Planet(Planet.planet_enum.MARS, res[3][0], res[3][1], res[3][2])
>>> Moon = Planet.Planet(Planet.planet_enum.MOON, res[9][0], res[9][1], res[9][2])
#2009 Jan 1, 12:00 UT1
>>> Time1 = dt.datetime(2009, 1, 1, 12, 0, 0).timetuple()
>>> abs(21.2 - Moon.calculate_percent_illuminated(Time1)) < PHASE_TOL
True
>>> abs(69.5 - Mercury.calculate_percent_illuminated(Time1)) < PHASE_TOL
True
>>> abs(57.5 - Venus.calculate_percent_illuminated(Time1)) < PHASE_TOL
True
>>> abs(99.8 - Mars.calculate_percent_illuminated(Time1)) < PHASE_TOL
True
#2009 Sep 20, 12:00 UT1
>>> Time2 = dt.datetime(2009, 9, 20, 12, 0, 0).timetuple()
>>> abs(4.1 - Moon.calculate_percent_illuminated(Time2)) < PHASE_TOL
True
>>> abs(0.5 - Mercury.calculate_percent_illuminated(Time2)) < PHASE_TOL
True
>>> abs(88.0 - Venus.calculate_percent_illuminated(Time2)) < PHASE_TOL
True
>>> abs(88.7 - Mars.calculate_percent_illuminated(Time2)) < PHASE_TOL
True
# 2010 Dec 25, 12:00 UT1
>>> Time3 = dt.datetime(2010, 12, 25, 12, 0, 0).timetuple()
>>> abs(79.0 - Moon.calculate_percent_illuminated(Time3)) < PHASE_TOL
True
>>> abs(12.1 - Mercury.calculate_percent_illuminated(Time3)) < PHASE_TOL
True
>>> abs(42.0 - Venus.calculate_percent_illuminated(Time3)) < PHASE_TOL
True
>>> abs(99.6 - Mars.calculate_percent_illuminated(Time3)) < PHASE_TOL
True
'''
pass
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,546
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/utils/Matrix4x4.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-26
@author: Neil Borle
'''
import math
from src.units.Vector3 import Vector3
def create_identity():
return create_scaling(1, 1, 1)
def create_scaling(x, y, z):
return Matrix4x4([float(x), 0, 0, 0,
0, float(y), 0, 0,
0, 0, float(z), 0,
0, 0, 0, 1])
def create_translation(x, y, z):
return Matrix4x4([1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
float(x), float(y), float(z), 1])
def create_rotation(angle, vector3):
m = [0.0] *16
x_sqr = vector3.x * vector3.x
y_sqr = vector3.y * vector3.y
z_sqr = vector3.z * vector3.z
sin_angle = math.sin(angle)
cos_angle = math.cos(angle)
one_minus_cos_angle = 1.0 - cos_angle
x_sin_angle = vector3.x * sin_angle
y_sin_angle = vector3.y * sin_angle
z_sin_angle = vector3.z * sin_angle
z_one_minus_cos_angle = vector3.z * one_minus_cos_angle
xy_one_minus_cos_angle = vector3.x * vector3.y * one_minus_cos_angle
xz_one_minus_cos_angle = vector3.x * z_one_minus_cos_angle
yz_one_minus_cos_angle = vector3.y * z_one_minus_cos_angle
m[0] = x_sqr + (y_sqr + z_sqr) * cos_angle
m[1] = xy_one_minus_cos_angle + z_sin_angle
m[2] = xz_one_minus_cos_angle - y_sin_angle
m[3] = 0
m[4] = xy_one_minus_cos_angle - z_sin_angle
m[5] = y_sqr + (x_sqr + z_sqr) * cos_angle
m[6] = yz_one_minus_cos_angle + x_sin_angle
m[7] = 0
m[8] = xz_one_minus_cos_angle + y_sin_angle
m[9] = yz_one_minus_cos_angle - x_sin_angle
m[10] = z_sqr + (x_sqr + y_sqr) * cos_angle
m[11] = 0
m[12] = 0
m[13] = 0
m[14] = 0
m[15] = 1
return Matrix4x4(m)
def create_perspective_projection(width, height, fovy_in_radians):
near = 0.01
far = 10000.0
inverse_aspect_ratio = height / float(width)
one_over_tan_half_radius_of_view = 1.0 / math.tan(fovy_in_radians)
return Matrix4x4([
inverse_aspect_ratio * one_over_tan_half_radius_of_view, 0, 0, 0,
0, one_over_tan_half_radius_of_view, 0, 0,
0, 0, -(far + near) / float(far - near), -1,
0, 0, -2.0*far*near / float(far - near), 0])
def create_view(look_dir, up, right):
return Matrix4x4([right.x, up.x, -look_dir.x, 0,
right.y, up.y, -look_dir.y, 0,
right.z, up.z, -look_dir.z, 0,
0, 0, 0, 1])
def multiply_MM(mat1, mat2):
m = mat1.values[:]
n = mat2.values[:]
return Matrix4x4([ \
m[0]*n[0] + m[4]*n[1] + m[8]*n[2] + m[12]*n[3],
m[1]*n[0] + m[5]*n[1] + m[9]*n[2] + m[13]*n[3],
m[2]*n[0] + m[6]*n[1] + m[10]*n[2] + m[14]*n[3],
m[3]*n[0] + m[7]*n[1] + m[11]*n[2] + m[15]*n[3],
m[0]*n[4] + m[4]*n[5] + m[8]*n[6] + m[12]*n[7],
m[1]*n[4] + m[5]*n[5] + m[9]*n[6] + m[13]*n[7],
m[2]*n[4] + m[6]*n[5] + m[10]*n[6] + m[14]*n[7],
m[3]*n[4] + m[7]*n[5] + m[11]*n[6] + m[15]*n[7],
m[0]*n[8] + m[4]*n[9] + m[8]*n[10] + m[12]*n[11],
m[1]*n[8] + m[5]*n[9] + m[9]*n[10] + m[13]*n[11],
m[2]*n[8] + m[6]*n[9] + m[10]*n[10] + m[14]*n[11],
m[3]*n[8] + m[7]*n[9] + m[11]*n[10] + m[15]*n[11],
m[0]*n[12] + m[4]*n[13] + m[8]*n[14] + m[12]*n[15],
m[1]*n[12] + m[5]*n[13] + m[9]*n[14] + m[13]*n[15],
m[2]*n[12] + m[6]*n[13] + m[10]*n[14] + m[14]*n[15],
m[3]*n[12] + m[7]*n[13] + m[11]*n[14] + m[15]*n[15]])
def multiply_MV(mat, v):
m = mat.values[:]
return Vector3(
m[0]*v.x + m[4]*v.y + m[8]*v.z + m[12],
m[1]*v.x + m[5]*v.y + m[9]*v.z + m[13],
m[2]*v.x + m[6]*v.y + m[10]*v.z + m[14])
def transform_vector(mat, v):
trans = multiply_MV(mat, v)
m = mat.values[:]
w = m[3]*v.x + m[7]*v.y + m[11]*v.z + m[15]
one_over_w = 1.0 / float(w)
trans.x *= one_over_w
trans.y *= one_over_w
# Don't transform z, we just leave it as a "pseudo-depth".
return trans
class Matrix4x4(object):
'''
4x4 matrix which is used in the rendering process
such as the view and perspective matrices
'''
values = [0.0] * 16
def __init__(self, contents):
'''
Constructor
'''
if len(contents) == 16:
self.values = [float(x) for x in contents]
else:
raise IndexError("input not of len 16")
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,547
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/touch/MapMover.py
|
'''
// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-08-19
@author: Neil Borle
'''
from src.utils.Geometry import radians_to_degrees
class MapMover(object):
'''
Responsible for updating the model when dragging,
zooming or rotation occurs.
'''
def on_drag(self, x_pixels, y_pixels):
pixels_to_rads = self.model.field_of_view / self.size_times_rads_to_degs
self.control_group.change_up_down(-y_pixels * pixels_to_rads)
self.control_group.change_right_left(-x_pixels * pixels_to_rads)
return True
def on_rotate(self, degrees):
if self.allow_rotation:
self.control_group.rotate(-degrees)
return True
else:
return False
def on_stretch(self, ratio):
self.control_group.zoom_by(1.0/ratio)
return True
def on_shared_preference_change(self, prefs):
self.allow_rotation = prefs.ALLOW_ROTATION
def __init__(self, model, controller_group, shared_prefs, screen_height):
'''
Constructor
'''
self.model = model
self.control_group = controller_group
self.shared_prefs = shared_prefs
self.size_times_rads_to_degs = radians_to_degrees(screen_height)
self.allow_rotation = shared_prefs.ALLOW_ROTATION
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,548
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/utils/Runnable.py
|
'''
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-07
@author: Neil Borle
'''
class Runnable(object):
'''
A Runnable class with a run method so that actions
can be queued and then run uniformly. This substitutes
for java's runnable interface.
'''
def run(self):
raise Exception("This method must be overwritten")
def __init__(self, run_method):
'''
Constructor
'''
self.run = run_method
if __name__ == "__main__":
def run_method():
print "Hello world"
r = Runnable(run_method)
r.run()
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,549
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/source/PointSource.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-16
@author: Neil Borle
'''
from Source import Source
from src.utils.Enumeration import enum
from src.units.GeocentricCoordinates import get_instance
shape_enum = enum(CIRCLE=0, STAR=1, ELLIPTICAL_GALAXY=2, \
SPIRAL_GALAXY=3, IRREGULAR_GALAXY=4, \
LENTICULAR_GALAXY=3, GLOBULAR_CLUSTER=5, \
OPEN_CLUSTER=6, NEBULA=7, HUBBLE_DEEP_FIELD=8)
class PointSource(Source):
'''
This class represents a astronomical point source,
such as a star, or a distant galaxy.
'''
def __init__(self, new_color, new_size, geo_coords=get_instance(0.0, 0.0), \
new_shape=shape_enum.CIRCLE):
'''
Constructor
'''
Source.__init__(self, new_color, geo_coords)
self.size = new_size
self.point_shape = new_shape
if __name__ == "__main__":
'''
For debugging purposes
'''
P = PointSource(0xF0F73615, 1)
print P.point_shape
print P.geocentric_coords.x
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,550
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/renderer/RenderState.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-26
@author: Neil Borle
'''
import math
from src.units.GeocentricCoordinates import GeocentricCoordinates
from src.utils.Matrix4x4 import create_identity
class RenderState(object):
'''
Contains all the state necessary for the SkyRenderer
to render properly.
'''
camera_pos = GeocentricCoordinates(0, 0, 0)
look_dir = GeocentricCoordinates(1, 0, 0)
up_dir = GeocentricCoordinates(0, 1, 0)
radius_of_view = 45.0 # in degrees
up_angle = 0.0
cos_up_angle = 1.0
sin_up_angle = 0.0
screen_width = 480 # originally 100
screen_height = 800 # originally 100
transform_to_device = create_identity()
transform_to_screen = create_identity()
night_vision_mode = False
active_sky_region_set = None
def set_camera_pos(self, pos):
self.camera_pos = pos.copy()
def set_look_dir(self, new_dir):
self.look_dir = new_dir.copy()
def set_up_dir(self, new_dir):
self.up_dir = new_dir.copy()
def set_up_angle(self, angle):
self.up_angle = angle
self.cos_up_angle = math.cos(angle)
self.sin_up_angle = math.sin(angle)
def set_screen_size(self, width, height):
self.screen_width = width
self.screen_height = height
def set_tranformation_matrices(self, to_device, to_screen):
self.transform_to_device = to_device
self.transform_to_screen = to_screen
def __init__(self):
'''
Constructor
'''
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,551
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/source/Source.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-16
@author: Neil Borle
'''
from src.units.GeocentricCoordinates import get_instance
from src.utils.Enumeration import enum
update_granularity = enum(Second=0, Minute=1, Hour=2, Day=3, Month=4, Year=5)
class Source(object):
'''
Base class for all sources since every source has features such
as position, color and granularity
'''
def __init__(self, new_color, geo_coords=get_instance(0.0, 0.0)):
'''
Constructor
'''
self.color = new_color
self.geocentric_coords = geo_coords
self.granulatriy = None
self.name_list = []
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,552
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/rendererUtil/VertexBuffer.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-03
@author: Neil Borle
'''
import numpy as np
from OpenGL import GL
from GLBuffer import GLBuffer
class VertexBuffer(object):
'''
Buffers the location of vertices such as stars (points)
to be loaded into OpenGL. Fixed point is not used in
PyOpenGL.
'''
def reset(self, num_verts):
self.num_vertices = num_verts
self.regenerate_buffer()
def reload(self):
self.gl_buffer.reload()
def add_point(self, vector3):
#fixed_x = 0xFFFFFFFF & int(vector3.x * 65536.0)
#fixed_y = 0xFFFFFFFF & int(vector3.y * 65536.0)
#fixed_z = 0xFFFFFFFF & int(vector3.z * 65536.0)
#self.vertex_buffer = np.append(self.vertex_buffer, [fixed_x, fixed_y, fixed_z], 0)
self.vertex_buffer = np.append(self.vertex_buffer, [vector3.z, vector3.y, vector3.x], 0)
def set(self, gl):
if self.num_vertices == 0:
return
if self.use_vbo and self.gl_buffer.can_use_VBO:
self.gl_buffer.bind(gl, self.vertex_buffer, 4*len(self.vertex_buffer))
gl.glVertexPointer(3, gl.GL_FLOAT, 0, None)
else:
gl.glVertexPointer(3, gl.GL_FLOAT, 0, self.vertex_buffer)
def regenerate_buffer(self):
if self.num_vertices == 0:
return
self.vertex_buffer = np.array([], dtype=np.float32)
def __init__(self, num_verts=0, vbo_bool=False):
'''
Constructor
'''
self.vertex_buffer = None
self.gl_buffer = GLBuffer(GL.GL_ARRAY_BUFFER)
self.use_vbo = vbo_bool
self.reset(num_verts)
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,553
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/layers/LayerManager.py
|
'''
// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-24
@author: Neil Borle
'''
from NewStarsLayer import NewStarsLayer
from NewConstellationsLayer import NewConstellationsLayer
from NewMessierLayer import NewMessierLayer
from PlanetsLayer import PlanetsLayer
from GridLayer import GridLayer
from EclipticLayer import EclipticLayer
from HorizonLayer import HorizonLayer
from MeteorShowerLayer import MeteorShowerLayer
from SkyGradientLayer import SkyGradientLayer
from src.utils.DebugOptions import Debug
def instantiate_layer_manager(model, shared_prefs):
'''
Add a new instance of each layer and initialize it
'''
layer_manager = LayerManager(shared_prefs)
layer_manager.add_layer(NewStarsLayer())
layer_manager.add_layer(NewMessierLayer())
layer_manager.add_layer(NewConstellationsLayer())
layer_manager.add_layer(PlanetsLayer(model))
layer_manager.add_layer(MeteorShowerLayer(model))
layer_manager.add_layer(GridLayer(24, 19))
layer_manager.add_layer(HorizonLayer(model))
layer_manager.add_layer(EclipticLayer())
layer_manager.add_layer(SkyGradientLayer(model))
if Debug.LAYER == "STARS ONLY":
layer_manager = LayerManager()
layer_manager.add_layer(NewStarsLayer())
elif Debug.LAYER == "FIRST 3":
layer_manager = LayerManager()
layer_manager.add_layer(NewStarsLayer())
layer_manager.add_layer(NewConstellationsLayer())
layer_manager.add_layer(NewMessierLayer())
layer_manager.init_layers()
return layer_manager
class LayerManager(object):
'''
Class responsible for grouping together all layers
so that they can be controlled together.
'''
def add_layer(self, layer):
self.layers.append(layer)
def init_layers(self):
for layer in self.layers:
layer.initialize()
def register_with_renderer(self, renderer_controller):
for layer in self.layers:
layer.register_with_renderer(renderer_controller)
pref_id = layer.get_preference_id()
visible_bool = self.shared_prefs.PREFERENCES[pref_id]
layer.set_visible(visible_bool)
def on_shared_preference_change(self, prefs, pref_id):
for layer in self.layers:
if layer.get_preference_id() == pref_id:
visible_bool = prefs.PREFERENCES[pref_id]
layer.set_visible(visible_bool)
def get_string(self):
return "Layer Manager"
def search_by_object_name(self):
raise NotImplementedError("not implemented")
def get_object_names_matching_prefix(self):
raise NotImplementedError("not implemented")
def is_layer_visible(self, layer):
return self.shared_prefs.PREFERENCES[layer]
def __init__(self, shared_prefs):
'''
Constructor
'''
self.shared_prefs = shared_prefs
self.layers = []
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,554
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/rendererUtil/NightVisionColorBuffer.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-05
@author: Neil Borle
'''
from ColorBuffer import ColorBuffer
class NightVisionBuffer(object):
'''
Creates and maintains two instances of color
buffers, one for night and a regular one. These
can be switched depending on what is selected.
'''
def reset(self, num_verts):
self.normal_buffer.reset(num_verts)
self.red_buffer.reset(num_verts)
def reload(self):
self.normal_buffer.reload()
self.red_buffer.reload()
def add_color(self, abgr=None, a=None, r=None, g=None, b=None):
if abgr != None:
a = int(abgr >> 24) & 0xff
b = int(abgr >> 16) & 0xff
g = int(abgr >> 8) & 0xff
r = int(abgr) & 0xff
self.normal_buffer.add_color(a, r, g, b)
avg = (r + g + b) / 3
self.red_buffer.add_color(a, avg, 0, 0)
def set(self, gl, night_vision_mode):
if night_vision_mode:
self.red_buffer.set(gl)
else:
self.normal_buffer.set(gl)
def __init__(self, num_verts=0, vbo_bool=False):
'''
Constructor
'''
self.normal_buffer = ColorBuffer(0, vbo_bool)
self.red_buffer = ColorBuffer(0, vbo_bool)
self.reset(num_verts)
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,555
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/renderer/RendererController.py
|
'''
// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: James Powell
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-28
@author: Neil Borle
'''
import threading
from Queue import Queue
from RendererControllerBase import RendererControllerBase
from src.renderer.RendererControllerBase import command_type
from src.utils.Runnable import Runnable
class RendererController(RendererControllerBase):
'''
The class for controlling atomic rendering
events. Runnable atomic sections are created and then
placed on the queue of runnable objects.
'''
class AtomicSection(RendererControllerBase):
'''
classdocs
'''
NEXT_ID = 0
lock = threading.Lock()
def to_string(self):
return "AtomicSection " + str(self.m_ID)
def release_events(self):
temp = self.queuer
self.queuer = Queue()
return temp
def __init__(self, skyrenderer):
'''
constructor
'''
RendererControllerBase.__init__(self, skyrenderer)
self.queuer = Queue()
#Use lock to synchronize
with self.lock:
self.m_ID = self.NEXT_ID
self.NEXT_ID += 1
def to_string(self):
return "RendererController"
def create_atomic(self):
return self.AtomicSection(self.renderer)
def queue_atomic(self, atomic):
def run_method():
events = atomic.release_events()
for runnable in list(events.queue):
runnable.run()
msg = "Applying " + atomic.to_string()
self.queue_runnable(msg, command_type.SYNCHRONIZATION, Runnable(run_method))
def __init__(self, skyrenderer, gl_surface_view=None):
'''
Some OpenGLES componenets need to be addressed
'''
RendererControllerBase.__init__(self, skyrenderer)
self.queuer = Queue()
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,556
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/testing/BaseTests.py
|
'''
// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-07-23
@author: Alyson Wu and Morgan Redshaw
'''
# PreconditionsTest
def testTestCheck():
'''
>>> from src.base.Preconditions import check
>>> check(True)
>>> check(False)
Traceback (most recent call last):
...
Exception: Unexpected State Encountered
'''
pass
def testCheckNotNull():
'''
>>> from src.base.Preconditions import check_not_none
>>> check_not_none('this')
>>> check_not_none(None)
Traceback (most recent call last):
...
Exception: Expected non-None, but got None.
'''
pass
def testCheckNotEmpty():
'''
>>> from src.base.Preconditions import check_not_empty
>>> check_not_empty('foo')
>>> testStrings = [None, "", " ", "\t"]
>>> for strings in testStrings:
... check_not_empty(strings)
Traceback (most recent call last):
...
Exception: Observed string was empty
'''
pass
def testCheckEqual():
'''
>>> from src.base.Preconditions import check_equal
>>> check_equal(None, None)
>>> check_equal("foo", "foo")
>>> testInputOne = [None, "foo", "bar"]
>>> testInputTwo = ["foo", None, "foo"]
>>> for i in testInputOne and testInputTwo:
... i = 0
... s1 = testInputOne[i]
... s2 = testInputTwo[i]
... check_equal(s1, s2)
... i += 1
Traceback (most recent call last):
...
Exception: inputs are not the same
'''
pass
def testCheckNotEqual():
'''
>>> from src.base.Preconditions import check_not_equal
>>> check_not_equal(None, "foo")
>>> check_not_equal("foo", None)
>>> check_not_equal("foo", "bar")
>>> s = "foo"
>>> check_not_equal(s,s)
Traceback (most recent call last):
...
Exception: expected inputs to be different
>>> check_not_equal([], [])
Traceback (most recent call last):
...
Exception: expected inputs to be different
'''
pass
def testCheckBetween():
'''
>>> from src.base.Preconditions import check_between
>>> check_between(3, 2, 4)
>>> check_between(2, 2, 4)
>>> check_between(4, 2, 4)
>>> check_between(1, 2, 4)
Traceback (most recent call last):
...
Exception: value is not in expected range
>>> check_between(5, 2, 4)
Traceback (most recent call last):
...
Exception: value is not in expected range
'''
pass
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,557
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/layers/HorizonLayer.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor, Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-24
@author: Neil Borle
'''
from time import mktime
from SourceLayer import SourceLayer
from src.source.AbstractAstronomicalSource import AbstractAstronomicalSource
from src.source.LineSource import LineSource
from src.source.TextSource import TextSource
from src.renderer.RendererObjectManager import RendererObjectManager
from src.units.GeocentricCoordinates import GeocentricCoordinates
from src.base.TimeConstants import MILLISECONDS_PER_SECOND
class HorizonLayer(SourceLayer):
'''
Identifies Nadir, the Zenith and the cardinal directions
'''
class HorizonSource(AbstractAstronomicalSource):
'''
Horizon elements extend Astronomical Sources so that they
can be rendered just as stars, constellations, ect...
'''
# The bug in the G1 rendering code in the original java is
# not present in the python code. Lines and labels are the same color.
LINE_COLOR = 0x7856B0F5
LABEL_COLOR = 0x7856B0F5
UPDATE_FREQ_MS = 1 * MILLISECONDS_PER_SECOND
def update_coords(self):
self.last_update_time_Ms = mktime(self.model.get_time())
self.zenith.assign(vector3=self.model.get_zenith())
self.nadir.assign(vector3=self.model.get_nadir())
self.north.assign(vector3=self.model.get_north())
self.south.assign(vector3=self.model.get_south())
self.east.assign(vector3=self.model.get_east())
self.west.assign(vector3=self.model.get_west())
def initialize(self):
self.update_coords()
return self
#override(AbstractAstronomicalSource)
def update(self):
update_types = set()
if abs(mktime(self.model.get_time()) - self.last_update_time_Ms > self.UPDATE_FREQ_MS):
self.update_coords()
update = RendererObjectManager().update_type.UpdatePositions
update_types = set([update])
return update_types
#override(AbstractAstronomicalSource)
def get_labels(self):
return self.text_sources
#override(AbstractAstronomicalSource)
def get_lines(self):
return self.line_sources
def __init__(self, model):
'''
constructor
'''
AbstractAstronomicalSource.__init__(self)
self.zenith = GeocentricCoordinates(0, 0, 0)
self.nadir = GeocentricCoordinates(0, 0, 0)
self.north = GeocentricCoordinates(0, 0, 0)
self.south = GeocentricCoordinates(0, 0, 0)
self.east = GeocentricCoordinates(0, 0, 0)
self.west = GeocentricCoordinates(0, 0, 0)
self.line_sources = []
self.text_sources = []
self.lastUpdateTimeMs = 0
self.model = model
vertices = [self.north, self.east, self.south, self.west, self.north]
self.line_sources.append(LineSource(vertices, self.LINE_COLOR, 1.5))
self.text_sources.append(TextSource("ZENITH", self.LABEL_COLOR, self.zenith))
self.text_sources.append(TextSource("NADIR", self.LABEL_COLOR, self.nadir))
self.text_sources.append(TextSource("NORTH", self.LABEL_COLOR, self.north))
self.text_sources.append(TextSource("SOUTH", self.LABEL_COLOR, self.south))
self.text_sources.append(TextSource("EAST", self.LABEL_COLOR, self.east))
self.text_sources.append(TextSource("WEST", self.LABEL_COLOR, self.west))
def initialize_astro_sources(self, sources):
sources.append(self.HorizonSource(self.model))
def get_layer_id(self):
return -106
def get_layer_name_id(self):
raise NotImplementedError("not implemented yet")
def get_preference_id(self):
return "source_provider.6"
def get_layer_name(self):
return "Horizon"
def __init__(self, model):
'''
Constructor
'''
SourceLayer.__init__(self, True)
self.model = model
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,558
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/layers/EclipticLayer.py
|
'''
// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor, Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-25
@author: Neil Borle
'''
from SourceLayer import SourceLayer
from src.source.AbstractAstronomicalSource import AbstractAstronomicalSource
from src.source.LineSource import LineSource
from src.source.TextSource import TextSource
from src.units.GeocentricCoordinates import get_instance
class EclipticLayer(SourceLayer):
'''
This class is the ecliptic, the apparent path of the sun
relative to the earth. This appears with the background
grid and is not parallel to the grid lines.
'''
class EclipticSource(AbstractAstronomicalSource):
'''
classdocs
'''
EPSILON = 23.439281
LINE_COLOR = 0x14BCEFF8
#override(AbstractAstronomicalSource)
def get_lines(self):
return self.line_sources
#override(AbstractAstronomicalSource)
def get_labels(self):
return self.text_sources
def __init__(self):
'''
constructor
'''
AbstractAstronomicalSource.__init__(self)
self.line_sources = []
self.text_sources = []
title = "Ecliptic"
self.text_sources.append(TextSource(title, self.LINE_COLOR,
get_instance(90.0, self.EPSILON)))
self.text_sources.append(TextSource(title, self.LINE_COLOR,
get_instance(270.0, -self.EPSILON)))
# Create line source.
ra = [0.0, 90.0, 180.0, 270.0, 0.0]
dec = [0.0, self.EPSILON, 0.0, -self.EPSILON, 0.0]
vertices = []
for i in range(0, len(ra)):
vertices.append(get_instance(ra[i], dec[i]))
self.line_sources.append(LineSource(vertices, self.LINE_COLOR, 1.5))
def initialize_astro_sources(self, sources):
sources.append(self.EclipticSource())
def get_layer_id(self):
return -105
def get_layer_name_id(self):
raise NotImplementedError("not implemented yet")
def get_preference_id(self):
return "source_provider.5"
def __init__(self):
'''
Constructor
'''
SourceLayer.__init__(self, False)
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,559
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/testing/ControlTests.py
|
'''
// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-07-26
@author: Alyson Wu and Morgan Redshaw
'''
#AstronomerModelTest
import math
tol_angle = float(0.001)
tol_length = float(0.001)
SQRT2 = math.sqrt(2)
def assertVectorEquals(v1, v2, tol_angle, tol_length):
import src.utils.Geometry as Geometry
import math
normv1 = v1.length()
normv2 = v2.length()
if abs(normv1 - normv2) > tol_length:
return False
cosineSim = Geometry.cosine_similarity(v1, v2)
cosTol = math.cos(tol_angle)
return cosineSim >= cosTol
def testAssertVectorEquals_sameVector():
# Checks that our assertion method works as intended.
'''
>>> from src.units.Vector3 import Vector3
>>> v1 = Vector3(0, 0, 1)
>>> v2 = Vector3(0, 0, 1)
>>> assertVectorEquals(v1,v2, 0.0001, 0.0001)
True
'''
pass
def testAssertVectorEquals_differentLengths():
# Checks that our assertion method works as intended.
'''
>>> from src.units.Vector3 import Vector3
>>> v1 = Vector3(0,0,1.0)
>>> v2 = Vector3(0,0,1.1)
>>> assertVectorEquals(v1,v2, 0.0001, 0.0001)
False
'''
pass
def testAssertVectorEquals_differentDirections():
# Checks that our assertion method works as intended.
'''
>>> from src.units.Vector3 import Vector3
>>> v1 = Vector3(0,0,1)
>>> v2 = Vector3(0,1,0)
>>> assertVectorEquals(v1,v2, 0.0001, 0.0001)
False
'''
pass
def testSetPhoneSensorValues_phoneFlatAtLat0Long90():
# The phone is flat, long side pointing North at lat,long = 0, 90.
'''
>>> from src.units.LatLong import LatLong
>>> from src.units.Vector3 import Vector3
>>> location = LatLong(0, 90)
>>> acceleration = Vector3(0, 0, -10)
>>> magneticField = Vector3(0, -1, 10)
>>> expectedZenith = Vector3(0, 1, 0)
>>> expectedNadir = Vector3(0, -1, 0)
>>> expectedNorth = Vector3(0, 0, 1)
>>> expectedEast = Vector3(-1, 0, 0)
>>> expectedSouth = Vector3(0, 0, -1)
>>> expectedWest = Vector3(1, 0, 0)
>>> expectedPointing = expectedNadir
>>> expectedUpAlongPhone = expectedNorth
>>> checkModelOrientation(location, acceleration, magneticField, expectedZenith, expectedNadir, expectedNorth, expectedEast, expectedSouth, expectedWest, expectedPointing, expectedUpAlongPhone)
'''
pass
def testSetPhoneSensorValues_phoneFlatAtLat45Long0():
# As previous test, but at lat, long = (45, 0)
'''
>>> from src.units.LatLong import LatLong
>>> from src.units.Vector3 import Vector3
>>> location = LatLong(45, 0)
>>> acceleration = Vector3(0, 0, -10)
>>> magneticField = Vector3(0, -10, 0)
>>> expectedZenith = Vector3(1 / SQRT2, 0, 1 / SQRT2)
>>> expectedNadir = Vector3(-1 / SQRT2, 0, -1 / SQRT2)
>>> expectedNorth = Vector3(-1 / SQRT2, 0, 1 / SQRT2)
>>> expectedEast = Vector3(0, 1, 0)
>>> expectedSouth = Vector3(1 / SQRT2, 0, -1 / SQRT2)
>>> expectedWest = Vector3(0, -1, 0)
>>> expectedPointing = expectedNadir
>>> expectedUpAlongPhone = expectedNorth
>>> checkModelOrientation(location, acceleration, magneticField, expectedZenith, expectedNadir, expectedNorth, expectedEast, expectedSouth, expectedWest, expectedPointing, expectedUpAlongPhone)
'''
pass
def testSetPhoneSensorValues_phoneFlatOnEquatorAtMeridian():
# As previous test, but at lat, long = (0, 0)
'''
>>> from src.units.LatLong import LatLong
>>> from src.units.Vector3 import Vector3
>>> location = LatLong(0, 0)
>>> acceleration = Vector3(0, 0, -10)
>>> magneticField = Vector3(0, -1, 10)
>>> expectedZenith = Vector3(1, 0, 0)
>>> expectedNadir = Vector3(-1, 0, 0)
>>> expectedNorth = Vector3(0, 0, 1)
>>> expectedEast = Vector3(0, 1, 0)
>>> expectedSouth = Vector3(0, 0, -1)
>>> expectedWest = Vector3(0, -1, 0)
>>> expectedPointing = expectedNadir
>>> expectedUpAlongPhone = expectedNorth
>>> checkModelOrientation(location, acceleration, magneticField, expectedZenith, expectedNadir, expectedNorth, expectedEast, expectedSouth, expectedWest, expectedPointing, expectedUpAlongPhone)
'''
pass
def testSetPhoneSensorValues_phoneLandscapeFacingEastOnEquatorAtMeridian():
# As previous test, but with the phone vertical, but in landscape mode and pointing east.
'''
>>> from src.units.LatLong import LatLong
>>> from src.units.Vector3 import Vector3
>>> location = LatLong(0, 0)
>>> acceleration = Vector3(10, 0, 0)
>>> magneticField = Vector3(-10, 1, 0)
>>> expectedZenith = Vector3(1, 0, 0)
>>> expectedNadir = Vector3(-1, 0, 0)
>>> expectedNorth = Vector3(0, 0, 1)
>>> expectedEast = Vector3(0, 1, 0)
>>> expectedSouth = Vector3(0, 0, -1)
>>> expectedWest = Vector3(0, -1, 0)
>>> expectedPointing = expectedEast
>>> expectedUpAlongPhone = expectedSouth
>>> checkModelOrientation(location, acceleration, magneticField, expectedZenith, expectedNadir, expectedNorth, expectedEast, expectedSouth, expectedWest, expectedPointing, expectedUpAlongPhone)
'''
def testSetPhoneSensorValues_phoneStandingUpFacingNorthOnEquatorAtMeridian():
# As previous test, but in portrait mode facing north.
'''
>>> from src.units.LatLong import LatLong
>>> from src.units.Vector3 import Vector3
>>> location = LatLong(0, 0)
>>> acceleration = Vector3(0, -10, 0)
>>> magneticField = Vector3(0, 10, 1)
>>> expectedZenith = Vector3(1, 0, 0)
>>> expectedNadir = Vector3(-1, 0, 0)
>>> expectedNorth = Vector3(0, 0, 1)
>>> expectedEast = Vector3(0, 1, 0)
>>> expectedSouth = Vector3(0, 0, -1)
>>> expectedWest = Vector3(0, -1, 0)
>>> expectedPointing = expectedNorth
>>> expectedUpAlongPhone = expectedZenith
>>> checkModelOrientation(location, acceleration, magneticField, expectedZenith, expectedNadir, expectedNorth, expectedEast, expectedSouth, expectedWest, expectedPointing, expectedUpAlongPhone)
'''
def checkModelOrientation(location, acceleration, magneticField, expectedZenith, expectedNadir, expectedNorth, expectedEast, expectedSouth, expectedWest, expectedPointing, expectedUpAlongPhone):
# For now only test a model with no magnetic correction.
import datetime as dt
import calendar
import time
from src.control.AstronomerModel import AstronomerModel
from src.control.ZeroMagneticDeclinationCalculator import ZeroMagneticDeclinationCalculator as ZMDC
Astronomer = AstronomerModel(ZMDC())
Astronomer.set_location(location)
class myClock():
clock = dt.datetime(2009, 3, 20, 12, 07, 24).timetuple()
def get_time(self):
return calendar.timegm(self.clock)
# This date is special as RA, DEC = (0, 0) is directly overhead at the equator on the Greenwich meridian.
# 12:07 March 20th 2009
Astronomer.set_clock(myClock())
Astronomer.set_phone_sensor_values(acceleration, magneticField)
worked = True
worked = assertVectorEquals(expectedZenith, Astronomer.get_zenith(), tol_length, tol_angle) & worked
worked = assertVectorEquals(expectedNadir, Astronomer.get_nadir(), tol_length, tol_angle) & worked
worked = assertVectorEquals(expectedNorth, Astronomer.get_north(), tol_length, tol_angle) & worked
worked = assertVectorEquals(expectedEast, Astronomer.get_east(), tol_length, tol_angle) & worked
worked = assertVectorEquals(expectedSouth, Astronomer.get_south(), tol_length, tol_angle) & worked
worked = assertVectorEquals(expectedWest, Astronomer.get_west(), tol_length, tol_angle) & worked
worked = assertVectorEquals(expectedPointing, Astronomer.get_pointing().get_line_of_sight(), tol_length, tol_angle) & worked
worked = assertVectorEquals(expectedUpAlongPhone, Astronomer.get_pointing().get_perpendicular(), tol_length, tol_angle) & worked
# AstronomerModelWithMagneticVariationTest
# def MagneticDeclinationCalculation(angle):
# angle = angle
# def get_declination(self):
# return angle
# def testAssertVectorEquals():
# '''
# >>> from units.Vector3 import Vector3
# >>> v1 = Vector3(0,0,1)
# >>> v2 = Vector3(0,0,1)
# >>> assertVectorEquals(v1,v2,0.0001,0.0001)
# True
# '''
# pass
# def testFlatOnEquatorMag0Degrees():
# '''
# >>> from units.LatLong import LatLong
# >>> from units.Vector3 import Vector3
# >>> location = LatLong(0, 0)
# >>> acceleration = Vector3(0, 0, -10)
# >>> magneticField = Vector3(0, -5, -10)
# >>> expectedZenith = Vector3(1, 0, 0)
# >>> expectedNadir = Vector3(-1, 0, 0)
# >>> expectedNorth = Vector3(0, 0, 1)
# >>> expectedEast = Vector3(0, 1, 0)
# >>> expectedSouth = Vector3(0, 0, -1)
# >>> expectedWest = Vector3(0, -1, 0)
# >>> expectedPointing = expectedNadir
# >>> expectedUpAlongPhone = expectedNorth
# >>> checkPointing(float(0.0), location, acceleration, magneticField, expectedZenith, expectedNadir, expectedNorth, expectedEast, expectedSouth, expectedWest, expectedPointing, expectedUpAlongPhone)
# '''
# pass
#
# def testFlatOnEquatorMagN45DegreesW():
# '''
# >>> from units.LatLong import LatLong
# >>> from units.Vector3 import Vector3
# >>> location = LatLong(0, 0)
# >>> acceleration = Vector3(0, 0, -10)
# >>> magneticField = Vector3(1, -1, -10)
# >>> expectedZenith = Vector3(1, 0, 0)
# >>> expectedNadir = Vector3(-1, 0, 0)
# >>> expectedNorth = Vector3(0, 0, 1)
# >>> expectedEast = Vector3(0, 1, 0)
# >>> expectedSouth = Vector3(0, 0, -1)
# >>> expectedWest = Vector3(0, -1, 0)
# >>> expectedPointing = expectedNadir
# >>> expectedUpAlongPhone = expectedNorth
# >>> checkPointing(float(-45.0), location, acceleration, magneticField, expectedZenith, expectedNadir, expectedNorth, expectedEast, expectedSouth, expectedWest, expectedPointing, expectedUpAlongPhone)
# '''
# pass
#
# def testStandingUpOnEquatorMagN10DegreesEast():
# '''
# >>> from units.LatLong import LatLong
# >>> from units.Vector3 import Vector3
# >>> import utils.Geometry as Geometry
# >>> import math
# >>> location = LatLong(0, 0)
# >>> acceleration = Vector3(0, -10, 0)
# >>> magneticField = Vector3(-math.sin(Geometry.degrees_to_radians(10)), 10, math.cos(Geometry.degrees_to_radians(10)))
# >>> expectedZenith = Vector3(1, 0, 0)
# >>> expectedNadir = Vector3(-1, 0, 0)
# >>> expectedNorth = Vector3(0, 0, 1)
# >>> expectedEast = Vector3(0, 1, 0)
# >>> expectedSouth = Vector3(0, 0, -1)
# >>> expectedWest = Vector3(0, -1, 0)
# >>> expectedPointing = expectedNorth
# >>> expectedUpAlongPhone = expectedZenith
# >>> checkPointing(10, location, acceleration, magneticField, expectedZenith, expectedNadir, expectedNorth, expectedEast, expectedSouth, expectedWest, expectedPointing, expectedUpAlongPhone)
# '''
#
# def checkPointing(magDeclination, location, acceleration, magneticField, expectedZenith, expectedNadir, expectedNorth, expectedEast, expectedSouth, expectedWest, expectedPointing, expectedUpAlongPhone):
# import datetime as dt
# import time
# from control.AstronomerModel import AstronomerModel
# from control.RealMagneticDeclinationCalculator import RealMagneticDeclinationCalculator as RMDC
# Astronomer = AstronomerModel(RMDC())
# MagneticDeclinationCalculation(magDeclination)
# Astronomer.set_location(location)
#
# class myClock():
# clock = dt.datetime(2009, 3, 20, 12, 07, 24).timetuple()
# def get_time(self):
# return calendar.timegm(self.clock)
#
# Astronomer.set_clock(myClock())
# Astronomer.set_phone_sensor_values(acceleration, magneticField)
# pointing = Astronomer.get_pointing().get_line_of_sight()
# upAlongPhone = Astronomer.get_pointing().get_perpendicular()
# north = Astronomer.get_north()
# east = Astronomer.get_east()
# south = Astronomer.get_south()
# west = Astronomer.get_west()
# zenith = Astronomer.get_zenith()
# nadir = Astronomer.get_nadir()
# assertVectorEquals(expectedZenith, zenith, tol_length, tol_angle)
# assertVectorEquals(expectedNadir, nadir, tol_length, tol_angle)
# assertVectorEquals(expectedNorth, north, tol_length, tol_angle)
# assertVectorEquals(expectedEast, east, tol_length, tol_angle)
# assertVectorEquals(expectedSouth, south, tol_length, tol_angle)
# assertVectorEquals(expectedWest, west, tol_length, tol_angle)
# assertVectorEquals(expectedPointing, pointing, tol_length, tol_angle)
# assertVectorEquals(expectedUpAlongPhone, upAlongPhone, tol_length, tol_angle)
#
# def testFlatLat45Long0MagN180Degrees():
# '''
# >>> from units.LatLong import LatLong
# >>> from units.Vector3 import Vector3
# >>> location = LatLong(45, 0)
# >>> acceleration = Vector3(0, 0, -10)
# >>> magneticField = Vector3(0, 10, 0)
# >>> expectedZenith = Vector3(1 / SQRT2, 0, 1 / SQRT2)
# >>> expectedNadir = Vector3(-1 / SQRT2, 0, -1 / SQRT2)
# >>> expectedNorth = Vector3(-1 / SQRT2, 0, 1 / SQRT2)
# >>> expectedEast = Vector3(0, 1, 0)
# >>> expectedSouth = Vector3(1 / SQRT2, 0, -1 / SQRT2)
# >>> expectedWest = Vector3(0, -1, 0)
# >>> expectedPointing = expectedNadir
# >>> expectedUpAlongPhone = expectedNorth
# >>> checkPointing(180, location, acceleration, magneticField, expectedZenith, expectedNadir, expectedNorth, expectedEast, expectedSouth, expectedWest, expectedPointing, expectedUpAlongPhone)
# '''
#ControllerGroupTest
def ControllerGroupTests():
'''
>>> import src.control.Controller as Controller
>>> import src.control.ControllerGroup as ControllerGroup
>>> controllerGroup = ControllerGroup.create_controller_group()
>>> controller1 = Controller.Controller()
>>> controller2 = Controller.Controller()
>>> controllerGroup.add_controller(controller1)
>>> controllerGroup.add_controller(controller2)
'''
pass
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,560
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/provider/OrbitalElements.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Kevin Serafini, Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-20
@author: Neil Borle
'''
import math
from src.utils.Geometry import mod_2_pi
class OrbitalElements(object):
'''
This class wraps the six parameters which define the path an object takes as
it orbits the sun.
The equations come from JPL's Solar System Dynamics site:
http://ssd.jpl.nasa.gov/?planet_pos
The original source for the calculations is based on the approximations described in:
Van Flandern T. C., Pulkkinen, K. F. (1979): "Low-Precision Formulae for
Planetary Positions", 1979, Astrophysical Journal Supplement Series, Vol. 41,
pp. 391-411.
'''
EPSILON = 1.0e-6
distance = None #Mean distance (AU)
eccentricity = None #Eccentricity of orbit
inclination = None #Inclination of orbit (AngleUtils.RADIANS)
ascending_node = None #Longitude of ascending node (AngleUtils.RADIANS)
perihelion = None #Longitude of perihelion (AngleUtils.RADIANS)
mean_longitude= None #Mean longitude (AngleUtils.RADIANS)
def get_anomaly(self):
'''
compute anomaly using mean anomaly and eccentricity
returns value in radians
'''
m = self.mean_longitude - self.perihelion
e = self.eccentricity
e0 = m + e * math.sin(m) * (1.0 + e * math.cos(m))
counter = 0
while(counter <= 100):
e1 = e0
e0 = e1 - (e1 - e * math.sin(e1) - m) / (1.0 - e * math.cos(e1))
if math.fabs(e0 - e1) > self.EPSILON:
break
counter += 1
v = 2.0 * math.atan(math.sqrt((1 + e) / (1 - e)) * math.tan(0.5 * e0))
return mod_2_pi(v)
def to_string(self):
l = []
l.append("Mean Distance: " + str(self.distance) + " (AU)\n");
l.append("Eccentricity: " + str(self.eccentricity) + "\n");
l.append("Inclination: " + str(self.inclination) + " (AngleUtils.RADIANS)\n");
l.append("Ascending Node: " + str(self.ascending_node) + " (AngleUtils.RADIANS)\n");
l.append("Perihelion: " + str(self.perihelion) + " (AngleUtils.RADIANS)\n");
l.append("Mean Longitude: " + str(self.mean_longitude) + " (AngleUtils.RADIANS)\n");
return ''.join(l)
def __init__(self, d, e, i, a, p, l):
'''
Constructor
'''
self.distance = d
self.eccentricity = e
self.inclination = i
self.ascending_node = a
self.perihelion = p
self.mean_longitude = l
if __name__ == "__main__":
'''
For debugging purposes
'''
OE = OrbitalElements(54, 0.5, 1, 87, 93, 30)
print OE.get_anomaly()
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,561
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/layers/PlanetsLayer.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor, Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-26
@author: Neil Borle
'''
from SourceLayer import SourceLayer
from src.provider.PlanetSource import PlanetSource
from src.provider.Planet import Planet, res
class PlanetsLayer(SourceLayer):
'''
Manages displaying the other planets, the sun and the moon.
'''
def initialize_astro_sources(self, sources):
for key in res.keys():
p = Planet(key, res[key][0], res[key][1], res[key][2])
sources.append(PlanetSource(p, self.model))
def get_layer_id(self):
return -103
def get_layer_name_id(self):
raise NotImplementedError("not implemented yet")
def get_preference_id(self):
return "source_provider.3"
def __init__(self, model):
'''
Constructor
'''
SourceLayer.__init__(self, True)
self.model = model
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,562
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/units/GeocentricCoordinates.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-16
@author: Neil Borle
'''
import math
from Vector3 import Vector3
def get_instance(ra, dec):
'''
Convert ra and dec to x,y,z where the point is place on the unit sphere.
'''
coords = GeocentricCoordinates(0.0, 0.0, 0.0)
coords.update_from_ra_dec(ra, dec)
return coords
def get_instance_from_list(l):
'''
Convert ra and dec to x,y,z where the point is place on the unit sphere.
'''
return GeocentricCoordinates(l[0], l[1], l[2])
def get_instance_from_vector3(v3):
'''
Convert ra and dec to x,y,z where the point is place on the unit sphere.
'''
return GeocentricCoordinates(v3.x, v3.y, v3.z)
class GeocentricCoordinates(Vector3):
'''
This class corresponds to an object's location in Euclidean space
when it is projected onto a unit sphere (with the Earth at the
center).
'''
def update_from_ra_dec(self, ra, dec):
'''
given radians and declination calculate
the x, y and z coords on the unit sphere
'''
ra_radians = ra * (math.pi / 180.0)
dec_radians = dec * (math.pi / 180.0)
self.x = math.cos(ra_radians) * math.cos(dec_radians)
self.y = math.sin(ra_radians) * math.cos(dec_radians)
self.z = math.sin(dec_radians)
def update_from_list(self, l):
self.x = l[0]
self.y = l[1]
self.z = l[2]
def copy(self):
return GeocentricCoordinates(self.x, self.y, self.z)
def __init__(self, new_x, new_y, new_z):
'''
Constructor
'''
Vector3.__init__(self, new_x, new_y, new_z)
if __name__ == "__main__":
'''
For debugging purposes
'''
GC = GeocentricCoordinates(4.0, 5.0, 0.0)
print GC.x, GC.y, GC.z
GC.assign(vector3=Vector3(1.0, 3.0, 5.0))
print GC.to_float_array()
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,563
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/utils/ColorParser.py
|
'''
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-20
@author: Neil Borle
'''
import sys
handle = open(sys.argv[1], 'r')
handle2 = open(sys.argv[2], 'w')
for line in handle.readlines():
'''
used for parsing color xml file from
http://stackoverflow.com/questions/3769762/android-color-xml-resource-file
'''
split_line = line.split('"')
color_code_int = split_line[2].split('<')[0]
color_code = color_code_int.split('#')[1]
print split_line[1].upper() + "=" + color_code +", \\"
handle2.write(split_line[1].upper() + "=0x" + color_code +", \\" + "\n")
handle.close()
handle2.close()
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,564
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/renderer/SkyRenderer.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-26
@author: Neil Borle
'''
import math
import numpy as np
from OpenGL import GL
from PySide.QtOpenGL import QGLWidget
from RenderState import RenderState
from SkyBox import SkyBox
from OverlayManager import OverlayManager
from PointObjectManager import PointObjectManager
from PolyLineObjectManager import PolyLineObjectManager
from LabelObjectManager import LabelObjectManager
from ImageObjectManager import ImageObjectManager
from src.rendererUtil.TextureManager import TextureManager
from src.rendererUtil.GLBuffer import GLBuffer
from src.rendererUtil.SkyRegionMap import SkyRegionMap
from src.units.GeocentricCoordinates import GeocentricCoordinates
from src.utils import Matrix4x4
from src.utils.VectorUtil import cross_product
from src.utils.DebugOptions import Debug
class SkyRenderer(QGLWidget):
'''
Main class that handles all of the rendering
'''
class ManagerReloadData(object):
'''
encapsulates what is needed to reload a manager
'''
def __init__(self, mgr, reload_bool):
self.manager = mgr
self.full_reload = reload_bool
# Indicates whether the transformation matrix has changed since the last
# time we started rendering
must_update_view = True
must_update_projection = True
def paintGL(self):
# Initialize any of the unloaded managers.
for m_reload_data in self.managers_to_reload:
m_reload_data.manager.reload(GL, m_reload_data.full_reload)
self.managers_to_reload = []
self.maybe_update_matrices(GL)
# Determine which sky regions should be rendered.
self.render_state.active_sky_region_set = \
SkyRegionMap().get_active_regions(
self.render_state.look_dir,
self.render_state.radius_of_view,
self.render_state.screen_width / float(self.render_state.screen_height))
GL.glClear(GL.GL_COLOR_BUFFER_BIT)
for managers in self.layers_to_managers.values():
# reverse to render images, text, lines then points
for manager in managers[::-1]:
manager.draw(GL)
self.check_for_errors(GL)
# Queue updates for the next frame.
for update in self.update_closures:
update.run()
def initializeGL(self):
GL.glEnable(GL.GL_DITHER);
# Some one-time OpenGL initialization can be made here
# probably based on features of this particular context
GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT,
GL.GL_FASTEST)
GL.glClearColor(0, 0, 0, 0)
GL.glEnable(GL.GL_CULL_FACE)
GL.glShadeModel(GL.GL_SMOOTH)
GL.glDisable(GL.GL_DEPTH_TEST)
# Release references to all of the old textures.
self.texture_manager.reset()
extensions = GL.glGetString(GL.GL_EXTENSIONS)
# Determine if the phone supports VBOs or not, and set this on the GLBuffer.
can_use_vbo = False
if "GL_OES_vertex_buffer_object" in extensions: # this will never pass at the moment
can_use_vbo = True
# VBO support on the Cliq and Behold is broken and say they can
# use them when they can't. Explicitly disable it for these devices.
#bad_models = ["MB200", "MB220", "Behold" ]
#for (String model : bad_models) {
# if (android.os.Build.MODEL.contains(model)) {
# can_use_vbo = false;
# }
#}
setattr(GLBuffer, "can_use_VBO", can_use_vbo)
# Reload all of the managers.
for rom in self.all_managers:
rom.reload(GL, True)
def resizeGL(self, width, height):
self.render_state.set_screen_size(width, height)
self.overlay_manager.resize(GL, width, height)
# Need to set the matrices.
self.must_update_view = True
self.must_update_projection = True
GL.glViewport(0, 0, width, height)
def set_radius_of_view(self, deg):
self.render_state.radius_of_view = deg
self.must_update_projection = True
def add_update_closure(self, update):
self.update_closures.append(update)
def remove_update_callback(self, update):
if update in self.update_closures:
i = self.update_closures.index(update)
self.update_closures.pop(i)
def set_viewer_up_direction(self, gc_up):
self.overlay_manager.set_view_up_direction(gc_up)
def add_object_manager(self, m):
m.render_state = self.render_state
m.listener = self.update_listener
self.all_managers.append(m)
self.managers_to_reload.append(self.ManagerReloadData(m, True))
if m.layer in self.layers_to_managers.keys():
self.layers_to_managers[m.layer].append(m)
else:
self.layers_to_managers[m.layer] = [m]
def remove_object_manager(self, m):
if m in self.all_managers:
index = self.all_managers.index(m)
self.all_managers.pop(index)
if m.layer in self.layers_to_managers.keys() and \
m in self.layers_to_managers[m.layer]:
index = self.layers_to_managers[m.layer].index(m)
self.layers_to_managers[m.layer].pop(index)
def enable_sky_gradient(self, sun_position):
self.sky_box.set_sun_position(sun_position)
self.sky_box.enabled = True
def disable_sky_gradient(self):
self.sky_box.enabled = False
def enable_search_overlay(self, gc_target, target_name):
raise NotImplementedError("not implemented yet")
def disable_search_overlay(self):
raise NotImplementedError("not implemented yet")
def set_night_vision_mode(self, enabled_bool):
self.render_state.night_vision_mode = enabled_bool
def set_text_angle(self, rad):
TWO_OVER_PI = 2.0 / math.pi
PI_OVER_TWO = math.pi / 2.0
new_angle = round(rad * TWO_OVER_PI) * PI_OVER_TWO
self.render_state.up_angle = new_angle
def set_view_orientation(self, dir_x, dir_y, dir_z,
up_x, up_y, up_z):
# Normalize the look direction
dir_len = math.sqrt(dir_x*dir_x + dir_y*dir_y + dir_z*dir_z)
one_over_dir_len = 1.0 / float(dir_len)
dir_x *= one_over_dir_len
dir_y *= one_over_dir_len
dir_z *= one_over_dir_len
# We need up to be perpendicular to the look direction, so we subtract
# off the projection of the look direction onto the up vector
look_dot_up = dir_x * up_x + dir_y * up_y + dir_z * up_z
up_x -= look_dot_up * dir_x
up_y -= look_dot_up * dir_y
up_z -= look_dot_up * dir_z
# Normalize the up vector
up_len = math.sqrt(up_x*up_x + up_y*up_y + up_z*up_z)
one_over_up_len = 1.0 / float(up_len)
up_x *= one_over_up_len
up_y *= one_over_up_len
up_z *= one_over_up_len
self.render_state.set_look_dir(GeocentricCoordinates(dir_x, dir_y, dir_z))
self.render_state.set_up_dir(GeocentricCoordinates(up_x, up_y, up_z))
self.must_update_view = True
self.overlay_manager.set_view_orientation(GeocentricCoordinates(dir_x, dir_y, dir_z),
GeocentricCoordinates(up_x, up_y, up_z))
def get_width(self):
return self.render_state.screen_width
def get_height(self):
return self.render_state.screen_height
def check_for_errors(self, gl):
error = gl.glGetError()
if error != 0:
raise RuntimeError("GL error: " + str(error))
def update_view(self, gl):
# Get a vector perpendicular to both, pointing to the right, by taking
# lookDir cross up.
look_dir = self.render_state.look_dir.copy()
up_dir = self.render_state.up_dir.copy()
right = cross_product(look_dir, up_dir)
if self.DEBUG_MODE != None:
from src.units.Vector3 import Vector3
look_dir = Vector3(Debug.LOOKDIRVECTORS[self.DEBUG_MODE][0],
Debug.LOOKDIRVECTORS[self.DEBUG_MODE][1],
Debug.LOOKDIRVECTORS[self.DEBUG_MODE][2])
up_dir = Vector3(Debug.UPDIRVECTORS[self.DEBUG_MODE][0],
Debug.UPDIRVECTORS[self.DEBUG_MODE][1],
Debug.UPDIRVECTORS[self.DEBUG_MODE][2])
right = Vector3(Debug.RIGHTVECTORS[self.DEBUG_MODE][0],
Debug.RIGHTVECTORS[self.DEBUG_MODE][1],
Debug.RIGHTVECTORS[self.DEBUG_MODE][2])
self.view_matrix = Matrix4x4.create_view(look_dir, up_dir, right)
gl.glMatrixMode(gl.GL_MODELVIEW)
adjust_matrix = Matrix4x4.Matrix4x4([0.0, 0.0, -1.0, 0.0,
0.0, 1.0, -0.0, 0.0,
1.0, 0.0, -0.0, 0.0,
0.0, 0.0, 0.0, 1.0])
matrix = Matrix4x4.multiply_MM(self.view_matrix, adjust_matrix)
# Invert the left/right rotation of the matrix
matrix.values[2] *= -1
matrix.values[8] *= -1
# Invert these so that we don't rotate in and out of the unit sphere
matrix.values[1] *= -1
matrix.values[4] *= -1
matrix = np.array(matrix.values, dtype=np.float32)
#matrix = np.array(self.view_matrix.values, dtype=np.float32)
gl.glLoadMatrixf(matrix)
def update_perspective(self, gl):
if self.DEBUG_MODE != None:
self.render_state.radius_of_view = Debug.RADIUSOFVIEW
self.projection_matrix = Matrix4x4.create_perspective_projection(
self.get_width(),
self.get_height(),
self.render_state.radius_of_view * 3.141593 / 360.0)
gl.glMatrixMode(gl.GL_PROJECTION)
matrix = np.array(self.projection_matrix.values, dtype=np.float32)
gl.glLoadMatrixf(matrix)
# The image is mirrored so scale it to make the polygon fronts into backs
gl.glScalef(-1.0, 1.0, 1.0)
# Switch back to the model view matrix.
gl.glMatrixMode(gl.GL_MODELVIEW)
def maybe_update_matrices(self, gl):
update_transform = self.must_update_view or self.must_update_projection
if self.must_update_view:
self.update_view(gl)
self.must_update_view = False
if self.must_update_projection:
self.update_perspective(gl)
self.must_update_projection = False
if update_transform:
# Device coordinates are a square from (-1, -1) to (1, 1). Screen
# coordinates are (0, 0) to (width, height). Both coordinates
# are useful in different circumstances, so we'll pre-compute
# matrices to do the transformations from world coordinates
# into each of these.
transform_to_device = Matrix4x4.multiply_MM(self.projection_matrix, self.view_matrix)
translate = Matrix4x4.create_translation(1.0, 1.0, 0.0)
scale = Matrix4x4.create_scaling(self.render_state.screen_width * 0.5,
self.render_state.screen_height * 0.5, 1)
transform_to_screen = \
Matrix4x4.multiply_MM(Matrix4x4.multiply_MM(scale, translate), transform_to_device)
self.render_state.set_tranformation_matrices(transform_to_device, transform_to_screen)
def create_point_manager(self, new_layer):
return PointObjectManager(new_layer, self.texture_manager)
def create_line_manager(self, new_layer):
return PolyLineObjectManager(new_layer, self.texture_manager)
def create_label_manager(self, new_layer):
return LabelObjectManager(self, new_layer, self.texture_manager)
def create_image_manager(self, new_layer):
return ImageObjectManager(new_layer, self.texture_manager)
def __init__(self, debug_mode=None):
'''
Constructor
'''
QGLWidget.__init__(self)
self.DEBUG_MODE = debug_mode
self.texture_manager = TextureManager()
self.render_state = RenderState()
self.projection_matrix = None
self.view_matrix = None
self.update_closures = []
self.all_managers = []
self.managers_to_reload = []
self.layers_to_managers = {}
def queue_for_reload(rom, full_reload):
self.managers_to_reload.append(self.ManagerReloadData(rom, full_reload))
self.update_listener = queue_for_reload
# The skybox should go behind everything.
self.sky_box = SkyBox(0x10000000, self.texture_manager)
self.sky_box.enabled = False
self.add_object_manager(self.sky_box)
#The overlays go on top of everything.
self.overlay_manager = OverlayManager(0xEFFFFFFF, self.texture_manager)
self.add_object_manager(self.overlay_manager)
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,565
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/rendererUtil/GLBuffer.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: James Powell
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-02
@author: Neil Borle
'''
from numpy import array_equal, empty_like
class GLBuffer(object):
'''
Buffer for OpenGL which encapsulates the buffer
binding and unbinding.
'''
can_use_VBO = False
def unbind(self, gl):
if self.can_use_VBO:
gl.glBindBuffer(gl.GL_ARRAY_BUFFER, 0)
gl.glBindBuffer(gl.GL_ELEMENT_ARRAY_BUFFER, 0)
def bind(self, gl, m_buffer, m_buff_size):
if self.can_use_VBO:
self.maybe_regen_buffer(gl, m_buffer, m_buff_size)
gl.glBindBuffer(self.buffer_type, self.buffer_id)
else:
raise Exception("Cannot use VBOs")
def reload(self):
# Just reset all of the values so we'll reload on the next call
# to maybeRegenerateBuffer.
self.buffer = None
self.buffer_size = 0
self.buffer_id = -1
def maybe_regen_buffer(self, gl, m_buffer, m_buff_size):
if not array_equal(self.buffer, m_buffer) or self.buffer_size != m_buff_size:
self.buffer = empty_like(m_buffer)
self.buffer = m_buffer[:]
self.buffer_size = m_buff_size
if self.buffer_id == -1:
self.buffer_id = gl.glGenBuffers(1)
gl.glBindBuffer(self.buffer_type, self.buffer_id)
gl.glBufferData(self.buffer_type, m_buff_size, m_buffer, gl.GL_STATIC_DRAW)
def __init__(self, b_type):
'''
Constructor
'''
self.buffer = None
self.buffer_size = 0
self.buffer_id = -1
self.buffer_type = b_type
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,566
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/source/AstronomicalSource.py
|
'''
// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-16
@author: Neil Borle
'''
from Source import Source
from src.utils.Colors import colors
class AstronomicalSource(Source):
'''
A state storage class for attributes of an
astronomical source
'''
def add_image(self, image):
self.image_sources.append(image)
def add_line(self, line):
self.line_sources.append(line)
def add_point(self, point):
self.point_sources.append(point)
def add_label(self, label):
self.text_sources.append(label)
def __init__(self, new_color=colors.WHITE):
'''
Constructor
'''
Source.__init__(self, new_color)
self.level = None
self.names = []
self.image_sources = []
self.line_sources = []
self.point_sources = []
self.text_sources = []
if __name__ == "__main__":
'''
For debugging purposes
'''
new = AstronomicalSource()
print new.point_sources
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,567
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/units/HeliocentricCoordinates.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-19
@author: Neil Borle
'''
import math
from Vector3 import Vector3
def get_instance(orbital_ele=None, planet=None, t_struct=None):
'''
Get the location of an object in heliocentric coordinates
given either an orbital element or a planet.
'''
if orbital_ele == None and planet == None: raise Exception("both None")
if orbital_ele == None:
orbital_ele = planet.get_orbital_elements(t_struct)
anomaly = orbital_ele.get_anomaly()
ecc = orbital_ele.eccentricity
radius = orbital_ele.distance * (1 - ecc * ecc) \
/ (1 + ecc * math.cos(anomaly))
per = orbital_ele.perihelion
asc = orbital_ele.ascending_node
inc = orbital_ele.inclination
xh = radius * (math.cos(asc) * math.cos(anomaly + per - asc) - \
math.sin(asc) * math.sin(anomaly + per - asc) * \
math.cos(inc))
yh = radius * (math.sin(asc) * math.cos(anomaly + per - asc) + \
math.cos(asc) * math.sin(anomaly + per - asc) * \
math.cos(inc))
zh = radius * (math.sin(anomaly + per - asc) * math.sin(inc))
return HeliocentricCoordinates(radius, xh, yh, zh)
class HeliocentricCoordinates(Vector3):
'''
Location of an object in heliocentric coordinates
'''
OBLIQUITY = 23.439281 * (math.pi / 180.0)
radius = 0
def subtract(self, helio_coords):
self.x -= helio_coords.x
self.y -= helio_coords.y
self.z -= helio_coords.z
def calculate_equitorial_coords(self):
return HeliocentricCoordinates(self.radius, self.x, \
self.y * math.cos(self.OBLIQUITY) - self.z * math.sin(self.OBLIQUITY), \
self.y * math.sin(self.OBLIQUITY) + self.z * math.cos(self.OBLIQUITY))
def distance_from(self, helio_coord):
dx = self.x - helio_coord.x
dy = self.y - helio_coord.y
dz = self.z - helio_coord.z
return math.sqrt(dx * dx + dy * dy + dz * dz)
def to_string(self):
return "({0}, {1}, {2}, {3})".format(self.x, self.y, \
self.z, self.radius)
def __init__(self, rad, xh, yh, zh):
'''
Constructor
'''
Vector3.__init__(self, xh, yh, zh)
self.radius = rad
if __name__ == "__main__":
'''
For debugging purposes
'''
from provider.OrbitalElements import OrbitalElements
HC = HeliocentricCoordinates(1000, 1, 0, 0)
HC2 = HC.get_instance(OrbitalElements(54, 0.5, 1, 87, 93, 30))
print HC2.length()
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,568
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/rendererUtil/LabelMaker.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-10
@author: Neil Borle
'''
import math
import numpy as np
from PySide.QtGui import QBitmap, QColor, QFont, QImage, QFontMetrics, QPainter
from PySide.QtOpenGL import QGLWidget
class LabelMaker(object):
'''
Creates a texture and paints text on top of it. This is then rendered
within an appropriately coloured rectangle.
'''
class LabelData(object):
'''
A class which contains data that describes a label and
its position in the texture.
'''
def set_texture_data(self, width_pixels, height_pixels,
crop_u, crop_v, crop_w, crop_h,
texel_width, texel_height):
self.width_in_pixels = width_pixels
self.height_in_pixels = height_pixels
text_coords_list = [0.0]*8
# lower left
text_coords_list[0] = crop_u * texel_width
text_coords_list[1] = crop_v * texel_height
# upper left
text_coords_list[2] = crop_u * texel_width
text_coords_list[3] = (crop_v + crop_h) * texel_height
# lower right
text_coords_list[4] = (crop_u + crop_w) * texel_width
text_coords_list[5] = crop_v * texel_height
# upper right
text_coords_list[6] = (crop_u + crop_w) * texel_width
text_coords_list[7] = (crop_v + crop_h) * texel_height
self.text_coords = np.array(text_coords_list, dtype=np.float32)
self.crop = [crop_u, crop_v, crop_w, crop_h]
def __init__(self, m_string='', m_color=0xFFFFFFFF, m_font_size=24):
'''
constructor
'''
self.string = m_string
self.color = m_color
self.font_size = m_font_size
self.width_in_pixels = 0
self.height_in_pixels = 0
self.text_coords = None
self.crop = None
def initialize(self, gl, render_state, labels, texture_manager):
'''
Call to initialize the class. Call whenever the surface has been created.
'''
self.texture = texture_manager.create_texture(gl)
self.texture.bind(gl)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER,
gl.GL_NEAREST)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER,
gl.GL_NEAREST)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S,
gl.GL_CLAMP_TO_EDGE)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T,
gl.GL_CLAMP_TO_EDGE)
gl.glTexEnvf(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_REPLACE)
min_height = self.add_labels_internal(gl, render_state, False, labels)
# Round up to the nearest power of two, since textures have to be a power of two in size.
rounded_height = 1
while rounded_height < min_height:
rounded_height <<= 1
self.strike_height = rounded_height;
self.texel_width = (1.0 / float(self.strike_width))
self.texel_height = (1.0 / float(self.strike_height))
self.begin_adding(gl)
self.add_labels_internal(gl, render_state, True, labels)
self.end_adding(gl)
return self.texture
def shutdown(self, gl):
'''
Call when the surface has been destroyed
'''
if self.texture == None:
self.texture.delete(gl)
def add_labels_internal(self, gl, render_state, draw_to_canvas, labels):
'''
call to add a list of labels
'''
text_paint = QPainter()
if draw_to_canvas:
text_paint.begin(self.bitmap)
text_paint.setRenderHints(QPainter.Antialiasing)
u = 0
v = 0
line_height = 0
for label in labels:
ascent = 0
descent = 0
measured_text_width = 0
height = 0
width = 0
font_size = label.font_size
while True:
metrics = None
if draw_to_canvas:
mask = 0x000000FF
b = (label.color >> 16) & mask
g = (label.color >> 8) & mask
r = label.color & mask
######################################################################## LINE CHANGED
text_paint.setPen(QColor(0, 0, 0))
#text_paint.setPen(QColor(r, g, b))
# The value 0.75 is hard coded representing phone pixel density
text_paint.setFont(QFont('Veranda', font_size * 0.75))
# Paint.ascent is negative, so negate it.
metrics = text_paint.fontMetrics()
else:
# The value 0.75 is hard coded representing phone pixel density
metrics = QFontMetrics(QFont('Veranda', font_size * 0.75))
ascent = math.ceil(metrics.ascent())
descent = math.ceil(metrics.descent())
measured_text_width = math.ceil(metrics.boundingRect(label.string).width())
height = int(ascent) + int(descent)
width = int(measured_text_width)
# If it's wider than the screen, try it again with a font size of 1
# smaller.
font_size -= 1
if font_size < 0 or width < render_state.screen_width:
break
next_u = 0
# Is there room for this string on the current line?
if u + width > self.strike_width:
# No room, go to the next line:
u = 0
next_u = width
v += line_height
line_height = 0
else:
next_u = u + width
line_height = max(line_height, height)
if (v + line_height > self.strike_height) and draw_to_canvas:
raise Exception("out of texture space.")
v_base = v + ascent
if draw_to_canvas:
text_paint.drawText(int(u), int(v_base), label.string)
label.set_texture_data(width, height, u, v + height, width, -height,
self.texel_width, self.texel_height)
u = next_u
if draw_to_canvas:
text_paint.end()
return v + line_height
def begin_adding(self, gl):
#Bitmap.Config config = mFullColor ? Bitmap.Config.ARGB_4444 : Bitmap.Config.ALPHA_8
#mBitmap = Bitmap.createBitmap(mStrikeWidth, mStrikeHeight, config)
self.bitmap = QBitmap(self.strike_width, self.strike_height)
self.bitmap.clear()
def end_adding(self, gl):
self.texture.bind(gl)
'''
IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
The image has to be mirrored for some reason
'''
img = QImage(self.bitmap.toImage()).mirrored()
img = QGLWidget.convertToGLFormat(img)
gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, img.width(), img.height(), 0, gl.GL_RGBA,
gl.GL_UNSIGNED_BYTE, str(img.bits()))
# This particular bitmap is no longer needed
self.bitmap = None
def __init__(self, color_bool):
'''
Constructor
'''
self.strike_height = -1
self.strike_width = 512
self.full_color = color_bool
self.bitmap = None
self.texture = None
self.texel_height = None # convert texel to V
self.texel_width = None # convert texel to U
if __name__ == "__main__":
import OpenGL.GL as gl
LM = LabelMaker(True)
LM.begin_adding(gl)
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,569
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/skypython/SharedPreferences.py
|
'''
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-08-12
@author: Neil Borle
'''
class SharedPreferences(object):
'''
The users preferences which are instantiated in
the SkyPython class. Since Android Shared Preferences
are not available in Python, this class simply acts as
a container for the state that would have been in
Shared Preferences.
'''
PREFERENCES = {"source_provider.0" : True,
"source_provider.1" : True,
"source_provider.2" : True,
"source_provider.3" : True,
"source_provider.4" : True,
"source_provider.5" : True,
"source_provider.6" : True,
"source_provider.7" : True,
"source_provider.8" : True,
"no_auto_locate" : False,
"force_gps" : False}
ALLOW_ROTATION = False
# The following is the location of Pisa.
LATITUDE, LONGITUDE = 43.7166667,10.3833333
def __init__(self):
'''
Constructor
'''
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,570
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/control/Controller.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-23
@author: Neil Borle
'''
class Controller(object):
'''
Super class that forces all controller sub classes
to have models and an enabled boolean.
'''
def __init__(self):
'''
Constructor
'''
self.model = None
self.enabled = True
if __name__ == "__main__":
'''
Do nothing
'''
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,571
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/rendererUtil/TextureManager.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: James Powell
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-11
@author: Neil Borle
'''
from PySide.QtGui import QImage
from PySide.QtOpenGL import QGLWidget
def construct_id_to_image_map(filename, id_map):
with open(filename) as f_handle:
for line in f_handle:
[value, key] = line.strip().split("=")
id_map[int(key, 0)] = value
class TextureManager(object):
'''
Manages the creation and organization of
textures.
'''
class TextureReference(object):
'''
Contains a reference to a texture, it's id, and
allows for invalidation of that texture
'''
def bind(self, gl):
self.check_valid()
gl.glBindTexture(gl.GL_TEXTURE_2D, self.texture_id)
def delete(self, gl):
self.check_valid()
# based on examples this single arg should be correct
gl.glDeleteTextures(self.texture_id)
self.invalidate()
def invalidate(self):
self.valid = False
def check_valid(self):
if not self.valid:
raise Exception("This is not valid")
def __init__(self, Id):
'''
constructor
'''
self.texture_id = Id
self.valid = True
class TextureData(object):
'''
State on the number of times a
texture has been referenced
'''
def __init__(self):
'''
constructor
'''
self.texture_ref = None
self.ref_count = 0
images = {}
id_to_texture_map = {}
all_textures = []
def create_texture(self, gl):
return self.create_texture_internal(gl)
def get_texture_from_resource(self, gl, resource_id):
# If the texture already exists, return it.
if resource_id in self.id_to_texture_map.keys():
text_data = self.id_to_texture_map[resource_id]
text_data.ref_count += 1
return text_data.texture_ref
text = self.create_texture_from_resource(gl, resource_id)
# Add it to the map.
data = self.TextureData()
data.texture_ref = text
data.ref_count = 1
self.id_to_texture_map[resource_id] = data
return text
def reset(self):
self.id_to_texture_map.clear()
while len(self.all_textures) > 0:
self.all_textures[0].invalidate()
self.all_textures.pop(0)
def create_texture_from_resource(self, gl, resource_id):
'''
Unlike the original java source, convertToGLFormat is used
'''
text = self.create_texture_internal(gl)
img = QImage("assets/drawable/" + self.images[resource_id] + ".png")
img = QGLWidget.convertToGLFormat(img)
text.bind(gl)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR);
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR);
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE);
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE);
gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, img.width(), img.height(), 0, gl.GL_RGBA,
gl.GL_UNSIGNED_BYTE, str(img.bits()))
return text
def create_texture_internal(self, gl):
text_id = gl.glGenTextures(1)
text = TextureManager.TextureReference(text_id)
self.all_textures.append(text)
return text
def __init__(self, testing=False):
'''
Constructor
'''
if not testing:
construct_id_to_image_map("assets/RImages.txt", self.images)
if __name__ == "__main__":
import OpenGL.GL as gl
m_map = {}
construct_id_to_image_map("../../assets/RImages.txt", m_map)
for key in m_map.keys():
print str(key) + ":" + m_map[key]
TM = TextureManager(True)
TM.images = m_map
TM.create_texture_from_resource(gl, 2130837609)
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,572
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/provider/Planet.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-26
@author: Neil Borle
'''
import time
import math
from OrbitalElements import OrbitalElements
from src.base.TimeConstants import MILLISECONDS_PER_DAY, MILLISECONDS_PER_WEEK, MILLISECONDS_PER_HOUR
from src.units.RaDec import RaDec, calculate_ra_dec_dist
from src.units.GeocentricCoordinates import get_instance as gc_get_instance
from src.units.HeliocentricCoordinates import get_instance as hc_get_instance
from src.utils import Geometry as Geometry
from src.utils.Enumeration import enum
from src.utils.TimeUtil import julian_centuries, calculate_julian_day
#Enum that identifies whether we are interested in rise or set time.
rise_set_indicator = enum(RISE=0, SET=1)
planet_enum = enum(MERCURY=0, VENUS=1, SUN=2, MARS=3,
JUPITER=4, SATURN=5, URANUS=6,
NEPTUNE=7, PLUTO=8, MOON=9)
res = {0 : ["mercury", "Mercury", 1 * MILLISECONDS_PER_DAY],
1 : ["venus", "Venus", 1 * MILLISECONDS_PER_DAY],
2 : ["sun", "Sun", 1 * MILLISECONDS_PER_DAY],
3 : ["mars", "Mars", 1 * MILLISECONDS_PER_DAY],
4 : ["jupiter", "Jupiter", 1 * MILLISECONDS_PER_WEEK],
5 : ["saturn", "Saturn", 1 * MILLISECONDS_PER_WEEK],
6 : ["uranus", "Uranus", 1 * MILLISECONDS_PER_WEEK],
7 : ["neptune", "Neptune", 1 * MILLISECONDS_PER_WEEK],
8 : ["pluto", "Pluto", 1 * MILLISECONDS_PER_WEEK],
9 : ["moon4", "Moon", 1 * MILLISECONDS_PER_HOUR]}
class Planet(object):
'''
This class is responsible for calculations and resources relating
to the other planets, the sun and the moon.
'''
#Maximum number of times to calculate rise/set times. If we cannot
# converge after this many iteretions, we will fail.
MAX_ITERATIONS = 25
def get_image_resource_id(self, time_struct):
# Returns the resource id for the planet's image.
if self.id == planet_enum.MOON:
return self.get_lunar_phase_image_id(time_struct)
return self.image_resource_id
def get_lunar_phase_image_id(self, time_struct):
# First, calculate phase angle:
phase = self.calculate_phase_angle(time_struct)
# Next, figure out what resource id to return.
if phase < 22.5:
# New moon.
return "moon0"
elif phase > 150.0:
# Full moon.
return "moon4"
# Either crescent, quarter, or gibbous. Need to see whether we are
# waxing or waning. Calculate the phase angle one day in the future.
# If phase is increasing, we are waxing. If not, we are waning.
tomorrow = time.gmtime(time.mktime(time_struct) + 24 * 3600 * 1000)
phase2 = self.calculate_phase_angle(tomorrow)
if phase < 67.5:
# Crescent
return "moon1" if phase2 > phase else "moon7"
elif phase < 112.5:
# Quarter
return "moon2" if phase2 > phase else "moon6"
# Gibbous
return "moon3" if phase2 > phase else "moon5"
# Taken from JPL's Planetary Positions page: http://ssd.jpl.nasa.gov/?planet_pos
# This gives us a good approximation for the years 1800 to 2050 AD.
def get_orbital_elements(self, t_struct):
# Centuries since J2000
jc = julian_centuries(t_struct)
if self.id == planet_enum.MERCURY:
a = 0.38709927 + 0.00000037 * jc
e = 0.20563593 + 0.00001906 * jc
i = Geometry.degrees_to_radians(7.00497902 - 0.00594749 * jc)
l = Geometry.mod_2_pi(Geometry.degrees_to_radians(252.25032350 + 149472.67411175 * jc))
w = Geometry.degrees_to_radians(77.45779628 + 0.16047689 * jc)
o = Geometry.degrees_to_radians(48.33076593 - 0.12534081 * jc)
return OrbitalElements(a, e, i, o, w, l)
elif self.id == planet_enum.VENUS:
a = 0.72333566 + 0.00000390 * jc
e = 0.00677672 - 0.00004107 * jc
i = Geometry.degrees_to_radians(3.39467605 - 0.00078890 * jc)
l = Geometry.mod_2_pi(Geometry.degrees_to_radians(181.97909950 + 58517.81538729 * jc))
w = Geometry.degrees_to_radians(131.60246718 + 0.00268329 * jc)
o = Geometry.degrees_to_radians(76.67984255 - 0.27769418 * jc)
return OrbitalElements(a, e, i, o, w, l)
elif self.id == planet_enum.SUN:
# Note that this is the orbital data for Earth.
a = 1.00000261 + 0.00000562 * jc
e = 0.01671123 - 0.00004392 * jc
i = Geometry.degrees_to_radians(-0.00001531 - 0.01294668 * jc)
l = Geometry.mod_2_pi(Geometry.degrees_to_radians(100.46457166 + 35999.37244981 * jc))
w = Geometry.degrees_to_radians(102.93768193 + 0.32327364 * jc)
o = 0.0
return OrbitalElements(a, e, i, o, w, l)
elif self.id == planet_enum.MARS:
a = 1.52371034 + 0.00001847 * jc
e = 0.09339410 + 0.00007882 * jc
i = Geometry.degrees_to_radians(1.84969142 - 0.00813131 * jc)
l = Geometry.mod_2_pi(Geometry.degrees_to_radians(-4.55343205 + 19140.30268499 * jc))
w = Geometry.degrees_to_radians(-23.94362959 + 0.44441088 * jc)
o = Geometry.degrees_to_radians(49.55953891 - 0.29257343 * jc)
return OrbitalElements(a, e, i, o, w, l)
elif self.id == planet_enum.JUPITER:
a = 5.20288700 - 0.00011607 * jc
e = 0.04838624 - 0.00013253 * jc
i = Geometry.degrees_to_radians(1.30439695 - 0.00183714 * jc)
l = Geometry.mod_2_pi(Geometry.degrees_to_radians(34.39644051 + 3034.74612775 * jc))
w = Geometry.degrees_to_radians(14.72847983 + 0.21252668 * jc)
o = Geometry.degrees_to_radians(100.47390909 + 0.20469106 * jc)
return OrbitalElements(a, e, i, o, w, l)
elif self.id == planet_enum.SATURN:
a = 9.53667594 - 0.00125060 * jc
e = 0.05386179 - 0.00050991 * jc
i = Geometry.degrees_to_radians(2.48599187 + 0.00193609 * jc)
l = Geometry.mod_2_pi(Geometry.degrees_to_radians(49.95424423 + 1222.49362201 * jc))
w = Geometry.degrees_to_radians(92.59887831 - 0.41897216 * jc)
o = Geometry.degrees_to_radians(113.66242448 - 0.28867794 * jc)
return OrbitalElements(a, e, i, o, w, l)
elif self.id == planet_enum.URANUS:
a = 19.18916464 - 0.00196176 * jc
e = 0.04725744 - 0.00004397 * jc
i = Geometry.degrees_to_radians(0.77263783 - 0.00242939 * jc)
l = Geometry.mod_2_pi(Geometry.degrees_to_radians(313.23810451 + 428.48202785 * jc))
w = Geometry.degrees_to_radians(170.95427630 + 0.40805281 * jc)
o = Geometry.degrees_to_radians(74.01692503 + 0.04240589 * jc)
return OrbitalElements(a, e, i, o, w, l)
elif self.id == planet_enum.NEPTUNE:
a = 30.06992276 + 0.00026291 * jc
e = 0.00859048 + 0.00005105 * jc
i = Geometry.degrees_to_radians(1.77004347 + 0.00035372 * jc)
l = Geometry.mod_2_pi(Geometry.degrees_to_radians(-55.12002969 + 218.45945325 * jc))
w = Geometry.degrees_to_radians(44.96476227 - 0.32241464 * jc)
o = Geometry.degrees_to_radians(131.78422574 - 0.00508664 * jc)
return OrbitalElements(a, e, i, o, w, l)
elif self.id == planet_enum.PLUTO:
a = 39.48211675 - 0.00031596 * jc
e = 0.24882730 + 0.00005170 * jc
i = Geometry.degrees_to_radians(17.14001206 + 0.00004818 * jc)
l = Geometry.mod_2_pi(Geometry.degrees_to_radians(238.92903833 + 145.20780515 * jc))
w = Geometry.degrees_to_radians(224.06891629 - 0.04062942 * jc)
o = Geometry.degrees_to_radians(110.30393684 - 0.01183482 * jc)
return OrbitalElements(a, e, i, o, w, l)
else:
raise RuntimeError("Unknown Planet:" + str(self.id))
def calculate_lunar_geocentric_location(self, t_struct):
'''
Calculate the geocentric right ascension and declination of the moon using
an approximation as described on page D22 of the 2008 Astronomical Almanac
All of the variables in this method use the same names as those described
in the text: lambda = Ecliptic longitude (degrees) beta = Ecliptic latitude
(degrees) pi = horizontal parallax (degrees) r = distance (Earth radii)
NOTE: The text does not give a specific time period where the approximation
is valid, but it should be valid through at least 2009.
'''
# First, calculate the number of Julian centuries from J2000.0.
t = ((calculate_julian_day(t_struct) - 2451545.0) / 36525.0)
# Second, calculate the approximate geocentric orbital elements.
lambda_val = 218.32 + 481267.881 * t + 6.29 \
* math.sin(Geometry.degrees_to_radians(135.0 + 477198.87 * t)) - 1.27 \
* math.sin(Geometry.degrees_to_radians(259.3 - 413335.36 * t)) + 0.66 \
* math.sin(Geometry.degrees_to_radians(235.7 + 890534.22 * t)) + 0.21 \
* math.sin(Geometry.degrees_to_radians(269.9 + 954397.74 * t)) - 0.19 \
* math.sin(Geometry.degrees_to_radians(357.5 + 35999.05 * t)) - 0.11 \
* math.sin(Geometry.degrees_to_radians(186.5 + 966404.03 * t))
beta = 5.13 \
* math.sin(Geometry.degrees_to_radians(93.3 + 483202.02 * t)) + 0.28 \
* math.sin(Geometry.degrees_to_radians(228.2 + 960400.89 * t)) - 0.28 \
* math.sin(Geometry.degrees_to_radians(318.3 + 6003.15 * t)) - 0.17 \
* math.sin(Geometry.degrees_to_radians(217.6 - 407332.21 * t))
# Third, convert to RA and Dec.
l = math.cos(Geometry.degrees_to_radians(beta)) \
* math.cos(Geometry.degrees_to_radians(lambda_val))
m = 0.9175 * math.cos(Geometry.degrees_to_radians(beta)) \
* math.sin(Geometry.degrees_to_radians(lambda_val)) - 0.3978 \
* math.sin(Geometry.degrees_to_radians(beta))
n = 0.3978 * math.cos(Geometry.degrees_to_radians(beta)) \
* math.sin(Geometry.degrees_to_radians(lambda_val)) + 0.9175 \
* math.sin(Geometry.degrees_to_radians(beta))
ra = Geometry.radians_to_degrees(Geometry.mod_2_pi(math.atan2(m, l)))
dec = Geometry.radians_to_degrees(math.asin(n))
return RaDec(ra, dec)
def calculate_phase_angle(self, t_struct):
'''
Calculates the phase angle of the planet, in degrees.
'''
# For the moon, we will approximate phase angle by calculating the
# elongation of the moon relative to the sun. This is accurate to within
# about 1%.
if self.id == planet_enum.MOON:
moon_ra_dec = self.calculate_lunar_geocentric_location(t_struct)
moon = gc_get_instance(moon_ra_dec.ra, moon_ra_dec.dec)
sun_coords = hc_get_instance(t_struct=t_struct,
planet=Planet(planet_enum.SUN,
res[planet_enum.SUN][0],
res[planet_enum.SUN][1],
res[planet_enum.SUN][2]))
sun_ra_dec = calculate_ra_dec_dist(sun_coords)
sun = gc_get_instance(sun_ra_dec.ra, sun_ra_dec.dec)
return 180.0 - \
Geometry.radians_to_degrees(math.acos(sun.x * moon.x + sun.y * moon.y + sun.z * moon.z))
# First, determine position in the solar system.
planet_coords = hc_get_instance(planet=self, t_struct=t_struct)
# Second, determine position relative to Earth
earth_coords = hc_get_instance(t_struct=t_struct,
planet=Planet(planet_enum.SUN,
res[planet_enum.SUN][0],
res[planet_enum.SUN][1],
res[planet_enum.SUN][2]))
earth_distance = planet_coords.distance_from(earth_coords)
# Finally, calculate the phase of the body.
phase = Geometry.radians_to_degrees(\
math.acos((earth_distance * earth_distance + \
planet_coords.radius * planet_coords.radius - \
earth_coords.radius * earth_coords.radius) / \
(2.0 * earth_distance * planet_coords.radius)))
return phase
def calculate_percent_illuminated(self, t_struct):
'''
Calculate the percent of the body that is illuminated. The value returned
is a fraction in the range from 0.0 to 100.0.
'''
phase_angle = self.calculate_phase_angle(t_struct)
return 50.0 * (1.0 + math.cos(Geometry.degrees_to_radians(phase_angle)))
def get_next_full_moon(self, now):
'''
Return the date of the next full moon after today.
'''
moon = Planet(planet_enum.MOON, res[planet_enum.MOON][0],
res[planet_enum.MOON][1], res[planet_enum.MOON][2])
# First, get the moon's current phase.
phase = moon.calculate_phase_angle(now)
# Next, figure out if the moon is waxing or waning.
later = time.gmtime(time.mktime(now) + 1 * 3600 * 1000)
phase2 = moon.calculate_phase_angle(later)
is_waxing = phase2 > phase
# If moon is waxing, next full moon is (180.0 - phase)/360.0 * 29.53.
# If moon is waning, next full moon is (360.0 - phase)/360.0 * 29.53.
LUNAR_CYCLE = 29.53 # In days.
base_angle = 180.0 if is_waxing else 360.0
num_days = (base_angle - phase) / 360.0 * LUNAR_CYCLE
return time.gmtime(time.mktime(now) + (num_days * 24.0 * 3600.0 * 1000.0))
def get_next_full_moon_slow(self, now):
'''
Return the date of the next full moon after today.
Slow incremental version, only correct to within an hour.
'''
moon = Planet(planet_enum.MOON, res[planet_enum.MOON][0],
res[planet_enum.MOON][1], res[planet_enum.MOON][2])
full_moon = time.gmtime(time.mktime(now))
phase = moon.calculate_phase_angle(now)
waxing = False
while True:
full_moon = time.gmtime(time.mktime(full_moon) + MILLISECONDS_PER_HOUR)
next_phase = moon.calculate_phase_angle(full_moon)
if waxing and (next_phase < phase):
full_moon = time.gmtime(time.mktime(full_moon) - MILLISECONDS_PER_HOUR)
return full_moon
waxing = (next_phase > phase)
phase = next_phase
def get_magnitude(self, t_struct):
'''
Calculates the planet's magnitude for the given date.
'''
if self.id == planet_enum.SUN:
return -27.0
if self.id == planet_enum.MOON:
return -10.0
# First, determine position in the solar system.
planet_coords = hc_get_instance(planet=self, t_struct=t_struct)
# Second, determine position relative to Earth
earth_coords = hc_get_instance(t_struct=t_struct,
planet=Planet(planet_enum.SUN,
res[planet_enum.SUN][0],
res[planet_enum.SUN][1],
res[planet_enum.SUN][2]))
earth_distance = planet_coords.distance_from(earth_coords)
# Third, calculate the phase of the body.
phase = Geometry.radians_to_degrees(\
math.acos((earth_distance * earth_distance + \
planet_coords.radius * planet_coords.radius - \
earth_coords.radius * earth_coords.radius) / \
(2.0 * earth_distance * planet_coords.radius)))
p = phase/100.0 # Normalized phase angle
# Finally, calculate the magnitude of the body.
mag = -100.0 # Apparent visual magnitude
if self.id == planet_enum.MERCURY:
mag = -0.42 + (3.80 - (2.73 - 2.00 * p) * p) * p
elif self.id == planet_enum.VENUS:
mag = -4.40 + (0.09 + (2.39 - 0.65 * p) * p) * p
elif self.id == planet_enum.MARS:
mag = -1.52 + 1.6 * p
elif self.id == planet_enum.JUPITER:
mag = -9.40 + 0.5 * p
elif self.id == planet_enum.SATURN:
mag = -8.75
elif self.id == planet_enum.URANUS:
mag = -7.19
elif self.id == planet_enum.NEPTUNE:
mag = -6.87
elif self.id == planet_enum.PLUTO:
mag = -1.0
else:
mag = 100
return (mag + 5.0 * math.log10(planet_coords.radius * earth_distance))
def get_planetary_image_size(self):
if self.id == planet_enum.SUN or self.id == planet_enum.MOON:
return 0.02
elif self.id == planet_enum.MERCURY or self.id == planet_enum.VENUS or \
self.id == planet_enum.MARS or self.id == planet_enum.PLUTO:
return 0.01
elif self.id == planet_enum.JUPITER:
return 0.025
elif self.id == planet_enum.URANUS or self.id == planet_enum.NEPTUNE:
return 0.015
elif self.id == planet_enum.SATURN:
return 0.035
else:
return 0.02
def calc_next_rise_set_time(self, now, loc, indicator):
'''
Calculates the next rise or set time of this planet from a given observer.
Returns null if the planet doesn't rise or set during the next day.
@param now Calendar time from which to calculate next rise / set time.
@param loc Location of observer.
@param indicator Indicates whether to look for rise or set time.
@return New Calendar set to the next rise or set time if within
the next day, otherwise null.
'''
raise NotImplementedError("not done yet")
# Make a copy of the calendar to return.
# Calendar riseSetTime = Calendar.getInstance();
# double riseSetUt = calcRiseSetTime(now.getTime(), loc, indicator);
# // Early out if no nearby rise set time.
# if (riseSetUt < 0) {
# return null;
# }
#
# // Find the start of this day in the local time zone. The (a / b) * b
# // formulation looks weird, it's using the properties of int arithmetic
# // so that (a / b) is really floor(a / b).
# long dayStart = (now.getTimeInMillis() / TimeConstants.MILLISECONDS_PER_DAY)
# * TimeConstants.MILLISECONDS_PER_DAY - riseSetTime.get(Calendar.ZONE_OFFSET);
# long riseSetUtMillis = (long) (calcRiseSetTime(now.getTime(), loc, indicator)
# * TimeConstants.MILLISECONDS_PER_HOUR);
# long newTime = dayStart + riseSetUtMillis + riseSetTime.get(Calendar.ZONE_OFFSET);
# // If the newTime is before the current time, go forward 1 day.
# if (newTime < now.getTimeInMillis()) {
# Log.d(TAG, "Nearest Rise/Set is in the past. Adding one day.");
# newTime += TimeConstants.MILLISECONDS_PER_DAY;
# }
# riseSetTime.setTimeInMillis(newTime);
# if (!riseSetTime.after(now)) {
# Log.e(TAG, "Next rise set time (" + riseSetTime.toString()
# + ") should be after current time (" + now.toString() + ")");
# }
# return riseSetTime;
def calc_rise_set_time(self, date, loc, indicator):
# Internally calculate the rise and set time of an object.
# Returns a double, the number of hours through the day in UT.
raise NotImplementedError("not done yet")
# Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UT"));
# cal.setTime(d);
#
# float sign = (indicator == RiseSetIndicator.RISE ? 1.0f : -1.0f);
# float delta = 5.0f;
# float ut = 12.0f;
#
# int counter = 0;
# while ((Math.abs(delta) > 0.008) && counter < MAX_ITERATIONS) {
# cal.set(Calendar.HOUR_OF_DAY, (int) MathUtil.floor(ut));
# float minutes = (ut - MathUtil.floor(ut)) * 60.0f;
# cal.set(Calendar.MINUTE, (int) minutes);
# cal.set(Calendar.SECOND, (int) ((minutes - MathUtil.floor(minutes)) * 60.f));
#
# // Calculate the hour angle and declination of the planet.
# // TODO(serafini): Need to fix this for arbitrary RA/Dec locations.
# Date tmp = cal.getTime();
# HeliocentricCoordinates sunCoordinates =
# HeliocentricCoordinates.getInstance(Planet.Sun, tmp);
# RaDec raDec = RaDec.getInstance(this, tmp, sunCoordinates);
#
# // GHA = GST - RA. (In degrees.)
# float gst = TimeUtil.meanSiderealTime(tmp, 0);
# float gha = gst - raDec.ra;
#
# // The value of -0.83 works for the diameter of the Sun and Moon. We
# // assume that other objects are simply points.
# float bodySize = (this == Planet.Sun || this == Planet.Moon) ? -0.83f : 0.0f;
# float hourAngle = calculateHourAngle(bodySize, loc.latitude, raDec.dec);
#
# delta = (gha + loc.longitude + (sign * hourAngle)) / 15.0f;
# while (delta < -24.0f) {
# delta = delta + 24.0f;
# }
# while (delta > 24.0f) {
# delta = delta - 24.0f;
# }
# ut = ut - delta;
#
# // I think we need to normalize UT
# while (ut < 0.0f) {
# ut = ut + 24.0f;
# }
# while (ut > 24.0f) {
# ut = ut - 24.0f;
# }
#
# ++counter;
# }
#
# // Return failure if we didn't converge.
# if (counter == MAX_ITERATIONS) {
# Log.d(TAG, "Rise/Set calculation didn't converge.");
# return -1.0f;
# }
#
# // TODO(serafini): Need to handle latitudes above 60
# // At latitudes above 60, we need to calculate the following:
# // sin h = sin phi sin delta + cos phi cos delta cos (gha + lambda)
# return ut;
def calculate_hour_angle(self, altitude, latitude, declination):
'''
Calculates the hour angle of a given declination for the given location.
This is a helper application for the rise and set calculations. Its
probably not worth using as a general purpose method.
All values are in degrees.
This method calculates the hour angle from the meridian using the
following equation from the Astronomical Almanac (p487):
cos ha = (sin alt - sin lat * sin dec) / (cos lat * cos dec)
'''
alt_rads = Geometry.degrees_to_radians(altitude)
lat_rads = Geometry.degrees_to_radians(latitude)
dec_rads = Geometry.degrees_to_radians(declination)
cos_ha = (math.sin(alt_rads) - math.sin(lat_rads) * math.sin(dec_rads)) / \
(math.cos(lat_rads) * math.cos(dec_rads))
return Geometry.radians_to_degrees(math.acos(cos_ha))
def __init__(self, new_id, image_resource_id, name_resource_id, update_freq_Ms):
'''
constructor
'''
self.id = new_id
self.image_resource_id = image_resource_id
self.name_resource_id = name_resource_id
self.update_freq_Ms = update_freq_Ms
if __name__ == "__main__":
pass
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,573
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/sourceProto/ProtobufAstronomicalSource.py
|
'''
// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-22
@author: Neil Borle
'''
import SourceProto
from src.source.AbstractAstronomicalSource import AbstractAstronomicalSource
from src.source.PointSource import shape_enum
from src.units.GeocentricCoordinates import get_instance
from src.source.PointSource import PointSource
from src.source.TextSource import TextSource
from src.source.LineSource import LineSource
def construct_id_to_string_map(filename, index_to_string):
with open(filename, 'r') as f_handle:
for line in f_handle:
key_value = line.strip().split(',')
index_to_string[int(key_value[0])] = key_value[1]
class ProtobufAstronomicalSource(AbstractAstronomicalSource):
'''
Once SourceProto, using the buffer protocol, has extracted the
source from the binary file, this class abstracts and wraps
access to that astronomical source providing a common interface.
This class is used for file based layers.
'''
shape_map = {SourceProto.CIRCLE : shape_enum.CIRCLE,
SourceProto.STAR : shape_enum.CIRCLE,
SourceProto.ELLIPTICAL_GALAXY : shape_enum.ELLIPTICAL_GALAXY,
SourceProto.SPIRAL_GALAXY : shape_enum.SPIRAL_GALAXY,
SourceProto.IRREGULAR_GALAXY : shape_enum.IRREGULAR_GALAXY,
SourceProto.LENTICULAR_GALAXY : shape_enum.LENTICULAR_GALAXY,
SourceProto.GLOBULAR_CLUSTER : shape_enum.GLOBULAR_CLUSTER,
SourceProto.OPEN_CLUSTER : shape_enum.OPEN_CLUSTER,
SourceProto.NEBULA : shape_enum.NEBULA,
SourceProto.HUBBLE_DEEP_FIELD : shape_enum.HUBBLE_DEEP_FIELD}
strings = {}
def set_names(self, APS):
'''
Strings are loaded from strings.txt in the assets folder.
'''
for name_id in APS.name_ids:
self.names.append(self.strings[name_id])
def get_geo_coords(self):
gc = self.astro_source_proto.search_location
return get_instance(gc.right_ascension, gc.declination)
#override(AbstractAstronomicalSource)
def get_points(self):
point_list = []
for p in self.astro_source_proto.point:
gc_proto = p.location
gc = get_instance(gc_proto.right_ascension, gc_proto.declination)
point_list.append(PointSource(p.color, p.size, gc, self.shape_map[p.shape]))
return point_list
#override(AbstractAstronomicalSource)
def get_labels(self):
'''
Strings are loaded from strings.txt in the assets folder.
'''
label_list = []
for l in self.astro_source_proto.label:
gc_proto = l.location
gc = get_instance(gc_proto.right_ascension, gc_proto.declination)
label_list.append(TextSource(self.strings[l.string_index], l.color,
gc, l.offset, l.font_size))
return label_list
#override(AbstractAstronomicalSource)
def get_lines(self):
line_list = []
for l in self.astro_source_proto.line:
geocentric_verticies = []
for gc_proto in l.vertex:
gc = get_instance(gc_proto.right_ascension, \
gc_proto.declination)
geocentric_verticies.append(gc)
line_list.append(LineSource(geocentric_verticies, l.color, \
l.line_width))
return line_list
def __init__(self, astronomical_source_proto):
'''
Constructor
'''
AbstractAstronomicalSource.__init__(self)
if len(self.strings.keys()) == 0:
construct_id_to_string_map("assets/Strings.txt", self.strings)
self.astro_source_proto = astronomical_source_proto
self.set_names(astronomical_source_proto)
if __name__ == "__main__":
'''
For debugging purposes
'''
print SourceProto.STAR, ProtobufAstronomicalSource.shape_map[SourceProto.STAR]
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,574
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/renderer/LabelObjectManager.py
|
'''
// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: James Powell
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-10
@author: Neil Borle
'''
import math
import numpy as np
from src.units.Vector3 import Vector3
from src.utils.Matrix4x4 import transform_vector
from RendererObjectManager import RendererObjectManager
from src.rendererUtil.SkyRegionMap import SkyRegionMap
from src.rendererUtil.LabelMaker import LabelMaker
from src.units.GeocentricCoordinates import GeocentricCoordinates
from src.utils.Matrix4x4 import create_rotation, multiply_MV
from src.utils.DebugOptions import Debug
class LabelObjectManager(RendererObjectManager):
'''
Manages the rendering of text labels by loading
text sources into buffers for rendering and maintaining
these buffers.
'''
class label(LabelMaker.LabelData):
'''
A private class which extends the LabelMaker's label data with an xyz position and rgba color values.
For the red-eye mode, it's easier to set the color in the texture to white and set the color when we render
the label than to have two textures, one with red labels and one without.
'''
def __init__(self, text_source):
'''
constructor
'''
LabelMaker.LabelData.__init__(self, text_source.label,
0xFFFFFFFF, text_source.font_size)
if text_source.label == None or text_source.label == '':
raise Exception("Bad label " + str(self))
self.x = text_source.geocentric_coords.x
self.y = text_source.geocentric_coords.y
self.z = text_source.geocentric_coords.z
self.offset = text_source.offset
# The distance this should be rendered underneath the specified position, in world coordinates.
self.rgb = text_source.color
self.a = 0xFF
self.b = (self.rgb >> 16) & 0xFF
self.g = (self.rgb >> 8) & 0xFF
self.r = self.rgb & 0xFF
# fixed point values
#self.fixed_a = int(65536.0 * self.a / 255.0) & 0xFFFFFFFF
#self.fixed_b = int(65536.0 * self.b / 255.0) & 0xFFFFFFFF
#self.fixed_g = int(65536.0 * self.g / 255.0) & 0xFFFFFFFF
#self.fixed_r = int(65536.0 * self.r / 255.0) & 0xFFFFFFFF
# Should we compute the regions for the labels?
# If false, we just put them in the catchall region.
COMPUTE_REGIONS = True
def update_objects(self, labels, update_type):
if self.update_type.Reset in update_type:
self.labels = [None] * len(labels)
for i in range(0, len(labels)):
self.labels[i] = self.label(labels[i])
self.queue_for_reload(False)
elif self.update_type.UpdatePositions in update_type:
if len(labels) != len(self.labels):
return
# Since we don't store the positions in any GPU memory, and do the
# transformations manually, we can just update the positions stored
# on the label objects.
for i in range(0, len(self.labels)):
pos = labels[i].gc_coords
self.labels[i].x = pos.x
self.labels[i].y = pos.y
self.labels[i].z = pos.z
self.sky_region_map.clear()
for l in self.labels:
if self.COMPUTE_REGIONS:
region = self.sky_region_map.get_object_region(GeocentricCoordinates(l.x, l.y, l.z))
else:
region = self.sky_region_map.CATCHALL_REGION_ID
self.sky_region_map.get_region_data(region).append(l)
def reload(self, gl, full_reload):
# We need to regenerate the texture. If we're re-creating the surface
# (fullReload=true), all resources were automatically released by OpenGL,
# so we don't want to try to release it again. Otherwise, we need to
# release it to avoid a resource leak (shutdown takes
# care of freeing the texture).
if not full_reload and self.label_maker == None:
self.label_maker.shutdown(gl)
self.label_maker = LabelMaker(True)
self.texture_ref = self.label_maker.initialize(gl, self.render_state,
self.labels, self.texture_manager)
def draw_internal(self, gl):
if Debug.DRAWING == "POINTS ONLY" or Debug.DRAWING == "POINTS AND LINES": return
gl.glTexEnvf(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE,
gl.GL_MODULATE)
gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY)
gl.glActiveTexture(gl.GL_TEXTURE0)
self.texture_ref.bind(gl)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S,
gl.GL_REPEAT)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T,
gl.GL_REPEAT)
self.begin_drawing(gl)
# Draw the labels for the active sky regions.
active_regions = self.render_state.active_sky_region_set
all_active_labels = self.sky_region_map.get_data_for_active_regions(active_regions)
for labels_in_region in all_active_labels:
for l in labels_in_region:
self.draw_label(gl, l)
self.end_drawing(gl)
def draw_label(self, gl, label):
look_dir = self.render_state.look_dir
if look_dir.x * label.x + look_dir.y * label.y + \
look_dir.z * label.z < self.dot_product_threshold:
return
# Offset the label to be underneath the given position (so a label will
# always appear underneath a star no matter how the phone is rotated)
v = Vector3(label.x - self.label_offset.x * label.offset,
label.y - self.label_offset.y * label.offset,
label.z - self.label_offset.z * label.offset)
screen_pos = transform_vector(self.render_state.transform_to_screen, v)
# We want this to align consistently with the pixels on the screen, so we
# snap to the nearest x/y coordinate, and add a magic offset of less than
# half a pixel. Without this, rounding error can cause the bottom and
# top of a label to be one pixel off, which results in a noticeable
# distortion in the text.
MAGIC_OFFSET = 0.25
screen_pos.x = int(screen_pos.x) + MAGIC_OFFSET
screen_pos.y = int(screen_pos.y) + MAGIC_OFFSET
gl.glPushMatrix()
gl.glTranslatef(screen_pos.x, screen_pos.y, 0)
gl.glRotatef((180.0 / math.pi) * self.render_state.up_angle, 0, 0, -1)
gl.glScalef(label.width_in_pixels, label.height_in_pixels, 1)
gl.glVertexPointer(2, gl.GL_FLOAT, 0, self.quad_buffer)
gl.glTexCoordPointer(2, gl.GL_FLOAT, 0, label.text_coords)
if self.render_state.night_vision_mode:
gl.glColor4ub(0xFF, 0, 0, label.a)
else:
gl.glColor4ub(label.r, label.g, label.b, 128)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)
gl.glPopMatrix()
def begin_drawing(self, gl):
'''
Sets OpenGL state for rapid drawing
'''
self.texture_ref.bind(gl)
gl.glShadeModel(gl.GL_FLAT)
########################################################################## added Blending
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glEnable(gl.GL_ALPHA_TEST)
gl.glAlphaFunc(gl.GL_GREATER, 0.5)
gl.glEnable(gl.GL_TEXTURE_2D)
# We're going to do the transformation on the CPU, so set the matrices
# to the identity
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glPushMatrix()
gl.glLoadIdentity()
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glPushMatrix()
gl.glLoadIdentity()
gl.glOrtho(0, self.render_state.screen_width,
0, self.render_state.screen_height,
-1, 1)
# equivalent of a call to GLBuffer.unbind(gl)
gl.glBindBuffer(gl.GL_ARRAY_BUFFER, 0)
gl.glBindBuffer(gl.GL_ELEMENT_ARRAY_BUFFER, 0)
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY)
gl.glDisableClientState(gl.GL_COLOR_ARRAY)
rs = self.render_state
view_width = rs.screen_width
view_height = rs.screen_height
rotation = create_rotation(rs.up_angle, rs.look_dir)
self.label_offset = multiply_MV(rotation, rs.up_dir)
# If a label isn't within the field of view angle from the target vector, it can't
# be on the screen. Compute the cosine of this angle so we can quickly identify these.
DEGREES_TO_RADIANS = math.pi / 180.0
self.dot_product_threshold = math.cos(rs.radius_of_view * DEGREES_TO_RADIANS * \
(1 + view_width / float(view_height)) * 0.5)
def end_drawing(self, gl):
##########################################################################added blending
gl.glDisable(gl.GL_BLEND)
gl.glDisable(gl.GL_ALPHA_TEST)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glPopMatrix()
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glPopMatrix()
gl.glDisable(gl.GL_TEXTURE_2D)
gl.glColor4f(1, 1, 1, 1)
def __init__(self, sky_renderer, new_layer, new_texture_manager):
'''
Constructor
'''
RendererObjectManager.__init__(self, new_layer, new_texture_manager)
self.label_maker = None
self.labels = []
self.sky_region_map = SkyRegionMap()
# These are intermediate variables set in beginDrawing() and used in
# draw() to make the transformations more efficient
self.label_offset = Vector3(0, 0, 0)
self.dot_product_threshold = None
self.texture_ref = None
# A quad with size 1 on each size, so we just need to multiply
# by the label's width and height to get it to the right size for each
# label.
vertices = [-0.5, -0.5, # lower left
-0.5, 0.5, # upper left
0.5, -0.5, # lower right
0.5, 0.5] # upper right
# make the vertices fixed point? byte buffer?
self.quad_buffer = np.array(vertices, dtype=np.float32)
# We want to initialize the labels of a sky region to an empty list.
def construct_method():
return []
self.sky_region_map.region_data_factory = \
SkyRegionMap.RegionDataFactory(construct_method)
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,575
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/provider/SolarPositionCalculator.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-17
@author: Neil Borle
'''
from src.provider.Planet import Planet, planet_enum, res
from src.units.RaDec import get_instance as radec_get_instance
from src.units.HeliocentricCoordinates import get_instance as hc_get_instance
def get_solar_position(time):
'''
# Calculates the position of the Sun in Ra and Dec
'''
sun = Planet(planet_enum.SUN, res[planet_enum.SUN][0],
res[planet_enum.SUN][1], res[planet_enum.SUN][2])
sun_coords = hc_get_instance(None, sun, time)
ra_dec = radec_get_instance(None, sun_coords, sun, time)
return ra_dec
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,576
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/layers/NewStarsLayer.py
|
'''
// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor, Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-22
@author: Neil Borle
'''
from FileBasedLayer import FileBasedLayer
class NewStarsLayer(FileBasedLayer):
'''
Displays stars in the renderer
'''
def get_layer_id(self):
return -100
def get_layer_name_id(self):
raise NotImplementedError("not implemented yet")
def get_preference_id(self):
return "source_provider.0"
def __init__(self):
'''
Constructor
'''
FileBasedLayer.__init__(self, "assets/stars.binary")
if __name__ == "__main__":
'''
For debugging purposes
'''
import os
os.chdir("../../")
SL = NewStarsLayer()
SL.initialize()
first_protobuf_source = SL.file_sources[0]
gc = first_protobuf_source.get_geo_coords()
print gc.x, gc.y, gc.z
print first_protobuf_source.names
print first_protobuf_source.get_points()
print first_protobuf_source.get_labels()
print first_protobuf_source.get_lines()
point = first_protobuf_source.get_points()[0]
label = first_protobuf_source.get_labels()[0]
#line = first_protobuf_source.get_lines()[0]
print point.size, point.color, point.geocentric_coords, point.point_shape
print label.label, label.geocentric_coords, label.color, label.offset, label.font_size
#print line.color, line.line_width, line.gc_verticies
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,577
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/renderer/SkyBox.py
|
'''
// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-17
@author: Neil Borle
'''
import math
from RendererObjectManager import RendererObjectManager
from src.rendererUtil.VertexBuffer import VertexBuffer
from src.rendererUtil.ColorBuffer import ColorBuffer
from src.rendererUtil.IndexBuffer import IndexBuffer
from src.units.Vector3 import Vector3
from src.units.GeocentricCoordinates import GeocentricCoordinates
from src.utils.VectorUtil import cross_product, normalized
class SkyBox(RendererObjectManager):
'''
Provides the background that goes behind everything
'''
NUM_VERTEX_BANDS = 8
# This number MUST be even
NUM_STEPS_IN_BAND = 10
# Used to make sure rounding error doesn't make us have off-by-one errors in our iterations.
EPSILON = 1e-3
def reload(self, gl, full_reload):
self.vertex_buffer.reload()
self.color_buffer.reload()
self.index_buffer.reload()
def set_sun_position(self, new_pos):
self.sun_pos = new_pos.copy()
def draw_internal(self, gl):
if self.render_state.night_vision_mode:
return
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
gl.glEnableClientState(gl.GL_COLOR_ARRAY)
gl.glDisableClientState(gl.GL_TEXTURE_COORD_ARRAY)
gl.glEnable(gl.GL_CULL_FACE)
gl.glFrontFace(gl.GL_CW)
gl.glCullFace(gl.GL_BACK)
gl.glShadeModel(gl.GL_SMOOTH)
gl.glPushMatrix()
# Rotate the sky box to the position of the sun.
cp = cross_product(Vector3(0, 1, 0), self.sun_pos)
cp = normalized(cp)
angle = 180.0 / math.pi * math.acos(self.sun_pos.y)
gl.glRotatef(angle, cp.x, cp.y, cp.z)
self.vertex_buffer.set(gl)
self.color_buffer.set(gl)
self.index_buffer.draw(gl, gl.GL_TRIANGLES)
gl.glPopMatrix()
def __init__(self, layer_id, texture_manager):
'''
Constructor
'''
RendererObjectManager.__init__(self, layer_id, texture_manager)
self.vertex_buffer = VertexBuffer(0, True)
self.color_buffer = ColorBuffer(0, True)
self.index_buffer = IndexBuffer(0, True)
self.sun_pos = GeocentricCoordinates(0, 1, 0)
num_vertices = self.NUM_VERTEX_BANDS * self.NUM_STEPS_IN_BAND
num_indices = (self.NUM_VERTEX_BANDS-1) * self.NUM_STEPS_IN_BAND * 6
self.vertex_buffer.reset(num_vertices)
self.color_buffer.reset(num_vertices)
self.index_buffer.reset(num_indices)
sin_angles = [0.0] * self.NUM_STEPS_IN_BAND
cos_angles = [0.0] * self.NUM_STEPS_IN_BAND
angle_in_band = 0
d_angle = 2* math.pi / float(self.NUM_STEPS_IN_BAND - 1)
for i in range(0, self.NUM_STEPS_IN_BAND):
sin_angles[i] = math.sin(angle_in_band)
cos_angles[i] = math.cos(angle_in_band)
angle_in_band += d_angle
band_step = 2.0 / float((self.NUM_VERTEX_BANDS-1) + self.EPSILON)
vb = self.vertex_buffer
cb = self.color_buffer
band_pos = 1
for band in range(0, self.NUM_VERTEX_BANDS):
a, r, g, b = 0, 0, 0, 0
if band_pos > 0:
intensity = long(band_pos * 20 + 50) & 0xFFFFFFFF
a = 0xFF
r = (intensity << 16) & 0x00FF0000
g = (intensity << 16) & 0x0000FF00
b = (intensity << 16) & 0x000000FF
else:
intensity = long(band_pos * 40 + 40) & 0xFFFFFFFF
color = (intensity << 16) | (intensity << 8) | (intensity)
a = 0xFF
r = color & 0x00FF0000
g = color & 0x0000FF00
b = color & 0x000000FF
band_pos -= band_step
sin_phi = math.sqrt(1 - band_pos*band_pos) if band_pos > -1 else 0
for i in range(0, self.NUM_STEPS_IN_BAND):
vb.add_point(Vector3(cos_angles[i] * sin_phi, band_pos, sin_angles[i] * sin_phi))
cb.add_color(a, r, g, b)
ib = self.index_buffer
# Set the indices for the first band.
top_band_start = 0
bottom_band_start = self.NUM_STEPS_IN_BAND
for triangle_band in range(0, self.NUM_VERTEX_BANDS-1):
for offset_from_start in range(0, self.NUM_STEPS_IN_BAND-1):
# Draw one quad as two triangles.
top_left = (top_band_start + offset_from_start)
top_right = (top_left + 1)
bottom_left = (bottom_band_start + offset_from_start)
bottom_right = (bottom_left + 1)
# First triangle
ib.add_index(top_left)
ib.add_index(bottom_right)
ib.add_index(bottom_left)
# Second triangle
ib.add_index(top_right)
ib.add_index(bottom_right)
ib.add_index(top_left)
# Last quad: connect the end with the beginning.
# Top left, bottom right, bottom left
ib.add_index((top_band_start + self.NUM_STEPS_IN_BAND - 1))
ib.add_index(bottom_band_start)
ib.add_index((bottom_band_start + self.NUM_STEPS_IN_BAND - 1))
# Top right, bottom right, top left
ib.add_index(top_band_start)
ib.add_index(bottom_band_start)
ib.add_index((top_band_start + self.NUM_STEPS_IN_BAND - 1))
top_band_start += self.NUM_STEPS_IN_BAND
bottom_band_start += self.NUM_STEPS_IN_BAND
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,578
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/layers/MeteorShowerLayer.py
|
'''
// Copyright 2011 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-25
@author: Neil Borle
'''
import datetime as dt
from time import mktime
from datetime import datetime
from SourceLayer import SourceLayer
from src.base.TimeConstants import MILLISECONDS_PER_DAY
from src.source.AbstractAstronomicalSource import AbstractAstronomicalSource
from src.source.TextSource import TextSource
from src.source.ImageSource import ImageSource
from src.renderer.RendererObjectManager import RendererObjectManager
from src.units.Vector3 import Vector3
from src.units.GeocentricCoordinates import get_instance
class MeteorShowerLayer(SourceLayer):
'''
Shows well known meteor showers in the sky.
'''
class Shower(object):
'''
state for a meteor shower
'''
def __init__(self, name_id, radiant, start, peak, end, peak_meteors_per_hour):
self.name_id = name_id
self.radiant = radiant
self.start = start
self.peak = peak
self.end = end
self.peak_meteors_per_hour = peak_meteors_per_hour
class MeteorRadiantSource(AbstractAstronomicalSource):
'''
Meteor Showers extend AstronomicalSource so that they can
be rendered in the same way as other Astronomical sources.
'''
# G1 bug not present in PyOpenGL
LABEL_COLOR = 0x817ef6
UP = Vector3(0.0, 1.0, 0.0)
UPDATE_FREQ_MS = 1 * MILLISECONDS_PER_DAY
SCALE_FACTOR = 0.03
def get_names(self):
return self.search_names
def get_search_location(self):
return self.shower.radiant
def update_shower(self):
self.last_update_time_Ms = mktime(self.model.get_time())
# We will only show the shower if it's the right time of year.
now = self.model.get_time()
# Standardize on the same year as we stored for the showers.
now = dt.datetime(MeteorShowerLayer.ANY_OLD_YEAR,
now.tm_mon,now.tm_mday,0,0,0).timetuple()
self.the_image.set_up_vector(self.UP)
if mktime(self.shower.start) < mktime(now) and \
mktime(self.shower.end) > mktime(now):
self.label.label = self.name
percent_to_peak = 0
if (mktime(now) < mktime(self.shower.peak)):
percent_to_peak = (mktime(now) - mktime(self.shower.start)) / \
(mktime(self.shower.peak) - mktime(self.shower.start))
else:
percent_to_peak = (mktime(self.shower.end) - mktime(now)) / \
(mktime(self.shower.end) - mktime(self.shower.peak))
# Not sure how best to calculate number of meteors - use linear interpolation for now.
number_of_meteors_per_hour = self.shower.peak_meteors_per_hour * percent_to_peak
if number_of_meteors_per_hour > MeteorShowerLayer.METEOR_THRESHOLD_PER_HR:
self.the_image.set_image_id("meteor2_screen")
else:
self.the_image.set_image_id("meteor1_screen")
else:
self.label.label = " "
self.the_image.set_image_id("blank")
def initialize(self):
self.update_shower()
return self
#override(AbstractAstronomicalSource)
def update(self):
update_types = set()
if abs(mktime(self.model.get_time()) - self.last_update_time_Ms) > self.UPDATE_FREQ_MS:
self.update_shower()
update_types = set([RendererObjectManager().update_type.Reset])
return update_types
#override(AbstractAstronomicalSource)
def get_images(self):
return self.image_sources
#override(AbstractAstronomicalSource)
def get_labels(self):
return self.label_sources
def __init__(self, model, shower):
'''
constructor
'''
AbstractAstronomicalSource.__init__(self)
self.image_sources = []
self.label_sources = []
self.lastUpdateTimeMs = 0
self.search_names = []
self.model = model
self.shower = shower
self.name = shower.name_id
start_date = datetime.fromtimestamp(mktime(shower.start)).strftime('%m/%d')
end_date = datetime.fromtimestamp(mktime(shower.end)).strftime('%m/%d')
self.search_names.append(self.name + " (" + start_date + "-" + end_date + ")")
# blank is a 1pxX1px image that should be invisible.
# We'd prefer not to show any image except on the shower dates, but there
# appears to be a bug in the renderer/layer interface in that Update values are not
# respected. Ditto the label.
self.the_image = ImageSource(shower.radiant, "blank", self.UP, self.SCALE_FACTOR)
self.image_sources.append(self.the_image)
self.label = TextSource(self.name, self.LABEL_COLOR, shower.radiant)
self.label_sources.append(self.label)
ANY_OLD_YEAR = 2000
# Number of meteors per hour for the larger graphic
METEOR_THRESHOLD_PER_HR = 10
def initialize_showers(self):
'''
A list of all the meteor showers with > 10 per hour
Source: http://www.imo.net/calendar/2011#table5
Note the zero-based month. 10=November
Actual start for Quadrantids is December 28 - but we can't cross a year boundary.
'''
self.showers.append(self.Shower("Quadrantids", get_instance(230, 49),
dt.datetime(self.ANY_OLD_YEAR,1,1,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,1,4,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,1,12,0,0,0).timetuple(),
120))
self.showers.append(self.Shower("Lyrids", get_instance(271, 34),
dt.datetime(self.ANY_OLD_YEAR,4,16,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,4,22,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,4,25,0,0,0).timetuple(),
18))
self.showers.append(self.Shower("Eta Aquariids", get_instance(338, -1),
dt.datetime(self.ANY_OLD_YEAR,4,19,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,5,6,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,5,28,0,0,0).timetuple(),
70))
self.showers.append(self.Shower("Delta Aquariids", get_instance(340, -16),
dt.datetime(self.ANY_OLD_YEAR,7,12,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,7,30,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,8,23,0,0,0).timetuple(),
16))
self.showers.append(self.Shower("Perseids", get_instance(48, 58),
dt.datetime(self.ANY_OLD_YEAR,7,17,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,8,13,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,8,24,0,0,0).timetuple(),
100))
self.showers.append(self.Shower("Orionids", get_instance(95, 16),
dt.datetime(self.ANY_OLD_YEAR,10,2,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,10,21,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,11,7,0,0,0).timetuple(),
25))
self.showers.append(self.Shower("Leonids", get_instance(152, 22),
dt.datetime(self.ANY_OLD_YEAR,11,6,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,11,18,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,11,30,0,0,0).timetuple(),
20))
self.showers.append(self.Shower("Puppid-Velids", get_instance(123, -45),
dt.datetime(self.ANY_OLD_YEAR,12,1,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,12,7,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,12,15,0,0,0).timetuple(),
10))
self.showers.append(self.Shower("Geminids", get_instance(112, 33),
dt.datetime(self.ANY_OLD_YEAR,12,7,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,12,14,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,12,17,0,0,0).timetuple(),
120))
self.showers.append(self.Shower("Ursids", get_instance(217, 76),
dt.datetime(self.ANY_OLD_YEAR,12,17,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,12,23,0,0,0).timetuple(),
dt.datetime(self.ANY_OLD_YEAR,12,26,0,0,0).timetuple(),
10))
def initialize_astro_sources(self, sources):
for shower in self.showers:
sources.append(self.MeteorRadiantSource(self.model, shower))
def get_layer_id(self):
return -107
def get_layer_name_id(self):
raise NotImplementedError("not implemented yet")
def get_preference_id(self):
return "source_provider.7"
def get_layer_name(self):
return "Meteor Showers"
def __init__(self, model):
'''
Constructor
'''
SourceLayer.__init__(self, True)
self.showers = []
self.model = model
self.initialize_showers()
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,579
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/control/LocationController.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-08-29
@author: Neil
'''
from Controller import Controller
from units.LatLong import LatLong
class LocationController(Controller):
'''
Sets the AstronomerModel's position in terms of
latitude and longitude.
'''
class LocationProvider(object):
'''
Get the location from a phone or from a config file
'''
FROM_FILE = True
def get_lat_long(self):
if self.FROM_FILE:
return self.lat_long_from_file()
else:
# have not tested with a phone
raise NotImplementedError
def lat_long_from_file(self):
with open("assets/LatitudeLongitudeConfig.txt", 'r') as f:
for line in f.readlines():
if not line.startswith('#'):
lat, lon = line.split(',')
return LatLong(float(lat), float(lon))
def __init__(self, force_gps):
self.force_gps = force_gps
# Must match the key in the preferences file.
NO_AUTO_LOCATE = "no_auto_locate"
# Must match the key in the preferences file.
FORCE_GPS = "force_gps"
MINIMUM_DISTANCE_BEFORE_UPDATE_METRES = 2000
LOCATION_UPDATE_TIME_MILLISECONDS = 600000
MIN_DIST_TO_SHOW_TOAST_DEGS = 0.01
def start(self):
no_auto_locate = self.shared_prefs.PREFERENCES[self.NO_AUTO_LOCATE]
force_gps = self.shared_prefs.PREFERENCES[self.FORCE_GPS]
if no_auto_locate:
self.set_location_from_prefs()
else:
location_provider = self.LocationProvider(force_gps)
self.set_location_in_model(location_provider.get_lat_long())
def set_location_in_model(self, lat_long):
self.model.set_location(lat_long)
def set_location_from_prefs(self):
lat, lon = self.shared_prefs.LATITUDE, self.shared_prefs.LONGITUDE
self.set_location_in_model(LatLong(lat, lon))
def stop(self):
# do nothing
pass
def on_location_change(self):
raise NotImplementedError
def __init__(self, prefs):
'''
Constructor
'''
Controller.__init__(self)
self.shared_prefs = prefs
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,580
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/utils/Colors.py
|
'''
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-20
@author: Neil Borle
'''
from Enumeration import enum
'''
Create a colour enum for easy access to the
hex values for all of the following colours
'''
colors = enum(\
WHITE=0xFFFFFF, \
IVORY=0xFFFFF0, \
LIGHTYELLOW=0xFFFFE0, \
YELLOW=0xFFFF00, \
SNOW=0xFFFAFA, \
FLORALWHITE=0xFFFAF0, \
LEMONCHIFFON=0xFFFACD, \
CORNSILK=0xFFF8DC, \
SEASHELL=0xFFF5EE, \
LAVENDERBLUSH=0xFFF0F5, \
PAPAYAWHIP=0xFFEFD5, \
BLANCHEDALMOND=0xFFEBCD, \
MISTYROSE=0xFFE4E1, \
BISQUE=0xFFE4C4, \
MOCCASIN=0xFFE4B5, \
NAVAJOWHITE=0xFFDEAD, \
PEACHPUFF=0xFFDAB9, \
GOLD=0xFFD700, \
PINK=0xFFC0CB, \
LIGHTPINK=0xFFB6C1, \
ORANGE=0xFFA500, \
LIGHTSALMON=0xFFA07A, \
DARKORANGE=0xFF8C00, \
CORAL=0xFF7F50, \
HOTPINK=0xFF69B4, \
TOMATO=0xFF6347, \
ORANGERED=0xFF4500, \
DEEPPINK=0xFF1493, \
FUCHSIA=0xFF00FF, \
MAGENTA=0xFF00FF, \
RED=0xFF0000, \
OLDLACE=0xFDF5E6, \
LIGHTGOLDENRODYELLOW=0xFAFAD2, \
LINEN=0xFAF0E6, \
ANTIQUEWHITE=0xFAEBD7, \
SALMON=0xFA8072, \
GHOSTWHITE=0xF8F8FF, \
MINTCREAM=0xF5FFFA, \
WHITESMOKE=0xF5F5F5, \
BEIGE=0xF5F5DC, \
WHEAT=0xF5DEB3, \
SANDYBROWN=0xF4A460, \
AZURE=0xF0FFFF, \
HONEYDEW=0xF0FFF0, \
ALICEBLUE=0xF0F8FF, \
KHAKI=0xF0E68C, \
LIGHTCORAL=0xF08080, \
PALEGOLDENROD=0xEEE8AA, \
VIOLET=0xEE82EE, \
DARKSALMON=0xE9967A, \
LAVENDER=0xE6E6FA, \
LIGHTCYAN=0xE0FFFF, \
BURLYWOOD=0xDEB887, \
PLUM=0xDDA0DD, \
GAINSBORO=0xDCDCDC, \
CRIMSON=0xDC143C, \
PALEVIOLETRED=0xDB7093, \
GOLDENROD=0xDAA520, \
ORCHID=0xDA70D6, \
THISTLE=0xD8BFD8, \
LIGHTGREY=0xD3D3D3, \
TAN=0xD2B48C, \
CHOCOLATE=0xD2691E, \
PERU=0xCD853F, \
INDIANRED=0xCD5C5C, \
MEDIUMVIOLETRED=0xC71585, \
SILVER=0xC0C0C0, \
DARKKHAKI=0xBDB76B, \
ROSYBROWN=0xBC8F8F, \
MEDIUMORCHID=0xBA55D3, \
DARKGOLDENROD=0xB8860B, \
FIREBRICK=0xB22222, \
POWDERBLUE=0xB0E0E6, \
LIGHTSTEELBLUE=0xB0C4DE, \
PALETURQUOISE=0xAFEEEE, \
GREENYELLOW=0xADFF2F, \
LIGHTBLUE=0xADD8E6, \
DARKGRAY=0xA9A9A9, \
BROWN=0xA52A2A, \
SIENNA=0xA0522D, \
YELLOWGREEN=0x9ACD32, \
DARKORCHID=0x9932CC, \
PALEGREEN=0x98FB98, \
DARKVIOLET=0x9400D3, \
MEDIUMPURPLE=0x9370DB, \
LIGHTGREEN=0x90EE90, \
DARKSEAGREEN=0x8FBC8F, \
SADDLEBROWN=0x8B4513, \
DARKMAGENTA=0x8B008B, \
DARKRED=0x8B0000, \
BLUEVIOLET=0x8A2BE2, \
LIGHTSKYBLUE=0x87CEFA, \
SKYBLUE=0x87CEEB, \
GRAY=0x808080, \
OLIVE=0x808000, \
PURPLE=0x800080, \
MAROON=0x800000, \
AQUAMARINE=0x7FFFD4, \
CHARTREUSE=0x7FFF00, \
LAWNGREEN=0x7CFC00, \
MEDIUMSLATEBLUE=0x7B68EE, \
LIGHTSLATEGRAY=0x778899, \
SLATEGRAY=0x708090, \
OLIVEDRAB=0x6B8E23, \
SLATEBLUE=0x6A5ACD, \
DIMGRAY=0x696969, \
MEDIUMAQUAMARINE=0x66CDAA, \
CORNFLOWERBLUE=0x6495ED, \
CADETBLUE=0x5F9EA0, \
DARKOLIVEGREEN=0x556B2F, \
INDIGO=0x4B0082, \
MEDIUMTURQUOISE=0x48D1CC, \
DARKSLATEBLUE=0x483D8B, \
STEELBLUE=0x4682B4, \
ROYALBLUE=0x4169E1, \
TURQUOISE=0x40E0D0, \
MEDIUMSEAGREEN=0x3CB371, \
LIMEGREEN=0x32CD32, \
DARKSLATEGRAY=0x2F4F4F, \
SEAGREEN=0x2E8B57, \
FORESTGREEN=0x228B22, \
LIGHTSEAGREEN=0x20B2AA, \
DODGERBLUE=0x1E90FF, \
MIDNIGHTBLUE=0x191970, \
AQUA=0x00FFFF, \
CYAN=0x00FFFF, \
SPRINGGREEN=0x00FF7F, \
LIME=0x00FF00, \
MEDIUMSPRINGGREEN=0x00FA9A, \
DARKTURQUOISE=0x00CED1, \
DEEPSKYBLUE=0x00BFFF, \
DARKCYAN=0x008B8B, \
TEAL=0x008080, \
GREEN=0x008000, \
DARKGREEN=0x006400, \
BLUE=0x0000FF, \
MEDIUMBLUE=0x0000CD, \
DARKBLUE=0x00008B, \
NAVY=0x000080, \
BLACK=0x000000)
if __name__ == "__main__":
'''
For debugging purposes
'''
print colors.NAVY
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,581
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/layers/FileBasedLayer.py
|
'''
// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor, Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-22
@author: Neil Borle
'''
from SourceLayer import SourceLayer
from src.sourceProto import SourceProto
from src.sourceProto.ProtobufAstronomicalSource import ProtobufAstronomicalSource
class FileBasedLayer(SourceLayer):
'''
For stars, constellations and messier objects. This is an abstraction
for all layers that obtain their data from files.
'''
executor_for_multiple_threads = None
file_name = ""
def initialize(self):
# Need to execute this in a background thread
self.read_source_file(self.file_name)
SourceLayer.initialize(self)
def initialize_astro_sources(self, sources):
sources += self.file_sources
def read_source_file(self, file_name):
astro_sources_proto = SourceProto.AstronomicalSourcesProto()
try:
f = open(file_name, "rb")
astro_sources_proto.ParseFromString(f.read())
except:
raise IOError("Could not open file: " + file_name)
finally:
f.close()
for source in astro_sources_proto.source:
self.file_sources.append(ProtobufAstronomicalSource(source))
def __init__(self, file_string):
'''
Constructor
'''
SourceLayer.__init__(self, False)
self.file_name = file_string
self.file_sources = []
if __name__ == "__main__":
'''
For debugging purposes
'''
import os
os.chdir("../..")
FBL = FileBasedLayer("assets/stars.binary")
FBL.initialize()
first_protobuf_source = FBL.file_sources[0]
gc = first_protobuf_source.get_geo_coords()
print gc.x, gc.y, gc.z
print first_protobuf_source.names
print first_protobuf_source.get_points()
print first_protobuf_source.get_labels()
print first_protobuf_source.get_lines()
#point = first_protobuf_source.get_points()[0]
#label = first_protobuf_source.get_labels()[0]
#line = first_protobuf_source.get_lines()[0]
#print point.size, point.color, point.geocentric_coords, point.point_shape
#print label.label, label.geocentric_coords, label.color, label.offset, label.font_size
#print line.color, line.line_width, line.gc_verticies
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,582
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/layers/SkyGradientLayer.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor, Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-17
@author: Neil Borle
'''
import threading
import calendar
from src.base.TimeConstants import MILLISECONDS_PER_MINUTE
from src.provider.SolarPositionCalculator import get_solar_position
from src.units.GeocentricCoordinates import get_instance
class SkyGradientLayer(object):
'''
updates the position of the sky gradient.
'''
renderer_lock = threading.RLock()
UPDATE_FREQUENCY_MS = 5 * MILLISECONDS_PER_MINUTE
def initialize(self):
# Do Nothing
pass
def register_with_renderer(self, rend_controller):
self.controller = rend_controller
self.redraw()
def set_visible(self, visible):
if visible:
self.redraw()
else:
with self.renderer_lock:
self.controller.queue_disable_sky_gradient()
def redraw(self):
'''
Redraws the sky shading gradient using the model's current time.
'''
model_time = self.model.get_time()
Ms_since_epoch = calendar.timegm(model_time) * 100
if abs(Ms_since_epoch - self.last_update_time_Ms) > self.UPDATE_FREQUENCY_MS:
self.last_update_time_Ms = Ms_since_epoch
sun_pos = get_solar_position(model_time)
with self.renderer_lock:
gc = get_instance(sun_pos.ra, sun_pos.dec)
self.controller.queue_enable_sky_gradient(gc)
def get_layer_id(self):
return 0
def get_layer_name(self):
return "Sky Gradient"
def get_preference_id(self):
return "source_provider.8"
def get_layer_name_id(self):
raise NotImplementedError("not implemented yet")
def search_by_object_name(self, name):
return []
def get_object_names_matching_prefix(self, prefix):
return set()
def __init__(self, model):
'''
Constructor
'''
self.model = model
self.controller = None
self.last_update_time_Ms = 0
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,583
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/control/AstronomerModel.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-23
@author: Neil Borle
'''
import math
import time
from Pointing import Pointing
from RealClock import RealClock
from src.skypython import ApplicationConstants
from src.utils import Geometry
from src.units.LatLong import LatLong
from src.units.Vector3 import Vector3
from src.units.Matrix33 import get_colmatrix_from_vectors, get_identity_matrix
from src.units.Matrix33 import get_rowmatrix_from_vectors
from src.units.GeocentricCoordinates import get_instance
from src.units.GeocentricCoordinates import get_instance_from_vector3
class AstronomerModel(object):
'''
Class responsible to modelling the astronomer
This class has state on the location and orientation of the astronomer
in space and performs calculations for obtaining directions and time.
As stated in the android version:
There are 3 frames of reference:
Celestial - a frame fixed against the background stars with
x, y, z axes pointing to (RA = 90, DEC = 0), (RA = 0, DEC = 0), DEC = 90
Phone - a frame fixed in the phone with x across the short side, y across
the long side, and z coming out of the phone screen.
Local - a frame fixed in the astronomer's local position. x is due east
along the ground y is due north along the ground, and z points towards the
zenith.
We calculate the local frame in phone coords, and in celestial coords and
calculate a transform between the two.
In the following, N, E, U correspond to the local
North, East and Up vectors (ie N, E along the ground, Up to the Zenith)
In Phone Space: axesPhone = [N, E, U]
In Celestial Space: axesSpace = [N, E, U]
We find T such that axesCelestial = T * axesPhone
Then, [viewDir, viewUp]_celestial = T * [viewDir, viewUp]_phone
where the latter vector is trivial to calculate.
'''
POINTING_DIR_IN_PHONE_COORDS = Vector3(0, 0, -1)
SCREEN_UP_IN_PHONE_COORDS = Vector3(0, 1, 0)
AXIS_OF_EARTHS_ROTATION = Vector3(0, 0, 1)
MINIMUM_TIME_BETWEEN_CELESTIAL_COORD_UPDATES_MILLIS = 60000.0
def get_time(self):
'''
return a time struct of the current GM time
'''
return time.gmtime(self.clock.get_time())
def set_location(self, lat_long):
self.location = lat_long
self.calculate_local_north_and_up_in_celestial_coords(True)
def set_phone_sensor_values(self, accel, mag_field):
self.acceleration.assign(vector3=accel)
self.magnetic_field.assign(vector3=mag_field)
def get_north(self):
'''
In celestial coordinates
'''
self.calculate_local_north_and_up_in_celestial_coords(False)
return get_instance_from_vector3(self.true_north_celestial)
def get_south(self):
'''
In celestial coordinates
'''
self.calculate_local_north_and_up_in_celestial_coords(False)
v = Geometry.scale_vector(self.true_north_celestial, -1)
return get_instance_from_vector3(v)
def get_zenith(self):
'''
In celestial coordinates
'''
self.calculate_local_north_and_up_in_celestial_coords(False)
return get_instance_from_vector3(self.up_celestial)
def get_nadir(self):
'''
In celestial coordinates
'''
self.calculate_local_north_and_up_in_celestial_coords(False)
v = Geometry.scale_vector(self.up_celestial, -1)
return get_instance_from_vector3(v)
def get_east(self):
'''
In celestial coordinates
'''
self.calculate_local_north_and_up_in_celestial_coords(False)
return get_instance_from_vector3(self.true_east_celestial)
def get_west(self):
'''
In celestial coordinates
'''
self.calculate_local_north_and_up_in_celestial_coords(False)
v = Geometry.scale_vector(self.true_east_celestial, -1)
return get_instance_from_vector3(v)
def set_mag_dec_calc(self, calculator):
self.magnetic_declination_calc = calculator
self.calculate_local_north_and_up_in_celestial_coords(True)
def calculate_pointing(self):
'''
update the direction that the phone is pointing and the up vector
perpendicular to the phone (in celestial coords).
'''
if not (self.auto_update_pointing):
return
transform = Geometry.matrix_multiply(self.axes_magnetic_celestial_matrix, \
self.axes_phone_inverse_matrix)
view_in_space_space = \
Geometry.matrix_vector_multiply(transform, self.POINTING_DIR_IN_PHONE_COORDS)
screen_up_in_space_space = \
Geometry.matrix_vector_multiply(transform, self.SCREEN_UP_IN_PHONE_COORDS)
self.pointing.update_line_of_sight(view_in_space_space)
self.pointing.update_perpendicular(screen_up_in_space_space)
def calculate_local_north_and_up_in_celestial_coords(self, force_update):
current_time = self.get_time_in_millis()
diff = math.fabs(current_time - self.celestial_coords_last_updated)
if (not force_update) and diff < self.MINIMUM_TIME_BETWEEN_CELESTIAL_COORD_UPDATES_MILLIS:
return
self.celestial_coords_last_updated = current_time
self.update_magnetic_correction()
up_ra, up_dec = Geometry.calculate_RADec_of_zenith(self.get_time(), self.location)
self.up_celestial = get_instance(up_ra, up_dec)
z = self.AXIS_OF_EARTHS_ROTATION
z_dotu = Geometry.scalar_product(self.up_celestial, z)
self.true_north_celestial = \
Geometry.add_vectors(z, Geometry.scale_vector(self.up_celestial, -z_dotu))
self.true_north_celestial.normalize()
self.true_east_celestial = Geometry.vector_product(self.true_north_celestial, \
self.up_celestial)
# Apply magnetic correction. Rather than correct the phone's axes for
# the magnetic declination, it's more efficient to rotate the
# celestial axes by the same amount in the opposite direction.
declination = self.magnetic_declination_calc.get_declination()
rotation_matrix = Geometry.calculate_rotation_matrix(declination, self.up_celestial)
magnetic_north_celestial = Geometry.matrix_vector_multiply(rotation_matrix, \
self.true_north_celestial)
magnetic_east_celestial = Geometry.vector_product(magnetic_north_celestial, \
self.up_celestial)
self.axes_magnetic_celestial_matrix = get_colmatrix_from_vectors(magnetic_north_celestial, \
self.up_celestial, \
magnetic_east_celestial)
def calculate_local_north_and_up_in_phone_coords(self):
down = self.acceleration.copy()
down.normalize()
# Magnetic field goes *from* North to South, so reverse it.
magnetic_field_to_north = self.magnetic_field.copy()
magnetic_field_to_north.scale(-1)
magnetic_field_to_north.normalize()
# This is the vector to magnetic North *along the ground*.
v2 = Geometry.scale_vector(down, -Geometry.scalar_product(magnetic_field_to_north, \
down))
magnetic_north_phone = Geometry.add_vectors(magnetic_field_to_north, v2)
magnetic_north_phone.normalize()
up_phone = Geometry.scale_vector(down, -1)
magnetic_east_phone = Geometry.vector_product(magnetic_north_phone, up_phone)
# The matrix is orthogonal, so transpose it to find its inverse.
# Easiest way to do that is to construct it from row vectors instead
# of column vectors.
self.axes_phone_inverse_matrix = \
get_rowmatrix_from_vectors(magnetic_north_phone,
up_phone,
magnetic_east_phone)
def update_magnetic_correction(self):
self.magnetic_declination_calc.set_location_and_time(\
self.location, self.get_time_in_millis())
def get_pointing(self):
self.calculate_local_north_and_up_in_phone_coords()
self.calculate_pointing()
return self.pointing
def set_pointing(self, line_of_sight, perpendicular):
'''
Takes 2 vector3 objects as parameters
'''
self.pointing.update_line_of_sight(line_of_sight)
self.pointing.update_perpendicular(perpendicular)
def set_clock(self, clock):
'''
clock must have a get_time() method
'''
self.clock = clock
self.calculate_local_north_and_up_in_celestial_coords(True)
def get_time_in_millis(self):
return int(self.clock.get_time() * 1000)
def __init__(self, mag_dec_calc):
'''
Constructor
'''
self.auto_update_pointing = True
self.field_of_view = 45 #Degrees
self.location = LatLong(0, 0)
self.clock = RealClock()
self.celestial_coords_last_updated = -1
# provides correction from true North to magnetic North
self.magnetic_declination_calc = mag_dec_calc
#The pointing comprises a vector into the phone's screen expressed in
#celestial coordinates combined with a perpendicular vector along the
#phone's longer side.
self.pointing = Pointing()
#The sensor acceleration in the phone's coordinate system.
self.acceleration = ApplicationConstants.INITIAL_DOWN
#The sensor magnetic field in the phone's coordinate system.
self.magnetic_field = ApplicationConstants.INITIAL_SOUTH
#North along the ground in celestial coordinates.
self.true_north_celestial = Vector3(1, 0, 0);
#Up in celestial coordinates.
self.up_celestial = Vector3(0, 1, 0)
#East in celestial coordinates.
self.true_east_celestial = self.AXIS_OF_EARTHS_ROTATION
#[North, Up, East]^-1 in phone coordinates.
self.axes_phone_inverse_matrix = get_identity_matrix();
#[North, Up, East] in celestial coordinates. */
self.axes_magnetic_celestial_matrix = get_identity_matrix();
if __name__ == "__main__":
'''
Do nothing
'''
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,584
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/rendererUtil/TextCoordBuffer.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-03
@author: Neil Borle
'''
import numpy as np
from OpenGL import GL
from GLBuffer import GLBuffer
class TextCoordBuffer(object):
'''
Buffers text coordinates, the rectangles that hold the
text, so that they can be loaded into OpenGL. Fixed point
buffering is not available in PyOpenGL.
'''
def reset(self, num_verts):
if num_verts < 0:
num_verts = 0
self.num_vertices = num_verts
self.regenerate_buffer()
def reload(self):
self.gl_buffer.reload()
def add_text_coord(self, u, v):
#fixed_u = 0xFFFFFFFF & int(u * 65536.0)
#fixed_v = 0xFFFFFFFF & int(v * 65536.0)
#self.text_coord_buffer = np.append(self.text_coord_buffer, [fixed_u, fixed_v], 0)
self.text_coord_buffer = np.append(self.text_coord_buffer, [u, v], 0)
def set(self, gl):
if self.num_vertices == 0:
return
if self.use_vbo and self.gl_buffer.can_use_VBO:
self.gl_buffer.bind(gl, self.text_coord_buffer, self.num_vertices)
gl.glTexCoordPointer(2, gl.GL_FLOAT, 0, 0)
else:
gl.glTexCoordPointer(2, gl.GL_FLOAT, 0, self.text_coord_buffer)
def regenerate_buffer(self):
if self.num_vertices == 0:
return
self.text_coord_buffer = np.array([], dtype=np.float32)
def __init__(self, num_verts=0, vbo_bool=False):
'''
Constructor
'''
self.text_coord_buffer = None
self.gl_buffer = GLBuffer(GL.GL_ARRAY_BUFFER)
self.use_vbo = vbo_bool
self.reset(num_verts)
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,585
|
wannaphong/SkyPython
|
refs/heads/master
|
/main.py
|
'''
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-14
@author: Neil Borle
'''
import sys
from src.skypython.SkyPython import start_application
def run_all_tests():
'''
Created on 2013-07-23
@author: Morgan Redshaw
'''
print "Running all."
import doctest
import src.testing.UnitsTesting as UnitsTesting
doctest.testmod(UnitsTesting)
import src.testing.UtilsTesting as UtilsTesting
doctest.testmod(UtilsTesting)
import src.testing.SanityChecks as SanityChecks
doctest.testmod(SanityChecks)
import src.testing.ControlTests as ControlTests
doctest.testmod(ControlTests)
import src.testing.ProviderTests as ProviderTests
doctest.testmod(ProviderTests)
import src.testing.BaseTests as BaseTests
doctest.testmod(BaseTests)
print "Completed."
if __name__ == '__main__':
if '-d' in sys.argv and 'images' in sys.argv:
run_all_tests()
start_application(mode='Debug')
elif '-d' in sys.argv:
run_all_tests()
else:
start_application()
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,586
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/testing/UnitsTesting.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-07-24
@author: Morgan Redshaw
'''
def GeocentricCoordinatesTests():
'''
>>> from src.units.GeocentricCoordinates import GeocentricCoordinates
>>> one = GeocentricCoordinates(1, 2, 3)
>>> two = GeocentricCoordinates(2, 4, 6)
>>> one.scale(2)
>>> one == two
False
>>> one.equals(two)
True
'''
pass
def RaDecTests():
'''
>>> import datetime as dt
>>> import src.units.RaDec as RaDec
>>> import src.units.HeliocentricCoordinates as HeliocentricCoordinates
>>> import src.provider.Planet as Planet
>>> import src.utils.Geometry as Geometry
# Runs through multiple tests for if the planets are at the correct position
>>> EPSILON = 0.25;
// Convert from hours to degrees
>>> HOURS_TO_DEGREES = 360.0/24.0
// 2009 Jan 1, 12:00 UT1
// Sun 18h 48.8m -22d 58m
// Mercury 20h 10.6m -21d 36m
// Venus 22h 02.0m -13d 36m
// Mars 18h 17.1m -24d 05m
// Jupiter 20h 05.1m -20d 45m
// Saturn 11h 33.0m + 5d 09m
// Uranus 23h 21.7m - 4d 57m
// Neptune 21h 39.7m -14d 22m
// Pluto 18h 05.3m -17d 45m
>>> res = Planet.res
>>> Mercury = Planet.Planet(Planet.planet_enum.MERCURY, res[0][0], res[0][1], res[0][2])
>>> Venus = Planet.Planet(Planet.planet_enum.VENUS, res[1][0], res[1][1], res[1][2])
>>> Sun = Planet.Planet(Planet.planet_enum.SUN, res[2][0], res[2][1], res[2][2])
>>> Mars = Planet.Planet(Planet.planet_enum.MARS, res[3][0], res[3][1], res[3][2])
>>> Jupiter = Planet.Planet(Planet.planet_enum.JUPITER, res[4][0], res[4][1], res[4][2])
>>> Saturn = Planet.Planet(Planet.planet_enum.SATURN, res[5][0], res[5][1], res[5][2])
>>> Uranus = Planet.Planet(Planet.planet_enum.URANUS, res[6][0], res[6][1], res[6][2])
>>> Neptune = Planet.Planet(Planet.planet_enum.NEPTUNE, res[7][0], res[7][1], res[7][2])
>>> Pluto = Planet.Planet(Planet.planet_enum.PLUTO, res[8][0], res[8][1], res[8][2])
>>> now = dt.datetime(2009, 1, 1, 12, 0, 0).timetuple()
>>> earthCoords = HeliocentricCoordinates.get_instance(planet=Sun, t_struct=now)
>>> pos = RaDec.get_instance(planet=Sun, time=now, earth_coord=earthCoords)
>>> abs(18.813 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-22.97 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Mercury, time=now, earth_coord=earthCoords)
>>> abs(20.177 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-21.60 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Venus, time=now, earth_coord=earthCoords)
>>> abs(22.033 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-13.60 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Mars, time=now, earth_coord=earthCoords)
>>> abs(18.285 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-24.08 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Jupiter, time=now, earth_coord=earthCoords)
>>> abs(20.085 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-20.75 - pos.dec) < EPSILON
True
#----------------------------------------------------------------------------#
#NOTE: The following test fails in the original Stardroid junit tests as well.
#----------------------------------------------------------------------------#
>>> pos = RaDec.get_instance(planet=Saturn, time=now, earth_coord=earthCoords)
>>> abs(11.550 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(5.15 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Uranus, time=now, earth_coord=earthCoords)
>>> abs(23.362 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-4.95 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Neptune, time=now, earth_coord=earthCoords)
>>> abs(21.662 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-14.37 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Pluto, time=now, earth_coord=earthCoords)
>>> abs(18.088 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-17.75 - pos.dec) < EPSILON
True
// 2009 Sep 20, 12:00 UT1
// Sun 11h 51.4m + 0d 56m
// Mercury 11h 46.1m - 1d 45m
// Venus 10h 09.4m +12d 21m
// Mars 7h 08.6m +23d 03m
// Jupiter 21h 23.2m -16d 29m
// Saturn 11h 46.0m + 3d 40m
// Uranus 23h 41.1m - 2d 55m
// Neptune 21h 46.7m -13d 51m
// Pluto 18h 02.8m -18d 00m
>>> now = dt.datetime(2009, 9, 20, 12, 0, 0).timetuple()
>>> earthCoords = HeliocentricCoordinates.get_instance(planet=Sun, t_struct=now)
>>> pos = RaDec.get_instance(planet=Sun, time=now, earth_coord=earthCoords)
>>> abs(11.857 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(0.933 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Mercury, time=now, earth_coord=earthCoords)
>>> abs(11.768 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-1.75 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Venus, time=now, earth_coord=earthCoords)
>>> abs(10.157 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(12.35 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Mars, time=now, earth_coord=earthCoords)
>>> abs(7.143 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(23.05 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Jupiter, time=now, earth_coord=earthCoords)
>>> abs(21.387 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-16.48 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Saturn, time=now, earth_coord=earthCoords)
>>> abs(11.767 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(3.67 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Uranus, time=now, earth_coord=earthCoords)
>>> abs(23.685 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-2.92 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Neptune, time=now, earth_coord=earthCoords)
>>> abs(21.778 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-13.85 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Pluto, time=now, earth_coord=earthCoords)
>>> abs(18.047 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-18.00 - pos.dec) < EPSILON
True
// 2010 Dec 25, 12:00 UT1
// Sun 18 15.6 -23 23
// Mercury 17 24.2 -20 10
// Venus 15 04.1 -13 50
// Mars 18 58.5 -23 43
// Jupiter 23 46.4 - 2 53
// Saturn 13 03.9 - 4 14
// Uranus 23 49.6 - 1 56
// Neptune 21 55.8 -13 07
// Pluto 18 21.5 -18 50
>>> now = dt.datetime(2010, 12, 25, 12, 0, 0).timetuple()
>>> earthCoords = HeliocentricCoordinates.get_instance(planet=Sun, t_struct=now)
>>> pos = RaDec.get_instance(planet=Sun, time=now, earth_coord=earthCoords)
>>> abs(18.260 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-23.38 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Mercury, time=now, earth_coord=earthCoords)
>>> abs(17.403 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-20.17 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Venus, time=now, earth_coord=earthCoords)
>>> abs(15.068 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-13.83 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Mars, time=now, earth_coord=earthCoords)
>>> abs(18.975 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-23.72 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Jupiter, time=now, earth_coord=earthCoords)
>>> abs(23.773 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-2.88 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Saturn, time=now, earth_coord=earthCoords)
>>> abs(13.065 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-4.23 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Uranus, time=now, earth_coord=earthCoords)
>>> abs(23.827 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-1.93 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Neptune, time=now, earth_coord=earthCoords)
>>> abs(21.930 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
>>> abs(-13.12 - pos.dec) < EPSILON
True
>>> pos = RaDec.get_instance(planet=Pluto, time=now, earth_coord=earthCoords)
>>> abs(18.358 * HOURS_TO_DEGREES - pos.ra) < EPSILON
True
'''
pass
def latLongTests():
'''
>>> from src.units.LatLong import LatLong
# Test distance from 90 degrees
>>> l1 = LatLong(0, 0)
>>> l2 = LatLong(0, 90)
>>> abs(90.0 - l1.distance_from(l2)) < 0.0001
True
# Test distance from same pos
>>> l1 = LatLong(30, 9)
>>> l2 = LatLong(30, 9)
>>> l1.distance_from(l2) < 0.0001
True
# Test distance from opposite poles
>>> l1 = LatLong(-90, 45)
>>> l2 = LatLong(90, 45)
>>> abs(180 - l1.distance_from(l2)) < 0.0001
True
# Test distance from on Equator
>>> l1 = LatLong(0, -20)
>>> l2 = LatLong(0, 30)
>>> abs(50 - l1.distance_from(l2)) < 0.0001
True
# Test distance from on merridian
>>> l1 = LatLong(-10, 0)
>>> l2 = LatLong(40, 0)
>>> abs(50 - l1.distance_from(l2)) < 0.0001
True
'''
pass
def assert_matrices_equal(m1, m2, delta):
'''
This is a specialized test for Matrix33Tests
'''
correct = True
correct = (abs(m1.xx - m2.xx) < delta) & correct
correct = (abs(m1.xy - m2.xy) < delta) & correct
correct = (abs(m1.xz - m2.xz) < delta) & correct
correct = (abs(m1.yx - m2.yx) < delta) & correct
correct = (abs(m1.yy - m2.yy) < delta) & correct
correct = (abs(m1.yz - m2.yz) < delta) & correct
correct = (abs(m1.zx - m2.zx) < delta) & correct
correct = (abs(m1.zy - m2.zy) < delta) & correct
correct = (abs(m1.zz - m2.zz) < delta) & correct
return correct
def Matrix33Tests():
'''
# All needed imports
>>> from src.units.Matrix33 import Matrix33, get_identity_matrix, get_rowmatrix_from_vectors, get_colmatrix_from_vectors
>>> from src.units.Vector3 import Vector3
>>> from src.utils.Geometry import matrix_multiply
# Test construct from row vectors
>>> v1 = Vector3(1, 2, 3);
>>> v2 = Vector3(4, 5, 6);
>>> v3 = Vector3(7, 8, 9);
>>> m = Matrix33(1, 4, 7,\
2, 5, 8,\
3, 6, 9);
>>> m.transpose();
>>> mt = get_rowmatrix_from_vectors(v1, v2, v3);
>>> assert_matrices_equal(m, mt, 0.00001);
True
# Test construct from col vectors
>>> v1 = Vector3(1, 2, 3)
>>> v2 = Vector3(4, 5, 6)
>>> v3 = Vector3(7, 8, 9)
>>> m = Matrix33(1, 4, 7, \
2, 5, 8, \
3, 6, 9)
>>> mt = get_colmatrix_from_vectors(v1, v2, v3)
>>> assert_matrices_equal(m, mt, 0.00001)
True
# Test transpose
>>> m = Matrix33(1, 2, 3, 4, 5, 6, 7, 8, 9)
>>> m.transpose()
>>> mt = Matrix33(1, 4, 7, 2, 5, 8, 3, 6, 9)
>>> assert_matrices_equal(m, mt, 0.00001)
True
# Test get_determinant
>>> abs(1 - get_identity_matrix().get_determinant()) < 0.00001
True
# Test id inverse
>>> matrix1 = get_identity_matrix().get_inverse()
>>> assert_matrices_equal(matrix1, get_identity_matrix(), 0.00001)
True
# Test inversion 1
>>> m = Matrix33(1, 2, 0, 0, 1, 5, 0, 0, 1)
>>> inv = m.get_inverse()
>>> product = matrix_multiply(m, inv)
>>> assert_matrices_equal(get_identity_matrix(), product, 0.00001)
True
# Test inversion 2
>>> m = Matrix33(1, 2, 3, 6, 5, 4, 0, 0, 1)
>>> inv = m.get_inverse()
>>> product = matrix_multiply(m, inv)
>>> assert_matrices_equal(get_identity_matrix(), product, 0.00001)
True
'''
pass
def Vector3Test():
'''
>>> from src.units.Vector3 import Vector3
>>> one = Vector3(1,2,3)
>>> two = Vector3(2,4,6)
>>> one.scale(2)
>>> one.equals(two)
True
>>> one == two
False
'''
def assertVectorsEqual(v1,v2):
DELTA = 0.00005
same = True
same = (abs(v1.x - v2.x) < DELTA) & same
same = (abs(v1.y - v2.y) < DELTA) & same
same = (abs(v1.z - v2.z) < DELTA) & same
return same
def assertVectorEquals(v1, v2, tol_angle, tol_length):
import utils.Geometry as Geometry
import math
cosineSim = Geometry.cosine_similarity(v1, v2);
cosTol = math.cos(tol_angle);
return cosineSim >= cosTol
def testAssertVectorEquals_sameVector():
'''
>>> from src.units.Vector3 import Vector3
>>> v1 = Vector3(0, 0, 1)
>>> v2 = Vector3(0, 0, 1)
>>> assertVectorsEqual(v1,v2)
True
'''
pass
def testAssertVectorEquals_differentLengths():
''''
from src.units.Vector3 import Vector3
from src.utils.VectorUtil import difference
v1 = Vector3(0,0,1.0)
v2 = Vector3(0,0,1.1)
if not abs(difference(v1,v2)) > float(0.0001):
'''
pass
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,587
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/rendererUtil/ColorBuffer.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-03
@author: Neil Borle
'''
import numpy as np
from OpenGL import GL
from GLBuffer import GLBuffer
class ColorBuffer(object):
'''
Buffers colors of objects using numpy arrays so that
when set, the buffer is loaded into OpenGL.
'''
def reset(self, num_verts):
self.num_vertices = num_verts
self.regenerate_buffer()
def reload(self):
self.gl_buffer.reload()
def add_color(self, a, r, g, b):
#if col == None:
# color = ((a & 0xff) << 24) | ((b & 0xff) << 16) | ((g & 0xff) << 8) | (r & 0xff)
# self.color_buffer = np.append(self.color_buffer, [color], 0)
#else:
# self.color_buffer = np.append(self.color_buffer, [col], 0)
self.color_buffer = np.append(self.color_buffer, [r, g, b, a], 0)
def set(self, gl):
if self.num_vertices == 0:
return
if self.use_vbo and self.gl_buffer.can_use_VBO:
self.gl_buffer.bind(gl, self.color_buffer, 4*len(self.color_buffer))
gl.glColorPointer(4, GL.GL_UNSIGNED_BYTE, 0, None)
else:
gl.glColorPointer(4, gl.GL_UNSIGNED_BYTE, 0, self.color_buffer)
def regenerate_buffer(self):
if self.num_vertices == 0:
return
self.color_buffer = np.array([], dtype=np.uint32)
def __init__(self, num_verts=0, vbo_bool=False):
'''
Constructor
'''
self.color_buffer = None
self.gl_buffer = GLBuffer(GL.GL_ARRAY_BUFFER)
self.use_vbo = vbo_bool
self.reset(num_verts)
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,588
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/control/ManualOrientationController.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-23
@author: Neil Borle
'''
from Controller import Controller
from src.utils import Geometry
class ManualOrientationController(Controller):
'''
This class is responsible for the manual rotation
of the sky relative to the astronomer.
'''
def start(self):
pass
def stop(self):
pass
def change_right_left(self, radians):
'''
Moves the astronomer's pointing right or left
@param radians the angular change in the pointing in radians (only
accurate in the limit as radians tends to 0.)
'''
if not self.enabled: return
pointing = self.model.pointing
pointing_xyz = pointing.get_line_of_sight()
top_xyz = pointing.get_perpendicular()
horizontal_xyz = Geometry.vector_product(pointing_xyz, top_xyz)
delta_xyz = Geometry.scale_vector(horizontal_xyz, radians)
new_pointing_xyz = Geometry.add_vectors(pointing_xyz, delta_xyz)
new_pointing_xyz.normalize()
self.model.set_pointing(new_pointing_xyz, top_xyz)
def change_up_down(self, radians):
'''
Moves the astronomer's pointing up or down.
@param radians the angular change in the pointing in radians (only
accurate in the limit as radians tends to 0.)
'''
if not self.enabled: return
pointing = self.model.pointing
pointing_xyz = pointing.get_line_of_sight()
top_xyz = pointing.get_perpendicular()
delta_xyz = Geometry.scale_vector(top_xyz, -radians)
new_pointing_xyz = Geometry.add_vectors(pointing_xyz, delta_xyz)
new_pointing_xyz.normalize()
delta_up_xyz = Geometry.scale_vector(pointing_xyz, radians)
new_up_xyz = Geometry.add_vectors(top_xyz, delta_up_xyz)
new_up_xyz.normalize()
self.model.set_pointing(new_pointing_xyz, new_up_xyz)
def rotate(self, degrees):
'''
rotate astronomers view (clockwise/anti-clockwise)
'''
if not self.enabled: return
pointing = self.model.pointing
pointing_xyz = pointing.get_line_of_sight()
top_xyz = pointing.get_perpendicular()
rotation = Geometry.calculate_rotation_matrix(degrees, pointing_xyz)
new_up_xyz = Geometry.matrix_vector_multiply(rotation, top_xyz)
new_up_xyz.normalize()
self.model.set_pointing(pointing_xyz, new_up_xyz)
def __init__(self):
'''
Constructor, initialize superclass
'''
Controller.__init__(self)
if __name__ == "__main__":
'''
Do nothing
'''
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,589
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/views/createdMenu.py
|
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'widget.ui'
#
# Created: Thu Aug 08 09:33:25 2013
# by: pyside-uic 0.2.14 running on PySide 1.2.0
#
# WARNING! All changes made in this file will be lost!
import images_rc
from PySide import QtCore, QtGui
class Ui_menuBackground(object):
def setupUi(self, menuBackground):
self.setObjectName("menuBackground")
self.setEnabled(True)
self.resize(93, 336)
self.setMouseTracking(True)
self.setAutoFillBackground(True)
self.setStyleSheet("")
self.gridlayout = QtGui.QGridLayout(self)
self.gridlayout.setObjectName("gridlayout")
self.constellationButton = QtGui.QPushButton(self)
self.constellationButton.setMinimumSize(QtCore.QSize(40, 40))
self.constellationButton.setText("")
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icons/assets/drawable/stars_on.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.constellationButton.setIcon(icon)
self.constellationButton.setIconSize(QtCore.QSize(40, 40))
self.constellationButton.setFlat(True)
self.constellationButton.setObjectName("constellationButton")
self.gridlayout.addWidget(self.constellationButton, 1, 0, 1, 1)
self.starButton = QtGui.QPushButton(self)
self.starButton.setMinimumSize(QtCore.QSize(40, 40))
self.starButton.setText("")
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/icons/assets/drawable/star_on.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.starButton.setIcon(icon1)
self.starButton.setIconSize(QtCore.QSize(40, 40))
self.starButton.setFlat(True)
self.starButton.setObjectName("starButton")
self.gridlayout.addWidget(self.starButton, 0, 0, 1, 1)
self.gridButton = QtGui.QPushButton(self)
self.gridButton.setMinimumSize(QtCore.QSize(40, 40))
self.gridButton.setText("")
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(":/icons/assets/drawable/grid_on.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.gridButton.setIcon(icon2)
self.gridButton.setIconSize(QtCore.QSize(40, 40))
self.gridButton.setFlat(True)
self.gridButton.setObjectName("gridButton")
self.gridlayout.addWidget(self.gridButton, 5, 0, 1, 1)
self.horizonButton = QtGui.QPushButton(self)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.horizonButton.sizePolicy().hasHeightForWidth())
self.horizonButton.setSizePolicy(sizePolicy)
self.horizonButton.setMinimumSize(QtCore.QSize(40, 40))
self.horizonButton.setText("")
icon3 = QtGui.QIcon()
icon3.addPixmap(QtGui.QPixmap(":/icons/assets/drawable/horizon_on.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.horizonButton.setIcon(icon3)
self.horizonButton.setIconSize(QtCore.QSize(40, 40))
self.horizonButton.setFlat(True)
self.horizonButton.setObjectName("horizonButton")
self.gridlayout.addWidget(self.horizonButton, 6, 0, 1, 1)
self.planetsButton = QtGui.QPushButton(self)
self.planetsButton.setMinimumSize(QtCore.QSize(40, 40))
self.planetsButton.setText("")
icon4 = QtGui.QIcon()
icon4.addPixmap(QtGui.QPixmap(":/icons/assets/drawable/planet_on.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.planetsButton.setIcon(icon4)
self.planetsButton.setIconSize(QtCore.QSize(40, 40))
self.planetsButton.setFlat(True)
self.planetsButton.setObjectName("planetsButton")
self.gridlayout.addWidget(self.planetsButton, 3, 0, 1, 1)
self.messierButton = QtGui.QPushButton(self)
self.messierButton.setMinimumSize(QtCore.QSize(40, 40))
self.messierButton.setText("")
icon5 = QtGui.QIcon()
icon5.addPixmap(QtGui.QPixmap(":/icons/assets/drawable/messier_on.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.messierButton.setIcon(icon5)
self.messierButton.setIconSize(QtCore.QSize(40, 40))
self.messierButton.setFlat(True)
self.messierButton.setObjectName("messierButton")
self.gridlayout.addWidget(self.messierButton, 2, 0, 1, 1)
self.meteorButton = QtGui.QPushButton(self)
self.meteorButton.setText("")
icon6 = QtGui.QIcon()
icon6.addPixmap(QtGui.QPixmap(":/icons/assets/drawable/b_meteor_on.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.meteorButton.setIcon(icon6)
self.meteorButton.setIconSize(QtCore.QSize(40, 40))
self.meteorButton.setFlat(True)
self.meteorButton.setObjectName("meteorButton")
self.gridlayout.addWidget(self.meteorButton, 4, 0, 1, 1)
self.retranslateUi()
def retranslateUi(self):
self.setWindowTitle(QtGui.QApplication.translate("menuBackground", "Widget", None, QtGui.QApplication.UnicodeUTF8))
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,590
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/renderer/RendererObjectManager.py
|
'''
// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-26
@author: Neil Borle
'''
import threading
from src.utils.Enumeration import enum
class RendererObjectManager(object):
'''
ABSTRACT CLASS DO NOT DIRECTLY INSTANTIATE
Abstracts the commonality between all the
object managers. Chiefly important attributes.
'''
lock = threading.RLock()
max_radius_of_view = 360 # in degrees
# Used to distinguish between different renderers, so we can have sets of them.
s_index = 0
update_type = enum(Reset=0, UpdatePositions=1, UpdateImages=2)
def compare_to(self, render_object_manager):
raise NotImplementedError("Not implemented")
def draw(self, gl):
if self.enabled and self.render_state.radius_of_view <= self.max_radius_of_view:
self.draw_internal(gl)
def queue_for_reload(self, bool_full_reload):
self.listener(self, bool_full_reload)
def __init__(self, new_layer, new_texture_manager):
'''
Constructor
'''
self.layer = new_layer
self.texture_manager = new_texture_manager
self.enabled = True
self.render_state = None
self.listener = None
with self.lock:
self.index = self.s_index + 1
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,591
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/rendererUtil/IndexBuffer.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Not stated
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-03
@author: Neil Borle
'''
import numpy as np
from OpenGL import GL
from GLBuffer import GLBuffer
class IndexBuffer(object):
'''
A buffer for indicies that correspond to verticies,
numpy arrays act as buffers and are loaded into OpenGL
'''
def reset(self, num_inds):
self.num_indices = num_inds
self.regenerate_buffer()
def reload(self):
self.gl_buffer.reload()
def add_index(self, index):
self.index_buffer = np.append(self.index_buffer, [index], 0)
def regenerate_buffer(self):
if self.num_indices == 0:
return
self.index_buffer = np.array([], dtype=np.ushort)
def draw(self, gl, primitive_type):
if self.num_indices == 0:
return
if self.use_vbo and self.gl_buffer.can_use_VBO:
self.gl_buffer.bind(gl, self.index_buffer, 2*len(self.index_buffer))
gl.glDrawElements(primitive_type, self.num_indices, gl.GL_UNSIGNED_SHORT, None)
self.gl_buffer.unbind(gl)
else:
gl.glDrawElements(primitive_type, self.num_indices,
gl.GL_UNSIGNED_SHORT, self.index_buffer)
def __init__(self, num_inds=0, vbo_bool=False):
'''
Constructor
'''
self.index_buffer = None
self.gl_buffer = GLBuffer(GL.GL_ELEMENT_ARRAY_BUFFER)
self.use_vbo = vbo_bool
self.reset(num_inds)
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,592
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/skypython/__init__.py
|
'''
Created on 2013-05-15
@author: Neil
'''
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,593
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/views/ZoomWidget.py
|
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '.\widget.ui'
#
# Created: Sun Aug 18 14:42:15 2013
# by: pyside-uic 0.2.14 running on PySide 1.1.2
#
# WARNING! All changes made in this file will be lost!
from PySide import QtCore, QtGui
class Ui_ZoomBar(object):
def setupUi(self, ZoomBar):
self.setObjectName("ZoomBar")
self.resize(221, 31)
self.ZoomOut = QtGui.QPushButton(self)
self.ZoomOut.setGeometry(QtCore.QRect(0, 0, 111, 31))
self.ZoomOut.setStyleSheet("font: 75 16pt \"MS Shell Dlg 2\";")
self.ZoomOut.setObjectName("ZoomOut")
self.ZoomIn = QtGui.QPushButton(self)
self.ZoomIn.setGeometry(QtCore.QRect(110, 0, 111, 31))
self.ZoomIn.setStyleSheet("font: 75 16pt \"MS Shell Dlg 2\";")
self.ZoomIn.setObjectName("ZoomIn")
self.retranslateUi()
QtCore.QMetaObject.connectSlotsByName(self)
def retranslateUi(self):
self.setWindowTitle(QtGui.QApplication.translate("ZoomBar", "Widget", None, QtGui.QApplication.UnicodeUTF8))
self.ZoomOut.setText(QtGui.QApplication.translate("ZoomBar", "-", None, QtGui.QApplication.UnicodeUTF8))
self.ZoomIn.setText(QtGui.QApplication.translate("ZoomBar", "+", None, QtGui.QApplication.UnicodeUTF8))
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,594
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/control/MagneticDeclinationCalculatorSwitcher.py
|
'''
// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-28
@author: Neil Borle
'''
from ZeroMagneticDeclinationCalculator import ZeroMagneticDeclinationCalculator
from RealMagneticDeclinationCalculator import RealMagneticDeclinationCalculator
class MagneticDeclinationCalculatorSwitcher(object):
'''
Aggregates the RealMagneticDeclinationCalculator and the
ZeroMagneticDeclinationCalculator and switches them in the AstronomerModel.
'''
def set_the_models_calculator(self, use_real):
if use_real:
self.model.set_mag_dec_calc(self.real_calculator)
else:
self.model.set_mag_dec_calc(self.zero_calculator)
def __init__(self, model, use_real=False):
'''
Constructor
'''
self.zero_calculator = ZeroMagneticDeclinationCalculator()
self.real_calculator = RealMagneticDeclinationCalculator()
self.model = model
self.set_the_models_calculator(use_real)
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,595
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/views/WidgetFader.py
|
'''
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-08-12
@author: Neil Borle
'''
from PySide.QtCore import QTimer
class WidgetFader(object):
'''
For a given widget in the UI, this fader attaches a timer
that hides that widget after a specified interval
'''
def make_active(self):
'''
shows the widget then sets the hide timer
'''
self.controls.show()
self.timer.start(self.time_out)
def make_inactive(self):
self.controls.hide()
def __init__(self, controls, time_out=1500):
'''
Constructor
'''
self.timer = QTimer()
self.timer.timeout.connect(self.make_inactive)
self.timer.setSingleShot(True)
self.time_out = time_out
self.controls = controls
self.controls.hide()
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,596
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/touch/DragRotateZoomGestureDetector.py
|
'''
// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-08-19
@author: Neil Borle
'''
import math
from PySide import QtCore
from src.utils.Enumeration import enum
class DragRotateZoomGestureDetector(object):
'''
Handles events such as key presses and mouse button
presses, which allows for dragging and zooming
'''
STATES = enum(READY=0, DRAGGING=1, DRAGGING2=2)
def on_motion_event(self, event):
'''
The state changes are as follows.
READY -> DRAGGING -> DRAGGING2 -> READY
ACTION_DOWN: READY->DRAGGING
last position = current position
ACTION_MOVE: no state change
calculate move = current position - last position
last position = current position
ACTION_UP: DRAGGING->READY
last position = null
...or...from DRAGGING
ACTION_POINTER_DOWN: DRAGGING->DRAGGING2
we're in multitouch mode
last position1 = current position1
last poisiton2 = current position2
ACTION_MOVE:
calculate move
last position1 = current position1
NOTE: MULTITOUCH (DRAGGING2) IS NOT IMPLEMENTED YET
'''
ACTION_DOWN = QtCore.QEvent.MouseButtonPress
ACTION_UP = QtCore.QEvent.MouseButtonRelease
ACTION_MOVE = QtCore.QEvent.MouseMove
if event.type() == QtCore.QEvent.KeyPress:
self.key_press_event(event)
return True
if event.type() == ACTION_DOWN and self.state == self.STATES.READY:
self.show_menu_bool = True
self.state = self.STATES.DRAGGING
self.last_x1, self.last_y1 = event.x(), event.y()
return True
if event.type() == ACTION_MOVE and self.state == self.STATES.DRAGGING:
self.show_menu_bool = False
current_x, current_y = event.x(), event.y()
self.map_mover.on_drag(current_x - self.last_x1, current_y - self.last_y1)
self.last_x1, self.last_y1 = current_x, current_y
return True
if event.type() == ACTION_UP and self.state != self.STATES.READY:
if self.show_menu_bool:
self.show_menus()
self.show_menu_bool = False
self.state = self.STATES.READY
return True
return False
def key_press_event(self, event):
if event.key() == 16777235: # up key, zoom in
self.map_mover.control_group.zoom_in()
elif event.key() == 16777237: # down key, zoom out
self.map_mover.control_group.zoom_out()
elif event.key() == 65: # "a" key, rotate left
self.map_mover.control_group.change_right_left(-math.pi/64.0)
elif event.key() == 68: # "d" key, rotate right
self.map_mover.control_group.change_right_left(math.pi/64.0)
elif event.key() == 87: # "w" key, rotate up
self.map_mover.control_group.change_up_down(-math.pi/64.0)
elif event.key() == 83: # "s" key, rotate down
self.map_mover.control_group.change_up_down(math.pi/64.0)
def norm_squared(self, x, y):
return (x*x + y*y)
def show_menus(self):
# This function should be assigned upon instantiation
raise Exception
def __init__(self, map_mover, show_menus_func):
'''
Constructor
'''
self.map_mover = map_mover
self.state = self.STATES.READY
self.last_x1, self.last_y1 = 0, 0
self.last_x2, self.last_y2 = 0, 0
self.show_menu_bool = False
self.show_menus = show_menus_func
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,597
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/views/ZoomButton.py
|
'''
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-08-18
@author: Neil Borle
'''
import PySide.QtCore as QtCore
import ZoomWidget
from PySide.QtGui import QWidget
class ZoomButton(QWidget, ZoomWidget.Ui_ZoomBar):
'''
A button widget that indirectly controls zoom in/out
on the model through a controller group.
'''
def __init__(self, parent=None):
'''
create ZoomButtons instance
'''
super(ZoomButton, self).__init__(parent)
self.setupUi(ZoomButton)
def checkForButtonPress(self, source, event, controller):
'''
checks to see if the event is a button press of either
the zoom in or zoom out buttons.
'''
if event.type() != QtCore.QEvent.MouseButtonPress:
return False
if source == self.ZoomIn:
controller.zoom_in()
return True
elif source == self.ZoomOut:
controller.zoom_out()
return True
else:
return False
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,598
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/utils/TimeUtil.py
|
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: Kevin Serafini, Brent Bryan
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-05-19
@author: Neil Borle
'''
import time
import math
def julian_centuries(t_struct=time.gmtime()):
'''
Calculate the number of Julian Centuries from the epoch 2000.0
(equivalent to Julian Day 2451545.0).
t_struct is a structure representing the current date (ex. time.gmtime())
'''
jd = calculate_julian_day(t_struct)
delta = jd - 2451545.0
return delta / 36525.0
def calculate_julian_day(t_struct=time.gmtime()):
'''
Calculate the Julian Day for a given date using the following formula:
JD = 367 * Y - INT(7 * (Y + INT((M + 9)/12))/4) + INT(275 * M / 9)
+ D + 1721013.5 + UT/24
Note that this is only valid for the year range 1900 - 2099.
t_struct is a structure representing the current date (ex. time.gmtime())
'''
hour = t_struct.tm_hour + (t_struct.tm_min / 60.0) + (t_struct.tm_sec / 3600.0)
day = t_struct.tm_mday
month = t_struct.tm_mon
year = t_struct.tm_year
tmp = math.floor(7.0 * (year + math.floor((month + 9.0) / 12.0)) / 4.0)
return 367.0 * year - tmp + math.floor(275.0 * month / 9.0)\
+ day + 1721013.5 + (hour / 24.0)
def calc_gregorian_date(julian_day):
'''
Convert the given Julian Day to Gregorian Date (in UT time zone).
Based on the formula given in the Explanitory Supplement to the
Astronomical Almanac, pg 604.
'''
l = (julian_day + 68569) & 0xFFFFFFFF
n = (((4 * l) & 0xFFFFFFFF) / 146097) & 0xFFFFFFFF
l = l - (((146097 * n + 3) & 0xFFFFFFFF) / 4) & 0xFFFFFFFF
i = (((4000 * (l + 1)) & 0xFFFFFFFF) / 1461001) & 0xFFFFFFFF
l = (l - (((1461 * i) / 4) & 0xFFFFFFFF) + 31) & 0xFFFFFFFF
j = (((80 * l) & 0xFFFFFFFF) / 2447) & 0xFFFFFFFF
d = (l - (((2447 * j) & 0xFFFFFFFF) / 80) & 0xFFFFFFFF) & 0xFFFFFFFF
l = (j / 11) & 0xFFFFFFFF
m = (j + 2 - 12 * l) & 0xFFFFFFFF
y = (((100 * (n - 49)) & 0xFFFFFFFF) + i + 1)
fraction = julian_day - math.floor(julian_day)
d_hours = fraction * 24.0
hours = d_hours & 0xFFFFFFFF
d_minutes = (d_hours - hours) * 60.0
minutes = d_minutes & 0xFFFFFFFF
seconds = ((d_minutes - minutes) * 60.0) & 0xFFFFFFFF
# this needs to be in the UT time zone
return [y, m, d, hours+12, minutes, seconds]
def mean_sidereal_time(t_struct, longitude):
'''
Calculate local mean sidereal time in degrees. Note that longitude is
negative for western longitude values.
t_struct is a structure representing the current date (ex. time.gmtime())
'''
jd = calculate_julian_day(t_struct)
delta = jd - 2451545.0
gst = 280.461 + 360.98564737 * delta
return normalize_angle(gst + longitude)
def normalize_angle(angle):
remainder = angle % 360
if remainder < 0:
remainder += 360
return remainder
def normalize_hours(time):
remainder = time % 24
if remainder < 0:
remainder += 24
return remainder
def clock_time_from_hrs(ut):
hours = math.floor(ut) & 0xFFFFFFFF
r_min = 60 * (ut - hours)
minutes = math.floor(r_min) & 0xFFFFFFFF
seconds = math.floor(r_min - minutes) & 0xFFFFFFFF
return [hours, minutes, seconds]
if __name__ == "__main__":
'''
For debugging purposes
'''
from units.LatLong import LatLong
print time.gmtime()
print mean_sidereal_time(time.gmtime(), LatLong(20, 16).longitude)
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,599
|
wannaphong/SkyPython
|
refs/heads/master
|
/src/views/PreferencesButton.py
|
'''
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on Aug 7, 2013
@author: Morgan Redshaw and Neil Borle
'''
import PySide.QtCore as QtCore
import createdMenu
from PySide.QtGui import QWidget, QIcon, QPixmap
class PreferencesButton(QWidget, createdMenu.Ui_menuBackground):
'''
Button widget that allows a user to enable or disable particular
layers at will. Once a button is clicked it's image will change
to become either the off icon or on icon for that layer.
'''
def __init__(self, parent=None):
'''
This class has the following buttons:
starButton, constellationButton,
messierButton, planetsButton,
meteorButton, gridButton, horizonButton
'''
super(PreferencesButton, self).__init__(parent)
self.setupUi(PreferencesButton)
self.starButtonActive = True
self.constellationButtonActive = True
self.messierButtonActive = True
self.planetsButtonActive = True
self.meteorButtonActive = True
self.gridButtonActive = True
self.horizonButtonActive = True
def checkForButtonPress(self, source, event):
'''
Checks to see if any of the buttons have been pressed, then
returns the names of the layers associated with those buttons.
'''
if event.type() != QtCore.QEvent.MouseButtonPress:
return False
if source == self.starButton:
self.StarButtonClicked()
return ["source_provider.0"]
elif source == self.constellationButton:
self.ConstellationButtonClicked()
return ["source_provider.1"]
elif source == self.messierButton:
self.MessierButtonClicked()
return ["source_provider.2"]
elif source == self.planetsButton:
self.PlanetButtonClicked()
return ["source_provider.3"]
elif source == self.meteorButton:
self.MeteorButtonClicked()
return ["source_provider.7"]
elif source == self.gridButton:
self.GridButtonClicked()
return ["source_provider.4", "source_provider.5"]
elif source == self.horizonButton:
self.HorizonButtonClicked()
return ["source_provider.6"]
else:
return False
def StarButtonClicked(self):
if self.starButtonActive:
imageOpen = "star_off"
else:
imageOpen = "star_on"
self.ChangeButton(self.starButton, imageOpen)
self.starButtonActive = not self.starButtonActive
def ConstellationButtonClicked(self):
if self.constellationButtonActive:
imageOpen = "stars_off"
else:
imageOpen = "stars_on"
self.ChangeButton(self.constellationButton, imageOpen)
self.constellationButtonActive = not self.constellationButtonActive
def MessierButtonClicked(self):
if self.messierButtonActive:
imageOpen = "messier_off"
else:
imageOpen = "messier_on"
self.ChangeButton(self.messierButton, imageOpen)
self.messierButtonActive = not self.messierButtonActive
def PlanetButtonClicked(self):
if self.planetsButtonActive:
imageOpen = "planet_off"
else:
imageOpen = "planet_on"
self.ChangeButton(self.planetsButton, imageOpen)
self.planetsButtonActive = not self.planetsButtonActive
def MeteorButtonClicked(self):
if self.meteorButtonActive:
imageOpen = "b_meteor_off"
else:
imageOpen = "b_meteor_on"
self.ChangeButton(self.meteorButton, imageOpen)
self.meteorButtonActive = not self.meteorButtonActive
def GridButtonClicked(self):
if self.gridButtonActive:
imageOpen = "grid_off"
else:
imageOpen = "grid_on"
self.ChangeButton(self.gridButton, imageOpen)
self.gridButtonActive = not self.gridButtonActive
def HorizonButtonClicked(self):
if self.horizonButtonActive:
imageOpen = "horizon_off"
else:
imageOpen = "horizon_on"
self.ChangeButton(self.horizonButton, imageOpen)
self.horizonButtonActive = not self.horizonButtonActive
def ChangeButton(self, buttonChosen, imageOpen):
icon = QIcon()
icon.addPixmap(QPixmap(":/icons/assets/drawable/" + imageOpen + ".png"), QIcon.Normal, QIcon.Off)
buttonChosen.setIcon(icon)
|
{"/src/renderer/OverlayManager.py": ["/src/rendererUtil/ColoredQuad.py", "/src/units/Vector3.py", "/src/utils/VectorUtil.py", "/src/utils/Matrix4x4.py"], "/src/renderer/RendererControllerBase.py": ["/src/utils/Runnable.py"], "/src/layers/Layer.py": ["/src/source/PointSource.py", "/src/source/LineSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py"], "/src/renderer/PointObjectManager.py": ["/src/units/Vector3.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/utils/VectorUtil.py": ["/src/units/Vector3.py"], "/src/layers/SourceLayer.py": ["/src/renderer/RendererObjectManager.py"], "/src/source/ImageSource.py": ["/src/units/Vector3.py", "/src/utils/Colors.py", "/src/utils/VectorUtil.py"], "/src/rendererUtil/SkyRegionMap.py": ["/src/utils/VectorUtil.py", "/src/utils/Geometry.py", "/src/units/GeocentricCoordinates.py"], "/src/renderer/LabelOverlayManager.py": ["/src/rendererUtil/LabelMaker.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/VertexBuffer.py"], "/src/renderer/PolyLineObjectManager.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/rendererUtil/NightVisionColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/rendererUtil/TextureManager.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py"], "/src/layers/GridLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py"], "/src/provider/PlanetSource.py": ["/src/renderer/RendererObjectManager.py", "/src/source/PointSource.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/units/RaDec.py"], "/src/rendererUtil/ColoredQuad.py": ["/src/units/Vector3.py"], "/src/source/LineSource.py": ["/src/utils/Colors.py"], "/src/skypython/SkyPython.py": ["/src/views/PreferencesButton.py", "/src/views/ZoomButton.py", "/src/views/WidgetFader.py", "/src/touch/MapMover.py", "/src/touch/DragRotateZoomGestureDetector.py", "/src/layers/LayerManager.py", "/src/control/AstronomerModel.py", "/src/control/ControllerGroup.py", "/src/renderer/SkyRenderer.py", "/src/renderer/RendererController.py", "/src/control/MagneticDeclinationCalculatorSwitcher.py"], "/src/renderer/ImageObjectManager.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/TextCoordBuffer.py", "/src/units/Vector3.py", "/src/utils/DebugOptions.py"], "/src/utils/Matrix4x4.py": ["/src/units/Vector3.py"], "/src/touch/MapMover.py": ["/src/utils/Geometry.py"], "/src/renderer/RenderState.py": ["/src/units/GeocentricCoordinates.py", "/src/utils/Matrix4x4.py"], "/src/source/Source.py": ["/src/units/GeocentricCoordinates.py"], "/src/layers/LayerManager.py": ["/src/utils/DebugOptions.py"], "/src/renderer/RendererController.py": ["/src/renderer/RendererControllerBase.py", "/src/utils/Runnable.py"], "/src/layers/HorizonLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/GeocentricCoordinates.py", "/src/base/TimeConstants.py"], "/src/layers/EclipticLayer.py": ["/src/source/LineSource.py", "/src/source/TextSource.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/PlanetsLayer.py": ["/src/provider/PlanetSource.py", "/src/provider/Planet.py"], "/src/renderer/SkyRenderer.py": ["/src/rendererUtil/TextureManager.py", "/src/rendererUtil/GLBuffer.py", "/src/rendererUtil/SkyRegionMap.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py", "/src/utils/DebugOptions.py", "/src/units/Vector3.py"], "/src/provider/Planet.py": ["/src/base/TimeConstants.py", "/src/units/RaDec.py", "/src/units/GeocentricCoordinates.py", "/src/units/HeliocentricCoordinates.py", "/src/utils/TimeUtil.py"], "/src/renderer/LabelObjectManager.py": ["/src/units/Vector3.py", "/src/utils/Matrix4x4.py", "/src/rendererUtil/SkyRegionMap.py", "/src/rendererUtil/LabelMaker.py", "/src/units/GeocentricCoordinates.py", "/src/utils/DebugOptions.py"], "/src/provider/SolarPositionCalculator.py": ["/src/provider/Planet.py", "/src/units/RaDec.py", "/src/units/HeliocentricCoordinates.py"], "/src/renderer/SkyBox.py": ["/src/rendererUtil/VertexBuffer.py", "/src/rendererUtil/ColorBuffer.py", "/src/rendererUtil/IndexBuffer.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py", "/src/utils/VectorUtil.py"], "/src/layers/MeteorShowerLayer.py": ["/src/base/TimeConstants.py", "/src/source/TextSource.py", "/src/source/ImageSource.py", "/src/renderer/RendererObjectManager.py", "/src/units/Vector3.py", "/src/units/GeocentricCoordinates.py"], "/src/layers/SkyGradientLayer.py": ["/src/base/TimeConstants.py", "/src/provider/SolarPositionCalculator.py", "/src/units/GeocentricCoordinates.py"], "/src/control/AstronomerModel.py": ["/src/skypython/__init__.py", "/src/units/LatLong.py", "/src/units/Vector3.py", "/src/units/Matrix33.py", "/src/units/GeocentricCoordinates.py"]}
|
11,615
|
santander-syngenta/rc
|
refs/heads/master
|
/api/models.py
|
from django.db import models
from django.conf import settings
from django.template.defaultfilters import date
# Create your models here.
class FormTags(models.Model):
name = models.CharField(max_length = 300)
def __str__(self):
return self.name
class Form(models.Model):
title = models.CharField(max_length = 300, null = True)
file = models.FileField(upload_to = "documents/", null = True)
date = models.DateField(auto_now_add = True, null = True)
tag = models.ManyToManyField(FormTags)
def __str__(self):
return self.title
class Link(models.Model):
title = models.CharField(max_length = 300)
url = models.CharField(max_length = 600)
date = models.DateField(auto_now_add = True)
def __str__(self):
return self.title
class Subject(models.Model):
name = models.CharField(max_length = 300)
def __str__(self):
return self.name
class Content(models.Model):
title = models.CharField(max_length = 300, null = True)
file = models.FileField(upload_to = "documents/training/", null = True)
file2 = models.FileField(upload_to = "documents/training/", null = True, blank = True)
date = models.DateField(auto_now_add = True, null = True)
subject = models.ManyToManyField(Subject)
def __str__(self):
return self.title
class Form2(models.Model):
title = models.CharField(max_length = 300, null = True)
file = models.FileField(upload_to = "documents/resourceForms/", null = True)
date = models.DateField(auto_now_add = True, null = True)
def __str__(self):
return self.title
class Contact(models.Model):
email = models.CharField(max_length = 300, null = True)
name = models.CharField(max_length = 300, null = True)
number = models.CharField(max_length = 300, null = True)
speciality = models.TextField(max_length = 300, null = True)
def __str__(self):
return self.name
|
{"/api/admin.py": ["/api/models.py"], "/api/forms.py": ["/api/models.py"], "/blog/views.py": ["/blog/models.py", "/api/models.py", "/api/serializers.py"], "/api/serializers.py": ["/api/models.py"], "/api/views.py": ["/api/serializers.py", "/api/models.py", "/api/forms.py"]}
|
11,616
|
santander-syngenta/rc
|
refs/heads/master
|
/api/migrations/0010_auto_20201210_0809.py
|
# Generated by Django 3.1 on 2020-12-10 16:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0009_form2'),
]
operations = [
migrations.AlterField(
model_name='form2',
name='file',
field=models.FileField(null=True, upload_to='documents/resourceForms/'),
),
]
|
{"/api/admin.py": ["/api/models.py"], "/api/forms.py": ["/api/models.py"], "/blog/views.py": ["/blog/models.py", "/api/models.py", "/api/serializers.py"], "/api/serializers.py": ["/api/models.py"], "/api/views.py": ["/api/serializers.py", "/api/models.py", "/api/forms.py"]}
|
11,617
|
santander-syngenta/rc
|
refs/heads/master
|
/blog/urls.py
|
from django.urls import path
from . import views
urlpatterns = [
path('', views.home, name = 'home'),
path('blog/', views.blog, name = 'blog'),
path('files/', views.files, name='files'),
path('train/', views.training, name = 'training'),
path('methods/', views.methods, name= 'methods'),
path('display/<str:pk>/', views.display, name='display'),
path('display2/<str:pk>/', views.display2, name='display2'),
path('display3/<str:pk>/', views.display3, name='display3'),
path('display4/<str:pk>/', views.display4, name='display4'),
path('tagDB/', views.tagDB, name = 'tagDB'),
path('search/<str:pk>/', views.search, name = 'search'),
path('search/<str:pk>/', views.search, name = 'search'),
path('resources/', views.resources, name='resources'),
path('links/', views.links, name='links'),
path('forms/', views.forms, name='forms'),
path('login/', views.login, name='login'),
path('trainingDB/', views.trainingUpload, name='trainingDB'),
path('resourceFormUpload/', views.resourceFormUpload, name='resourceFormUpload'),
path('linkUpload/', views.linkUpload, name='linkUpload'),
path('support/', views.support, name='support'),
path('supportAdmin/', views.supportAdmin, name='supportAdmin'),
path('calculator/', views.calculator, name='calculator'),
]
|
{"/api/admin.py": ["/api/models.py"], "/api/forms.py": ["/api/models.py"], "/blog/views.py": ["/blog/models.py", "/api/models.py", "/api/serializers.py"], "/api/serializers.py": ["/api/models.py"], "/api/views.py": ["/api/serializers.py", "/api/models.py", "/api/forms.py"]}
|
11,618
|
santander-syngenta/rc
|
refs/heads/master
|
/api/migrations/0015_remove_contact_date.py
|
# Generated by Django 3.1 on 2021-01-12 17:46
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('api', '0014_contact_number'),
]
operations = [
migrations.RemoveField(
model_name='contact',
name='date',
),
]
|
{"/api/admin.py": ["/api/models.py"], "/api/forms.py": ["/api/models.py"], "/blog/views.py": ["/blog/models.py", "/api/models.py", "/api/serializers.py"], "/api/serializers.py": ["/api/models.py"], "/api/views.py": ["/api/serializers.py", "/api/models.py", "/api/forms.py"]}
|
11,619
|
santander-syngenta/rc
|
refs/heads/master
|
/api/migrations/0008_auto_20201202_0823.py
|
# Generated by Django 3.1 on 2020-12-02 16:23
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0007_content'),
]
operations = [
migrations.CreateModel(
name='Subject',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=300)),
],
),
migrations.RemoveField(
model_name='content',
name='active',
),
migrations.RemoveField(
model_name='content',
name='file_type',
),
migrations.RemoveField(
model_name='content',
name='name',
),
migrations.RemoveField(
model_name='content',
name='path',
),
migrations.RemoveField(
model_name='content',
name='size',
),
migrations.RemoveField(
model_name='content',
name='timestamp',
),
migrations.RemoveField(
model_name='content',
name='updated',
),
migrations.RemoveField(
model_name='content',
name='uploaded',
),
migrations.RemoveField(
model_name='content',
name='user',
),
migrations.AddField(
model_name='content',
name='date',
field=models.DateField(auto_now_add=True, null=True),
),
migrations.AddField(
model_name='content',
name='file',
field=models.FileField(null=True, upload_to='documents/training/'),
),
migrations.AddField(
model_name='content',
name='title',
field=models.CharField(max_length=300, null=True),
),
migrations.AddField(
model_name='content',
name='subject',
field=models.ManyToManyField(to='api.Subject'),
),
]
|
{"/api/admin.py": ["/api/models.py"], "/api/forms.py": ["/api/models.py"], "/blog/views.py": ["/blog/models.py", "/api/models.py", "/api/serializers.py"], "/api/serializers.py": ["/api/models.py"], "/api/views.py": ["/api/serializers.py", "/api/models.py", "/api/forms.py"]}
|
11,620
|
santander-syngenta/rc
|
refs/heads/master
|
/api/admin.py
|
from django.contrib import admin
from .models import *
# Register your models here.
admin.site.register(Form)
admin.site.register(FormTags)
admin.site.register(Link)
admin.site.register(Content)
admin.site.register(Subject)
admin.site.register(Form2)
admin.site.register(Contact)
|
{"/api/admin.py": ["/api/models.py"], "/api/forms.py": ["/api/models.py"], "/blog/views.py": ["/blog/models.py", "/api/models.py", "/api/serializers.py"], "/api/serializers.py": ["/api/models.py"], "/api/views.py": ["/api/serializers.py", "/api/models.py", "/api/forms.py"]}
|
11,621
|
santander-syngenta/rc
|
refs/heads/master
|
/api/forms.py
|
from django.forms import ModelForm
from .models import *
from django.contrib.auth.forms import UserCreationForm
from django import forms
class upload(ModelForm):
class Meta:
model = Form
fields = '__all__'
exclude = ['date']
class uploadTrainingContent(ModelForm):
class Meta:
model = Content
fields = '__all__'
exclude = ['date']
class uploadResourceForm(ModelForm):
class Meta:
model = Form2
fields = '__all__'
exclude = ['date']
|
{"/api/admin.py": ["/api/models.py"], "/api/forms.py": ["/api/models.py"], "/blog/views.py": ["/blog/models.py", "/api/models.py", "/api/serializers.py"], "/api/serializers.py": ["/api/models.py"], "/api/views.py": ["/api/serializers.py", "/api/models.py", "/api/forms.py"]}
|
11,622
|
santander-syngenta/rc
|
refs/heads/master
|
/api/migrations/0005_auto_20201012_1519.py
|
# Generated by Django 3.0.8 on 2020-10-12 19:19
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('api', '0004_auto_20201008_1155'),
]
operations = [
migrations.DeleteModel(
name='Link',
),
migrations.DeleteModel(
name='LinkTags',
),
]
|
{"/api/admin.py": ["/api/models.py"], "/api/forms.py": ["/api/models.py"], "/blog/views.py": ["/blog/models.py", "/api/models.py", "/api/serializers.py"], "/api/serializers.py": ["/api/models.py"], "/api/views.py": ["/api/serializers.py", "/api/models.py", "/api/forms.py"]}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.