Merge pull request #24438 from Rexbas/fix-openscad-transform-conflict

Gui: Fix transform tool conflict with OpenSCAD navigation style
This commit is contained in:
Chris Hennes
2025-10-05 21:05:19 -05:00
committed by GitHub
5 changed files with 31 additions and 25 deletions

View File

@@ -959,25 +959,6 @@ SbBool GestureNavigationStyle::processSoEvent_bypass(const SoEvent* const ev)
return superclass::processSoEvent(ev);
}
bool GestureNavigationStyle::isDraggerUnderCursor(SbVec2s pos)
{
SoRayPickAction rp(this->viewer->getSoRenderManager()->getViewportRegion());
rp.setRadius(viewer->getPickRadius());
rp.setPoint(pos);
rp.apply(this->viewer->getSoRenderManager()->getSceneGraph());
SoPickedPoint* pick = rp.getPickedPoint();
if (pick){
const auto fullpath = static_cast<const SoFullPath*>(pick->getPath());
for(int i = 0; i < fullpath->getLength(); ++i){
if(fullpath->getNode(i)->isOfType(SoDragger::getClassTypeId()))
return true;
}
return false;
} else {
return false;
}
}
bool GestureNavigationStyle::is2DViewing() const
{
// #FIXME: detect sketch editing, ! any editing

View File

@@ -98,8 +98,6 @@ protected: // members variables
int rollDir = 0;
bool logging = false;
protected: //helper functions
bool isDraggerUnderCursor(SbVec2s pos);
public:
bool is2DViewing() const;

View File

@@ -24,6 +24,7 @@
# include <Inventor/SbViewportRegion.h>
# include <Inventor/SoPickedPoint.h>
# include <Inventor/actions/SoGetBoundingBoxAction.h>
# include <Inventor/draggers/SoDragger.h>
# include <Inventor/errors/SoDebugError.h>
# include <Inventor/nodes/SoSeparator.h>
# include <Inventor/nodes/SoCamera.h>
@@ -1542,6 +1543,25 @@ const std::vector<SbVec2s>& NavigationStyle::getPolygon(SelectionRole* role) con
return pcPolygon;
}
bool NavigationStyle::isDraggerUnderCursor(const SbVec2s pos) const
{
SoRayPickAction rp(this->viewer->getSoRenderManager()->getViewportRegion());
rp.setRadius(viewer->getPickRadius());
rp.setPoint(pos);
rp.apply(this->viewer->getSoRenderManager()->getSceneGraph());
SoPickedPoint* pick = rp.getPickedPoint();
if (pick) {
const auto fullpath = static_cast<const SoFullPath*>(pick->getPath());
for (int i = 0; i < fullpath->getLength(); ++i) {
if (fullpath->getNode(i)->isOfType(SoDragger::getClassTypeId())) {
return true;
}
}
return false;
}
return false;
}
// This method adds another point to the mouse location log, used for spin
// animation calculations.
void NavigationStyle::addToLog(const SbVec2s pos, const SbTime time)

View File

@@ -189,6 +189,8 @@ public:
SbBool isSelecting() const;
const std::vector<SbVec2s>& getPolygon(SelectionRole* role=nullptr) const;
bool isDraggerUnderCursor(const SbVec2s pos) const;
void setOrbitStyle(OrbitStyle style);
OrbitStyle getOrbitStyle() const;

View File

@@ -187,9 +187,14 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev)
this->lockrecenter = true;
const auto event = (const SoLocation2Event *) ev;
if (!viewer->isEditing() && curmode == NavigationStyle::SELECTION) {
newmode = NavigationStyle::DRAGGING;
saveCursorPosition(ev);
this->centerTime = ev->getTime();
if (button1down && isDraggerUnderCursor(ev->getPosition())) {
newmode = NavigationStyle::INTERACT;
}
else {
newmode = NavigationStyle::DRAGGING;
saveCursorPosition(ev);
this->centerTime = ev->getTime();
}
}
else if (curmode == NavigationStyle::ZOOMING) {
// OpenSCAD uses vertical mouse position, not horizontal
@@ -241,7 +246,7 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev)
newmode = NavigationStyle::IDLE;
break;
case BUTTON1DOWN:
if (newmode != NavigationStyle::DRAGGING)
if (newmode != NavigationStyle::DRAGGING && newmode != NavigationStyle::INTERACT)
newmode = NavigationStyle::SELECTION;
break;
case BUTTON2DOWN: