Skip to content

Commit 2428d77

Browse files
committed
set version to 0.03
rename property horizontal_shift -> vertical_shift add update functions to update freecad objects to newer versions of openglider
1 parent 34386f3 commit 2428d77

9 files changed

Lines changed: 149 additions & 86 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# profile-drag
2+
3+
To make good prediction of the position of the lower attachment point (connection harness/glider) it's necessary to know about all acting forces. All forces are split into drag (parallel to v_inf) and lift (perpendicular to v_inf)
4+
- Lift of the wing:
5+
Predicted via the panel-method (para-bem) by summing pressure over all surfaces and computing the v_inf perpendicular part. Dependent on wake definitions.
6+
- Induced drag:
7+
Predicted via the panel-method (para-bem) by summing pressure over all surfaces and computing the v_inf parallel part.
8+
- Line drag are predicted with a specific cd-value for each line and is accessible via `lineset.get_drag`.
9+
- Pilot drag:
10+
Best to predict with experiement / calibration. s * rho * v**2 / 2 (s ~ 0.8, rho = 1.2, v ~ 11)
11+
- Profile-drag:
12+
Lift and drag predicted by computing the potential-flow does not take viscous drag into account. A prediction can be made by using the known drag and a given glide-angle.
13+

freecad/freecad_glider/init_gui.py

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,6 @@
1010

1111

1212

13-
# as long as this isn't part of std pivy:
14-
########################################################################################
15-
def SoGroup__iadd__(self, other):
16-
if isinstance(other, (list, tuple)):
17-
for other_i in other:
18-
self.__iadd__(other_i)
19-
return self
20-
else:
21-
try:
22-
self.addChild(other)
23-
return self
24-
except TypeError as e:
25-
raise TypeError(str(self.__class__) + " accepts only objects of type pivy.coin.SoNode")
26-
27-
def SoGroup__isub__(self, other):
28-
if isinstance(other, (list, tuple)):
29-
for other_i in other:
30-
self.__isub__(other_i)
31-
return self
32-
else:
33-
try:
34-
self.removeChild(other)
35-
return self
36-
except TypeError as e:
37-
raise TypeError(str(self.__class__) + " can't remove child of type " + str(type(other)))
38-
39-
40-
def SoGroup_getByName(self, name):
41-
for child in self:
42-
if name == child.getName():
43-
return child
44-
return None
45-
46-
47-
coin.SoGroup.__iadd__ = SoGroup__iadd__
48-
coin.SoGroup.__isub__ = SoGroup__isub__
49-
coin.SoGroup.getByName = SoGroup_getByName
50-
########################################################################################
5113

5214
Dir = os.path.abspath(os.path.dirname(__file__))
5315
Gui.addIconPath(os.path.join(Dir, 'icons'))
@@ -151,8 +113,7 @@ def Initialize(self):
151113
self.appendToolbar('GliderView', self.viewBox)
152114
self.appendToolbar('Develop', self.devBox)
153115

154-
155-
Gui.addPreferencePage(Dir + '/ui/preferences.ui', 'Display')
116+
# Gui.addPreferencePage(Dir + '/ui/preferences.ui', 'glider')
156117

157118
def Activated(self):
158119
pass
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# updaing projects to newer versions of openglider and dependencies
2+
# defining an interface to do this?
3+
4+
import openglider
5+
from freecad import app
6+
from .glider import addProperty
7+
8+
# 1 write update function:
9+
# 2 append function to "version_update"
10+
11+
def version_update(obj):
12+
from_0_01_to_0_02(obj)
13+
from_0_02_to_0_03(obj)
14+
15+
def from_0_01_to_0_02(obj):
16+
# no version was specified so we have to update to 0.2
17+
if not hasattr(obj, "openglider_version"):
18+
obj.addProperty('App::PropertyString',
19+
'openglider_version', 'metadata',
20+
'the version of openglider used to create this glider', 1)
21+
22+
obj.addProperty('App::PropertyString',
23+
'freecad_version', 'metadata',
24+
'the version of openglider used to create this glider', 1)
25+
26+
obj.openglider_version = "0.02"
27+
obj.freecad_version = "{}.{}".format(*app.Version())
28+
app.Console.PrintWarning("updating {} from openglider 0.01 to openglider 0.02\n".format(obj.Label))
29+
30+
def from_0_02_to_0_03(obj):
31+
if obj.openglider_version == "0.02":
32+
if hasattr(obj, "horizontal_shift"):
33+
value = obj.horizontal_shift
34+
obj.removeProperty("horizontal_shift")
35+
addProperty(obj, 'vertical_shift', value, 'hole', 'relative vertical shift')
36+
obj.openglider_version = "0.03"
37+
app.Console.PrintWarning("updating {} from openglider 0.02 to openglider 0.03\n".format(obj.Label))
38+
39+

