FEM: constraint centrif, Gui tools

This commit is contained in:
UR-0
2021-06-23 07:56:22 +02:00
committed by Bernd Hahnebach
parent f0b543ed81
commit 46282db7c8
9 changed files with 411 additions and 1 deletions

View File

@@ -461,6 +461,7 @@ SET(FemGuiObjects_SRCS
SET(FemGuiTaskPanels_SRCS
femtaskpanels/__init__.py
femtaskpanels/task_constraint_centrif.py
femtaskpanels/task_constraint_electrostaticpotential.py
femtaskpanels/task_constraint_flowvelocity.py
femtaskpanels/task_constraint_initialflowvelocity.py

View File

@@ -365,6 +365,7 @@ INSTALL(FILES ${FemGuiIcon_SVG} DESTINATION "${CMAKE_INSTALL_DATADIR}/Mod/Fem/Re
# Python modules ui files, they are copied as they are, thus the need not to be added to Fem.qrc
# see https://forum.freecadweb.org/viewtopic.php?f=10&t=25833
SET(FemGuiPythonUI_SRCS
Resources/ui/ConstraintCentrif.ui
Resources/ui/ConstraintTie.ui
Resources/ui/ConstraintSectionPrint.ui
Resources/ui/ElectrostaticPotential.ui

View File

@@ -10,6 +10,7 @@
<!-- gui command icons: constraints -->
<file>icons/FEM_ConstraintBearing.svg</file>
<file>icons/FEM_ConstraintCentrif.svg</file>
<file>icons/FEM_ConstraintContact.svg</file>
<file>icons/FEM_ConstraintDisplacement.svg</file>
<file>icons/FEM_ConstraintElectrostaticPotential.svg</file>
@@ -142,6 +143,7 @@
<file>translations/Fem_zh-TW.qm</file>
<!-- task panels -->
<file>ui/ConstraintCentrif.ui</file>
<file>ui/ConstraintSectionPrint.ui</file>
<file>ui/ConstraintTie.ui</file>
<file>ui/ElectrostaticPotential.ui</file>

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="64px" height="64px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<defs>
<linearGradient id="linearGradient3367" x1="-11" x2="-18" y1="26" y2="14" gradientTransform="translate(-20 -6)" gradientUnits="userSpaceOnUse" spreadMethod="reflect">
<stop stop-color="#c4a000" offset="0"/>
<stop stop-color="#fce94f" offset="1"/>
</linearGradient>
<linearGradient id="linearGradient3369" x1="32.558" x2="26.302" y1="32.918" y2="12.207" gradientTransform="translate(10.413 -18.142)" gradientUnits="userSpaceOnUse">
<stop stop-color="#edd400" offset="0"/>
<stop stop-color="#fce94f" offset="1"/>
</linearGradient>
</defs>
<metadata>
<rdf:RDF>
<cc:Work rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
<dc:creator>
<cc:Agent>
<dc:title>[Przemo Firszt]</dc:title>
</cc:Agent>
</dc:creator>
<dc:date>2015-07-28</dc:date>
<dc:relation>http://www.freecadweb.org/wiki/index.php?title=Artwork</dc:relation>
<dc:publisher>
<cc:Agent>
<dc:title>FreeCAD</dc:title>
</cc:Agent>
</dc:publisher>
<dc:identifier>FreeCAD/src/Mod/</dc:identifier>
<dc:rights>
<cc:Agent>
<dc:title>FreeCAD LGPL2+</dc:title>
</cc:Agent>
</dc:rights>
<cc:license>https://www.gnu.org/copyleft/lesser.html</cc:license>
<dc:contributor>
<cc:Agent>
<dc:title>[agryson] Alexander Gryson</dc:title>
</cc:Agent>
</dc:contributor>
</cc:Work>
</rdf:RDF>
</metadata>
<g transform="translate(87.958,2.1036)">
<g stroke-width="2">
<path d="m-69.198 25.198 16.221-10.644c11.343-4.6433 24.729 13.209 12.401 22.256l-15.696 9.8408z" color="#000000" fill="#edd400" stroke="#302b00" stroke-linejoin="round"/>
<path d="m-70.279 28.105 15.947-10.448c10.365-7.6968 23.946 10.626 12.01 17.872l-15.696 9.8408z" color="#000000" fill="url(#linearGradient3367)" stroke="#fce94f" stroke-linejoin="round"/>
<g fill="none" stroke="#302b00">
<path d="m-59.9 18.9c12-1 18.571 11 14.571 21" color="#000000"/>
<path d="m-60.7 25.9 17-11" color="#000000"/>
<path d="m-52.7 34.9 17-11" color="#000000"/>
</g>
</g>
<g transform="matrix(.92148 .21648 -.046568 .97753 -75.828 17.995)" color="#000000" stroke-linecap="round" stroke-linejoin="round">
<path transform="translate(-17,-7)" d="m44 22c0 6.6274-5.3726 12-12 12s-12-5.3726-12-12 5.3726-12 12-12 12 5.3726 12 12z" fill="#ef2929" stroke="#000" stroke-width="2.0956"/>
<path transform="matrix(.83333 0 0 .83333 -11.667 -3.3333)" d="m44 22c0 6.6274-5.3726 12-12 12s-12-5.3726-12-12 5.3726-12 12-12 12 5.3726 12 12z" fill="url(#linearGradient3369)" stroke="#fae94f" stroke-width="2.5147"/>
</g>
<g fill="none">
<g transform="matrix(.92148 .21648 -.046568 .97753 -75.896 17.973)" color="#000000">
<path transform="translate(-17,-7)" d="m44 22c0 6.6274-5.3726 12-12 12s-12-5.3726-12-12 5.3726-12 12-12 12 5.3726 12 12z" stroke-width=".9996"/>
<path transform="matrix(.83333 0 0 .83333 -11.667 -3.3333)" d="m44 22c0 6.6274-5.3726 12-12 12s-12-5.3726-12-12 5.3726-12 12-12 12 5.3726 12 12z" stroke-width="1.1995"/>
</g>
<g stroke="#000" stroke-width="2">
<path d="m-59.7 24.9v23" color="#000000"/>
<path d="m-66.7 24.9v21" color="#000000"/>
<path d="m-72.7 28.9 21 7" color="#000000"/>
<path d="m-73.7 35.9 21 7" color="#000000"/>
</g>
<g fill="none" stroke-linecap="round">
<path transform="matrix(.95301 -.17255 .047914 .55781 -76.601 7.3128)" d="m13.709 3.3757 10.341 5.7409-10.142 6.0855-0.09947-5.9132z" stroke="#000" stroke-width="9.5266"/>
<path transform="matrix(.95301 -.17255 .047914 .55781 -76.601 7.3128)" d="m13.709 3.3757 10.341 5.7409-10.142 6.0855-0.09947-5.9132z" fill="#f00" stroke="#fe0000" stroke-width="5.4423"/>
<path d="m-46.738 53.734s-6.79 5.0646-13.023 4.9716c-10.517-0.157-20.194-8.7834-23.485-18.773-2.5664-7.7898 0.33383-18.519 6.7154-23.671 4.9087-3.9629 9.4238-4.8603 9.4238-4.8603" fill="none" stroke="#000" stroke-linecap="round" stroke-width="6.9997"/>
<path d="m-46.738 53.734s-6.79 5.0646-13.023 4.9716c-10.517-0.157-20.194-8.7834-23.485-18.773-2.5664-7.7898 0.33383-18.519 6.7154-23.671 4.9087-3.9629 9.4238-4.8603 9.4238-4.8603" fill="none" stroke="#f00" stroke-linecap="round" stroke-width="3.9987"/>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -0,0 +1,131 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>500</height>
</rect>
</property>
<property name="windowTitle">
<string>Centrif parameter</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>1677215</height>
</size>
</property>
<property name="title">
<string>Parameter</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="horizontalSpacing">
<number>4</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="l_rotation_frequency">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Rotation frequency f&lt;sub&gt;rot&lt;/sub&gt; [rps]</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="indent">
<number>-1</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::InputField" name="if_rotation_frequency">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>revolutions per second</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>0.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="singleStep" stdset="0">
<double>1.000000000000000</double>
</property>
<property name="maximum" stdset="0">
<double>1000000000.000000000000000</double>
</property>
<property name="unit" stdset="0">
<string>1/s</string>
</property>
<property name="decimals" stdset="0">
<number>2</number>
</property>
<property name="value" stdset="0">
<double>0.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::InputField</class>
<extends>QLineEdit</extends>
<header>Gui/InputField.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -142,6 +142,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
<< "Separator"
<< "FEM_ConstraintForce"
<< "FEM_ConstraintPressure"
<< "FEM_ConstraintCentrif"
<< "FEM_ConstraintSelfWeight";
Gui::ToolBarItem* thermal = new Gui::ToolBarItem(root);
@@ -268,6 +269,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
<< "Separator"
<< "FEM_ConstraintForce"
<< "FEM_ConstraintPressure"
<< "FEM_ConstraintCentrif"
<< "FEM_ConstraintSelfWeight";
Gui::MenuItem* thermal = new Gui::MenuItem;

View File

@@ -162,6 +162,17 @@ class _ConstraintBodyHeatSource(CommandManager):
self.do_activated = "add_obj_on_gui_noset_edit"
class _ConstraintCentrif(CommandManager):
"The FEM_ConstraintCentrif command definition"
def __init__(self):
super(_ConstraintCentrif, self).__init__()
self.menuetext = "Constraint centrif"
self.tooltip = "Creates a FEM constraint centrif"
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_set_edit"
class _ConstraintElectrostaticPotential(CommandManager):
"The FEM_ConstraintElectrostaticPotential command definition"
@@ -815,6 +826,10 @@ FreeCADGui.addCommand(
"FEM_ConstraintBodyHeatSource",
_ConstraintBodyHeatSource()
)
FreeCADGui.addCommand(
"FEM_ConstraintCentrif",
_ConstraintCentrif()
)
FreeCADGui.addCommand(
"FEM_ConstraintElectrostaticPotential",
_ConstraintElectrostaticPotential()

View File

@@ -0,0 +1,173 @@
# ***************************************************************************
# * Copyright (c) 2020 Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program 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 Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
__title__ = "FreeCAD FEM constraint centrif task panel for the document object"
__author__ = "Bernd Hahnebach"
__url__ = "https://www.freecadweb.org"
## @package task_constraint_centrif
# \ingroup FEM
# \brief task panel for constraint centrif object
from PySide import QtCore
from PySide import QtGui
import FreeCAD
import FreeCADGui
from femguiutils import selection_widgets
class _TaskPanel:
"""
The TaskPanel for editing References property of FemConstraintCentrif objects
"""
def __init__(self, obj):
self.obj = obj
# parameter widget
self.parameterWidget = FreeCADGui.PySideUic.loadUi(
FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/ConstraintCentrif.ui"
)
QtCore.QObject.connect(
self.parameterWidget.if_rotation_frequency,
QtCore.SIGNAL("valueChanged(Base::Quantity)"),
self.rotation_frequency_changed
)
self.init_parameter_widget()
# axis of rotation selection widget
self.AxisSelectionWidget = selection_widgets.GeometryElementsSelection(
obj.RotationAxis,
["Edge"],
False,
False
)
# loaded body selection widget
self.BodySelectionWidget = selection_widgets.GeometryElementsSelection(
obj.References,
["Solid"],
False,
False
)
# form made from param and selection widget
self.form = [self.parameterWidget, self.BodySelectionWidget, self.AxisSelectionWidget]
def accept(self):
# check values RotationAxis
items = len(self.AxisSelectionWidget.references)
FreeCAD.Console.PrintMessage(
"Task panel: found axis references: {}\n{}\n"
.format(items, self.AxisSelectionWidget.references)
)
if items != 1:
msgBox = QtGui.QMessageBox()
msgBox.setIcon(QtGui.QMessageBox.Question)
msgBox.setText(
"Constraint Centrif requires exactly one line\n\nfound references: {}"
.format(items)
)
msgBox.setWindowTitle("FreeCAD FEM Constraint Centrif - Axis selection")
retryButton = msgBox.addButton(QtGui.QMessageBox.Retry)
ignoreButton = msgBox.addButton(QtGui.QMessageBox.Ignore)
msgBox.exec_()
if msgBox.clickedButton() == retryButton:
return False
elif msgBox.clickedButton() == ignoreButton:
pass
# check values BodyReference
items = len(self.BodySelectionWidget.references)
FreeCAD.Console.PrintMessage(
"Task panel: found body references: {}\n{}\n"
.format(items, self.BodySelectionWidget.references)
)
# if no solid is added as reference all volume elements are used
"""
if items == 0:
msgBox = QtGui.QMessageBox()
msgBox.setIcon(QtGui.QMessageBox.Question)
msgBox.setText("Constraint Centrif requires at least one solid")
msgBox.setWindowTitle("FreeCAD FEM Constraint Centrif - Body selection")
retryButton = msgBox.addButton(QtGui.QMessageBox.Retry)
ignoreButton = msgBox.addButton(QtGui.QMessageBox.Ignore)
msgBox.exec_()
if msgBox.clickedButton() == retryButton:
return False
elif msgBox.clickedButton() == ignoreButton:
pass
"""
# check value RotationFrequency
if self.rotation_frequency == 0:
msgBox = QtGui.QMessageBox()
msgBox.setIcon(QtGui.QMessageBox.Question)
msgBox.setText("Rotational speed is zero")
msgBox.setWindowTitle("FreeCAD FEM Constraint Centrif - Rotational speed setting")
retryButton = msgBox.addButton(QtGui.QMessageBox.Retry)
ignoreButton = msgBox.addButton(QtGui.QMessageBox.Ignore)
msgBox.exec_()
if msgBox.clickedButton() == retryButton:
return False
elif msgBox.clickedButton() == ignoreButton:
pass
self.obj.RotationFrequency = self.rotation_frequency
self.obj.RotationAxis = self.AxisSelectionWidget.references
self.obj.References = self.BodySelectionWidget.references
self.recompute_and_set_back_all()
return True
def reject(self):
self.recompute_and_set_back_all()
return True
def recompute_and_set_back_all(self):
doc = FreeCADGui.getDocument(self.obj.Document)
doc.Document.recompute()
self.AxisSelectionWidget.setback_listobj_visibility()
if self.AxisSelectionWidget.sel_server:
FreeCADGui.Selection.removeObserver(self.AxisSelectionWidget.sel_server)
self.BodySelectionWidget.setback_listobj_visibility()
if self.BodySelectionWidget.sel_server:
FreeCADGui.Selection.removeObserver(self.BodySelectionWidget.sel_server)
doc.resetEdit()
def init_parameter_widget(self):
self.rotation_frequency = self.obj.RotationFrequency
self.parameterWidget.if_rotation_frequency.setText(self.rotation_frequency.UserString)
def rotation_frequency_changed(self, base_quantity_value):
self.rotation_frequency = base_quantity_value

View File

@@ -29,6 +29,7 @@ __url__ = "https://www.freecadweb.org"
# \ingroup FEM
# \brief view provider for constraint centrif object
from femtaskpanels import task_constraint_centrif
from . import view_base_femconstraint
@@ -37,4 +38,10 @@ class VPConstraintCentrif(view_base_femconstraint.VPBaseFemConstraint):
A View Provider for the ConstraintCentrif object
"""
pass
def setEdit(self, vobj, mode=0):
view_base_femconstraint.VPBaseFemConstraint.setEdit(
self,
vobj,
mode,
task_constraint_centrif._TaskPanel
)