-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from aerospaceresearch/sid
GUI Starting
- Loading branch information
Showing
7 changed files
with
987 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
# VisMa | ||
# VisMa | ||
A visual equation solver, which aims to help in grasping how mathematical equations are transformed and solved. By this the threshold for obtaining deeper mathematical understanding can be reduced. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,215 @@ | ||
from OpenGL.GL import * | ||
from OpenGL.GLU import * | ||
from OpenGL.GLUT import * | ||
|
||
|
||
#----------- | ||
# VARIABLES | ||
#----------- | ||
|
||
g_fViewDistance = 9. | ||
g_Width = 600 | ||
g_Height = 600 | ||
|
||
g_nearPlane = 1. | ||
g_farPlane = 1000. | ||
|
||
action = "" | ||
xStart = yStart = 0. | ||
zoom = 65. | ||
|
||
xRotate = 0. | ||
yRotate = 0. | ||
zRotate = 0. | ||
|
||
xTrans = 0. | ||
yTrans = 0. | ||
|
||
|
||
#------------------- | ||
# SCENE CONSTRUCTOR | ||
#------------------- | ||
verticies = [ | ||
(0,0,0), | ||
(1000, 0, 0), | ||
(-1000, 0, 0), | ||
(0, 1000, 0), | ||
(0, -1000, 0), | ||
(0, 0, 1000), | ||
(0, 0, -1000) | ||
] | ||
|
||
edges = [ | ||
(0,1), | ||
(0,2), | ||
(0,3), | ||
(0,4), | ||
(0,5), | ||
(0,6) | ||
] | ||
|
||
|
||
def scenemodel(): | ||
glRotate(90,0.,0.,1.) | ||
|
||
glBegin(GL_LINES) | ||
val = 0 | ||
col = 0 | ||
for edge in edges: | ||
for vertex in edge: | ||
if col == 0: | ||
glColor(1.0, 0, 0) | ||
elif col == 1: | ||
glColor(0, 1.0, 0) | ||
else: | ||
glColor(0, 0, 1.0) | ||
|
||
glVertex3fv(verticies[vertex]) | ||
val += 1 | ||
if val % 2 == 0: | ||
col += 1 | ||
glEnd() | ||
|
||
|
||
|
||
#-------- | ||
# VIEWER | ||
#-------- | ||
|
||
def printHelp(): | ||
print """\n\n | ||
-------------------------------------------------------------------\n | ||
Left Mousebutton - move eye position (+ Shift for third axis)\n | ||
Middle Mousebutton - translate the scene\n | ||
Right Mousebutton - move up / down to zoom in / out\n | ||
R Key - reset viewpoint\n | ||
Q Key - exit the program\n | ||
-------------------------------------------------------------------\n | ||
\n""" | ||
|
||
|
||
def init(): | ||
glEnable(GL_NORMALIZE) | ||
#glLightfv(GL_LIGHT0,GL_POSITION,[ .0, 10.0, 10., 0. ] ) | ||
#glLightfv(GL_LIGHT0,GL_AMBIENT,[ .0, .0, .0, 1.0 ]); | ||
#glLightfv(GL_LIGHT0,GL_DIFFUSE,[ 1.0, 1.0, 1.0, 1.0 ]); | ||
#glLightfv(GL_LIGHT0,GL_SPECULAR,[ 1.0, 1.0, 1.0, 1.0 ]); | ||
#glEnable(GL_LIGHT0) | ||
#glEnable(GL_LIGHTING) | ||
glEnable(GL_DEPTH_TEST) | ||
glDepthFunc(GL_LESS) | ||
glShadeModel(GL_SMOOTH) | ||
resetView() | ||
|
||
|
||
def resetView(): | ||
global zoom, xRotate, yRotate, zRotate, xTrans, yTrans | ||
zoom = 65. | ||
xRotate = 0. | ||
yRotate = 0. | ||
zRotate = 0. | ||
xTrans = 0. | ||
yTrans = 0. | ||
glutPostRedisplay() | ||
|
||
|
||
def display(): | ||
# Clear frame buffer and depth buffer | ||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) | ||
# Set up viewing transformation, looking down -Z axis | ||
glLoadIdentity() | ||
gluLookAt(0, 0, -g_fViewDistance, 0, 0, 0, -.1, 0, 0) #-.1,0,0 | ||
# Set perspective (also zoom) | ||
glMatrixMode(GL_PROJECTION) | ||
glLoadIdentity() | ||
gluPerspective(zoom, float(g_Width)/float(g_Height), g_nearPlane, g_farPlane) | ||
glMatrixMode(GL_MODELVIEW) | ||
# Render the scene | ||
polarView() | ||
scenemodel() | ||
# Make sure changes appear onscreen | ||
glutSwapBuffers() | ||
|
||
|
||
def reshape(width, height): | ||
global g_Width, g_Height | ||
g_Width = width | ||
g_Height = height | ||
glViewport(0, 0, g_Width, g_Height) | ||
|
||
|
||
def polarView(): | ||
glTranslatef( yTrans/100., 0.0, 0.0 ) | ||
glTranslatef( 0.0, -xTrans/100., 0.0) | ||
glRotatef( -zRotate, 0.0, 0.0, 1.0) | ||
glRotatef( -xRotate, 1.0, 0.0, 0.0) | ||
glRotatef( -yRotate, .0, 1.0, 0.0) | ||
|
||
|
||
def keyboard(key, x, y): | ||
global zTr, yTr, xTr | ||
if(key=='r'): resetView() | ||
if(key=='q'): exit(0) | ||
glutPostRedisplay() | ||
|
||
|
||
def mouse(button, state, x, y): | ||
global action, xStart, yStart | ||
if (button==GLUT_LEFT_BUTTON): | ||
if (glutGetModifiers() == GLUT_ACTIVE_SHIFT): | ||
action = "MOVE_EYE_2" | ||
else: | ||
action = "MOVE_EYE" | ||
elif (button==GLUT_MIDDLE_BUTTON): | ||
action = "TRANS" | ||
elif (button==GLUT_RIGHT_BUTTON): | ||
action = "ZOOM" | ||
xStart = x | ||
yStart = y | ||
|
||
|
||
def motion(x, y): | ||
global zoom, xStart, yStart, xRotate, yRotate, zRotate, xTrans, yTrans | ||
if (action=="MOVE_EYE"): | ||
xRotate += x - xStart | ||
yRotate -= y - yStart | ||
elif (action=="MOVE_EYE_2"): | ||
zRotate += y - yStart | ||
elif (action=="TRANS"): | ||
xTrans += x - xStart | ||
yTrans += y - yStart | ||
elif (action=="ZOOM"): | ||
zoom -= y - yStart | ||
if zoom > 150.: | ||
zoom = 150. | ||
elif zoom < 1.1: | ||
zoom = 1.1 | ||
else: | ||
print("unknown action\n", action) | ||
xStart = x | ||
yStart = y | ||
glutPostRedisplay() | ||
|
||
|
||
#------ | ||
# MAIN | ||
#------ | ||
if __name__=="__main__": | ||
# GLUT Window Initialization | ||
glutInit() | ||
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB| GLUT_DEPTH) # zBuffer | ||
glutInitWindowSize (g_Width,g_Height) | ||
glutInitWindowPosition (0 + 4, g_Height / 4) | ||
glutCreateWindow ("VisMa") | ||
glClearColor(1.0, 1.0, 1.0, 0.0) | ||
# Initialize OpenGL graphics state | ||
init () | ||
# Register callbacks | ||
glutReshapeFunc(reshape) | ||
glutDisplayFunc(display) | ||
glutMouseFunc(mouse) | ||
glutMotionFunc(motion) | ||
glutKeyboardFunc(keyboard) | ||
printHelp() | ||
# Turn the flow of control over to GLUT | ||
glutMainLoop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import sys | ||
from PyQt4.QtGui import * | ||
from PyQt4.QtCore import * | ||
from PyQt4 import QtGui | ||
|
||
|
||
class Window(QtGui.QMainWindow): | ||
|
||
def __init__(self): | ||
super(Window, self).__init__() | ||
|
||
self.initUI() | ||
|
||
|
||
def initUI(self): | ||
|
||
textEdit = QtGui.QTextEdit() | ||
self.setCentralWidget(textEdit) | ||
|
||
exitAction = QtGui.QAction(QtGui.QIcon('resources/exit.png'), 'Exit', self) | ||
exitAction.setShortcut('Ctrl+Q') | ||
exitAction.setStatusTip('Exit application') | ||
exitAction.triggered.connect(self.close) | ||
|
||
self.statusBar() | ||
|
||
menubar = self.menuBar() | ||
fileMenu = menubar.addMenu('&File') | ||
fileMenu.addAction(exitAction) | ||
|
||
toolbar = self.addToolBar('Exit') | ||
toolbar.addAction(exitAction) | ||
|
||
workSpace = WorkSpace() | ||
self.setCentralWidget(workSpace) | ||
self.setGeometry(300, 300, 1280, 720) | ||
self.setWindowTitle('VisMa') | ||
self.show() | ||
|
||
|
||
|
||
class WorkSpace(QWidget): | ||
|
||
def __init__(self): | ||
super(WorkSpace, self).__init__() | ||
self.initUI() | ||
|
||
def initUI(self): | ||
|
||
hbox = QHBoxLayout(self) | ||
|
||
eqautionList = QFrame() | ||
eqautionList.setFrameShape(QFrame.StyledPanel) | ||
#eqautionList.setStyleSheet("background-color: rgb(0, 0, 255)") | ||
inputList = QFrame() | ||
inputList.setFrameShape(QFrame.StyledPanel) | ||
#inputList.setStyleSheet("background-color: rgb(0, 255, 0)") | ||
buttonSpace = QFrame() | ||
buttonSpace.setFrameShape(QFrame.StyledPanel) | ||
#buttonSpace.setStyleSheet("background-color: rgb(255, 0, 0)") | ||
|
||
splitter1 = QSplitter(Qt.Vertical) | ||
textedit = QTextEdit() | ||
splitter1.addWidget(textedit) | ||
splitter1.addWidget(buttonSpace) | ||
splitter1.setSizes([600, 400]) | ||
|
||
splitter2 = QSplitter(Qt.Horizontal) | ||
splitter2.addWidget(splitter1) | ||
splitter2.addWidget(inputList) | ||
splitter2.setSizes([800, 400]) | ||
|
||
splitter3 = QSplitter(Qt.Horizontal) | ||
splitter3.addWidget(eqautionList) | ||
splitter3.addWidget(splitter2) | ||
splitter3.setSizes([400, 1200]) | ||
|
||
hbox.addWidget(splitter3) | ||
|
||
self.setLayout(hbox) | ||
QApplication.setStyle(QStyleFactory.create('Cleanlooks')) | ||
|
||
|
||
def main(): | ||
app = QApplication(sys.argv) | ||
ex = Window() | ||
sys.exit(app.exec_()) | ||
|
||
if __name__ == '__main__': | ||
main() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
sudo apt-get install python2.7-dev python-pip | ||
sudo apt-get install build-essential freeglut3-dev python-qt4 | ||
sudo pip install pyopengl | ||
python main.py | ||
python graph.py | ||
|