Path: Consolidate available tool types and material types to one place. Fixes issue #3335
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="PersistencePy"
|
||||
Name="ToolPy"
|
||||
Twin="Tool"
|
||||
TwinPointer="Tool"
|
||||
Include="Mod/Path/App/Tooltable.h"
|
||||
Namespace="Path"
|
||||
FatherInclude="Base/PersistencePy.h"
|
||||
<PythonExport
|
||||
Father="PersistencePy"
|
||||
Name="ToolPy"
|
||||
Twin="Tool"
|
||||
TwinPointer="Tool"
|
||||
Include="Mod/Path/App/Tooltable.h"
|
||||
Namespace="Path"
|
||||
FatherInclude="Base/PersistencePy.h"
|
||||
FatherNamespace="Base"
|
||||
Constructor="true"
|
||||
Delete="true">
|
||||
@@ -16,7 +16,7 @@
|
||||
<UserDocu>The Tool objects holds the properties of a CNC tool.
|
||||
optional attributes:
|
||||
name: a user-defined name for this tool
|
||||
tooltype: Drill, CenterDrill, CounterSink, CounterBore, Reamer, Tap, EndMill, SlotCutter, BallEndMill, ChamferMill, CornerRound, Engraver or Undefined
|
||||
tooltype: Drill, CenterDrill, CounterSink, CounterBore, Reamer, Tap, EndMill, SlotCutter, BallEndMill, ChamferMill, CornerRound, Engraver or Undefined
|
||||
material: HighSpeedSteel, HighCarbonToolSteel, Carbide, CastAlloy, Ceramics, Diamond, Sialon or Undefined
|
||||
diameter : the diameter of this tool
|
||||
lengthOffset
|
||||
@@ -86,6 +86,16 @@ HighCarbonToolSteel CastAlloy, Ceramics, Diamond, Sialon or Undefined</UserDocu>
|
||||
<UserDocu>returns a copy of this tool</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getToolTypes">
|
||||
<Documentation>
|
||||
<UserDocu>returns all available tool types</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getToolMaterials">
|
||||
<Documentation>
|
||||
<UserDocu>returns all available tool materials</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setFromTemplate">
|
||||
<Documentation>
|
||||
<UserDocu>setFromTemplate(xmlString|dictionary) ... fills receiver with values from the template string or dictionary</UserDocu>
|
||||
|
||||
@@ -45,7 +45,7 @@ TYPESYSTEM_SOURCE(Path::Tool , Base::Persistence);
|
||||
Tool::Tool(const char* name,
|
||||
ToolType type,
|
||||
ToolMaterial /*material*/,
|
||||
double diameter,
|
||||
double diameter,
|
||||
double lengthoffset,
|
||||
double flatradius,
|
||||
double cornerradius,
|
||||
@@ -108,6 +108,49 @@ void Tool::Restore(XMLReader &reader)
|
||||
std::string type = reader.hasAttribute("type") ? reader.getAttribute("type") : "";
|
||||
std::string mat = reader.hasAttribute("mat") ? reader.getAttribute("mat") : "";
|
||||
|
||||
Type = getToolType(type);
|
||||
Material = getToolMaterial(mat);
|
||||
|
||||
|
||||
}
|
||||
|
||||
const std::vector<std::string> Tool::ToolTypes(void)
|
||||
{
|
||||
std::vector<std::string> toolTypes(13);
|
||||
toolTypes[0] ="EndMill";
|
||||
toolTypes[1] ="Drill";
|
||||
toolTypes[2] ="CenterDrill";
|
||||
toolTypes[3] ="CounterSink";
|
||||
toolTypes[4] ="CounterBore";
|
||||
toolTypes[5] ="FlyCutter";
|
||||
toolTypes[6] ="Reamer";
|
||||
toolTypes[7] ="Tap";
|
||||
toolTypes[8] ="SlotCutter";
|
||||
toolTypes[9] ="BallEndMill";
|
||||
toolTypes[10] ="ChamferMill";
|
||||
toolTypes[11] ="CornerRound";
|
||||
toolTypes[12] ="Engraver";
|
||||
return toolTypes;
|
||||
|
||||
}
|
||||
|
||||
const std::vector<std::string> Tool::ToolMaterials(void)
|
||||
{
|
||||
std::vector<std::string> toolMat(7);
|
||||
toolMat[0] ="Carbide";
|
||||
toolMat[1] ="HighSpeedSteel";
|
||||
toolMat[2] ="HighCarbonToolSteel";
|
||||
toolMat[3] ="CastAlloy";
|
||||
toolMat[4] ="Ceramics";
|
||||
toolMat[5] ="Diamond";
|
||||
toolMat[6] ="Sialon";
|
||||
return toolMat;
|
||||
|
||||
}
|
||||
|
||||
Tool::ToolType Tool::getToolType(std::string type)
|
||||
{
|
||||
Tool::ToolType Type;
|
||||
if(type=="EndMill")
|
||||
Type = Tool::ENDMILL;
|
||||
else if(type=="Drill")
|
||||
@@ -118,6 +161,8 @@ void Tool::Restore(XMLReader &reader)
|
||||
Type = Tool::COUNTERSINK;
|
||||
else if(type=="CounterBore")
|
||||
Type = Tool::COUNTERBORE;
|
||||
else if(type=="FlyCutter")
|
||||
Type = Tool::FLYCUTTER;
|
||||
else if(type=="Reamer")
|
||||
Type = Tool::REAMER;
|
||||
else if(type=="Tap")
|
||||
@@ -132,9 +177,15 @@ void Tool::Restore(XMLReader &reader)
|
||||
Type = Tool::CORNERROUND;
|
||||
else if(type=="Engraver")
|
||||
Type = Tool::ENGRAVER;
|
||||
else
|
||||
else
|
||||
Type = Tool::UNDEFINED;
|
||||
|
||||
|
||||
return Type;
|
||||
}
|
||||
|
||||
Tool::ToolMaterial Tool::getToolMaterial(std::string mat)
|
||||
{
|
||||
Tool::ToolMaterial Material;
|
||||
if(mat=="Carbide")
|
||||
Material = Tool::CARBIDE;
|
||||
else if(mat=="HighSpeedSteel")
|
||||
@@ -151,6 +202,8 @@ void Tool::Restore(XMLReader &reader)
|
||||
Material = Tool::SIALON;
|
||||
else
|
||||
Material = Tool::MATUNDEFINED;
|
||||
|
||||
return Material;
|
||||
}
|
||||
|
||||
const char* Tool::TypeName(Tool::ToolType typ) {
|
||||
@@ -163,6 +216,8 @@ const char* Tool::TypeName(Tool::ToolType typ) {
|
||||
return "CounterSink";
|
||||
case Tool::COUNTERBORE:
|
||||
return "CounterBore";
|
||||
case Tool::FLYCUTTER:
|
||||
return "FlyCutter";
|
||||
case Tool::REAMER:
|
||||
return "Reamer";
|
||||
case Tool::TAP:
|
||||
@@ -292,7 +347,3 @@ void Tooltable::Restore (XMLReader &reader)
|
||||
Tools[id] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -31,12 +31,12 @@
|
||||
|
||||
namespace Path
|
||||
{
|
||||
|
||||
|
||||
/** The representation of a single tool */
|
||||
class PathExport Tool : public Base::Persistence
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
|
||||
|
||||
public:
|
||||
enum ToolType {
|
||||
UNDEFINED,
|
||||
@@ -44,6 +44,7 @@ namespace Path
|
||||
CENTERDRILL,
|
||||
COUNTERSINK,
|
||||
COUNTERBORE,
|
||||
FLYCUTTER,
|
||||
REAMER,
|
||||
TAP,
|
||||
ENDMILL,
|
||||
@@ -52,7 +53,7 @@ namespace Path
|
||||
CHAMFERMILL,
|
||||
CORNERROUND,
|
||||
ENGRAVER };
|
||||
|
||||
|
||||
enum ToolMaterial {
|
||||
MATUNDEFINED,
|
||||
HIGHSPEEDSTEEL,
|
||||
@@ -62,25 +63,25 @@ namespace Path
|
||||
CERAMICS,
|
||||
DIAMOND,
|
||||
SIALON };
|
||||
|
||||
|
||||
//constructors
|
||||
Tool();
|
||||
Tool(const char* name,
|
||||
Tool(const char* name,
|
||||
ToolType type=Tool::UNDEFINED,
|
||||
ToolMaterial material=Tool::MATUNDEFINED,
|
||||
double diameter=10.0,
|
||||
double diameter=10.0,
|
||||
double lengthoffset=100,
|
||||
double flatradius=0,
|
||||
double cornerradius=0,
|
||||
double cuttingedgeangle=0,
|
||||
double cuttingedgeheight=0);
|
||||
~Tool();
|
||||
|
||||
|
||||
// from base class
|
||||
virtual unsigned int getMemSize (void) const;
|
||||
virtual void Save (Base::Writer &/*writer*/) const;
|
||||
virtual void Restore(Base::XMLReader &/*reader*/);
|
||||
|
||||
|
||||
// attributes
|
||||
std::string Name;
|
||||
ToolType Type;
|
||||
@@ -91,21 +92,25 @@ namespace Path
|
||||
double CornerRadius;
|
||||
double CuttingEdgeAngle;
|
||||
double CuttingEdgeHeight;
|
||||
|
||||
|
||||
static const std::vector<std::string> ToolTypes(void);
|
||||
static const std::vector<std::string> ToolMaterials(void);
|
||||
static const char* TypeName(ToolType typ);
|
||||
static ToolType getToolType(std::string type);
|
||||
static ToolMaterial getToolMaterial(std::string mat);
|
||||
static const char* MaterialName(ToolMaterial mat);
|
||||
};
|
||||
|
||||
|
||||
/** The representation of a table of tools */
|
||||
class PathExport Tooltable : public Base::Persistence
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
|
||||
|
||||
public:
|
||||
//constructors
|
||||
Tooltable();
|
||||
~Tooltable();
|
||||
|
||||
|
||||
// from base class
|
||||
virtual unsigned int getMemSize (void) const;
|
||||
virtual void Save (Base::Writer &/*writer*/) const;
|
||||
@@ -115,7 +120,7 @@ namespace Path
|
||||
void addTool(const Tool &tool); // adds a tool at the end
|
||||
void setTool(const Tool &tool, int); // inserts a tool
|
||||
void deleteTool(int); // deletes a tool
|
||||
|
||||
|
||||
// auto
|
||||
unsigned int getSize(void) const {return Tools.size();}
|
||||
const Tool &getTool(int pos) {return *Tools[pos];}
|
||||
@@ -125,7 +130,7 @@ namespace Path
|
||||
// attributes
|
||||
std::map<int,Tool*> Tools;
|
||||
};
|
||||
|
||||
|
||||
} //namespace Path
|
||||
|
||||
#endif // PATH_TOOLTABLE_H
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="PersistencePy"
|
||||
Name="TooltablePy"
|
||||
Twin="Tooltable"
|
||||
TwinPointer="Tooltable"
|
||||
Include="Mod/Path/App/Tooltable.h"
|
||||
Namespace="Path"
|
||||
FatherInclude="Base/PersistencePy.h"
|
||||
<PythonExport
|
||||
Father="PersistencePy"
|
||||
Name="TooltablePy"
|
||||
Twin="Tooltable"
|
||||
TwinPointer="Tooltable"
|
||||
Include="Mod/Path/App/Tooltable.h"
|
||||
Namespace="Path"
|
||||
FatherInclude="Base/PersistencePy.h"
|
||||
FatherNamespace="Base"
|
||||
Constructor="true"
|
||||
Delete="true">
|
||||
|
||||
@@ -51,7 +51,7 @@ std::string ToolPy::representation(void) const
|
||||
|
||||
PyObject *ToolPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
{
|
||||
// create a new instance of ToolPy and the Twin object
|
||||
// create a new instance of ToolPy and the Twin object
|
||||
return new ToolPy(new Tool);
|
||||
}
|
||||
|
||||
@@ -93,51 +93,12 @@ int ToolPy::PyInit(PyObject* args, PyObject* kwd)
|
||||
}
|
||||
|
||||
getToolPtr()->Name = name;
|
||||
|
||||
std::string typeStr(type);
|
||||
if(typeStr=="Drill")
|
||||
getToolPtr()->Type = Tool::DRILL;
|
||||
else if(typeStr=="CenterDrill")
|
||||
getToolPtr()->Type = Tool::CENTERDRILL;
|
||||
if(typeStr=="CounterSink")
|
||||
getToolPtr()->Type = Tool::COUNTERSINK;
|
||||
if(typeStr=="CounterBore")
|
||||
getToolPtr()->Type = Tool::COUNTERBORE;
|
||||
if(typeStr=="Reamer")
|
||||
getToolPtr()->Type = Tool::REAMER;
|
||||
if(typeStr=="Tap")
|
||||
getToolPtr()->Type = Tool::TAP;
|
||||
else if(typeStr=="EndMill")
|
||||
getToolPtr()->Type = Tool::ENDMILL;
|
||||
else if(typeStr=="SlotCutter")
|
||||
getToolPtr()->Type = Tool::SLOTCUTTER;
|
||||
else if(typeStr=="BallEndMill")
|
||||
getToolPtr()->Type = Tool::BALLENDMILL;
|
||||
else if(typeStr=="ChamferMill")
|
||||
getToolPtr()->Type = Tool::CHAMFERMILL;
|
||||
else if(typeStr=="CornerRound")
|
||||
getToolPtr()->Type = Tool::CORNERROUND;
|
||||
else if(typeStr=="Engraver")
|
||||
getToolPtr()->Type = Tool::ENGRAVER;
|
||||
else
|
||||
getToolPtr()->Type = Tool::UNDEFINED;
|
||||
|
||||
getToolPtr()->Type = Tool::getToolType(typeStr);
|
||||
|
||||
std::string matStr(mat);
|
||||
if(matStr=="HighSpeedSteel")
|
||||
getToolPtr()->Material = Tool::HIGHSPEEDSTEEL;
|
||||
else if(matStr=="Carbide")
|
||||
getToolPtr()->Material = Tool::CARBIDE;
|
||||
else if(matStr=="HighCarbonToolSteel")
|
||||
getToolPtr()->Material = Tool::HIGHCARBONTOOLSTEEL;
|
||||
else if(matStr=="CastAlloy")
|
||||
getToolPtr()->Material = Tool::CASTALLOY;
|
||||
else if(matStr=="Ceramics")
|
||||
getToolPtr()->Material = Tool::CERAMICS;
|
||||
else if(matStr=="Diamond")
|
||||
getToolPtr()->Material = Tool::DIAMOND;
|
||||
else if(matStr=="Sialon")
|
||||
getToolPtr()->Material = Tool::SIALON;
|
||||
else
|
||||
getToolPtr()->Material = Tool::MATUNDEFINED;
|
||||
getToolPtr()->Material = Tool::getToolMaterial(matStr);
|
||||
|
||||
getToolPtr()->Diameter = dia ? PyFloat_AsDouble(dia) : 0.0;
|
||||
getToolPtr()->LengthOffset = len ? PyFloat_AsDouble(len) : 0.0;
|
||||
@@ -170,33 +131,8 @@ Py::String ToolPy::getToolType(void) const
|
||||
void ToolPy::setToolType(Py::String arg)
|
||||
{
|
||||
std::string typeStr(arg.as_std_string());
|
||||
if(typeStr=="Drill")
|
||||
getToolPtr()->Type = Tool::DRILL;
|
||||
else if(typeStr=="CenterDrill")
|
||||
getToolPtr()->Type = Tool::CENTERDRILL;
|
||||
else if(typeStr=="CounterSink")
|
||||
getToolPtr()->Type = Tool::COUNTERSINK;
|
||||
else if(typeStr=="CounterBore")
|
||||
getToolPtr()->Type = Tool::COUNTERBORE;
|
||||
else if(typeStr=="Reamer")
|
||||
getToolPtr()->Type = Tool::REAMER;
|
||||
else if(typeStr=="Tap")
|
||||
getToolPtr()->Type = Tool::TAP;
|
||||
else if(typeStr=="EndMill")
|
||||
getToolPtr()->Type = Tool::ENDMILL;
|
||||
else if(typeStr=="SlotCutter")
|
||||
getToolPtr()->Type = Tool::SLOTCUTTER;
|
||||
else if(typeStr=="BallEndMill")
|
||||
getToolPtr()->Type = Tool::BALLENDMILL;
|
||||
else if(typeStr=="ChamferMill")
|
||||
getToolPtr()->Type = Tool::CHAMFERMILL;
|
||||
else if(typeStr=="CornerRound")
|
||||
getToolPtr()->Type = Tool::CORNERROUND;
|
||||
getToolPtr()->Type = Tool::getToolType(typeStr);
|
||||
|
||||
else if(typeStr=="Engraver")
|
||||
getToolPtr()->Type = Tool::ENGRAVER;
|
||||
else
|
||||
getToolPtr()->Type = Tool::UNDEFINED;
|
||||
}
|
||||
|
||||
Py::String ToolPy::getMaterial(void) const
|
||||
@@ -207,22 +143,7 @@ Py::String ToolPy::getMaterial(void) const
|
||||
void ToolPy::setMaterial(Py::String arg)
|
||||
{
|
||||
std::string matStr(arg.as_std_string());
|
||||
if(matStr=="HighSpeedSteel")
|
||||
getToolPtr()->Material = Tool::HIGHSPEEDSTEEL;
|
||||
else if(matStr=="Carbide")
|
||||
getToolPtr()->Material = Tool::CARBIDE;
|
||||
else if(matStr=="HighCarbonToolSteel")
|
||||
getToolPtr()->Material = Tool::HIGHCARBONTOOLSTEEL;
|
||||
else if(matStr=="CastAlloy")
|
||||
getToolPtr()->Material = Tool::CASTALLOY;
|
||||
else if(matStr=="Ceramics")
|
||||
getToolPtr()->Material = Tool::CERAMICS;
|
||||
else if(matStr=="Diamond")
|
||||
getToolPtr()->Material = Tool::DIAMOND;
|
||||
else if(matStr=="Sialon")
|
||||
getToolPtr()->Material = Tool::SIALON;
|
||||
else
|
||||
getToolPtr()->Material = Tool::MATUNDEFINED;
|
||||
getToolPtr()->Material = Tool::getToolMaterial(matStr);
|
||||
}
|
||||
|
||||
Py::Float ToolPy::getDiameter(void) const
|
||||
@@ -294,7 +215,7 @@ PyObject *ToolPy::getCustomAttributes(const char* /*attr*/) const
|
||||
|
||||
int ToolPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject* ToolPy::copy(PyObject * args)
|
||||
@@ -305,7 +226,6 @@ PyObject* ToolPy::copy(PyObject * args)
|
||||
throw Py::Exception("This method accepts no argument");
|
||||
}
|
||||
|
||||
|
||||
PyObject* ToolPy::setFromTemplate(PyObject * args)
|
||||
{
|
||||
char *pstr = 0;
|
||||
@@ -359,6 +279,35 @@ PyObject* ToolPy::templateAttrs(PyObject * args)
|
||||
throw Py::Exception("This method accepts no argument");
|
||||
}
|
||||
|
||||
PyObject* ToolPy::getToolTypes(PyObject * args)
|
||||
{
|
||||
if (PyArg_ParseTuple(args, "")) {
|
||||
std::vector<std::string> toolTypes = Tool::ToolTypes();
|
||||
PyObject *list = PyList_New(0);
|
||||
for(unsigned i = 0; i != toolTypes.size(); i++) {
|
||||
|
||||
PyList_Append(list, PYSTRING_FROMSTRING(toolTypes[i].c_str()));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
throw Py::Exception("This method accepts no argument");
|
||||
}
|
||||
|
||||
PyObject* ToolPy::getToolMaterials(PyObject * args)
|
||||
{
|
||||
if (PyArg_ParseTuple(args, "")) {
|
||||
std::vector<std::string> toolMaterials = Tool::ToolMaterials();
|
||||
PyObject *list = PyList_New(0);
|
||||
for(unsigned i = 0; i != toolMaterials.size(); i++) {
|
||||
|
||||
PyList_Append(list, PYSTRING_FROMSTRING(toolMaterials[i].c_str()));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
throw Py::Exception("This method accepts no argument");
|
||||
}
|
||||
|
||||
|
||||
// TooltablePy
|
||||
|
||||
|
||||
@@ -544,7 +493,7 @@ PyObject *TooltablePy::getCustomAttributes(const char* /*attr*/) const
|
||||
|
||||
int TooltablePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -52,71 +52,7 @@
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Drill</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>CenterDrill</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>CounterSink</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>CounterBore</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Flycutter</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Reamer</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Tap</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>EndMill</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>SlotCutter</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>BallEndMill</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>ChamferMill</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>CornerRound</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Engraver</string>
|
||||
</property>
|
||||
</item>
|
||||
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
@@ -128,41 +64,7 @@
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="MaterialField">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>HighSpeedSteel</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>HighCarbonSteel</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>CastAlloy</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Carbide</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Ceramics</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Diamond</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Sialon</string>
|
||||
</property>
|
||||
</item>
|
||||
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
|
||||
@@ -415,9 +415,7 @@ class EditorPanel():
|
||||
|
||||
def getType(self, tooltype):
|
||||
"gets a combobox index number for a given type or viceversa"
|
||||
toolslist = ["Drill", "CenterDrill", "CounterSink", "CounterBore",
|
||||
"Reamer", "Tap", "EndMill", "SlotCutter", "BallEndMill",
|
||||
"ChamferMill", "CornerRound", "Engraver"]
|
||||
toolslist = Path.Tool.getToolTypes(Path.Tool())
|
||||
if isinstance(tooltype, str):
|
||||
if tooltype in toolslist:
|
||||
return toolslist.index(tooltype)
|
||||
@@ -428,8 +426,7 @@ class EditorPanel():
|
||||
|
||||
def getMaterial(self, material):
|
||||
"gets a combobox index number for a given material or viceversa"
|
||||
matslist = ["HighSpeedSteel", "HighCarbonToolSteel", "CastAlloy",
|
||||
"Carbide", "Ceramics", "Diamond", "Sialon"]
|
||||
matslist = Path.Tool.getToolMaterials(Path.Tool())
|
||||
if isinstance(material, str):
|
||||
if material in matslist:
|
||||
return matslist.index(material)
|
||||
@@ -441,6 +438,13 @@ class EditorPanel():
|
||||
def addTool(self):
|
||||
t = Path.Tool()
|
||||
editform = FreeCADGui.PySideUic.loadUi(":/panels/ToolEdit.ui")
|
||||
editform.TypeField.clear()
|
||||
for tooltype in Path.Tool.getToolTypes(t):
|
||||
editform.TypeField.addItem(tooltype)
|
||||
|
||||
editform.MaterialField.clear()
|
||||
for material in Path.Tool.getToolMaterials(t):
|
||||
editform.MaterialField.addItem(material)
|
||||
|
||||
r = editform.exec_()
|
||||
if r:
|
||||
@@ -513,6 +517,14 @@ class EditorPanel():
|
||||
tool = self.TLM.getTool(listname, toolnum)
|
||||
editform = FreeCADGui.PySideUic.loadUi(":/panels/ToolEdit.ui")
|
||||
|
||||
editform.TypeField.clear()
|
||||
for tooltype in Path.Tool.getToolTypes(tool):
|
||||
editform.TypeField.addItem(tooltype)
|
||||
|
||||
editform.MaterialField.clear()
|
||||
for material in Path.Tool.getToolMaterials(tool):
|
||||
editform.MaterialField.addItem(material)
|
||||
|
||||
editform.NameField.setText(tool.Name)
|
||||
editform.TypeField.setCurrentIndex(self.getType(tool.ToolType))
|
||||
editform.MaterialField.setCurrentIndex(self.getMaterial(tool.Material))
|
||||
@@ -661,4 +673,3 @@ class CommandToolLibraryEdit():
|
||||
if FreeCAD.GuiUp:
|
||||
# register the FreeCAD command
|
||||
FreeCADGui.addCommand('Path_ToolLibraryEdit',CommandToolLibraryEdit())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user