Assembly: Handle thrown Base::Exception in ViewProviderAssembly

This commit is contained in:
wmayer
2024-11-11 01:11:56 +01:00
parent 72728ece52
commit ae32212245
2 changed files with 26 additions and 1 deletions

View File

@@ -342,6 +342,17 @@ bool ViewProviderAssembly::keyPressed(bool pressed, int key)
}
bool ViewProviderAssembly::mouseMove(const SbVec2s& cursorPos, Gui::View3DInventorViewer* viewer)
{
try {
return tryMouseMove(cursorPos, viewer);
}
catch (const Base::Exception& e) {
Base::Console().Warning("%s\n", e.what());
return false;
}
}
bool ViewProviderAssembly::tryMouseMove(const SbVec2s& cursorPos, Gui::View3DInventorViewer* viewer)
{
if (!isInEditMode()) {
return false;
@@ -819,6 +830,16 @@ ViewProviderAssembly::DragMode ViewProviderAssembly::findDragMode()
}
void ViewProviderAssembly::initMove(const SbVec2s& cursorPos, Gui::View3DInventorViewer* viewer)
{
try {
tryInitMove(cursorPos, viewer);
}
catch (const Base::Exception& e) {
Base::Console().Warning("%s\n", e.what());
}
}
void ViewProviderAssembly::tryInitMove(const SbVec2s& cursorPos, Gui::View3DInventorViewer* viewer)
{
dragMode = findDragMode();
if (dragMode == DragMode::None) {

View File

@@ -130,7 +130,7 @@ public:
/// is called when the Provider is in edit and a key event ocours. Only ESC ends edit.
bool keyPressed(bool pressed, int key) override;
/// is called when the provider is in edit and the mouse is moved
bool mouseMove(const SbVec2s& pos, Gui::View3DInventorViewer* viewer) override;
bool mouseMove(const SbVec2s& cursorPos, Gui::View3DInventorViewer* viewer) override;
/// is called when the Provider is in edit and the mouse is clicked
bool mouseButtonPressed(int Button,
bool pressed,
@@ -226,6 +226,10 @@ public:
SoSwitch* asmDraggerSwitch = nullptr;
SoFieldSensor* translationSensor = nullptr;
SoFieldSensor* rotationSensor = nullptr;
private:
bool tryMouseMove(const SbVec2s& cursorPos, Gui::View3DInventorViewer* viewer);
void tryInitMove(const SbVec2s& cursorPos, Gui::View3DInventorViewer* viewer);
};
} // namespace AssemblyGui