delete subplots and add frames in gui

Commit
899d36f49d1170e819c17ee3ec6cf4de0cc37707
Author
Marius Peter <blendoit@gmail.com>
Author date
Committer
Marius Peter <blendoit@gmail.com>
Committer date
Changed files
creator.py
index 16207b14..8277b108 100644..100644
@@ -362,30 +362,30 @@
362 362 """This function plots the airfoil's + sub-components' geometry."""
363 363
364 364 fig, ax = plt.subplots()
365 Removed: ax.axis('off')
365 Added: # ax.axis('off')
366 366
367 367 # Plot chord
368 368 x = [0, airfoil.chord]
369 369 y = [0, 0]
370 Removed: fig.add_subplot(111).plot(x, y, linewidth='1')
370 Added: ax.plot(x, y, linewidth='1')
371 371 # Plot quarter chord
372 Removed: fig.add_subplot(111).plot(airfoil.chord / 4, 0,
373 Removed: '.', color='g', markersize=24,
374 Removed: label='Quarter-chord')
372 Added: ax.plot(airfoil.chord / 4, 0,
373 Added: '.', color='g', markersize=24,
374 Added: label='Quarter-chord')
375 375 # Plot mean camber line
376 Removed: fig.add_subplot(111).plot(airfoil.x_c, airfoil.z_c,
377 Removed: '-.', color='r', linewidth='2',
378 Removed: label='Mean camber line')
376 Added: ax.plot(airfoil.x_c, airfoil.z_c,
377 Added: '-.', color='r', linewidth='2',
378 Added: label='Mean camber line')
379 379 # Plot airfoil surfaces
380 Removed: fig.add_subplot(111).plot(airfoil.x, airfoil.z,
381 Removed: color='b', linewidth='1')
380 Added: ax.plot(airfoil.x, airfoil.z,
381 Added: color='b', linewidth='1')
382 382
383 383 # Plot spars
384 384 try:
385 385 for _ in range(len(airfoil.spar.x)):
386 386 x = (airfoil.spar.x[_])
387 387 y = (airfoil.spar.z[_])
388 Removed: fig.add_subplot(111).plot(x, y, '-', color='y', linewidth='4')
388 Added: ax.plot(x, y, '-', color='y', linewidth='4')
389 389 except AttributeError:
390 390 print('No spars to plot.')
391 391 # Plot stringers
@@ -393,17 +393,19 @@
393 393 for _ in range(0, len(airfoil.stringer.x)):
394 394 x = airfoil.stringer.x[_]
395 395 y = airfoil.stringer.z[_]
396 Removed: fig.add_subplot(111).plot(x, y, '.', color='y', markersize=12)
396 Added: ax.plot(x, y, '.', color='y', markersize=12)
397 397 except AttributeError:
398 398 print('No stringers to plot.')
399 399
400 400 # Graph formatting
401 401 ax.set(title='NACA ' + str(airfoil.naca_num) + ' airfoil',
402 402 xlabel='X axis',
403 Removed: ylabel='Z axis')
403 Added: ylabel='Z axis', ylim=[-50, 50])
404 404 plt.grid(axis='both', linestyle=':', linewidth=1)
405 405 plt.gca().set_aspect('equal', adjustable='box')
406 Removed: plt.gca().legend()
406 Added: plt.gca().legend(bbox_to_anchor=(1, 1),
407 Added: bbox_transform=plt.gcf().transFigure)
408 Added:
407 409 if view == True:
408 410 plt.show()
409 411 else:
gui.py
index b987e05f..05afc385 100644..100644
@@ -28,29 +28,36 @@
28 28 root.wm_title('MAE 154B - Airfoil Design, Evaluation, Optimization')
29 29 # root.geometry('1000x400')
30 30
31 Removed: # # User inputs
32 Removed: l_naca = ttk.Label(root, text='NACA Number')
33 Removed: e_naca = ttk.Entry(root)
34 Removed: l_chord = ttk.Label(root, text='Chord Length')
35 Removed: e_chord = ttk.Entry(root)
31 Added: # Object definition
32 Added: # User inputs
33 Added: frame_1 = ttk.Frame(root)
34 Added: l_naca = ttk.Label(frame_1, text='NACA Number')
35 Added: naca = tk.StringVar()
36 Added: e_naca = ttk.Entry(frame_1, textvariable=naca)
37 Added: l_chord = ttk.Label(frame_1, text='Chord Length')
38 Added: e_chord = ttk.Entry(frame_1)
36 39 af = generator.default_airfoil()
37 Removed:
38 Removed: # # Graph window
40 Added: # Graph window
41 Added: frame_2 = ttk.Frame(root)
39 42 fig, ax = creator.plot_geom(af, False)
40 Removed:
41 Removed: plot = FigureCanvasTkAgg(fig, master=root)
43 Added: plot = FigureCanvasTkAgg(fig, frame_2)
42 44 plot.draw()
43 Removed: plot.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
44 Removed:
45 Removed: toolbar = NavigationToolbar2Tk(plot, root)
45 Added: toolbar = NavigationToolbar2Tk(plot, frame_2)
46 46 toolbar.update()
47 Removed: plot.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
48 47
49 Removed: # # Layout
50 Removed: l_naca.pack()
51 Removed: e_naca.pack()
52 Removed: l_chord.pack()
53 Removed: e_chord.pack()
48 Added: # Layout
49 Added: # User input
50 Added: l_naca.grid(row=0, column=0)
51 Added: e_naca.grid(row=0, column=1, padx=4)
52 Added: l_chord.grid(row=1, column=0)
53 Added: e_chord.grid(row=1, column=1, padx=4)
54 Added: frame_1.pack(side=tk.LEFT)
55 Added: # Graph window
56 Added: plot.get_tk_widget().pack(fill=tk.BOTH)
57 Added: toolbar.pack()
58 Added: frame_2.pack(side=tk.LEFT)
59 Added:
60 Added: # plot.get_tk_widget().pack()
54 61
55 62 root.mainloop()
56 63