git-svn-id: svn://db.shs.com.ru/libs@421 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -30,6 +30,7 @@ QGLView::QGLView(QWidget * parent): QGraphicsView(parent), fbo_selection(3) {
|
||||
_w = 0;
|
||||
need_init_ = is_first_draw = true;
|
||||
objects_.is_root = true;
|
||||
objects_.view_ = this;
|
||||
painter_ = 0;
|
||||
backColor_ = Qt::black;
|
||||
hoverHaloColor_ = QColor(195, 140, 255, 96);
|
||||
@@ -119,9 +120,14 @@ void QGLView::addObject(QWidget * o, Qt::WindowFlags f) {
|
||||
|
||||
|
||||
void QGLView::addObject(GLObjectBase * o) {
|
||||
o->setView(this);
|
||||
objects_.addChild(o);
|
||||
o->setView(this);
|
||||
collectLights();
|
||||
QList<GLObjectBase*> cl = o->children(true);
|
||||
cl << o;
|
||||
foreach (GLObjectBase * i, cl) {
|
||||
emit objectAdded(i);
|
||||
}
|
||||
if (is_init) {
|
||||
globMutex.lock();
|
||||
o->init();
|
||||
@@ -130,9 +136,30 @@ void QGLView::addObject(GLObjectBase * o) {
|
||||
}
|
||||
|
||||
|
||||
void QGLView::removeObject(GLObjectBase * o, bool inChildren) {
|
||||
o->setView(0);
|
||||
if (inChildren)
|
||||
removeObjectInternal(o, &objects_);
|
||||
else
|
||||
objects_.removeChild(o);
|
||||
objectDeleted(o);
|
||||
}
|
||||
|
||||
|
||||
void QGLView::clearObjects(bool deleteAll) {
|
||||
removeObject(camera_);
|
||||
objects_.clearChildren(deleteAll);
|
||||
addObject(camera());
|
||||
selectObject(0);
|
||||
hov_obj = 0;
|
||||
}
|
||||
|
||||
|
||||
void QGLView::selectObject(GLObjectBase * o) {
|
||||
emit selectionChanged(o, sel_obj);
|
||||
if (o == sel_obj) return;
|
||||
GLObjectBase * pso = sel_obj;
|
||||
sel_obj = o;
|
||||
emit selectionChanged(sel_obj, pso);
|
||||
}
|
||||
|
||||
|
||||
@@ -224,6 +251,7 @@ void QGLView::paintGL() {
|
||||
if (need_init_)
|
||||
initializeGL();
|
||||
#endif
|
||||
emit glBeforePaint();
|
||||
//qDebug() << "paintGL";
|
||||
//QMutexLocker ml_v(&v_mutex);
|
||||
glEnable(GL_CULL_FACE);
|
||||
@@ -473,6 +501,13 @@ void QGLView::collectLights() {
|
||||
}
|
||||
|
||||
|
||||
void QGLView::objectDeleted(GLObjectBase * o) {
|
||||
//qDebug() << "del" << o;
|
||||
if (sel_obj == o) selectObject(0);
|
||||
if (hov_obj == o) hov_obj = 0;
|
||||
}
|
||||
|
||||
|
||||
QList<QGraphicsItem * > QGLView::collectGraphicItems() {
|
||||
QList<QGraphicsItem * > list = scene()->items();
|
||||
foreach (QGraphicsItem * i, list)
|
||||
@@ -500,6 +535,17 @@ void QGLView::collectObjectLights(GLObjectBase * o) {
|
||||
}
|
||||
|
||||
|
||||
void QGLView::removeObjectInternal(GLObjectBase * o, GLObjectBase * where) {
|
||||
foreach (GLObjectBase * i, where->children_) {
|
||||
if (o == i)
|
||||
where->removeChild(i);
|
||||
else
|
||||
removeObjectInternal(o, i);
|
||||
objectDeleted(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QGLView::checkCaps() {
|
||||
glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisotropic);
|
||||
//glGetIntegerv(GL_MAX_TEXTURE_UNITS, &max_texture_chanels);
|
||||
|
||||
Reference in New Issue
Block a user