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 dc101d61ad
commit 01e7a56a56
4 changed files with 94 additions and 1 deletions

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