FEM: Python constraints, do not open a new constraint if another task panel is open
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
# * Copyright (c) 2017 - Markus Hovorka <m.hovorka@live.de> *
|
||||
# * Copyright (c) 2018 - 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) *
|
||||
@@ -22,7 +23,7 @@
|
||||
|
||||
|
||||
__title__ = "_Base ViewProvider"
|
||||
__author__ = "Markus Hovorka"
|
||||
__author__ = "Markus Hovorka, Bernd Hahnebach"
|
||||
__url__ = "http://www.freecadweb.org"
|
||||
|
||||
|
||||
@@ -58,10 +59,13 @@ class ViewProxy(object):
|
||||
return False
|
||||
|
||||
def doubleClicked(self, vobj):
|
||||
doc = FreeCADGui.getDocument(vobj.Object.Document)
|
||||
guidoc = FreeCADGui.getDocument(vobj.Object.Document)
|
||||
# check if another VP is in edit mode, https://forum.freecadweb.org/viewtopic.php?t=13077#p104702
|
||||
if not doc.getInEdit():
|
||||
doc.setEdit(vobj.Object.Name)
|
||||
if not guidoc.getInEdit():
|
||||
guidoc.setEdit(vobj.Object.Name)
|
||||
else:
|
||||
FreeCAD.Console.PrintError('Active Task Dialog found! Please close this one first!\n')
|
||||
from PySide.QtGui import QMessageBox
|
||||
message = 'Active Task Dialog found! Please close this one before open a new one!'
|
||||
QMessageBox.critical(None, "Error in tree view", message)
|
||||
FreeCAD.Console.PrintError(message + '\n')
|
||||
return True
|
||||
|
||||
@@ -27,11 +27,12 @@ __url__ = "http://www.freecadweb.org"
|
||||
|
||||
|
||||
import FreeCAD
|
||||
import femtools.femutils as FemUtils
|
||||
import FreeCADGui
|
||||
from . import ViewProviderFemConstraint
|
||||
from FreeCAD import Units
|
||||
|
||||
import FreeCADGui as Gui
|
||||
# for the panel
|
||||
import femtools.femutils as FemUtils
|
||||
from FreeCAD import Units
|
||||
from . import FemSelectionWidgets
|
||||
|
||||
|
||||
@@ -47,16 +48,12 @@ class ViewProxy(ViewProviderFemConstraint.ViewProxy):
|
||||
o.ViewObject.hide()
|
||||
# show task panel
|
||||
task = _TaskPanel(vobj.Object)
|
||||
Gui.Control.showDialog(task)
|
||||
FreeCADGui.Control.showDialog(task)
|
||||
return True
|
||||
|
||||
def unsetEdit(self, vobj, mode=0):
|
||||
Gui.Control.closeDialog()
|
||||
|
||||
def doubleClicked(self, vobj):
|
||||
if Gui.Control.activeDialog():
|
||||
Gui.Control.closeDialog()
|
||||
Gui.ActiveDocument.setEdit(vobj.Object.Name)
|
||||
return True
|
||||
FreeCADGui.Control.closeDialog()
|
||||
return
|
||||
|
||||
|
||||
class _TaskPanel(object):
|
||||
@@ -65,7 +62,7 @@ class _TaskPanel(object):
|
||||
self._obj = obj
|
||||
self._refWidget = FemSelectionWidgets.BoundarySelector()
|
||||
self._refWidget.setReferences(obj.References)
|
||||
self._paramWidget = Gui.PySideUic.loadUi(
|
||||
self._paramWidget = FreeCADGui.PySideUic.loadUi(
|
||||
FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/ElectrostaticPotential.ui")
|
||||
self._initParamWidget()
|
||||
self.form = [self._refWidget, self._paramWidget]
|
||||
@@ -84,6 +81,7 @@ class _TaskPanel(object):
|
||||
|
||||
def reject(self):
|
||||
self._restoreVisibility()
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
return True
|
||||
|
||||
def accept(self):
|
||||
@@ -91,6 +89,7 @@ class _TaskPanel(object):
|
||||
self._obj.References = self._refWidget.references()
|
||||
self._applyWidgetChanges()
|
||||
self._obj.Document.recompute()
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
self._restoreVisibility()
|
||||
return True
|
||||
|
||||
|
||||
@@ -27,11 +27,12 @@ __url__ = "http://www.freecadweb.org"
|
||||
|
||||
|
||||
import FreeCAD
|
||||
import femtools.femutils as FemUtils
|
||||
import FreeCADGui
|
||||
from . import ViewProviderFemConstraint
|
||||
from FreeCAD import Units
|
||||
|
||||
import FreeCADGui as Gui
|
||||
# for the panel
|
||||
import femtools.femutils as FemUtils
|
||||
from FreeCAD import Units
|
||||
from . import FemSelectionWidgets
|
||||
|
||||
|
||||
@@ -47,16 +48,12 @@ class ViewProxy(ViewProviderFemConstraint.ViewProxy):
|
||||
o.ViewObject.hide()
|
||||
# show task panel
|
||||
task = _TaskPanel(vobj.Object)
|
||||
Gui.Control.showDialog(task)
|
||||
FreeCADGui.Control.showDialog(task)
|
||||
return True
|
||||
|
||||
def unsetEdit(self, vobj, mode=0):
|
||||
Gui.Control.closeDialog()
|
||||
|
||||
def doubleClicked(self, vobj):
|
||||
if Gui.Control.activeDialog():
|
||||
Gui.Control.closeDialog()
|
||||
Gui.ActiveDocument.setEdit(vobj.Object.Name)
|
||||
return True
|
||||
FreeCADGui.Control.closeDialog()
|
||||
return
|
||||
|
||||
|
||||
class _TaskPanel(object):
|
||||
@@ -65,7 +62,7 @@ class _TaskPanel(object):
|
||||
self._obj = obj
|
||||
self._refWidget = FemSelectionWidgets.BoundarySelector()
|
||||
self._refWidget.setReferences(obj.References)
|
||||
self._paramWidget = Gui.PySideUic.loadUi(
|
||||
self._paramWidget = FreeCADGui.PySideUic.loadUi(
|
||||
FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/FlowVelocity.ui")
|
||||
self._initParamWidget()
|
||||
self.form = [self._refWidget, self._paramWidget]
|
||||
@@ -87,6 +84,8 @@ class _TaskPanel(object):
|
||||
self._part.ViewObject.show()
|
||||
|
||||
def reject(self):
|
||||
# self._obj.ViewObject.finishEditing()
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
self._restoreVisibility()
|
||||
return True
|
||||
|
||||
@@ -95,6 +94,8 @@ class _TaskPanel(object):
|
||||
self._obj.References = self._refWidget.references()
|
||||
self._applyWidgetChanges()
|
||||
self._obj.Document.recompute()
|
||||
# self._obj.ViewObject.finishEditing()
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
self._restoreVisibility()
|
||||
return True
|
||||
|
||||
|
||||
@@ -27,11 +27,12 @@ __url__ = "http://www.freecadweb.org"
|
||||
|
||||
|
||||
import FreeCAD
|
||||
import femtools.femutils as FemUtils
|
||||
import FreeCADGui
|
||||
from . import ViewProviderFemConstraint
|
||||
from FreeCAD import Units
|
||||
|
||||
import FreeCADGui as Gui
|
||||
# for the panel
|
||||
import femtools.femutils as FemUtils
|
||||
from FreeCAD import Units
|
||||
|
||||
|
||||
class ViewProxy(ViewProviderFemConstraint.ViewProxy):
|
||||
@@ -46,23 +47,19 @@ class ViewProxy(ViewProviderFemConstraint.ViewProxy):
|
||||
o.ViewObject.hide()
|
||||
# show task panel
|
||||
task = _TaskPanel(vobj.Object)
|
||||
Gui.Control.showDialog(task)
|
||||
FreeCADGui.Control.showDialog(task)
|
||||
return True
|
||||
|
||||
def unsetEdit(self, vobj, mode=0):
|
||||
Gui.Control.closeDialog()
|
||||
|
||||
def doubleClicked(self, vobj):
|
||||
if Gui.Control.activeDialog():
|
||||
Gui.Control.closeDialog()
|
||||
Gui.ActiveDocument.setEdit(vobj.Object.Name)
|
||||
return True
|
||||
FreeCADGui.Control.closeDialog()
|
||||
return
|
||||
|
||||
|
||||
class _TaskPanel(object):
|
||||
|
||||
def __init__(self, obj):
|
||||
self._obj = obj
|
||||
self._paramWidget = Gui.PySideUic.loadUi(
|
||||
self._paramWidget = FreeCADGui.PySideUic.loadUi(
|
||||
FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/InitialFlowVelocity.ui")
|
||||
self._initParamWidget()
|
||||
self.form = [self._paramWidget]
|
||||
@@ -80,12 +77,14 @@ class _TaskPanel(object):
|
||||
self._part.ViewObject.show()
|
||||
|
||||
def reject(self):
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
self._restoreVisibility()
|
||||
return True
|
||||
|
||||
def accept(self):
|
||||
self._applyWidgetChanges()
|
||||
self._obj.Document.recompute()
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
self._restoreVisibility()
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user