CAM: Suppress rendering of first rapids (#25440)

This commit is contained in:
sliptonic
2025-12-02 12:20:07 -06:00
committed by GitHub
parent a0c9b2ecb9
commit 20c2eee9db
4 changed files with 94 additions and 1 deletions

View File

@@ -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();
}
/**

View File

@@ -398,6 +398,32 @@
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Hide first rapid move</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::PrefCheckBox" name="HideFirstRapid">
<property name="toolTip">
<string>Hide the initial rapid move in path visualization by setting the start index to the first feed move</string>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>HideFirstRapid</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/CAM</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -424,6 +450,11 @@
<extends>QComboBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>DefaultNormalPathColor</tabstop>

View File

@@ -41,6 +41,7 @@
#include <App/DocumentObject.h>
#include <Base/Parameter.h>
#include <Base/Stream.h>
#include <Mod/CAM/App/Command.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Inventor/SoAxisCrossKit.h>
@@ -496,6 +497,28 @@ void ViewProviderPath::updateData(const App::Property* prop)
{
Path::Feature* pcPathObj = static_cast<Path::Feature*>(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<Path::Command*>& 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<long>(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 -----------------------------------------------------------------------

View File

@@ -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;