diff --git a/src/Mod/Path/CMakeLists.txt b/src/Mod/Path/CMakeLists.txt index 01b3605e68..1040aa70d5 100644 --- a/src/Mod/Path/CMakeLists.txt +++ b/src/Mod/Path/CMakeLists.txt @@ -57,6 +57,7 @@ SET(PathScripts_SRCS PathScripts/PathPreferencesPathDressup.py PathScripts/PathPreferencesPathJob.py PathScripts/PathProfileBase.py + PathScripts/PathProfileBaseGui.py PathScripts/PathProfileEdges.py PathScripts/PathProfileEdgesGui.py PathScripts/PathProfileFaces.py diff --git a/src/Mod/Path/Gui/Resources/Path.qrc b/src/Mod/Path/Gui/Resources/Path.qrc index ac791c3ce0..658a25a142 100644 --- a/src/Mod/Path/Gui/Resources/Path.qrc +++ b/src/Mod/Path/Gui/Resources/Path.qrc @@ -64,10 +64,8 @@ panels/PageBaseGeometryEdit.ui panels/PageDepthsEdit.ui panels/PageHeightsEdit.ui - panels/PageOpContourEdit.ui panels/PageOpPocketEdit.ui - panels/PageOpProfileEdgesEdit.ui - panels/PageOpProfileFacesEdit.ui + panels/PageOpProfileFullEdit.ui panels/PocketEdit.ui panels/PointEdit.ui panels/ProfileEdgesEdit.ui diff --git a/src/Mod/Path/Gui/Resources/panels/PageOpContourEdit.ui b/src/Mod/Path/Gui/Resources/panels/PageOpContourEdit.ui deleted file mode 100644 index c5634c1ce5..0000000000 --- a/src/Mod/Path/Gui/Resources/panels/PageOpContourEdit.ui +++ /dev/null @@ -1,127 +0,0 @@ - - - Form - - - - 0 - 0 - 424 - 263 - - - - Form - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - Tool Controller - - - - - - - - - - - - - - - - Direction - - - - - - - - CW - - - - - CCW - - - - - - - - Extra Offset - - - - - - - - 0 - 0 - - - - - - - - - - - - - - Use Start Point - - - - - - - Use Compensation - - - - - - - - - - Qt::Vertical - - - - 20 - 1 - - - - - - - - - Gui::InputField - QLineEdit -
Gui/InputField.h
-
-
- - -
diff --git a/src/Mod/Path/Gui/Resources/panels/PageOpProfileEdgesEdit.ui b/src/Mod/Path/Gui/Resources/panels/PageOpProfileEdgesEdit.ui deleted file mode 100644 index 914e41eb09..0000000000 --- a/src/Mod/Path/Gui/Resources/panels/PageOpProfileEdgesEdit.ui +++ /dev/null @@ -1,148 +0,0 @@ - - - Form - - - - 0 - 0 - 400 - 298 - - - - Form - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - Tool Controller - - - - - - - - - - - - - - - - Cut Side - - - - - - - - Outside - - - - - Inside - - - - - - - - Direction - - - - - - - - CW - - - - - CCW - - - - - - - - Extra Offset - - - - - - - - 0 - 0 - - - - - - - - - - - - - - Use Compensation - - - - - - - Use Start Point - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Gui::InputField - QLineEdit -
Gui/InputField.h
-
-
- - -
diff --git a/src/Mod/Path/Gui/Resources/panels/PageOpProfileFacesEdit.ui b/src/Mod/Path/Gui/Resources/panels/PageOpProfileFullEdit.ui similarity index 96% rename from src/Mod/Path/Gui/Resources/panels/PageOpProfileFacesEdit.ui rename to src/Mod/Path/Gui/Resources/panels/PageOpProfileFullEdit.ui index 3f32a4c7d8..9b79800e15 100644 --- a/src/Mod/Path/Gui/Resources/panels/PageOpProfileFacesEdit.ui +++ b/src/Mod/Path/Gui/Resources/panels/PageOpProfileFullEdit.ui @@ -40,7 +40,7 @@ - + Cut Side @@ -61,7 +61,7 @@ - + Direction @@ -82,7 +82,7 @@ - + Extra Offset diff --git a/src/Mod/Path/PathScripts/PathContour.py b/src/Mod/Path/PathScripts/PathContour.py index fb831ae1c0..98600acce3 100644 --- a/src/Mod/Path/PathScripts/PathContour.py +++ b/src/Mod/Path/PathScripts/PathContour.py @@ -96,7 +96,7 @@ class ObjectContour(PathProfileBase.ObjectProfile): return [(PathUtils.getEnvelope(partshape=baseobject.Shape, subshape=None, depthparams=self.depthparams), False)] def opAreaParams(self, obj, isHole): - params = baseObject().opAreaParams(obj, isHole) + params = self.baseObject().opAreaParams(obj, isHole) params['Coplanar'] = 2 return params diff --git a/src/Mod/Path/PathScripts/PathContourGui.py b/src/Mod/Path/PathScripts/PathContourGui.py index a31df641f0..a9f85c0c0e 100644 --- a/src/Mod/Path/PathScripts/PathContourGui.py +++ b/src/Mod/Path/PathScripts/PathContourGui.py @@ -23,52 +23,17 @@ # *************************************************************************** import FreeCAD -import FreeCADGui -import Path import PathScripts.PathAreaOpGui as PathAreaOpGui import PathScripts.PathContour as PathContour -import PathScripts.PathLog as PathLog -import PathScripts.PathSelection as PathSelection +import PathScripts.PathProfileBaseGui as PathProfileBaseGui -from PathScripts import PathUtils -from PySide import QtCore, QtGui +from PySide import QtCore -def translate(context, text, disambig=None): - return QtCore.QCoreApplication.translate(context, text, disambig) +class TaskPanelOpPage(PathProfileBaseGui.TaskPanelOpPage): -class TaskPanelOpPage(PathAreaOpGui.TaskPanelPage): - - def getForm(self): - return FreeCADGui.PySideUic.loadUi(":/panels/PageOpContourEdit.ui") - - def getFields(self, obj): - PathLog.track() - self.obj.OffsetExtra = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value - self.obj.UseComp = self.form.useCompensation.isChecked() - self.obj.Direction = str(self.form.direction.currentText()) - self.obj.UseStartPoint = self.form.useStartPoint.isChecked() - - tc = PathUtils.findToolController(self.obj, self.form.toolController.currentText()) - self.obj.ToolController = tc - - def setFields(self, obj): - PathLog.track() - self.form.extraOffset.setText(FreeCAD.Units.Quantity(self.obj.OffsetExtra.Value, FreeCAD.Units.Length).UserString) - self.form.useCompensation.setChecked(self.obj.UseComp) - self.form.useStartPoint.setChecked(self.obj.UseStartPoint) - - self.selectInComboBox(self.obj.Direction, self.form.direction) - self.setupToolController(self.obj, self.form.toolController) - - def getSignalsForUpdate(self, obj): - PathLog.track() - signals = [] - signals.append(self.form.direction.currentIndexChanged) - signals.append(self.form.toolController.currentIndexChanged) - signals.append(self.form.useCompensation.clicked) - signals.append(self.form.useStartPoint.clicked) - signals.append(self.form.extraOffset.editingFinished) - return signals + def profileFeatures(self): + # I know this looks bad, contour is just the most basic profile op there is + return 0 PathAreaOpGui.SetupOperation('Contour', PathContour.Create, diff --git a/src/Mod/Path/PathScripts/PathProfileBaseGui.py b/src/Mod/Path/PathScripts/PathProfileBaseGui.py new file mode 100644 index 0000000000..9dd6d05cd5 --- /dev/null +++ b/src/Mod/Path/PathScripts/PathProfileBaseGui.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- + +# *************************************************************************** +# * * +# * Copyright (c) 2017 sliptonic * +# * * +# * 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 * +# * * +# *************************************************************************** + +import FreeCAD +import FreeCADGui +import Path +import PathScripts.PathAreaOpGui as PathAreaOpGui +import PathScripts.PathLog as PathLog +import PathScripts.PathProfileFaces as PathProfileFaces +import PathScripts.PathSelection as PathSelection + +from PathScripts import PathUtils +from PySide import QtCore, QtGui + +def translate(context, text, disambig=None): + return QtCore.QCoreApplication.translate(context, text, disambig) + +FeatureSide = 0x01 +FeatureProcessing = 0x02 + +class TaskPanelOpPage(PathAreaOpGui.TaskPanelPage): + + def getForm(self): + form = FreeCADGui.PySideUic.loadUi(":/panels/PageOpProfileFullEdit.ui") + + if not FeatureSide & self.profileFeatures(): + form.cutSide.hide() + form.cutSideLabel.hide() + + if not FeatureProcessing & self.profileFeatures(): + form.processCircles.hide() + form.processHoles.hide() + form.processPerimeter.hide() + + return form + + def getFields(self, obj): + self.obj.OffsetExtra = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value + self.obj.UseComp = self.form.useCompensation.isChecked() + self.obj.UseStartPoint = self.form.useStartPoint.isChecked() + self.obj.Direction = str(self.form.direction.currentText()) + + tc = PathUtils.findToolController(self.obj, self.form.toolController.currentText()) + self.obj.ToolController = tc + + if FeatureSide & self.profileFeatures(): + self.obj.Side = str(self.form.cutSide.currentText()) + + if FeatureProcessing & self.profileFeatures(): + self.obj.processHoles = self.form.processHoles.isChecked() + self.obj.processPerimeter = self.form.processPerimeter.isChecked() + self.obj.processCircles = self.form.processCircles.isChecked() + + def setFields(self, obj): + self.form.extraOffset.setText(FreeCAD.Units.Quantity(self.obj.OffsetExtra.Value, FreeCAD.Units.Length).UserString) + self.form.useCompensation.setChecked(self.obj.UseComp) + self.form.useStartPoint.setChecked(self.obj.UseStartPoint) + + self.selectInComboBox(self.obj.Direction, self.form.direction) + self.setupToolController(self.obj, self.form.toolController) + + if FeatureSide & self.profileFeatures(): + self.selectInComboBox(self.obj.Side, self.form.cutSide) + + if FeatureProcessing & self.profileFeatures(): + self.form.processHoles.setChecked(self.obj.processHoles) + self.form.processPerimeter.setChecked(self.obj.processPerimeter) + self.form.processCircles.setChecked(self.obj.processCircles) + + def getSignalsForUpdate(self, obj): + signals = [] + signals.append(self.form.direction.currentIndexChanged) + signals.append(self.form.useCompensation.clicked) + signals.append(self.form.useStartPoint.clicked) + signals.append(self.form.extraOffset.editingFinished) + + if FeatureSide & self.profileFeatures(): + signals.append(self.form.cutSide.currentIndexChanged) + + if FeatureProcessing & self.profileFeatures(): + signals.append(self.form.processHoles.clicked) + signals.append(self.form.processPerimeter.clicked) + signals.append(self.form.processCircles.clicked) + + return signals diff --git a/src/Mod/Path/PathScripts/PathProfileEdgesGui.py b/src/Mod/Path/PathScripts/PathProfileEdgesGui.py index c4be5ff2f5..66d3f06450 100644 --- a/src/Mod/Path/PathScripts/PathProfileEdgesGui.py +++ b/src/Mod/Path/PathScripts/PathProfileEdgesGui.py @@ -23,53 +23,16 @@ # *************************************************************************** import FreeCAD -import FreeCADGui -import Path import PathScripts.PathAreaOpGui as PathAreaOpGui -import PathScripts.PathLog as PathLog +import PathScripts.PathProfileBaseGui as PathProfileBaseGui import PathScripts.PathProfileEdges as PathProfileEdges -import PathScripts.PathSelection as PathSelection -from PathScripts import PathUtils -from PySide import QtCore, QtGui - -def translate(context, text, disambig=None): - return QtCore.QCoreApplication.translate(context, text, disambig) - -class TaskPanelOpPage(PathAreaOpGui.TaskPanelPage): - - def getForm(self): - return FreeCADGui.PySideUic.loadUi(":/panels/PageOpProfileEdgesEdit.ui") - - def getFields(self, obj): - self.obj.OffsetExtra = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value - self.obj.UseComp = self.form.useCompensation.isChecked() - self.obj.UseStartPoint = self.form.useStartPoint.isChecked() - self.obj.Side = str(self.form.cutSide.currentText()) - self.obj.Direction = str(self.form.direction.currentText()) - - tc = PathUtils.findToolController(self.obj, self.form.toolController.currentText()) - self.obj.ToolController = tc - - def setFields(self, obj): - self.form.extraOffset.setText(FreeCAD.Units.Quantity(self.obj.OffsetExtra.Value, FreeCAD.Units.Length).UserString) - self.form.useCompensation.setChecked(self.obj.UseComp) - self.form.useStartPoint.setChecked(self.obj.UseStartPoint) - - self.selectInComboBox(self.obj.Side, self.form.cutSide) - self.selectInComboBox(self.obj.Direction, self.form.direction) - self.setupToolController(self.obj, self.form.toolController) - - def getSignalsForUpdate(self, obj): - signals = [] - signals.append(self.form.cutSide.currentIndexChanged) - signals.append(self.form.direction.currentIndexChanged) - signals.append(self.form.useCompensation.clicked) - signals.append(self.form.useStartPoint.clicked) - signals.append(self.form.extraOffset.editingFinished) - return signals +from PySide import QtCore +class TaskPanelOpPage(PathProfileBaseGui.TaskPanelOpPage): + def profileFeatures(self): + return PathProfileBaseGui.FeatureSide PathAreaOpGui.SetupOperation('Profile Edges', PathProfileEdges.Create, diff --git a/src/Mod/Path/PathScripts/PathProfileFacesGui.py b/src/Mod/Path/PathScripts/PathProfileFacesGui.py index c1b8aaa285..c64182f2ff 100644 --- a/src/Mod/Path/PathScripts/PathProfileFacesGui.py +++ b/src/Mod/Path/PathScripts/PathProfileFacesGui.py @@ -23,60 +23,16 @@ # *************************************************************************** import FreeCAD -import FreeCADGui -import Path import PathScripts.PathAreaOpGui as PathAreaOpGui -import PathScripts.PathLog as PathLog +import PathScripts.PathProfileBaseGui as PathProfileBaseGui import PathScripts.PathProfileFaces as PathProfileFaces -import PathScripts.PathSelection as PathSelection -from PathScripts import PathUtils -from PySide import QtCore, QtGui +from PySide import QtCore -def translate(context, text, disambig=None): - return QtCore.QCoreApplication.translate(context, text, disambig) +class TaskPanelOpPage(PathProfileBaseGui.TaskPanelOpPage): -class TaskPanelOpPage(PathAreaOpGui.TaskPanelPage): - - def getForm(self): - return FreeCADGui.PySideUic.loadUi(":/panels/PageOpProfileFacesEdit.ui") - - def getFields(self, obj): - self.obj.OffsetExtra = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value - self.obj.UseComp = self.form.useCompensation.isChecked() - self.obj.UseStartPoint = self.form.useStartPoint.isChecked() - self.obj.Side = str(self.form.cutSide.currentText()) - self.obj.Direction = str(self.form.direction.currentText()) - self.obj.processHoles = self.form.processHoles.isChecked() - self.obj.processPerimeter = self.form.processPerimeter.isChecked() - self.obj.processCircles = self.form.processCircles.isChecked() - - tc = PathUtils.findToolController(self.obj, self.form.toolController.currentText()) - self.obj.ToolController = tc - - def setFields(self, obj): - self.form.extraOffset.setText(FreeCAD.Units.Quantity(self.obj.OffsetExtra.Value, FreeCAD.Units.Length).UserString) - self.form.useCompensation.setChecked(self.obj.UseComp) - self.form.useStartPoint.setChecked(self.obj.UseStartPoint) - self.form.processHoles.setChecked(self.obj.processHoles) - self.form.processPerimeter.setChecked(self.obj.processPerimeter) - self.form.processCircles.setChecked(self.obj.processCircles) - - self.selectInComboBox(self.obj.Side, self.form.cutSide) - self.selectInComboBox(self.obj.Direction, self.form.direction) - self.setupToolController(self.obj, self.form.toolController) - - def getSignalsForUpdate(self, obj): - signals = [] - signals.append(self.form.cutSide.currentIndexChanged) - signals.append(self.form.direction.currentIndexChanged) - signals.append(self.form.useCompensation.clicked) - signals.append(self.form.useStartPoint.clicked) - signals.append(self.form.extraOffset.editingFinished) - signals.append(self.form.processHoles.clicked) - signals.append(self.form.processPerimeter.clicked) - signals.append(self.form.processCircles.clicked) - return signals + def profileFeatures(self): + return PathProfileBaseGui.FeatureSide | PathProfileBaseGui.FeatureProcessing PathAreaOpGui.SetupOperation('Profile Faces', PathProfileFaces.Create,