diff --git a/src/Mod/Arch/ArchCutPlane.py b/src/Mod/Arch/ArchCutPlane.py index 62033b797056..069d61ecd2a5 100644 --- a/src/Mod/Arch/ArchCutPlane.py +++ b/src/Mod/Arch/ArchCutPlane.py @@ -35,7 +35,6 @@ def translate(ctxt,txt): __author__ = "Jonathan Wiedemann" __url__ = "http://www.freecadweb.org" -# Couper def cutComponentwithPlane(archObject, cutPlane, sideFace): """cut object from a plan define by a face, Behind = 0 , front = 1""" cutVolume = ArchCommands.getCutVolume(cutPlane, archObject.Object.Shape) @@ -44,15 +43,14 @@ def cutComponentwithPlane(archObject, cutPlane, sideFace): else: cutVolume = cutVolume[1] if cutVolume: - obj = FreeCAD.ActiveDocument.addObject("Part::Feature", "CutVolume") + obj = FreeCAD.ActiveDocument.addObject("Part::Feature", str(translate("Arch","CutVolume"))) obj.Shape = cutVolume obj.ViewObject.ShapeColor = (1.00,0.00,0.00) obj.ViewObject.Transparency = 75 - # add substraction component to Arch object if "Additions" in archObject.Object.PropertiesList: return ArchCommands.removeComponents(obj,archObject.Object) else: - cutObj = FreeCAD.ActiveDocument.addObject("Part::Cut", "CutPlane") + cutObj = FreeCAD.ActiveDocument.addObject("Part::Cut", str(translate("Arch","CutPlane"))) cutObj.Base = archObject.Object cutObj.Tool = obj return cutObj @@ -73,29 +71,24 @@ def Activated(self): class _CutPlaneTaskPanel: def __init__(self): - self.title = QtGui.QLabel('Cut Plane options') - self.infoText = QtGui.QLabel('Wich side') - self.grid = QtGui.QGridLayout() - self.grid.addWidget(self.title, 1, 0) - self.grid.addWidget(self.infoText, 2, 0) - self.combobox = QtGui.QComboBox() - items = ["Behind","Front"] - self.combobox.addItems(items) - self.combobox.setCurrentIndex(items.index("Behind")) - self.grid.addWidget(self.combobox, 2, 1) - groupBox = QtGui.QGroupBox() - groupBox.setLayout(self.grid) - self.form = groupBox - # Connecter la combobox a la fonction preveiwCutVolume - QtCore.QObject.connect(self.combobox,QtCore.SIGNAL("currentIndexChanged(int)"),self.previewCutVolume) - # Ajouter un objet PreveiwCutVolume vide - self.obj = FreeCAD.ActiveDocument.addObject("Part::Feature", "PreviewCutVolume") - # Afficher la preview CutVolume en fonction du choix par defaut de la combobox - self.previewCutVolume(self.combobox.currentIndex()) + self.form = QtGui.QWidget() + self.form.setObjectName("TaskPanel") + self.grid = QtGui.QGridLayout(self.form) + self.grid.setObjectName("grid") + self.title = QtGui.QLabel(self.form) + self.grid.addWidget(self.title, 1, 0) + self.infoText = QtGui.QLabel(self.form) + self.grid.addWidget(self.infoText, 2, 0) + self.combobox = QtGui.QComboBox() + self.combobox.setCurrentIndex(0) + self.grid.addWidget(self.combobox, 2, 1) + QtCore.QObject.connect(self.combobox,QtCore.SIGNAL("currentIndexChanged(int)"),self.previewCutVolume) + self.previewObj = FreeCAD.ActiveDocument.addObject("Part::Feature", str(translate("Arch", "PreviewCutVolume"))) + self.retranslateUi(self.form) + self.previewCutVolume(self.combobox.currentIndex()) def accept(self): - # Suppression objet PreviewCutVolume - FreeCAD.ActiveDocument.removeObject(self.obj.Name) + FreeCAD.ActiveDocument.removeObject(self.previewObj.Name) val = self.combobox.currentIndex() FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Cutting"))) FreeCADGui.addModule("Arch") @@ -105,8 +98,7 @@ def accept(self): return True def reject(self): - # Suppression objet PreviewCutVolume - FreeCAD.ActiveDocument.removeObject(self.obj.Name) + FreeCAD.ActiveDocument.removeObject(self.previewObj.Name) FreeCAD.Console.PrintMessage("Cancel Cut Plane\n") return True @@ -115,17 +107,23 @@ def getStandardButtons(self): def previewCutVolume(self, i): cutVolume = ArchCommands.getCutVolume(FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0], FreeCADGui.Selection.getSelectionEx()[0].Object.Shape) - FreeCAD.ActiveDocument.removeObject(self.obj.Name) - self.obj = FreeCAD.ActiveDocument.addObject("Part::Feature", "PreviewCutVolume") - #self.obj.Shape = cutVolume - self.obj.ViewObject.ShapeColor = (1.00,0.00,0.00) - self.obj.ViewObject.Transparency = 75 + FreeCAD.ActiveDocument.removeObject(self.previewObj.Name) + self.previewObj = FreeCAD.ActiveDocument.addObject("Part::Feature", "PreviewCutVolume") + self.previewObj.ViewObject.ShapeColor = (1.00,0.00,0.00) + self.previewObj.ViewObject.Transparency = 75 if i == 1: cutVolume = cutVolume[1] else: cutVolume = cutVolume[2] if cutVolume: - self.obj.Shape = cutVolume + self.previewObj.Shape = cutVolume + + def retranslateUi(self, TaskPanel): + TaskPanel.setWindowTitle(QtGui.QApplication.translate("Arch", "Cut Plane", None, QtGui.QApplication.UnicodeUTF8)) + self.title.setText(QtGui.QApplication.translate("Arch", "Cut Plane options", None, QtGui.QApplication.UnicodeUTF8)) + self.infoText.setText(QtGui.QApplication.translate("Arch", "Wich side to cut", None, QtGui.QApplication.UnicodeUTF8)) + self.combobox.addItems([QtGui.QApplication.translate("Arch", "Behind", None, QtGui.QApplication.UnicodeUTF8), + QtGui.QApplication.translate("Arch", "Front", None, QtGui.QApplication.UnicodeUTF8)]) if FreeCAD.GuiUp: FreeCADGui.addCommand('Arch_CutPlane',_CommandCutPlane())