diff --git a/src/Gui/BlenderNavigationStyle.cpp b/src/Gui/BlenderNavigationStyle.cpp index 81fc6f5202..563b124e86 100644 --- a/src/Gui/BlenderNavigationStyle.cpp +++ b/src/Gui/BlenderNavigationStyle.cpp @@ -117,7 +117,7 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { const SoKeyboardEvent * const event = static_cast(ev); - processed = handleKeyboardEvent(event, posn); + processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling @@ -146,30 +146,8 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev) else if (viewer->isEditing() && (this->currentmode == NavigationStyle::SPINNING)) { processed = true; } - // issue #0002433: avoid to swallow the UP event if down the - // scene graph somewhere a dialog gets opened - else if (press) { - SbTime tmp = (ev->getTime() - mouseDownConsumedEvent.getTime()); - float dci = (float)QApplication::doubleClickInterval()/1000.0f; - // a double-click? - if (tmp.getValue() < dci) { - mouseDownConsumedEvent = *event; - mouseDownConsumedEvent.setTime(ev->getTime()); - processed = true; - } - else { - mouseDownConsumedEvent.setTime(ev->getTime()); - // 'ANY' is used to mark that we don't know yet if it will - // be a double-click event. - mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY); - } - } - else if (!press) { - if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON1) { - // now handle the postponed event - inherited::processSoEvent(&mouseDownConsumedEvent); - mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY); - } + else { + processed = processClickEvent(event); } break; case SoMouseButtonEvent::BUTTON2: diff --git a/src/Gui/CADNavigationStyle.cpp b/src/Gui/CADNavigationStyle.cpp index 53d893f0ff..c9e351fb2b 100644 --- a/src/Gui/CADNavigationStyle.cpp +++ b/src/Gui/CADNavigationStyle.cpp @@ -121,7 +121,7 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { const SoKeyboardEvent * const event = static_cast(ev); - processed = handleKeyboardEvent(event, posn); + processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling @@ -158,30 +158,8 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev) else if (viewer->isEditing() && (this->currentmode == NavigationStyle::SPINNING)) { processed = true; } - // issue #0002433: avoid to swallow the UP event if down the - // scene graph somewhere a dialog gets opened - else if (press) { - SbTime tmp = (ev->getTime() - mouseDownConsumedEvent.getTime()); - float dci = (float)QApplication::doubleClickInterval()/1000.0f; - // a double-click? - if (tmp.getValue() < dci) { - mouseDownConsumedEvent = *event; - mouseDownConsumedEvent.setTime(ev->getTime()); - processed = true; - } - else { - mouseDownConsumedEvent.setTime(ev->getTime()); - // 'ANY' is used to mark that we don't know yet if it will - // be a double-click event. - mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY); - } - } - else if (!press) { - if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON1) { - // now handle the postponed event - inherited::processSoEvent(&mouseDownConsumedEvent); - mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY); - } + else { + processed = processClickEvent(event); } break; case SoMouseButtonEvent::BUTTON2: diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index b901e97e8d..8990d7af4f 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -839,6 +839,7 @@ SET(View3D_CPP_SRCS MayaGestureNavigationStyle.cpp OpenCascadeNavigationStyle.cpp OpenSCADNavigationStyle.cpp + TinkerCADNavigationStyle.cpp TouchpadNavigationStyle.cpp GestureNavigationStyle.cpp SplitView3DInventor.cpp diff --git a/src/Gui/GestureNavigationStyle.cpp b/src/Gui/GestureNavigationStyle.cpp index 7d0732ae54..946efb1dcf 100644 --- a/src/Gui/GestureNavigationStyle.cpp +++ b/src/Gui/GestureNavigationStyle.cpp @@ -72,6 +72,7 @@ #include "GestureNavigationStyle.h" #include +#include #include #include "View3DInventorViewer.h" #include "Application.h" diff --git a/src/Gui/InventorNavigationStyle.cpp b/src/Gui/InventorNavigationStyle.cpp index 4c57393cb4..b9bfe2986d 100644 --- a/src/Gui/InventorNavigationStyle.cpp +++ b/src/Gui/InventorNavigationStyle.cpp @@ -125,7 +125,7 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { const SoKeyboardEvent * const event = static_cast(ev); - processed = handleKeyboardEvent(event, posn); + processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling @@ -179,30 +179,8 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev) processed = true; this->lockrecenter = true; } - // issue #0002433: avoid to swallow the UP event if down the - // scene graph somewhere a dialog gets opened - else if (press) { - SbTime tmp = (ev->getTime() - mouseDownConsumedEvent.getTime()); - float dci = (float)QApplication::doubleClickInterval()/1000.0f; - // a double-click? - if (tmp.getValue() < dci) { - mouseDownConsumedEvent = *event; - mouseDownConsumedEvent.setTime(ev->getTime()); - processed = true; - } - else { - mouseDownConsumedEvent.setTime(ev->getTime()); - // 'ANY' is used to mark that we don't know yet if it will - // be a double-click event. - mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY); - } - } - else if (!press) { - if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON1) { - // now handle the postponed event - inherited::processSoEvent(&mouseDownConsumedEvent); - mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY); - } + else { + processed = processClickEvent(event); } break; case SoMouseButtonEvent::BUTTON2: diff --git a/src/Gui/MayaGestureNavigationStyle.cpp b/src/Gui/MayaGestureNavigationStyle.cpp index 2a34f062e5..8c9bd83c6c 100644 --- a/src/Gui/MayaGestureNavigationStyle.cpp +++ b/src/Gui/MayaGestureNavigationStyle.cpp @@ -378,11 +378,11 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev) this->mouseMoveThresholdBroken = false; pan(viewer->getSoRenderManager()->getCamera());//set up panningplane int &cnt = this->mousedownConsumedCount; - this->mousedownConsumedEvent[cnt] = *event;//hopefully, a shallow copy is enough. There are no pointers stored in events, apparently. Will lose a subclass, though. + this->mousedownConsumedEvents[cnt] = *event;//hopefully, a shallow copy is enough. There are no pointers stored in events, apparently. Will lose a subclass, though. cnt++; assert(cnt<=2); - if(cnt>static_cast(sizeof(mousedownConsumedEvent))){ - cnt=sizeof(mousedownConsumedEvent);//we are in trouble + if(cnt>static_cast(sizeof(mousedownConsumedEvents))){ + cnt=sizeof(mousedownConsumedEvents);//we are in trouble } processed = true;//just consume this event, and wait for the move threshold to be broken to start dragging/panning } @@ -396,7 +396,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev) if(! processed) { //re-synthesize all previously-consumed mouseDowns, if any. They might have been re-synthesized already when threshold was broken. for( int i=0; i < this->mousedownConsumedCount; i++ ){ - inherited::processSoEvent(& (this->mousedownConsumedEvent[i]));//simulate the previously-comsumed mousedown. + inherited::processSoEvent(& (this->mousedownConsumedEvents[i]));//simulate the previously-comsumed mousedown. } this->mousedownConsumedCount = 0; processed = inherited::processSoEvent(ev);//explicitly, just for clarity that we are sending a full click sequence. @@ -441,7 +441,7 @@ SbBool MayaGestureNavigationStyle::processSoEvent(const SoEvent * const ev) //no, we are not entering navigation. //re-synthesize all previously-consumed mouseDowns, if any, and propagate this mousemove. for( int i=0; i < this->mousedownConsumedCount; i++ ){ - inherited::processSoEvent(& (this->mousedownConsumedEvent[i]));//simulate the previously-comsumed mousedown. + inherited::processSoEvent(& (this->mousedownConsumedEvents[i]));//simulate the previously-comsumed mousedown. } this->mousedownConsumedCount = 0; processed = inherited::processSoEvent(ev);//explicitly, just for clarity that we are sending a full click sequence. diff --git a/src/Gui/NavigationStyle.cpp b/src/Gui/NavigationStyle.cpp index dc66d74beb..fb971292e1 100644 --- a/src/Gui/NavigationStyle.cpp +++ b/src/Gui/NavigationStyle.cpp @@ -64,7 +64,7 @@ struct NavigationStyleP { { this->animationsteps = 0; this->animationdelta = 0; - this->animsensor = 0; + this->animsensor = nullptr; this->sensitivity = 2.0f; this->resetcursorpos = false; this->rotationCenterFound = false; @@ -173,7 +173,7 @@ const Base::Type& NavigationStyleEvent::style() const TYPESYSTEM_SOURCE_ABSTRACT(Gui::NavigationStyle,Base::BaseClass) -NavigationStyle::NavigationStyle() : viewer(0), mouseSelection(0) +NavigationStyle::NavigationStyle() : viewer(nullptr), mouseSelection(nullptr) { PRIVATE(this) = new NavigationStyleP(); PRIVATE(this)->animsensor = new SoTimerSensor(NavigationStyleP::viewAnimationCB, this); @@ -261,17 +261,17 @@ void NavigationStyle::finalize() delete[] this->log.time; } -void NavigationStyle::interactiveCountInc(void) +void NavigationStyle::interactiveCountInc() { viewer->interactiveCountInc(); } -void NavigationStyle::interactiveCountDec(void) +void NavigationStyle::interactiveCountDec() { viewer->interactiveCountDec(); } -int NavigationStyle::getInteractiveCount(void) const +int NavigationStyle::getInteractiveCount() const { return viewer->getInteractiveCount(); } @@ -288,7 +288,7 @@ NavigationStyle::OrbitStyle NavigationStyle::getOrbitStyle() const return NavigationStyle::OrbitStyle(projector->getOrbitStyle()); } -SbBool NavigationStyle::isViewing(void) const +SbBool NavigationStyle::isViewing() const { return viewer->isViewing(); } @@ -298,7 +298,7 @@ void NavigationStyle::setViewing(SbBool enable) viewer->setViewing(enable); } -SbBool NavigationStyle::isSeekMode(void) const +SbBool NavigationStyle::isSeekMode() const { return viewer->isSeekMode(); } @@ -321,7 +321,7 @@ void NavigationStyle::seekToPoint(const SbVec3f& scenepos) SbBool NavigationStyle::lookAtPoint(const SbVec2s screenpos) { SoCamera* cam = viewer->getSoRenderManager()->getCamera(); - if (cam == 0) return false; + if (cam == nullptr) return false; SoRayPickAction rpaction(viewer->getSoRenderManager()->getViewportRegion()); rpaction.setPoint(screenpos); @@ -343,7 +343,7 @@ SbBool NavigationStyle::lookAtPoint(const SbVec2s screenpos) void NavigationStyle::lookAtPoint(const SbVec3f& pos) { SoCamera* cam = viewer->getSoRenderManager()->getCamera(); - if (cam == 0) return; + if (cam == nullptr) return; PRIVATE(this)->rotationCenterFound = false; // Find global coordinates of focal point. @@ -401,7 +401,7 @@ void NavigationStyle::lookAtPoint(const SbVec3f& pos) void NavigationStyle::setCameraOrientation(const SbRotation& rot, SbBool moveToCenter) { SoCamera* cam = viewer->getSoRenderManager()->getCamera(); - if (cam == 0) return; + if (cam == nullptr) return; // Find global coordinates of focal point. SbVec3f direction; @@ -611,7 +611,7 @@ void NavigationStyle::viewAll() */ void NavigationStyle::reorientCamera(SoCamera * cam, const SbRotation & rot) { - if (cam == NULL) return; + if (cam == nullptr) return; // Find global coordinates of focal point. SbVec3f direction; @@ -630,7 +630,7 @@ void NavigationStyle::reorientCamera(SoCamera * cam, const SbRotation & rot) void NavigationStyle::panCamera(SoCamera * cam, float aspectratio, const SbPlane & panplane, const SbVec2f & currpos, const SbVec2f & prevpos) { - if (cam == NULL) return; // can happen for empty scenegraph + if (cam == nullptr) return; // can happen for empty scenegraph if (currpos == prevpos) return; // useless invocation @@ -659,7 +659,7 @@ void NavigationStyle::pan(SoCamera* camera) // The plane we're projecting the mouse coordinates to get 3D // coordinates should stay the same during the whole pan // operation, so we should calculate this value here. - if (camera == NULL) { // can happen for empty scenegraph + if (camera == nullptr) { // can happen for empty scenegraph this->panningplane = SbPlane(SbVec3f(0, 0, 1), 0); } else { @@ -689,7 +689,7 @@ void NavigationStyle::panToCenter(const SbPlane & pplane, const SbVec2f & currpo */ void NavigationStyle::zoom(SoCamera * cam, float diffvalue) { - if (cam == NULL) return; // can happen for empty scenegraph + if (cam == nullptr) return; // can happen for empty scenegraph SoType t = cam->getTypeId(); SbName tname = t.getName(); @@ -870,7 +870,7 @@ void NavigationStyle::setRotationCenter(const SbVec3f& cnt) SbVec3f NavigationStyle::getFocalPoint() const { SoCamera* cam = viewer->getSoRenderManager()->getCamera(); - if (cam == 0) + if (cam == nullptr) return SbVec3f(0,0,0); // Find global coordinates of focal point. @@ -887,7 +887,7 @@ SbVec3f NavigationStyle::getFocalPoint() const void NavigationStyle::spin(const SbVec2f & pointerpos) { if (this->log.historysize < 2) return; - assert(this->spinprojector != NULL); + assert(this->spinprojector != nullptr); const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion(); SbVec2s glsize(vp.getViewportSizePixels()); @@ -965,7 +965,7 @@ void NavigationStyle::spin(const SbVec2f & pointerpos) * \param prevpos previous normalized position of mouse pointer */ void NavigationStyle::spin_simplified(SoCamera* cam, SbVec2f curpos, SbVec2f prevpos){ - assert(this->spinprojector != NULL); + assert(this->spinprojector != nullptr); // 0000333: Turntable camera rotation SbMatrix mat; @@ -1163,7 +1163,7 @@ NavigationStyle::setAnimationEnabled(const SbBool enable) */ SbBool -NavigationStyle::isAnimationEnabled(void) const +NavigationStyle::isAnimationEnabled() const { return this->spinanimatingallowed; } @@ -1172,7 +1172,7 @@ NavigationStyle::isAnimationEnabled(void) const Query if the model in the viewer is currently in spinning mode after a user drag. */ -SbBool NavigationStyle::isAnimating(void) const +SbBool NavigationStyle::isAnimating() const { return this->currentmode == NavigationStyle::SPINNING; } @@ -1195,7 +1195,7 @@ void NavigationStyle::startAnimating(const SbVec3f& axis, float velocity) this->spinRotation = rot; } -void NavigationStyle::stopAnimating(void) +void NavigationStyle::stopAnimating() { if (this->currentmode != NavigationStyle::SPINNING) { return; @@ -1321,7 +1321,7 @@ void NavigationStyle::stopSelection() if (mouseSelection) { mouseSelection->releaseMouseModel(); delete mouseSelection; - mouseSelection = 0; + mouseSelection = nullptr; } } @@ -1367,7 +1367,7 @@ void NavigationStyle::addToLog(const SbVec2s pos, const SbTime time) // This method "clears" the mouse location log, used for spin // animation calculations. -void NavigationStyle::clearLog(void) +void NavigationStyle::clearLog() { this->log.historysize = 0; } @@ -1387,55 +1387,6 @@ void NavigationStyle::syncModifierKeys(const SoEvent * const ev) } } -SbBool NavigationStyle::handleKeyboardEvent(const SoKeyboardEvent * const event, const SbVec2f & posn) -{ - SbBool processed = false; - const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; - switch (event->getKey()) { - case SoKeyboardEvent::LEFT_CONTROL: - case SoKeyboardEvent::RIGHT_CONTROL: - this->ctrldown = press; - break; - case SoKeyboardEvent::LEFT_SHIFT: - case SoKeyboardEvent::RIGHT_SHIFT: - this->shiftdown = press; - break; - case SoKeyboardEvent::LEFT_ALT: - case SoKeyboardEvent::RIGHT_ALT: - this->altdown = press; - break; - case SoKeyboardEvent::H: - processed = true; - viewer->saveHomePosition(); - break; - case SoKeyboardEvent::R: - processed = true; - viewer->resetToHomePosition(); - break; - case SoKeyboardEvent::S: - case SoKeyboardEvent::HOME: - case SoKeyboardEvent::LEFT_ARROW: - case SoKeyboardEvent::UP_ARROW: - case SoKeyboardEvent::RIGHT_ARROW: - case SoKeyboardEvent::DOWN_ARROW: - if (!this->isViewing()) - this->setViewing(true); - break; - case SoKeyboardEvent::PAGE_UP: - processed = true; - doZoom(viewer->getSoRenderManager()->getCamera(), getDelta(), posn); - break; - case SoKeyboardEvent::PAGE_DOWN: - processed = true; - doZoom(viewer->getSoRenderManager()->getCamera(), -getDelta(), posn); - break; - default: - break; - } - - return processed; -} - // The viewer is a state machine, and all changes to the current state // are made through this call. void NavigationStyle::setViewingMode(const ViewerMode newmode) @@ -1510,14 +1461,14 @@ SbBool NavigationStyle::processEvent(const SoEvent * const ev) pcPolygon = mouseSelection->getPositions(); selectedRole = mouseSelection->selectedRole(); delete mouseSelection; - mouseSelection = 0; + mouseSelection = nullptr; syncWithEvent(ev); return NavigationStyle::processSoEvent(ev); } else if (hd==AbstractMouseSelection::Cancel) { pcPolygon.clear(); delete mouseSelection; - mouseSelection = 0; + mouseSelection = nullptr; syncWithEvent(ev); return NavigationStyle::processSoEvent(ev); } @@ -1544,27 +1495,19 @@ SbBool NavigationStyle::processEvent(const SoEvent * const ev) SbBool NavigationStyle::processSoEvent(const SoEvent * const ev) { - const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion(); - const SbVec2s size(vp.getViewportSizePixels()); - const SbVec2s pos(ev->getPosition()); - const SbVec2f posn((float) pos[0] / (float) std::max((int)(size[0] - 1), 1), - (float) pos[1] / (float) std::max((int)(size[1] - 1), 1)); bool processed = false; //handle mouse wheel zoom - if(ev->isOfType(SoMouseWheelEvent::getClassTypeId())){ - doZoom( - viewer->getSoRenderManager()->getCamera(), - static_cast(ev)->getDelta(), - posn - ); - processed = true; + if (ev->isOfType(SoMouseWheelEvent::getClassTypeId())) { + const SoMouseWheelEvent * const event = static_cast(ev); + processed = processWheelEvent(event); } - if (! processed) - return viewer->processSoEventBase(ev); - else - return processed; + if (!processed) { + processed = viewer->processSoEventBase(ev); + } + + return processed; } void NavigationStyle::syncWithEvent(const SoEvent * const ev) @@ -1578,15 +1521,7 @@ void NavigationStyle::syncWithEvent(const SoEvent * const ev) // Mismatches in state of the modifier keys happens if the user // presses or releases them outside the viewer window. - if (this->ctrldown != ev->wasCtrlDown()) { - this->ctrldown = ev->wasCtrlDown(); - } - if (this->shiftdown != ev->wasShiftDown()) { - this->shiftdown = ev->wasShiftDown(); - } - if (this->altdown != ev->wasAltDown()) { - this->altdown = ev->wasAltDown(); - } + syncModifierKeys(ev); // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { @@ -1664,12 +1599,111 @@ SbBool NavigationStyle::processMotionEvent(const SoMotion3Event * const ev) return true; } +SbBool NavigationStyle::processKeyboardEvent(const SoKeyboardEvent * const event) +{ + SbBool processed = false; + const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; + switch (event->getKey()) { + case SoKeyboardEvent::LEFT_CONTROL: + case SoKeyboardEvent::RIGHT_CONTROL: + this->ctrldown = press; + break; + case SoKeyboardEvent::LEFT_SHIFT: + case SoKeyboardEvent::RIGHT_SHIFT: + this->shiftdown = press; + break; + case SoKeyboardEvent::LEFT_ALT: + case SoKeyboardEvent::RIGHT_ALT: + this->altdown = press; + break; + case SoKeyboardEvent::H: + processed = true; + viewer->saveHomePosition(); + break; + case SoKeyboardEvent::R: + processed = true; + viewer->resetToHomePosition(); + break; + case SoKeyboardEvent::S: + case SoKeyboardEvent::HOME: + case SoKeyboardEvent::LEFT_ARROW: + case SoKeyboardEvent::UP_ARROW: + case SoKeyboardEvent::RIGHT_ARROW: + case SoKeyboardEvent::DOWN_ARROW: + if (!this->isViewing()) + this->setViewing(true); + break; + case SoKeyboardEvent::PAGE_UP: + { + processed = true; + const SbVec2f posn = normalizePixelPos(event->getPosition()); + doZoom(viewer->getSoRenderManager()->getCamera(), getDelta(), posn); + break; + } + case SoKeyboardEvent::PAGE_DOWN: + { + processed = true; + const SbVec2f posn = normalizePixelPos(event->getPosition()); + doZoom(viewer->getSoRenderManager()->getCamera(), -getDelta(), posn); + break; + } + default: + break; + } + + return processed; +} + +SbBool NavigationStyle::processClickEvent(const SoMouseButtonEvent * const event) +{ + // issue #0002433: avoid to swallow the UP event if down the + // scene graph somewhere a dialog gets opened + SbBool processed = false; + const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; + if (press) { + SbTime tmp = (event->getTime() - mouseDownConsumedEvent.getTime()); + float dci = (float)QApplication::doubleClickInterval()/1000.0f; + // a double-click? + if (tmp.getValue() < dci) { + mouseDownConsumedEvent = *event; + mouseDownConsumedEvent.setTime(event->getTime()); + processed = true; + } + else { + mouseDownConsumedEvent.setTime(event->getTime()); + // 'ANY' is used to mark that we don't know yet if it will + // be a double-click event. + mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY); + } + } + else if (!press) { + if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON1) { + // now handle the postponed event + NavigationStyle::processSoEvent(&mouseDownConsumedEvent); + mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY); + } + } + + return processed; +} + +SbBool NavigationStyle::processWheelEvent(const SoMouseWheelEvent * const event) +{ + const SbVec2s pos(event->getPosition()); + const SbVec2f posn = normalizePixelPos(pos); + + //handle mouse wheel zoom + doZoom(viewer->getSoRenderManager()->getCamera(), + event->getDelta(), posn); + return true; +} + void NavigationStyle::setPopupMenuEnabled(const SbBool on) { this->menuenabled = on; } -SbBool NavigationStyle::isPopupMenuEnabled(void) const +SbBool NavigationStyle::isPopupMenuEnabled() const { return this->menuenabled; } diff --git a/src/Gui/NavigationStyle.h b/src/Gui/NavigationStyle.h index 5f394c550b..7f493ec55a 100644 --- a/src/Gui/NavigationStyle.h +++ b/src/Gui/NavigationStyle.h @@ -37,9 +37,11 @@ #include #include #include +#include // forward declarations class SoEvent; +class SoMouseWheelEvent; class SoMotion3Event; class SoQtViewer; class SoCamera; @@ -115,11 +117,11 @@ public: void setViewer(View3DInventorViewer*); void setAnimationEnabled(const SbBool enable); - SbBool isAnimationEnabled(void) const; + SbBool isAnimationEnabled() const; void startAnimating(const SbVec3f& axis, float velocity); - void stopAnimating(void); - SbBool isAnimating(void) const; + void stopAnimating(); + SbBool isAnimating() const; void setSensitivity(float); float getSensitivity() const; @@ -151,16 +153,19 @@ public: int getViewingMode() const; virtual SbBool processEvent(const SoEvent * const ev); virtual SbBool processMotionEvent(const SoMotion3Event * const ev); + virtual SbBool processKeyboardEvent(const SoKeyboardEvent * const event); + virtual SbBool processClickEvent(const SoMouseButtonEvent * const event); + virtual SbBool processWheelEvent(const SoMouseWheelEvent * const event); void setPopupMenuEnabled(const SbBool on); - SbBool isPopupMenuEnabled(void) const; + SbBool isPopupMenuEnabled() const; void startSelection(AbstractMouseSelection*); void startSelection(SelectionMode = Lasso); void abortSelection(); void stopSelection(); SbBool isSelecting() const; - const std::vector& getPolygon(SelectionRole* role=0) const; + const std::vector& getPolygon(SelectionRole* role=nullptr) const; void setOrbitStyle(OrbitStyle style); OrbitStyle getOrbitStyle() const; @@ -169,13 +174,13 @@ protected: void initialize(); void finalize(); - void interactiveCountInc(void); - void interactiveCountDec(void); - int getInteractiveCount(void) const; + void interactiveCountInc(); + void interactiveCountDec(); + int getInteractiveCount() const; - SbBool isViewing(void) const; + SbBool isViewing() const; void setViewing(SbBool); - SbBool isSeekMode(void) const; + SbBool isSeekMode() const; void setSeekMode(SbBool enable); SbBool seekToPoint(const SbVec2s screenpos); void seekToPoint(const SbVec3f& scenepos); @@ -210,11 +215,10 @@ protected: void syncWithEvent(const SoEvent * const ev); virtual void openPopupMenu(const SbVec2s& position); - void clearLog(void); + void clearLog(); void addToLog(const SbVec2s pos, const SbTime time); void syncModifierKeys(const SoEvent * const ev); - SbBool handleKeyboardEvent(const SoKeyboardEvent * const event, const SbVec2f & posn); protected: struct { // tracking mouse movement in a log @@ -226,6 +230,7 @@ protected: View3DInventorViewer* viewer; ViewerMode currentmode; + SoMouseButtonEvent mouseDownConsumedEvent; SbVec2f lastmouseposition; SbVec2s globalPos; SbVec2s localPos; @@ -295,9 +300,6 @@ public: protected: SbBool processSoEvent(const SoEvent * const ev); - -private: - SoMouseButtonEvent mouseDownConsumedEvent; }; class GuiExport CADNavigationStyle : public UserNavigationStyle { @@ -315,7 +317,6 @@ protected: private: SbBool lockButton1; - SoMouseButtonEvent mouseDownConsumedEvent; }; class GuiExport RevitNavigationStyle : public UserNavigationStyle { @@ -333,7 +334,6 @@ protected: private: SbBool lockButton1; - SoMouseButtonEvent mouseDownConsumedEvent; }; class GuiExport BlenderNavigationStyle : public UserNavigationStyle { @@ -351,7 +351,6 @@ protected: private: SbBool lockButton1; - SoMouseButtonEvent mouseDownConsumedEvent; }; class GuiExport MayaGestureNavigationStyle : public UserNavigationStyle { @@ -371,7 +370,7 @@ protected: short mouseMoveThreshold;//setting. Minimum move required to consider it a move (in pixels). bool mouseMoveThresholdBroken;//a flag that the move threshold was surpassed since last mousedown. int mousedownConsumedCount;//a flag for remembering that a mousedown of button1/button2 was consumed. - SoMouseButtonEvent mousedownConsumedEvent[5];//the event that was consumed and is to be refired. 2 should be enough, but just for a case of the maximum 5 buttons... + SoMouseButtonEvent mousedownConsumedEvents[5];//the event that was consumed and is to be refired. 2 should be enough, but just for a case of the maximum 5 buttons... bool testMoveThreshold(const SbVec2s currentPos) const; bool thisClickIsComplex;//a flag that becomes set when a complex clicking pattern is detected (i.e., two or more mouse buttons were down at the same time). @@ -390,9 +389,6 @@ public: protected: SbBool processSoEvent(const SoEvent * const ev); - -private: - SoMouseButtonEvent mouseDownConsumedEvent; }; class GuiExport OpenCascadeNavigationStyle : public UserNavigationStyle { @@ -407,9 +403,6 @@ public: protected: SbBool processSoEvent(const SoEvent * const ev); - -private: - SoMouseButtonEvent mouseDownConsumedEvent; }; class GuiExport OpenSCADNavigationStyle : public UserNavigationStyle { @@ -424,9 +417,20 @@ public: protected: SbBool processSoEvent(const SoEvent * const ev); +}; -private: - SoMouseButtonEvent mouseDownConsumedEvent; +class GuiExport TinkerCADNavigationStyle : public UserNavigationStyle { + typedef UserNavigationStyle inherited; + + TYPESYSTEM_HEADER(); + +public: + TinkerCADNavigationStyle(); + ~TinkerCADNavigationStyle(); + const char* mouseButtons(ViewerMode); + +protected: + SbBool processSoEvent(const SoEvent * const ev); }; } // namespace Gui diff --git a/src/Gui/OpenCascadeNavigationStyle.cpp b/src/Gui/OpenCascadeNavigationStyle.cpp index 58501d9d7b..1cbf7b322e 100644 --- a/src/Gui/OpenCascadeNavigationStyle.cpp +++ b/src/Gui/OpenCascadeNavigationStyle.cpp @@ -117,7 +117,7 @@ SbBool OpenCascadeNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { const SoKeyboardEvent * const event = static_cast(ev); - processed = handleKeyboardEvent(event, posn); + processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling @@ -146,30 +146,8 @@ SbBool OpenCascadeNavigationStyle::processSoEvent(const SoEvent * const ev) else if (viewer->isEditing() && (this->currentmode == NavigationStyle::SPINNING)) { processed = true; } - // issue #0002433: avoid to swallow the UP event if down the - // scene graph somewhere a dialog gets opened - else if (press) { - SbTime tmp = (ev->getTime() - mouseDownConsumedEvent.getTime()); - float dci = (float)QApplication::doubleClickInterval()/1000.0f; - // a double-click? - if (tmp.getValue() < dci) { - mouseDownConsumedEvent = *event; - mouseDownConsumedEvent.setTime(ev->getTime()); - processed = true; - } - else { - mouseDownConsumedEvent.setTime(ev->getTime()); - // 'ANY' is used to mark that we don't know yet if it will - // be a double-click event. - mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY); - } - } - else if (!press) { - if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON1) { - // now handle the postponed event - inherited::processSoEvent(&mouseDownConsumedEvent); - mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY); - } + else { + processed = processClickEvent(event); } break; case SoMouseButtonEvent::BUTTON2: diff --git a/src/Gui/OpenSCADNavigationStyle.cpp b/src/Gui/OpenSCADNavigationStyle.cpp index 75b34dac11..c1c1ee1e6b 100644 --- a/src/Gui/OpenSCADNavigationStyle.cpp +++ b/src/Gui/OpenSCADNavigationStyle.cpp @@ -117,7 +117,7 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { const SoKeyboardEvent * const event = static_cast(ev); - processed = handleKeyboardEvent(event, posn); + processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling @@ -146,30 +146,8 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev) else if (viewer->isEditing() && (curmode == NavigationStyle::SPINNING)) { processed = true; } - // issue #0002433: avoid to swallow the UP event if down the - // scene graph somewhere a dialog gets opened - else if (press) { - SbTime tmp = (ev->getTime() - mouseDownConsumedEvent.getTime()); - float dci = (float)QApplication::doubleClickInterval()/1000.0f; - // a double-click? - if (tmp.getValue() < dci) { - mouseDownConsumedEvent = *event; - mouseDownConsumedEvent.setTime(ev->getTime()); - processed = true; - } - else { - mouseDownConsumedEvent.setTime(ev->getTime()); - // 'ANY' is used to mark that we don't know yet if it will - // be a double-click event. - mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY); - } - } - else if (!press) { - if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON1) { - // now handle the postponed event - inherited::processSoEvent(&mouseDownConsumedEvent); - mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY); - } + else { + processed = processClickEvent(event); } break; case SoMouseButtonEvent::BUTTON2: diff --git a/src/Gui/Quarter/ContextMenu.cpp b/src/Gui/Quarter/ContextMenu.cpp index dc28d9500b..88c3535a5e 100644 --- a/src/Gui/Quarter/ContextMenu.cpp +++ b/src/Gui/Quarter/ContextMenu.cpp @@ -58,9 +58,9 @@ ContextMenu::ContextMenu(QuarterWidget * quarterwidget) SoRenderManager * sorendermanager = quarterwidget->getSoRenderManager(); - QActionGroup * rendermodegroup = NULL; - QActionGroup * stereomodegroup = NULL; - QActionGroup * transparencytypegroup = NULL; + QActionGroup * rendermodegroup = nullptr; + QActionGroup * stereomodegroup = nullptr; + QActionGroup * transparencytypegroup = nullptr; foreach (QAction * action, quarterwidget->renderModeActions()) { if (!rendermodegroup) { @@ -138,7 +138,7 @@ ContextMenu::~ContextMenu() } QMenu * -ContextMenu::getMenu(void) const +ContextMenu::getMenu() const { return this->contextmenu; } diff --git a/src/Gui/Quarter/ContextMenu.h b/src/Gui/Quarter/ContextMenu.h index a9965001e3..13603e194d 100644 --- a/src/Gui/Quarter/ContextMenu.h +++ b/src/Gui/Quarter/ContextMenu.h @@ -48,7 +48,7 @@ public: ContextMenu(QuarterWidget * quarterwidget); ~ContextMenu(); - QMenu * getMenu(void) const; + QMenu * getMenu() const; public Q_SLOTS: void changeRenderMode(QAction * action); diff --git a/src/Gui/Quarter/DragDropHandler.cpp b/src/Gui/Quarter/DragDropHandler.cpp index 55b4d9ee43..796295cde8 100644 --- a/src/Gui/Quarter/DragDropHandler.cpp +++ b/src/Gui/Quarter/DragDropHandler.cpp @@ -50,7 +50,7 @@ #include #include -#include +#include namespace SIM { namespace Coin3D { namespace Quarter { @@ -152,7 +152,7 @@ DragDropHandlerP::dropEvent(QDropEvent * event) // attempt to import it root = SoDB::readAll(&in); - if (root == NULL) return; + if (root == nullptr) return; // set new scenegraph this->quarterwidget->setSceneGraph(root); diff --git a/src/Gui/Quarter/EventFilter.cpp b/src/Gui/Quarter/EventFilter.cpp index 695159ceea..faf056d375 100644 --- a/src/Gui/Quarter/EventFilter.cpp +++ b/src/Gui/Quarter/EventFilter.cpp @@ -177,7 +177,7 @@ EventFilter::eventFilter(QObject * obj, QEvent * qevent) Returns mouse position in global coordinates */ const QPoint & -EventFilter::globalMousePosition(void) const +EventFilter::globalMousePosition() const { return PRIVATE(this)->globalmousepos; } diff --git a/src/Gui/Quarter/ImageReader.cpp b/src/Gui/Quarter/ImageReader.cpp index 9d8336e261..75c121db98 100644 --- a/src/Gui/Quarter/ImageReader.cpp +++ b/src/Gui/Quarter/ImageReader.cpp @@ -39,12 +39,12 @@ using namespace SIM::Coin3D::Quarter; -ImageReader::ImageReader(void) +ImageReader::ImageReader() { SbImage::addReadImageCB(ImageReader::readImageCB, this); } -ImageReader::~ImageReader(void) +ImageReader::~ImageReader() { SbImage::removeReadImageCB(ImageReader::readImageCB, this); } diff --git a/src/Gui/Quarter/ImageReader.h b/src/Gui/Quarter/ImageReader.h index a0da5ad526..9d8ad2c186 100644 --- a/src/Gui/Quarter/ImageReader.h +++ b/src/Gui/Quarter/ImageReader.h @@ -43,8 +43,8 @@ namespace SIM { namespace Coin3D { namespace Quarter { class ImageReader { public: - ImageReader(void); - ~ImageReader(void); + ImageReader(); + ~ImageReader(); SbBool readImage(const SbString & filename, SbImage & image) const; diff --git a/src/Gui/Quarter/InputDevice.cpp b/src/Gui/Quarter/InputDevice.cpp index a29d74d7fa..b2cc008b6a 100644 --- a/src/Gui/Quarter/InputDevice.cpp +++ b/src/Gui/Quarter/InputDevice.cpp @@ -48,7 +48,7 @@ using namespace SIM::Coin3D::Quarter; devices. */ -InputDevice::InputDevice(void) : quarter(nullptr) +InputDevice::InputDevice() : quarter(nullptr) { this->mousepos = SbVec2s(0, 0); } diff --git a/src/Gui/Quarter/InteractionMode.cpp b/src/Gui/Quarter/InteractionMode.cpp index d9a0375bcd..f7a577261f 100644 --- a/src/Gui/Quarter/InteractionMode.cpp +++ b/src/Gui/Quarter/InteractionMode.cpp @@ -34,7 +34,7 @@ InteractionMode::setEnabled(bool yes) } bool -InteractionMode::enabled(void) const +InteractionMode::enabled() const { return this->isenabled; } @@ -62,7 +62,7 @@ InteractionMode::setOn(bool on) } bool -InteractionMode::on(void) const +InteractionMode::on() const { return this->altkeydown; } diff --git a/src/Gui/Quarter/InteractionMode.h b/src/Gui/Quarter/InteractionMode.h index 0397b3290f..d2562844b8 100644 --- a/src/Gui/Quarter/InteractionMode.h +++ b/src/Gui/Quarter/InteractionMode.h @@ -54,10 +54,10 @@ public: virtual ~InteractionMode(); void setEnabled(bool yes); - bool enabled(void) const; + bool enabled() const; void setOn(bool on); - bool on(void) const; + bool on() const; protected: virtual bool eventFilter(QObject *, QEvent * event); diff --git a/src/Gui/Quarter/Keyboard.cpp b/src/Gui/Quarter/Keyboard.cpp index b7fbf9f028..e16e4a62f3 100644 --- a/src/Gui/Quarter/Keyboard.cpp +++ b/src/Gui/Quarter/Keyboard.cpp @@ -55,7 +55,7 @@ using namespace SIM::Coin3D::Quarter; #define PRIVATE(obj) obj->pimpl -Keyboard::Keyboard(void) +Keyboard::Keyboard() { PRIVATE(this) = new KeyboardP(this); } @@ -81,7 +81,7 @@ Keyboard::translateEvent(QEvent * event) case QEvent::KeyRelease: return PRIVATE(this)->keyEvent((QKeyEvent *) event); default: - return NULL; + return nullptr; } } diff --git a/src/Gui/Quarter/KeyboardP.cpp b/src/Gui/Quarter/KeyboardP.cpp index 6854ffae7d..1cbc87907c 100644 --- a/src/Gui/Quarter/KeyboardP.cpp +++ b/src/Gui/Quarter/KeyboardP.cpp @@ -44,7 +44,7 @@ KeyboardP::KeyboardP(Keyboard * publ) PUBLIC(this) = publ; this->keyboard = new SoKeyboardEvent; - if (keyboardmap == NULL) { + if (keyboardmap == nullptr) { keyboardmap = new KeyMap; keypadmap = new KeyMap; this->initKeyMap(); @@ -57,7 +57,7 @@ KeyboardP::~KeyboardP() } bool -KeyboardP::debugKeyEvents(void) +KeyboardP::debugKeyEvents() { const char * env = coin_getenv("QUARTER_DEBUG_KEYEVENTS"); return env && (atoi(env) > 0); @@ -103,11 +103,11 @@ KeyboardP::keyEvent(QKeyEvent * qevent) return this->keyboard; } -KeyboardP::KeyMap * KeyboardP::keyboardmap = NULL; -KeyboardP::KeyMap * KeyboardP::keypadmap = NULL; +KeyboardP::KeyMap * KeyboardP::keyboardmap = nullptr; +KeyboardP::KeyMap * KeyboardP::keypadmap = nullptr; void -KeyboardP::initKeyMap(void) +KeyboardP::initKeyMap() { // keyboard keyboardmap->insert(Qt::Key_Shift, SoKeyboardEvent::LEFT_SHIFT); diff --git a/src/Gui/Quarter/KeyboardP.h b/src/Gui/Quarter/KeyboardP.h index e5dfe6a998..fb0e5d2cbd 100644 --- a/src/Gui/Quarter/KeyboardP.h +++ b/src/Gui/Quarter/KeyboardP.h @@ -49,8 +49,8 @@ public: ~KeyboardP(); const SoEvent * keyEvent(QKeyEvent * event); - void initKeyMap(void); - static bool debugKeyEvents(void); + void initKeyMap(); + static bool debugKeyEvents(); typedef QMap KeyMap; static KeyMap * keyboardmap; diff --git a/src/Gui/Quarter/Mouse.cpp b/src/Gui/Quarter/Mouse.cpp index 6667dee6bd..fa182955fc 100644 --- a/src/Gui/Quarter/Mouse.cpp +++ b/src/Gui/Quarter/Mouse.cpp @@ -95,7 +95,7 @@ using namespace SIM::Coin3D::Quarter; #define PRIVATE(obj) obj->pimpl #define PUBLIC(obj) obj->publ -Mouse::Mouse(void) +Mouse::Mouse() { PRIVATE(this) = new MouseP(this); } @@ -131,9 +131,9 @@ Mouse::translateEvent(QEvent * event) return PRIVATE(this)->mouseWheelEvent((QWheelEvent *) event); case QEvent::Resize: PRIVATE(this)->resizeEvent((QResizeEvent *) event); - return NULL; + return nullptr; default: - return NULL; + return nullptr; } } diff --git a/src/Gui/Quarter/NativeEvent.cpp b/src/Gui/Quarter/NativeEvent.cpp index def9b09c02..790f21cd68 100644 --- a/src/Gui/Quarter/NativeEvent.cpp +++ b/src/Gui/Quarter/NativeEvent.cpp @@ -55,7 +55,7 @@ NativeEvent::getEvent() const NativeEvent::NativeEvent() : QEvent(QEvent::User) { - this->rawevent = NULL; + this->rawevent = nullptr; } #endif // !HAVE_SPACENAV_LIB diff --git a/src/Gui/Quarter/QtCoinCompatibility.cpp b/src/Gui/Quarter/QtCoinCompatibility.cpp index 3ffd38cf81..c62431a462 100644 --- a/src/Gui/Quarter/QtCoinCompatibility.cpp +++ b/src/Gui/Quarter/QtCoinCompatibility.cpp @@ -22,7 +22,7 @@ QtCoinCompatibility::QImageToSbImage(const QImage & image, SbImage & sbimage) } SbVec2s size((short) w, (short) h); - sbimage.setValue(size, c, NULL); + sbimage.setValue(size, c, nullptr); unsigned char * buffer = sbimage.getValue(size, c); if (c == 1) { diff --git a/src/Gui/Quarter/Quarter.cpp b/src/Gui/Quarter/Quarter.cpp index 5d48a0f64a..976b02e478 100644 --- a/src/Gui/Quarter/Quarter.cpp +++ b/src/Gui/Quarter/Quarter.cpp @@ -152,7 +152,7 @@ using namespace SIM::Coin3D::Quarter; -static QuarterP * self = NULL; +static QuarterP * self = nullptr; /*! initialize Quarter, and implicitly Coin @@ -182,14 +182,14 @@ Quarter::init(bool initCoin) clean up resources */ void -Quarter::clean(void) +Quarter::clean() { COMPILE_ONLY_BEFORE(2,0,0,"Should not be encapsulated in double Quarter namespace"); assert(self); bool initCoin = self->initCoin; delete self; - self = NULL; + self = nullptr; if (initCoin) { // SoDB::finish() will clean up everything that has been diff --git a/src/Gui/Quarter/Quarter.h b/src/Gui/Quarter/Quarter.h index 1853b5118e..22e538e7c2 100644 --- a/src/Gui/Quarter/Quarter.h +++ b/src/Gui/Quarter/Quarter.h @@ -39,7 +39,7 @@ namespace SIM { namespace Coin3D { namespace Quarter { namespace Quarter { void QUARTER_DLL_API init(bool initCoin = true); - void QUARTER_DLL_API clean(void); + void QUARTER_DLL_API clean(); void QUARTER_DLL_API setTimerEpsilon(double sec); } diff --git a/src/Gui/Quarter/QuarterP.cpp b/src/Gui/Quarter/QuarterP.cpp index fbfd30e380..f227527065 100644 --- a/src/Gui/Quarter/QuarterP.cpp +++ b/src/Gui/Quarter/QuarterP.cpp @@ -4,13 +4,13 @@ #include "KeyboardP.h" using namespace SIM::Coin3D::Quarter; -QuarterP::StateCursorMap * QuarterP::statecursormap = NULL; +QuarterP::StateCursorMap * QuarterP::statecursormap = nullptr; -QuarterP::QuarterP(void) +QuarterP::QuarterP() { this->sensormanager = new SensorManager; this->imagereader = new ImageReader; - assert(QuarterP::statecursormap == NULL); + assert(QuarterP::statecursormap == nullptr); QuarterP::statecursormap = new StateCursorMap; } @@ -20,17 +20,17 @@ QuarterP::~QuarterP() delete this->imagereader; delete this->sensormanager; - assert(QuarterP::statecursormap != NULL); + assert(QuarterP::statecursormap != nullptr); delete QuarterP::statecursormap; // FIXME: Why not use an atexit mechanism for this? - if (KeyboardP::keyboardmap != NULL) { + if (KeyboardP::keyboardmap != nullptr) { KeyboardP::keyboardmap->clear(); KeyboardP::keypadmap->clear(); delete KeyboardP::keyboardmap; delete KeyboardP::keypadmap; - KeyboardP::keyboardmap = NULL; - KeyboardP::keypadmap = NULL; + KeyboardP::keyboardmap = nullptr; + KeyboardP::keypadmap = nullptr; } diff --git a/src/Gui/Quarter/QuarterWidget.cpp b/src/Gui/Quarter/QuarterWidget.cpp index e7034760b9..b3376d851c 100644 --- a/src/Gui/Quarter/QuarterWidget.cpp +++ b/src/Gui/Quarter/QuarterWidget.cpp @@ -52,7 +52,7 @@ #pragma warning(disable : 4267) #endif -#include +#include #include #include @@ -152,7 +152,7 @@ class CustomGLWidget : public QOpenGLWidget { public: QSurfaceFormat myFormat; - CustomGLWidget(const QSurfaceFormat& format, QWidget* parent = 0, const QOpenGLWidget* shareWidget = 0, Qt::WindowFlags f = Qt::WindowFlags()) + CustomGLWidget(const QSurfaceFormat& format, QWidget* parent = nullptr, const QOpenGLWidget* shareWidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags()) : QOpenGLWidget(parent, f), myFormat(format) { Q_UNUSED(shareWidget); @@ -308,7 +308,7 @@ QuarterWidget::constructor(const QtGLFormat & format, const QtGLWidget * sharewi PRIVATE(this)->eventfilter = new EventFilter(this); PRIVATE(this)->interactionmode = new InteractionMode(this); - PRIVATE(this)->currentStateMachine = NULL; + PRIVATE(this)->currentStateMachine = nullptr; PRIVATE(this)->headlight = new SoDirectionalLight; PRIVATE(this)->headlight->ref(); @@ -364,10 +364,10 @@ QuarterWidget::~QuarterWidget() delete PRIVATE(this)->currentStateMachine; } PRIVATE(this)->headlight->unref(); - PRIVATE(this)->headlight = NULL; - this->setSceneGraph(NULL); - this->setSoRenderManager(NULL); - this->setSoEventManager(NULL); + PRIVATE(this)->headlight = nullptr; + this->setSceneGraph(nullptr); + this->setSoRenderManager(nullptr); + this->setSoEventManager(nullptr); delete PRIVATE(this)->eventfilter; delete PRIVATE(this); } @@ -418,7 +418,7 @@ QuarterWidget::setHeadlightEnabled(bool onoff) Returns true if the headlight is on, false if it is off */ bool -QuarterWidget::headlightEnabled(void) const +QuarterWidget::headlightEnabled() const { return PRIVATE(this)->headlight->on.getValue(); } @@ -427,7 +427,7 @@ QuarterWidget::headlightEnabled(void) const Returns the light used for the headlight. */ SoDirectionalLight * -QuarterWidget::getHeadlight(void) const +QuarterWidget::getHeadlight() const { return PRIVATE(this)->headlight; } @@ -452,7 +452,7 @@ QuarterWidget::setClearZBuffer(bool onoff) Returns true if the z buffer is cleared before rendering. */ bool -QuarterWidget::clearZBuffer(void) const +QuarterWidget::clearZBuffer() const { return PRIVATE(this)->clearzbuffer; } @@ -477,7 +477,7 @@ QuarterWidget::setClearWindow(bool onoff) Returns true if the rendering buffer is cleared before rendering. */ bool -QuarterWidget::clearWindow(void) const +QuarterWidget::clearWindow() const { return PRIVATE(this)->clearwindow; } @@ -503,7 +503,7 @@ QuarterWidget::setInteractionModeEnabled(bool onoff) Returns true if interaction mode is enabled, false otherwise. */ bool -QuarterWidget::interactionModeEnabled(void) const +QuarterWidget::interactionModeEnabled() const { return PRIVATE(this)->interactionmode->enabled(); } @@ -527,7 +527,7 @@ QuarterWidget::setInteractionModeOn(bool onoff) Returns true if interaction mode is on. */ bool -QuarterWidget::interactionModeOn(void) const +QuarterWidget::interactionModeOn() const { return PRIVATE(this)->interactionmode->on(); } @@ -536,7 +536,7 @@ QuarterWidget::interactionModeOn(void) const Returns the Coin cache context id for this widget. */ uint32_t -QuarterWidget::getCacheContextId(void) const +QuarterWidget::getCacheContextId() const { return PRIVATE(this)->getCacheContextId(); } @@ -562,7 +562,7 @@ QuarterWidget::setTransparencyType(TransparencyType type) \retval The current \ref TransparencyType */ QuarterWidget::TransparencyType -QuarterWidget::transparencyType(void) const +QuarterWidget::transparencyType() const { assert(PRIVATE(this)->sorendermanager); SoGLRenderAction * action = PRIVATE(this)->sorendermanager->getGLRenderAction(); @@ -590,7 +590,7 @@ QuarterWidget::setRenderMode(RenderMode mode) \retval The current \ref RenderMode */ QuarterWidget::RenderMode -QuarterWidget::renderMode(void) const +QuarterWidget::renderMode() const { assert(PRIVATE(this)->sorendermanager); return static_cast(PRIVATE(this)->sorendermanager->getRenderMode()); @@ -618,7 +618,7 @@ QuarterWidget::setStereoMode(StereoMode mode) \retval The current \ref StereoMode */ QuarterWidget::StereoMode -QuarterWidget::stereoMode(void) const +QuarterWidget::stereoMode() const { assert(PRIVATE(this)->sorendermanager); return static_cast(PRIVATE(this)->sorendermanager->getStereoMode()); @@ -636,7 +636,7 @@ the widget is located within, and updated whenever any change occurs, emitting a */ qreal -QuarterWidget::devicePixelRatio(void) const +QuarterWidget::devicePixelRatio() const { return PRIVATE(this)->device_pixel_ratio; } @@ -653,11 +653,11 @@ QuarterWidget::setSceneGraph(SoNode * node) if (PRIVATE(this)->scene) { PRIVATE(this)->scene->unref(); - PRIVATE(this)->scene = NULL; + PRIVATE(this)->scene = nullptr; } - SoCamera * camera = NULL; - SoSeparator * superscene = NULL; + SoCamera * camera = nullptr; + SoSeparator * superscene = nullptr; bool viewall = false; if (node) { @@ -690,7 +690,7 @@ QuarterWidget::setSceneGraph(SoNode * node) Returns pointer to root of scene graph */ SoNode * -QuarterWidget::getSceneGraph(void) const +QuarterWidget::getSceneGraph() const { return PRIVATE(this)->scene; } @@ -702,10 +702,10 @@ void QuarterWidget::setSoRenderManager(SoRenderManager * manager) { bool carrydata = false; - SoNode * scene = NULL; - SoCamera * camera = NULL; + SoNode * scene = nullptr; + SoCamera * camera = nullptr; SbViewportRegion vp; - if (PRIVATE(this)->sorendermanager && (manager != NULL)) { + if (PRIVATE(this)->sorendermanager && (manager != nullptr)) { scene = PRIVATE(this)->sorendermanager->getSceneGraph(); camera = PRIVATE(this)->sorendermanager->getCamera(); vp = PRIVATE(this)->sorendermanager->getViewportRegion(); @@ -735,7 +735,7 @@ QuarterWidget::setSoRenderManager(SoRenderManager * manager) Returns a pointer to the render manager. */ SoRenderManager * -QuarterWidget::getSoRenderManager(void) const +QuarterWidget::getSoRenderManager() const { return PRIVATE(this)->sorendermanager; } @@ -747,10 +747,10 @@ void QuarterWidget::setSoEventManager(SoEventManager * manager) { bool carrydata = false; - SoNode * scene = NULL; - SoCamera * camera = NULL; + SoNode * scene = nullptr; + SoCamera * camera = nullptr; SbViewportRegion vp; - if (PRIVATE(this)->soeventmanager && (manager != NULL)) { + if (PRIVATE(this)->soeventmanager && (manager != nullptr)) { scene = PRIVATE(this)->soeventmanager->getSceneGraph(); camera = PRIVATE(this)->soeventmanager->getCamera(); vp = PRIVATE(this)->soeventmanager->getViewportRegion(); @@ -780,7 +780,7 @@ QuarterWidget::setSoEventManager(SoEventManager * manager) Returns a pointer to the event manager */ SoEventManager * -QuarterWidget::getSoEventManager(void) const +QuarterWidget::getSoEventManager() const { return PRIVATE(this)->soeventmanager; } @@ -789,7 +789,7 @@ QuarterWidget::getSoEventManager(void) const Returns a pointer to the event filter */ EventFilter * -QuarterWidget::getEventFilter(void) const +QuarterWidget::getEventFilter() const { return PRIVATE(this)->eventfilter; } @@ -798,7 +798,7 @@ QuarterWidget::getEventFilter(void) const Reposition the current camera to display the entire scene */ void -QuarterWidget::viewAll(void) +QuarterWidget::viewAll() { const SbName viewallevent("sim.coin3d.coin.navigation.ViewAll"); for (int c = 0; c < PRIVATE(this)->soeventmanager->getNumSoScXMLStateMachines(); ++c) { @@ -816,7 +816,7 @@ QuarterWidget::viewAll(void) Camera typically seeks towards what the mouse is pointing at. */ void -QuarterWidget::seek(void) +QuarterWidget::seek() { const SbName seekevent("sim.coin3d.coin.navigation.Seek"); for (int c = 0; c < PRIVATE(this)->soeventmanager->getNumSoScXMLStateMachines(); ++c) { @@ -830,10 +830,10 @@ QuarterWidget::seek(void) } bool -QuarterWidget::updateDevicePixelRatio(void) { +QuarterWidget::updateDevicePixelRatio() { qreal dev_pix_ratio = 1.0; QWidget* winwidg = window(); - QWindow* win = NULL; + QWindow* win = nullptr; if(winwidg) { win = winwidg->windowHandle(); } @@ -1023,7 +1023,7 @@ bool QuarterWidget::viewportEvent(QEvent* event) render manager and render the scene by calling this method. */ void -QuarterWidget::redraw(void) +QuarterWidget::redraw() { // we're triggering the next paintGL(). Set a flag to remember this // to avoid that we process the delay queue in paintGL() @@ -1050,7 +1050,7 @@ QuarterWidget::redraw(void) Overridden from QGLWidget to render the scenegraph */ void -QuarterWidget::actualRedraw(void) +QuarterWidget::actualRedraw() { PRIVATE(this)->sorendermanager->render(PRIVATE(this)->clearwindow, PRIVATE(this)->clearzbuffer); @@ -1102,7 +1102,7 @@ QuarterWidget::setBackgroundColor(const QColor & color) rendering the scene. */ QColor -QuarterWidget::backgroundColor(void) const +QuarterWidget::backgroundColor() const { SbColor4f bg = PRIVATE(this)->sorendermanager->getBackgroundColor(); @@ -1116,7 +1116,7 @@ QuarterWidget::backgroundColor(void) const Returns the context menu used by the widget. */ QMenu * -QuarterWidget::getContextMenu(void) const +QuarterWidget::getContextMenu() const { return PRIVATE(this)->contextMenu(); } @@ -1125,7 +1125,7 @@ QuarterWidget::getContextMenu(void) const \retval Is context menu enabled? */ bool -QuarterWidget::contextMenuEnabled(void) const +QuarterWidget::contextMenuEnabled() const { return PRIVATE(this)->contextmenuenabled; } @@ -1175,8 +1175,8 @@ void QuarterWidget::removeStateMachine(SoScXMLStateMachine * statemachine) { SoEventManager * em = this->getSoEventManager(); - statemachine->setSceneGraphRoot(NULL); - statemachine->setActiveCamera(NULL); + statemachine->setSceneGraphRoot(nullptr); + statemachine->setActiveCamera(nullptr); em->removeSoScXMLStateMachine(statemachine); } @@ -1184,7 +1184,7 @@ QuarterWidget::removeStateMachine(SoScXMLStateMachine * statemachine) See \ref QWidget::minimumSizeHint */ QSize -QuarterWidget::minimumSizeHint(void) const +QuarterWidget::minimumSizeHint() const { return QSize(50, 50); } @@ -1195,7 +1195,7 @@ QuarterWidget::minimumSizeHint(void) const QuarterWidget, add these actions to the menu. */ QList -QuarterWidget::transparencyTypeActions(void) const +QuarterWidget::transparencyTypeActions() const { return PRIVATE(this)->transparencyTypeActions(); } @@ -1206,7 +1206,7 @@ QuarterWidget::transparencyTypeActions(void) const QuarterWidget, add these actions to the menu. */ QList -QuarterWidget::stereoModeActions(void) const +QuarterWidget::stereoModeActions() const { return PRIVATE(this)->stereoModeActions(); } @@ -1217,7 +1217,7 @@ QuarterWidget::stereoModeActions(void) const QuarterWidget, add these actions to the menu. */ QList -QuarterWidget::renderModeActions(void) const +QuarterWidget::renderModeActions() const { return PRIVATE(this)->renderModeActions(); } @@ -1239,7 +1239,7 @@ QuarterWidget::renderModeActions(void) const Removes any navigationModeFile set. */ void -QuarterWidget::resetNavigationModeFile(void) { +QuarterWidget::resetNavigationModeFile() { this->setNavigationModeFile(QUrl()); } @@ -1276,7 +1276,7 @@ QuarterWidget::setNavigationModeFile(const QUrl & url) if (PRIVATE(this)->currentStateMachine) { this->removeStateMachine(PRIVATE(this)->currentStateMachine); delete PRIVATE(this)->currentStateMachine; - PRIVATE(this)->currentStateMachine = NULL; + PRIVATE(this)->currentStateMachine = nullptr; PRIVATE(this)->navigationModeFile = url; } return; @@ -1287,7 +1287,7 @@ QuarterWidget::setNavigationModeFile(const QUrl & url) } QByteArray filenametmp = filename.toLocal8Bit(); - ScXMLStateMachine * stateMachine = NULL; + ScXMLStateMachine * stateMachine = nullptr; if (filenametmp.startsWith("coin:")){ stateMachine = ScXML::readFile(filenametmp.data()); @@ -1350,7 +1350,7 @@ QuarterWidget::setNavigationModeFile(const QUrl & url) \retval The current navigationModeFile */ const QUrl & -QuarterWidget::navigationModeFile(void) const +QuarterWidget::navigationModeFile() const { return PRIVATE(this)->navigationModeFile; } diff --git a/src/Gui/Quarter/QuarterWidget.h b/src/Gui/Quarter/QuarterWidget.h index d69bf2c5b6..80e781b613 100644 --- a/src/Gui/Quarter/QuarterWidget.h +++ b/src/Gui/Quarter/QuarterWidget.h @@ -81,9 +81,9 @@ class QUARTER_DLL_API QuarterWidget : public QGraphicsView { public: - explicit QuarterWidget(QWidget * parent = 0, const QtGLWidget * sharewidget = 0, Qt::WindowFlags f = Qt::WindowFlags()); - explicit QuarterWidget(QtGLContext * context, QWidget * parent = 0, const QtGLWidget * sharewidget = 0, Qt::WindowFlags f = Qt::WindowFlags()); - explicit QuarterWidget(const QtGLFormat & format, QWidget * parent = 0, const QtGLWidget * shareWidget = 0, Qt::WindowFlags f = Qt::WindowFlags()); + explicit QuarterWidget(QWidget * parent = nullptr, const QtGLWidget * sharewidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); + explicit QuarterWidget(QtGLContext * context, QWidget * parent = nullptr, const QtGLWidget * sharewidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); + explicit QuarterWidget(const QtGLFormat & format, QWidget * parent = nullptr, const QtGLWidget * shareWidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); virtual ~QuarterWidget(); enum TransparencyType { @@ -117,70 +117,70 @@ public: INTERLEAVED_COLUMNS = SoRenderManager::INTERLEAVED_COLUMNS }; - TransparencyType transparencyType(void) const; - RenderMode renderMode(void) const; - StereoMode stereoMode(void) const; + TransparencyType transparencyType() const; + RenderMode renderMode() const; + StereoMode stereoMode() const; void setBackgroundColor(const QColor & color); - QColor backgroundColor(void) const; + QColor backgroundColor() const; - qreal devicePixelRatio(void) const; + qreal devicePixelRatio() const; - void resetNavigationModeFile(void); + void resetNavigationModeFile(); void setNavigationModeFile(const QUrl & url = QUrl(QString::fromLatin1(DEFAULT_NAVIGATIONFILE))); - const QUrl & navigationModeFile(void) const; + const QUrl & navigationModeFile() const; void setContextMenuEnabled(bool yes); - bool contextMenuEnabled(void) const; - QMenu * getContextMenu(void) const; + bool contextMenuEnabled() const; + QMenu * getContextMenu() const; - bool headlightEnabled(void) const; + bool headlightEnabled() const; void setHeadlightEnabled(bool onoff); - SoDirectionalLight * getHeadlight(void) const; + SoDirectionalLight * getHeadlight() const; - bool clearZBuffer(void) const; + bool clearZBuffer() const; void setClearZBuffer(bool onoff); - bool clearWindow(void) const; + bool clearWindow() const; void setClearWindow(bool onoff); - bool interactionModeEnabled(void) const; + bool interactionModeEnabled() const; void setInteractionModeEnabled(bool onoff); - bool interactionModeOn(void) const; + bool interactionModeOn() const; void setInteractionModeOn(bool onoff); void setStateCursor(const SbName & state, const QCursor & cursor); QCursor stateCursor(const SbName & state); - uint32_t getCacheContextId(void) const; + uint32_t getCacheContextId() const; virtual void setSceneGraph(SoNode * root); - virtual SoNode * getSceneGraph(void) const; + virtual SoNode * getSceneGraph() const; void setSoEventManager(SoEventManager * manager); - SoEventManager * getSoEventManager(void) const; + SoEventManager * getSoEventManager() const; void setSoRenderManager(SoRenderManager * manager); - SoRenderManager * getSoRenderManager(void) const; + SoRenderManager * getSoRenderManager() const; - EventFilter * getEventFilter(void) const; + EventFilter * getEventFilter() const; void addStateMachine(SoScXMLStateMachine * statemachine); void removeStateMachine(SoScXMLStateMachine * statemachine); virtual bool processSoEvent(const SoEvent * event); - virtual QSize minimumSizeHint(void) const; + virtual QSize minimumSizeHint() const; - QList transparencyTypeActions(void) const; - QList stereoModeActions(void) const; - QList renderModeActions(void) const; + QList transparencyTypeActions() const; + QList stereoModeActions() const; + QList renderModeActions() const; public Q_SLOTS: - virtual void viewAll(void); - virtual void seek(void); + virtual void viewAll(); + virtual void seek(); - void redraw(void); + void redraw(); void setRenderMode(RenderMode mode); void setStereoMode(StereoMode mode); @@ -197,8 +197,8 @@ protected: virtual void paintEvent(QPaintEvent*); virtual void resizeEvent(QResizeEvent*); virtual bool viewportEvent(QEvent* event); - virtual void actualRedraw(void); - virtual bool updateDevicePixelRatio(void); + virtual void actualRedraw(); + virtual bool updateDevicePixelRatio(); private: void constructor(const QtGLFormat& format, const QtGLWidget* sharewidget); diff --git a/src/Gui/Quarter/QuarterWidgetP.cpp b/src/Gui/Quarter/QuarterWidgetP.cpp index 4cba6614b3..8c5a84c84f 100644 --- a/src/Gui/Quarter/QuarterWidgetP.cpp +++ b/src/Gui/Quarter/QuarterWidgetP.cpp @@ -57,7 +57,7 @@ #include "ContextMenu.h" #include "QuarterP.h" -#include +#include using namespace SIM::Coin3D::Quarter; @@ -67,19 +67,19 @@ public: SbList widgetlist; }; -static SbList * cachecontext_list = NULL; +static SbList * cachecontext_list = nullptr; QuarterWidgetP::QuarterWidgetP(QuarterWidget * masterptr, const QtGLWidget * sharewidget) : master(masterptr), - scene(NULL), - eventfilter(NULL), - interactionmode(NULL), - sorendermanager(NULL), - soeventmanager(NULL), + scene(nullptr), + eventfilter(nullptr), + interactionmode(nullptr), + sorendermanager(nullptr), + soeventmanager(nullptr), initialsorendermanager(false), initialsoeventmanager(false), - headlight(NULL), - cachecontext(NULL), + headlight(nullptr), + cachecontext(nullptr), contextmenuenabled(true), autoredrawenabled(true), interactionmodeenabled(false), @@ -87,7 +87,7 @@ QuarterWidgetP::QuarterWidgetP(QuarterWidget * masterptr, const QtGLWidget * sha clearwindow(true), addactions(true), device_pixel_ratio(1.0), - contextmenu(NULL) + contextmenu(nullptr) { this->cachecontext = findCacheContext(masterptr, sharewidget); @@ -121,11 +121,11 @@ QuarterWidgetP::searchForCamera(SoNode * root) return (SoCamera *) node; } } - return NULL; + return nullptr; } uint32_t -QuarterWidgetP::getCacheContextId(void) const +QuarterWidgetP::getCacheContextId() const { return this->cachecontext->id; } @@ -133,7 +133,7 @@ QuarterWidgetP::getCacheContextId(void) const QuarterWidgetP_cachecontext * QuarterWidgetP::findCacheContext(QuarterWidget * widget, const QtGLWidget * sharewidget) { - if (cachecontext_list == NULL) { + if (cachecontext_list == nullptr) { // FIXME: static memory leak cachecontext_list = new SbList ; } @@ -257,7 +257,7 @@ QuarterWidgetP::statechangecb(void * userdata, ScXMLStateMachine * statemachine, QList -QuarterWidgetP::transparencyTypeActions(void) const +QuarterWidgetP::transparencyTypeActions() const { if (this->transparencytypeactions.isEmpty()) { this->transparencytypegroup = new QActionGroup(this->master); @@ -277,7 +277,7 @@ QuarterWidgetP::transparencyTypeActions(void) const } QList -QuarterWidgetP::stereoModeActions(void) const +QuarterWidgetP::stereoModeActions() const { if (this->stereomodeactions.isEmpty()) { this->stereomodegroup = new QActionGroup(this->master); @@ -291,7 +291,7 @@ QuarterWidgetP::stereoModeActions(void) const } QList -QuarterWidgetP::renderModeActions(void) const +QuarterWidgetP::renderModeActions() const { if (this->rendermodeactions.isEmpty()) { this->rendermodegroup = new QActionGroup(this->master); @@ -308,7 +308,7 @@ QuarterWidgetP::renderModeActions(void) const #undef ADD_ACTION QMenu * -QuarterWidgetP::contextMenu(void) +QuarterWidgetP::contextMenu() { if (!this->contextmenu) { this->contextmenu = new ContextMenu(this->master); diff --git a/src/Gui/Quarter/QuarterWidgetP.h b/src/Gui/Quarter/QuarterWidgetP.h index 7b5c99dc78..d9373961cb 100644 --- a/src/Gui/Quarter/QuarterWidgetP.h +++ b/src/Gui/Quarter/QuarterWidgetP.h @@ -66,12 +66,12 @@ public: ~QuarterWidgetP(); SoCamera * searchForCamera(SoNode * root); - uint32_t getCacheContextId(void) const; - QMenu * contextMenu(void); + uint32_t getCacheContextId() const; + QMenu * contextMenu(); - QList transparencyTypeActions(void) const; - QList renderModeActions(void) const; - QList stereoModeActions(void) const; + QList transparencyTypeActions() const; + QList renderModeActions() const; + QList stereoModeActions() const; QuarterWidget * const master; SoNode * scene; diff --git a/src/Gui/Quarter/SensorManager.cpp b/src/Gui/Quarter/SensorManager.cpp index 59d2d13b55..5d2ebf115f 100644 --- a/src/Gui/Quarter/SensorManager.cpp +++ b/src/Gui/Quarter/SensorManager.cpp @@ -43,7 +43,7 @@ using namespace SIM::Coin3D::Quarter; -SensorManager::SensorManager(void) +SensorManager::SensorManager() : inherited() { this->mainthreadid = cc_thread_id(); @@ -74,7 +74,7 @@ SensorManager::SensorManager(void) SensorManager::~SensorManager() { // remove the Coin callback before shutting down - SoDB::getSensorManager()->setChangedCallback(NULL, NULL); + SoDB::getSensorManager()->setChangedCallback(nullptr, nullptr); if (this->signalthread->isRunning()) { this->signalthread->stopThread(); @@ -104,7 +104,7 @@ SensorManager::sensorQueueChangedCB(void * closure) } void -SensorManager::sensorQueueChanged(void) +SensorManager::sensorQueueChanged() { SoSensorManager * sensormanager = SoDB::getSensorManager(); assert(sensormanager); @@ -144,7 +144,7 @@ SensorManager::sensorQueueChanged(void) } void -SensorManager::idleTimeout(void) +SensorManager::idleTimeout() { SoDB::getSensorManager()->processTimerQueue(); SoDB::getSensorManager()->processDelayQueue(true); @@ -152,14 +152,14 @@ SensorManager::idleTimeout(void) } void -SensorManager::timerQueueTimeout(void) +SensorManager::timerQueueTimeout() { SoDB::getSensorManager()->processTimerQueue(); this->sensorQueueChanged(); } void -SensorManager::delayTimeout(void) +SensorManager::delayTimeout() { SoDB::getSensorManager()->processTimerQueue(); SoDB::getSensorManager()->processDelayQueue(false); diff --git a/src/Gui/Quarter/SensorManager.h b/src/Gui/Quarter/SensorManager.h index 6344cf93e6..6628ba9e3a 100644 --- a/src/Gui/Quarter/SensorManager.h +++ b/src/Gui/Quarter/SensorManager.h @@ -45,14 +45,14 @@ class SensorManager : public QObject { Q_OBJECT typedef QObject inherited; public: - SensorManager(void); + SensorManager(); ~SensorManager(); public Q_SLOTS: - void idleTimeout(void); - void delayTimeout(void); - void timerQueueTimeout(void); - void sensorQueueChanged(void); + void idleTimeout(); + void delayTimeout(); + void timerQueueTimeout(); + void sensorQueueChanged(); void setTimerEpsilon(double sec); private: diff --git a/src/Gui/Quarter/SignalThread.cpp b/src/Gui/Quarter/SignalThread.cpp index 6d18f8636d..a242286258 100644 --- a/src/Gui/Quarter/SignalThread.cpp +++ b/src/Gui/Quarter/SignalThread.cpp @@ -36,7 +36,7 @@ using namespace SIM::Coin3D::Quarter; -SignalThread::SignalThread(void) +SignalThread::SignalThread() : isstopped(false) { } @@ -46,7 +46,7 @@ SignalThread::~SignalThread() } void -SignalThread::trigger(void) +SignalThread::trigger() { // lock first to make sure the QThread is actually waiting for a signal QMutexLocker ml(&this->mutex); @@ -54,7 +54,7 @@ SignalThread::trigger(void) } void -SignalThread::stopThread(void) +SignalThread::stopThread() { QMutexLocker ml(&this->mutex); this->isstopped = true; @@ -63,7 +63,7 @@ SignalThread::stopThread(void) void -SignalThread::run(void) +SignalThread::run() { QMutexLocker ml(&this->mutex); while (!this->isstopped) { diff --git a/src/Gui/Quarter/SignalThread.h b/src/Gui/Quarter/SignalThread.h index e96117ae0c..718383991b 100644 --- a/src/Gui/Quarter/SignalThread.h +++ b/src/Gui/Quarter/SignalThread.h @@ -44,16 +44,16 @@ namespace SIM { namespace Coin3D { namespace Quarter { class SignalThread : public QThread { Q_OBJECT public: - SignalThread(void); + SignalThread(); virtual ~SignalThread(); - virtual void run(void); - void trigger(void); - void stopThread(void); + virtual void run(); + void trigger(); + void stopThread(); Q_SIGNALS: - void triggerSignal(void); + void triggerSignal(); private: QWaitCondition waitcond; diff --git a/src/Gui/Quarter/SoQTQuarterAdaptor.cpp b/src/Gui/Quarter/SoQTQuarterAdaptor.cpp index 552b055ebe..9d787b3694 100644 --- a/src/Gui/Quarter/SoQTQuarterAdaptor.cpp +++ b/src/Gui/Quarter/SoQTQuarterAdaptor.cpp @@ -168,7 +168,7 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::init() m_seekdistanceabs = false; m_seekperiod = 2.0f; m_inseekmode = false; - m_storedcamera = 0; + m_storedcamera = nullptr; m_viewingflag = false; pickRadius = 5.0; @@ -298,12 +298,12 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::convertPerspective2Ortho(const So out->height = 2.0f * focaldist * (float)tan(in->heightAngle.getValue() / 2.0); } -SoCamera* SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getCamera(void) const +SoCamera* SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getCamera() const { return getSoRenderManager()->getCamera(); } -const SbViewportRegion & SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getViewportRegion(void) const +const SbViewportRegion & SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getViewportRegion() const { return getSoRenderManager()->getViewportRegion(); } @@ -318,17 +318,17 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::setViewing(SbBool enable) if(m_viewingflag) { SoGLRenderAction* action = getSoRenderManager()->getGLRenderAction(); - if(action != NULL) + if(action != nullptr) SoLocateHighlight::turnOffCurrentHighlight(action); } } -SbBool SIM::Coin3D::Quarter::SoQTQuarterAdaptor::isViewing(void) const +SbBool SIM::Coin3D::Quarter::SoQTQuarterAdaptor::isViewing() const { return m_viewingflag; } -void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::interactiveCountInc(void) +void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::interactiveCountInc() { // Catch problems with missing interactiveCountDec() calls. assert(m_interactionnesting < 100); @@ -338,7 +338,7 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::interactiveCountInc(void) } } -void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::interactiveCountDec(void) +void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::interactiveCountDec() { if(--m_interactionnesting <= 0) { m_interactionEndCallback.invokeCallbacks(this); @@ -346,7 +346,7 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::interactiveCountDec(void) } } -int SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getInteractiveCount(void) const +int SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getInteractiveCount() const { return m_interactionnesting; } @@ -372,22 +372,22 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::removeFinishCallback(SIM::Coin3D: } -float SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getSeekDistance(void) const +float SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getSeekDistance() const { return m_seekdistance; } -float SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getSeekTime(void) const +float SIM::Coin3D::Quarter::SoQTQuarterAdaptor::getSeekTime() const { return m_seekperiod; } -SbBool SIM::Coin3D::Quarter::SoQTQuarterAdaptor::isSeekMode(void) const +SbBool SIM::Coin3D::Quarter::SoQTQuarterAdaptor::isSeekMode() const { return m_inseekmode; } -SbBool SIM::Coin3D::Quarter::SoQTQuarterAdaptor::isSeekValuePercentage(void) const +SbBool SIM::Coin3D::Quarter::SoQTQuarterAdaptor::isSeekValuePercentage() const { return m_seekdistanceabs ? false : true; } @@ -541,7 +541,7 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::seeksensorCB(void* data, SoSensor if(end) thisp->setSeekMode(false); } -void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::saveHomePosition(void) +void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::saveHomePosition() { SoCamera* cam = getSoRenderManager()->getCamera(); if (!cam) { @@ -562,7 +562,7 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::saveHomePosition(void) m_storedcamera->copyFieldValues(getSoRenderManager()->getCamera()); } -void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::resetToHomePosition(void) +void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::resetToHomePosition() { SoCamera* cam = getSoRenderManager()->getCamera(); if (!cam) { @@ -724,7 +724,7 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::paintEvent(QPaintEvent* event) this->framesPerSecond = addFrametime(start); } -void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::resetFrameCounter(void) +void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::resetFrameCounter() { this->framecount = 0; this->frametime = 0.0f; diff --git a/src/Gui/Quarter/SoQTQuarterAdaptor.h b/src/Gui/Quarter/SoQTQuarterAdaptor.h index 84956532d4..e9cee0b949 100644 --- a/src/Gui/Quarter/SoQTQuarterAdaptor.h +++ b/src/Gui/Quarter/SoQTQuarterAdaptor.h @@ -47,9 +47,9 @@ typedef void SoQTQuarterAdaptorCB(void* data, SoQTQuarterAdaptor* viewer); class QUARTER_DLL_API SoQTQuarterAdaptor : public QuarterWidget { public: - explicit SoQTQuarterAdaptor(QWidget* parent = 0, const QtGLWidget* sharewidget = 0, Qt::WindowFlags f = Qt::WindowFlags()); - explicit SoQTQuarterAdaptor(const QtGLFormat& format, QWidget* parent = 0, const QtGLWidget* shareWidget = 0, Qt::WindowFlags f = Qt::WindowFlags()); - explicit SoQTQuarterAdaptor(QtGLContext* context, QWidget* parent = 0, const QtGLWidget* sharewidget = 0, Qt::WindowFlags f = Qt::WindowFlags()); + explicit SoQTQuarterAdaptor(QWidget* parent = nullptr, const QtGLWidget* sharewidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); + explicit SoQTQuarterAdaptor(const QtGLFormat& format, QWidget* parent = nullptr, const QtGLWidget* shareWidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); + explicit SoQTQuarterAdaptor(QtGLContext* context, QWidget* parent = nullptr, const QtGLWidget* sharewidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); virtual ~SoQTQuarterAdaptor(); //the functions available in soqtviewer but missing in quarter @@ -59,38 +59,38 @@ public: QWidget* getGLWidget() const; virtual void setCameraType(SoType type); - SoCamera * getCamera(void) const; + SoCamera * getCamera() const; - const SbViewportRegion & getViewportRegion(void) const; + const SbViewportRegion & getViewportRegion() const; virtual void setViewing(SbBool enable); - SbBool isViewing(void) const; + SbBool isViewing() const; - void interactiveCountInc(void); - void interactiveCountDec(void); - int getInteractiveCount(void) const; + void interactiveCountInc(); + void interactiveCountDec(); + int getInteractiveCount() const; - void addStartCallback(SoQTQuarterAdaptorCB* func, void* data = NULL); - void addFinishCallback(SoQTQuarterAdaptorCB* func, void* data = NULL); - void removeStartCallback(SoQTQuarterAdaptorCB* func, void* data = NULL); - void removeFinishCallback(SoQTQuarterAdaptorCB* func, void* data = NULL); + void addStartCallback(SoQTQuarterAdaptorCB* func, void* data = nullptr); + void addFinishCallback(SoQTQuarterAdaptorCB* func, void* data = nullptr); + void removeStartCallback(SoQTQuarterAdaptorCB* func, void* data = nullptr); + void removeFinishCallback(SoQTQuarterAdaptorCB* func, void* data = nullptr); virtual void setSeekMode(SbBool enable); - SbBool isSeekMode(void) const; + SbBool isSeekMode() const; SbBool seekToPoint(const SbVec2s screenpos); void seekToPoint(const SbVec3f& scenepos); void setSeekTime(const float seconds); - float getSeekTime(void) const; + float getSeekTime() const; void setSeekDistance(const float distance); - float getSeekDistance(void) const; + float getSeekDistance() const; void setSeekValueAsPercentage(const SbBool on); - SbBool isSeekValuePercentage(void) const; + SbBool isSeekValuePercentage() const; - virtual float getPickRadius(void) const {return this->pickRadius;} + virtual float getPickRadius() const {return this->pickRadius;} virtual void setPickRadius(float pickRadius); - virtual void saveHomePosition(void); - virtual void resetToHomePosition(void); + virtual void saveHomePosition(); + virtual void resetToHomePosition(); virtual void setSceneGraph(SoNode* root) { QuarterWidget::setSceneGraph(root); @@ -100,7 +100,7 @@ public: virtual void paintEvent(QPaintEvent*); //this functions still need to be ported - virtual void afterRealizeHook(void) {} //enables spacenav and joystick in soqt, dunno if this is needed + virtual void afterRealizeHook() {} //enables spacenav and joystick in soqt, dunno if this is needed private: void init(); @@ -109,7 +109,7 @@ private: void getCameraCoordinateSystem(SoCamera * camera, SoNode * root, SbMatrix & matrix, SbMatrix & inverse); static void seeksensorCB(void * data, SoSensor * s); void moveCameraScreen(const SbVec2f & screenpos); - void resetFrameCounter(void); + void resetFrameCounter(); SbVec2f addFrametime(double ft); bool m_viewingflag; diff --git a/src/Gui/Quarter/SpaceNavigatorDevice.cpp b/src/Gui/Quarter/SpaceNavigatorDevice.cpp index 14fe49e871..5726845439 100644 --- a/src/Gui/Quarter/SpaceNavigatorDevice.cpp +++ b/src/Gui/Quarter/SpaceNavigatorDevice.cpp @@ -128,7 +128,7 @@ const SoEvent * SpaceNavigatorDevice::translateEvent(QEvent * event) { Q_UNUSED(event); - SoEvent * ret = NULL; + SoEvent * ret = nullptr; #ifdef HAVE_SPACENAV_LIB NativeEvent * ce = dynamic_cast(event); diff --git a/src/Gui/Quarter/devices/InputDevice.h b/src/Gui/Quarter/devices/InputDevice.h index bf2785d1eb..be46a1649a 100644 --- a/src/Gui/Quarter/devices/InputDevice.h +++ b/src/Gui/Quarter/devices/InputDevice.h @@ -47,7 +47,7 @@ class QuarterWidget; class QUARTER_DLL_API InputDevice { public: InputDevice(QuarterWidget * quarter); - InputDevice(void); + InputDevice(); virtual ~InputDevice() {} /*! diff --git a/src/Gui/Quarter/devices/Keyboard.h b/src/Gui/Quarter/devices/Keyboard.h index 8284798881..2299adf3d9 100644 --- a/src/Gui/Quarter/devices/Keyboard.h +++ b/src/Gui/Quarter/devices/Keyboard.h @@ -44,7 +44,7 @@ namespace SIM { namespace Coin3D { namespace Quarter { class QUARTER_DLL_API Keyboard : public InputDevice { public: Keyboard(QuarterWidget* quarter); - Keyboard(void); + Keyboard(); virtual ~Keyboard(); virtual const SoEvent * translateEvent(QEvent * event); diff --git a/src/Gui/Quarter/devices/Mouse.h b/src/Gui/Quarter/devices/Mouse.h index 49405368c2..6ac878063d 100644 --- a/src/Gui/Quarter/devices/Mouse.h +++ b/src/Gui/Quarter/devices/Mouse.h @@ -44,7 +44,7 @@ namespace SIM { namespace Coin3D { namespace Quarter { class QUARTER_DLL_API Mouse : public InputDevice { public: Mouse(QuarterWidget* quarter); - Mouse(void); + Mouse(); virtual ~Mouse(); virtual const SoEvent * translateEvent(QEvent * event); diff --git a/src/Gui/Quarter/devices/SpaceNavigatorDevice.h b/src/Gui/Quarter/devices/SpaceNavigatorDevice.h index 30224f6446..c8f6e8a5b3 100644 --- a/src/Gui/Quarter/devices/SpaceNavigatorDevice.h +++ b/src/Gui/Quarter/devices/SpaceNavigatorDevice.h @@ -43,7 +43,7 @@ namespace SIM { namespace Coin3D { namespace Quarter { class QUARTER_DLL_API SpaceNavigatorDevice : public InputDevice { public: SpaceNavigatorDevice(QuarterWidget* quarter); - SpaceNavigatorDevice(void); + SpaceNavigatorDevice(); virtual ~SpaceNavigatorDevice(); virtual const SoEvent * translateEvent(QEvent * event); diff --git a/src/Gui/Quarter/eventhandlers/EventFilter.h b/src/Gui/Quarter/eventhandlers/EventFilter.h index 68c7cbdf06..5f4f95bd1b 100644 --- a/src/Gui/Quarter/eventhandlers/EventFilter.h +++ b/src/Gui/Quarter/eventhandlers/EventFilter.h @@ -53,7 +53,7 @@ public: void registerInputDevice(InputDevice * device); void unregisterInputDevice(InputDevice * device); - const QPoint & globalMousePosition(void) const; + const QPoint & globalMousePosition() const; protected: bool eventFilter(QObject * obj, QEvent * event); diff --git a/src/Gui/RevitNavigationStyle.cpp b/src/Gui/RevitNavigationStyle.cpp index 3408929108..6bc4ee8ced 100644 --- a/src/Gui/RevitNavigationStyle.cpp +++ b/src/Gui/RevitNavigationStyle.cpp @@ -117,7 +117,7 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { const SoKeyboardEvent * const event = static_cast(ev); - processed = handleKeyboardEvent(event, posn); + processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling @@ -146,30 +146,8 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev) else if (viewer->isEditing() && (this->currentmode == NavigationStyle::SPINNING)) { processed = true; } - // issue #0002433: avoid to swallow the UP event if down the - // scene graph somewhere a dialog gets opened - else if (press) { - SbTime tmp = (ev->getTime() - mouseDownConsumedEvent.getTime()); - float dci = (float)QApplication::doubleClickInterval()/1000.0f; - // a double-click? - if (tmp.getValue() < dci) { - mouseDownConsumedEvent = *event; - mouseDownConsumedEvent.setTime(ev->getTime()); - processed = true; - } - else { - mouseDownConsumedEvent.setTime(ev->getTime()); - // 'ANY' is used to mark that we don't know yet if it will - // be a double-click event. - mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY); - } - } - else if (!press) { - if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON1) { - // now handle the postponed event - inherited::processSoEvent(&mouseDownConsumedEvent); - mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY); - } + else { + processed = processClickEvent(event); } break; case SoMouseButtonEvent::BUTTON2: diff --git a/src/Gui/SoFCDB.cpp b/src/Gui/SoFCDB.cpp index 0dc42462fe..92e9045ad3 100644 --- a/src/Gui/SoFCDB.cpp +++ b/src/Gui/SoFCDB.cpp @@ -186,6 +186,7 @@ void Gui::SoFCDB::init() GestureNavigationStyle ::init(); OpenCascadeNavigationStyle ::init(); OpenSCADNavigationStyle ::init(); + TinkerCADNavigationStyle ::init(); GLGraphicsItem ::init(); GLFlagWindow ::init(); diff --git a/src/Gui/TinkerCADNavigationStyle.cpp b/src/Gui/TinkerCADNavigationStyle.cpp new file mode 100644 index 0000000000..50b28e47ad --- /dev/null +++ b/src/Gui/TinkerCADNavigationStyle.cpp @@ -0,0 +1,263 @@ +/*************************************************************************** + * Copyright (c) 2021 Werner Mayer * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#include "PreCompiled.h" +#ifndef _PreComp_ +# include +# include "InventorAll.h" +# include +# include +# include +# include +# include +# include +# include +# include +# include +#endif + +#include +#include "NavigationStyle.h" +#include "View3DInventorViewer.h" +#include "Application.h" +#include "MenuManager.h" +#include "MouseSelection.h" + +using namespace Gui; + +// ---------------------------------------------------------------------------------- + +/* TRANSLATOR Gui::TinkerCADNavigationStyle */ + +TYPESYSTEM_SOURCE(Gui::TinkerCADNavigationStyle, Gui::UserNavigationStyle) + +TinkerCADNavigationStyle::TinkerCADNavigationStyle() +{ +} + +TinkerCADNavigationStyle::~TinkerCADNavigationStyle() +{ +} + +const char* TinkerCADNavigationStyle::mouseButtons(ViewerMode mode) +{ + switch (mode) { + case NavigationStyle::SELECTION: + return QT_TR_NOOP("Press left mouse button"); + case NavigationStyle::PANNING: + return QT_TR_NOOP("Press middle mouse button"); + case NavigationStyle::DRAGGING: + return QT_TR_NOOP("Press right mouse button"); + case NavigationStyle::ZOOMING: + return QT_TR_NOOP("Scroll middle mouse button"); + default: + return "No description"; + } +} + +SbBool TinkerCADNavigationStyle::processSoEvent(const SoEvent * const ev) +{ + // Events when in "ready-to-seek" mode are ignored, except those + // which influence the seek mode itself -- these are handled further + // up the inheritance hierarchy. + if (this->isSeekMode()) { return inherited::processSoEvent(ev); } + // Switch off viewing mode + if (!this->isSeekMode() && !this->isAnimating() && this->isViewing()) + this->setViewing(false); // by default disable viewing mode to render the scene + + const SoType type(ev->getTypeId()); + + const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion(); + const SbVec2s pos(ev->getPosition()); + const SbVec2f posn = normalizePixelPos(pos); + + const SbVec2f prevnormalized = this->lastmouseposition; + this->lastmouseposition = posn; + + // Set to true if any event processing happened. Note that it is not + // necessary to restrict ourselves to only do one "action" for an + // event, we only need this flag to see if any processing happened + // at all. + SbBool processed = false; + + const ViewerMode curmode = this->currentmode; + ViewerMode newmode = curmode; + + // Mismatches in state of the modifier keys happens if the user + // presses or releases them outside the viewer window. + syncModifierKeys(ev); + + // give the nodes in the foreground root the chance to handle events (e.g color bar) + if (!viewer->isEditing()) { + processed = handleEventInForeground(ev); + if (processed) + return true; + } + + // Keyboard handling + if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { + const SoKeyboardEvent * const event = static_cast(ev); + processed = processKeyboardEvent(event); + } + + // Mouse Button / Spaceball Button handling + if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { + const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev; + const int button = event->getButton(); + const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; + SbBool canOpenPopupMenu = false; + + switch (button) { + case SoMouseButtonEvent::BUTTON1: + this->button1down = press; + if (press && (curmode == NavigationStyle::SEEK_WAIT_MODE)) { + newmode = NavigationStyle::SEEK_MODE; + this->seekToPoint(pos); // implicitly calls interactiveCountInc() + processed = true; + } + else if (viewer->isEditing() && (curmode == NavigationStyle::SPINNING)) { + processed = true; + } + else { + processed = processClickEvent(event); + } + break; + case SoMouseButtonEvent::BUTTON2: + // If we are in edit mode then simply ignore the RMB events + // to pass the event to the base class. + this->button2down = press; + if (press) { + mouseDownConsumedEvent = *event; + mouseDownConsumedEvent.setTime(ev->getTime()); + } + else if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON2) { + SbTime tmp = (ev->getTime() - mouseDownConsumedEvent.getTime()); + float dci = float(QApplication::doubleClickInterval())/1000.0f; + // time between press and release event + if (tmp.getValue() < dci) { + canOpenPopupMenu = true; + } + } + + // About to start rotating + if (press && (curmode == NavigationStyle::IDLE)) { + // Use this variable to spot move events + saveCursorPosition(ev); + this->centerTime = ev->getTime(); + processed = true; + } + else if (!press && (curmode == NavigationStyle::DRAGGING)) { + if (!viewer->isEditing() && canOpenPopupMenu) { + // If we are in drag mode but mouse hasn't been moved open the context-menu + if (this->isPopupMenuEnabled()) { + this->openPopupMenu(event->getPosition()); + } + } + newmode = NavigationStyle::IDLE; + processed = true; + } + break; + case SoMouseButtonEvent::BUTTON3: + this->button3down = press; + if (press) { + this->centerTime = ev->getTime(); + float ratio = vp.getViewportAspectRatio(); + SbViewVolume vv = viewer->getSoRenderManager()->getCamera()->getViewVolume(ratio); + this->panningplane = vv.getPlane(viewer->getSoRenderManager()->getCamera()->focalDistance.getValue()); + } + else if (curmode == NavigationStyle::PANNING) { + newmode = NavigationStyle::IDLE; + processed = true; + } + break; + default: + break; + } + } + + // Mouse Movement handling + if (type.isDerivedFrom(SoLocation2Event::getClassTypeId())) { + const SoLocation2Event * const event = (const SoLocation2Event *) ev; + if (curmode == NavigationStyle::PANNING) { + float ratio = vp.getViewportAspectRatio(); + panCamera(viewer->getSoRenderManager()->getCamera(), ratio, this->panningplane, posn, prevnormalized); + processed = true; + } + else if (curmode == NavigationStyle::DRAGGING) { + this->addToLog(event->getPosition(), event->getTime()); + this->spin(posn); + moveCursorPosition(); + processed = true; + } + } + + // Spaceball & Joystick handling + if (type.isDerivedFrom(SoMotion3Event::getClassTypeId())) { + const SoMotion3Event * const event = static_cast(ev); + if (event) + this->processMotionEvent(event); + processed = true; + } + + enum { + BUTTON1DOWN = 1 << 0, + BUTTON3DOWN = 1 << 1, + CTRLDOWN = 1 << 2, + SHIFTDOWN = 1 << 3, + BUTTON2DOWN = 1 << 4 + }; + unsigned int combo = + (this->button1down ? BUTTON1DOWN : 0) | + (this->button2down ? BUTTON2DOWN : 0) | + (this->button3down ? BUTTON3DOWN : 0) | + (this->ctrldown ? CTRLDOWN : 0) | + (this->shiftdown ? SHIFTDOWN : 0); + + switch (combo) { + case 0: + if (curmode == NavigationStyle::SPINNING) { break; } + newmode = NavigationStyle::IDLE; + break; + case BUTTON1DOWN: + newmode = NavigationStyle::SELECTION; + break; + case BUTTON2DOWN: + newmode = NavigationStyle::DRAGGING; + break; + case BUTTON3DOWN: + newmode = NavigationStyle::PANNING; + break; + default: + break; + } + + if (newmode != curmode) { + this->setViewingMode(newmode); + } + + // If not handled in this class, pass on upwards in the inheritance + // hierarchy. + if (!processed) + processed = inherited::processSoEvent(ev); + return processed; +} diff --git a/src/Gui/TouchpadNavigationStyle.cpp b/src/Gui/TouchpadNavigationStyle.cpp index 606412fdd8..dbb2dc8b6c 100644 --- a/src/Gui/TouchpadNavigationStyle.cpp +++ b/src/Gui/TouchpadNavigationStyle.cpp @@ -117,7 +117,7 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev) // Keyboard handling if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { const SoKeyboardEvent * const event = static_cast(ev); - processed = handleKeyboardEvent(event, posn); + processed = processKeyboardEvent(event); } // Mouse Button / Spaceball Button handling @@ -146,30 +146,8 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev) else if (viewer->isEditing() && (this->currentmode == NavigationStyle::SPINNING)) { processed = true; } - // issue #0002433: avoid to swallow the UP event if down the - // scene graph somewhere a dialog gets opened - else if (press) { - SbTime tmp = (ev->getTime() - mouseDownConsumedEvent.getTime()); - float dci = (float)QApplication::doubleClickInterval()/1000.0f; - // a double-click? - if (tmp.getValue() < dci) { - mouseDownConsumedEvent = *event; - mouseDownConsumedEvent.setTime(ev->getTime()); - processed = true; - } - else { - mouseDownConsumedEvent.setTime(ev->getTime()); - // 'ANY' is used to mark that we don't know yet if it will - // be a double-click event. - mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY); - } - } - else if (!press) { - if (mouseDownConsumedEvent.getButton() == SoMouseButtonEvent::BUTTON1) { - // now handle the postponed event - inherited::processSoEvent(&mouseDownConsumedEvent); - mouseDownConsumedEvent.setButton(SoMouseButtonEvent::ANY); - } + else { + processed = processClickEvent(event); } break; case SoMouseButtonEvent::BUTTON2: diff --git a/src/Main/MainCmd.cpp b/src/Main/MainCmd.cpp index fa230acacc..ae4e36ffd9 100644 --- a/src/Main/MainCmd.cpp +++ b/src/Main/MainCmd.cpp @@ -108,7 +108,7 @@ int main( int argc, char ** argv ) std::string appName = App::Application::Config()["ExeName"]; std::stringstream msg; msg << "While initializing " << appName << " the following exception occurred: '" << e.what() << "'\n\n"; - msg << "Python is searching for its runtime files in the following directories:\n" << Py_GetPath() << "\n\n"; + msg << "Python is searching for its runtime files in the following directories:\n" << Py_EncodeLocale(Py_GetPath(),nullptr) << "\n\n"; msg << "Python version information:\n" << Py_GetVersion() << "\n"; const char* pythonhome = getenv("PYTHONHOME"); if ( pythonhome ) { diff --git a/src/Mod/MeshPart/App/AppMeshPart.cpp b/src/Mod/MeshPart/App/AppMeshPart.cpp index fbd6d1da92..e4cc0d004b 100644 --- a/src/Mod/MeshPart/App/AppMeshPart.cpp +++ b/src/Mod/MeshPart/App/AppMeshPart.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) * + * Copyright (c) 2008 Jürgen Riegel * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/MeshPart/App/AppMeshPartPy.cpp b/src/Mod/MeshPart/App/AppMeshPartPy.cpp index 489ae76933..a1b96ff51e 100644 --- a/src/Mod/MeshPart/App/AppMeshPartPy.cpp +++ b/src/Mod/MeshPart/App/AppMeshPartPy.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) * + * Copyright (c) 2008 Jürgen Riegel * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/MeshPart/App/CurveProjector.cpp b/src/Mod/MeshPart/App/CurveProjector.cpp index e559834e66..5731521aa3 100644 --- a/src/Mod/MeshPart/App/CurveProjector.cpp +++ b/src/Mod/MeshPart/App/CurveProjector.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) Juergen Riegel * + * Copyright (c) 2008 Juergen Riegel * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/MeshPart/App/CurveProjector.h b/src/Mod/MeshPart/App/CurveProjector.h index 20d2479fea..5efcd7566d 100644 --- a/src/Mod/MeshPart/App/CurveProjector.h +++ b/src/Mod/MeshPart/App/CurveProjector.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) Juergen Riegel * + * Copyright (c) 2008 Juergen Riegel * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/MeshPart/App/MeshAlgos.cpp b/src/Mod/MeshPart/App/MeshAlgos.cpp index 0f1f2439d2..3551766207 100644 --- a/src/Mod/MeshPart/App/MeshAlgos.cpp +++ b/src/Mod/MeshPart/App/MeshAlgos.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) Juergen Riegel * + * Copyright (c) 2008 Juergen Riegel * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/MeshPart/App/MeshAlgos.h b/src/Mod/MeshPart/App/MeshAlgos.h index d524f7effd..a0f482421d 100644 --- a/src/Mod/MeshPart/App/MeshAlgos.h +++ b/src/Mod/MeshPart/App/MeshAlgos.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) Juergen Riegel * + * Copyright (c) 2008 Juergen Riegel * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/MeshPart/App/PreCompiled.cpp b/src/Mod/MeshPart/App/PreCompiled.cpp index 46269e9671..1e5d389dd2 100644 --- a/src/Mod/MeshPart/App/PreCompiled.cpp +++ b/src/Mod/MeshPart/App/PreCompiled.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) * + * Copyright (c) 2008 Jürgen Riegel * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/MeshPart/App/PreCompiled.h b/src/Mod/MeshPart/App/PreCompiled.h index 07eac4d2e8..754261f3a7 100644 --- a/src/Mod/MeshPart/App/PreCompiled.h +++ b/src/Mod/MeshPart/App/PreCompiled.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) * + * Copyright (c) 2008 Jürgen Riegel * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/MeshPart/Gui/AppMeshPartGui.cpp b/src/Mod/MeshPart/Gui/AppMeshPartGui.cpp index 5bd034c4eb..64aa198feb 100644 --- a/src/Mod/MeshPart/Gui/AppMeshPartGui.cpp +++ b/src/Mod/MeshPart/Gui/AppMeshPartGui.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) * + * Copyright (c) 2008 Jürgen Riegel * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/MeshPart/Gui/Command.cpp b/src/Mod/MeshPart/Gui/Command.cpp index 22f2ff929e..f91ff09030 100644 --- a/src/Mod/MeshPart/Gui/Command.cpp +++ b/src/Mod/MeshPart/Gui/Command.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) * + * Copyright (c) 2008 Jürgen Riegel * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/MeshPart/Gui/MeshFlatteningCommand.py b/src/Mod/MeshPart/Gui/MeshFlatteningCommand.py index ed0d1aec6e..8d09f86c82 100644 --- a/src/Mod/MeshPart/Gui/MeshFlatteningCommand.py +++ b/src/Mod/MeshPart/Gui/MeshFlatteningCommand.py @@ -1,3 +1,25 @@ +#*************************************************************************** +#* Copyright (c) 2017 Lorenz Lechner * +#* * +#* This file is part of the FreeCAD CAx development system. * +#* * +#* This library is free software; you can redistribute it and/or * +#* modify it under the terms of the GNU Library General Public * +#* License as published by the Free Software Foundation; either * +#* version 2 of the License, or (at your option) any later version. * +#* * +#* This library is distributed in the hope that it will be useful, * +#* but WITHOUT ANY WARRANTY; without even the implied warranty of * +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +#* GNU Library General Public License for more details. * +#* * +#* You should have received a copy of the GNU Library General Public * +#* License along with this library; see the file COPYING.LIB. If not, * +#* write to the Free Software Foundation, Inc., 59 Temple Place, * +#* Suite 330, Boston, MA 02111-1307, USA * +#* * +#***************************************************************************/ + import Mesh import FreeCAD as App import FreeCADGui as Gui diff --git a/src/Mod/MeshPart/Gui/PreCompiled.cpp b/src/Mod/MeshPart/Gui/PreCompiled.cpp index 46269e9671..1e5d389dd2 100644 --- a/src/Mod/MeshPart/Gui/PreCompiled.cpp +++ b/src/Mod/MeshPart/Gui/PreCompiled.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) * + * Copyright (c) 2008 Jürgen Riegel * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/MeshPart/Gui/PreCompiled.h b/src/Mod/MeshPart/Gui/PreCompiled.h index 7cef9ef237..9f90acb0d8 100644 --- a/src/Mod/MeshPart/Gui/PreCompiled.h +++ b/src/Mod/MeshPart/Gui/PreCompiled.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) * + * Copyright (c) 2008 Jürgen Riegel * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/MeshPart/Init.py b/src/Mod/MeshPart/Init.py index c9c37c802b..dd8dea3aee 100644 --- a/src/Mod/MeshPart/Init.py +++ b/src/Mod/MeshPart/Init.py @@ -1,8 +1,8 @@ -# FreeCAD init script of the MeshPart module +# FreeCAD init script of the MeshPart module # (c) 2001 Juergen Riegel #*************************************************************************** -#* (c) Juergen Riegel (juergen.riegel@web.de) 2002 * +#* Copyright (c) 2002 Juergen Riegel * #* * #* This file is part of the FreeCAD CAx development system. * #* * @@ -13,14 +13,13 @@ #* for detail see the LICENCE text file. * #* * #* FreeCAD is distributed in the hope that it will be useful, * -#* but WITHOUT ANY WARRANTY; without even the implied warranty of * +#* but WITHOUT ANY WARRANTY; without even the implied warranty of * #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * #* GNU Lesser General Public License for more details. * #* * #* You should have received a copy of the GNU Library General Public * -#* License along with FreeCAD; if not, write to the Free Software * +#* License along with FreeCAD; if not, write to the Free Software * #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * -#* Juergen Riegel 2002 * #***************************************************************************/ diff --git a/src/Mod/MeshPart/InitGui.py b/src/Mod/MeshPart/InitGui.py index 82a917f2ea..17d0102f1f 100644 --- a/src/Mod/MeshPart/InitGui.py +++ b/src/Mod/MeshPart/InitGui.py @@ -1,4 +1,4 @@ -# MeshPart gui init module +# MeshPart gui init module # (c) 2003 Juergen Riegel # # Gathering all the information to start FreeCAD @@ -6,7 +6,7 @@ # runs when the gui is up #*************************************************************************** -#* (c) Juergen Riegel (juergen.riegel@web.de) 2002 * +#* Copyright (c) 2002 Juergen Riegel * #* * #* This file is part of the FreeCAD CAx development system. * #* * @@ -26,44 +26,46 @@ #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * -#* Juergen Riegel 2002 * #***************************************************************************/ class MeshPartWorkbench ( Workbench ): - "MeshPart workbench object" - Icon = """ - /* XPM */ - static const char *MeshPart_Box[]={ - "16 16 3 1", - ". c None", - "# c #000000", - "a c #c6c642", - "................", - ".......#######..", - "......#aaaaa##..", - ".....#aaaaa###..", - "....#aaaaa##a#..", - "...#aaaaa##aa#..", - "..#aaaaa##aaa#..", - ".########aaaa#..", - ".#aaaaa#aaaaa#..", - ".#aaaaa#aaaa##..", - ".#aaaaa#aaa##...", - ".#aaaaa#aa##....", - ".#aaaaa#a##... .", - ".#aaaaa###......", - ".########.......", - "................"}; - """ - MenuText = "MeshPart" - ToolTip = "MeshPart workbench" + "MeshPart workbench object" + Icon = """ + /* XPM */ + static const char *MeshPart_Box[]={ + "16 16 3 1", + ". c None", + "# c #000000", + "a c #c6c642", + "................", + ".......#######..", + "......#aaaaa##..", + ".....#aaaaa###..", + "....#aaaaa##a#..", + "...#aaaaa##aa#..", + "..#aaaaa##aaa#..", + ".########aaaa#..", + ".#aaaaa#aaaaa#..", + ".#aaaaa#aaaa##..", + ".#aaaaa#aaa##...", + ".#aaaaa#aa##....", + ".#aaaaa#a##... .", + ".#aaaaa###......", + ".########.......", + "................"}; + """ + MenuText = "MeshPart" + ToolTip = "MeshPart workbench" - def Initialize(self): - # load the module - import MeshPartGui - import MeshPart - def GetClassName(self): - return "MeshPartGui::Workbench" -#Gui.addWorkbench(MeshPartWorkbench()) + def Initialize(self): + # load the module + import MeshPartGui + import MeshPart + + + def GetClassName(self): + return "MeshPartGui::Workbench" + +# Gui.addWorkbench(MeshPartWorkbench()) diff --git a/src/Mod/OpenSCAD/OpenSCADFeatures.py b/src/Mod/OpenSCAD/OpenSCADFeatures.py index 93332b67a2..4f3f4d21d8 100644 --- a/src/Mod/OpenSCAD/OpenSCADFeatures.py +++ b/src/Mod/OpenSCAD/OpenSCADFeatures.py @@ -200,13 +200,11 @@ class Resize : self.createGeometry(fp) def createGeometry(self, fp) : - print("Resize create Geometry") import FreeCAD mat = FreeCAD.Matrix() mat.A11 = self.Vector[0] mat.A22 = self.Vector[1] mat.A33 = self.Vector[2] - print(mat) fp.Shape = self.Target.Shape.transformGeometry(mat) def __getstate__(self): @@ -387,7 +385,7 @@ class Frustum: fp.Placement = plm class Twist: - def __init__(self, obj,child=None,h=1.0,angle=0.0,scale=[1.0,1.0]): + def __init__(self, obj, child=None, h=1.0, angle=0.0, scale=[1.0,1.0]): import FreeCAD obj.addProperty("App::PropertyLink","Base","Base", "The base object that must be transformed") @@ -406,10 +404,10 @@ class Twist: self.createGeometry(fp) def onChanged(self, fp, prop): - if prop in ["Angle","Height"]: + if prop in ["Angle","Height","Scale"]: self.createGeometry(fp) - def createGeometry(self,fp): + def createGeometry(self, fp): import FreeCAD,Part,math,sys if fp.Base and fp.Height and fp.Base.Shape.isValid(): solids = [] @@ -443,7 +441,6 @@ class Twist: pipe_shell.add(wire1) pipe_shell.add(wire2) pipe_shell.setAuxiliarySpine(auxiliary_spine,True,0) - print(pipe_shell.getStatus()) assert(pipe_shell.isReady()) pipe_shell.build() faces.extend(pipe_shell.shape().Faces) @@ -534,10 +531,9 @@ class PrismaticToroid: solid = Part.makeSolid (clean_shell) if solid.Volume < 0: solid.reverse() - print (f"Solid volume is {solid.Volume}") solids.append(solid) except Part.OCCError: - print ("Could not create solid: creating compound instead") + FreeCAD.Console.PrintWarning("Could not create solid: creating compound instead") solids.append(Part.Compound(faces)) fp.Shape = Part.Compound(solids) @@ -587,139 +583,146 @@ class CGALFeature: raise ValueError def makeSurfaceVolume(filename): - import FreeCAD,Part,sys + import FreeCAD + import Part + import sys + coords = [] with open(filename) as f1: - coords = [] min_z = sys.float_info.max for line in f1.readlines(): - sline=line.strip() + sline = line.strip() if sline and not sline.startswith('#'): - ycoord=len(coords) - lcoords=[] + ycoord = len(coords) + lcoords = [] for xcoord, num in enumerate(sline.split()): - fnum=float(num) + fnum = float(num) lcoords.append(FreeCAD.Vector(float(xcoord),float(ycoord),fnum)) min_z = min(fnum,min_z) coords.append(lcoords) - - num_rows = len(coords) - num_cols = len(coords[0]) - # OpenSCAD does not spline this surface, so neither do we: just create a bunch of faces, - # using four triangles per quadrilateral - faces = [] - for row in range(num_rows-1): - for col in range(num_cols-1): - a = coords[row+0][col+0] - b = coords[row+0][col+1] - c = coords[row+1][col+1] - d = coords[row+1][col+0] - centroid = 0.25 * (a + b + c + d) - ab = Part.makeLine(a,b) - bc = Part.makeLine(b,c) - cd = Part.makeLine(c,d) - da = Part.makeLine(d,a) + num_rows = len(coords) + if num_rows == 0: + FreeCAD.Console.PrintWarning(f"No data found in surface file {filename}") + return None,0,0 + num_cols = len(coords[0]) - diag_a = Part.makeLine(a, centroid) - diag_b = Part.makeLine(b, centroid) - diag_c = Part.makeLine(c, centroid) - diag_d = Part.makeLine(d, centroid) + # OpenSCAD does not spline this surface, so neither do we: just create a + # bunch of faces, + # using four triangles per quadrilateral + faces = [] + for row in range(num_rows - 1): + for col in range(num_cols - 1): + a = coords[row + 0][col + 0] + b = coords[row + 0][col + 1] + c = coords[row + 1][col + 1] + d = coords[row + 1][col + 0] + centroid = 0.25 * (a + b + c + d) + ab = Part.makeLine(a,b) + bc = Part.makeLine(b,c) + cd = Part.makeLine(c,d) + da = Part.makeLine(d,a) - wire1 = Part.Wire([ab,diag_a,diag_b]) - wire2 = Part.Wire([bc,diag_b,diag_c]) - wire3 = Part.Wire([cd,diag_c,diag_d]) - wire4 = Part.Wire([da,diag_d,diag_a]) + diag_a = Part.makeLine(a, centroid) + diag_b = Part.makeLine(b, centroid) + diag_c = Part.makeLine(c, centroid) + diag_d = Part.makeLine(d, centroid) - try: - face = Part.Face(wire1) - faces.append(face) - face = Part.Face(wire2) - faces.append(face) - face = Part.Face(wire3) - faces.append(face) - face = Part.Face(wire4) - faces.append(face) - except Exception: - print ("Failed to create the face from {},{},{},{}".format(coords[row+0][col+0],\ - coords[row+0][col+1],coords[row+1][col+1],coords[row+1][col+0])) - - last_row = num_rows-1 - last_col = num_cols-1 + wire1 = Part.Wire([ab,diag_a,diag_b]) + wire2 = Part.Wire([bc,diag_b,diag_c]) + wire3 = Part.Wire([cd,diag_c,diag_d]) + wire4 = Part.Wire([da,diag_d,diag_a]) - # Create the face to close off the y-min border: OpenSCAD places the lower surface of the shell - # at 1 unit below the lowest coordinate in the surface - lines = [] - corner1 = FreeCAD.Vector(coords[0][0].x, coords[0][0].y, min_z-1) - lines.append (Part.makeLine(corner1,coords[0][0])) - for col in range(num_cols-1): - a = coords[0][col] - b = coords[0][col+1] - lines.append (Part.makeLine(a, b)) - corner2 = FreeCAD.Vector(coords[0][last_col].x, coords[0][last_col].y, min_z-1) - lines.append (Part.makeLine(corner2,coords[0][last_col])) - lines.append (Part.makeLine(corner1,corner2)) - wire = Part.Wire(lines) - face = Part.Face(wire) - faces.append(face) - - # Create the face to close off the y-max border - lines = [] - corner1 = FreeCAD.Vector(coords[last_row][0].x, coords[last_row][0].y, min_z-1) - lines.append (Part.makeLine(corner1,coords[last_row][0])) - for col in range(num_cols-1): - a = coords[last_row][col] - b = coords[last_row][col+1] - lines.append (Part.makeLine(a, b)) - corner2 = FreeCAD.Vector(coords[last_row][last_col].x, coords[last_row][last_col].y, min_z-1) - lines.append (Part.makeLine(corner2,coords[last_row][last_col])) - lines.append (Part.makeLine(corner1,corner2)) - wire = Part.Wire(lines) - face = Part.Face(wire) - faces.append(face) + try: + face = Part.Face(wire1) + faces.append(face) + face = Part.Face(wire2) + faces.append(face) + face = Part.Face(wire3) + faces.append(face) + face = Part.Face(wire4) + faces.append(face) + except Exception: + FreeCAD.Console.PrintWarning("Failed to create the face from {},{},{},{}".format(coords[row + 0][col + 0],\ + coords[row + 0][col + 1],coords[row + 1][col + 1],coords[row + 1][col + 0])) - # Create the face to close off the x-min border - lines = [] - corner1 = FreeCAD.Vector(coords[0][0].x, coords[0][0].y, min_z-1) - lines.append (Part.makeLine(corner1,coords[0][0])) - for row in range(num_rows-1): - a = coords[row][0] - b = coords[row+1][0] - lines.append (Part.makeLine(a, b)) - corner2 = FreeCAD.Vector(coords[last_row][0].x, coords[last_row][0].y, min_z-1) - lines.append (Part.makeLine(corner2,coords[last_row][0])) - lines.append (Part.makeLine(corner1,corner2)) - wire = Part.Wire(lines) - face = Part.Face(wire) - faces.append(face) + last_row = num_rows - 1 + last_col = num_cols - 1 - # Create the face to close off the x-max border - lines = [] - corner1 = FreeCAD.Vector(coords[0][last_col].x, coords[0][last_col].y, min_z-1) - lines.append (Part.makeLine(corner1,coords[0][last_col])) - for row in range(num_rows-1): - a = coords[row][last_col] - b = coords[row+1][last_col] - lines.append (Part.makeLine(a, b)) - corner2 = FreeCAD.Vector(coords[last_row][last_col].x, coords[last_row][last_col].y, min_z-1) - lines.append (Part.makeLine(corner2,coords[last_row][last_col])) - lines.append (Part.makeLine(corner1,corner2)) - wire = Part.Wire(lines) - face = Part.Face(wire) - faces.append(face) + # Create the face to close off the y-min border: OpenSCAD places the lower + # surface of the shell + # at 1 unit below the lowest coordinate in the surface + lines = [] + corner1 = FreeCAD.Vector(coords[0][0].x, coords[0][0].y, min_z - 1) + lines.append(Part.makeLine(corner1,coords[0][0])) + for col in range(num_cols - 1): + a = coords[0][col] + b = coords[0][col + 1] + lines.append(Part.makeLine(a, b)) + corner2 = FreeCAD.Vector(coords[0][last_col].x, coords[0][last_col].y, min_z - 1) + lines.append(Part.makeLine(corner2,coords[0][last_col])) + lines.append(Part.makeLine(corner1,corner2)) + wire = Part.Wire(lines) + face = Part.Face(wire) + faces.append(face) - # Create a bottom surface to close off the shell - a = FreeCAD.Vector(coords[0][0].x, coords[0][0].y, min_z-1) - b = FreeCAD.Vector(coords[0][last_col].x, coords[0][last_col].y, min_z-1) - c = FreeCAD.Vector(coords[last_row][last_col].x, coords[last_row][last_col].y, min_z-1) - d = FreeCAD.Vector(coords[last_row][0].x, coords[last_row][0].y, min_z-1) - ab = Part.makeLine(a,b) - bc = Part.makeLine(b,c) - cd = Part.makeLine(c,d) - da = Part.makeLine(d,a) - wire = Part.Wire([ab,bc,cd,da]) - face = Part.Face(wire) - faces.append(face) + # Create the face to close off the y-max border + lines = [] + corner1 = FreeCAD.Vector(coords[last_row][0].x, coords[last_row][0].y, min_z - 1) + lines.append(Part.makeLine(corner1,coords[last_row][0])) + for col in range(num_cols - 1): + a = coords[last_row][col] + b = coords[last_row][col + 1] + lines.append(Part.makeLine(a, b)) + corner2 = FreeCAD.Vector(coords[last_row][last_col].x, coords[last_row][last_col].y, min_z - 1) + lines.append(Part.makeLine(corner2,coords[last_row][last_col])) + lines.append(Part.makeLine(corner1,corner2)) + wire = Part.Wire(lines) + face = Part.Face(wire) + faces.append(face) - s = Part.Shell(faces) - solid = Part.Solid(s) - return solid,last_col,last_row + # Create the face to close off the x-min border + lines = [] + corner1 = FreeCAD.Vector(coords[0][0].x, coords[0][0].y, min_z - 1) + lines.append(Part.makeLine(corner1,coords[0][0])) + for row in range(num_rows - 1): + a = coords[row][0] + b = coords[row + 1][0] + lines.append(Part.makeLine(a, b)) + corner2 = FreeCAD.Vector(coords[last_row][0].x, coords[last_row][0].y, min_z - 1) + lines.append(Part.makeLine(corner2,coords[last_row][0])) + lines.append(Part.makeLine(corner1,corner2)) + wire = Part.Wire(lines) + face = Part.Face(wire) + faces.append(face) + + # Create the face to close off the x-max border + lines = [] + corner1 = FreeCAD.Vector(coords[0][last_col].x, coords[0][last_col].y, min_z - 1) + lines.append(Part.makeLine(corner1,coords[0][last_col])) + for row in range(num_rows - 1): + a = coords[row][last_col] + b = coords[row + 1][last_col] + lines.append(Part.makeLine(a, b)) + corner2 = FreeCAD.Vector(coords[last_row][last_col].x, coords[last_row][last_col].y, min_z - 1) + lines.append(Part.makeLine(corner2,coords[last_row][last_col])) + lines.append(Part.makeLine(corner1,corner2)) + wire = Part.Wire(lines) + face = Part.Face(wire) + faces.append(face) + + # Create a bottom surface to close off the shell + a = FreeCAD.Vector(coords[0][0].x, coords[0][0].y, min_z - 1) + b = FreeCAD.Vector(coords[0][last_col].x, coords[0][last_col].y, min_z - 1) + c = FreeCAD.Vector(coords[last_row][last_col].x, coords[last_row][last_col].y, min_z - 1) + d = FreeCAD.Vector(coords[last_row][0].x, coords[last_row][0].y, min_z - 1) + ab = Part.makeLine(a,b) + bc = Part.makeLine(b,c) + cd = Part.makeLine(c,d) + da = Part.makeLine(d,a) + wire = Part.Wire([ab,bc,cd,da]) + face = Part.Face(wire) + faces.append(face) + + s = Part.Shell(faces) + solid = Part.Solid(s) + return solid,last_col,last_row diff --git a/src/Mod/OpenSCAD/OpenSCADTest/app/test_importCSG.py b/src/Mod/OpenSCAD/OpenSCADTest/app/test_importCSG.py index 59759a7c47..24dda152a2 100644 --- a/src/Mod/OpenSCAD/OpenSCADTest/app/test_importCSG.py +++ b/src/Mod/OpenSCAD/OpenSCADTest/app/test_importCSG.py @@ -38,6 +38,7 @@ __url__ = "https://www.freecadweb.org" class TestImportCSG(unittest.TestCase): MODULE = 'test_importCSG' # file name without extension + temp_dir = tempfile.TemporaryDirectory() def setUp(self): @@ -73,113 +74,78 @@ class TestImportCSG(unittest.TestCase): FreeCAD.closeDocument("CSG") + def utility_create_scad(self, scadCode, name): + filename = self.temp_dir.name + os.path.sep + name + ".scad" + print (f"Creating {filename}") + f = open(filename,"w+") + f.write(scadCode) + f.close() + return importCSG.open(filename) + def test_import_sphere(self): - with tempfile.TemporaryDirectory() as temp_dir: - filename = temp_dir + os.path.sep + "sphere.scad" - f = open(filename,"w+") - f.write("sphere(10.0);") - f.close() - doc = importCSG.open(filename) - sphere = doc.getObject("sphere") - self.assertTrue (sphere is not None) - self.assertTrue (sphere.Radius == 10.0) - FreeCAD.closeDocument(doc.Name) + doc = self.utility_create_scad("sphere(10.0);","sphere") + sphere = doc.getObject("sphere") + self.assertTrue (sphere is not None) + self.assertTrue (sphere.Radius == 10.0) + FreeCAD.closeDocument(doc.Name) def test_import_cylinder(self): - with tempfile.TemporaryDirectory() as temp_dir: - filename = temp_dir + os.path.sep + "cylinder.scad" - f = open(filename,"w+") - f.write("cylinder(50.0,d=10.0);") - f.close() - doc = importCSG.open(filename) - cylinder = doc.getObject("cylinder") - self.assertTrue (cylinder is not None) - self.assertTrue (cylinder.Radius == 5.0) - self.assertTrue (cylinder.Height == 50.0) - FreeCAD.closeDocument(doc.Name) + doc = self.utility_create_scad("cylinder(50.0,d=10.0);","cylinder") + cylinder = doc.getObject("cylinder") + self.assertTrue (cylinder is not None) + self.assertTrue (cylinder.Radius == 5.0) + self.assertTrue (cylinder.Height == 50.0) + FreeCAD.closeDocument(doc.Name) def test_import_cube(self): - with tempfile.TemporaryDirectory() as temp_dir: - filename = temp_dir + os.path.sep + "cube.scad" - f = open(filename,"w+") - f.write("cube([1.0,2.0,3.0]);") - f.close() - doc = importCSG.open(filename) - cube = doc.getObject("cube") - self.assertTrue (cube is not None) - self.assertTrue (cube.Length == 1.0) - self.assertTrue (cube.Width == 2.0) - self.assertTrue (cube.Height == 3.0) - FreeCAD.closeDocument(doc.Name) + doc = self.utility_create_scad("cube([1.0,2.0,3.0]);","cube") + cube = doc.getObject("cube") + self.assertTrue (cube is not None) + self.assertTrue (cube.Length == 1.0) + self.assertTrue (cube.Width == 2.0) + self.assertTrue (cube.Height == 3.0) + FreeCAD.closeDocument(doc.Name) def test_import_circle(self): - with tempfile.TemporaryDirectory() as temp_dir: - filename = temp_dir + os.path.sep + "circle.scad" - f = open(filename,"w+") - f.write("circle(10.0);") - f.close() - doc = importCSG.open(filename) - circle = doc.getObject("circle") - self.assertTrue (circle is not None) - self.assertTrue (circle.Radius == 10.0) - FreeCAD.closeDocument(doc.Name) + doc = self.utility_create_scad("circle(10.0);","circle") + circle = doc.getObject("circle") + self.assertTrue (circle is not None) + self.assertTrue (circle.Radius == 10.0) + FreeCAD.closeDocument(doc.Name) def test_import_square(self): - with tempfile.TemporaryDirectory() as temp_dir: - filename = temp_dir + os.path.sep + "square.scad" - f = open(filename,"w+") - f.write("square([1.0,2.0]);") - f.close() - doc = importCSG.open(filename) - square = doc.getObject("square") - self.assertTrue (square is not None) - self.assertTrue (square.Length == 1.0) - self.assertTrue (square.Width == 2.0) - FreeCAD.closeDocument(doc.Name) + doc = self.utility_create_scad("square([1.0,2.0]);","square") + square = doc.getObject("square") + self.assertTrue (square is not None) + self.assertTrue (square.Length == 1.0) + self.assertTrue (square.Width == 2.0) + FreeCAD.closeDocument(doc.Name) def test_import_text(self): - with tempfile.TemporaryDirectory() as temp_dir: - filename = temp_dir + os.path.sep + "text.scad" - f = open(filename,"w+") - f.write("text(\"X\");") # Keep it short to keep the test fast-ish - f.close() - try: - doc = importCSG.open(filename) - text = doc.getObject("text") - self.assertTrue (text is not None) - FreeCAD.closeDocument(doc.Name) - except Exception: - pass # We may not have the DXF importer available + try: + doc = self.utility_create_scad("text(\"X\");","text") # Keep it short to keep the test fast-ish + text = doc.getObject("text") + self.assertTrue (text is not None) + FreeCAD.closeDocument(doc.Name) + except Exception: + pass # We may not have the DXF importer available def test_import_polygon_nopath(self): - with tempfile.TemporaryDirectory() as temp_dir: - filename = temp_dir + os.path.sep + "polygon_nopath.scad" - f = open(filename,"w+") - f.write("polygon(points=[[0,0],[100,0],[130,50],[30,50]]);") - f.close() - doc = importCSG.open(filename) - polygon = doc.getObject("polygon") - self.assertTrue (polygon is not None) - self.assertAlmostEqual (polygon.Shape.Area, 5000.0) - FreeCAD.closeDocument(doc.Name) + doc = self.utility_create_scad("polygon(points=[[0,0],[100,0],[130,50],[30,50]]);","polygon_nopath") + polygon = doc.getObject("polygon") + self.assertTrue (polygon is not None) + self.assertAlmostEqual (polygon.Shape.Area, 5000.0) + FreeCAD.closeDocument(doc.Name) def test_import_polygon_path(self): - with tempfile.TemporaryDirectory() as temp_dir: - filename = temp_dir + os.path.sep + "polygon_path.scad" - f = open(filename,"w+") - f.write("polygon([[0,0],[100,0],[130,50],[30,50]], paths=[[0,1,2,3]]);") - f.close() - doc = importCSG.open(filename) - wire = doc.ActiveObject # With paths, the polygon gets created as a wire... - self.assertTrue (wire is not None) - self.assertAlmostEqual (wire.Shape.Area, 5000.0) - FreeCAD.closeDocument(doc.Name) + doc = self.utility_create_scad("polygon([[0,0],[100,0],[130,50],[30,50]], paths=[[0,1,2,3]]);","polygon_path") + wire = doc.ActiveObject # With paths, the polygon gets created as a wire... + self.assertTrue (wire is not None) + self.assertAlmostEqual (wire.Shape.Area, 5000.0) + FreeCAD.closeDocument(doc.Name) def test_import_polyhedron(self): - with tempfile.TemporaryDirectory() as temp_dir: - filename = temp_dir + os.path.sep + "polyhedron.scad" - f = open(filename,"w+") - f.write( + doc = self.utility_create_scad( """ polyhedron( points=[ [10,10,0],[10,-10,0],[-10,-10,0],[-10,10,0], // the four points at base @@ -187,22 +153,12 @@ polyhedron( faces=[ [0,1,4],[1,2,4],[2,3,4],[3,0,4], // each triangle side [1,0,3],[2,1,3] ] // two triangles for square base ); -""" +""","polyhedron" ) - f.close() - doc = importCSG.open(filename) - polyhedron = doc.ActiveObject # With paths, the polygon gets created as a wire... - self.assertTrue (polyhedron is not None) - self.assertAlmostEqual (polyhedron.Shape.Volume, 1333.3333, 4) - FreeCAD.closeDocument(doc.Name) - - def utility_create_scad(self, scadCode, name): - with tempfile.TemporaryDirectory() as temp_dir: - filename = temp_dir + os.path.sep + name + ".scad" - f = open(filename,"w+") - f.write(scadCode) - f.close() - return importCSG.open(filename) + polyhedron = doc.ActiveObject # With paths, the polygon gets created as a wire... + self.assertTrue (polyhedron is not None) + self.assertAlmostEqual (polyhedron.Shape.Volume, 1333.3333, 4) + FreeCAD.closeDocument(doc.Name) def test_import_difference(self): doc = self.utility_create_scad("difference() { cube(15, center=true); sphere(10); }", "difference") diff --git a/src/Mod/OpenSCAD/importCSG.py b/src/Mod/OpenSCAD/importCSG.py index c59dc778ce..9007750f34 100644 --- a/src/Mod/OpenSCAD/importCSG.py +++ b/src/Mod/OpenSCAD/importCSG.py @@ -79,7 +79,7 @@ def setColorRecursively(obj, color, transp): "Part::Common", "Part::MultiCommon"] if obj.TypeId in boolean_features: for currentObject in obj.OutList: - print(f"Fixing up colors for: {currentObject.FullName}") + if printverbose: print(f"Fixing up colors for: {currentObject.FullName}") if currentObject not in hassetcolor: setColorRecursively(currentObject, color, transp) @@ -767,14 +767,15 @@ def p_linear_extrude_with_transform(p): 'linear_extrude_with_transform : linear_extrude LPAREN keywordargument_list RPAREN OBRACE block_list EBRACE' if printverbose: print("Linear Extrude With Transform") h = float(p[3]['height']) - s = 1.0 + if printverbose: print("Height : ",h) + s = [1.0,1.0] t = 0.0 - if printverbose: print("Twist : ",p[3]) if 'scale' in p[3]: s = [float(p[3]['scale'][0]), float(p[3]['scale'][1])] - print ("Scale: " + str(s)) + if printverbose: print ("Scale: " + str(s)) if 'twist' in p[3]: t = float(p[3]['twist']) + if printverbose: print("Twist : ",t) # Test if null object like from null text if (len(p[6]) == 0) : p[0] = [] @@ -783,7 +784,7 @@ def p_linear_extrude_with_transform(p): obj = fuse(p[6],"Linear Extrude Union") else : obj = p[6][0] - if t != 0.0 or s != 1.0: + if t != 0.0 or s[0] != 1.0 or s[1] != 1.0: newobj = process_linear_extrude_with_transform(obj,h,t,s) else: newobj = process_linear_extrude(obj,h) @@ -1286,11 +1287,7 @@ def p_polyhedron_action(p) : pp =[v2(v[k]) for k in i] # Add first point to end of list to close polygon pp.append(pp[0]) - print("pp") - print(pp) w = Part.makePolygon(pp) - print("w") - print(w) try: f = Part.Face(w) except Exception: @@ -1315,7 +1312,6 @@ def p_projection_action(p) : for shape in p[6]: shape.Shape.tessellate(0.05) bbox.add(shape.Shape.BoundBox) - print (bbox) plane = doc.addObject("Part::Plane","xy_plane_used_for_projection") plane.Length = bbox.XLength plane.Width = bbox.YLength diff --git a/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp b/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp index 36cab259a2..9ae610ef18 100644 --- a/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp @@ -55,7 +55,7 @@ using namespace Gui; /* TRANSLATOR PartDesignGui::TaskLoftParameters */ -TaskLoftParameters::TaskLoftParameters(ViewProviderLoft *LoftView,bool /*newObj*/, QWidget *parent) +TaskLoftParameters::TaskLoftParameters(ViewProviderLoft *LoftView, bool /*newObj*/, QWidget *parent) : TaskSketchBasedParameters(LoftView, parent, "PartDesign_AdditiveLoft", tr("Loft parameters")) , ui(new Ui_TaskLoftParameters) { @@ -69,7 +69,7 @@ TaskLoftParameters::TaskLoftParameters(ViewProviderLoft *LoftView,bool /*newObj* connect(ui->buttonRefAdd, SIGNAL(toggled(bool)), this, SLOT(onRefButtonAdd(bool))); connect(ui->buttonRefRemove, SIGNAL(toggled(bool)), - this, SLOT(onRefButtonRemvove(bool))); + this, SLOT(onRefButtonRemove(bool))); connect(ui->checkBoxRuled, SIGNAL(toggled(bool)), this, SLOT(onRuled(bool))); connect(ui->checkBoxClosed, SIGNAL(toggled(bool)), @@ -129,16 +129,15 @@ TaskLoftParameters::TaskLoftParameters(ViewProviderLoft *LoftView,bool /*newObj* for (QWidget* child : proxy->findChildren()) child->blockSignals(false); - updateUI(0); + updateUI(); } TaskLoftParameters::~TaskLoftParameters() { } -void TaskLoftParameters::updateUI(int index) +void TaskLoftParameters::updateUI() { - Q_UNUSED(index); } void TaskLoftParameters::onSelectionChanged(const Gui::SelectionChanges& msg) @@ -324,7 +323,7 @@ void TaskLoftParameters::onRefButtonAdd(bool checked) { } } -void TaskLoftParameters::onRefButtonRemvove(bool checked) { +void TaskLoftParameters::onRefButtonRemove(bool checked) { if (checked) { Gui::Selection().clearSelection(); @@ -359,7 +358,7 @@ bool TaskDlgLoftParameters::accept() // TODO Fill this with commands (2015-09-11, Fat-Zer) PartDesign::Loft* pcLoft = static_cast(vp->getObject()); - for(App::DocumentObject* obj : pcLoft->Sections.getValues()) { + for (App::DocumentObject* obj : pcLoft->Sections.getValues()) { FCMD_OBJ_HIDE(obj); } diff --git a/src/Mod/PartDesign/Gui/TaskLoftParameters.h b/src/Mod/PartDesign/Gui/TaskLoftParameters.h index b99a771edf..e04011ef4b 100644 --- a/src/Mod/PartDesign/Gui/TaskLoftParameters.h +++ b/src/Mod/PartDesign/Gui/TaskLoftParameters.h @@ -56,7 +56,7 @@ public: private Q_SLOTS: void onProfileButton(bool); void onRefButtonAdd(bool); - void onRefButtonRemvove(bool); + void onRefButtonRemove(bool); void onClosed(bool); void onRuled(bool); void onDeleteSection(); @@ -67,7 +67,7 @@ protected: private: void onSelectionChanged(const Gui::SelectionChanges& msg); - void updateUI(int index); + void updateUI(); bool referenceSelected(const Gui::SelectionChanges& msg) const; void removeFromListWidget(QListWidget*w, QString name); void clearButtons(); diff --git a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp index 66465f3814..6dd611b873 100644 --- a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp @@ -94,6 +94,7 @@ TaskPipeParameters::TaskPipeParameters(ViewProviderPipe *PipeView, bool /*newObj // Create context menu QAction* remove = new QAction(tr("Remove"), this); remove->setShortcut(QKeySequence::Delete); + remove->setShortcutContext(Qt::WidgetShortcut); #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) // display shortcut behind the context menu entry remove->setShortcutVisibleInContextMenu(true); @@ -587,6 +588,7 @@ TaskPipeOrientation::TaskPipeOrientation(ViewProviderPipe* PipeView, bool /*newO // Create context menu QAction* remove = new QAction(tr("Remove"), this); remove->setShortcut(QKeySequence::Delete); + remove->setShortcutContext(Qt::WidgetShortcut); #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) // display shortcut behind the context menu entry remove->setShortcutVisibleInContextMenu(true); @@ -902,6 +904,7 @@ TaskPipeScaling::TaskPipeScaling(ViewProviderPipe* PipeView, bool /*newObj*/, QW // Create context menu QAction* remove = new QAction(tr("Remove"), this); remove->setShortcut(QKeySequence::Delete); + remove->setShortcutContext(Qt::WidgetShortcut); #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) // display shortcut behind the context menu entry remove->setShortcutVisibleInContextMenu(true); diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index f7d00610ee..ba1496e225 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -555,7 +555,8 @@ public: "conList.append(Sketcher.Constraint('Horizontal',%i))\n" "conList.append(Sketcher.Constraint('Vertical',%i))\n" "conList.append(Sketcher.Constraint('Vertical',%i))\n" - "%s.addConstraint(conList)\n", + "%s.addConstraint(conList)\n" + "del geoList, conList\n", EditCurve[0].x,EditCurve[0].y,EditCurve[1].x,EditCurve[1].y, // line 1 EditCurve[1].x,EditCurve[1].y,EditCurve[2].x,EditCurve[2].y, // line 2 EditCurve[2].x,EditCurve[2].y,EditCurve[3].x,EditCurve[3].y, // line 3 @@ -594,7 +595,8 @@ public: "conList.append(Sketcher.Constraint('Vertical',%i))\n" "conList.append(Sketcher.Constraint('Vertical',%i))\n" "conList.append(Sketcher.Constraint('Symmetric',%i,2,%i,1,%i,1))\n" - "%s.addConstraint(conList)\n", + "%s.addConstraint(conList)\n" + "del geoList, conList\n", EditCurve[0].x,EditCurve[0].y,EditCurve[1].x,EditCurve[1].y, // line 1 EditCurve[1].x,EditCurve[1].y,EditCurve[2].x,EditCurve[2].y, // line 2 EditCurve[2].x,EditCurve[2].y,EditCurve[3].x,EditCurve[3].y, // line 3 @@ -930,7 +932,8 @@ public: "conList.append(Sketcher.Constraint('Equal', %i, %i))\n" "conList.append(Sketcher.Constraint('Equal', %i, %i))\n" "conList.append(Sketcher.Constraint('Equal', %i, %i))\n" - "%s.addConstraint(conList)\n", + "%s.addConstraint(conList)\n" + "del geoList, conList\n", StartPos.x + (signX * radius), StartPos.y + (signY * radius), // center of the arc 1 radius, start, end, // start and end angle of arc1 @@ -984,7 +987,8 @@ public: "conList.append(Sketcher.Constraint('PointOnObject', %i, 1, %i, ))\n" "conList.append(Sketcher.Constraint('PointOnObject', %i, 1, %i, ))\n" "conList.append(Sketcher.Constraint('PointOnObject', %i, 1, %i, ))\n" - "%s.addConstraint(conList)\n", + "%s.addConstraint(conList)\n" + "del geoList, conList\n", StartPos.x, StartPos.y, // point at StartPos EndPos.x, EndPos.y, // point at EndPos Gui::Command::getObjectCmd(sketchgui->getObject()).c_str(), // the sketch @@ -4843,6 +4847,7 @@ public: } cstream << Gui::Command::getObjectCmd(sketchgui->getObject()) << ".addConstraint(conList)\n"; + cstream << "del conList\n"; Gui::Command::doCommand(Gui::Command::Doc, cstream.str().c_str()); @@ -7129,7 +7134,8 @@ public: "conList.append(Sketcher.Constraint('Tangent', %i, 2, %i, 1))\n" "conList.append(Sketcher.Constraint('Tangent', %i, 2, %i, 1))\n" "conList.append(Sketcher.Constraint('Equal', %i, %i))\n" - "%s.addConstraint(conList)\n", + "%s.addConstraint(conList)\n" + "del geoList, conList\n", StartPos.x, StartPos.y, // center of the arc1 r, // radius arc1 start, end, // start and end angle of arc1 diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp b/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp index acfb48c942..93ec845a5e 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp @@ -379,7 +379,7 @@ public: class ExpressionDelegate : public QStyledItemDelegate { public: - ExpressionDelegate(QListWidget * _view) : view(_view) { } + ExpressionDelegate(QListWidget * _view) : QStyledItemDelegate(_view), view(_view) { } protected: QPixmap getIcon(const char* name, const QSize& size) const { diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index c3a89f5c12..e22254d2af 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -6376,6 +6376,7 @@ bool ViewProviderSketch::setEdit(int ModNum) " tv.sketchClipPlane(ActiveSketch, ActiveSketch.ViewObject.SectionView)\n" "tv.hide(ActiveSketch)\n" "del(tv)\n" + "del(ActiveSketch)\n" ).arg(QString::fromLatin1(getDocument()->getDocument()->getName()), QString::fromLatin1(getSketchObject()->getNameInDocument()), QString::fromLatin1(Gui::Command::getObjectCmd(editObj).c_str()), @@ -6907,6 +6908,7 @@ void ViewProviderSketch::unsetEdit(int ModNum) " tv.restore()\n" "ActiveSketch.ViewObject.TempoVis = None\n" "del(tv)\n" + "del(ActiveSketch)\n" ).arg(QString::fromLatin1(getDocument()->getDocument()->getName())).arg( QString::fromLatin1(getSketchObject()->getNameInDocument())); QByteArray cmdstr_bytearray = cmdstr.toLatin1(); diff --git a/src/Mod/Tux/NavigationIndicatorGui.py b/src/Mod/Tux/NavigationIndicatorGui.py index 516c17258b..c49048c42c 100644 --- a/src/Mod/Tux/NavigationIndicatorGui.py +++ b/src/Mod/Tux/NavigationIndicatorGui.py @@ -288,6 +288,42 @@ def retranslateUi(): """ + global t9 + t9 = "

