PATH: Add support to visualize probe moves

G38.2/3/4/5
This commit is contained in:
sliptonic 2016-12-07 19:22:26 -06:00
parent 26e1a24060
commit 7d1a58e593
3 changed files with 252 additions and 201 deletions

View File

@ -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,7 @@ void DlgSettingsPathColor::saveSettings()
DefaultPathLineWidth->onSave();
DefaultPathMarkerColor->onSave();
DefaultExtentsColor->onSave();
DefaultProbePathColor->onSave();
}
void DlgSettingsPathColor::loadSettings()
@ -68,6 +69,7 @@ void DlgSettingsPathColor::loadSettings()
DefaultPathLineWidth->onRestore();
DefaultPathMarkerColor->onRestore();
DefaultExtentsColor->onRestore();
DefaultProbePathColor->onRestore();
}
/**

View File

@ -6,192 +6,225 @@
<rect>
<x>0</x>
<y>0</y>
<width>359</width>
<height>282</height>
<width>297</width>
<height>281</height>
</rect>
</property>
<property name="windowTitle">
<string>Path colors</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBoxDefaultColors">
<property name="title">
<string>Default Path colors</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="minimumSize">
<size>
<width>182</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Default normal path color</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::PrefColorButton" name="DefaultNormalPathColor">
<property name="toolTip">
<string>The default color for new shapes</string>
</property>
<property name="color">
<color>
<red>0</red>
<green>170</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>DefaultNormalPathColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_9">
<property name="minimumSize">
<size>
<width>182</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Default pathline width</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::PrefSpinBox" name="DefaultPathLineWidth">
<property name="toolTip">
<string>The default line thickness for new shapes</string>
</property>
<property name="suffix">
<string>px</string>
</property>
<property name="maximum">
<number>9</number>
</property>
<property name="value">
<number>1</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>DefaultPathLineWidth</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_10">
<property name="minimumSize">
<size>
<width>182</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Default path marker color</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="Gui::PrefColorButton" name="DefaultPathMarkerColor">
<property name="toolTip">
<string>The default line color for new shapes</string>
</property>
<property name="color">
<color>
<red>85</red>
<green>255</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>DefaultPathMarkerColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_7">
<property name="minimumSize">
<size>
<width>182</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Rapid path color</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="Gui::PrefColorButton" name="DefaultRapidPathColor">
<property name="toolTip">
<string>The default line color for new shapes</string>
</property>
<property name="color">
<color>
<red>170</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>DefaultRapidPathColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Machine extents color</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="Gui::PrefColorButton" name="DefaultExtentsColor">
<property name="prefEntry" stdset="0">
<cstring>DefaultExtentsColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="minimumSize">
<size>
<width>28</width>
<height>20</height>
<width>182</width>
<height>0</height>
</size>
</property>
</spacer>
<property name="text">
<string>Default normal path color</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::PrefColorButton" name="DefaultNormalPathColor">
<property name="toolTip">
<string>The default color for new shapes</string>
</property>
<property name="color" stdset="0">
<color>
<red>0</red>
<green>170</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>DefaultNormalPathColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_9">
<property name="minimumSize">
<size>
<width>182</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Default pathline width</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::PrefSpinBox" name="DefaultPathLineWidth">
<property name="toolTip">
<string>The default line thickness for new shapes</string>
</property>
<property name="suffix">
<string>px</string>
</property>
<property name="maximum">
<number>9</number>
</property>
<property name="value">
<number>1</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>DefaultPathLineWidth</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_10">
<property name="minimumSize">
<size>
<width>182</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Default path marker color</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::PrefColorButton" name="DefaultPathMarkerColor">
<property name="toolTip">
<string>The default line color for new shapes</string>
</property>
<property name="color" stdset="0">
<color>
<red>85</red>
<green>255</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>DefaultPathMarkerColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_7">
<property name="minimumSize">
<size>
<width>182</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Rapid path color</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="Gui::PrefColorButton" name="DefaultRapidPathColor">
<property name="toolTip">
<string>The default line color for new shapes</string>
</property>
<property name="color" stdset="0">
<color>
<red>170</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>DefaultRapidPathColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_8">
<property name="minimumSize">
<size>
<width>182</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Probe Path color</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="Gui::PrefColorButton" name="DefaultProbePathColor">
<property name="toolTip">
<string>The default line color for new shapes</string>
</property>
<property name="color" stdset="0">
<color>
<red>255</red>
<green>255</green>
<blue>5</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>DefaultProbePathColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Machine extents color</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="Gui::PrefColorButton" name="DefaultExtentsColor">
<property name="prefEntry" stdset="0">
<cstring>DefaultExtentsColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
</layout>
<zorder>DefaultRapidPathColor_2</zorder>
<zorder>label_8</zorder>
<zorder>label_8</zorder>
<zorder>DefaultProbePathColor</zorder>
</widget>
</item>
<item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>7</width>
<height>220</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>

View File

@ -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;i<colorindex.size();i++) {
if (colorindex[i] == 0)
colors[i] = SbColor(rr,rg,rb);
else
else if (colorindex[i] == 1)
colors[i] = SbColor(c.r,c.g,c.b);
else
colors[i] = SbColor(pr,pg,pb);
}
pcLineColor->diffuseColor.finishEditing();
}
@ -220,14 +226,14 @@ void ViewProviderPath::updateData(const App::Property* prop)
Path::Feature* pcPathObj = static_cast<Path::Feature*>(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<Base::Vector3d> 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;i<markers.size();i++)
pcMarkerCoords->point.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;