summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--creator.py30
-rw-r--r--gui.py43
2 files changed, 41 insertions, 32 deletions
diff --git a/creator.py b/creator.py
index 16207b1..8277b10 100644
--- a/creator.py
+++ b/creator.py
@@ -362,30 +362,30 @@ def plot_geom(airfoil, view: False):
"""This function plots the airfoil's + sub-components' geometry."""
fig, ax = plt.subplots()
- ax.axis('off')
+ # ax.axis('off')
# Plot chord
x = [0, airfoil.chord]
y = [0, 0]
- fig.add_subplot(111).plot(x, y, linewidth='1')
+ ax.plot(x, y, linewidth='1')
# Plot quarter chord
- fig.add_subplot(111).plot(airfoil.chord / 4, 0,
- '.', color='g', markersize=24,
- label='Quarter-chord')
+ ax.plot(airfoil.chord / 4, 0,
+ '.', color='g', markersize=24,
+ label='Quarter-chord')
# Plot mean camber line
- fig.add_subplot(111).plot(airfoil.x_c, airfoil.z_c,
- '-.', color='r', linewidth='2',
- label='Mean camber line')
+ ax.plot(airfoil.x_c, airfoil.z_c,
+ '-.', color='r', linewidth='2',
+ label='Mean camber line')
# Plot airfoil surfaces
- fig.add_subplot(111).plot(airfoil.x, airfoil.z,
- color='b', linewidth='1')
+ ax.plot(airfoil.x, airfoil.z,
+ color='b', linewidth='1')
# Plot spars
try:
for _ in range(len(airfoil.spar.x)):
x = (airfoil.spar.x[_])
y = (airfoil.spar.z[_])
- fig.add_subplot(111).plot(x, y, '-', color='y', linewidth='4')
+ ax.plot(x, y, '-', color='y', linewidth='4')
except AttributeError:
print('No spars to plot.')
# Plot stringers
@@ -393,17 +393,19 @@ def plot_geom(airfoil, view: False):
for _ in range(0, len(airfoil.stringer.x)):
x = airfoil.stringer.x[_]
y = airfoil.stringer.z[_]
- fig.add_subplot(111).plot(x, y, '.', color='y', markersize=12)
+ ax.plot(x, y, '.', color='y', markersize=12)
except AttributeError:
print('No stringers to plot.')
# Graph formatting
ax.set(title='NACA ' + str(airfoil.naca_num) + ' airfoil',
xlabel='X axis',
- ylabel='Z axis')
+ ylabel='Z axis', ylim=[-50, 50])
plt.grid(axis='both', linestyle=':', linewidth=1)
plt.gca().set_aspect('equal', adjustable='box')
- plt.gca().legend()
+ plt.gca().legend(bbox_to_anchor=(1, 1),
+ bbox_transform=plt.gcf().transFigure)
+
if view == True:
plt.show()
else:
diff --git a/gui.py b/gui.py
index b987e05..05afc38 100644
--- a/gui.py
+++ b/gui.py
@@ -28,29 +28,36 @@ def main():
root.wm_title('MAE 154B - Airfoil Design, Evaluation, Optimization')
# root.geometry('1000x400')
- # # User inputs
- l_naca = ttk.Label(root, text='NACA Number')
- e_naca = ttk.Entry(root)
- l_chord = ttk.Label(root, text='Chord Length')
- e_chord = ttk.Entry(root)
+ # Object definition
+ # User inputs
+ frame_1 = ttk.Frame(root)
+ l_naca = ttk.Label(frame_1, text='NACA Number')
+ naca = tk.StringVar()
+ e_naca = ttk.Entry(frame_1, textvariable=naca)
+ l_chord = ttk.Label(frame_1, text='Chord Length')
+ e_chord = ttk.Entry(frame_1)
af = generator.default_airfoil()
-
- # # Graph window
+ # Graph window
+ frame_2 = ttk.Frame(root)
fig, ax = creator.plot_geom(af, False)
-
- plot = FigureCanvasTkAgg(fig, master=root)
+ plot = FigureCanvasTkAgg(fig, frame_2)
plot.draw()
- plot.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
-
- toolbar = NavigationToolbar2Tk(plot, root)
+ toolbar = NavigationToolbar2Tk(plot, frame_2)
toolbar.update()
- plot.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
- # # Layout
- l_naca.pack()
- e_naca.pack()
- l_chord.pack()
- e_chord.pack()
+ # Layout
+ # User input
+ l_naca.grid(row=0, column=0)
+ e_naca.grid(row=0, column=1, padx=4)
+ l_chord.grid(row=1, column=0)
+ e_chord.grid(row=1, column=1, padx=4)
+ frame_1.pack(side=tk.LEFT)
+ # Graph window
+ plot.get_tk_widget().pack(fill=tk.BOTH)
+ toolbar.pack()
+ frame_2.pack(side=tk.LEFT)
+
+ # plot.get_tk_widget().pack()
root.mainloop()
Copyright 2019--2024 Marius PETER