FEM: separate selection observer class from _TaskPanel shellthickness and beamsection
This commit is contained in:
parent
dc20525edc
commit
ba394818a3
|
@ -103,6 +103,7 @@ SET(FemScripts_SRCS
|
|||
FemTools.py
|
||||
MechanicalAnalysis.py
|
||||
MechanicalMaterial.py
|
||||
SelectionObserverFem.py
|
||||
TestFem.py
|
||||
|
||||
TaskPanelFemBeamSection.ui
|
||||
|
|
|
@ -14,6 +14,7 @@ INSTALL(
|
|||
convert2TetGen.py
|
||||
FemExample.py
|
||||
|
||||
SelectionObserverFem.py
|
||||
TestFem.py
|
||||
|
||||
ccxDatReader.py
|
||||
|
|
44
src/Mod/Fem/SelectionObserverFem.py
Normal file
44
src/Mod/Fem/SelectionObserverFem.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
# ***************************************************************************
|
||||
# * *
|
||||
# * Copyright (c) 2015 - Bernd Hahnebach <bernd@bimstatik.org> *
|
||||
# * *
|
||||
# * 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__ = "SelectionObserverFem"
|
||||
__author__ = "Bernd Hahnebach"
|
||||
__url__ = "http://www.freecadweb.org"
|
||||
|
||||
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
|
||||
|
||||
class SelectionObserverFem:
|
||||
'''SelectionObserverFem'''
|
||||
def __init__(self, parseSelectionFunction, print_message=''):
|
||||
self.parseSelectionFunction = parseSelectionFunction
|
||||
FreeCADGui.Selection.addObserver(self)
|
||||
FreeCAD.Console.PrintMessage(print_message + "!\n")
|
||||
|
||||
def addSelection(self, docName, objName, sub, pos):
|
||||
selected_object = FreeCAD.getDocument(docName).getObject(objName) # get the obj objName
|
||||
self.added_obj = (selected_object, sub)
|
||||
|
||||
if sub: # on doubleClick the solid is selected and sub will be empty
|
||||
self.parseSelectionFunction(self.added_obj)
|
|
@ -86,7 +86,9 @@ class _TaskPanelFemBeamSection:
|
|||
# here the addReference button EditTaskPanel has to be triggered to start selection mode
|
||||
FreeCADGui.Selection.clearSelection()
|
||||
# start SelectionObserver and parse the function to add the References to the widget
|
||||
self.sel_server = ReferenceShapeSelectionObserver(self.selectionParser)
|
||||
print_message = "Select Edges by single click on them to add them to the list"
|
||||
import SelectionObserverFem
|
||||
self.sel_server = SelectionObserverFem.SelectionObserverFem(self.selectionParser, print_message)
|
||||
|
||||
def selectionParser(self, selection):
|
||||
# print('selection: ', selection[0].Shape.ShapeType, ' ', selection[0].Name, ' ', selection[1])
|
||||
|
@ -109,18 +111,3 @@ class _TaskPanelFemBeamSection:
|
|||
items.append(item_name)
|
||||
for listItemName in sorted(items):
|
||||
self.form.list_References.addItem(listItemName)
|
||||
|
||||
|
||||
class ReferenceShapeSelectionObserver:
|
||||
'''ReferenceShapeSelectionObserver
|
||||
started on click button addReference'''
|
||||
def __init__(self, parseSelectionFunction):
|
||||
self.parseSelectionFunction = parseSelectionFunction
|
||||
FreeCADGui.Selection.addObserver(self)
|
||||
FreeCAD.Console.PrintMessage("Select Faces to add them to the list!\n")
|
||||
|
||||
def addSelection(self, docName, objName, sub, pos):
|
||||
selected_object = FreeCAD.getDocument(docName).getObject(objName) # get the obj objName
|
||||
self.added_obj = (selected_object, sub)
|
||||
if sub: # on doubleClick the solid is selected and sub will be empty
|
||||
self.parseSelectionFunction(self.added_obj)
|
||||
|
|
|
@ -86,7 +86,9 @@ class _TaskPanelFemShellThickness:
|
|||
# here the addReference button EditTaskPanel has to be triggered to start selection mode
|
||||
FreeCADGui.Selection.clearSelection()
|
||||
# start SelectionObserver and parse the function to add the References to the widget
|
||||
self.sel_server = ReferenceShapeSelectionObserver(self.selectionParser)
|
||||
print_message = "Select Faces by single click on them to add them to the list"
|
||||
import SelectionObserverFem
|
||||
self.sel_server = SelectionObserverFem.SelectionObserverFem(self.selectionParser, print_message)
|
||||
|
||||
def selectionParser(self, selection):
|
||||
# print('selection: ', selection[0].Shape.ShapeType, ' ', selection[0].Name, ' ', selection[1])
|
||||
|
@ -109,18 +111,3 @@ class _TaskPanelFemShellThickness:
|
|||
items.append(item_name)
|
||||
for listItemName in sorted(items):
|
||||
self.form.list_References.addItem(listItemName)
|
||||
|
||||
|
||||
class ReferenceShapeSelectionObserver:
|
||||
'''ReferenceShapeSelectionObserver
|
||||
started on click button addReference'''
|
||||
def __init__(self, parseSelectionFunction):
|
||||
self.parseSelectionFunction = parseSelectionFunction
|
||||
FreeCADGui.Selection.addObserver(self)
|
||||
FreeCAD.Console.PrintMessage("Select Faces to add them to the list!\n")
|
||||
|
||||
def addSelection(self, docName, objName, sub, pos):
|
||||
selected_object = FreeCAD.getDocument(docName).getObject(objName) # get the obj objName
|
||||
self.added_obj = (selected_object, sub)
|
||||
if sub: # on doubleClick the solid is selected and sub will be empty
|
||||
self.parseSelectionFunction(self.added_obj)
|
||||
|
|
Loading…
Reference in New Issue
Block a user