Skip to content

Commit

Permalink
Gui: Prohibit interrupting a rubber-band selection in sketcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexbas committed Jan 24, 2024
1 parent 7e031c1 commit 5c4b8dd
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 13 deletions.
12 changes: 8 additions & 4 deletions src/Gui/BlenderNavigationStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,15 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
case 0:
if (curmode == NavigationStyle::SPINNING) { break; }
newmode = NavigationStyle::IDLE;
// The left mouse button has been released right now but
// we want to avoid that the event is processed elsewhere
// The left mouse button has been released right now
if (this->lockButton1) {
this->lockButton1 = false;
processed = true;
}
break;
case BUTTON1DOWN:
case CTRLDOWN|BUTTON1DOWN:
// make sure not to change the selection when stopping spinning
if (curmode == NavigationStyle::SPINNING || this->lockButton1)
if (!viewer->isEditing() && (curmode == NavigationStyle::SPINNING || this->lockButton1))
newmode = NavigationStyle::IDLE;
else
newmode = NavigationStyle::SELECTION;
Expand Down Expand Up @@ -286,6 +284,12 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
processed = true;
}

// Prevent interrupting rubber-band selection in sketcher
if (viewer->isEditing() && curmode == NavigationStyle::SELECTION && newmode != NavigationStyle::IDLE) {
newmode = NavigationStyle::SELECTION;
processed = false;
}

if (newmode != curmode) {
this->setViewingMode(newmode);
}
Expand Down
12 changes: 8 additions & 4 deletions src/Gui/CADNavigationStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,14 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
case 0:
if (curmode == NavigationStyle::SPINNING) { break; }
newmode = NavigationStyle::IDLE;
// The left mouse button has been released right now but
// we want to avoid that the event is processed elsewhere
// The left mouse button has been released right now
if (this->lockButton1) {
this->lockButton1 = false;
processed = true;
}
break;
case BUTTON1DOWN:
// make sure not to change the selection when stopping spinning
if (curmode == NavigationStyle::SPINNING || this->lockButton1)
if (!viewer->isEditing() && (curmode == NavigationStyle::SPINNING || this->lockButton1))
newmode = NavigationStyle::IDLE;
else
newmode = NavigationStyle::SELECTION;
Expand Down Expand Up @@ -310,6 +308,12 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
processed = true;
}

// Prevent interrupting rubber-band selection in sketcher
if (viewer->isEditing() && curmode == NavigationStyle::SELECTION && newmode != NavigationStyle::IDLE) {
newmode = NavigationStyle::SELECTION;
processed = false;
}

if (newmode != curmode) {
this->setViewingMode(newmode);
}
Expand Down
6 changes: 6 additions & 0 deletions src/Gui/InventorNavigationStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,12 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
processed = true;
}

// Prevent interrupting rubber-band selection in sketcher
if (viewer->isEditing() && curmode == NavigationStyle::SELECTION && newmode != NavigationStyle::IDLE) {
newmode = NavigationStyle::SELECTION;
processed = false;
}

if (newmode != curmode) {
this->setViewingMode(newmode);
}
Expand Down
34 changes: 33 additions & 1 deletion src/Gui/MayaGestureNavigationStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,40 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)

//all mode-dependent stuff is within this switch.
switch(curmode){
case NavigationStyle::IDLE:
case NavigationStyle::SELECTION:
// Prevent interrupting rubber-band selection in sketcher
if (viewer->isEditing()) {
if (evIsButton) {
auto const event = (const SoMouseButtonEvent*)ev;
const SbBool press = event->getState() == SoButtonEvent::DOWN;
const int button = event->getButton();

if (!press && button == SoMouseButtonEvent::BUTTON1) {
setViewingMode(NavigationStyle::IDLE);
break;
}
}

if (this->button1down) {
break;
}
}
[[fallthrough]];
case NavigationStyle::IDLE:
// Prevent interrupting rubber-band selection in sketcher
if (viewer->isEditing()) {
if (evIsButton) {
auto const event = (const SoMouseButtonEvent*)ev;
const SbBool press = event->getState() == SoButtonEvent::DOWN;
const int button = event->getButton();

if (press && button == SoMouseButtonEvent::BUTTON1 && !this->altdown) {
setViewingMode(NavigationStyle::SELECTION);
break;
}
}
}
[[fallthrough]];
case NavigationStyle::INTERACT: {
//idle and interaction

Expand Down
6 changes: 6 additions & 0 deletions src/Gui/OpenCascadeNavigationStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@ SbBool OpenCascadeNavigationStyle::processSoEvent(const SoEvent * const ev)
processed = true;
}

// Prevent interrupting rubber-band selection in sketcher
if (viewer->isEditing() && curmode == NavigationStyle::SELECTION && newmode != NavigationStyle::IDLE) {
newmode = NavigationStyle::SELECTION;
processed = false;
}

if (newmode != curmode) {
this->setViewingMode(newmode);
}
Expand Down
6 changes: 6 additions & 0 deletions src/Gui/OpenSCADNavigationStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev)
processed = true;
}

// Prevent interrupting rubber-band selection in sketcher
if (viewer->isEditing() && curmode == NavigationStyle::SELECTION && newmode != NavigationStyle::IDLE) {
newmode = NavigationStyle::SELECTION;
processed = false;
}

if (newmode != curmode) {
this->setViewingMode(newmode);
}
Expand Down
12 changes: 8 additions & 4 deletions src/Gui/RevitNavigationStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,15 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev)
case 0:
if (curmode == NavigationStyle::SPINNING) { break; }
newmode = NavigationStyle::IDLE;
// The left mouse button has been released right now but
// we want to avoid that the event is processed elsewhere
// The left mouse button has been released right now
if (this->lockButton1) {
this->lockButton1 = false;
processed = true;
}
break;
case BUTTON1DOWN:
case CTRLDOWN|BUTTON1DOWN:
// make sure not to change the selection when stopping spinning
if (curmode == NavigationStyle::SPINNING || this->lockButton1)
if (!viewer->isEditing() && (curmode == NavigationStyle::SPINNING || this->lockButton1))
newmode = NavigationStyle::IDLE;
else
newmode = NavigationStyle::SELECTION;
Expand Down Expand Up @@ -288,6 +286,12 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev)
processed = true;
}

// Prevent interrupting rubber-band selection in sketcher
if (viewer->isEditing() && curmode == NavigationStyle::SELECTION && newmode != NavigationStyle::IDLE) {
newmode = NavigationStyle::SELECTION;
processed = false;
}

if (newmode != curmode) {
this->setViewingMode(newmode);
}
Expand Down
6 changes: 6 additions & 0 deletions src/Gui/TinkerCADNavigationStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ SbBool TinkerCADNavigationStyle::processSoEvent(const SoEvent * const ev)
processed = true;
}

// Prevent interrupting rubber-band selection in sketcher
if (viewer->isEditing() && curmode == NavigationStyle::SELECTION && newmode != NavigationStyle::IDLE) {
newmode = NavigationStyle::SELECTION;
processed = false;
}

if (newmode != curmode) {
this->setViewingMode(newmode);
}
Expand Down
6 changes: 6 additions & 0 deletions src/Gui/TouchpadNavigationStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
processed = true;
}

// Prevent interrupting rubber-band selection in sketcher
if (viewer->isEditing() && curmode == NavigationStyle::SELECTION && newmode != NavigationStyle::IDLE) {
newmode = NavigationStyle::SELECTION;
processed = false;
}

if (newmode != curmode) {
this->setViewingMode(newmode);
}
Expand Down

0 comments on commit 5c4b8dd

Please sign in to comment.