Merge pull request #22150 from Rexbas/remove-camera-adjust-method

Remove Command::adjustCameraPosition()
This commit is contained in:
Kacper Donat
2025-06-25 13:11:00 +02:00
committed by GitHub
4 changed files with 1 additions and 62 deletions

View File

@@ -916,47 +916,6 @@ const char* Command::keySequenceToAccel(int sk) const
return (strings[sk] = static_cast<const char*>(data)).c_str();
}
void Command::adjustCameraPosition()
{
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (doc) {
auto view = static_cast<Gui::View3DInventor*>(doc->getActiveView());
Gui::View3DInventorViewer* viewer = view->getViewer();
SoCamera* camera = viewer->getSoRenderManager()->getCamera();
if (!camera || !camera->isOfType(SoOrthographicCamera::getClassTypeId()))
return;
// get scene bounding box
SoGetBoundingBoxAction action(viewer->getSoRenderManager()->getViewportRegion());
action.apply(viewer->getSceneGraph());
SbBox3f box = action.getBoundingBox();
if (box.isEmpty())
return;
// get cirumscribing sphere and check if camera is inside
SbVec3f cam_pos = camera->position.getValue();
SbVec3f box_cnt = box.getCenter();
SbSphere bs;
bs.circumscribe(box);
float radius = bs.getRadius();
float distance_to_midpoint = (box_cnt-cam_pos).length();
if (radius >= distance_to_midpoint) {
// Move the camera to the edge of the bounding sphere, while still
// pointing at the scene.
SbVec3f direction = cam_pos - box_cnt;
(void) direction.normalize(); // we know this is not a null vector
camera->position.setValue(box_cnt + direction * radius);
// New distance to mid point
distance_to_midpoint =
(camera->position.getValue() - box.getCenter()).length();
camera->nearDistance = distance_to_midpoint - radius;
camera->farDistance = distance_to_midpoint + radius;
camera->focalDistance = distance_to_midpoint;
}
}
}
void Command::printConflictingAccelerators() const
{
auto cmd = Application::Instance->commandManager().checkAcceleratorForConflicts(sAccel, this);

View File

@@ -575,11 +575,6 @@ public:
/// Obtain the current shortcut of this command
virtual QString getShortcut() const;
/** @name arbitrary helper methods */
//@{
void adjustCameraPosition();
//@}
/// Helper class to disable python console log
class LogDisabler {
public:

View File

@@ -1635,9 +1635,7 @@ void CmdPartOffset::activated(int iMsg)
updateActive();
doCommand(Gui,"Gui.ActiveDocument.setEdit('%s')",offset.c_str());
adjustCameraPosition();
copyVisual(offset.c_str(), "ShapeAppearance", shape->getNameInDocument());
copyVisual(offset.c_str(), "LineColor" , shape->getNameInDocument());
copyVisual(offset.c_str(), "PointColor", shape->getNameInDocument());
@@ -1692,7 +1690,6 @@ void CmdPartOffset2D::activated(int iMsg)
doCommand(Doc,"App.ActiveDocument.%s.Value = 1.0",offset.c_str());
updateActive();
doCommand(Gui,"Gui.ActiveDocument.setEdit('%s')",offset.c_str());
adjustCameraPosition();
copyVisual(offset.c_str(), "ShapeAppearance", shape->getNameInDocument());
copyVisual(offset.c_str(), "LineColor" , shape->getNameInDocument());
@@ -1876,7 +1873,6 @@ void CmdPartThickness::activated(int iMsg)
obj->getDocument()->getName(), obj->getNameInDocument());
}
doCommand(Gui,"Gui.ActiveDocument.setEdit('%s')",thick.c_str());
adjustCameraPosition();
copyVisual(thick.c_str(), "ShapeAppearance", obj->getNameInDocument());
copyVisual(thick.c_str(), "LineColor" , obj->getNameInDocument());

View File

@@ -1075,7 +1075,6 @@ void prepareProfileBased(Gui::Command* cmd, const std::string& which, double len
}
finishProfileBased(cmd, sketch, Feat);
cmd->adjustCameraPosition();
};
prepareProfileBased(pcActiveBody, cmd, which, worker);
@@ -1172,7 +1171,6 @@ void CmdPartDesignHole::activated(int iMsg)
return;
finishProfileBased(cmd, sketch, Feat);
cmd->adjustCameraPosition();
};
prepareProfileBased(pcActiveBody, this, "Hole", worker);
@@ -1228,7 +1226,6 @@ void CmdPartDesignRevolution::activated(int iMsg)
FCMD_OBJ_CMD(Feat,"Reversed = 1");
finishProfileBased(cmd, sketch, Feat);
cmd->adjustCameraPosition();
};
prepareProfileBased(pcActiveBody, this, "Revolution", worker);
@@ -1292,7 +1289,6 @@ void CmdPartDesignGroove::activated(int iMsg)
}
finishProfileBased(cmd, sketch, Feat);
cmd->adjustCameraPosition();
};
prepareProfileBased(pcActiveBody, this, "Groove", worker);
@@ -1339,7 +1335,6 @@ void CmdPartDesignAdditivePipe::activated(int iMsg)
Gui::Command::updateActive();
finishProfileBased(cmd, sketch, Feat);
cmd->adjustCameraPosition();
};
prepareProfileBased(pcActiveBody, this, "AdditivePipe", worker);
@@ -1387,7 +1382,6 @@ void CmdPartDesignSubtractivePipe::activated(int iMsg)
Gui::Command::updateActive();
finishProfileBased(cmd, sketch, Feat);
cmd->adjustCameraPosition();
};
prepareProfileBased(pcActiveBody, this, "SubtractivePipe", worker);
@@ -1435,7 +1429,6 @@ void CmdPartDesignAdditiveLoft::activated(int iMsg)
Gui::Command::updateActive();
finishProfileBased(cmd, sketch, Feat);
cmd->adjustCameraPosition();
};
prepareProfileBased(pcActiveBody, this, "AdditiveLoft", worker);
@@ -1483,7 +1476,6 @@ void CmdPartDesignSubtractiveLoft::activated(int iMsg)
Gui::Command::updateActive();
finishProfileBased(cmd, sketch, Feat);
cmd->adjustCameraPosition();
};
prepareProfileBased(pcActiveBody, this, "SubtractiveLoft", worker);
@@ -1555,8 +1547,6 @@ void CmdPartDesignAdditiveHelix::activated(int iMsg)
view->makeTemporaryVisible(true);
}
}
cmd->adjustCameraPosition();
};
prepareProfileBased(pcActiveBody, this, "AdditiveHelix", worker);
@@ -1611,7 +1601,6 @@ void CmdPartDesignSubtractiveHelix::activated(int iMsg)
}
finishProfileBased(cmd, sketch, Feat);
cmd->adjustCameraPosition();
};
prepareProfileBased(pcActiveBody, this, "SubtractiveHelix", worker);