Merge pull request #8122 from Roy-043/Arch-improve-context-menus
Arch: improve context menus
This commit is contained in:
@@ -271,7 +271,7 @@ class _ViewProviderAxis:
|
||||
return []
|
||||
|
||||
def attach(self, vobj):
|
||||
|
||||
self.Object = vobj.Object
|
||||
self.bubbles = None
|
||||
self.bubbletexts = []
|
||||
self.bubbledata = []
|
||||
@@ -610,7 +610,9 @@ class _ViewProviderAxis:
|
||||
|
||||
return self.bubbledata
|
||||
|
||||
def setEdit(self,vobj,mode=0):
|
||||
def setEdit(self, vobj, mode):
|
||||
if mode == 1 or mode == 2:
|
||||
return None
|
||||
|
||||
taskd = _AxisTaskPanel()
|
||||
taskd.obj = vobj.Object
|
||||
@@ -618,14 +620,40 @@ class _ViewProviderAxis:
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
def unsetEdit(self,vobj,mode):
|
||||
def unsetEdit(self, vobj, mode):
|
||||
if mode == 1 or mode == 2:
|
||||
return None
|
||||
|
||||
FreeCADGui.Control.closeDialog()
|
||||
return
|
||||
return True
|
||||
|
||||
def doubleClicked(self,vobj):
|
||||
def setupContextMenu(self, vobj, menu):
|
||||
actionEdit = QtGui.QAction(translate("Arch", "Edit"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionEdit,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.edit)
|
||||
menu.addAction(actionEdit)
|
||||
|
||||
self.setEdit(vobj)
|
||||
# The default Part::FeaturePython context menu contains a `Set colors`
|
||||
# option. This option makes no sense for Axis objects. We therefore
|
||||
# override this menu and have to add our own `Transform` item.
|
||||
# To override the default menu this function must return `True`.
|
||||
action_transform = QtGui.QAction(FreeCADGui.getIcon("Std_TransformManip.svg"),
|
||||
translate("Command", "Transform"), # Context `Command` instead of `Arch`.
|
||||
menu)
|
||||
QtCore.QObject.connect(action_transform,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.transform)
|
||||
menu.addAction(action_transform)
|
||||
|
||||
return True
|
||||
|
||||
def edit(self):
|
||||
FreeCADGui.ActiveDocument.setEdit(self.Object, 0)
|
||||
|
||||
def transform(self):
|
||||
FreeCADGui.ActiveDocument.setEdit(self.Object, 1)
|
||||
|
||||
def __getstate__(self):
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ class _ViewProviderAxisSystem:
|
||||
return []
|
||||
|
||||
def attach(self, vobj):
|
||||
|
||||
self.Object = vobj.Object
|
||||
self.axes = vobj.Object.Axes
|
||||
vobj.addDisplayMode(coin.SoSeparator(),"Default")
|
||||
|
||||
@@ -228,20 +228,34 @@ class _ViewProviderAxisSystem:
|
||||
for o in vobj.Object.Axes:
|
||||
o.ViewObject.Visibility = vobj.Visibility
|
||||
|
||||
def setEdit(self,vobj,mode=0):
|
||||
def setEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
taskd = AxisSystemTaskPanel(vobj.Object)
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
def unsetEdit(self,vobj,mode):
|
||||
def unsetEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
FreeCADGui.Control.closeDialog()
|
||||
return
|
||||
return True
|
||||
|
||||
def doubleClicked(self,vobj):
|
||||
def doubleClicked(self, vobj):
|
||||
self.edit()
|
||||
|
||||
self.setEdit(vobj)
|
||||
def setupContextMenu(self, vobj, menu):
|
||||
actionEdit = QtGui.QAction(translate("Arch", "Edit"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionEdit,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.edit)
|
||||
menu.addAction(actionEdit)
|
||||
|
||||
def edit(self):
|
||||
FreeCADGui.ActiveDocument.setEdit(self.Object, 0)
|
||||
|
||||
def __getstate__(self):
|
||||
|
||||
|
||||
@@ -880,44 +880,89 @@ class ViewProviderBuildingPart:
|
||||
o.ViewObject.Lighting = "Two side"
|
||||
return True
|
||||
|
||||
def doubleClicked(self,vobj):
|
||||
def setEdit(self, vobj, mode):
|
||||
# For some reason mode is always 0.
|
||||
# Using FreeCADGui.getUserEditMode() as a workaound.
|
||||
if FreeCADGui.getUserEditMode() in ("Transform", "Cutting"):
|
||||
return None
|
||||
|
||||
self.activate()
|
||||
return False # Return `False` as we don't want to enter edit mode.
|
||||
|
||||
def unsetEdit(self, vobj, mode):
|
||||
# For some reason mode is always 0.
|
||||
# Using FreeCADGui.getUserEditMode() as a workaound.
|
||||
if FreeCADGui.getUserEditMode() in ("Transform", "Cutting"):
|
||||
return None
|
||||
|
||||
self.activate(vobj)
|
||||
if (not hasattr(vobj,"DoubleClickActivates")) or vobj.DoubleClickActivates:
|
||||
FreeCADGui.Selection.clearSelection()
|
||||
return True
|
||||
|
||||
def activate(self,vobj):
|
||||
def setupContextMenu(self, vobj, menu):
|
||||
from PySide import QtCore, QtGui
|
||||
import Draft_rc
|
||||
|
||||
if FreeCADGui.ActiveDocument.ActiveView.getActiveObject("Arch") == vobj.Object:
|
||||
FreeCADGui.ActiveDocument.ActiveView.setActiveObject("Arch",None)
|
||||
if (not hasattr(vobj,"DoubleClickActivates")) or vobj.DoubleClickActivates:
|
||||
if FreeCADGui.ActiveDocument.ActiveView.getActiveObject("Arch") == self.Object:
|
||||
menuTxt = translate("Arch", "Deactivate")
|
||||
else:
|
||||
menuTxt = translate("Arch", "Activate")
|
||||
actionActivate = QtGui.QAction(menuTxt,
|
||||
menu)
|
||||
QtCore.QObject.connect(actionActivate,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.activate)
|
||||
menu.addAction(actionActivate)
|
||||
|
||||
actionSetWorkingPlane = QtGui.QAction(QtGui.QIcon(":/icons/Draft_SelectPlane.svg"),
|
||||
translate("Arch", "Set working plane"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionSetWorkingPlane,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.setWorkingPlane)
|
||||
menu.addAction(actionSetWorkingPlane)
|
||||
|
||||
actionWriteCamera = QtGui.QAction(QtGui.QIcon(":/icons/Draft_SelectPlane.svg"),
|
||||
translate("Arch", "Write camera position"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionWriteCamera,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.writeCamera)
|
||||
menu.addAction(actionWriteCamera)
|
||||
|
||||
actionCreateGroup = QtGui.QAction(translate("Arch", "Create group..."),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionCreateGroup,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.createGroup)
|
||||
menu.addAction(actionCreateGroup)
|
||||
|
||||
actionReorder = QtGui.QAction(translate("Arch", "Reorder children alphabetically"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionReorder,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.reorder)
|
||||
menu.addAction(actionReorder)
|
||||
|
||||
actionCloneUp = QtGui.QAction(translate("Arch", "Clone level up"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionCloneUp,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.cloneUp)
|
||||
menu.addAction(actionCloneUp)
|
||||
|
||||
def activate(self):
|
||||
vobj = self.Object.ViewObject
|
||||
|
||||
if FreeCADGui.ActiveDocument.ActiveView.getActiveObject("Arch") == self.Object:
|
||||
FreeCADGui.ActiveDocument.ActiveView.setActiveObject("Arch", None)
|
||||
if vobj.SetWorkingPlane:
|
||||
self.setWorkingPlane(restore=True)
|
||||
else:
|
||||
if (not hasattr(vobj,"DoubleClickActivates")) or vobj.DoubleClickActivates:
|
||||
FreeCADGui.ActiveDocument.ActiveView.setActiveObject("Arch",vobj.Object)
|
||||
elif (not hasattr(vobj,"DoubleClickActivates")) or vobj.DoubleClickActivates:
|
||||
FreeCADGui.ActiveDocument.ActiveView.setActiveObject("Arch", self.Object)
|
||||
if vobj.SetWorkingPlane:
|
||||
self.setWorkingPlane()
|
||||
|
||||
def setupContextMenu(self,vobj,menu):
|
||||
|
||||
from PySide import QtCore,QtGui
|
||||
import Draft_rc
|
||||
action1 = QtGui.QAction(QtGui.QIcon(":/icons/Draft_SelectPlane.svg"),"Set working plane",menu)
|
||||
QtCore.QObject.connect(action1,QtCore.SIGNAL("triggered()"),self.setWorkingPlane)
|
||||
menu.addAction(action1)
|
||||
action2 = QtGui.QAction(QtGui.QIcon(":/icons/Draft_SelectPlane.svg"),"Write camera position",menu)
|
||||
QtCore.QObject.connect(action2,QtCore.SIGNAL("triggered()"),self.writeCamera)
|
||||
menu.addAction(action2)
|
||||
action3 = QtGui.QAction(QtGui.QIcon(),"Create group...",menu)
|
||||
QtCore.QObject.connect(action3,QtCore.SIGNAL("triggered()"),self.createGroup)
|
||||
menu.addAction(action3)
|
||||
action4 = QtGui.QAction(QtGui.QIcon(),"Reorder children alphabetically",menu)
|
||||
QtCore.QObject.connect(action4,QtCore.SIGNAL("triggered()"),self.reorder)
|
||||
menu.addAction(action4)
|
||||
action5 = QtGui.QAction(QtGui.QIcon(),"Clone level up",menu)
|
||||
QtCore.QObject.connect(action5,QtCore.SIGNAL("triggered()"),self.cloneUp)
|
||||
menu.addAction(action5)
|
||||
FreeCADGui.Selection.clearSelection()
|
||||
|
||||
def setWorkingPlane(self,restore=False):
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ def addComponents(objectsList,host):
|
||||
if hostType in ["Floor","Building","Site","Project","BuildingPart"]:
|
||||
for o in objectsList:
|
||||
host.addObject(o)
|
||||
elif hostType in ["Wall","Structure","Window","Roof","Stairs","StructuralSystem","Panel","Component"]:
|
||||
elif hostType in ["Wall","Structure","Precast","Window","Roof","Stairs","StructuralSystem","Panel","Component"]:
|
||||
import DraftGeomUtils
|
||||
a = host.Additions
|
||||
if hasattr(host,"Axes"):
|
||||
@@ -111,7 +111,7 @@ def addComponents(objectsList,host):
|
||||
g = o.Hosts
|
||||
g.append(host)
|
||||
o.Hosts = g
|
||||
elif DraftGeomUtils.isValidPath(o.Shape) and (hostType == "Structure"):
|
||||
elif DraftGeomUtils.isValidPath(o.Shape) and (hostType in ["Structure","Precast"]):
|
||||
if o.Support == host:
|
||||
o.Support = None
|
||||
host.Tool = o
|
||||
@@ -142,7 +142,7 @@ def removeComponents(objectsList,host=None):
|
||||
if not isinstance(objectsList,list):
|
||||
objectsList = [objectsList]
|
||||
if host:
|
||||
if Draft.getType(host) in ["Wall","Structure","Window","Roof","Stairs","StructuralSystem","Panel","Component"]:
|
||||
if Draft.getType(host) in ["Wall","Structure","Precast","Window","Roof","Stairs","StructuralSystem","Panel","Component"]:
|
||||
if hasattr(host,"Tool"):
|
||||
if objectsList[0] == host.Tool:
|
||||
host.Tool = None
|
||||
@@ -183,7 +183,7 @@ def removeComponents(objectsList,host=None):
|
||||
c.remove(o)
|
||||
h.Group = c
|
||||
o.ViewObject.show()
|
||||
elif tp in ["Wall","Structure"]:
|
||||
elif tp in ["Wall","Structure","Precast"]:
|
||||
a = h.Additions
|
||||
s = h.Subtractions
|
||||
if o in a:
|
||||
|
||||
@@ -1449,54 +1449,29 @@ class ViewProviderComponent:
|
||||
return c
|
||||
return []
|
||||
|
||||
def setEdit(self,vobj,mode):
|
||||
"""Method called when the document requests the object to enter edit mode.
|
||||
def setEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
Edit mode is entered when a user double clicks on an object in the tree
|
||||
view, or when they use the menu option [Edit -> Toggle Edit Mode].
|
||||
taskd = ComponentTaskPanel()
|
||||
taskd.obj = self.Object
|
||||
taskd.update()
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
Parameters
|
||||
----------
|
||||
vobj: <Gui.ViewProviderDocumentObject>
|
||||
The component's view provider object.
|
||||
mode: int or str
|
||||
The edit mode the document has requested. Set to 0 when requested via
|
||||
a double click or [Edit -> Toggle Edit Mode].
|
||||
|
||||
Returns
|
||||
-------
|
||||
bool
|
||||
If edit mode was entered.
|
||||
"""
|
||||
|
||||
if mode == 0:
|
||||
taskd = ComponentTaskPanel()
|
||||
taskd.obj = self.Object
|
||||
taskd.update()
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
return False
|
||||
|
||||
def unsetEdit(self,vobj,mode):
|
||||
"""Method called when the document requests the object exit edit mode.
|
||||
|
||||
Returns
|
||||
-------
|
||||
False
|
||||
"""
|
||||
def unsetEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
FreeCADGui.Control.closeDialog()
|
||||
return False
|
||||
return True
|
||||
|
||||
def setupContextMenu(self,vobj,menu):
|
||||
def setupContextMenu(self, vobj, menu):
|
||||
"""Add the component specific options to the context menu.
|
||||
|
||||
The context menu is the drop down menu that opens when the user right
|
||||
clicks on the component in the tree view.
|
||||
|
||||
Add a menu choice to call the Arch_ToggleSubs Gui command. See
|
||||
ArchCommands._ToggleSubs
|
||||
|
||||
Parameters
|
||||
----------
|
||||
vobj: <Gui.ViewProviderDocumentObject>
|
||||
@@ -1505,16 +1480,30 @@ class ViewProviderComponent:
|
||||
The context menu already assembled prior to this method being
|
||||
called.
|
||||
"""
|
||||
self.contextMenuAddEdit(menu)
|
||||
self.contextMenuAddToggleSubcomponents(menu)
|
||||
|
||||
from PySide import QtCore,QtGui
|
||||
action1 = QtGui.QAction(QtGui.QIcon(":/icons/Arch_ToggleSubs.svg"),translate("Arch","Toggle subcomponents"),menu)
|
||||
QtCore.QObject.connect(action1,QtCore.SIGNAL("triggered()"),self.toggleSubcomponents)
|
||||
menu.addAction(action1)
|
||||
def contextMenuAddEdit(self, menu):
|
||||
actionEdit = QtGui.QAction(translate("Arch", "Edit"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionEdit,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.edit)
|
||||
menu.addAction(actionEdit)
|
||||
|
||||
def contextMenuAddToggleSubcomponents(self, menu):
|
||||
actionToggleSubcomponents = QtGui.QAction(QtGui.QIcon(":/icons/Arch_ToggleSubs.svg"),
|
||||
translate("Arch", "Toggle subcomponents"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionToggleSubcomponents,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.toggleSubcomponents)
|
||||
menu.addAction(actionToggleSubcomponents)
|
||||
|
||||
def edit(self):
|
||||
FreeCADGui.ActiveDocument.setEdit(self.Object, 0)
|
||||
|
||||
def toggleSubcomponents(self):
|
||||
"""Simple wrapper to call Arch_ToggleSubs when the relevant context
|
||||
menu choice is selected."""
|
||||
|
||||
FreeCADGui.runCommand("Arch_ToggleSubs")
|
||||
|
||||
def areDifferentColors(self,a,b):
|
||||
@@ -1724,7 +1713,8 @@ class ComponentTaskPanel:
|
||||
else:
|
||||
import os
|
||||
# the BIM_Classification command needs to be added before it can be used
|
||||
FreeCADGui.activateWorkbench("BIMWorkbench")
|
||||
if not "BIM_Classification" in FreeCADGui.listCommands():
|
||||
FreeCADGui.activateWorkbench("BIMWorkbench")
|
||||
self.classButton.setIcon(QtGui.QIcon(os.path.join(os.path.dirname(BimClassification.__file__),"icons","BIM_Classification.svg")))
|
||||
|
||||
QtCore.QObject.connect(self.addButton, QtCore.SIGNAL("clicked()"), self.addElement)
|
||||
|
||||
@@ -298,20 +298,34 @@ class ViewProviderArchGrid:
|
||||
import Arch_rc
|
||||
return ":/icons/Arch_Grid.svg"
|
||||
|
||||
def setEdit(self,vobj,mode=0):
|
||||
def attach(self, vobj):
|
||||
self.Object = vobj.Object
|
||||
|
||||
def setEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
taskd = ArchGridTaskPanel(vobj.Object)
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
def unsetEdit(self,vobj,mode):
|
||||
def unsetEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
FreeCADGui.Control.closeDialog()
|
||||
return
|
||||
return True
|
||||
|
||||
def doubleClicked(self,vobj):
|
||||
def setupContextMenu(self, vobj, menu):
|
||||
actionEdit = QtGui.QAction(translate("Arch", "Edit"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionEdit,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.edit)
|
||||
menu.addAction(actionEdit)
|
||||
|
||||
self.setEdit(vobj)
|
||||
def edit(self):
|
||||
FreeCADGui.ActiveDocument.setEdit(self.Object, 0)
|
||||
|
||||
def __getstate__(self):
|
||||
|
||||
|
||||
@@ -25,35 +25,67 @@ import FreeCAD, ArchIFC
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
from PySide import QtGui
|
||||
from PySide import QtCore, QtGui
|
||||
from draftutils.translate import translate
|
||||
else:
|
||||
def translate(ctxt,txt):
|
||||
return txt
|
||||
|
||||
class IfcContextView:
|
||||
"""A default view provider for IfcContext objects."""
|
||||
|
||||
def setEdit(self, viewObject, mode):
|
||||
"""Method called when the document requests the object to enter edit mode.
|
||||
def attach(self, vobj):
|
||||
self.Object = vobj.Object
|
||||
|
||||
Opens the IfcContextUi as the task panel.
|
||||
def setEdit(self, vobj, mode):
|
||||
if mode == 1 or mode == 2:
|
||||
return None
|
||||
|
||||
Edit mode is entered when a user double clicks on an object in the tree
|
||||
view, or when they use the menu option [Edit -> Toggle Edit Mode].
|
||||
|
||||
Parameters
|
||||
----------
|
||||
mode: int or str
|
||||
The edit mode the document has requested. Set to 0 when requested via
|
||||
a double click or [Edit -> Toggle Edit Mode].
|
||||
|
||||
Returns
|
||||
-------
|
||||
bool
|
||||
If edit mode was entered.
|
||||
"""
|
||||
|
||||
# What does mode do?
|
||||
FreeCADGui.Control.showDialog(IfcContextUI(viewObject.Object))
|
||||
FreeCADGui.Control.showDialog(IfcContextUI(vobj.Object))
|
||||
return True
|
||||
|
||||
def unsetEdit(self, vobj, mode):
|
||||
if mode == 1 or mode == 2:
|
||||
return None
|
||||
|
||||
FreeCADGui.Control.closeDialog()
|
||||
return True
|
||||
|
||||
def setupContextMenu(self, vobj, menu):
|
||||
actionEdit = QtGui.QAction(translate("Arch", "Edit"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionEdit,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.edit)
|
||||
menu.addAction(actionEdit)
|
||||
|
||||
# The default Part::FeaturePython context menu contains a `Set colors`
|
||||
# option. This option does not makes sense here. We therefore
|
||||
# override this menu and have to add our own `Transform` item.
|
||||
# To override the default menu this function must return `True`.
|
||||
actionTransform = QtGui.QAction(FreeCADGui.getIcon("Std_TransformManip.svg"),
|
||||
translate("Command", "Transform"), # Context `Command` instead of `Arch`.
|
||||
menu)
|
||||
QtCore.QObject.connect(actionTransform,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.transform)
|
||||
menu.addAction(actionTransform)
|
||||
|
||||
return True
|
||||
|
||||
def edit(self):
|
||||
FreeCADGui.ActiveDocument.setEdit(self.Object, 0)
|
||||
|
||||
def transform(self):
|
||||
FreeCADGui.ActiveDocument.setEdit(self.Object, 1)
|
||||
|
||||
def __getstate__(self):
|
||||
return None
|
||||
|
||||
def __setstate__(self,state):
|
||||
return None
|
||||
|
||||
|
||||
class IfcContextUI:
|
||||
"""A default task panel for editing context objects."""
|
||||
|
||||
@@ -75,6 +107,11 @@ class IfcContextUI:
|
||||
for lineEdit in self.lineEditObjects:
|
||||
data[lineEdit.objectName()] = lineEdit.text()
|
||||
ArchIFC.IfcRoot.setObjIfcComplexAttributeValue(self, self.object, "RepresentationContexts", data)
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
return True
|
||||
|
||||
def reject(self):
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
return True
|
||||
|
||||
def createBaseLayout(self):
|
||||
|
||||
@@ -209,14 +209,21 @@ class _ViewProviderArchMaterialContainer:
|
||||
def attach(self,vobj):
|
||||
self.Object = vobj.Object
|
||||
|
||||
def setupContextMenu(self,vobj,menu):
|
||||
from PySide import QtCore,QtGui
|
||||
action1 = QtGui.QAction(QtGui.QIcon(":/icons/Arch_Material_Group.svg"),"Merge duplicates",menu)
|
||||
QtCore.QObject.connect(action1,QtCore.SIGNAL("triggered()"),self.mergeByName)
|
||||
menu.addAction(action1)
|
||||
action2 = QtGui.QAction(QtGui.QIcon(),"Reorder children alphabetically",menu)
|
||||
QtCore.QObject.connect(action2,QtCore.SIGNAL("triggered()"),self.reorder)
|
||||
menu.addAction(action2)
|
||||
def setupContextMenu(self, vobj, menu):
|
||||
actionMergeByName = QtGui.QAction(QtGui.QIcon(":/icons/Arch_Material_Group.svg"),
|
||||
translate("Arch", "Merge duplicates"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionMergeByName,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.mergeByName)
|
||||
menu.addAction(actionMergeByName)
|
||||
|
||||
actionReorder = QtGui.QAction(translate("Arch", "Reorder children alphabetically"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionReorder,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.reorder)
|
||||
menu.addAction(actionReorder)
|
||||
|
||||
def mergeByName(self):
|
||||
if hasattr(self,"Object"):
|
||||
@@ -426,7 +433,6 @@ class _ViewProviderArchMaterial:
|
||||
|
||||
def attach(self, vobj):
|
||||
self.Object = vobj.Object
|
||||
return
|
||||
|
||||
def updateData(self, obj, prop):
|
||||
if prop == "Color":
|
||||
@@ -466,19 +472,33 @@ class _ViewProviderArchMaterial:
|
||||
if o.Label == vobj.Object.Material["Father"]:
|
||||
o.touch()
|
||||
|
||||
def setEdit(self,vobj,mode):
|
||||
def setEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
self.taskd = _ArchMaterialTaskPanel(vobj.Object)
|
||||
FreeCADGui.Control.showDialog(self.taskd)
|
||||
self.taskd.form.FieldName.setFocus()
|
||||
self.taskd.form.FieldName.selectAll()
|
||||
return True
|
||||
|
||||
def unsetEdit(self,vobj,mode):
|
||||
def unsetEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
FreeCADGui.Control.closeDialog()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
if hasattr(self,"taskd"):
|
||||
del self.taskd
|
||||
return
|
||||
return True
|
||||
|
||||
def setupContextMenu(self, vobj, menu):
|
||||
actionEdit = QtGui.QAction(translate("Arch", "Edit"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionEdit,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.edit)
|
||||
menu.addAction(actionEdit)
|
||||
|
||||
def edit(self):
|
||||
FreeCADGui.ActiveDocument.setEdit(self.Object, 0)
|
||||
|
||||
def setTaskValue(self,widgetname,value):
|
||||
if hasattr(self,"taskd"):
|
||||
@@ -618,9 +638,13 @@ class _ArchMaterialTaskPanel:
|
||||
if hasattr(self.obj,"Material"):
|
||||
self.obj.Material = self.material
|
||||
self.obj.Label = self.material['Name']
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
FreeCADGui.Control.closeDialog()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
return True
|
||||
|
||||
def reject(self):
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
return True
|
||||
|
||||
def chooseMat(self, card):
|
||||
"sets self.material from a card"
|
||||
@@ -738,25 +762,44 @@ class _ViewProviderArchMultiMaterial:
|
||||
def getIcon(self):
|
||||
return ":/icons/Arch_Material_Multi.svg"
|
||||
|
||||
def setEdit(self,vobj,mode=0):
|
||||
def attach(self, vobj):
|
||||
self.Object = vobj.Object
|
||||
|
||||
def setEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
taskd = _ArchMultiMaterialTaskPanel(vobj.Object)
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
def unsetEdit(self,vobj,mode=0):
|
||||
def unsetEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
FreeCADGui.Control.closeDialog()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
return True
|
||||
|
||||
def doubleClicked(self,vobj):
|
||||
self.edit()
|
||||
|
||||
def setupContextMenu(self, vobj, menu):
|
||||
actionEdit = QtGui.QAction(translate("Arch", "Edit"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionEdit,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.edit)
|
||||
menu.addAction(actionEdit)
|
||||
|
||||
def edit(self):
|
||||
FreeCADGui.ActiveDocument.setEdit(self.Object, 0)
|
||||
|
||||
def __getstate__(self):
|
||||
return None
|
||||
|
||||
def __setstate__(self,state):
|
||||
return None
|
||||
|
||||
def doubleClicked(self,vobj):
|
||||
self.setEdit(vobj)
|
||||
|
||||
def isShow(self):
|
||||
return True
|
||||
|
||||
@@ -968,6 +1011,11 @@ class _ArchMultiMaterialTaskPanel:
|
||||
if self.form.nameField.text():
|
||||
self.obj.Label = self.form.nameField.text()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
return True
|
||||
|
||||
def reject(self):
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
return True
|
||||
|
||||
|
||||
|
||||
@@ -1403,19 +1403,21 @@ class ViewProviderPanelSheet(Draft._ViewProviderDraft):
|
||||
|
||||
return ":/icons/Draft_Drawing.svg"
|
||||
|
||||
def setEdit(self,vobj,mode):
|
||||
def setEdit(self, vobj, mode):
|
||||
if mode == 1 or mode == 2:
|
||||
return None
|
||||
|
||||
if mode == 0:
|
||||
taskd = SheetTaskPanel(vobj.Object)
|
||||
taskd.update()
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
return False
|
||||
taskd = SheetTaskPanel(vobj.Object)
|
||||
taskd.update()
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
def unsetEdit(self,vobj,mode):
|
||||
def unsetEdit(self, vobj, mode):
|
||||
if mode == 1 or mode == 2:
|
||||
return None
|
||||
|
||||
FreeCADGui.Control.closeDialog()
|
||||
return False
|
||||
return True
|
||||
|
||||
def attach(self,vobj):
|
||||
|
||||
|
||||
@@ -728,30 +728,32 @@ class _ViewProviderPrecast(ArchComponent.ViewProviderComponent):
|
||||
return ":/icons/Arch_Structure_Clone.svg"
|
||||
return ":/icons/Arch_Structure_Tree.svg"
|
||||
|
||||
def setEdit(self,vobj,mode):
|
||||
def setEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
if mode == 0:
|
||||
import FreeCADGui
|
||||
taskd = ArchComponent.ComponentTaskPanel()
|
||||
taskd.obj = self.Object
|
||||
taskd.update()
|
||||
if hasattr(self.Object,"Dents"):
|
||||
self.dentd = _DentsTaskPanel()
|
||||
self.dentd.form.show()
|
||||
self.dentd.fillDents(self.Object.Dents)
|
||||
taskd.form = [taskd.form,self.dentd.form]
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
return False
|
||||
import FreeCADGui
|
||||
taskd = ArchComponent.ComponentTaskPanel()
|
||||
taskd.obj = self.Object
|
||||
taskd.update()
|
||||
if hasattr(self.Object,"Dents"):
|
||||
self.dentd = _DentsTaskPanel()
|
||||
self.dentd.form.show()
|
||||
self.dentd.fillDents(self.Object.Dents)
|
||||
taskd.form = [taskd.form,self.dentd.form]
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
def unsetEdit(self,vobj,mode):
|
||||
def unsetEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
import FreeCADGui
|
||||
if hasattr(self,"dentd"):
|
||||
self.Object.Dents = self.dentd.getValues()
|
||||
del self.dentd
|
||||
FreeCADGui.Control.closeDialog()
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
class _PrecastTaskPanel:
|
||||
|
||||
@@ -243,6 +243,7 @@ class _Profile(Draft._DraftObject):
|
||||
def __setstate__(self,state):
|
||||
if isinstance(state,list):
|
||||
self.Profile = state
|
||||
self.Type = "Profile"
|
||||
|
||||
def cleanProperties(self, obj):
|
||||
|
||||
@@ -472,17 +473,20 @@ class ViewProviderProfile(Draft._ViewProviderDraft):
|
||||
import Arch_rc
|
||||
return ":/icons/Arch_Profile.svg"
|
||||
|
||||
def setEdit(self,vobj,mode):
|
||||
def setEdit(self, vobj, mode):
|
||||
if mode == 1 or mode == 2:
|
||||
return None
|
||||
|
||||
taskd = ProfileTaskPanel(vobj.Object)
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
def unsetEdit(self,vobj,mode):
|
||||
def unsetEdit(self, vobj, mode):
|
||||
if mode == 1 or mode == 2:
|
||||
return None
|
||||
|
||||
FreeCADGui.Control.closeDialog()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
return
|
||||
return True
|
||||
|
||||
|
||||
class ProfileTaskPanel:
|
||||
@@ -594,6 +598,11 @@ class ProfileTaskPanel:
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
return True
|
||||
|
||||
def reject(self):
|
||||
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
return True
|
||||
|
||||
def retranslateUi(self, TaskPanel):
|
||||
|
||||
self.form.setWindowTitle(self.type+" "+QtGui.QApplication.translate("Arch", "Profile", None))
|
||||
|
||||
@@ -512,24 +512,32 @@ class _ViewProviderRebar(ArchComponent.ViewProviderComponent):
|
||||
return ":/icons/Arch_Rebar_Tree.svg"
|
||||
|
||||
def setEdit(self, vobj, mode):
|
||||
# The Reinforcement Workbench does not implement resetEdit.
|
||||
# Therefore unsetEdit is never called and objects would stay in
|
||||
# edit mode if this function were to return `True`.
|
||||
|
||||
if mode == 0:
|
||||
if hasattr(vobj.Object, "RebarShape"):
|
||||
try:
|
||||
# Import module of RebarShape
|
||||
module = __import__(vobj.Object.RebarShape)
|
||||
except ImportError:
|
||||
FreeCAD.Console.PrintError("Unable to import RebarShape module\n")
|
||||
return
|
||||
module.editDialog(vobj)
|
||||
elif vobj.RebarShape:
|
||||
try:
|
||||
# Import module of RebarShape
|
||||
module = __import__(vobj.RebarShape)
|
||||
except ImportError:
|
||||
FreeCAD.Console.PrintError("Unable to import RebarShape module\n")
|
||||
return
|
||||
module.editDialog(vobj)
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
if hasattr(vobj.Object, "RebarShape"):
|
||||
try:
|
||||
# Import module of RebarShape
|
||||
module = __import__(vobj.Object.RebarShape)
|
||||
except ImportError:
|
||||
FreeCAD.Console.PrintError("Unable to import RebarShape module\n")
|
||||
return False
|
||||
elif vobj.RebarShape:
|
||||
try:
|
||||
# Import module of RebarShape
|
||||
module = __import__(vobj.RebarShape)
|
||||
except ImportError:
|
||||
FreeCAD.Console.PrintError("Unable to import RebarShape module\n")
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
|
||||
module.editDialog(vobj)
|
||||
return False
|
||||
|
||||
def updateData(self,obj,prop):
|
||||
|
||||
|
||||
@@ -386,19 +386,6 @@ class ViewProviderArchReference:
|
||||
import Arch_rc
|
||||
return ":/icons/Arch_Reference.svg"
|
||||
|
||||
def setEdit(self,vobj,mode=0):
|
||||
|
||||
taskd = ArchReferenceTaskPanel(vobj.Object)
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
def unsetEdit(self,vobj,mode):
|
||||
|
||||
FreeCADGui.Control.closeDialog()
|
||||
from DraftGui import todo
|
||||
todo.delay(vobj.Proxy.recolorize,vobj)
|
||||
return
|
||||
|
||||
def attach(self,vobj):
|
||||
|
||||
self.Object = vobj.Object
|
||||
@@ -408,10 +395,6 @@ class ViewProviderArchReference:
|
||||
s = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetInt("ReferenceCheckInterval",60)
|
||||
self.timer.start(1000*s)
|
||||
|
||||
def doubleClicked(self,vobj):
|
||||
|
||||
self.setEdit(vobj)
|
||||
|
||||
def __getstate__(self):
|
||||
|
||||
return None
|
||||
@@ -485,14 +468,50 @@ class ViewProviderArchReference:
|
||||
del self.timer
|
||||
return True
|
||||
|
||||
def setupContextMenu(self,vobj,menu):
|
||||
def setEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
action1 = QtGui.QAction(QtGui.QIcon(":/icons/view-refresh.svg"),"Reload reference",menu)
|
||||
QtCore.QObject.connect(action1,QtCore.SIGNAL("triggered()"),self.onReload)
|
||||
menu.addAction(action1)
|
||||
action2 = QtGui.QAction(QtGui.QIcon(":/icons/document-open.svg"),"Open reference",menu)
|
||||
QtCore.QObject.connect(action2,QtCore.SIGNAL("triggered()"),self.onOpen)
|
||||
menu.addAction(action2)
|
||||
taskd = ArchReferenceTaskPanel(vobj.Object)
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
def unsetEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
FreeCADGui.Control.closeDialog()
|
||||
from DraftGui import todo
|
||||
todo.delay(vobj.Proxy.recolorize,vobj)
|
||||
return True
|
||||
|
||||
def setupContextMenu(self, vobj, menu):
|
||||
|
||||
actionEdit = QtGui.QAction(translate("Arch", "Edit"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionEdit,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.edit)
|
||||
menu.addAction(actionEdit)
|
||||
|
||||
actionOnReload = QtGui.QAction(QtGui.QIcon(":/icons/view-refresh.svg"),
|
||||
translate("Arch", "Reload reference"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionOnReload,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.onReload)
|
||||
menu.addAction(actionOnReload)
|
||||
|
||||
actionOnOpen = QtGui.QAction(QtGui.QIcon(":/icons/document-open.svg"),
|
||||
translate("Arch", "Open reference"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionOnOpen,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.onOpen)
|
||||
menu.addAction(actionOnOpen)
|
||||
|
||||
def edit(self):
|
||||
FreeCADGui.ActiveDocument.setEdit(self.Object, 0)
|
||||
|
||||
def onReload(self):
|
||||
|
||||
|
||||
@@ -897,11 +897,10 @@ class _ViewProviderRoof(ArchComponent.ViewProviderComponent):
|
||||
self.Object = vobj.Object
|
||||
return
|
||||
|
||||
def unsetEdit(self, vobj, mode):
|
||||
FreeCADGui.Control.closeDialog()
|
||||
return
|
||||
|
||||
def setEdit(self, vobj, mode=0):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
if vobj.Object.Base.Shape.Solids:
|
||||
taskd = ArchComponent.ComponentTaskPanel()
|
||||
taskd.obj = self.Object
|
||||
|
||||
@@ -358,19 +358,44 @@ class _ViewProviderArchSchedule:
|
||||
def attach(self, vobj):
|
||||
self.Object = vobj.Object
|
||||
|
||||
def setEdit(self,vobj,mode=0):
|
||||
if hasattr(self,"taskd"):
|
||||
if self.taskd:
|
||||
self.taskd.form.hide()
|
||||
def setEdit(self, vobj, mode=0):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
self.taskd = ArchScheduleTaskPanel(vobj.Object)
|
||||
return True
|
||||
|
||||
def doubleClicked(self,vobj):
|
||||
self.setEdit(vobj)
|
||||
def unsetEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
def unsetEdit(self,vobj,mode):
|
||||
return True
|
||||
|
||||
def doubleClicked(self, vobj):
|
||||
self.edit()
|
||||
|
||||
def setupContextMenu(self, vobj, menu):
|
||||
actionEdit = QtGui.QAction(translate("Arch", "Edit"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionEdit,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.edit)
|
||||
menu.addAction(actionEdit)
|
||||
|
||||
actionAttachSpreadsheet = QtGui.QAction(QtGui.QIcon(":/icons/Arch_Schedule.svg"),
|
||||
translate("Arch", "Attach spreadsheet"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionAttachSpreadsheet,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.attachSpreadsheet)
|
||||
menu.addAction(actionAttachSpreadsheet)
|
||||
|
||||
def edit(self):
|
||||
FreeCADGui.ActiveDocument.setEdit(self.Object, 0)
|
||||
|
||||
def attachSpreadsheet(self):
|
||||
self.Object.Proxy.setSpreadsheetData(self.Object, force=True)
|
||||
|
||||
def claimChildren(self):
|
||||
if hasattr(self,"Object"):
|
||||
return [self.Object.Result]
|
||||
@@ -390,15 +415,6 @@ class _ViewProviderArchSchedule:
|
||||
def setDisplayMode(self,mode):
|
||||
return mode
|
||||
|
||||
def setupContextMenu(self,vobj,menu):
|
||||
action1 = QtGui.QAction(QtGui.QIcon(":/icons/Arch_Schedule.svg"),"Attach spreadsheet",menu)
|
||||
QtCore.QObject.connect(action1,QtCore.SIGNAL("triggered()"),self.attachSpreadsheet)
|
||||
menu.addAction(action1)
|
||||
|
||||
def attachSpreadsheet(self):
|
||||
if hasattr(self,"Object"):
|
||||
self.Object.Proxy.setSpreadsheetData(self.Object,force=True)
|
||||
|
||||
|
||||
class ArchScheduleTaskPanel:
|
||||
|
||||
@@ -447,8 +463,6 @@ class ArchScheduleTaskPanel:
|
||||
self.form.list.clearContents()
|
||||
|
||||
if self.obj:
|
||||
if not obj.Description:
|
||||
return
|
||||
for p in [obj.Value,obj.Unit,obj.Objects,obj.Filter]:
|
||||
if len(obj.Description) != len(p):
|
||||
return
|
||||
@@ -632,6 +646,7 @@ class ArchScheduleTaskPanel:
|
||||
# commit values
|
||||
self.writeValues()
|
||||
self.form.hide()
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
return True
|
||||
|
||||
def reject(self):
|
||||
@@ -639,6 +654,7 @@ class ArchScheduleTaskPanel:
|
||||
"""Close dialog without saving"""
|
||||
|
||||
self.form.hide()
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
return True
|
||||
|
||||
def writeValues(self):
|
||||
|
||||
@@ -1213,7 +1213,9 @@ class _ViewProviderSectionPlane:
|
||||
|
||||
return None
|
||||
|
||||
def setEdit(self,vobj,mode):
|
||||
def setEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
taskd = SectionPlaneTaskPanel()
|
||||
taskd.obj = vobj.Object
|
||||
@@ -1221,27 +1223,35 @@ class _ViewProviderSectionPlane:
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
def unsetEdit(self,vobj,mode):
|
||||
def unsetEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
FreeCADGui.Control.closeDialog()
|
||||
return False
|
||||
return True
|
||||
|
||||
def doubleClicked(self,vobj):
|
||||
def doubleClicked(self, vobj):
|
||||
self.edit()
|
||||
|
||||
self.setEdit(vobj,None)
|
||||
def setupContextMenu(self, vobj, menu):
|
||||
actionEdit = QtGui.QAction(translate("Arch", "Edit"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionEdit,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.edit)
|
||||
menu.addAction(actionEdit)
|
||||
|
||||
def setupContextMenu(self,vobj,menu):
|
||||
"""CONTEXT MENU setup"""
|
||||
from PySide import QtCore,QtGui
|
||||
action1 = QtGui.QAction(QtGui.QIcon(":/icons/Draft_Edit.svg"),"Toggle Cutview",menu)
|
||||
action1.triggered.connect(lambda f=self.contextCutview, arg=vobj:f(arg))
|
||||
menu.addAction(action1)
|
||||
actionToggleCutview = QtGui.QAction(QtGui.QIcon(":/icons/Draft_Edit.svg"),
|
||||
translate("Arch", "Toggle Cutview"),
|
||||
menu)
|
||||
actionToggleCutview.triggered.connect(lambda f=self.toggleCutview, arg=vobj: f(arg))
|
||||
menu.addAction(actionToggleCutview)
|
||||
|
||||
def contextCutview(self,vobj):
|
||||
"""CONTEXT MENU command to toggle CutView property on and off"""
|
||||
if vobj.CutView:
|
||||
vobj.CutView = False
|
||||
else: vobj.CutView = True
|
||||
def edit(self):
|
||||
FreeCADGui.ActiveDocument.setEdit(self.Object, 0)
|
||||
|
||||
def toggleCutview(self, vobj):
|
||||
vobj.CutView = not vobj.CutView
|
||||
|
||||
|
||||
class _ArchDrawingView:
|
||||
|
||||
@@ -27,6 +27,7 @@ containers for Arch objects, and also define a terrain surface.
|
||||
import FreeCAD,Draft,ArchCommands,math,re,datetime,ArchIFC
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
from PySide import QtGui,QtCore
|
||||
from draftutils.translate import translate
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
else:
|
||||
@@ -897,47 +898,62 @@ class _ViewProviderSite:
|
||||
objs.extend(self.Object.Subtractions)
|
||||
return objs
|
||||
|
||||
def setEdit(self,vobj,mode):
|
||||
"""Method called when the document requests the object to enter edit mode.
|
||||
def setEdit(self, vobj, mode):
|
||||
if mode == 1 or mode == 2:
|
||||
return None
|
||||
|
||||
Edit mode is entered when a user double clicks on an object in the tree
|
||||
view, or when they use the menu option [Edit -> Toggle Edit Mode].
|
||||
import ArchComponent
|
||||
taskd = ArchComponent.ComponentTaskPanel()
|
||||
taskd.obj = self.Object
|
||||
taskd.update()
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
Just display the standard Arch component task panel.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
mode: int or str
|
||||
The edit mode the document has requested. Set to 0 when requested via
|
||||
a double click or [Edit -> Toggle Edit Mode].
|
||||
|
||||
Returns
|
||||
-------
|
||||
bool
|
||||
If edit mode was entered.
|
||||
"""
|
||||
|
||||
if (mode == 0) and hasattr(self,"Object"):
|
||||
import ArchComponent
|
||||
taskd = ArchComponent.ComponentTaskPanel()
|
||||
taskd.obj = self.Object
|
||||
taskd.update()
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
return False
|
||||
|
||||
def unsetEdit(self,vobj,mode):
|
||||
"""Method called when the document requests the object exit edit mode.
|
||||
|
||||
Close the Arch component edit task panel.
|
||||
|
||||
Returns
|
||||
-------
|
||||
False
|
||||
"""
|
||||
def unsetEdit(self, vobj, mode):
|
||||
if mode == 1 or mode == 2:
|
||||
return None
|
||||
|
||||
FreeCADGui.Control.closeDialog()
|
||||
return False
|
||||
return True
|
||||
|
||||
def setupContextMenu(self, vobj, menu):
|
||||
actionEdit = QtGui.QAction(translate("Arch", "Edit"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionEdit,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.edit)
|
||||
menu.addAction(actionEdit)
|
||||
|
||||
actionToggleSubcomponents = QtGui.QAction(QtGui.QIcon(":/icons/Arch_ToggleSubs.svg"),
|
||||
translate("Arch", "Toggle subcomponents"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionToggleSubcomponents,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.toggleSubcomponents)
|
||||
menu.addAction(actionToggleSubcomponents)
|
||||
|
||||
# The default Part::FeaturePython context menu contains a `Set colors`
|
||||
# option. This option does not work well for Site objects. We therefore
|
||||
# override this menu and have to add our own `Transform` item.
|
||||
# To override the default menu this function must return `True`.
|
||||
actionTransform = QtGui.QAction(FreeCADGui.getIcon("Std_TransformManip.svg"),
|
||||
translate("Command", "Transform"), # Context `Command` instead of `Arch`.
|
||||
menu)
|
||||
QtCore.QObject.connect(actionTransform,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.transform)
|
||||
menu.addAction(actionTransform)
|
||||
|
||||
return True
|
||||
|
||||
def edit(self):
|
||||
FreeCADGui.ActiveDocument.setEdit(self.Object, 0)
|
||||
|
||||
def toggleSubcomponents(self):
|
||||
FreeCADGui.runCommand("Arch_ToggleSubs")
|
||||
|
||||
def transform(self):
|
||||
FreeCADGui.ActiveDocument.setEdit(self.Object, 1)
|
||||
|
||||
def attach(self,vobj):
|
||||
"""Add display modes' data to the coin scenegraph.
|
||||
|
||||
@@ -723,7 +723,10 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent):
|
||||
if hasattr(vobj,"Transparency"):
|
||||
self.fmat.transparency.setValue(vobj.Transparency/100.0)
|
||||
|
||||
def setEdit(self,vobj,mode):
|
||||
def setEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
taskd = SpaceTaskPanel()
|
||||
taskd.obj = self.Object
|
||||
taskd.update()
|
||||
|
||||
@@ -1128,15 +1128,15 @@ class _ViewProviderStructure(ArchComponent.ViewProviderComponent):
|
||||
else:
|
||||
ArchComponent.ViewProviderComponent.onChanged(self,vobj,prop)
|
||||
|
||||
def setEdit(self,vobj,mode):
|
||||
def setEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
if mode == 0:
|
||||
taskd = StructureTaskPanel(vobj.Object)
|
||||
taskd.obj = self.Object
|
||||
taskd.update()
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
return False
|
||||
taskd = StructureTaskPanel(vobj.Object)
|
||||
taskd.obj = self.Object
|
||||
taskd.update()
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
|
||||
class StructureTaskPanel(ArchComponent.ComponentTaskPanel):
|
||||
|
||||
@@ -1729,12 +1729,18 @@ class _ViewProviderWall(ArchComponent.ViewProviderComponent):
|
||||
return "Wireframe"
|
||||
return ArchComponent.ViewProviderComponent.setDisplayMode(self,mode)
|
||||
|
||||
def setupContextMenu(self,vobj,menu):
|
||||
def setupContextMenu(self, vobj, menu):
|
||||
super().contextMenuAddEdit(menu)
|
||||
|
||||
from PySide import QtCore,QtGui
|
||||
action1 = QtGui.QAction(QtGui.QIcon(":/icons/Arch_Wall_Tree.svg"),"Flip direction",menu)
|
||||
QtCore.QObject.connect(action1,QtCore.SIGNAL("triggered()"),self.flipDirection)
|
||||
menu.addAction(action1)
|
||||
actionFlipDirection = QtGui.QAction(QtGui.QIcon(":/icons/Arch_Wall_Tree.svg"),
|
||||
translate("Arch", "Flip direction"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionFlipDirection,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.flipDirection)
|
||||
menu.addAction(actionFlipDirection)
|
||||
|
||||
super().contextMenuAddToggleSubcomponents(menu)
|
||||
|
||||
def flipDirection(self):
|
||||
|
||||
|
||||
@@ -1114,29 +1114,6 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent):
|
||||
self.colorize(vobj.Object,force=True)
|
||||
ArchComponent.ViewProviderComponent.onChanged(self,vobj,prop)
|
||||
|
||||
def setEdit(self,vobj,mode):
|
||||
|
||||
taskd = _ArchWindowTaskPanel()
|
||||
taskd.obj = self.Object
|
||||
self.sets = [vobj.DisplayMode,vobj.Transparency]
|
||||
vobj.DisplayMode = "Shaded"
|
||||
vobj.Transparency = 80
|
||||
if self.Object.Base:
|
||||
self.Object.Base.ViewObject.show()
|
||||
taskd.update()
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
def unsetEdit(self,vobj,mode):
|
||||
|
||||
vobj.DisplayMode = self.sets[0]
|
||||
vobj.Transparency = self.sets[1]
|
||||
vobj.DiffuseColor = vobj.DiffuseColor # reset face colors
|
||||
if self.Object.Base:
|
||||
self.Object.Base.ViewObject.hide()
|
||||
FreeCADGui.Control.closeDialog()
|
||||
return
|
||||
|
||||
def colorize(self,obj,force=False):
|
||||
|
||||
"setting different part colors"
|
||||
@@ -1211,17 +1188,67 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent):
|
||||
ccol = (ccol[0],ccol[1],ccol[2],t)
|
||||
return ccol
|
||||
|
||||
def setupContextMenu(self,vobj,menu):
|
||||
def setEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
if hasattr(self,"Object"):
|
||||
from PySide import QtCore,QtGui
|
||||
import Draft_rc
|
||||
action1 = QtGui.QAction(QtGui.QIcon(":/icons/Arch_Window_Tree.svg"),"Invert opening direction",menu)
|
||||
QtCore.QObject.connect(action1,QtCore.SIGNAL("triggered()"),self.invertOpening)
|
||||
menu.addAction(action1)
|
||||
action2 = QtGui.QAction(QtGui.QIcon(":/icons/Arch_Window_Tree.svg"),"Invert hinge position",menu)
|
||||
QtCore.QObject.connect(action2,QtCore.SIGNAL("triggered()"),self.invertHinge)
|
||||
menu.addAction(action2)
|
||||
taskd = _ArchWindowTaskPanel()
|
||||
taskd.obj = self.Object
|
||||
self.sets = [vobj.DisplayMode,vobj.Transparency]
|
||||
vobj.DisplayMode = "Shaded"
|
||||
vobj.Transparency = 80
|
||||
if self.Object.Base:
|
||||
self.Object.Base.ViewObject.show()
|
||||
taskd.update()
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
def unsetEdit(self, vobj, mode):
|
||||
if mode != 0:
|
||||
return None
|
||||
|
||||
vobj.DisplayMode = self.sets[0]
|
||||
vobj.Transparency = self.sets[1]
|
||||
vobj.DiffuseColor = vobj.DiffuseColor # reset face colors
|
||||
if self.Object.Base:
|
||||
self.Object.Base.ViewObject.hide()
|
||||
FreeCADGui.Control.closeDialog()
|
||||
return True
|
||||
|
||||
def setupContextMenu(self, vobj, menu):
|
||||
# WindowParts example:
|
||||
# ["OuterFrame", "Frame", "Wire0,Wire1", "100.0+V", "0.00+V",
|
||||
# "InnerFrame", "Frame", "Wire2,Wire3,Edge8,Mode1", "100.0", "100.0+V",
|
||||
# "InnerGlass", "Glass panel", "Wire3", "10.0", "150.0+V"]
|
||||
|
||||
hasOpening = False
|
||||
parts = self.Object.WindowParts
|
||||
for i in range(len(parts) // 5):
|
||||
wireData = parts[2 + (i * 5)]
|
||||
if wireData.find("Edge") >= 0:
|
||||
hasOpening = True
|
||||
break
|
||||
|
||||
super().contextMenuAddEdit(menu)
|
||||
|
||||
if hasOpening:
|
||||
actionInvertOpening = QtGui.QAction(QtGui.QIcon(":/icons/Arch_Window_Tree.svg"),
|
||||
translate("Arch", "Invert opening direction"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionInvertOpening,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.invertOpening)
|
||||
menu.addAction(actionInvertOpening)
|
||||
|
||||
actionInvertHinge = QtGui.QAction(QtGui.QIcon(":/icons/Arch_Window_Tree.svg"),
|
||||
translate("Arch", "Invert hinge position"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionInvertHinge,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.invertHinge)
|
||||
menu.addAction(actionInvertHinge)
|
||||
|
||||
super().contextMenuAddToggleSubcomponents(menu)
|
||||
|
||||
def invertOpening(self):
|
||||
|
||||
|
||||
@@ -391,14 +391,14 @@ class ViewProviderDraft(object):
|
||||
tp = utils.get_type(vobj.Object)
|
||||
|
||||
if tp in ("Wire", "Circle", "Ellipse", "Rectangle", "Polygon",
|
||||
"BSpline", "BezCurve"): # Facebinder and ShapeString objects have their own setEdit.
|
||||
"BSpline", "BezCurve"): # Facebinder, ShapeString, PanelSheet and Profile objects have their own setEdit.
|
||||
if not "Draft_Edit" in Gui.listCommands():
|
||||
self.wb_before_edit = Gui.activeWorkbench()
|
||||
Gui.activateWorkbench("DraftWorkbench")
|
||||
Gui.runCommand("Draft_Edit")
|
||||
return True
|
||||
|
||||
if tp in ("Fillet", "Point", "Shape2DView"):
|
||||
if tp in ("Fillet", "Point", "Shape2DView", "PanelCut"):
|
||||
Gui.runCommand("Std_TransformManip")
|
||||
return True
|
||||
|
||||
@@ -415,7 +415,7 @@ class ViewProviderDraft(object):
|
||||
tp = utils.get_type(vobj.Object)
|
||||
|
||||
if tp in ("Wire", "Circle", "Ellipse", "Rectangle", "Polygon",
|
||||
"BSpline", "BezCurve"): # Facebinder and ShapeString objects have their own setEdit.
|
||||
"BSpline", "BezCurve"): # Facebinder, ShapeString, PanelSheet and Profile objects have their own unsetEdit.
|
||||
if hasattr(App, "activeDraftCommand") and App.activeDraftCommand:
|
||||
App.activeDraftCommand.finish()
|
||||
Gui.Control.closeDialog()
|
||||
@@ -424,7 +424,7 @@ class ViewProviderDraft(object):
|
||||
delattr(self, "wb_before_edit")
|
||||
return True
|
||||
|
||||
if tp in ("Fillet", "Point", "Shape2DView"):
|
||||
if tp in ("Fillet", "Point", "Shape2DView", "PanelCut"):
|
||||
return True
|
||||
|
||||
return None
|
||||
@@ -433,7 +433,8 @@ class ViewProviderDraft(object):
|
||||
tp = utils.get_type(self.Object)
|
||||
|
||||
if tp in ("Wire", "Circle", "Ellipse", "Rectangle", "Polygon",
|
||||
"BSpline", "BezCurve", "Facebinder", "ShapeString"):
|
||||
"BSpline", "BezCurve", "Facebinder", "ShapeString",
|
||||
"PanelSheet", "Profile"):
|
||||
action_edit = QtGui.QAction(translate("draft", "Edit"),
|
||||
menu)
|
||||
QtCore.QObject.connect(action_edit,
|
||||
@@ -455,7 +456,8 @@ class ViewProviderDraft(object):
|
||||
# have to add our own `Transform` item.
|
||||
# To override the default menu this function must return `True`.
|
||||
if tp in ("Wire", "Circle", "Ellipse", "Rectangle", "Polygon",
|
||||
"BSpline","BezCurve", "Fillet", "Point", "Shape2DView"):
|
||||
"BSpline","BezCurve", "Fillet", "Point", "Shape2DView",
|
||||
"PanelCut", "PanelSheet", "Profile"):
|
||||
action_transform = QtGui.QAction(Gui.getIcon("Std_TransformManip.svg"),
|
||||
translate("Command", "Transform"), # Context `Command` instead of `draft`.
|
||||
menu)
|
||||
|
||||
Reference in New Issue
Block a user