Files
qglengine/mouse_controller.h
2022-12-14 14:14:44 +03:00

88 lines
2.6 KiB
C++

/*
QGL MouseController
Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MOUSE_CONTROLLER_H
#define MOUSE_CONTROLLER_H
#include "glcamera.h"
#include "glprimitives.h"
#include "renderer_service.h"
#include <QMouseEvent>
#include <QTime>
class MouseController: public QObject {
friend class QGLView;
friend class RendererSelection;
Q_OBJECT
public:
MouseController(QGLView * view_);
virtual ~MouseController();
bool isGrabMouseEnabled() const { return grabMouse_; }
bool isMouseRotateEnabled() const { return mouseRotate_; }
bool isMouseSelectionEnabled() const { return mouseSelect_; }
bool isCameraOrbit() const { return cameraOrbit_; }
Qt::MouseButton selectionButton() const { return sel_button; }
Qt::KeyboardModifier selectionModifier() const { return sel_mod; }
void setSelectionButton(Qt::MouseButton v) { sel_button = v; }
void setSelectionModifier(Qt::KeyboardModifier v) { sel_mod = v; }
protected:
void resize();
void mousePressEvent(QMouseEvent * e);
void mouseMoveEvent(QMouseEvent * e);
void mouseReleaseEvent(QMouseEvent * e);
void wheelEvent(QWheelEvent * e);
void leaveEvent(QEvent *);
void mouseDoubleClickEvent(QMouseEvent * e);
private:
QGLView * view;
QPoint lastPos, downPos;
QSet<int> keys_;
QVector<ObjectBase *> hov_objects, hov_aims;
Qt::MouseButton sel_button;
Qt::KeyboardModifier sel_mod;
RendererService::HandleAction cur_action;
QFlags<RendererService::HandleMesh> cur_handle;
float app_scale;
bool grabMouse_, mouse_first, mouseRotate_, mouseSelect_, customMouseMove_, canSelect_;
bool cameraOrbit_, selecting_, mouse_sec;
private slots:
public slots:
void setGrabMouseEnabled(const bool & arg) {
grabMouse_ = arg;
mouse_first = true;
}
void setMouseRotateEnabled(const bool & arg) { mouseRotate_ = arg; }
void setMouseSelectionEnabled(const bool & arg) { mouseSelect_ = arg; }
void setCustomMouseMove(const bool & arg) { customMouseMove_ = arg; }
void setCameraOrbit(const bool & arg) { cameraOrbit_ = arg; }
signals:
};
#endif // QGLVIEW_H