git-svn-id: svn://db.shs.com.ru/libs@626 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
95
qglengine/plugin/qglviewplugin.cpp
Normal file
95
qglengine/plugin/qglviewplugin.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
#include "../glwidget.h"
|
||||
#include "qglviewplugin.h"
|
||||
#include <QtCore/QtPlugin>
|
||||
#include "glprimitives.h"
|
||||
#include "qglview.h"
|
||||
|
||||
|
||||
QGLViewPlugin::QGLViewPlugin(QObject * parent): QObject(parent) {
|
||||
m_initialized = false;
|
||||
}
|
||||
|
||||
|
||||
void QGLViewPlugin::initialize(QDesignerFormEditorInterface * /* core */) {
|
||||
if (m_initialized)
|
||||
return;
|
||||
|
||||
// Add extension registrations, etc. here
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
|
||||
bool QGLViewPlugin::isInitialized() const {
|
||||
return m_initialized;
|
||||
}
|
||||
|
||||
|
||||
QWidget * QGLViewPlugin::createWidget(QWidget * parent) {
|
||||
GLWidget * w = new GLWidget(parent);
|
||||
if (m_initialized) {
|
||||
auto axis = new GLObjectBase();
|
||||
GLObjectBase * obj;
|
||||
float al = 1.;
|
||||
obj = new GLPrimitiveLine(QVector3D(0, 0, -al), QVector3D(0, 0, al));
|
||||
obj->material().color_diffuse = Qt::darkBlue; obj->setAcceptLight(false);
|
||||
obj->setSelectable(false);
|
||||
axis->addChild(obj);
|
||||
obj = new GLPrimitiveLine(QVector3D(-al, 0, 0), QVector3D(al, 0, 0));
|
||||
obj->material().color_diffuse = Qt::darkRed; obj->setAcceptLight(false);
|
||||
obj->setSelectable(false);
|
||||
axis->addChild(obj);
|
||||
obj = new GLPrimitiveLine(QVector3D(0, -al, 0), QVector3D(0, al, 0));
|
||||
obj->material().color_diffuse = Qt::darkGreen; obj->setAcceptLight(false);
|
||||
obj->setSelectable(false);
|
||||
axis->addChild(obj);
|
||||
w->view()->addObject(axis);
|
||||
auto cam_light = new Light();
|
||||
cam_light->intensity = 0.5;
|
||||
cam_light->setName("Camera_Light");
|
||||
w->view()->camera()->addChild(cam_light);
|
||||
w->start();
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
|
||||
QString QGLViewPlugin::name() const {
|
||||
return QLatin1String("GLWidget");
|
||||
}
|
||||
|
||||
|
||||
QString QGLViewPlugin::group() const {
|
||||
return QLatin1String("Display Widgets");
|
||||
}
|
||||
|
||||
|
||||
QIcon QGLViewPlugin::icon() const {
|
||||
return QIcon("://icons/qglview.png");
|
||||
}
|
||||
|
||||
|
||||
QString QGLViewPlugin::toolTip() const {
|
||||
return QLatin1String("");
|
||||
}
|
||||
|
||||
|
||||
QString QGLViewPlugin::whatsThis() const {
|
||||
return QLatin1String("");
|
||||
}
|
||||
|
||||
|
||||
bool QGLViewPlugin::isContainer() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
QString QGLViewPlugin::domXml() const {
|
||||
return QLatin1String("<widget class=\"GLWidget\" name=\"glview\">\n</widget>\n");
|
||||
}
|
||||
|
||||
|
||||
QString QGLViewPlugin::includeFile() const {
|
||||
return QLatin1String("glwidget.h");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user