git-svn-id: svn://db.shs.com.ru/libs@626 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
12
qglengine/plugin/CMakeLists.txt
Normal file
12
qglengine/plugin/CMakeLists.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
project(qglengine_plugin)
|
||||
include_directories("..")
|
||||
add_definitions(-DQT_PLUGIN)
|
||||
add_definitions(-DQT_NO_DEBUG)
|
||||
add_definitions(-DQT_SHARED)
|
||||
add_definitions(-DQDESIGNER_EXPORT_WIDGETS)
|
||||
find_qt(${QtVersions} Core Designer Gui Widgets OpenGL)
|
||||
qt_sources(SRC)
|
||||
qt_wrap(${SRC} CPPS out_CPP QMS out_QM)
|
||||
qt_add_library(${PROJECT_NAME} SHARED out_CPP)
|
||||
qt_target_link_libraries(${PROJECT_NAME} qglengine)
|
||||
qt_install(TARGETS ${PROJECT_NAME} DESTINATION QtPlugins/designer)
|
||||
14
qglengine/plugin/qglview_designerplugin.cpp
Normal file
14
qglengine/plugin/qglview_designerplugin.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "qglview_designerplugin.h"
|
||||
#include "qglviewplugin.h"
|
||||
|
||||
|
||||
QGLViewDesignerPlugin::QGLViewDesignerPlugin(QObject * parent): QObject(parent)
|
||||
{
|
||||
m_widgets.append(new QGLViewPlugin(this));
|
||||
}
|
||||
|
||||
|
||||
QList<QDesignerCustomWidgetInterface * > QGLViewDesignerPlugin::customWidgets() const {
|
||||
return m_widgets;
|
||||
}
|
||||
|
||||
22
qglengine/plugin/qglview_designerplugin.h
Normal file
22
qglengine/plugin/qglview_designerplugin.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef QGLVIEW_DESIGNERPLUGIN_H
|
||||
#define QGLVIEW_DESIGNERPLUGIN_H
|
||||
|
||||
#include <QtDesigner/QtDesigner>
|
||||
#include <QtCore/qplugin.h>
|
||||
|
||||
|
||||
class QGLViewDesignerPlugin: public QObject, public QDesignerCustomWidgetCollectionInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "qad.qglview")
|
||||
Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)
|
||||
public:
|
||||
QGLViewDesignerPlugin(QObject * parent = 0);
|
||||
virtual QList<QDesignerCustomWidgetInterface * > customWidgets() const;
|
||||
|
||||
private:
|
||||
QList<QDesignerCustomWidgetInterface * > m_widgets;
|
||||
|
||||
};
|
||||
|
||||
#endif // QGLVIEW_DESIGNERPLUGIN_H
|
||||
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");
|
||||
}
|
||||
|
||||
33
qglengine/plugin/qglviewplugin.h
Normal file
33
qglengine/plugin/qglviewplugin.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef QGLVIEWPLUGIN_H
|
||||
#define QGLVIEWPLUGIN_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtUiPlugin/QDesignerCustomWidgetInterface>
|
||||
|
||||
|
||||
class QGLViewPlugin: public QObject, public QDesignerCustomWidgetInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QDesignerCustomWidgetInterface)
|
||||
|
||||
public:
|
||||
explicit QGLViewPlugin(QObject * parent = 0);
|
||||
|
||||
bool isContainer() const;
|
||||
bool isInitialized() const;
|
||||
QIcon icon() const;
|
||||
QString domXml() const;
|
||||
QString group() const;
|
||||
QString includeFile() const;
|
||||
QString name() const;
|
||||
QString toolTip() const;
|
||||
QString whatsThis() const;
|
||||
QWidget * createWidget(QWidget * parent);
|
||||
void initialize(QDesignerFormEditorInterface * core);
|
||||
|
||||
private:
|
||||
bool m_initialized;
|
||||
|
||||
};
|
||||
|
||||
#endif //QGLVIEWPLUGIN_H
|
||||
Reference in New Issue
Block a user