summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Korpipää <tomi.korpipaa@digia.com>2013-06-06 13:31:29 +0300
committerTomi Korpipää <tomi.korpipaa@digia.com>2013-06-06 13:31:56 +0300
commitb61b63ff5e3b4ba7c4f4174c16b33bedadbfcfb8 (patch)
treedb038c1e76588e7b00a588019cad7af9bd17b06d
parentf412e68d45fb3f629d793988d5350ad458809bc0 (diff)
QML2 Q3DBars hardcoded h4x0r version implemented
You can enable QML2 version of engine by uncommenting Change-Id: Ia12fcf9d503d648cc9792a4932e5f8b3488a743c Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
-rw-r--r--examples/qmlbarchart/main.cpp3
-rw-r--r--examples/qmlbarchart/qml/qmlbarchart/main.qml76
-rw-r--r--src/datavis3d/engine/q3dbars.cpp30
-rw-r--r--src/datavis3d/engine/q3dwindow.cpp5
-rw-r--r--src/datavis3d/global/qdatavis3dglobal.h3
-rw-r--r--src/datavis3dqml2/datavisview.cpp44
-rw-r--r--src/datavis3dqml2/scenerenderernode.cpp17
7 files changed, 91 insertions, 87 deletions
diff --git a/examples/qmlbarchart/main.cpp b/examples/qmlbarchart/main.cpp
index 79891676..37fd461e 100644
--- a/examples/qmlbarchart/main.cpp
+++ b/examples/qmlbarchart/main.cpp
@@ -35,7 +35,8 @@ int main(int argc, char *argv[])
QString::fromLatin1("qml")));
#endif
viewer.setMainQmlFile(QStringLiteral("qml/qmlbarchart/main.qml"));
- viewer.showExpanded();
+ viewer.setResizeMode(QQuickView::SizeRootObjectToView);
+ viewer.show();
return app.exec();
}
diff --git a/examples/qmlbarchart/qml/qmlbarchart/main.qml b/examples/qmlbarchart/qml/qmlbarchart/main.qml
index 62ac58d1..f36aece6 100644
--- a/examples/qmlbarchart/qml/qmlbarchart/main.qml
+++ b/examples/qmlbarchart/qml/qmlbarchart/main.qml
@@ -24,12 +24,14 @@ import com.digia.QtDataVis3D 1.0
Item {
id: container
- anchors.fill: parent
+ //anchors.fill: parent
+ width: 800
+ height: 500
DataVisView {
id: mainview
- width: 360
- height: 360
+ anchors.fill: parent
+ antialiasing: true
DataItem {
id: testitem
@@ -48,49 +50,49 @@ Item {
testrow.addItem(testitem2);
}
}
- Bars {
- id: testchart
- visible: true
- width: mainview.width
- height: mainview.height
- //x: mainview.x + mainview.width
- //y: mainview.y
+// Bars {
+// id: testchart
+// visible: true
+// width: mainview.width
+// height: mainview.height
+// //x: mainview.x + mainview.width
+// //y: mainview.y
- grid: false
- shadowQuality: Bars.ShadowNone
- selectionMode: Bars.ModeNone
- labelTransparency: Bars.TransparencyNone
- windowTitle: "QmlTest3DBars"
+// grid: false
+// shadowQuality: Bars.ShadowNone
+// selectionMode: Bars.ModeNone
+// labelTransparency: Bars.TransparencyNone
+// windowTitle: "QmlTest3DBars"
- function setUpBars() {
- /*console.log(parent)
- console.log(container.x)
- console.log(container.y)
- console.log(Window.x)
- console.log(Window.y)
- console.log(Screen.desktopAvailableHeight)
- console.log(Screen.desktopAvailableWidth)
- console.log(mainview.x)
- console.log(mainview.y)
- console.log(x)
- console.log(y)*/
- testchart.setupSampleSpace(2, 1);
- testchart.addDataRow(testrow);
- }
- }
+// function setUpBars() {
+// /*console.log(parent)
+// console.log(container.x)
+// console.log(container.y)
+// console.log(Window.x)
+// console.log(Window.y)
+// console.log(Screen.desktopAvailableHeight)
+// console.log(Screen.desktopAvailableWidth)
+// console.log(mainview.x)
+// console.log(mainview.y)
+// console.log(x)
+// console.log(y)*/
+// testchart.setupSampleSpace(2, 1);
+// testchart.addDataRow(testrow);
+// }
+// }
MouseArea {
anchors.fill: parent
onClicked: {
- testchart.destroy();
- testchart.close();
+// testchart.destroy();
+// testchart.close();
Qt.quit();
}
}
- Component.onCompleted: {
- testrow.addData();
- testchart.setUpBars();
- }
+// Component.onCompleted: {
+// testrow.addData();
+// testchart.setUpBars();
+// }
}
}
diff --git a/src/datavis3d/engine/q3dbars.cpp b/src/datavis3d/engine/q3dbars.cpp
index 61cdb361..7ccab074 100644
--- a/src/datavis3d/engine/q3dbars.cpp
+++ b/src/datavis3d/engine/q3dbars.cpp
@@ -179,7 +179,11 @@ void Q3DBars::initialize()
QVector3D(0.0f, 1.0f, 0.0f));
// Set view port
+#ifdef USE_QML2_VERSION
+ glViewport(0, 0, 800, 500);
+#else
glViewport(0, 0, width(), height());
+#endif
// Set initialized -flag
d_ptr->m_isInitialized = true;
@@ -187,6 +191,14 @@ void Q3DBars::initialize()
void Q3DBars::render()
{
+#ifdef USE_QML2_VERSION
+ glDepthMask(true);
+ glEnable(GL_DEPTH_TEST);
+ glDepthFunc(GL_LESS);
+ glEnable(GL_CULL_FACE);
+ glCullFace(GL_BACK);
+#endif
+
if (!d_ptr->m_isInitialized)
return;
@@ -269,7 +281,6 @@ void Q3DBars::drawZoomScene()
QVector3D(0.0f, 0.0f, zComp),
QVector3D(0.0f, 1.0f, 0.0f));
-
// Set light position a bit below the camera to reduce glare (depends on do we have row or column zoom)
QVector3D zoomLightPos = defaultLightPos;
zoomLightPos.setY(-10.0f);
@@ -450,6 +461,10 @@ void Q3DBars::drawScene()
static QVector3D selection = skipColor;
+#ifdef USE_QML2_VERSION
+ d_ptr->m_sceneViewPort = QRect(0, 0, 800, 500);
+#endif
+
// Specify viewport
glViewport(d_ptr->m_sceneViewPort.x(), d_ptr->m_sceneViewPort.y(),
d_ptr->m_sceneViewPort.width(), d_ptr->m_sceneViewPort.height());
@@ -460,6 +475,14 @@ void Q3DBars::drawScene()
/ (GLfloat)d_ptr->m_sceneViewPort.height(), 0.1f, 100.0f);
// Calculate view matrix
+#ifdef USE_QML2_VERSION
+ static int rot = 0;
+ rot += 5;
+ if (rot > 2870)
+ rot = 0;
+ d_ptr->m_mousePos.setX(rot);
+ d_ptr->m_mousePos.setY(100);
+#endif
QMatrix4x4 viewMatrix = CameraHelper::calculateViewMatrix(d_ptr->m_mousePos,
d_ptr->m_zoomLevel
* d_ptr->m_zoomAdjustment,
@@ -973,7 +996,6 @@ void Q3DBars::drawScene()
#endif
depthMVPMatrix = depthProjectionMatrix * depthViewMatrix * modelMatrix;
-
QVector3D backgroundColor = Utils::vectorFromColor(d_ptr->m_theme->m_backgroundColor);
// Set shader bindings
@@ -2104,7 +2126,11 @@ Q3DBarsPrivate::Q3DBarsPrivate(Q3DBars *q)
m_axisLabelX(QStringLiteral("X")),
m_axisLabelZ(QStringLiteral("Z")),
m_axisLabelY(QStringLiteral("Y")),
+ #ifdef USE_QML2_VERSION
+ m_sceneViewPort(0, 0, 800, 500),
+ #else
m_sceneViewPort(0, 0, q->width(), q->height()),
+ #endif
m_zoomViewPort(0, 0, q->width(), q->height()),
m_zoomActivated(false),
m_textureHelper(new TextureHelper()),
diff --git a/src/datavis3d/engine/q3dwindow.cpp b/src/datavis3d/engine/q3dwindow.cpp
index 359947c8..869dc328 100644
--- a/src/datavis3d/engine/q3dwindow.cpp
+++ b/src/datavis3d/engine/q3dwindow.cpp
@@ -70,12 +70,17 @@ Q3DWindow::Q3DWindow(QWindow *parent)
create();
+#ifndef USE_QML2_VERSION
d_ptr->m_context->setFormat(requestedFormat());
d_ptr->m_context->create();
d_ptr->m_context->makeCurrent(this);
+#endif
+
initializeOpenGLFunctions();
+#ifndef USE_QML2_VERSION
initialize();
+#endif
}
Q3DWindow::~Q3DWindow()
diff --git a/src/datavis3d/global/qdatavis3dglobal.h b/src/datavis3d/global/qdatavis3dglobal.h
index 7e135937..c57d5101 100644
--- a/src/datavis3d/global/qdatavis3dglobal.h
+++ b/src/datavis3d/global/qdatavis3dglobal.h
@@ -25,6 +25,9 @@
//#define ROTATE_ZOOM_SELECTION
+// Uncomment this if you want to try hardcoded QML2 -integration h4x0r version of the engine
+//#define USE_QML2_VERSION
+
#define QTENTERPRISE_DATAVIS3D_VERSION_STR "0.0.1"
/*
QTENTERPRISE_DATAVIS3D_VERSION is (major << 16) + (minor << 8) + patch.
diff --git a/src/datavis3dqml2/datavisview.cpp b/src/datavis3dqml2/datavisview.cpp
index b828b539..bc7da610 100644
--- a/src/datavis3dqml2/datavisview.cpp
+++ b/src/datavis3dqml2/datavisview.cpp
@@ -39,26 +39,15 @@
**
****************************************************************************/
-//#define TEST1
-//#define TEST2
+#define TEST1
#include "datavisview.h"
#include "scenerenderernode_p.h"
#include <QDebug>
-#ifdef TEST1
-#include "q3dbars.h"
-#include <QtQuick/QQuickWindow>
-#endif
-
QTENTERPRISE_DATAVIS3D_BEGIN_NAMESPACE
-#ifdef TEST1
-Q3DBars *test_scene;
-QQuickWindow *test_window;
-#endif
-
DataVisView::DataVisView(QQuickItem *parent):
QQuickItem(parent)
{
@@ -67,6 +56,9 @@ DataVisView::DataVisView(QQuickItem *parent):
// following line and re-implement updatePaintNode()
setFlag(ItemHasContents, true);
+ setRotation(180.0);
+ setAntialiasing(true);
+ setSmooth(true);
}
DataVisView::~DataVisView()
@@ -76,34 +68,6 @@ DataVisView::~DataVisView()
QSGNode *DataVisView::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
{
#ifdef TEST1
- static bool done = false;
- if (!done) {
- qDebug() << "create scene";
- test_scene = new Q3DBars();
- //test_scene->initialize();
-
- // TODO: For testing. Add some data to scene.
- QVector< QVector<float> > data;
- QVector<float> row;
- for (int j = 0; j < 2; j++) {
- for (int i = 0; i < 2; i++)
- row.append(1.0f);
- data.append(row);
- row.clear();
- }
- // Set up sample space based on inserted data
- test_scene->setupSampleSpace(2, 2);
- // Add data to chart
- test_scene->addDataSet(data);
-
- test_window = window();
- QObject::connect(test_window, &QQuickWindow::beforeRendering,
- test_scene, &Q3DBars::renderNow,
- Qt::DirectConnection);
- test_window->update();
- done = true;
- }
-#elif TEST2
// Delete old node and recreate it. This function gets called when window geometry changes.
if (oldNode)
delete oldNode;
diff --git a/src/datavis3dqml2/scenerenderernode.cpp b/src/datavis3dqml2/scenerenderernode.cpp
index 00f03e5e..778cedbe 100644
--- a/src/datavis3dqml2/scenerenderernode.cpp
+++ b/src/datavis3dqml2/scenerenderernode.cpp
@@ -66,8 +66,6 @@ SceneRendererNode::~SceneRendererNode()
void SceneRendererNode::render()
{
- //qDebug("render");
-
QSize size = rect().size().toSize();
if (!m_fbo) {
@@ -80,20 +78,25 @@ void SceneRendererNode::render()
// DataVisView can then give it here as an argument in constructor?
m_scene = new Q3DBars();
+ m_scene->setSelectionMode(ModeNone);
+ m_scene->setShadowQuality(ShadowNone);
+ m_scene->setTheme(ThemeSystem);
+ m_scene->initialize();
// TODO: For testing. Add some data to scene.
QVector< QVector<float> > data;
QVector<float> row;
- for (int j = 0; j < 2; j++) {
- for (int i = 0; i < 2; i++)
- row.append(1.0f);
+ for (float j = 0.0f; j < 5.0f; j++) {
+ for (float i = 0.0f; i < 5.0f; i++)
+ row.append(j / 10.0f + i / 10.0f);
data.append(row);
row.clear();
}
// Set up sample space based on inserted data
- m_scene->setupSampleSpace(2, 2);
+ m_scene->setupSampleSpace(5, 5);
// Add data to chart
m_scene->addDataSet(data);
+ m_scene->setBarType(Cones);
//m_scene = new Q3DMaps();
setTexture(m_texture);
@@ -102,7 +105,7 @@ void SceneRendererNode::render()
m_fbo->bind();
// TODO: Render here, or "capture" the rendering we do at Q3DBars/Q3DMaps
- m_scene->renderNow();
+ m_scene->render();
m_fbo->bindDefault();