git-svn-id: svn://db.shs.com.ru/libs@652 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2019-12-04 17:16:13 +00:00
parent 888f970f44
commit 2dbdf09bb9
3 changed files with 33 additions and 14 deletions

View File

@@ -60,19 +60,25 @@ void MouseController::mouseReleaseEvent(QMouseEvent * e) {
view->scene_->selectObjects(hov_objects.toList(), add_ts);
return;
}
if (canSelect_ && mouseSelect_ && e->button() == Qt::LeftButton) {
if (canSelect_ && mouseSelect_) {
if ((lastPos - downPos).manhattanLength() < QApplication::startDragDistance()) {
qDebug() << hov_objects << hov_aims;
if (hov_objects.isEmpty() && hov_aims.isEmpty()) {
view->scene()->clearSelection();
} else {
if (!hov_objects.isEmpty())
view->scene_->selectObject(hov_objects[0], add_ts);
if (!hov_aims.isEmpty()) {
view->scene_->selectObject(hov_aims[0], add_ts);
hov_aims[0]->selected_aim = true;
if (e->button() == Qt::LeftButton) {
//qDebug() << hov_objects << hov_aims;
if (hov_objects.isEmpty() && hov_aims.isEmpty()) {
view->scene()->clearSelection();
} else {
if (!hov_objects.isEmpty())
view->scene_->selectObject(hov_objects[0], add_ts);
if (!hov_aims.isEmpty()) {
view->scene_->selectObject(hov_aims[0], add_ts);
hov_aims[0]->selected_aim = true;
}
}
}
if (e->button() == Qt::RightButton) {
if (view->renderer_.edit_mode && !view->scene()->selectedObjects().isEmpty())
view->context_menu.popup(e->globalPos());
}
}
}
canSelect_ = e->buttons() == 0;

View File

@@ -28,6 +28,7 @@
#include "renderer.h"
#include "mouse_controller.h"
#include <QTime>
#include <QMenu>
class QGLView: public OpenGLWindow
@@ -170,7 +171,7 @@ public:
QImage materialThumbnail(Material * m) {return renderer_.materialThumbnail(m);}
void setCurrentAction(RendererService::HandleAction ha) {renderer_.rend_service.setCurrentAction(ha);}
void setContextActions(QList<QAction*> al) {context_menu.clear(); context_menu.addActions(al);}
GLfloat aspect, iaspect;
Renderer renderer_;
@@ -202,6 +203,7 @@ private:
Scene * scene_;
Camera * camera_;
MouseController mouse;
QMenu context_menu;
// uint cid;
QSet<int> keys_;
QColor backColor_, fogColor_, ambientColor_, hoverHaloColor_, selectionHaloColor_;

View File

@@ -43,6 +43,13 @@ enum ObjectType {
};
QAction * newSeparator() {
QAction * s = new QAction();
s->setSeparator(true);
return s;
}
SceneTree::SceneTree(QWidget * parent): QWidget(parent) {
ui = new Ui::SceneTree();
ui->setupUi(this);
@@ -71,11 +78,13 @@ SceneTree::~SceneTree() {
void SceneTree::assignQGLView(QGLView * v) {
view = v;
objectsTreeChanged();
if (!view) return;
connect(view, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
connect(view, SIGNAL(materialsChanged()), this, SLOT(materialsChanged()));
connect(view->scene(), SIGNAL(treeChanged()), this, SLOT(objectsTreeChanged()));
connect(view->scene(), SIGNAL(__objectDeleted(ObjectBase*)), this, SLOT(__objectDeleted(ObjectBase*)));
objectsTreeChanged();
view->setContextActions(actionsSelection());
}
@@ -88,8 +97,10 @@ QList<QAction *> SceneTree::actionsAdd() {
QList<QAction *> SceneTree::actionsSelection() {
QList<QAction *> ret;
ret << ui->actionFocus << ui->actionRemove << ui->actionClone << ui->actionGroup
<< ui->actionSelect_parent << ui->actionSelect_by_mesh << ui->actionSelect_by_material;
ret << ui->actionFocus << newSeparator()
<< ui->actionGroup << ui->actionClone << newSeparator()
<< ui->actionSelect_parent << ui->actionSelect_by_mesh << ui->actionSelect_by_material << newSeparator()
<< ui->actionRemove;
return ret;
}