Converted PathProfile to be based on PathAreaOp.

This commit is contained in:
Markus Lampert
2017-08-05 16:17:45 -07:00
parent 520fa8d4e3
commit 39c1320bc7
3 changed files with 290 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ INSTALL(
SET(PathScripts_SRCS
PathCommands.py
PathScripts/PathAreaOp.py
PathScripts/PathAreaOpGui.py
PathScripts/PathArray.py
PathScripts/PathCircularHoleBase.py
PathScripts/PathCircularHoleBaseGui.py

View File

@@ -0,0 +1,169 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>446</width>
<height>419</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Tool Controller</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="toolController"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Cut Side</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cutSide">
<item>
<property name="text">
<string>Outside</string>
</property>
</item>
<item>
<property name="text">
<string>Inside</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Direction</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="direction">
<item>
<property name="text">
<string>CW</string>
</property>
</item>
<item>
<property name="text">
<string>CCW</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Extra Offset</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::InputField" name="extraOffset">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QCheckBox" name="useStartPoint">
<property name="text">
<string>Use Start Point</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="processHoles">
<property name="text">
<string>Process Holes</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="useCompensation">
<property name="text">
<string>Use Compensation</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="processCircles">
<property name="text">
<string>Process Cirles</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="processPerimeter">
<property name="text">
<string>Process Perimeter</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::InputField</class>
<extends>QLineEdit</extends>
<header>Gui/InputField.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,120 @@
# -*- coding: utf-8 -*-
# ***************************************************************************
# * *
# * Copyright (c) 2017 sliptonic <shopinthewoods@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 *
# * *
# ***************************************************************************
import FreeCAD
import FreeCADGui
import Path
import PathScripts.PathAreaOpGui as PathAreaOpGui
import PathScripts.PathLog as PathLog
import PathScripts.PathProfile as PathProfile
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/PageOpProfileEdit.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
class ViewProviderProfile(PathAreaOpGui.ViewProvider):
def getTaskPanelOpPage(self, obj):
return TaskPanelOpPage(obj)
def getIcon(self):
return ":/icons/Path-Profile-Face.svg"
def getSelectionFactory(self):
return PathSelection.profileselect
def Create(name):
FreeCAD.ActiveDocument.openTransaction(translate("Path", "Create a Profile"))
obj = PathProfile.Create(name)
vobj = ViewProviderProfile(obj.ViewObject)
FreeCAD.ActiveDocument.commitTransaction()
obj.ViewObject.startEditing()
return obj
class CommandPathProfile:
def GetResources(self):
return {'Pixmap': 'Path-Profile-Face',
'MenuText': QtCore.QT_TRANSLATE_NOOP("PathProfile", "Face Profile"),
'Accel': "P, F",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("PathProfile", "Profile based on face or faces")}
def IsActive(self):
if FreeCAD.ActiveDocument is not None:
for o in FreeCAD.ActiveDocument.Objects:
if o.Name[:3] == "Job":
return True
return False
def Activated(self):
return Create('Profile')
FreeCADGui.addCommand('Path_Profile', CommandPathProfile())
FreeCAD.Console.PrintLog("Loading PathProfileGui... done\n")