30 #include <QApplication> 34 #include <OgreSceneManager.h> 35 #include <OgreCamera.h> 51 , focus_on_mouse_move_(true)
53 , scene_manager_(nullptr)
54 , view_controller_(nullptr)
55 , context_menu_visible_(false)
57 , fake_mouse_move_event_timer_(new QTimer())
58 , default_camera_(nullptr)
60 setFocusPolicy(Qt::WheelFocus);
61 setFocus(Qt::OtherFocusReason);
62 setMouseTracking(
true);
87 ss <<
"RenderPanelCamera" << count++;
99 QPoint cursor_pos = QCursor::pos();
100 QPoint mouse_rel_widget = mapFromGlobal(cursor_pos);
101 if (rect().contains(mouse_rel_widget))
103 bool mouse_over_this =
false;
104 QWidget* w = QApplication::widgetAt(cursor_pos);
109 mouse_over_this =
true;
112 w = w->parentWidget();
114 if (!mouse_over_this)
119 QMouseEvent fake_event(QEvent::MouseMove, mouse_rel_widget, Qt::NoButton,
120 QApplication::mouseButtons(), QApplication::queryKeyboardModifiers());
127 setCursor(Qt::ArrowCursor);
146 setFocus(Qt::MouseFocusReason);
200 QApplication::postEvent(
this,
new QContextMenuEvent(QContextMenuEvent::Mouse, QPoint()));
223 connect(context_menu.get(), SIGNAL(aboutToHide()),
this, SLOT(
onContextMenuHide()));
224 context_menu->exec(QCursor::pos());
virtual void setStatus(const QString &message)=0
ViewController * view_controller_
virtual void handleMouseEvent(const ViewportMouseEvent &event)=0
Handle a mouse event.
void initialize(Ogre::SceneManager *scene_manager, DisplayContext *manager)
void sceneManagerDestroyed(Ogre::SceneManager *source) override
void sendMouseMoveEvent()
Ogre::Camera * getCamera() const
void setFocusOnMouseMove(bool enabled)
void setViewController(ViewController *controller)
Set the ViewController which should control the camera position for this view.
void showContextMenu(boost::shared_ptr< QMenu > menu)
bool context_menu_visible_
bool getFocusOnMouseMove() const
virtual void handleChar(QKeyEvent *event, RenderPanel *panel)=0
Handle a single key event for a given RenderPanel.
Ogre::SceneManager * scene_manager_
void onRenderWindowMouseEvents(QMouseEvent *event)
Called when any mouse event happens inside the render window.
Pure-virtual base class for objects which give Display subclasses context in which to work...
bool contextMenuVisible()
int mouse_y_
Y position of the last mouse event.
Ogre::Viewport * getViewport() const
void leaveEvent(QEvent *event) override
DisplayContext * context_
QTimer * fake_mouse_move_event_timer_
bool focus_on_mouse_move_
a moving the mouse catches keyboard focus
int mouse_x_
X position of the last mouse event.
boost::shared_ptr< QMenu > context_menu_
void wheelEvent(QWheelEvent *event) override
Called when there is a mouse-wheel event.
void activate()
Called by RenderPanel when this view controller is about to be used.
void setCamera(Ogre::Camera *camera)
void keyPressEvent(QKeyEvent *event) override
boost::mutex context_menu_mutex_
RenderPanel(QWidget *parent=nullptr)
Ogre::Camera * default_camera_
A default camera created in initialize().
void contextMenuEvent(QContextMenuEvent *event) override