Merge branch 'master' into bugfix/pocket-shape-extensions

This commit is contained in:
sliptonic
2019-06-30 09:32:07 -05:00
committed by GitHub
7 changed files with 240 additions and 277 deletions

View File

@@ -435,7 +435,10 @@ class DraftToolBar:
if hide:
button.hide()
if icon:
button.setIcon(QtGui.QIcon.fromTheme(icon, QtGui.QIcon(':/icons/'+icon+'.svg')))
if icon.endswith(".svg"):
button.setIcon(QtGui.QIcon(icon))
else:
button.setIcon(QtGui.QIcon.fromTheme(icon, QtGui.QIcon(':/icons/'+icon+'.svg')))
#button.setIconSize(QtCore.QSize(isize, isize))
if checkable:
button.setCheckable(True)
@@ -772,9 +775,10 @@ class DraftToolBar:
self.widthButton = self._spinbox("widthButton", self.bottomtray, val=self.linewidth,hide=False,size=(bsize * 2,bsize))
self.widthButton.setSuffix("px")
self.fontsizeButton = self._spinbox("fontsizeButton",self.bottomtray, val=self.fontsize,vmax=999, hide=False,double=True,size=(bsize * 4,bsize))
self.applyButton = self._pushbutton("applyButton", self.toptray, hide=False, icon='Draft_Apply',square=True)
self.autoGroupButton = self._pushbutton("autoGroup",self.bottomtray,icon="Draft_AutoGroup_off",hide=False,width=120)
self.autoGroupButton = self._pushbutton("autoGroup",self.bottomtray,icon=":/icons/button_invalid.svg",hide=False,width=120)
self.autoGroupButton.setText("None")
self.autoGroupButton.setFlat(True)
self.applyButton = self._pushbutton("applyButton", self.toptray, hide=False, icon='Draft_Apply',square=True)
QtCore.QObject.connect(self.wplabel,QtCore.SIGNAL("pressed()"),self.selectplane)
QtCore.QObject.connect(self.colorButton,QtCore.SIGNAL("pressed()"),self.getcol)
@@ -2022,15 +2026,21 @@ class DraftToolBar:
def selectplane(self):
FreeCADGui.runCommand("Draft_SelectPlane")
def popupMenu(self,mlist):
def popupMenu(self,llist,ilist=None):
"pops up a menu filled with the given list"
self.groupmenu = QtGui.QMenu()
for i in mlist:
self.groupmenu.addAction(i)
for i,l in enumerate(llist):
if ilist:
self.groupmenu.addAction(ilist[i],l)
else:
self.groupmenu.addAction(l)
pos = FreeCADGui.getMainWindow().cursor().pos()
self.groupmenu.popup(pos)
QtCore.QObject.connect(self.groupmenu,QtCore.SIGNAL("triggered(QAction *)"),self.popupTriggered)
def getIcon(self,iconpath):
return QtGui.QIcon(iconpath)
def popupTriggered(self,action):
self.sourceCmd.proceed(str(action.text()))
@@ -2093,7 +2103,7 @@ class DraftToolBar:
self.autogroup = None
self.autoGroupButton.setText("None")
self.autoGroupButton.setIcon(QtGui.QIcon.fromTheme('Draft_AutoGroup_off',
QtGui.QIcon(':/icons/Draft_AutoGroup_off.svg')))
QtGui.QIcon(':/icons/button_invalid.svg')))
self.autoGroupButton.setToolTip(translate("draft", "Autogroup off"))
self.autoGroupButton.setDown(False)
else:
@@ -2101,15 +2111,14 @@ class DraftToolBar:
if obj:
self.autogroup = value
self.autoGroupButton.setText(obj.Label)
self.autoGroupButton.setIcon(QtGui.QIcon.fromTheme('Draft_AutoGroup_on',
QtGui.QIcon(':/icons/Draft_AutoGroup_on.svg')))
self.autoGroupButton.setIcon(obj.ViewObject.Icon)
self.autoGroupButton.setToolTip(translate("draft", "Autogroup: ")+obj.Label)
self.autoGroupButton.setDown(False)
else:
self.autogroup = None
self.autoGroupButton.setText("None")
self.autoGroupButton.setIcon(QtGui.QIcon.fromTheme('Draft_AutoGroup_off',
QtGui.QIcon(':/icons/Draft_AutoGroup_off.svg')))
QtGui.QIcon(':/icons/button_invalid.svg')))
self.autoGroupButton.setToolTip(translate("draft", "Autogroup off"))
self.autoGroupButton.setDown(False)

View File

@@ -277,6 +277,20 @@ class ViewProviderLayer:
parent.Group = g
FreeCAD.ActiveDocument.recompute()
def setupContextMenu(self,vobj,menu):
from PySide import QtCore,QtGui
action1 = QtGui.QAction(QtGui.QIcon(":/icons/button_right.svg"),translate("draft","Activate this layer"),menu)
action1.triggered.connect(self.activate)
menu.addAction(action1)
def activate(self):
if hasattr(self,"Object"):
FreeCADGui.Selection.clearSelection()
FreeCADGui.Selection.addSelection(self.Object)
FreeCADGui.runCommand("Draft_AutoGroup")
class LayerContainer:
@@ -289,7 +303,9 @@ class LayerContainer:
def execute(self,obj):
return
g = obj.Group
g.sort(key=lambda o: o.Label)
obj.Group = g
def __getstate__(self):

View File

@@ -5303,20 +5303,26 @@ class SetAutoGroup():
self.ui = FreeCADGui.draftToolBar
s = FreeCADGui.Selection.getSelection()
if len(s) == 1:
if s[0].isDerivedFrom("App::DocumentObjectGroup") or (Draft.getType(s[0]) in ["Site","Building","Floor"]):
if (Draft.getType(s[0]) == "Layer") or \
( FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/BIM").GetBool("AutogroupAddGroups",False) and \
(s[0].isDerivedFrom("App::DocumentObjectGroup") or (Draft.getType(s[0]) in ["Site","Building","Floor","BuildingPart",]))):
self.ui.setAutoGroup(s[0].Name)
return
self.groups = ["None"]
gn = Draft.getGroupNames()
gn = [o.Name for o in FreeCAD.ActiveDocument.Objects if Draft.getType(o) == "Layer"]
if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/BIM").GetBool("AutogroupAddGroups",False):
gn.extend(Draft.getGroupNames())
if gn:
self.groups.extend(gn)
self.labels = ["None"]
self.icons = [self.ui.getIcon(":/icons/button_invalid.svg")]
for g in gn:
o = FreeCAD.ActiveDocument.getObject(g)
if o:
self.labels.append(o.Label)
self.icons.append(o.ViewObject.Icon)
self.ui.sourceCmd = self
self.ui.popupMenu(self.labels)
self.ui.popupMenu(self.labels,self.icons)
def proceed(self,labelname):
self.ui.sourceCmd = None

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>486</width>
<height>758</height>
<height>781</height>
</rect>
</property>
<property name="windowTitle">
@@ -17,16 +17,7 @@
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>9</number>
</property>
<item>
@@ -373,6 +364,25 @@ Values with differences below this value will be treated as same. This value wil
</item>
</layout>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="checkBox_3">
<property name="toolTip">
<string>If this option is checked, the layers drop-down list will also show groups, allowing you to automatically add objects to groups too.</string>
</property>
<property name="text">
<string>Show groups in layers list drop-down button</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>AutogroupAddGroups</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -442,7 +452,7 @@ Values with differences below this value will be treated as same. This value wil
<property name="toolTip">
<string>This is the default color for objects being drawn while in construction mode.</string>
</property>
<property name="color" stdset="0">
<property name="color">
<color>
<red>44</red>
<green>125</green>
@@ -505,14 +515,14 @@ Values with differences below this value will be treated as same. This value wil
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutRelative</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutRelative</cstring>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
@@ -555,14 +565,14 @@ Values with differences below this value will be treated as same. This value wil
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutContinue</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutContinue</cstring>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
@@ -605,14 +615,14 @@ Values with differences below this value will be treated as same. This value wil
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutClose</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutClose</cstring>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
@@ -657,14 +667,14 @@ Values with differences below this value will be treated as same. This value wil
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutCopy</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutCopy</cstring>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
@@ -705,14 +715,14 @@ Values with differences below this value will be treated as same. This value wil
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutSubelementMode</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutSubelementMode</cstring>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
@@ -753,14 +763,14 @@ Values with differences below this value will be treated as same. This value wil
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutFill</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutFill</cstring>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
@@ -805,14 +815,14 @@ Values with differences below this value will be treated as same. This value wil
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutExit</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutExit</cstring>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
@@ -853,14 +863,14 @@ Values with differences below this value will be treated as same. This value wil
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutSelectEdge</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutSelectEdge</cstring>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
@@ -901,14 +911,14 @@ Values with differences below this value will be treated as same. This value wil
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutAddHold</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutAddHold</cstring>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
@@ -953,14 +963,14 @@ Values with differences below this value will be treated as same. This value wil
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutLength</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutLength</cstring>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
@@ -1001,14 +1011,14 @@ Values with differences below this value will be treated as same. This value wil
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutWipe</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutWipe</cstring>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
@@ -1049,14 +1059,14 @@ Values with differences below this value will be treated as same. This value wil
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutSetWP</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutSetWP</cstring>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
@@ -1101,14 +1111,14 @@ Values with differences below this value will be treated as same. This value wil
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutCycleSnap</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutCycleSnap</cstring>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
@@ -1159,14 +1169,14 @@ Values with differences below this value will be treated as same. This value wil
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutSnap</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutSnap</cstring>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
@@ -1207,14 +1217,14 @@ Values with differences below this value will be treated as same. This value wil
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutIncreaseRadius</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutIncreaseRadius</cstring>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
@@ -1255,14 +1265,14 @@ Values with differences below this value will be treated as same. This value wil
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutDecreaseRadius</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutDecreaseRadius</cstring>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
@@ -1307,14 +1317,14 @@ Values with differences below this value will be treated as same. This value wil
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutRestrictX</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutRestrictX</cstring>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
@@ -1355,14 +1365,14 @@ Values with differences below this value will be treated as same. This value wil
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutRestrictY</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutRestrictY</cstring>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
@@ -1403,14 +1413,14 @@ Values with differences below this value will be treated as same. This value wil
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<property name="prefEntry" stdset="0">
<cstring>RestrictZ</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
<property name="prefEntry" stdset="0">
<cstring>RestrictZ</cstring>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
@@ -1439,11 +1449,21 @@ Values with differences below this value will be treated as same. This value wil
<layoutdefault spacing="6" margin="11"/>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>Gui::ColorButton</class>
<extends>QPushButton</extends>
<header>Gui/Widgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefSpinBox</class>
<extends>QSpinBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefColorButton</class>
<extends>Gui::ColorButton</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
@@ -1454,26 +1474,16 @@ Values with differences below this value will be treated as same. This value wil
<extends>QComboBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::ColorButton</class>
<extends>QPushButton</extends>
<header>Gui/Widgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefColorButton</class>
<extends>Gui::ColorButton</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefLineEdit</class>
<extends>QLineEdit</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>532</width>
<height>484</height>
<width>531</width>
<height>552</height>
</rect>
</property>
<property name="windowTitle">
@@ -26,90 +26,6 @@
<string>Visual Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Default line color</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Gui::PrefColorButton" name="gui::prefcolorbutton">
<property name="toolTip">
<string>The default color for new objects</string>
</property>
<property name="color">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>color</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Default line width</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Gui::PrefSpinBox" name="gui::prefspinbox">
<property name="toolTip">
<string>The default linewidth for new objects</string>
</property>
<property name="value">
<number>2</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>linewidth</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>

View File

@@ -37,11 +37,25 @@ from femtest.testresult import TestResult
from femtest.testccxtools import TestCcxTools
from femtest.testsolverframework import TestSolverFrameWork
# dummy usage to get flake8 and lgtm quiet
False if TestFemCommon.__name__ else True
False if TestObjectCreate.__name__ else True
False if TestObjectType.__name__ else True
False if TestMaterialUnits.__name__ else True
False if TestMeshCommon.__name__ else True
False if TestMeshEleTetra10.__name__ else True
False if TestMeshEleTetra10.__name__ else True
False if TestResult.__name__ else True
False if TestCcxTools.__name__ else True
False if TestSolverFrameWork.__name__ else True
# For more information on how to run a specific test class or a test method see
# file src/Mod/Test/__init__ and forum https://forum.freecadweb.org/viewtopic.php?f=10&t=22190#p175546
# file src/Mod/Test/__init__
# forum https://forum.freecadweb.org/viewtopic.php?f=10&t=22190#p175546
# It may be useful to temporary comment FreeCAD.closeDocument(self.doc_name) in tearDown method to not close the document
# It may be useful to temporary comment FreeCAD.closeDocument(self.doc_name)
# in tearDown method to not close the document
'''
@@ -60,8 +74,9 @@ Test.runTestsFromClass(femtest.testcommon.TestFemCommon)
# method
import unittest
mytest = unittest.TestLoader().loadTestsFromName("femtest.testcommon.TestFemCommon.test_pyimport_all_FEM_modules")
unittest.TextTestRunner().run(mytest)
thetest = "femtest.testcommon.TestFemCommon.test_pyimport_all_FEM_modules"
alltest = unittest.TestLoader().loadTestsFromName(thetest)
unittest.TextTestRunner().run(alltest)
# examples from shell in build dir:
@@ -96,7 +111,8 @@ unittest.TextTestRunner().run(mytest)
./bin/FreeCAD --run-test "femtest.testcommon.TestFemCommon.test_pyimport_all_FEM_modules"
# unit test command to run a specific FEM unit test to copy for fast tests :-)
# to get all command to start FreeCAD from build dir on Linux and run FEM unit test this could be used
# to get all commands to start FreeCAD from build dir on Linux
# and run FEM unit test this could be used:
from femtest.utilstest import get_fem_test_defs as gf
gf()
@@ -133,7 +149,8 @@ gf()
./bin/FreeCADCmd --run-test "femtest.testsolverframework.TestSolverFrameWork.test_solver_framework"
# to get all command to start FreeCAD from build dir on Linux and run FEM unit test this could be used
# to get all command to start FreeCAD from build dir on Linux
# and run FEM unit test this could be used:
from femtest.utilstest import get_fem_test_defs as gf
gf('in')
@@ -234,12 +251,13 @@ unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromName("femtest.t
# open files from FEM test suite source code
# be careful on updating these files, they contain the original results!
# TODO update files, because some of them have non-existing FEM object classes
doc = FreeCAD.open(FreeCAD.ConfigGet("AppHomePath") + 'Mod/Fem/femtest/testfiles/ccx/cube.FCStd')
doc = FreeCAD.open(FreeCAD.ConfigGet("AppHomePath") + 'Mod/Fem/femtest/testfiles/ccx/cube_frequency.FCStd')
doc = FreeCAD.open(FreeCAD.ConfigGet("AppHomePath") + 'Mod/Fem/femtest/testfiles/ccx/cube_static.FCStd')
doc = FreeCAD.open(FreeCAD.ConfigGet("AppHomePath") + 'Mod/Fem/femtest/testfiles/ccx/Flow1D_thermomech.FCStd')
doc = FreeCAD.open(FreeCAD.ConfigGet("AppHomePath") + 'Mod/Fem/femtest/testfiles/ccx/multimat.FCStd')
doc = FreeCAD.open(FreeCAD.ConfigGet("AppHomePath") + 'Mod/Fem/femtest/testfiles/ccx/spine_thermomech.FCStd')
app_home = FreeCAD.ConfigGet("AppHomePath")
doc = FreeCAD.open(app_home + 'Mod/Fem/femtest/testfiles/ccx/cube.FCStd')
doc = FreeCAD.open(app_home + 'Mod/Fem/femtest/testfiles/ccx/cube_frequency.FCStd')
doc = FreeCAD.open(app_home + 'Mod/Fem/femtest/testfiles/ccx/cube_static.FCStd')
doc = FreeCAD.open(app_home + 'Mod/Fem/femtest/testfiles/ccx/Flow1D_thermomech.FCStd')
doc = FreeCAD.open(app_home + 'Mod/Fem/femtest/testfiles/ccx/multimat.FCStd')
doc = FreeCAD.open(app_home + 'Mod/Fem/femtest/testfiles/ccx/spine_thermomech.FCStd')
# open files generated from test suite
import femtest.utilstest as ut
@@ -252,10 +270,11 @@ doc = ut.multimat()
doc = ut.spine_thermomech()
# load std FEM example files
doc = FreeCAD.open(FreeCAD.ConfigGet("AppHomePath") + 'data/examples/FemCalculixCantilever2D.FCStd')
doc = FreeCAD.open(FreeCAD.ConfigGet("AppHomePath") + 'data/examples/FemCalculixCantilever3D.FCStd')
doc = FreeCAD.open(FreeCAD.ConfigGet("AppHomePath") + 'data/examples/FemCalculixCantilever3D_newSolver.FCStd')
doc = FreeCAD.open(FreeCAD.ConfigGet("AppHomePath") + 'data/examples/Fem.FCStd')
doc = FreeCAD.open(FreeCAD.ConfigGet("AppHomePath") + 'data/examples/Fem2.FCStd')
app_home = FreeCAD.ConfigGet("AppHomePath")
doc = FreeCAD.open(app_home + 'data/examples/FemCalculixCantilever2D.FCStd')
doc = FreeCAD.open(app_home + 'data/examples/FemCalculixCantilever3D.FCStd')
doc = FreeCAD.open(app_home + 'data/examples/FemCalculixCantilever3D_newSolver.FCStd')
doc = FreeCAD.open(app_home + 'data/examples/Fem.FCStd')
doc = FreeCAD.open(app_home + 'data/examples/Fem2.FCStd')
'''

View File

@@ -46,8 +46,8 @@ __url__ = "http://www.freecadweb.org"
__doc__ = "Path Profile operation based on faces."
__contributors__ = "russ4262 (Russell Johnson)"
__created__ = "2014"
__scriptVersion__ = "2h testing"
__lastModified__ = "2019-06-18 22:36 CST"
__scriptVersion__ = "2i testing"
__lastModified__ = "2019-06-29 23:05 CST"
LOGLEVEL = False
@@ -94,12 +94,21 @@ class ObjectProfile(PathProfileBase.ObjectProfile):
if not hasattr(obj, 'AttemptInverseAngle'):
obj.addProperty('App::PropertyBool', 'AttemptInverseAngle', 'Rotation', QtCore.QT_TRANSLATE_NOOP('App::Property', 'Attempt the inverse angle for face access if original rotation fails.'))
if not hasattr(obj, 'HandleMultipleFeatures'):
obj.addProperty('App::PropertyEnumeration', 'HandleMultipleFeatures', 'Profile', QtCore.QT_TRANSLATE_NOOP('PathPocket', 'Choose how to process multiple Base Geometry features.'))
obj.HandleMultipleFeatures = ['Collectively', 'Individually']
self.baseObject().initAreaOp(obj)
def opOnDocumentRestored(self, obj):
'''opOnDocumentRestored(obj) ... adds the properties if they doesn't exist.'''
# self.initAreaOp(obj)
pass
def areaOpShapes(self, obj):
'''areaOpShapes(obj) ... returns envelope for all base shapes or wires for Arch.Panels.'''
PathLog.track()
PathLog.debug("----- areaOpShapes() in PathProfileFaces.py")
PathLog.info("----- areaOpShapes() in PathProfileFaces.py")
if obj.UseComp:
self.commandlist.append(Path.Command("(Compensated Tool Path. Diameter: " + str(self.radius * 2) + ")"))
@@ -108,7 +117,6 @@ class ObjectProfile(PathProfileBase.ObjectProfile):
shapes = []
self.profileshape = []
finalDepths = []
startDepths = []
faceDepths = []
@@ -140,8 +148,6 @@ class ObjectProfile(PathProfileBase.ObjectProfile):
else:
msg = translate("Path", "Consider toggling the 'InverseAngle' property and recomputing.")
PathLog.error(msg)
# title = translate("Path", 'Rotation Warning')
# self.guiMessage(title, msg, False)
else:
PathLog.debug("Face appears to be oriented correctly.")
@@ -154,17 +160,11 @@ class ObjectProfile(PathProfileBase.ObjectProfile):
tag = base.Name + '_' + axis + str(angle).replace('.', '_')
stock = PathUtils.findParentJob(obj).Stock
tup = base, sub, tag, angle, axis, stock
# Eif
allTuples.append(tup)
# Eif
# Efor
# Efor
if subCount > 1:
msg = translate('Path', "Multiple faces in Base Geometry.") + " "
msg += translate('Path', "Depth settings will be applied to all faces.")
PathLog.warning(msg)
# title = translate("Path", "Depth Warning")
# self.guiMessage(title, msg)
(Tags, Grps) = self.sortTuplesByIndex(allTuples, 2) # return (TagList, GroupList)
subList = []
for o in range(0, len(Tags)):
@@ -175,7 +175,7 @@ class ObjectProfile(PathProfileBase.ObjectProfile):
baseSubsTuples.append(pair)
# Efor
else:
PathLog.info(translate("Path", "EnableRotation property is 'Off'."))
PathLog.debug(translate("Path", "EnableRotation property is 'Off'."))
stock = PathUtils.findParentJob(obj).Stock
for (base, subList) in obj.Base:
baseSubsTuples.append((base, subList, 0.0, 'X', stock))
@@ -205,9 +205,6 @@ class ObjectProfile(PathProfileBase.ObjectProfile):
# Raise FinalDepth to lowest face in list on Inside profile ops
finDep = obj.FinalDepth.Value
if obj.Side == 'Inside':
finDep = min(faceDepths)
finalDepths.append(finDep)
strDep = obj.StartDepth.Value
if strDep > stock.Shape.BoundBox.ZMax:
@@ -239,46 +236,37 @@ class ObjectProfile(PathProfileBase.ObjectProfile):
self.profileshape.append(profileshape)
if obj.processPerimeter:
PathLog.track()
try:
env = PathUtils.getEnvelope(base.Shape, subshape=profileshape, depthparams=self.depthparams)
except Exception:
# PathUtils.getEnvelope() failed to return an object.
PathLog.error(translate('Path', 'Unable to create path for face(s).'))
else:
# shapes.append((env, False))
tup = env, False, 'pathProfileFaces', angle, axis, strDep, finDep
shapes.append(tup)
else:
for shape in faces:
finalDep = finDep
# Recalculate depthparams
if obj.Side == 'Inside':
if finalDep < shape.BoundBox.ZMin:
custDepthparams = PathUtils.depth_params(
clearance_height=obj.ClearanceHeight.Value,
safe_height=obj.SafeHeight.Value,
start_depth=strDep, # obj.StartDepth.Value,
step_down=obj.StepDown.Value,
z_finish_step=finish_step,
final_depth=shape.BoundBox.ZMin, # obj.FinalDepth.Value,
user_depths=None)
env = PathUtils.getEnvelope(base.Shape, subshape=shape, depthparams=custDepthparams)
finalDep = shape.BoundBox.ZMin
else:
env = PathUtils.getEnvelope(base.Shape, subshape=shape, depthparams=self.depthparams)
if obj.HandleMultipleFeatures == 'Collectively':
PathLog.track()
try:
env = PathUtils.getEnvelope(base.Shape, subshape=profileshape, depthparams=self.depthparams)
except Exception:
# PathUtils.getEnvelope() failed to return an object.
PathLog.error(translate('Path', 'Unable to create path for face(s).'))
else:
env = PathUtils.getEnvelope(base.Shape, subshape=shape, depthparams=self.depthparams)
tup = env, False, 'pathProfileFaces', angle, axis, strDep, finalDep
shapes.append(tup)
# Eif
# shapes.append((env, False))
tup = env, False, 'pathProfileFaces', angle, axis, strDep, finDep
shapes.append(tup)
elif obj.HandleMultipleFeatures == 'Individually':
for shape in faces:
finalDep = obj.FinalDepth.Value
custDepthparams = self.depthparams
if obj.Side == 'Inside':
if finalDep < shape.BoundBox.ZMin:
# Recalculate depthparams
finalDep = shape.BoundBox.ZMin
custDepthparams = PathUtils.depth_params(
clearance_height=obj.ClearanceHeight.Value,
safe_height=obj.SafeHeight.Value,
start_depth=strDep, # obj.StartDepth.Value,
step_down=obj.StepDown.Value,
z_finish_step=finish_step,
final_depth=finalDep, # obj.FinalDepth.Value,
user_depths=None)
env = PathUtils.getEnvelope(base.Shape, subshape=shape, depthparams=custDepthparams)
tup = env, False, 'pathProfileFaces', angle, axis, strDep, finalDep
shapes.append(tup)
# adjust Start/Final Depths as needed
# Raise existing Final Depth to level of lowest profile face
if obj.Side == 'Inside':
finalDepth = min(finalDepths)
if obj.FinalDepth.Value < finalDepth:
obj.FinalDepth.Value = finalDepth
# Lower high Start Depth to top of Stock
startDepth = max(startDepths)
if obj.StartDepth.Value > startDepth:
@@ -324,9 +312,7 @@ class ObjectProfile(PathProfileBase.ObjectProfile):
obj.InverseAngle = False
obj.AttemptInverseAngle = True
obj.B_AxisErrorOverride = False
# def checkDepths(self, obj, shape):
# return (strDept, finDep)
obj.HandleMultipleFeatures = 'Collectively'
def SetupProperties():
@@ -338,6 +324,7 @@ def SetupProperties():
setup.append("InverseAngle")
setup.append("B_AxisErrorOverride")
setup.append("AttemptInverseAngle")
setup.append("HandleMultipleFeatures")
return setup