aims_project 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/AimsProjectManager +5 -5
- data/lib/aims_project/app_controller.rb +24 -77
- data/lib/aims_project/crystal_viewer.rb +22 -9
- data/lib/aims_project/geometry_console.rb +155 -0
- data/lib/aims_project/geometry_editor.rb +5 -33
- data/lib/aims_project/geometry_file.rb +11 -12
- data/lib/aims_project/geometry_window.rb +11 -23
- metadata +15 -14
data/bin/AimsProjectManager
CHANGED
|
@@ -14,6 +14,7 @@ require 'aims_project/atom.rb'
|
|
|
14
14
|
require 'aims_project/inspector.rb'
|
|
15
15
|
require 'aims_project/crystal_viewer.rb'
|
|
16
16
|
require 'aims_project/geometry_editor.rb'
|
|
17
|
+
require 'aims_project/geometry_console.rb'
|
|
17
18
|
require 'aims_project/project_tree.rb'
|
|
18
19
|
require 'aims_project/calculation_tree.rb'
|
|
19
20
|
require 'aims_project/app_controller.rb'
|
|
@@ -25,15 +26,14 @@ require 'aims_project/crystal_viewer_options.rb'
|
|
|
25
26
|
controller = AimsProject::AppController.new
|
|
26
27
|
|
|
27
28
|
unless __FILE__.nil?
|
|
28
|
-
cwd = File.
|
|
29
|
+
cwd = File.expand_path(".")
|
|
29
30
|
controller.working_dir = cwd
|
|
30
31
|
end
|
|
31
32
|
|
|
32
|
-
controller.open_file(ARGV[0]) if ARGV[0]
|
|
33
33
|
|
|
34
|
-
project_obj_files = Dir["*.yaml"]
|
|
35
|
-
controller.project = AimsProject::Project.load(project_obj_files.first) unless project_obj_files.empty?
|
|
34
|
+
# project_obj_files = Dir["*.yaml"]
|
|
35
|
+
# controller.project = AimsProject::Project.load(project_obj_files.first) unless project_obj_files.empty?
|
|
36
36
|
AimsProject::ThreadCallbackEvent.set_event_type(Wx::Event.new_event_type)
|
|
37
37
|
Wx::EvtHandler.register_class(AimsProject::ThreadCallbackEvent, AimsProject::ThreadCallbackEvent.event_type, "evt_thread_callback", 0)
|
|
38
38
|
|
|
39
|
-
controller.main_loop
|
|
39
|
+
controller.main_loop
|
|
@@ -48,51 +48,13 @@ class AppController < Wx::App
|
|
|
48
48
|
# Initialize the inspector
|
|
49
49
|
@inspector = Inspector.new(self, @frame)
|
|
50
50
|
|
|
51
|
-
# Create the notebook
|
|
52
|
-
@notebook = Notebook.new(@frame)
|
|
53
|
-
|
|
54
51
|
# Create the geometry notebook page
|
|
55
|
-
@geomWindow = GeometryWindow.new(self, @
|
|
56
|
-
|
|
57
|
-
#
|
|
58
|
-
#
|
|
59
|
-
# Left side is a list of control files
|
|
60
|
-
# right side is a Rich Text Control
|
|
61
|
-
controlWindow = SplitterWindow.new(@notebook)
|
|
62
|
-
@controlList = ListCtrl.new(controlWindow);
|
|
63
|
-
@controlEditor = RichTextCtrl.new(controlWindow)
|
|
64
|
-
controlWindow.split_horizontally(@controlList, @controlEditor)
|
|
65
|
-
|
|
66
|
-
# Create the calculations window
|
|
67
|
-
# Similar to the geometryWindow
|
|
68
|
-
# Left side is a list control
|
|
69
|
-
# Right side is a crystal viewer
|
|
70
|
-
calcWindow = CalculationWindow.new(self, @notebook)
|
|
71
|
-
|
|
72
|
-
# Add windows to the notebook
|
|
73
|
-
@notebook.add_page(@geomWindow, 'Geometry')
|
|
74
|
-
@notebook.add_page(controlWindow, "Control")
|
|
75
|
-
@notebook.add_page(calcWindow, "Calculations")
|
|
76
|
-
|
|
77
|
-
evt_notebook_page_changed(@notebook) {|evt|
|
|
78
|
-
cp = @notebook.get_current_page
|
|
79
|
-
if cp.respond_to? :show_inspector
|
|
80
|
-
@notebook.get_current_page.show_inspector
|
|
81
|
-
end
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
# Set the selected notebook page
|
|
85
|
-
@notebook.set_selection(2)
|
|
86
|
-
|
|
87
|
-
# @tree = ProjectTree.new(self, hsplitter)
|
|
52
|
+
@geomWindow = GeometryWindow.new(self, @frame)
|
|
53
|
+
frameSizer = VBoxSizer.new
|
|
54
|
+
# frameSizer.add_item(@geomWindow, :proportion => 1, :flag => EXPAND)
|
|
55
|
+
# @frame.set_sizer(frameSizer)
|
|
88
56
|
@frame.set_menu_bar(menubar)
|
|
89
|
-
# @toolbar = @frame.create_tool_bar
|
|
90
|
-
# populate_toolbar(@toolbar) if @toolbar
|
|
91
|
-
|
|
92
57
|
|
|
93
|
-
# Check off the current tool
|
|
94
|
-
# set_tool
|
|
95
|
-
|
|
96
58
|
# Display
|
|
97
59
|
@frame.show
|
|
98
60
|
end
|
|
@@ -172,6 +134,7 @@ class AppController < Wx::App
|
|
|
172
134
|
|
|
173
135
|
# Show the inspector
|
|
174
136
|
def show_inspector
|
|
137
|
+
@geomWindow.show_inspector
|
|
175
138
|
@inspector.show(true)
|
|
176
139
|
end
|
|
177
140
|
|
|
@@ -208,18 +171,9 @@ class AppController < Wx::App
|
|
|
208
171
|
end
|
|
209
172
|
end
|
|
210
173
|
puts "Opening #{file}"
|
|
211
|
-
|
|
174
|
+
@geomWindow.open_geometry_file(file)
|
|
212
175
|
@frame.set_title(file)
|
|
213
|
-
|
|
214
|
-
@calcTree.hide
|
|
215
|
-
|
|
216
|
-
if (project)
|
|
217
|
-
erb = ERB.new(File.read(file))
|
|
218
|
-
show_geometry Aims::GeometryParser.parse_string(erb.result(project.get_binding))
|
|
219
|
-
else
|
|
220
|
-
show_geometry Aims::GeometryParser.parse(file)
|
|
221
|
-
end
|
|
222
|
-
|
|
176
|
+
|
|
223
177
|
|
|
224
178
|
rescue Exception => dang
|
|
225
179
|
error_dialog(dang)
|
|
@@ -228,37 +182,35 @@ class AppController < Wx::App
|
|
|
228
182
|
alias_method :open_file, :open_geometry_file
|
|
229
183
|
|
|
230
184
|
def save_geometry
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
geometry
|
|
234
|
-
begin
|
|
185
|
+
geometry = @geomWindow.geometry
|
|
186
|
+
begin
|
|
187
|
+
if geometry.file
|
|
235
188
|
geometry.save
|
|
236
|
-
|
|
237
|
-
|
|
189
|
+
else
|
|
190
|
+
save_geometry_as
|
|
238
191
|
end
|
|
239
|
-
|
|
192
|
+
rescue Exception => e
|
|
193
|
+
error_dialog(e)
|
|
194
|
+
end
|
|
240
195
|
end
|
|
241
196
|
|
|
242
197
|
# Save the geometry
|
|
243
198
|
def save_geometry_as
|
|
244
199
|
|
|
245
|
-
|
|
246
|
-
if (page.respond_to? :geometry) && not(page.geometry.nil?)
|
|
247
|
-
geometry = @notebook.get_current_page.geometry
|
|
200
|
+
geometry = @geomWindow.geometry
|
|
248
201
|
|
|
249
|
-
fd =
|
|
202
|
+
fd = FileDialog.new(@frame, :message => "Save Geometry", :style => FD_SAVE, :default_dir => @working_dir)
|
|
250
203
|
if Wx::ID_OK == fd.show_modal
|
|
251
204
|
begin
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
205
|
+
@working_dir = fd.get_directory
|
|
206
|
+
geom_name = fd.get_path
|
|
207
|
+
new_geom = geometry.save_as(geom_name)
|
|
208
|
+
@geomWindow.show_geometry(new_geom)
|
|
255
209
|
rescue Exception => e
|
|
256
210
|
error_dialog(e)
|
|
257
211
|
end
|
|
258
212
|
end
|
|
259
|
-
|
|
260
|
-
error_dialog("No geometry selected.")
|
|
261
|
-
end
|
|
213
|
+
|
|
262
214
|
end
|
|
263
215
|
|
|
264
216
|
# Display an error dialog for the exception
|
|
@@ -275,19 +227,14 @@ class AppController < Wx::App
|
|
|
275
227
|
def save_image
|
|
276
228
|
|
|
277
229
|
begin
|
|
278
|
-
|
|
279
|
-
if (page.respond_to? :image)
|
|
280
|
-
image = page.image
|
|
230
|
+
image = @geomWindow.image
|
|
281
231
|
fd = FileDialog.new(@frame, :message => "Save Image", :style => FD_SAVE, :default_dir => @working_dir)
|
|
282
232
|
if Wx::ID_OK == fd.show_modal
|
|
283
233
|
@working_dir = fd.get_directory
|
|
284
234
|
puts "Writing #{fd.get_path}"
|
|
285
235
|
image.mirror(false).save_file(fd.get_path)
|
|
286
236
|
end
|
|
287
|
-
|
|
288
|
-
error_dialog("Sorry, could not generate an image.")
|
|
289
|
-
end
|
|
290
|
-
|
|
237
|
+
|
|
291
238
|
rescue Exception => e
|
|
292
239
|
error_dialog(e)
|
|
293
240
|
end
|
|
@@ -214,7 +214,8 @@ class CrystalViewer < Wx::Panel
|
|
|
214
214
|
init_clip_planes
|
|
215
215
|
|
|
216
216
|
@unit_cell.add_observer(self, :unit_cell_changed)
|
|
217
|
-
|
|
217
|
+
draw_scene
|
|
218
|
+
|
|
218
219
|
end
|
|
219
220
|
|
|
220
221
|
def unit_cell_changed
|
|
@@ -223,13 +224,15 @@ class CrystalViewer < Wx::Panel
|
|
|
223
224
|
end
|
|
224
225
|
|
|
225
226
|
def init_clip_planes
|
|
226
|
-
|
|
227
|
+
|
|
227
228
|
Thread.new(self) { |evtHandler|
|
|
228
229
|
@unit_cell_corrected = @unit_cell.correct
|
|
229
230
|
evt = ThreadCallbackEvent.new
|
|
230
231
|
evtHandler.add_pending_event(evt)
|
|
231
232
|
}
|
|
232
233
|
|
|
234
|
+
return unless (@unit_cell and @unit_cell.is_valid?)
|
|
235
|
+
|
|
233
236
|
# each bounding box is a 2 element array [max, min]
|
|
234
237
|
bounding_box = @unit_cell.bounding_box(false)
|
|
235
238
|
xmax = bounding_box[0].x
|
|
@@ -475,8 +478,12 @@ class CrystalViewer < Wx::Panel
|
|
|
475
478
|
@options.y_repeat.times do |j|
|
|
476
479
|
@options.z_repeat.times do |k|
|
|
477
480
|
|
|
478
|
-
origin =
|
|
479
|
-
|
|
481
|
+
origin = if self.unit_cell.lattice_vectors
|
|
482
|
+
atoms.lattice_vectors[0]*i + atoms.lattice_vectors[1]*j + atoms.lattice_vectors[2]*k
|
|
483
|
+
else
|
|
484
|
+
Vector[0, 0, 0]
|
|
485
|
+
end
|
|
486
|
+
|
|
480
487
|
draw_bonds(origin) if @options.show_bonds
|
|
481
488
|
draw_lattice(origin)
|
|
482
489
|
end
|
|
@@ -484,6 +491,7 @@ class CrystalViewer < Wx::Panel
|
|
|
484
491
|
end
|
|
485
492
|
end
|
|
486
493
|
draw_clip_planes
|
|
494
|
+
rescue GeometryEvaluationException => e
|
|
487
495
|
rescue AimsProjectException => e
|
|
488
496
|
puts e.message
|
|
489
497
|
puts e.backtrace.join("\n")
|
|
@@ -558,20 +566,25 @@ class CrystalViewer < Wx::Panel
|
|
|
558
566
|
glMatrixMode(GL_MODELVIEW)
|
|
559
567
|
|
|
560
568
|
glInitNames
|
|
561
|
-
if self.unit_cell
|
|
569
|
+
if self.unit_cell
|
|
562
570
|
atoms = self.unit_cell
|
|
563
571
|
@options.x_repeat.times do |i|
|
|
564
572
|
@options.y_repeat.times do |j|
|
|
565
573
|
@options.z_repeat.times do |k|
|
|
566
574
|
|
|
567
|
-
|
|
568
|
-
|
|
575
|
+
# Hack to display non-periodic systems
|
|
576
|
+
origin = if self.unit_cell.lattice_vectors
|
|
577
|
+
atoms.lattice_vectors[0]*i + atoms.lattice_vectors[1]*j + atoms.lattice_vectors[2]*k
|
|
578
|
+
else
|
|
579
|
+
Vector[0,0,0]
|
|
580
|
+
end
|
|
581
|
+
|
|
569
582
|
self.draw_lattice(origin)
|
|
570
|
-
self.draw_clip_planes
|
|
571
583
|
end
|
|
572
584
|
end
|
|
573
585
|
end
|
|
574
586
|
end
|
|
587
|
+
self.draw_clip_planes
|
|
575
588
|
|
|
576
589
|
self.picking = false
|
|
577
590
|
|
|
@@ -609,7 +622,7 @@ class CrystalViewer < Wx::Panel
|
|
|
609
622
|
|
|
610
623
|
# Find the center of all atoms, not just visible ones.
|
|
611
624
|
@center = atoms.center unless @center
|
|
612
|
-
|
|
625
|
+
|
|
613
626
|
# Move camera out along z-axis
|
|
614
627
|
glMatrixMode(GL_MODELVIEW)
|
|
615
628
|
glLoadIdentity()
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
|
|
2
|
+
module AimsProject
|
|
3
|
+
|
|
4
|
+
class CommandHistory
|
|
5
|
+
|
|
6
|
+
def initialize
|
|
7
|
+
@history= []
|
|
8
|
+
@counter = 0
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def save(cmd)
|
|
12
|
+
@history.push(cmd)
|
|
13
|
+
@counter = @history.size
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def prev
|
|
17
|
+
@counter = @history.size unless @counter
|
|
18
|
+
if @counter > 0
|
|
19
|
+
@counter = @counter - 1
|
|
20
|
+
end
|
|
21
|
+
@history[@counter]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def succ
|
|
25
|
+
@counter = @history.size unless @counter
|
|
26
|
+
if @counter < @history.size-1
|
|
27
|
+
@counter = @counter + 1
|
|
28
|
+
end
|
|
29
|
+
@history[@counter]
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class GeometryConsole < Wx::ScrolledWindow
|
|
34
|
+
|
|
35
|
+
include Wx
|
|
36
|
+
include Aims
|
|
37
|
+
|
|
38
|
+
def initialize(app, window)
|
|
39
|
+
super(window)
|
|
40
|
+
@app = app
|
|
41
|
+
@text_ctrl = RichTextCtrl.new(self)
|
|
42
|
+
@history = CommandHistory.new
|
|
43
|
+
sizer = BoxSizer.new(VERTICAL)
|
|
44
|
+
sizer.add_item(@text_ctrl, :proportion => 1, :flag => EXPAND | ALL, :border => 5)
|
|
45
|
+
|
|
46
|
+
set_auto_layout(true)
|
|
47
|
+
set_sizer(sizer)
|
|
48
|
+
prompt
|
|
49
|
+
|
|
50
|
+
@text_ctrl.evt_key_down do |evt|
|
|
51
|
+
k = evt.get_key_code
|
|
52
|
+
caret_pos = @text_ctrl.get_insertion_point
|
|
53
|
+
|
|
54
|
+
case k
|
|
55
|
+
when K_UP
|
|
56
|
+
prev = @history.prev
|
|
57
|
+
@text_ctrl.remove(@line_start, @text_ctrl.get_last_position)
|
|
58
|
+
@text_ctrl.append_text(prev) if prev
|
|
59
|
+
when K_DOWN
|
|
60
|
+
succ = @history.succ
|
|
61
|
+
@text_ctrl.remove(@line_start,@text_ctrl.get_last_position)
|
|
62
|
+
@text_ctrl.append_text(succ) if succ
|
|
63
|
+
when K_LEFT
|
|
64
|
+
if caret_pos > @line_start
|
|
65
|
+
@text_ctrl.set_insertion_point(caret_pos-1)
|
|
66
|
+
end
|
|
67
|
+
when K_RIGHT
|
|
68
|
+
if caret_pos < @text_ctrl.get_last_position
|
|
69
|
+
@text_ctrl.set_insertion_point(caret_pos+1)
|
|
70
|
+
end
|
|
71
|
+
else
|
|
72
|
+
if caret_pos < @line_start
|
|
73
|
+
@text_ctrl.set_insertion_point(@line_start+1)
|
|
74
|
+
end
|
|
75
|
+
evt.skip
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
@text_ctrl.evt_char do |evt|
|
|
80
|
+
k = evt.get_key_code
|
|
81
|
+
case k
|
|
82
|
+
when K_RETURN
|
|
83
|
+
cmd = @text_ctrl.get_range(@line_start, @text_ctrl.get_caret_position+1).strip
|
|
84
|
+
@history.save(cmd)
|
|
85
|
+
print "\n"
|
|
86
|
+
# evaluate
|
|
87
|
+
begin
|
|
88
|
+
result = get_binding.eval(cmd)
|
|
89
|
+
if result
|
|
90
|
+
result_str = result.to_s
|
|
91
|
+
print(result_str+"\n")
|
|
92
|
+
end
|
|
93
|
+
rescue Exception => e
|
|
94
|
+
print(e.message + "\n", Wx::RED)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
prompt
|
|
98
|
+
when K_HOME # For some reason, ctrl-a maps to this
|
|
99
|
+
@text_ctrl.set_insertion_point(@line_start)
|
|
100
|
+
when K_HELP # For some reason, ctrl-e maps to this
|
|
101
|
+
@text_ctrl.set_insertion_point_end
|
|
102
|
+
else
|
|
103
|
+
evt.skip()
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def get_binding
|
|
110
|
+
unless @binding
|
|
111
|
+
@binding = binding()
|
|
112
|
+
end
|
|
113
|
+
@binding
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def prompt
|
|
117
|
+
@text_ctrl.append_text(">> ")
|
|
118
|
+
@text_ctrl.move_end
|
|
119
|
+
@line_start = @text_ctrl.get_caret_position + 1
|
|
120
|
+
@text_ctrl.show_position(@line_start)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def print(str, color=Wx::BLACK)
|
|
124
|
+
start = @text_ctrl.get_caret_position
|
|
125
|
+
@text_ctrl.append_text(str)
|
|
126
|
+
stop = @text_ctrl.get_caret_position
|
|
127
|
+
@text_ctrl.set_style(start..stop, RichTextAttr.new(color))
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def echo(str, color=Wx::BLACK)
|
|
131
|
+
print(str+"\n", color)
|
|
132
|
+
return nil
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def ls(pattern = "*")
|
|
136
|
+
match = Dir[pattern]
|
|
137
|
+
print(match.join("\n") + "\n")
|
|
138
|
+
return nil
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def geometry
|
|
142
|
+
@app.geometry
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def set_geometry(geom)
|
|
146
|
+
if geom.is_a? Aims::Geometry
|
|
147
|
+
puts "All Good"
|
|
148
|
+
@app.show_geometry(GeometryFile.new(geom))
|
|
149
|
+
else
|
|
150
|
+
echo("Not a valid geometry object")
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
end
|
|
155
|
+
end
|
|
@@ -21,37 +21,18 @@ class GeometryEditor < Wx::ScrolledWindow
|
|
|
21
21
|
# Create the button panel (A toolbar for the top of this panel)
|
|
22
22
|
@button_panel = HBoxSizer.new
|
|
23
23
|
|
|
24
|
-
@toggle_source = CheckBox.new(self, ID_ANY, "Source")
|
|
25
|
-
|
|
26
24
|
basedir = File.dirname(__FILE__)
|
|
27
25
|
arrow_icon = Image.new(File.join(basedir,"green_arrow.jpg"), BITMAP_TYPE_JPEG)
|
|
28
26
|
@eval_button = BitmapButton.new(self, :bitmap => arrow_icon.rescale(16,15).convert_to_bitmap,:style=>BU_EXACTFIT, :name => "evaluate")
|
|
29
27
|
|
|
30
|
-
# error_icon = Image.new(File.join(basedir, "red_cross.jpeg"), BITMAP_TYPE_JPEG)
|
|
31
|
-
# @clear_errors_button = BitmapButton.new(self, :bitmap => error_icon.rescale(16,15).convert_to_bitmap,:style=>BU_EXACTFIT, :name => "Clear Errors")
|
|
32
|
-
|
|
33
|
-
@button_panel.add_item(@toggle_source,1)
|
|
34
|
-
@button_panel.add_stretch_spacer
|
|
35
28
|
@button_panel.add_item(@eval_button,3)
|
|
36
|
-
|
|
37
|
-
evt_checkbox(@toggle_source) {|evt|
|
|
38
|
-
if @toggle_source.is_checked
|
|
39
|
-
@text_ctrl.set_read_only(false)
|
|
40
|
-
@text_ctrl.set_text(@unit_cell.raw_input)
|
|
41
|
-
else
|
|
42
|
-
@text_ctrl.set_read_only(false)
|
|
43
|
-
@text_ctrl.set_text(@unit_cell.input_geometry)
|
|
44
|
-
@text_ctrl.set_read_only(true)
|
|
45
|
-
end
|
|
46
|
-
}
|
|
47
|
-
|
|
29
|
+
|
|
48
30
|
sizer.add_item(@button_panel, :flag => EXPAND)
|
|
49
31
|
sizer.add_item(@text_ctrl, :proportion => 1, :flag => EXPAND | ALL, :border => 5)
|
|
50
32
|
|
|
51
33
|
set_auto_layout(true)
|
|
52
34
|
set_sizer(sizer)
|
|
53
|
-
|
|
54
|
-
|
|
35
|
+
|
|
55
36
|
evt_button(@eval_button) {|event|
|
|
56
37
|
self.evaluate
|
|
57
38
|
}
|
|
@@ -60,28 +41,19 @@ class GeometryEditor < Wx::ScrolledWindow
|
|
|
60
41
|
|
|
61
42
|
# Apply the edits to the geometry_file and evaluate
|
|
62
43
|
def evaluate
|
|
44
|
+
|
|
63
45
|
@unit_cell.raw_input = @text_ctrl.get_text
|
|
64
46
|
begin
|
|
65
47
|
@unit_cell.evaluate
|
|
66
48
|
rescue
|
|
67
49
|
# @button_pane.add_item(@clear_errors_button, 3)
|
|
68
|
-
@
|
|
50
|
+
@app.display_exception($!)
|
|
69
51
|
end
|
|
70
52
|
end
|
|
71
53
|
|
|
72
54
|
def unit_cell=(uc)
|
|
73
55
|
@unit_cell = uc
|
|
74
|
-
|
|
75
|
-
@text_ctrl.set_read_only(false)
|
|
76
|
-
@text_ctrl.set_text(@unit_cell.raw_input)
|
|
77
|
-
@text_ctrl.set_read_only(false)
|
|
78
|
-
|
|
79
|
-
else
|
|
80
|
-
@text_ctrl.set_read_only(false)
|
|
81
|
-
@text_ctrl.set_text(@unit_cell.input_geometry)
|
|
82
|
-
@text_ctrl.set_read_only(true)
|
|
83
|
-
|
|
84
|
-
end
|
|
56
|
+
@text_ctrl.set_text(@unit_cell.input_geometry)
|
|
85
57
|
end
|
|
86
58
|
|
|
87
59
|
def select_atom(atom)
|
|
@@ -43,7 +43,13 @@ module AimsProject
|
|
|
43
43
|
# @param input If input is a File, the file is read and evaluated with ERB
|
|
44
44
|
# If input is a String, the input is directly evaluated with ERB
|
|
45
45
|
# @param _binding The binding to use when evaluating with EB
|
|
46
|
-
def initialize(input, _binding=nil)
|
|
46
|
+
def initialize(input = nil, _binding=nil)
|
|
47
|
+
|
|
48
|
+
if input.nil?
|
|
49
|
+
@raw_input = ""
|
|
50
|
+
@input_geometry = ""
|
|
51
|
+
return
|
|
52
|
+
end
|
|
47
53
|
|
|
48
54
|
if input.respond_to? :read
|
|
49
55
|
@file = input
|
|
@@ -67,12 +73,8 @@ module AimsProject
|
|
|
67
73
|
# Set the raw input
|
|
68
74
|
# @param str The string to set the raw input to
|
|
69
75
|
# @param notify Whether or not to notify observer. Set this to false if you intend to call evaluate immediately after
|
|
70
|
-
def raw_input=(str
|
|
76
|
+
def raw_input=(str)
|
|
71
77
|
@raw_input = str
|
|
72
|
-
if notify
|
|
73
|
-
changed
|
|
74
|
-
notify_observers
|
|
75
|
-
end
|
|
76
78
|
end
|
|
77
79
|
|
|
78
80
|
# Evaluate the raw input and return a geometry String formatted in the Aims geometry.in format
|
|
@@ -91,6 +93,7 @@ module AimsProject
|
|
|
91
93
|
@aims_geometry
|
|
92
94
|
end
|
|
93
95
|
|
|
96
|
+
|
|
94
97
|
# Delegate calls to the Aims::Geometry object if it exists.
|
|
95
98
|
def method_missing(symbol, *args, &block)
|
|
96
99
|
if @aims_geometry.nil?
|
|
@@ -105,7 +108,7 @@ module AimsProject
|
|
|
105
108
|
begin
|
|
106
109
|
validate
|
|
107
110
|
return true
|
|
108
|
-
rescue
|
|
111
|
+
rescue Exception => e
|
|
109
112
|
return false
|
|
110
113
|
end
|
|
111
114
|
end
|
|
@@ -170,11 +173,7 @@ module AimsProject
|
|
|
170
173
|
f.write @raw_input
|
|
171
174
|
}
|
|
172
175
|
|
|
173
|
-
|
|
174
|
-
return self
|
|
175
|
-
else
|
|
176
|
-
GeometryFile.new(File.new(file.path, "r"))
|
|
177
|
-
end
|
|
176
|
+
return self
|
|
178
177
|
|
|
179
178
|
end
|
|
180
179
|
|
|
@@ -29,15 +29,7 @@ module AimsProject
|
|
|
29
29
|
sizer.add_item(topSplitterWindow, :proportion => 1, :flag => EXPAND)
|
|
30
30
|
|
|
31
31
|
set_sizer(sizer)
|
|
32
|
-
|
|
33
|
-
# The top is a list control
|
|
34
|
-
@geomList = ListCtrl.new(topSplitterWindow)
|
|
35
|
-
app.project.geometries.sort{|a,b| a <=> b}.each{|geom|
|
|
36
|
-
li = ListItem.new
|
|
37
|
-
li.set_text(File.basename(geom))
|
|
38
|
-
li.set_data(geom)
|
|
39
|
-
@geomList.insert_item(li)
|
|
40
|
-
}
|
|
32
|
+
@console = GeometryConsole.new(self, topSplitterWindow)
|
|
41
33
|
|
|
42
34
|
# The bottom is a vertical splitter
|
|
43
35
|
geomWindowSplitter = SplitterWindow.new(topSplitterWindow)
|
|
@@ -47,26 +39,17 @@ module AimsProject
|
|
|
47
39
|
geomWindowSplitter.split_vertically(@geomEditor, @geomViewer)
|
|
48
40
|
|
|
49
41
|
# Add top and bottom sides together
|
|
50
|
-
topSplitterWindow.split_horizontally(
|
|
42
|
+
topSplitterWindow.split_horizontally(geomWindowSplitter, @console, -100)
|
|
51
43
|
layout
|
|
52
44
|
|
|
53
45
|
# Define events
|
|
54
|
-
evt_list_item_selected(@
|
|
46
|
+
evt_list_item_selected(@console) {|evt|
|
|
55
47
|
open_geometry_file(evt.get_item.get_data)
|
|
56
48
|
}
|
|
57
49
|
|
|
50
|
+
show_geometry(GeometryFile.new)
|
|
51
|
+
|
|
58
52
|
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
# Add a geometry with the given name
|
|
62
|
-
def add_geometry(geometry)
|
|
63
|
-
@app.project.geometries << geometry
|
|
64
|
-
li = ListItem.new
|
|
65
|
-
li.set_text(File.basename(geometry.file))
|
|
66
|
-
li.set_data(geometry.file)
|
|
67
|
-
li.set_state(LIST_STATE_SELECTED)
|
|
68
|
-
@geomList.insert_item(li)
|
|
69
|
-
@geomList.sort{|a,b| a <=> b}
|
|
70
53
|
end
|
|
71
54
|
|
|
72
55
|
|
|
@@ -114,7 +97,7 @@ module AimsProject
|
|
|
114
97
|
begin
|
|
115
98
|
@original_uc = geometry
|
|
116
99
|
@geomViewer.unit_cell = @original_uc
|
|
117
|
-
|
|
100
|
+
rescue AimsProjectException => e
|
|
118
101
|
@app.error_dialog(e)
|
|
119
102
|
ensure
|
|
120
103
|
@geomEditor.unit_cell = @original_uc
|
|
@@ -128,6 +111,7 @@ module AimsProject
|
|
|
128
111
|
puts "Selection:"
|
|
129
112
|
puts @selection[:atoms].each{|a| puts a.format_geometry_in}
|
|
130
113
|
@geomEditor.select_atom(atom)
|
|
114
|
+
@console.echo(atom.to_s)
|
|
131
115
|
end
|
|
132
116
|
|
|
133
117
|
def nudge_selected_atoms(x,y,z)
|
|
@@ -138,6 +122,10 @@ module AimsProject
|
|
|
138
122
|
@geomEditor.update
|
|
139
123
|
end
|
|
140
124
|
|
|
125
|
+
def display_exception(e)
|
|
126
|
+
@console.print(e.message, Wx::RED)
|
|
127
|
+
end
|
|
128
|
+
|
|
141
129
|
# Apply UI settings to viewer and re-render
|
|
142
130
|
def update_viewer
|
|
143
131
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: aims_project
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,22 +9,22 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-05-
|
|
12
|
+
date: 2013-05-30 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: wxruby-ruby19
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &5564000 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ~>
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: 2.0.
|
|
21
|
+
version: 2.0.0
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *5564000
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: ruby-opengl2
|
|
27
|
-
requirement: &
|
|
27
|
+
requirement: &5563770 !ruby/object:Gem::Requirement
|
|
28
28
|
none: false
|
|
29
29
|
requirements:
|
|
30
30
|
- - ~>
|
|
@@ -32,10 +32,10 @@ dependencies:
|
|
|
32
32
|
version: 0.60.3
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *5563770
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
37
37
|
name: aims
|
|
38
|
-
requirement: &
|
|
38
|
+
requirement: &5563540 !ruby/object:Gem::Requirement
|
|
39
39
|
none: false
|
|
40
40
|
requirements:
|
|
41
41
|
- - ~>
|
|
@@ -43,10 +43,10 @@ dependencies:
|
|
|
43
43
|
version: 0.3.0
|
|
44
44
|
type: :runtime
|
|
45
45
|
prerelease: false
|
|
46
|
-
version_requirements: *
|
|
46
|
+
version_requirements: *5563540
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
48
|
name: highline
|
|
49
|
-
requirement: &
|
|
49
|
+
requirement: &5563310 !ruby/object:Gem::Requirement
|
|
50
50
|
none: false
|
|
51
51
|
requirements:
|
|
52
52
|
- - ~>
|
|
@@ -54,10 +54,10 @@ dependencies:
|
|
|
54
54
|
version: 1.6.11
|
|
55
55
|
type: :runtime
|
|
56
56
|
prerelease: false
|
|
57
|
-
version_requirements: *
|
|
57
|
+
version_requirements: *5563310
|
|
58
58
|
- !ruby/object:Gem::Dependency
|
|
59
59
|
name: capistrano
|
|
60
|
-
requirement: &
|
|
60
|
+
requirement: &5563080 !ruby/object:Gem::Requirement
|
|
61
61
|
none: false
|
|
62
62
|
requirements:
|
|
63
63
|
- - ~>
|
|
@@ -65,7 +65,7 @@ dependencies:
|
|
|
65
65
|
version: 2.11.2
|
|
66
66
|
type: :runtime
|
|
67
67
|
prerelease: false
|
|
68
|
-
version_requirements: *
|
|
68
|
+
version_requirements: *5563080
|
|
69
69
|
description: This gem simplifies and streamlines the calculation pipeline for FHI-AIMS.
|
|
70
70
|
email: joshua.shapiro@gmail.com
|
|
71
71
|
executables:
|
|
@@ -84,6 +84,7 @@ files:
|
|
|
84
84
|
- lib/aims_project/calculation_window.rb
|
|
85
85
|
- lib/aims_project/crystal_viewer.rb
|
|
86
86
|
- lib/aims_project/crystal_viewer_options.rb
|
|
87
|
+
- lib/aims_project/geometry_console.rb
|
|
87
88
|
- lib/aims_project/geometry_editor.rb
|
|
88
89
|
- lib/aims_project/geometry_file.rb
|
|
89
90
|
- lib/aims_project/geometry_window.rb
|
|
@@ -108,7 +109,7 @@ files:
|
|
|
108
109
|
- bin/AimsProjectManager
|
|
109
110
|
- bin/AimsCalc
|
|
110
111
|
- bin/AimsProject
|
|
111
|
-
homepage:
|
|
112
|
+
homepage: https://github.com/jns/AimsProject
|
|
112
113
|
licenses: []
|
|
113
114
|
post_install_message:
|
|
114
115
|
rdoc_options: []
|