-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdefault_init.py
executable file
·165 lines (131 loc) · 5.5 KB
/
default_init.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
"""
default_init.py
Copyright (c) 2015-2016 Dany Vohl, David G. Barnes, Christopher J. Fluke,
Yuri Benovitski, Tsz Ho Wong, Owen L Kaluza, Toan D. Nguyen.
This file is part of encube.
encube is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
encube is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with encube. If not, see <http://www.gnu.org/licenses/>.
We would appreciate it if research outcomes using encube would
provide the following acknowledgement:
"Visual analytics of multidimensional data was conducted with encube."
and a reference to
Dany Vohl, David G. Barnes, Christopher J. Fluke, Govinda Poudel, Nellie Georgiou-Karistianis,
Amr H. Hassan, Yuri Benovitski, Tsz Ho Wong, Owen L Kaluza, Toan D. Nguyen, C. Paul Bonnington. (2016).
Large-scale comparative visualisation of sets of multidimensional data. PeerJ Computer Science, In Press.
"""
# This script is executed when the omegalib python interpreter (orun) starts,
# before running application scripts.
# It sets up a system menu with several config options for sound, navigation,
# graphics etc. If you want to change (or remove) the default menu, use the
# orun/initScript config option to specify a new or an empty script.
# You can also change the orun/appStartFunction config option to change the
# entry point into this script (by default it is set to _onAppStart)
from omega import *
from euclid import *
speedLabel = None
mainmnu = None
# add the current path to the data search paths.
import os
addDataPath(os.getcwd())
def _setCamSpeed(speedLevel):
global speedLabel
s = 10 ** (speedLevel - 4)
speedLabel.setText("Navigation Speed: " + str(s) + "x")
cc = getDefaultCamera().getController()
if(cc != None):
cc.setSpeed(s)
def _resetCamera():
getDefaultCamera().setPosition(Vector3(0, 0, 0))
getDefaultCamera().setPitchYawRoll(Vector3(0, 0, 0))
def _autonearfar(value):
if(value):
queueCommand(":autonearfar on")
else:
queueCommand(":autonearfar off")
def _displayWand(value):
if(value):
queueCommand("getSceneManager().displayWand(0, 1)")
else:
queueCommand("getSceneManager().hideWand(0)")
def _setSoundServerVolume( value ):
newVolume = value - 30
globalVolumeLabel.setText("Global Volume: " + str(newVolume) )
soundEnv.setServerVolume(newVolume)
def _onAppStart():
global mainmnu
# mm = getViewer().getMenuManager()
mm = MenuManager.createAndInitialize()
mainmnu = mm.createMenu("Main Menu")
# If menus are in 2d mode, add a menu open button
if(not getBoolSetting('config/ui', 'menu3dEnabled', False)):
uim = UiModule.instance()
wf = uim.getWidgetFactory()
mainButton = wf.createButton('mainButton', uim.getUi())
mainButton.setText("Main Menu")
mainButton.setUIEventCommand('mainmnu.show()')
mainButton.setStyleValue('fill', 'black')
mainmnu.getContainer().setPosition(Vector2(5, 25))
mi = mainmnu.addImage(loadImage("omegalib-transparent-white.png"))
ics = mi.getImage().getSize() * 0.1
mi.getImage().setSize(ics)
mm.setMainMenu(mainmnu)
sysmnu = mainmnu.addSubMenu("System")
mi = sysmnu.addButton("Toggle freefly", ":freefly")
mi.getButton().setCheckable(True)
mi = sysmnu.addButton("Reset", "_resetCamera()")
mi = sysmnu.addButton("Auto Near / Far", "_autonearfar(%value%)")
mi.getButton().setCheckable(True)
mi = sysmnu.addButton("Display Wand", "_displayWand(%value%)")
mi.getButton().setCheckable(True)
global speedLabel
speedLabel = sysmnu.addLabel("sd")
_setCamSpeed(4)
ss = sysmnu.addSlider(10, "_setCamSpeed(%value%)")
ss.getSlider().setValue(4)
ss.getWidget().setWidth(200)
if( isSoundEnabled() ):
global soundEnv
global serverVolume
global globalVolumeLabel
soundEnv = getSoundEnvironment()
serverVolume = soundEnv.getServerVolume();
globalVolumeLabel = sysmnu.addLabel("Global Volume: --")
value = serverVolume + 30
globalVolumeLabel.setText("Global Volume: " + str(serverVolume))
ss = sysmnu.addSlider(39, "_setSoundServerVolume(%value%)")
ss.getSlider().setValue(30)
ss.getWidget().setWidth(200)
ss.getSlider().setValue(value)
mi = sysmnu.addButton("Enable Stereo", "toggleStereo()")
mi.getButton().setCheckable(True)
mi.getButton().setChecked(isStereoEnabled())
mi = sysmnu.addButton("Toggle Console", ":c")
mi = sysmnu.addButton("List Active Modules", "printModules()")
mi = sysmnu.addButton("Exit omegalib", "_shutdown()")
shuttingDown = False
fadeOutVal = 0
def _shutdown():
global shuttingDown
global fadeOutVal
shuttingDown = True
fadeOutVal = 0
def onUpdate(frame, t, dt):
global shuttingDown
global fadeOutVal
if(shuttingDown):
if(fadeOutVal >= 1): oexit()
else:
uim = UiModule.instance()
ui = uim.getUi()
alpha = int(fadeOutVal * 256)
ui.setStyleValue('fill', '#000000' + hex(alpha)[2:])
fadeOutVal += dt
setUpdateFunction(onUpdate)