diff --git a/src/Mod/CAM/Gui/DlgSettingsPathColor.cpp b/src/Mod/CAM/Gui/DlgSettingsPathColor.cpp
index faa2b727e1..ad111fd049 100644
--- a/src/Mod/CAM/Gui/DlgSettingsPathColor.cpp
+++ b/src/Mod/CAM/Gui/DlgSettingsPathColor.cpp
@@ -63,6 +63,7 @@ void DlgSettingsPathColor::saveSettings()
ui->DefaultBBoxNormalColor->onSave();
ui->DefaultSelectionStyle->onSave();
ui->DefaultTaskPanelLayout->onSave();
+ ui->HideFirstRapid->onSave();
}
void DlgSettingsPathColor::loadSettings()
@@ -78,6 +79,7 @@ void DlgSettingsPathColor::loadSettings()
ui->DefaultBBoxNormalColor->onRestore();
ui->DefaultSelectionStyle->onRestore();
ui->DefaultTaskPanelLayout->onRestore();
+ ui->HideFirstRapid->onRestore();
}
/**
diff --git a/src/Mod/CAM/Gui/DlgSettingsPathColor.ui b/src/Mod/CAM/Gui/DlgSettingsPathColor.ui
index ac8698592d..830545518c 100644
--- a/src/Mod/CAM/Gui/DlgSettingsPathColor.ui
+++ b/src/Mod/CAM/Gui/DlgSettingsPathColor.ui
@@ -398,6 +398,32 @@
+ -
+
+
+ Hide first rapid move
+
+
+
+ -
+
+
+ Hide the initial rapid move in path visualization by setting the start index to the first feed move
+
+
+
+
+
+ false
+
+
+ HideFirstRapid
+
+
+ Mod/CAM
+
+
+
@@ -424,6 +450,11 @@
QComboBox
+
+ Gui::PrefCheckBox
+ QCheckBox
+
+
DefaultNormalPathColor
diff --git a/src/Mod/CAM/Gui/ViewProviderPath.cpp b/src/Mod/CAM/Gui/ViewProviderPath.cpp
index b84f9309c2..fa47880c3e 100644
--- a/src/Mod/CAM/Gui/ViewProviderPath.cpp
+++ b/src/Mod/CAM/Gui/ViewProviderPath.cpp
@@ -41,6 +41,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -496,6 +497,28 @@ void ViewProviderPath::updateData(const App::Property* prop)
{
Path::Feature* pcPathObj = static_cast(pcObject);
if (prop == &pcPathObj->Path) {
+ // Check if we should hide the first rapid moves
+ ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
+ "User parameter:BaseApp/Preferences/Mod/CAM"
+ );
+ bool hideFirstRapid = hGrp->GetBool("HideFirstRapid", false);
+
+ if (hideFirstRapid) {
+ // Find the first feed move and set StartIndex accordingly
+ long firstFeedIndex = findFirstFeedMoveIndex(pcPathObj->Path.getValue());
+ if (firstFeedIndex > 0) {
+ StartIndex.setValue(firstFeedIndex);
+ StartIndex.purgeTouched();
+ }
+ }
+ else {
+ // Reset StartIndex to show all commands from the beginning
+ if (StartIndex.getValue() != 0) {
+ StartIndex.setValue(0);
+ StartIndex.purgeTouched();
+ }
+ }
+
updateVisual(true);
return;
}
@@ -826,9 +849,37 @@ void ViewProviderPath::recomputeBoundingBox()
pcBoundingBox->maxBounds.setValue(MaxX, MaxY, MaxZ);
}
+long ViewProviderPath::findFirstFeedMoveIndex(const Path::Toolpath& path) const
+{
+ const std::vector& commands = path.getCommands();
+ for (size_t i = 0; i < commands.size(); ++i) {
+ const Path::Command* cmd = commands[i];
+ if (!cmd) {
+ continue;
+ }
+ std::string name = cmd->Name;
+
+ // Skip comments and empty commands
+ if (name.empty() || name[0] == '(' || name[0] == ';' || name[0] == '%') {
+ continue;
+ }
+
+ // Skip rapid moves (G0)
+ if (name == "G0" || name == "G00") {
+ continue;
+ }
+
+ // Found the first non-rapid move
+ return static_cast(i);
+ }
+
+ // If no feed move found, return 0 to show from the beginning
+ return 0;
+}
+
QIcon ViewProviderPath::getIcon() const
{
- return Gui::BitmapFactory().pixmap("CAM_Toolpath");
+ return Gui::BitmapFactory().pixmap("Path-ToolPath");
}
// Python object -----------------------------------------------------------------------
diff --git a/src/Mod/CAM/Gui/ViewProviderPath.h b/src/Mod/CAM/Gui/ViewProviderPath.h
index 5257f98b86..c8e0a61e5b 100644
--- a/src/Mod/CAM/Gui/ViewProviderPath.h
+++ b/src/Mod/CAM/Gui/ViewProviderPath.h
@@ -41,6 +41,11 @@ class SoMaterialBinding;
class SoTransform;
class SoSwitch;
+namespace Path
+{
+class Toolpath;
+}
+
namespace PathGui
{
@@ -89,6 +94,10 @@ public:
friend class PathSelectionObserver;
+private:
+ /// Find the index of the first non-rapid move command
+ long findFirstFeedMoveIndex(const Path::Toolpath& path) const;
+
protected:
void onChanged(const App::Property* prop) override;
unsigned long getBoundColor() const override;