Gui: Use auto and range-based for (#7481)
* On lines where the variable type is obvious from inspection, avoid repeating the type using auto. * When possible use a ranged for loop instead of begin() and end() iterators
This commit is contained in:
@@ -185,7 +185,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
//before this block, mouse button states in NavigationStyle::buttonXdown reflected those before current event arrived.
|
||||
//track mouse button states
|
||||
if (evIsButton) {
|
||||
const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev;
|
||||
auto const event = (const SoMouseButtonEvent *) ev;
|
||||
const int button = event->getButton();
|
||||
const SbBool press //the button was pressed (if false -> released)
|
||||
= event->getState() == SoButtonEvent::DOWN ? true : false;
|
||||
@@ -226,7 +226,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
|
||||
//track gestures
|
||||
if (evIsGesture) {
|
||||
const SoGestureEvent* gesture = static_cast<const SoGestureEvent*>(ev);
|
||||
auto gesture = static_cast<const SoGestureEvent*>(ev);
|
||||
switch(gesture->state) {
|
||||
case SoGestureEvent::SbGSStart:
|
||||
//assert(!inGesture);//start of another gesture before the first finished? Happens all the time for Pan gesture... No idea why! --DeepSOIC
|
||||
@@ -277,7 +277,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
|
||||
// Mode-independent keyboard handling
|
||||
if (evIsKeyboard) {
|
||||
const SoKeyboardEvent * const event = (const SoKeyboardEvent *) ev;
|
||||
auto const event = (const SoKeyboardEvent *) ev;
|
||||
const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false;
|
||||
switch (event->getKey()) {
|
||||
case SoKeyboardEvent::H:
|
||||
@@ -300,7 +300,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
|
||||
//mode-independent spaceball/joystick handling
|
||||
if (evIsLoc3) {
|
||||
const SoMotion3Event * const event = static_cast<const SoMotion3Event *>(ev);
|
||||
auto const event = static_cast<const SoMotion3Event *>(ev);
|
||||
if (event)
|
||||
this->processMotionEvent(event);
|
||||
processed = true;
|
||||
@@ -317,7 +317,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
|
||||
//keyboard
|
||||
if (evIsKeyboard) {
|
||||
const SoKeyboardEvent * const event = (const SoKeyboardEvent *) ev;
|
||||
auto const event = (const SoKeyboardEvent *) ev;
|
||||
const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false;
|
||||
|
||||
switch(event->getKey()){
|
||||
@@ -352,7 +352,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
|
||||
// Mouse Button / Spaceball Button handling
|
||||
if (evIsButton) {
|
||||
const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev;
|
||||
auto const event = (const SoMouseButtonEvent *) ev;
|
||||
const int button = event->getButton();
|
||||
const SbBool press //the button was pressed (if false -> released)
|
||||
= event->getState() == SoButtonEvent::DOWN ? true : false;
|
||||
@@ -445,7 +445,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
|
||||
//gesture start
|
||||
if (evIsGesture && /*!this->button1down &&*/ !this->button2down){//ignore gestures when mouse buttons are down. Button1down check was disabled because of wrong state after doubleclick on sketcher constraint to edit datum
|
||||
const SoGestureEvent* gesture = static_cast<const SoGestureEvent*>(ev);
|
||||
auto gesture = static_cast<const SoGestureEvent*>(ev);
|
||||
if (gesture->state == SoGestureEvent::SbGSStart
|
||||
|| gesture->state == SoGestureEvent::SbGSUpdate) {//even if we didn't get a start, assume the first update is a start (sort-of fail-safe).
|
||||
if (type.isDerivedFrom(SoGesturePanEvent::getClassTypeId())) {
|
||||
@@ -472,7 +472,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
|
||||
// Mouse Button / Spaceball Button handling
|
||||
if (evIsButton) {
|
||||
const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev;
|
||||
auto const event = (const SoMouseButtonEvent *) ev;
|
||||
const int button = event->getButton();
|
||||
switch(button){
|
||||
case SoMouseButtonEvent::BUTTON1:
|
||||
@@ -520,14 +520,14 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
//the essence part 2!
|
||||
//gesture into camera motion
|
||||
if (evIsGesture){
|
||||
const SoGestureEvent* gesture = static_cast<const SoGestureEvent*>(ev);
|
||||
auto gesture = static_cast<const SoGestureEvent*>(ev);
|
||||
assert(gesture);
|
||||
if (gesture->state == SoGestureEvent::SbGSEnd) {
|
||||
setViewingMode(NavigationStyle::SELECTION);
|
||||
processed=true;
|
||||
} else if (gesture->state == SoGestureEvent::SbGSUpdate){
|
||||
if(type.isDerivedFrom(SoGesturePinchEvent::getClassTypeId())){
|
||||
const SoGesturePinchEvent* const event = static_cast<const SoGesturePinchEvent*>(ev);
|
||||
auto const event = static_cast<const SoGesturePinchEvent*>(ev);
|
||||
if (this->zoomAtCursor){
|
||||
//this is just dealing with the pan part of pinch gesture. Taking care of zooming to pos is done in doZoom.
|
||||
SbVec2f panDist = this->normalizePixelPos(event->deltaCenter.getValue());
|
||||
@@ -539,7 +539,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
processed = true;
|
||||
}
|
||||
if(type.isDerivedFrom(SoGesturePanEvent::getClassTypeId())){
|
||||
const SoGesturePanEvent* const event = static_cast<const SoGesturePanEvent*>(ev);
|
||||
auto const event = static_cast<const SoGesturePanEvent*>(ev);
|
||||
//this is just dealing with the pan part of pinch gesture. Taking care of zooming to pos is done in doZoom.
|
||||
SbVec2f panDist = this->normalizePixelPos(event->deltaOffset);
|
||||
NavigationStyle::panCamera(viewer->getSoRenderManager()->getCamera(), ratio, this->panningplane, panDist, SbVec2f(0,0));
|
||||
@@ -555,7 +555,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
} break;//end of actual navigation
|
||||
case NavigationStyle::SEEK_WAIT_MODE:{
|
||||
if (evIsButton) {
|
||||
const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev;
|
||||
auto const event = (const SoMouseButtonEvent *) ev;
|
||||
const int button = event->getButton();
|
||||
const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false;
|
||||
if (button == SoMouseButtonEvent::BUTTON1 && press) {
|
||||
|
||||
Reference in New Issue
Block a user