freecad/freecad_glider/tools/features.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,17 @@ def onDocumentRestored(self, obj):
6363
self.obj.parent.ViewObject.Visibility = False
6464
self.obj.parent.Proxy.onDocumentRestored(self.obj.parent)
6565

66+
from . import backward_comatipility as bc
67+
bc.version_update(obj)
68+
69+
# if we have modified the glider without gui, the view-provider is empty and we
70+
# have to resore it:
6671
if App.GuiUp and not self.obj.ViewObject.Proxy:
6772
self.restore_view_provider() # defined in parent class
68-
# backward compatibility (remove this)
69-
# self.obj.Proxy.addProperties()
7073

7174
self.obj.ViewObject.Proxy.recompute = True
7275
# we have blocked the automatic update mechanism. so now we have to call it manually
7376
if self.obj.ViewObject.Visibility:
74-
print(self)
75-
print("updating the view")
7677
self.obj.ViewObject.Proxy.updateData(prop='Visibility')
7778
#########################################################################################
7879

@@ -184,7 +185,6 @@ def __init__(self, obj, parent):
184185
def getGliderInstance(self):
185186
glider = copy.deepcopy(self.obj.parent.Proxy.getGliderInstance())
186187
new_ribs = []
187-
self.addProperties()
188188

189189
single_skin_par = {'att_dist': self.obj.att_dist,
190190
'height': self.obj.height,
@@ -221,7 +221,7 @@ def getGliderInstance(self):
221221
att_pnt.rib_pos < self.obj.max_hole_pos):
222222
att_pnt.rib.holes.append(RibHole(att_pnt.rib_pos,
223223
size=hole_size,
224-
horizontal_shift=self.obj.horizontal_shift))
224+
vertical_shift=self.obj.vertical_shift))
225225
for i, rib in enumerate(glider.ribs):
226226
rib.xrot = self.obj.xrot[i]
227227

@@ -239,7 +239,7 @@ def addProperties(self):
239239
self.addProperty('hole_height', 0.7, 'hole', 'height of ellipse')
240240
self.addProperty('hole_width', 0.3, 'hole', 'width of ellipse')
241241
self.addProperty('max_hole_pos', 1., 'hole', 'maximal relative position of hole')
242-
self.addProperty('horizontal_shift', 0.2, 'hole', 'relative horizontal shift')
242+
self.addProperty('vertical_shift', 0.2, 'hole', 'relative vertical shift')
243243
self.addProperty('min_hole_pos', 0.2, 'hole', 'minimal relative position of hole')
244244
self.addProperty('continued_min', False, 'bows', 'add an offset to the airfoil')
245245
self.addProperty('continued_min_end', 0.9, 'bows', 'no idea')
@@ -269,7 +269,6 @@ def addProperties(self):
269269
def getGliderInstance(self):
270270
glider = copy.deepcopy(self.obj.parent.Proxy.getGliderInstance())
271271
new_ribs = []
272-
self.addProperties()
273272

274273
for i, rib in enumerate(glider.ribs):
275274
if i in self.obj.flap_ribs:
@@ -292,7 +291,6 @@ def getGliderInstance(self):
292291

293292
ribs = [rib for i, rib in enumerate(glider.ribs) if i in self.obj.ribs]
294293
new_ribs = []
295-
self.addProperties()
296294

297295
hole_size = np.array([self.obj.hole_width, self.obj.hole_height])
298296
if self.obj.holes:
@@ -302,7 +300,7 @@ def getGliderInstance(self):
302300
att_pnt.rib_pos < self.obj.max_hole_pos):
303301
att_pnt.rib.holes.append(RibHole(att_pnt.rib_pos,
304302
size=hole_size,
305-
horizontal_shift=self.obj.horizontal_shift,
303+
vertical_shift=self.obj.vertical_shift,
306304
rotation=self.obj.rotation))
307305

308306
return glider
@@ -313,7 +311,7 @@ def addProperties(self):
313311
self.addProperty('hole_height', 0.7, 'hole', 'height of ellipse')
314312
self.addProperty('hole_width', 0.3, 'hole', 'width of ellipse')
315313
self.addProperty('max_hole_pos', 1., 'hole', 'maximal relative position of hole')
316-
self.addProperty('horizontal_shift', 0.2, 'hole', 'relative horizontal shift')
314+
self.addProperty('vertical_shift', 0.2, 'hole', 'relative vertical shift')
317315
self.addProperty('min_hole_pos', 0.2, 'hole', 'minimal relative position of hole')
318316
self.addProperty('rotation', 0.0, 'hole', 'docs')
319317

