-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathRocketGui.py
More file actions
188 lines (155 loc) · 8.1 KB
/
Copy pathRocketGui.py
File metadata and controls
188 lines (155 loc) · 8.1 KB
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# SPDX-License-Identifier: LGPL-2.1-or-later
# SPDX-File-Notice: Part of the Rocket addon.
################################################################################
# #
# © 2021 David Carter <dcarter@davidcarter.ca> #
# #
# This addon is free software: you can redistribute it and/or modify #
# it under the terms of the GNU Lesser General Public License as #
# published by the Free Software Foundation, either version 2.1 #
# of the License, or (at your option) any later version. #
# #
# This addon 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 Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser General Public #
# License along with this addon. If not, see https://www.gnu.org/licenses #
# #
################################################################################
__author__ = "David Carter"
__url__ = "https://www.davesrocketshop.com"
import FreeCAD
import FreeCADGui
translate = FreeCAD.Qt.translate
from Ui.Commands.Command import Command
from Ui.Commands.CmdRocket import CmdRocket, CmdToggleRocket
from Ui.Commands.CmdStage import CmdStage, CmdToggleStage
from Ui.Commands.CmdParallelStage import CmdParallelStage, CmdToggleParallelStage
from Ui.Commands.CmdNoseCone import CmdNoseCone
from Ui.Commands.CmdTransition import CmdTransition
from Ui.Commands.CmdCenteringRing import CmdCenteringRing
from Ui.Commands.CmdBodyTube import CmdBodyTube, CmdCoupler, CmdInnerTube, CmdEngineBlock
from Ui.Commands.CmdPod import CmdPod
from Ui.Commands.CmdBulkhead import CmdBulkhead
from Ui.Commands.CmdLaunchGuides import CmdLaunchLug, CmdRailButton, CmdRailGuide, CmdStandOff
from Ui.Commands.CmdFin import CmdFin
from Ui.Commands.CmdFinCan import CmdFinCan
from Ui.Commands.CmdRingtail import CmdRingtail
from Ui.Commands.CmdParachute import CmdParachute
from Ui.Commands.CmdEditTree import CmdMoveUp, CmdMoveDown
# Calculators
from Ui.Commands.CmdCalcBlackPowder import CmdCalcBlackPowder
from Ui.Commands.CmdCalcParachute import CmdCalcParachute
from Ui.Commands.CmdScaling import CmdScalingPairs, CmdScalingTubes
from Ui.Commands.CmdCalcThrustToWeight import CmdCalcThrustToWeight
from Ui.Commands.CmdCalcVentHoles import CmdCalcVentHoles
# Rocket specific sketcher
from Ui.Commands.CmdSketcher import CmdNewSketch
# Template generators
from Ui.Commands.CmdParachuteGore import CmdParachuteGore
# Analysis
from Ui.Commands.CmdFlutterAnalysis import CmdFinFlutter
from Ui.Commands.CmdFemAnalysis import CmdFemAnalysis
# try:
from Ui.Commands.CmdCFDAnalysis import CmdCFDAnalysis
# except:
# pass
from Ui.Commands.CmdMaterialEditor import CmdMaterialEditor
from Rocket.Constants import FEATURE_BODY_TUBE
from Rocket.Constants import FEATURE_LAUNCH_LUG, FEATURE_RAIL_BUTTON, FEATURE_RAIL_GUIDE, FEATURE_OFFSET
FreeCADGui.addCommand('Rocket_Rocket', CmdRocket())
FreeCADGui.addCommand('Rocket_ToggleRocket', CmdToggleRocket())
FreeCADGui.addCommand('Rocket_Stage', CmdStage())
FreeCADGui.addCommand('Rocket_ToggleStage', CmdToggleStage())
FreeCADGui.addCommand('Rocket_ParallelStage', CmdParallelStage())
FreeCADGui.addCommand('Rocket_ToggleParallelStage', CmdToggleParallelStage())
FreeCADGui.addCommand('Rocket_NoseCone', CmdNoseCone())
FreeCADGui.addCommand('Rocket_Transition', CmdTransition())
FreeCADGui.addCommand('Rocket_CenteringRing', CmdCenteringRing())
FreeCADGui.addCommand('Rocket_Bulkhead', CmdBulkhead())
FreeCADGui.addCommand('Rocket_Fin', CmdFin())
FreeCADGui.addCommand('Rocket_FinCan', CmdFinCan())
FreeCADGui.addCommand('Rocket_Ringtail', CmdRingtail())
FreeCADGui.addCommand('Rocket_BodyTube', CmdBodyTube())
FreeCADGui.addCommand('Rocket_Coupler', CmdCoupler())
FreeCADGui.addCommand('Rocket_InnerTube', CmdInnerTube())
FreeCADGui.addCommand('Rocket_EngineBlock', CmdEngineBlock())
FreeCADGui.addCommand('Rocket_Pod', CmdPod())
FreeCADGui.addCommand('Rocket_LaunchLug', CmdLaunchLug())
FreeCADGui.addCommand('Rocket_RailButton', CmdRailButton())
FreeCADGui.addCommand('Rocket_RailGuide', CmdRailGuide())
FreeCADGui.addCommand('Rocket_Standoff', CmdStandOff())
FreeCADGui.addCommand('Rocket_Parachute', CmdParachute())
FreeCADGui.addCommand('Rocket_CalcBlackPowder', CmdCalcBlackPowder())
FreeCADGui.addCommand('Rocket_CalcParachute', CmdCalcParachute())
FreeCADGui.addCommand('Rocket_CalcThrustToWeight', CmdCalcThrustToWeight())
FreeCADGui.addCommand('Rocket_CalcVentHoles', CmdCalcVentHoles())
FreeCADGui.addCommand('Rocket_ScalingPairs', CmdScalingPairs())
FreeCADGui.addCommand('Rocket_ScalingTubes', CmdScalingTubes())
FreeCADGui.addCommand('Rocket_MoveUp', CmdMoveUp())
FreeCADGui.addCommand('Rocket_MoveDown', CmdMoveDown())
FreeCADGui.addCommand('Rocket_NewSketch', CmdNewSketch())
FreeCADGui.addCommand('Rocket_ParachuteGore', CmdParachuteGore())
FreeCADGui.addCommand('Rocket_FinFlutter', CmdFinFlutter())
FreeCADGui.addCommand('Rocket_FemAnalysis', CmdFemAnalysis())
try:
FreeCADGui.addCommand('Rocket_CFDAnalysis', CmdCFDAnalysis())
except:
pass
FreeCADGui.addCommand('Rocket_MaterialEditor', CmdMaterialEditor())
class _CalculatorGroupCommand:
def GetCommands(self):
return tuple(['Rocket_CalcBlackPowder', 'Rocket_CalcParachute', 'Rocket_CalcThrustToWeight', 'Rocket_CalcVentHoles'])
def GetResources(self):
return {
'MenuText': translate('Rocket', 'Calculators'),
'ToolTip': translate('Rocket', 'Calculators'),
'Pixmap': FreeCAD.getUserAppDataDir() + "Mod/Rocket/Resources/icons/Rocket_Calculator.svg"
}
def IsActive(self):
# Always available, even without active document
return True
class _ScalingGroupCommand:
def GetCommands(self):
return tuple(['Rocket_ScalingTubes', 'Rocket_ScalingPairs'])
def GetResources(self):
return {
'MenuText': translate('Rocket', 'Scaling Tools'),
'ToolTip': translate('Rocket', 'Scaling Tools'),
'Pixmap': FreeCAD.getUserAppDataDir() + "Mod/Rocket/Resources/icons/Rocket_Scaling.svg"
}
def IsActive(self):
# Always available, even without active document
return True
class _TubeGroupCommand(Command):
def GetCommands(self):
return tuple(['Rocket_BodyTube', 'Rocket_Coupler', 'Rocket_InnerTube'])
def GetResources(self):
return {
'MenuText': translate('Rocket', 'Body Tubes'),
'ToolTip': translate('Rocket', 'Body Tubes'),
'Pixmap': FreeCAD.getUserAppDataDir() + "Mod/Rocket/Resources/icons/Rocket_BodyTube.svg"
}
def IsActive(self):
if FreeCAD.ActiveDocument:
return self.partEligibleFeature(FEATURE_BODY_TUBE)
return False
class _GuidesGroupCommand(Command):
def GetCommands(self):
return tuple(['Rocket_LaunchLug', 'Rocket_RailButton', 'Rocket_RailGuide'])
def GetResources(self):
return {
'MenuText': translate('Rocket', 'Launch Guides'),
'ToolTip': translate('Rocket', 'Launch Guides'),
'Pixmap': FreeCAD.getUserAppDataDir() + "Mod/Rocket/Resources/icons/Rocket_LaunchLug.svg"
}
def IsActive(self):
if FreeCAD.ActiveDocument:
return self.partEligibleFeature([FEATURE_LAUNCH_LUG, FEATURE_RAIL_BUTTON, FEATURE_RAIL_GUIDE, FEATURE_OFFSET])
return False
FreeCADGui.addCommand('Rocket_Calculators', _CalculatorGroupCommand())
FreeCADGui.addCommand('Rocket_Scaling', _ScalingGroupCommand())
FreeCADGui.addCommand('Rocket_BodyTubes', _TubeGroupCommand())
FreeCADGui.addCommand('Rocket_LaunchGuides', _GuidesGroupCommand())