| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| |
|
| | #ifndef GUI_NAVIGATIONSTYLE_H
|
| | #define GUI_NAVIGATIONSTYLE_H
|
| |
|
| | #include <Inventor/C/basic.h>
|
| | #include <Inventor/SbBox2s.h>
|
| | #include <Inventor/SbPlane.h>
|
| | #include <Inventor/SbRotation.h>
|
| | #include <Inventor/SbSphere.h>
|
| | #include <Inventor/SbTime.h>
|
| | #include <Inventor/SbVec2f.h>
|
| | #include <Inventor/SbVec2s.h>
|
| | #include <Inventor/SbVec3f.h>
|
| | #include <Inventor/events/SoEvents.h>
|
| |
|
| | #include <QEvent>
|
| | #include <QAction>
|
| | #include <Base/BaseClass.h>
|
| | #include <Base/SmartPtrPy.h>
|
| | #include <Gui/Namespace.h>
|
| | #include <FCGlobal.h>
|
| | #include <memory>
|
| | #include <optional>
|
| |
|
| |
|
| | class SoEvent;
|
| | class SoMouseWheelEvent;
|
| | class SoMotion3Event;
|
| | class SoQtViewer;
|
| | class SoCamera;
|
| | class SoSensor;
|
| | class SbSphereSheetProjector;
|
| |
|
| |
|
| | namespace Gui
|
| | {
|
| |
|
| | class View3DInventorViewer;
|
| | class NavigationAnimator;
|
| | class AbstractMouseSelection;
|
| | class NavigationAnimation;
|
| |
|
| | |
| | |
| |
|
| | class GuiExport NavigationStyleEvent: public QEvent
|
| | {
|
| | public:
|
| | explicit NavigationStyleEvent(const Base::Type& s);
|
| | ~NavigationStyleEvent() override;
|
| | const Base::Type& style() const;
|
| |
|
| | private:
|
| | Base::Type t;
|
| | };
|
| |
|
| | |
| | |
| | |
| |
|
| | class GuiExport NavigationStyle: public Base::BaseClass
|
| | {
|
| | TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
| |
|
| | public:
|
| | enum ViewerMode
|
| | {
|
| | IDLE,
|
| | INTERACT,
|
| | ZOOMING,
|
| | BOXZOOM,
|
| | PANNING,
|
| | DRAGGING,
|
| | SPINNING,
|
| | SEEK_WAIT_MODE,
|
| | SEEK_MODE,
|
| | SELECTION
|
| | };
|
| |
|
| | enum SelectionMode
|
| | {
|
| | Lasso = 0,
|
| | Rectangle = 1,
|
| | Rubberband = 2,
|
| | BoxZoom = 3,
|
| | Clip = 4,
|
| | };
|
| |
|
| | enum class ClarifySelectionMode
|
| | {
|
| | Default,
|
| | Ctrl
|
| | };
|
| |
|
| | enum OrbitStyle
|
| | {
|
| | Turntable,
|
| | Trackball,
|
| | FreeTurntable,
|
| | TrackballClassic,
|
| | RoundedArcball
|
| | };
|
| |
|
| | enum class RotationCenterMode
|
| | {
|
| | WindowCenter = 0,
|
| | ScenePointAtCursor = 1, |
| |
|
| | FocalPointAtCursor = 2,
|
| | BoundingBoxCenter = 4
|
| | };
|
| | Q_DECLARE_FLAGS(RotationCenterModes, RotationCenterMode)
|
| |
|
| | public:
|
| | NavigationStyle();
|
| | ~NavigationStyle() override;
|
| | NavigationStyle(const NavigationStyle&) = delete;
|
| |
|
| | NavigationStyle& operator=(const NavigationStyle& ns);
|
| | void setViewer(View3DInventorViewer*);
|
| |
|
| | void setAnimationEnabled(const SbBool enable);
|
| | void setSpinningAnimationEnabled(const SbBool enable);
|
| | SbBool isAnimationEnabled() const;
|
| | SbBool isSpinningAnimationEnabled() const;
|
| | SbBool isAnimating() const;
|
| | SbBool isSpinning() const;
|
| | void startAnimating(const std::shared_ptr<NavigationAnimation>& animation, bool wait = false) const;
|
| | void stopAnimating() const;
|
| |
|
| | void setSensitivity(float);
|
| | float getSensitivity() const;
|
| |
|
| | void setResetCursorPosition(SbBool);
|
| | SbBool isResetCursorPosition() const;
|
| |
|
| | void setZoomInverted(SbBool);
|
| | SbBool isZoomInverted() const;
|
| | void setZoomStep(float);
|
| | void setZoomAtCursor(SbBool);
|
| | SbBool isZoomAtCursor() const;
|
| | void zoomIn();
|
| | void zoomOut();
|
| | void setRotationCenterMode(RotationCenterModes);
|
| | RotationCenterModes getRotationCenterMode() const;
|
| | void setRotationCenter(const SbVec3f& cnt);
|
| | SbVec3f getFocalPoint() const;
|
| |
|
| | SoCamera* getCamera() const;
|
| | std::shared_ptr<NavigationAnimation> setCameraOrientation(
|
| | const SbRotation& orientation,
|
| | SbBool moveToCenter = false
|
| | ) const;
|
| | std::shared_ptr<NavigationAnimation> translateCamera(const SbVec3f& translation) const;
|
| |
|
| | #if (COIN_MAJOR_VERSION * 100 + COIN_MINOR_VERSION * 10 + COIN_MICRO_VERSION < 403)
|
| | void findBoundingSphere();
|
| | #endif
|
| |
|
| | void reorientCamera(SoCamera* camera, const SbRotation& rotation);
|
| | void reorientCamera(SoCamera* camera, const SbRotation& rotation, const SbVec3f& rotationCenter);
|
| |
|
| | void boxZoom(const SbBox2s& box);
|
| |
|
| | void scale(float factor);
|
| | virtual void viewAll();
|
| |
|
| | void setViewingMode(const ViewerMode newmode);
|
| | 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() const;
|
| |
|
| | void startSelection(AbstractMouseSelection*);
|
| | void startSelection(SelectionMode = Lasso);
|
| | void abortSelection();
|
| | void stopSelection();
|
| | SbBool isSelecting() const;
|
| | const std::vector<SbVec2s>& getPolygon(SelectionRole* role = nullptr) const;
|
| |
|
| | bool isDraggerUnderCursor(const SbVec2s pos) const;
|
| |
|
| | virtual ClarifySelectionMode clarifySelectionMode() const
|
| | {
|
| | return ClarifySelectionMode::Default;
|
| | }
|
| |
|
| | void setOrbitStyle(OrbitStyle style);
|
| | OrbitStyle getOrbitStyle() const;
|
| |
|
| | SbBool isViewing() const;
|
| | void setViewing(SbBool);
|
| |
|
| | SbVec3f getRotationCenter(SbBool&) const;
|
| |
|
| | std::optional<SbVec2s>& getRightClickPosition();
|
| |
|
| | PyObject* getPyObject() override;
|
| |
|
| | protected:
|
| | void initialize();
|
| | void finalize();
|
| |
|
| | void interactiveCountInc();
|
| | void interactiveCountDec();
|
| | int getInteractiveCount() const;
|
| |
|
| | SbBool isSeekMode() const;
|
| | void setSeekMode(SbBool enable);
|
| | SbBool seekToPoint(const SbVec2s screenpos);
|
| | void seekToPoint(const SbVec3f& scenepos);
|
| | void lookAtPoint(const SbVec2s screenpos);
|
| | void lookAtPoint(const SbVec3f& position);
|
| |
|
| | void panCamera(
|
| | SoCamera* camera,
|
| | float vpaspect,
|
| | const SbPlane& panplane,
|
| | const SbVec2f& previous,
|
| | const SbVec2f& current
|
| | );
|
| | void setupPanningPlane(const SoCamera* camera);
|
| | int getDelta() const;
|
| | void zoom(SoCamera* camera, float diffvalue);
|
| | virtual void zoomByCursor(const SbVec2f& thispos, const SbVec2f& prevpos);
|
| | void doZoom(SoCamera* camera, int wheeldelta, const SbVec2f& pos);
|
| | void doZoom(SoCamera* camera, float logzoomfactor, const SbVec2f& pos);
|
| | void doScale(SoCamera* camera, float factor);
|
| | void doRotate(SoCamera* camera, float angle, const SbVec2f& pos);
|
| | void spin(const SbVec2f& pointerpos);
|
| | SbBool doSpin();
|
| | void spin_simplified(SbVec2f curpos, SbVec2f prevpos);
|
| | void moveCursorPosition();
|
| | void saveCursorPosition(const SoEvent* const ev);
|
| |
|
| | SbVec2f normalizePixelPos(SbVec2s pixpos);
|
| | SbVec2f normalizePixelPos(SbVec2f pixpos);
|
| |
|
| | SbBool handleEventInForeground(const SoEvent* const e);
|
| | virtual SbBool processSoEvent(const SoEvent* const ev);
|
| | void syncWithEvent(const SoEvent* const ev);
|
| | virtual void openPopupMenu(const SbVec2s& position);
|
| |
|
| | private:
|
| | void spinInternal(const SbVec2f& pointerpos, const SbVec2f& lastpos);
|
| | void spinSimplifiedInternal(const SbVec2f curpos, const SbVec2f prevpos);
|
| | bool isNavigationStyleAction(QAction* action, QActionGroup* navMenuGroup) const;
|
| | QWidget* findView3DInventorWidget() const;
|
| | void applyNavigationStyleChange(QAction* selectedAction);
|
| |
|
| | protected:
|
| | void clearLog();
|
| | void addToLog(const SbVec2s pos, const SbTime time);
|
| |
|
| | void syncModifierKeys(const SoEvent* const ev);
|
| |
|
| | protected:
|
| | struct
|
| | {
|
| | short size;
|
| | short historysize;
|
| | SbVec2s* position;
|
| | SbTime* time;
|
| | } log;
|
| |
|
| | View3DInventorViewer* viewer {nullptr};
|
| | NavigationAnimator* animator;
|
| | SbBool animationEnabled;
|
| | ViewerMode currentmode;
|
| | SoMouseButtonEvent mouseDownConsumedEvent;
|
| | SbVec2f lastmouseposition;
|
| | SbVec2s globalPos;
|
| | SbVec2s localPos;
|
| | SbPlane panningplane;
|
| | SbTime centerTime;
|
| | SbBool lockrecenter;
|
| | SbBool menuenabled;
|
| | SbBool ctrldown, shiftdown, altdown;
|
| | SbBool button1down, button2down, button3down;
|
| | SbBool invertZoom;
|
| | SbBool zoomAtCursor;
|
| | float zoomStep;
|
| | SbBool hasDragged;
|
| | SbBool hasPanned;
|
| | SbBool hasZoomed;
|
| |
|
| |
|
| |
|
| | AbstractMouseSelection* mouseSelection {nullptr};
|
| | std::vector<SbVec2s> pcPolygon;
|
| | SelectionRole selectedRole;
|
| |
|
| |
|
| |
|
| |
|
| | SbBool spinningAnimationEnabled;
|
| | int spinsamplecounter;
|
| | SbRotation spinincrement;
|
| | SbSphereSheetProjector* spinprojector;
|
| |
|
| |
|
| | Py::SmartPtr pythonObject;
|
| |
|
| |
|
| |
|
| | std::optional<SbVec2s> rightClickPosition;
|
| |
|
| | private:
|
| | friend class NavigationAnimator;
|
| |
|
| | SbVec3f rotationCenter;
|
| | SbBool rotationCenterFound;
|
| | SbBool rotationCenterIsScenePointAtCursor;
|
| | NavigationStyle::RotationCenterModes rotationCenterMode;
|
| | float sensitivity;
|
| | SbBool resetcursorpos;
|
| |
|
| | #if (COIN_MAJOR_VERSION * 100 + COIN_MINOR_VERSION * 10 + COIN_MICRO_VERSION < 403)
|
| | SbSphere boundingSphere;
|
| | #endif
|
| | };
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | class GuiExport UserNavigationStyle: public NavigationStyle
|
| | {
|
| | TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
| |
|
| | public:
|
| | UserNavigationStyle() = default;
|
| | ~UserNavigationStyle() override = default;
|
| | virtual const char* mouseButtons(ViewerMode) = 0;
|
| | virtual std::string userFriendlyName() const;
|
| | static std::map<Base::Type, std::string> getUserFriendlyNames();
|
| | };
|
| |
|
| | class GuiExport InventorNavigationStyle: public UserNavigationStyle
|
| | {
|
| | using inherited = UserNavigationStyle;
|
| |
|
| | TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
| |
|
| | public:
|
| | InventorNavigationStyle();
|
| | ~InventorNavigationStyle() override;
|
| | const char* mouseButtons(ViewerMode) override;
|
| | std::string userFriendlyName() const override;
|
| | ClarifySelectionMode clarifySelectionMode() const override
|
| | {
|
| | return ClarifySelectionMode::Ctrl;
|
| | }
|
| |
|
| | protected:
|
| | SbBool processSoEvent(const SoEvent* const ev) override;
|
| | };
|
| |
|
| | class GuiExport CADNavigationStyle: public UserNavigationStyle
|
| | {
|
| | using inherited = UserNavigationStyle;
|
| |
|
| | TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
| |
|
| | public:
|
| | CADNavigationStyle();
|
| | ~CADNavigationStyle() override;
|
| | const char* mouseButtons(ViewerMode) override;
|
| |
|
| | protected:
|
| | SbBool processSoEvent(const SoEvent* const ev) override;
|
| |
|
| | private:
|
| | SbBool lockButton1 {false};
|
| | };
|
| |
|
| | class GuiExport RevitNavigationStyle: public UserNavigationStyle
|
| | {
|
| | using inherited = UserNavigationStyle;
|
| |
|
| | TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
| |
|
| | public:
|
| | RevitNavigationStyle();
|
| | ~RevitNavigationStyle() override;
|
| | const char* mouseButtons(ViewerMode) override;
|
| |
|
| | protected:
|
| | SbBool processSoEvent(const SoEvent* const ev) override;
|
| |
|
| | private:
|
| | SbBool lockButton1 {false};
|
| | };
|
| |
|
| | class GuiExport BlenderNavigationStyle: public UserNavigationStyle
|
| | {
|
| | using inherited = UserNavigationStyle;
|
| |
|
| | TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
| |
|
| | public:
|
| | BlenderNavigationStyle();
|
| | ~BlenderNavigationStyle() override;
|
| | const char* mouseButtons(ViewerMode) override;
|
| |
|
| | protected:
|
| | SbBool processSoEvent(const SoEvent* const ev) override;
|
| |
|
| | private:
|
| | SbBool lockButton1 {false};
|
| | };
|
| |
|
| | class GuiExport SolidWorksNavigationStyle: public UserNavigationStyle
|
| | {
|
| | using inherited = UserNavigationStyle;
|
| |
|
| | TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
| |
|
| | public:
|
| | SolidWorksNavigationStyle();
|
| | ~SolidWorksNavigationStyle() override;
|
| | const char* mouseButtons(ViewerMode) override;
|
| |
|
| | protected:
|
| | SbBool processSoEvent(const SoEvent* const ev) override;
|
| |
|
| | private:
|
| | SbBool lockButton1 {false};
|
| | };
|
| |
|
| | class GuiExport MayaGestureNavigationStyle: public UserNavigationStyle
|
| | {
|
| | using inherited = UserNavigationStyle;
|
| |
|
| | TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
| |
|
| | public:
|
| | MayaGestureNavigationStyle();
|
| | ~MayaGestureNavigationStyle() override;
|
| | const char* mouseButtons(ViewerMode) override;
|
| |
|
| | protected:
|
| | void zoomByCursor(const SbVec2f& thispos, const SbVec2f& prevpos) override;
|
| |
|
| | SbBool processSoEvent(const SoEvent* const ev) override;
|
| |
|
| | SbVec2s mousedownPos;
|
| | short mouseMoveThreshold;
|
| | bool mouseMoveThresholdBroken;
|
| | int mousedownConsumedCount;
|
| |
|
| | SoMouseButtonEvent mousedownConsumedEvents[5];
|
| |
|
| |
|
| | bool testMoveThreshold(const SbVec2s currentPos) const;
|
| |
|
| | bool thisClickIsComplex;
|
| |
|
| | bool inGesture;
|
| | };
|
| |
|
| | class GuiExport TouchpadNavigationStyle: public UserNavigationStyle
|
| | {
|
| | using inherited = UserNavigationStyle;
|
| |
|
| | TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
| |
|
| | public:
|
| | TouchpadNavigationStyle();
|
| | ~TouchpadNavigationStyle() override;
|
| | const char* mouseButtons(ViewerMode) override;
|
| |
|
| | protected:
|
| | SbBool processSoEvent(const SoEvent* const ev) override;
|
| |
|
| | private:
|
| | SbBool blockPan {false};
|
| | };
|
| |
|
| | class GuiExport OpenCascadeNavigationStyle: public UserNavigationStyle
|
| | {
|
| | using inherited = UserNavigationStyle;
|
| |
|
| | TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
| |
|
| | public:
|
| | OpenCascadeNavigationStyle();
|
| | ~OpenCascadeNavigationStyle() override;
|
| | const char* mouseButtons(ViewerMode) override;
|
| |
|
| | protected:
|
| | SbBool processSoEvent(const SoEvent* const ev) override;
|
| | };
|
| |
|
| | class GuiExport OpenSCADNavigationStyle: public UserNavigationStyle
|
| | {
|
| | using inherited = UserNavigationStyle;
|
| |
|
| | TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
| |
|
| | public:
|
| | OpenSCADNavigationStyle();
|
| | ~OpenSCADNavigationStyle() override;
|
| | const char* mouseButtons(ViewerMode) override;
|
| | ClarifySelectionMode clarifySelectionMode() const override
|
| | {
|
| | return ClarifySelectionMode::Ctrl;
|
| | }
|
| |
|
| | protected:
|
| | SbBool processSoEvent(const SoEvent* const ev) override;
|
| | };
|
| |
|
| | class GuiExport TinkerCADNavigationStyle: public UserNavigationStyle
|
| | {
|
| | using inherited = UserNavigationStyle;
|
| |
|
| | TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
| |
|
| | public:
|
| | TinkerCADNavigationStyle();
|
| | ~TinkerCADNavigationStyle() override;
|
| | const char* mouseButtons(ViewerMode) override;
|
| |
|
| | protected:
|
| | SbBool processSoEvent(const SoEvent* const ev) override;
|
| | };
|
| |
|
| | }
|
| |
|
| |
|
| | Q_DECLARE_OPERATORS_FOR_FLAGS(Gui::NavigationStyle::RotationCenterModes)
|
| |
|
| | #endif
|
| |
|