diff --git a/src/Mod/Path/Gui/DlgSettingsPathColor.cpp b/src/Mod/Path/Gui/DlgSettingsPathColor.cpp
index 7e301ee59..f644bf056 100644
--- a/src/Mod/Path/Gui/DlgSettingsPathColor.cpp
+++ b/src/Mod/Path/Gui/DlgSettingsPathColor.cpp
@@ -33,8 +33,8 @@ using namespace PathGui;
/* TRANSLATOR PathGui::DlgSettingsPathColor */
/**
- * Constructs a DlgSettingsObjectColor which is a child of 'parent', with the
- * name 'name' and widget flags set to 'f'
+ * Constructs a DlgSettingsObjectColor which is a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'
*/
DlgSettingsPathColor::DlgSettingsPathColor(QWidget* parent)
: PreferencePage(parent)
@@ -42,7 +42,7 @@ DlgSettingsPathColor::DlgSettingsPathColor(QWidget* parent)
this->setupUi(this);
}
-/**
+/**
* Destroys the object and frees any allocated resources
*/
DlgSettingsPathColor::~DlgSettingsPathColor()
@@ -58,6 +58,8 @@ void DlgSettingsPathColor::saveSettings()
DefaultPathLineWidth->onSave();
DefaultPathMarkerColor->onSave();
DefaultExtentsColor->onSave();
+ DefaultProbePathColor->onSave();
+ DefaultHighlightPathColor->onSave();
}
void DlgSettingsPathColor::loadSettings()
@@ -68,6 +70,8 @@ void DlgSettingsPathColor::loadSettings()
DefaultPathLineWidth->onRestore();
DefaultPathMarkerColor->onRestore();
DefaultExtentsColor->onRestore();
+ DefaultProbePathColor->onRestore();
+ DefaultHighlightPathColor->onRestore();
}
/**
diff --git a/src/Mod/Path/Gui/DlgSettingsPathColor.ui b/src/Mod/Path/Gui/DlgSettingsPathColor.ui
index 226a6d57d..fa7df4cd0 100644
--- a/src/Mod/Path/Gui/DlgSettingsPathColor.ui
+++ b/src/Mod/Path/Gui/DlgSettingsPathColor.ui
@@ -6,192 +6,255 @@
0
0
- 359
- 282
+ 310
+ 304
Path colors
-
- -
+
+
-
Default Path colors
-
-
-
-
-
-
-
-
-
- 182
- 0
-
-
-
- Default normal path color
-
-
-
- -
-
-
- The default color for new shapes
-
-
-
- 0
- 170
- 0
-
-
-
- DefaultNormalPathColor
-
-
- Mod/Path
-
-
-
- -
-
-
-
- 182
- 0
-
-
-
- Default pathline width
-
-
-
- -
-
-
- The default line thickness for new shapes
-
-
- px
-
-
- 9
-
-
- 1
-
-
- DefaultPathLineWidth
-
-
- Mod/Path
-
-
-
- -
-
-
-
- 182
- 0
-
-
-
- Default path marker color
-
-
-
- -
-
-
- The default line color for new shapes
-
-
-
- 85
- 255
- 0
-
-
-
- DefaultPathMarkerColor
-
-
- Mod/Path
-
-
-
- -
-
-
-
- 182
- 0
-
-
-
- Rapid path color
-
-
-
- -
-
-
- The default line color for new shapes
-
-
-
- 170
- 0
- 0
-
-
-
- DefaultRapidPathColor
-
-
- Mod/Path
-
-
-
- -
-
-
- Machine extents color
-
-
-
- -
-
-
- DefaultExtentsColor
-
-
- Mod/Path
-
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
+
+
-
+
+
- 28
- 20
+ 182
+ 0
-
+
+ Default normal path color
+
+
+
+ -
+
+
+ The default color for new shapes
+
+
+
+ 0
+ 170
+ 0
+
+
+
+ DefaultNormalPathColor
+
+
+ Mod/Path
+
+
+
+ -
+
+
+
+ 182
+ 0
+
+
+
+ Default pathline width
+
+
+
+ -
+
+
+ The default line thickness for new shapes
+
+
+ px
+
+
+ 9
+
+
+ 1
+
+
+ DefaultPathLineWidth
+
+
+ Mod/Path
+
+
+
+ -
+
+
+
+ 182
+ 0
+
+
+
+ Default path marker color
+
+
+
+ -
+
+
+ The default line color for new shapes
+
+
+
+ 85
+ 255
+ 0
+
+
+
+ DefaultPathMarkerColor
+
+
+ Mod/Path
+
+
+
+ -
+
+
+
+ 182
+ 0
+
+
+
+ Rapid path color
+
+
+
+ -
+
+
+ The default line color for new shapes
+
+
+
+ 170
+ 0
+ 0
+
+
+
+ DefaultRapidPathColor
+
+
+ Mod/Path
+
+
+
+ -
+
+
+
+ 182
+ 0
+
+
+
+ Probe Path color
+
+
+
+ -
+
+
+ The default line color for new shapes
+
+
+
+ 255
+ 255
+ 5
+
+
+
+ DefaultProbePathColor
+
+
+ Mod/Path
+
+
+
+ -
+
+
+ Machine extents color
+
+
+
+ -
+
+
+ DefaultExtentsColor
+
+
+ Mod/Path
+
+
+
+ -
+
+
+
+ 182
+ 0
+
+
+
+ Path Highlight Color
+
+
+
+ -
+
+
+ The default line color for new shapes
+
+
+
+ 255
+ 125
+ 0
+
+
+
+ DefaultHighlightPathColor
+
+
+ Mod/Path
+
+
+ label_6
+ DefaultNormalPathColor
+ label_9
+ DefaultPathLineWidth
+ label_10
+ DefaultPathMarkerColor
+ label_7
+ DefaultRapidPathColor
+ label
+ DefaultExtentsColor
+ label_8
+ DefaultProbePathColor
+ label_11
+ DefaultHighlightPathColor
- -
+
-
Qt::Vertical
@@ -204,6 +267,19 @@
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 7
+ 220
+
+
+
+
diff --git a/src/Mod/Path/Gui/Resources/panels/ProbeGridEdit.ui b/src/Mod/Path/Gui/Resources/panels/ProbeGridEdit.ui
new file mode 100644
index 000000000..7882265cb
--- /dev/null
+++ b/src/Mod/Path/Gui/Resources/panels/ProbeGridEdit.ui
@@ -0,0 +1,210 @@
+
+
+ Dialog
+
+
+
+ 0
+ 0
+ 273
+ 287
+
+
+
+
+ 0
+ 0
+
+
+
+ Dialog
+
+
+
+
+ 30
+ 240
+ 231
+ 32
+
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
+
+ 0
+ 0
+ 261
+ 231
+
+
+
+ -
+
+
+
-
+
+
+ Probe Area Shape
+
+
+
+ -
+
+
-
+
+ BoundBox
+
+
+ -
+
+ Perimeter
+
+
+
+
+
+
+
+ -
+
+
+
-
+
+
+ Probe Distance
+
+
+
+ -
+
+
+ 0.100000000000000
+
+
+ 5.000000000000000
+
+
+
+
+
+
+ -
+
+
+
-
+
+
+ Probe Feed Rate
+
+
+
+ -
+
+
+ 50.000000000000000
+
+
+
+
+
+
+ -
+
+
+ Probe Points:
+
+
+
+ -
+
+
+
-
+
+
+ X:
+
+
+
+ -
+
+
+ 5
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 77
+ 20
+
+
+
+
+ -
+
+
+ Y:
+
+
+
+ -
+
+
+ 5
+
+
+
+
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ Dialog
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ Dialog
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/src/Mod/Path/Gui/ViewProviderPath.cpp b/src/Mod/Path/Gui/ViewProviderPath.cpp
index 38348eb47..e2c4322f8 100644
--- a/src/Mod/Path/Gui/ViewProviderPath.cpp
+++ b/src/Mod/Path/Gui/ViewProviderPath.cpp
@@ -83,14 +83,14 @@ ViewProviderPath::ViewProviderPath()
ADD_PROPERTY_TYPE(LineWidth,(lwidth),"Path",App::Prop_None,"The line width of this path");
ADD_PROPERTY_TYPE(ShowFirstRapid,(true),"Path",App::Prop_None,"Turns the display of the first rapid move on/off");
ADD_PROPERTY_TYPE(ShowNodes,(false),"Path",App::Prop_None,"Turns the display of nodes on/off");
-
+
pcPathRoot = new Gui::SoFCSelection();
pcPathRoot->style = Gui::SoFCSelection::EMISSIVE;
pcPathRoot->highlightMode = Gui::SoFCSelection::AUTO;
pcPathRoot->selectionMode = Gui::SoFCSelection::SEL_ON;
pcPathRoot->ref();
-
+
pcTransform = new SoTransform();
pcTransform->ref();
@@ -99,7 +99,7 @@ ViewProviderPath::ViewProviderPath()
pcMarkerCoords = new SoCoordinate3();
pcMarkerCoords->ref();
-
+
pcDrawStyle = new SoDrawStyle();
pcDrawStyle->ref();
pcDrawStyle->style = SoDrawStyle::LINES;
@@ -108,17 +108,17 @@ ViewProviderPath::ViewProviderPath()
pcLines = new PartGui::SoBrepEdgeSet();
pcLines->ref();
pcLines->coordIndex.setNum(0);
-
+
pcLineColor = new SoMaterial;
pcLineColor->ref();
-
+
pcMatBind = new SoMaterialBinding;
pcMatBind->ref();
pcMatBind->value = SoMaterialBinding::OVERALL;
pcMarkerColor = new SoBaseColor;
pcMarkerColor->ref();
-
+
NormalColor.touch();
MarkerColor.touch();
}
@@ -186,12 +186,16 @@ void ViewProviderPath::onChanged(const App::Property* prop)
pcDrawStyle->lineWidth = LineWidth.getValue();
} else if (prop == &NormalColor) {
if (colorindex.size() > 0) {
- const App::Color& c = NormalColor.getValue();
+ const App::Color& c = NormalColor.getValue();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Path");
unsigned long rcol = hGrp->GetUnsigned("DefaultRapidPathColor",2852126975UL); // dark red (170,0,0)
float rr,rg,rb;
rr = ((rcol >> 24) & 0xff) / 255.0; rg = ((rcol >> 16) & 0xff) / 255.0; rb = ((rcol >> 8) & 0xff) / 255.0;
-
+
+ unsigned long pcol = hGrp->GetUnsigned("DefaultProbePathColor",4293591295UL); // yellow (255,255,5)
+ float pr,pg,pb;
+ pr = ((pcol >> 24) & 0xff) / 255.0; pg = ((pcol >> 16) & 0xff) / 255.0; pb = ((pcol >> 8) & 0xff) / 255.0;
+
pcMatBind->value = SoMaterialBinding::PER_PART;
// resizing and writing the color vector:
pcLineColor->diffuseColor.setNum(colorindex.size());
@@ -199,8 +203,10 @@ void ViewProviderPath::onChanged(const App::Property* prop)
for(unsigned int i=0;idiffuseColor.finishEditing();
}
@@ -220,14 +226,14 @@ void ViewProviderPath::updateData(const App::Property* prop)
Path::Feature* pcPathObj = static_cast(pcObject);
if (prop == &pcPathObj->Path) {
-
+
const Toolpath &tp = pcPathObj->Path.getValue();
if(tp.getSize()==0) {
pcLineCoords->point.deleteValues(0);
pcMarkerCoords->point.deleteValues(0);
return;
}
-
+
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part");
float deviation = hGrp->GetFloat("MeshDeviation",0.2);
std::vector points;
@@ -237,7 +243,7 @@ void ViewProviderPath::updateData(const App::Property* prop)
bool absolute = true;
bool absolutecenter = false;
bool first = true;
-
+
for (unsigned int i = 0; i < tp.getSize(); i++) {
Path::Command cmd = tp.getCommand(i);
std::string name = cmd.Name;
@@ -250,7 +256,7 @@ void ViewProviderPath::updateData(const App::Property* prop)
next.y = last.y;
if (!cmd.has("Z"))
next.z = last.z;
-
+
if ( (name == "G0") || (name == "G00") || (name == "G1") || (name == "G01") ) {
// straight line
if ( (!first) || (ShowFirstRapid.getValue() == true) || (name == "G1") || (name == "G01") ) {
@@ -273,12 +279,12 @@ void ViewProviderPath::updateData(const App::Property* prop)
markers.push_back(last); // startpoint of path
}
first = false;
-
+
} else if ( (name == "G2") || (name == "G02") || (name == "G3") || (name == "G03") ) {
// arc
Base::Vector3d norm;
Base::Vector3d center;
-
+
if ( (name == "G2") || (name == "G02") )
norm.Set(0,0,-1);
else
@@ -321,23 +327,23 @@ void ViewProviderPath::updateData(const App::Property* prop)
}
last = next;
colorindex.push_back(1);
-
+
} else if (name == "G90") {
// absolute mode
absolute = true;
-
+
} else if (name == "G91") {
// relative mode
absolute = false;
-
+
} else if (name == "G90.1") {
// absolute mode
absolutecenter = true;
-
+
} else if (name == "G91.1") {
// relative mode
absolutecenter = false;
-
+
} else if ((name=="G81")||(name=="G82")||(name=="G83")||(name=="G84")||(name=="G85")||(name=="G86")||(name=="G89")){
// drill,tap,bore
double r = 0;
@@ -373,9 +379,19 @@ void ViewProviderPath::updateData(const App::Property* prop)
if (ShowNodes.getValue() == true)
markers.push_back(p2);
colorindex.push_back(0);
- }
- }
-
+
+ } else if ((name=="G38.2")||(name=="38.3")||(name=="G38.4")||(name=="G38.5")){
+ // Straight probe
+ Base::Vector3d p1(next.x,next.y,last.z);
+ points.push_back(p1);
+ colorindex.push_back(0);
+ points.push_back(next);
+ colorindex.push_back(2);
+ Base::Vector3d p3(next.x,next.y,last.z);
+ points.push_back(p3);
+ colorindex.push_back(0);
+ }}
+
if (!points.empty()) {
pcLineCoords->point.deleteValues(0);
pcLineCoords->point.setNum(points.size());
@@ -387,20 +403,20 @@ void ViewProviderPath::updateData(const App::Property* prop)
int* segs = &ei[0];
pcLines->coordIndex.setNum(points.size());
pcLines->coordIndex.setValues(0,points.size(),(const int32_t*)segs);
-
+
pcMarkerCoords->point.deleteValues(0);
-
+
pcMarkerCoords->point.setNum(markers.size());
for(unsigned int i=0;ipoint.set1Value(i,markers[i].x,markers[i].y,markers[i].z);
-
+
// update the coloring after we changed the color vector
NormalColor.touch();
recomputeBoundingBox();
}
-
+
} else if ( prop == &pcPathObj->Placement) {
-
+
Base::Placement pl = *(&pcPathObj->Placement.getValue());
Base::Vector3d pos = pl.getPosition();
double q1, q2, q3, q4;
diff --git a/src/Mod/Path/PathScripts/PathInspect.py b/src/Mod/Path/PathScripts/PathInspect.py
index 6c2125b3a..4fbc473dd 100644
--- a/src/Mod/Path/PathScripts/PathInspect.py
+++ b/src/Mod/Path/PathScripts/PathInspect.py
@@ -25,7 +25,7 @@
from PySide import QtCore, QtGui
import FreeCAD
import FreeCADGui
-
+import Path
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
@@ -110,11 +110,21 @@ class GCodeHighlighter(QtGui.QSyntaxHighlighter):
class GCodeEditorDialog(QtGui.QDialog):
- def __init__(self, parent=FreeCADGui.getMainWindow()):
-
+ def __init__(self, PathObj, parent=FreeCADGui.getMainWindow()):
+ self.PathObj = PathObj
QtGui.QDialog.__init__(self, parent)
layout = QtGui.QVBoxLayout(self)
+ p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
+ c = p.GetUnsigned("DefaultHighlightPathColor", 4286382335 )
+ Q = QtGui.QColor(int((c >> 24) & 0xFF), int((c >> 16) & 0xFF), int((c >> 8) & 0xFF))
+ highlightcolor = (Q.red()/255., Q.green()/255., Q.blue()/255., Q.alpha()/255.)
+
+ self.selectionobj = FreeCAD.ActiveDocument.addObject("Path::Feature","selection")
+ self.selectionobj.ViewObject.LineWidth = 4
+ self.selectionobj.ViewObject.NormalColor = highlightcolor
+ self.selectionobj.ViewObject.ShowFirstRapid = False
+
# nice text editor widget for editing the gcode
self.editor = QtGui.QTextEdit()
font = QtGui.QFont()
@@ -140,6 +150,53 @@ class GCodeEditorDialog(QtGui.QDialog):
layout.addWidget(self.buttons)
self.buttons.accepted.connect(self.accept)
self.buttons.rejected.connect(self.reject)
+ self.editor.selectionChanged.connect(self.hightlightpath)
+ self.finished.connect(self.cleanup)
+
+ def cleanup(self):
+ FreeCAD.ActiveDocument.removeObject(self.selectionobj.Name)
+
+ def hightlightpath(self):
+ cursor = self.editor.textCursor()
+ sp = cursor.selectionStart()
+ ep = cursor.selectionEnd()
+ cursor.setPosition(sp)
+ startrow = cursor.blockNumber()
+ cursor.setPosition(ep)
+ endrow = cursor.blockNumber()
+
+ commands = self.PathObj.Commands
+
+ #Derive the starting position for the first selected command
+ prevX = prevY = prevZ = None
+ prevcommands = commands[:startrow]
+ prevcommands.reverse()
+ for c in prevcommands:
+ if prevX is None:
+ if c.Parameters.get("X") is not None:
+ prevX = c.Parameters.get("X")
+ if prevY is None:
+ if c.Parameters.get("Y") is not None:
+ prevY = c.Parameters.get("Y")
+ if prevZ is None:
+ if c.Parameters.get("Z") is not None:
+ prevZ = c.Parameters.get("Z")
+ if prevX is not None and prevY is not None and prevZ is not None:
+ break
+ if prevX is None:
+ prevX = 0.0
+ if prevY is None:
+ prevY = 0.0
+ if prevZ is None:
+ prevZ = 0.0
+
+ #Build a new path with selection
+ p = Path.Path()
+ firstrapid = Path.Command("G0", {"X": prevX, "Y":prevY, "Z":prevZ})
+
+ selectionpath = [firstrapid] + commands[startrow:endrow +1]
+ p.Commands = selectionpath
+ self.selectionobj.Path = p
def show(obj):
@@ -147,7 +204,7 @@ def show(obj):
if hasattr(obj, "Path"):
if obj.Path:
- dia = GCodeEditorDialog()
+ dia = GCodeEditorDialog(obj.Path)
dia.editor.setText(obj.Path.toGCode())
result = dia.exec_()
# exec_() returns 0 or 1 depending on the button pressed (Ok or