OpenSCAD " + text06 + """

+ + + + + + + + + + + + + + + +
""" + text01 + """""" + text02 + """""" + text02 + """""" + text03 + """""" + text04 + """
""" + + global t10 + t10 = "

TinkerCAD " + text06 + """

+ + + + + + + + + + + + + +
""" + text01 + """""" + text02 + """""" + text03 + """""" + text04 + """
""" + menuSettings.setTitle(translate("NavigationIndicator", "Settings")) menuOrbit.setTitle(translate("NavigationIndicator", "Orbit style")) aCompact.setText(translate("NavigationIndicator", "Compact")) @@ -384,6 +420,18 @@ a8.setText("OpenCascade") a8.setData("Gui::OpenCascadeNavigationStyle") a8.setObjectName("Indicator_NavigationOpenCascade") +a9 = QtGui.QAction(gStyle) +a9.setIcon(QtGui.QIcon(":/icons/NavigationOpenSCAD_dark.svg")) +a9.setText("OpenSCAD") +a9.setData("Gui::OpenSCADNavigationStyle") +a9.setObjectName("Indicator_NavigationOpenSCAD") + +a10 = QtGui.QAction(gStyle) +a10.setIcon(QtGui.QIcon(":/icons/NavigationTinkerCAD_dark.svg")) +a10.setText("TinkerCAD") +a10.setData("Gui::TinkerCADNavigationStyle") +a10.setObjectName("Indicator_NavigationTinkerCAD") + menu.addMenu(menuSettings) menu.addSeparator() menu.addAction(a0) @@ -395,6 +443,8 @@ menu.addAction(a5) menu.addAction(a6) menu.addAction(a7) menu.addAction(a8) +menu.addAction(a9) +menu.addAction(a10) def onCompact(): @@ -430,6 +480,8 @@ def onTooltip(): a6.setToolTip(t6) a7.setToolTip(t7) a8.setToolTip(t8) + a9.setToolTip(t9) + a10.setToolTip(t10) p.SetBool("Tooltip", 1) else: for i in gStyle.actions(): diff --git a/src/Mod/Tux/Resources/Tux.qrc b/src/Mod/Tux/Resources/Tux.qrc index e503675307..471f97fcc8 100644 --- a/src/Mod/Tux/Resources/Tux.qrc +++ b/src/Mod/Tux/Resources/Tux.qrc @@ -58,6 +58,17 @@ icons/NavigationOpenInventor_dark.svg icons/NavigationOpenInventor_ZoomAlt.svg icons/NavigationOpenInventor_Zoom.svg + icons/NavigationCAD_dark.svg + icons/NavigationOpenCascade_Select.svg + icons/NavigationOpenCascade_PanAlt.svg + icons/NavigationOpenCascade_PanAlt.svg + icons/NavigationOpenCascade_Select.svg + icons/NavigationGesture_Pan.svg + icons/NavigationCAD_dark.svg + icons/NavigationOpenCascade_Select.svg + icons/NavigationOpenCascade_Zoom.svg + icons/NavigationGesture_Pan.svg + icons/NavigationOpenCascade_PanAlt.svg icons/NavigationRevit_Pan.svg icons/NavigationRevit_Rotate.svg icons/NavigationRevit_light.svg