freecad/freecad_glider/tools/glider.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import numpy as np
66

77
import FreeCAD as App
8+
import openglider
89
from openglider import jsonify, mesh
910
from openglider.glider import ParametricGlider
1011
from openglider.glider.cell.elements import TensionLine
@@ -30,6 +31,7 @@ def coin_SoSwitch(parent, name):
3031
# a list of all default parameters
3132
preference_table = {'default_show_half_glider': (bool, True),
3233
'default_show_panels': (bool, False),
34+
'default_fill_ribs': (bool, True),
3335
'default_num_prof_points': (int, 20),
3436
'default_num_cell_points': (int, 0),
3537
'default_num_line_points': (int, 2),
@@ -79,7 +81,7 @@ def mesh_sep(mesh, color, draw_lines=False):
7981
sep += [line_mat, line_set]
8082
return sep
8183

82-
def _addProperty(obj, name, value, group, docs, p_type=None):
84+
def addProperty(obj, name, value, group, docs, p_type=None):
8385
'''
8486
property_list:
8587
property_name property_value, property_group, property_docs
@@ -118,7 +120,16 @@ def _addProperty(obj, name, value, group, docs, p_type=None):
118120

119121
class OGBaseObject(object):
120122
def __init__(self, obj):
123+
obj.addProperty('App::PropertyString',
124+
'openglider_version', 'metadata',
125+
'the version of openglider used to create this glider', 1)
126+
127+
obj.addProperty('App::PropertyString',
128+
'freecad_version', 'metadata',
129+
'the version of openglider used to create this glider', 1)
121130
obj.Proxy = self
131+
obj.openglider_version = openglider.__version__
132+
obj.freecad_version = "{}.{}".format(*App.Version())
122133
self.obj = obj
123134

124135
def addProperties(self):
@@ -128,7 +139,7 @@ def execute(self, fp):
128139
pass
129140

130141
def addProperty(self, name, value, group, docs, p_type=None):
131-
_addProperty(self.obj, name, value, group, docs, p_type)
142+
addProperty(self.obj, name, value, group, docs, p_type)
132143

133144
def restore_view_provider(self):
134145
# adding the Proxy to the ViewObject (FeaturePython)
@@ -144,7 +155,7 @@ def __init__(self, view_obj):
144155
self.obj = view_obj.Object
145156

146157
def addProperty(self, name, value, group, docs, p_type=None, view_obj=None):
147-
_addProperty(view_obj or self.view_obj, name, value, group, docs, p_type)
158+
addProperty(view_obj or self.view_obj, name, value, group, docs, p_type)
148159

149160
def attach(self, view_obj):
150161
self.view_obj = view_obj
@@ -235,20 +246,18 @@ def __setstate__(self, state):
235246
def onDocumentRestored(self, obj):
236247
if not hasattr(self, 'obj'): # make sure this function is only run once
237248
self.obj = obj
249+
from . import backward_comatipility as bc
238250

239-
# backward compatibility (remove this)
240-
try:
241-
self.obj.ViewObject.Proxy.addProperties(self.obj.ViewObject)
242-
except AttributeError:
243-
# this doesn't work always
244-
pass
251+
bc.version_update(obj)
245252

253+
# if we have modified the glider without gui, the view-provider is empty and we
254+
# have to resore it:
246255
if App.GuiUp and not self.obj.ViewObject.Proxy:
247256
self.restore_view_provider()
248257
self.obj.ViewObject.Proxy.recompute = True
249258
# we have blocked the automatic update mechanism. so now we have to call it manually
250-
if self.obj.ViewObject.Visibility:
251-
self.obj.ViewObject.Proxy.updateData(prop='Visibility')
259+
# if self.obj.ViewObject.Visibility:
260+
# self.obj.ViewObject.Proxy.updateData(prop='Visibility')
252261
##################################################################################
253262

254263
# the update system on file-open of freecad is difficult.
@@ -309,7 +318,7 @@ def __init__(self, view_obj):
309318
view_obj.ribs = True
310319
view_obj.half_glider = get_parameter('default_show_half_glider')
311320
view_obj.hole_num = get_parameter('default_num_hole_points')
312-
view_obj.fill_ribs = False
321+
view_obj.fill_ribs = get_parameter('default_fill_ribs')
313322
view_obj.x = 0.
314323
view_obj.y = 0.
315324
view_obj.z = 0.

0 commit comments

Comments
 (0)