[TD]Add MoveView and CopyView commands
This commit is contained in:
committed by
WandererFan
parent
d1a94de371
commit
5a40cd0ae5
90
src/Mod/TechDraw/TechDrawTools/CommandCopyView.py
Normal file
90
src/Mod/TechDraw/TechDrawTools/CommandCopyView.py
Normal file
@@ -0,0 +1,90 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2022 Wanderer Fan <wandererfan@gmail.com> *
|
||||
# * *
|
||||
# * 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 *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
"""Provides the TechDraw CopyView GuiCommand."""
|
||||
|
||||
__title__ = "TechDrawTools.CommandCopyView"
|
||||
__author__ = "WandererFan"
|
||||
__url__ = "http://www.freecadweb.org/index.html"
|
||||
__version__ = "00.01"
|
||||
__date__ = "2022/01/11"
|
||||
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
import FreeCAD as App
|
||||
import FreeCADGui as Gui
|
||||
|
||||
import TechDrawTools
|
||||
|
||||
class CommandCopyView:
|
||||
"""Copies a View from current Page to a different Page."""
|
||||
|
||||
def __init__(self):
|
||||
"""Initialize variables for the command that must exist at all times."""
|
||||
pass
|
||||
|
||||
def GetResources(self):
|
||||
"""Return a dictionary with data that will be used by the button or menu item."""
|
||||
return {'Pixmap': 'actions/TechDraw_CopyView.svg',
|
||||
'Accel': "",
|
||||
'MenuText': QT_TRANSLATE_NOOP("CopyView", "Copy View"),
|
||||
'ToolTip': QT_TRANSLATE_NOOP("CopyView", "Copy a View to a second Page")}
|
||||
|
||||
def Activated(self):
|
||||
"""Run the following code when the command is activated (button press)."""
|
||||
# print("Activated()")
|
||||
sel = Gui.Selection.getSelection()
|
||||
|
||||
vName = ""
|
||||
views = list()
|
||||
for o in sel:
|
||||
if o.isDerivedFrom("TechDraw::DrawView"):
|
||||
views.append(o)
|
||||
if views:
|
||||
vName = views[0].Name
|
||||
|
||||
toPageName = ""
|
||||
fromPageName = ""
|
||||
pages = list()
|
||||
for o in sel:
|
||||
if o.isDerivedFrom("TechDraw::DrawPage"):
|
||||
pages.append(o)
|
||||
if pages:
|
||||
fromPageName = pages[0].Name
|
||||
if len(pages) > 1:
|
||||
toPageName = pages[1].Name
|
||||
|
||||
self.ui = TechDrawTools.TaskCopyView()
|
||||
|
||||
self.ui.setValues(vName, fromPageName, toPageName)
|
||||
Gui.Control.showDialog(self.ui)
|
||||
|
||||
def IsActive(self):
|
||||
"""Return True when the command should be active or False when it should be disabled (greyed)."""
|
||||
if App.ActiveDocument:
|
||||
return TechDrawTools.TDToolsUtil.havePage() and TechDrawTools.TDToolsUtil.haveView()
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
#
|
||||
# The command must be "registered" with a unique name by calling its class.
|
||||
Gui.addCommand('TechDraw_CopyView', CommandCopyView())
|
||||
|
||||
89
src/Mod/TechDraw/TechDrawTools/CommandMoveView.py
Normal file
89
src/Mod/TechDraw/TechDrawTools/CommandMoveView.py
Normal file
@@ -0,0 +1,89 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2022 Wanderer Fan <wandererfan@gmail.com> *
|
||||
# * *
|
||||
# * 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 *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
"""Provides the TechDraw MoveView GuiCommand."""
|
||||
|
||||
__title__ = "TechDrawTools.CommandMoveView"
|
||||
__author__ = "WandererFan"
|
||||
__url__ = "http://www.freecadweb.org/index.html"
|
||||
__version__ = "00.01"
|
||||
__date__ = "2022/01/11"
|
||||
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
import FreeCAD as App
|
||||
import FreeCADGui as Gui
|
||||
|
||||
import TechDrawTools
|
||||
|
||||
class CommandMoveView:
|
||||
"""Moves a View from current Page to a different Page."""
|
||||
|
||||
def __init__(self):
|
||||
"""Initialize variables for the command that must exist at all times."""
|
||||
pass
|
||||
|
||||
def GetResources(self):
|
||||
"""Return a dictionary with data that will be used by the button or menu item."""
|
||||
return {'Pixmap': 'actions/TechDraw_MoveView.svg',
|
||||
'Accel': "",
|
||||
'MenuText': QT_TRANSLATE_NOOP("MoveView", "Move View"),
|
||||
'ToolTip': QT_TRANSLATE_NOOP("MoveView", "Move a View to a new Page")}
|
||||
|
||||
def Activated(self):
|
||||
"""Run the following code when the command is activated (button press)."""
|
||||
sel = Gui.Selection.getSelection()
|
||||
|
||||
viewName = ""
|
||||
views = list()
|
||||
for o in sel:
|
||||
if o.isDerivedFrom("TechDraw::DrawView"):
|
||||
views.append(o)
|
||||
if views:
|
||||
viewName = views[0].Name
|
||||
|
||||
toPageName = ""
|
||||
fromPageName = ""
|
||||
pages = list()
|
||||
for o in sel:
|
||||
if o.isDerivedFrom("TechDraw::DrawPage"):
|
||||
pages.append(o)
|
||||
if pages:
|
||||
fromPageName = pages[0].Name
|
||||
if len(pages) > 1:
|
||||
toPageName = pages[1].Name
|
||||
|
||||
self.ui = TechDrawTools.TaskMoveView()
|
||||
|
||||
self.ui.setValues(viewName, fromPageName, toPageName)
|
||||
Gui.Control.showDialog(self.ui)
|
||||
|
||||
def IsActive(self):
|
||||
"""Return True when the command should be active or False when it should be disabled (greyed)."""
|
||||
if App.ActiveDocument:
|
||||
return TechDrawTools.TDToolsUtil.havePage() and TechDrawTools.TDToolsUtil.haveView()
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
#
|
||||
# The command must be "registered" with a unique name by calling its class.
|
||||
Gui.addCommand('TechDraw_MoveView', CommandMoveView())
|
||||
|
||||
73
src/Mod/TechDraw/TechDrawTools/TDToolsMovers.py
Normal file
73
src/Mod/TechDraw/TechDrawTools/TDToolsMovers.py
Normal file
@@ -0,0 +1,73 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2022 - Wanderer Fan <wandererfan@gmail.com> *
|
||||
# * *
|
||||
# * 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 *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
"""Provides view moving functions for TD Tools."""
|
||||
|
||||
import FreeCAD as App
|
||||
|
||||
#move a simple view and its dependents (dimensions, balloons, etc) from fromPage to toPage
|
||||
def simpleViewMove(view, fromPage, toPage, copy):
|
||||
deps = [x for x in view.InList if x.isDerivedFrom("TechDraw::DrawView")]
|
||||
if not copy:
|
||||
for d in deps:
|
||||
rc = fromPage.removeView(d)
|
||||
rc = fromPage.removeView(view)
|
||||
#redraw fromPage without view
|
||||
fromPage.requestPaint()
|
||||
|
||||
toPage.addView(view)
|
||||
for d in deps:
|
||||
toPage.addView(d)
|
||||
|
||||
view.recompute() #update the view feature
|
||||
App.ActiveDocument.recompute() #update views dependents if necessary
|
||||
return
|
||||
|
||||
#move a section view, its Base View and all its dependents (items, dimensions, balloons, etc) of both from fromPage to toPage
|
||||
def sectionViewMove(view, fromPage, toPage, copy):
|
||||
#move the base
|
||||
base = view.BaseView
|
||||
simpleViewMove(base, fromPage, toPage, copy)
|
||||
|
||||
#move a projection group and all its dependents (items, dimensions, balloons, etc) from fromPage to toPage
|
||||
def projGroupMove(view, fromPage, toPage, copy):
|
||||
items = [x for x in view.Views if x.isDerivedFrom("TechDraw::DrawProjGroupItem")]
|
||||
if not copy:
|
||||
for i in items:
|
||||
id = [x for x in i.InList if x.isDerivedFrom("TechDraw::DrawView")]
|
||||
for dep in id:
|
||||
fromPage.removeView(dep)
|
||||
fromPage.removeView(view)
|
||||
|
||||
toPage.addView(view)
|
||||
for i in items:
|
||||
id = [x for x in i.InList if x.isDerivedFrom("TechDraw::DrawView")]
|
||||
for dep in id:
|
||||
if not dep.isDerivedFrom("TechDraw::DrawProjGroup"): #probably superfluous
|
||||
toPage.addView(dep)
|
||||
|
||||
def moveView(view, fromPage, toPage, copy=False):
|
||||
if view.isDerivedFrom("TechDraw::DrawProjGroup"):
|
||||
projGroupMove(view, fromPage, toPage, copy)
|
||||
elif view.isDerivedFrom("TechDraw::DrawViewSection") or view.isDerivedFrom("TechDraw::DrawViewDetail"):
|
||||
sectionViewMove(view, fromPage, toPage, copy)
|
||||
elif view.isDerivedFrom("TechDraw::DrawView"):
|
||||
simpleViewMove(view, fromPage, toPage, copy)
|
||||
|
||||
38
src/Mod/TechDraw/TechDrawTools/TDToolsUtil.py
Normal file
38
src/Mod/TechDraw/TechDrawTools/TDToolsUtil.py
Normal file
@@ -0,0 +1,38 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2022 - Wanderer Fan <wandererfan@gmail.com> *
|
||||
# * *
|
||||
# * 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 *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
"""Provides utility funtions for TD Tools."""
|
||||
|
||||
import FreeCAD as App
|
||||
|
||||
def havePage():
|
||||
objs = App.ActiveDocument.Objects
|
||||
for o in objs:
|
||||
if o.isDerivedFrom("TechDraw::DrawPage"):
|
||||
return True
|
||||
return False
|
||||
|
||||
def haveView():
|
||||
objs = App.ActiveDocument.Objects
|
||||
for o in objs:
|
||||
if o.isDerivedFrom("TechDraw::DrawView"):
|
||||
return True
|
||||
return False
|
||||
|
||||
133
src/Mod/TechDraw/TechDrawTools/TaskCopyView.py
Normal file
133
src/Mod/TechDraw/TechDrawTools/TaskCopyView.py
Normal file
@@ -0,0 +1,133 @@
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
# * Copyright (c) 2022 - Wanderer Fan <wandererfan@gmail.com> *
|
||||
# * *
|
||||
# * 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 *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
"""Provides the TechDraw CopyView Task Dialog."""
|
||||
|
||||
__title__ = "TechDrawTools.TaskCopyView"
|
||||
__author__ = "WandeererFan"
|
||||
__url__ = "http://www.freecadweb.org/index.html"
|
||||
__version__ = "00.01"
|
||||
__date__ = "2022/01/11"
|
||||
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
from PySide import QtCore
|
||||
import PySide.QtGui as QtGui
|
||||
|
||||
import FreeCAD as App
|
||||
import FreeCADGui as Gui
|
||||
|
||||
from TechDrawTools import TDToolsMovers
|
||||
|
||||
import os
|
||||
|
||||
class TaskCopyView:
|
||||
def __init__(self):
|
||||
self._uiPath = App.getHomePath()
|
||||
self._uiPath = os.path.join(self._uiPath, "Mod/TechDraw/Gui/TaskMoveView.ui")
|
||||
self.form = Gui.PySideUic.loadUi(self._uiPath)
|
||||
|
||||
self.form.setWindowTitle(QT_TRANSLATE_NOOP("CopyView", "Copy View to a second Page"))
|
||||
|
||||
self.form.pbView.clicked.connect(self.pickView)
|
||||
self.form.pbFromPage.clicked.connect(self.pickFromPage)
|
||||
self.form.pbToPage.clicked.connect(self.pickToPage)
|
||||
|
||||
self.viewName = ""
|
||||
self.fromPageName = ""
|
||||
self.toPageName = ""
|
||||
|
||||
def accept(self):
|
||||
# print ("Accept")
|
||||
view = App.ActiveDocument.getObject(self.viewName)
|
||||
fromPage = App.ActiveDocument.getObject(self.fromPageName)
|
||||
toPage = App.ActiveDocument.getObject(self.toPageName)
|
||||
TDToolsMovers.moveView(view, fromPage, toPage, True)
|
||||
return True
|
||||
|
||||
def reject(self):
|
||||
# print ("Reject")
|
||||
return True
|
||||
|
||||
def pickView(self):
|
||||
# print("pickView")
|
||||
_dlgPath = App.getHomePath()
|
||||
_dlgPath = os.path.join(_dlgPath, "Mod/TechDraw/Gui/DlgPageChooser.ui")
|
||||
dlg = Gui.PySideUic.loadUi(_dlgPath)
|
||||
dlg.lPrompt.setText(QT_TRANSLATE_NOOP("CopyView", "Select View to copy from list."))
|
||||
dlg.setWindowTitle(QT_TRANSLATE_NOOP("CopyView", "Select View"))
|
||||
|
||||
views = [x for x in App.ActiveDocument.Objects if x.isDerivedFrom("TechDraw::DrawView")]
|
||||
for v in views:
|
||||
s = v.Label + " / " + v.Name
|
||||
item = QtGui.QListWidgetItem(s, dlg.lwPages)
|
||||
item.setData(QtCore.Qt.UserRole, v.Name)
|
||||
if (dlg.exec() == QtGui.QDialog.Accepted) :
|
||||
if dlg.lwPages.selectedItems():
|
||||
selItem = dlg.lwPages.selectedItems()[0]
|
||||
self.viewName = selItem.data(QtCore.Qt.UserRole)
|
||||
self.form.leView.setText(self.viewName)
|
||||
|
||||
def pickFromPage(self):
|
||||
# print("pickFromPage")
|
||||
_dlgPath = App.getHomePath()
|
||||
_dlgPath = os.path.join(_dlgPath, "Mod/TechDraw/Gui/DlgPageChooser.ui")
|
||||
dlg = Gui.PySideUic.loadUi(_dlgPath)
|
||||
dlg.lPrompt.setText(QT_TRANSLATE_NOOP("CopyView", "Select From Page."))
|
||||
dlg.setWindowTitle(QT_TRANSLATE_NOOP("CopyView", "Select Page"))
|
||||
|
||||
pages = [x for x in App.ActiveDocument.Objects if x.isDerivedFrom("TechDraw::DrawPage")]
|
||||
for p in pages:
|
||||
s = p.Label + " / " + p.Name
|
||||
item = QtGui.QListWidgetItem(s, dlg.lwPages)
|
||||
item.setData(QtCore.Qt.UserRole, p.Name)
|
||||
if (dlg.exec() == QtGui.QDialog.Accepted) :
|
||||
if dlg.lwPages.selectedItems():
|
||||
selItem = dlg.lwPages.selectedItems()[0]
|
||||
self.fromPageName = selItem.data(QtCore.Qt.UserRole)
|
||||
self.form.leFromPage.setText(self.fromPageName)
|
||||
|
||||
def pickToPage(self):
|
||||
# print("pickToPage")
|
||||
_dlgPath = App.getHomePath()
|
||||
_dlgPath = os.path.join(_dlgPath, "Mod/TechDraw/Gui/DlgPageChooser.ui")
|
||||
dlg = Gui.PySideUic.loadUi(_dlgPath)
|
||||
dlg.lPrompt.setText(QT_TRANSLATE_NOOP("CopyView", "Select To Page."))
|
||||
dlg.setWindowTitle(QT_TRANSLATE_NOOP("CopyView", "Select Page"))
|
||||
|
||||
pages = [x for x in App.ActiveDocument.Objects if x.isDerivedFrom("TechDraw::DrawPage")]
|
||||
for p in pages:
|
||||
s = p.Label + " / " + p.Name
|
||||
item = QtGui.QListWidgetItem(s, dlg.lwPages)
|
||||
item.setData(QtCore.Qt.UserRole, p.Name)
|
||||
if (dlg.exec() == QtGui.QDialog.Accepted) :
|
||||
if dlg.lwPages.selectedItems():
|
||||
selItem = dlg.lwPages.selectedItems()[0]
|
||||
self.toPageName = selItem.data(QtCore.Qt.UserRole)
|
||||
self.form.leToPage.setText(self.toPageName)
|
||||
|
||||
def setValues(self, viewName, fromPageName, toPageName):
|
||||
self.viewName = viewName
|
||||
self.form.leView.setText(viewName)
|
||||
self.fromPageName = fromPageName
|
||||
self.form.leFromPage.setText(fromPageName)
|
||||
self.toPageName = toPageName
|
||||
self.form.leToPage.setText(toPageName)
|
||||
|
||||
134
src/Mod/TechDraw/TechDrawTools/TaskMoveView.py
Normal file
134
src/Mod/TechDraw/TechDrawTools/TaskMoveView.py
Normal file
@@ -0,0 +1,134 @@
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
# * Copyright (c) 2022 - Wanderer Fan <wandererfan@gmail.com> *
|
||||
# * *
|
||||
# * 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 *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
"""Provides the TechDraw MoveView Task Dialog."""
|
||||
|
||||
__title__ = "TechDrawTools.TaskMoveView"
|
||||
__author__ = "WandeererFan"
|
||||
__url__ = "http://www.freecadweb.org/index.html"
|
||||
__version__ = "00.01"
|
||||
__date__ = "2022/01/11"
|
||||
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
from PySide import QtCore
|
||||
import PySide.QtGui as QtGui
|
||||
|
||||
import FreeCAD as App
|
||||
import FreeCADGui as Gui
|
||||
|
||||
from TechDrawTools import TDToolsMovers
|
||||
|
||||
import os
|
||||
|
||||
class TaskMoveView:
|
||||
def __init__(self):
|
||||
import os
|
||||
self._uiPath = App.getHomePath()
|
||||
self._uiPath = os.path.join(self._uiPath, "Mod/TechDraw/Gui/TaskMoveView.ui")
|
||||
self.form = Gui.PySideUic.loadUi(self._uiPath)
|
||||
|
||||
self.form.setWindowTitle(QT_TRANSLATE_NOOP("MoveView", "Move View to a different Page"))
|
||||
|
||||
self.form.pbView.clicked.connect(self.pickView)
|
||||
self.form.pbFromPage.clicked.connect(self.pickFromPage)
|
||||
self.form.pbToPage.clicked.connect(self.pickToPage)
|
||||
|
||||
self.viewName = ""
|
||||
self.fromPageName = ""
|
||||
self.toPageName = ""
|
||||
|
||||
def accept(self):
|
||||
# print ("Accept")
|
||||
view = App.ActiveDocument.getObject(self.viewName)
|
||||
fromPage = App.ActiveDocument.getObject(self.fromPageName)
|
||||
toPage = App.ActiveDocument.getObject(self.toPageName)
|
||||
TDToolsMovers.moveView(view, fromPage, toPage)
|
||||
return True
|
||||
|
||||
def reject(self):
|
||||
# print ("Reject")
|
||||
return True
|
||||
|
||||
def pickView(self):
|
||||
# print("pickView")
|
||||
_dlgPath = App.getHomePath()
|
||||
_dlgPath = os.path.join(_dlgPath, "Mod/TechDraw/Gui/DlgPageChooser.ui")
|
||||
dlg = Gui.PySideUic.loadUi(_dlgPath)
|
||||
dlg.lPrompt.setText(QT_TRANSLATE_NOOP("MoveView", "Select View to move from list."))
|
||||
dlg.setWindowTitle(QT_TRANSLATE_NOOP("MoveView", "Select View"))
|
||||
|
||||
views = [x for x in App.ActiveDocument.Objects if x.isDerivedFrom("TechDraw::DrawView")]
|
||||
for v in views:
|
||||
s = v.Label + " / " + v.Name
|
||||
item = QtGui.QListWidgetItem(s, dlg.lwPages)
|
||||
item.setData(QtCore.Qt.UserRole, v.Name)
|
||||
if (dlg.exec() == QtGui.QDialog.Accepted) :
|
||||
if dlg.lwPages.selectedItems():
|
||||
selItem = dlg.lwPages.selectedItems()[0]
|
||||
self.viewName = selItem.data(QtCore.Qt.UserRole)
|
||||
self.form.leView.setText(self.viewName)
|
||||
|
||||
def pickFromPage(self):
|
||||
# print("pickFromPage")
|
||||
_dlgPath = App.getHomePath()
|
||||
_dlgPath = os.path.join(_dlgPath, "Mod/TechDraw/Gui/DlgPageChooser.ui")
|
||||
dlg = Gui.PySideUic.loadUi(_dlgPath)
|
||||
dlg.lPrompt.setText(QT_TRANSLATE_NOOP("MoveView", "Select From Page."))
|
||||
dlg.setWindowTitle(QT_TRANSLATE_NOOP("MoveView", "Select Page"))
|
||||
|
||||
pages = [x for x in App.ActiveDocument.Objects if x.isDerivedFrom("TechDraw::DrawPage")]
|
||||
for p in pages:
|
||||
s = p.Label + " / " + p.Label
|
||||
item = QtGui.QListWidgetItem(s, dlg.lwPages)
|
||||
item.setData(QtCore.Qt.UserRole, p.Name)
|
||||
if (dlg.exec() == QtGui.QDialog.Accepted) :
|
||||
if dlg.lwPages.selectedItems():
|
||||
selItem = dlg.lwPages.selectedItems()[0]
|
||||
self.fromPageName = selItem.data(QtCore.Qt.UserRole)
|
||||
self.form.leFromPage.setText(self.fromPageName)
|
||||
|
||||
def pickToPage(self):
|
||||
# print("pickToPage")
|
||||
_dlgPath = App.getHomePath()
|
||||
_dlgPath = os.path.join(_dlgPath, "Mod/TechDraw/Gui/DlgPageChooser.ui")
|
||||
dlg = Gui.PySideUic.loadUi(_dlgPath)
|
||||
dlg.lPrompt.setText(QT_TRANSLATE_NOOP("MoveView", "Select To Page."))
|
||||
dlg.setWindowTitle(QT_TRANSLATE_NOOP("MoveView", "Select Page"))
|
||||
|
||||
pages = [x for x in App.ActiveDocument.Objects if x.isDerivedFrom("TechDraw::DrawPage")]
|
||||
for p in pages:
|
||||
s = p.Label + " / " + p.Name
|
||||
item = QtGui.QListWidgetItem(s, dlg.lwPages)
|
||||
item.setData(QtCore.Qt.UserRole, p.Name)
|
||||
if (dlg.exec() == QtGui.QDialog.Accepted) :
|
||||
if dlg.lwPages.selectedItems():
|
||||
selItem = dlg.lwPages.selectedItems()[0]
|
||||
self.toPageName = selItem.data(QtCore.Qt.UserRole)
|
||||
self.form.leToPage.setText(self.toPageName)
|
||||
|
||||
def setValues(self, viewName, fromPageName, toPageName):
|
||||
self.viewName = viewName
|
||||
self.form.leView.setText(viewName)
|
||||
self.fromPageName = fromPageName
|
||||
self.form.leFromPage.setText(fromPageName)
|
||||
self.toPageName = toPageName
|
||||
self.form.leToPage.setText(toPageName)
|
||||
|
||||
38
src/Mod/TechDraw/TechDrawTools/__init__.py
Normal file
38
src/Mod/TechDraw/TechDrawTools/__init__.py
Normal file
@@ -0,0 +1,38 @@
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
# * Copyright (c) 2022 - Wanderer Fan <wandererfan@gmail.com> *
|
||||
# * *
|
||||
# * 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__ = "TechDrawTools package"
|
||||
__author__ = "WandererFan"
|
||||
__url__ = "https://www.freecadweb.org"
|
||||
__version__ = "00.01"
|
||||
__date__ = "2022-01-11"
|
||||
|
||||
## @package TechDrawTools
|
||||
# \ingroup TechDraw
|
||||
# \brief TechDrawTools Package for TechDraw workbench
|
||||
|
||||
from .TDToolsMovers import *
|
||||
from .TDToolsUtil import *
|
||||
from .CommandCopyView import CommandCopyView
|
||||
from .CommandMoveView import CommandMoveView
|
||||
from .TaskCopyView import TaskCopyView
|
||||
from .TaskMoveView import TaskMoveView
|
||||
Reference in New Issue
Block a user