git-svn-id: svn://db.shs.com.ru/libs@652 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -60,9 +60,10 @@ void MouseController::mouseReleaseEvent(QMouseEvent * e) {
|
|||||||
view->scene_->selectObjects(hov_objects.toList(), add_ts);
|
view->scene_->selectObjects(hov_objects.toList(), add_ts);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (canSelect_ && mouseSelect_ && e->button() == Qt::LeftButton) {
|
if (canSelect_ && mouseSelect_) {
|
||||||
if ((lastPos - downPos).manhattanLength() < QApplication::startDragDistance()) {
|
if ((lastPos - downPos).manhattanLength() < QApplication::startDragDistance()) {
|
||||||
qDebug() << hov_objects << hov_aims;
|
if (e->button() == Qt::LeftButton) {
|
||||||
|
//qDebug() << hov_objects << hov_aims;
|
||||||
if (hov_objects.isEmpty() && hov_aims.isEmpty()) {
|
if (hov_objects.isEmpty() && hov_aims.isEmpty()) {
|
||||||
view->scene()->clearSelection();
|
view->scene()->clearSelection();
|
||||||
} else {
|
} else {
|
||||||
@@ -74,6 +75,11 @@ void MouseController::mouseReleaseEvent(QMouseEvent * e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (e->button() == Qt::RightButton) {
|
||||||
|
if (view->renderer_.edit_mode && !view->scene()->selectedObjects().isEmpty())
|
||||||
|
view->context_menu.popup(e->globalPos());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
canSelect_ = e->buttons() == 0;
|
canSelect_ = e->buttons() == 0;
|
||||||
emit view->glMouseReleaseEvent(e);
|
emit view->glMouseReleaseEvent(e);
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
#include "mouse_controller.h"
|
#include "mouse_controller.h"
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
|
|
||||||
class QGLView: public OpenGLWindow
|
class QGLView: public OpenGLWindow
|
||||||
@@ -170,7 +171,7 @@ public:
|
|||||||
|
|
||||||
QImage materialThumbnail(Material * m) {return renderer_.materialThumbnail(m);}
|
QImage materialThumbnail(Material * m) {return renderer_.materialThumbnail(m);}
|
||||||
void setCurrentAction(RendererService::HandleAction ha) {renderer_.rend_service.setCurrentAction(ha);}
|
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;
|
GLfloat aspect, iaspect;
|
||||||
Renderer renderer_;
|
Renderer renderer_;
|
||||||
@@ -202,6 +203,7 @@ private:
|
|||||||
Scene * scene_;
|
Scene * scene_;
|
||||||
Camera * camera_;
|
Camera * camera_;
|
||||||
MouseController mouse;
|
MouseController mouse;
|
||||||
|
QMenu context_menu;
|
||||||
// uint cid;
|
// uint cid;
|
||||||
QSet<int> keys_;
|
QSet<int> keys_;
|
||||||
QColor backColor_, fogColor_, ambientColor_, hoverHaloColor_, selectionHaloColor_;
|
QColor backColor_, fogColor_, ambientColor_, hoverHaloColor_, selectionHaloColor_;
|
||||||
|
|||||||
@@ -43,6 +43,13 @@ enum ObjectType {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
QAction * newSeparator() {
|
||||||
|
QAction * s = new QAction();
|
||||||
|
s->setSeparator(true);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SceneTree::SceneTree(QWidget * parent): QWidget(parent) {
|
SceneTree::SceneTree(QWidget * parent): QWidget(parent) {
|
||||||
ui = new Ui::SceneTree();
|
ui = new Ui::SceneTree();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@@ -71,11 +78,13 @@ SceneTree::~SceneTree() {
|
|||||||
|
|
||||||
void SceneTree::assignQGLView(QGLView * v) {
|
void SceneTree::assignQGLView(QGLView * v) {
|
||||||
view = v;
|
view = v;
|
||||||
|
objectsTreeChanged();
|
||||||
|
if (!view) return;
|
||||||
connect(view, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
|
connect(view, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
|
||||||
connect(view, SIGNAL(materialsChanged()), this, SLOT(materialsChanged()));
|
connect(view, SIGNAL(materialsChanged()), this, SLOT(materialsChanged()));
|
||||||
connect(view->scene(), SIGNAL(treeChanged()), this, SLOT(objectsTreeChanged()));
|
connect(view->scene(), SIGNAL(treeChanged()), this, SLOT(objectsTreeChanged()));
|
||||||
connect(view->scene(), SIGNAL(__objectDeleted(ObjectBase*)), this, SLOT(__objectDeleted(ObjectBase*)));
|
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 *> SceneTree::actionsSelection() {
|
||||||
QList<QAction *> ret;
|
QList<QAction *> ret;
|
||||||
ret << ui->actionFocus << ui->actionRemove << ui->actionClone << ui->actionGroup
|
ret << ui->actionFocus << newSeparator()
|
||||||
<< ui->actionSelect_parent << ui->actionSelect_by_mesh << ui->actionSelect_by_material;
|
<< ui->actionGroup << ui->actionClone << newSeparator()
|
||||||
|
<< ui->actionSelect_parent << ui->actionSelect_by_mesh << ui->actionSelect_by_material << newSeparator()
|
||||||
|
<< ui->actionRemove;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user