diff --git a/graphics/icons.png b/graphics/icons.png new file mode 100644 index 0000000..77dbd89 Binary files /dev/null and b/graphics/icons.png differ diff --git a/graphics/icons.svg b/graphics/icons.svg new file mode 100644 index 0000000..d57fe81 --- /dev/null +++ b/graphics/icons.svg @@ -0,0 +1,99 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/data/images/logo.svg b/graphics/logo.svg similarity index 100% rename from data/images/logo.svg rename to graphics/logo.svg diff --git a/src/interface/modeler/quickapp/MainModelerWindow.cpp b/src/interface/modeler/quickapp/MainModelerWindow.cpp new file mode 100644 index 0000000..f8cca47 --- /dev/null +++ b/src/interface/modeler/quickapp/MainModelerWindow.cpp @@ -0,0 +1,24 @@ +#include "MainModelerWindow.h" + +#include "OpenGLView.h" +#include "Scenery.h" +#include "OpenGLRenderer.h" + +MainModelerWindow::MainModelerWindow() +{ + scenery = new Scenery(); + scenery->autoPreset(); + renderer = new OpenGLRenderer(scenery); + + qmlRegisterType("Paysages", 1, 0, "OpenGLView"); + + setTitle(QObject::tr("Paysages 3D")); + setResizeMode(QQuickView::SizeRootObjectToView); + setSource(QUrl("qrc:///main.qml")); +} + +MainModelerWindow::~MainModelerWindow() +{ + delete renderer; + delete scenery; +} diff --git a/src/interface/modeler/quickapp/MainModelerWindow.h b/src/interface/modeler/quickapp/MainModelerWindow.h new file mode 100644 index 0000000..f599381 --- /dev/null +++ b/src/interface/modeler/quickapp/MainModelerWindow.h @@ -0,0 +1,28 @@ +#ifndef MAINMODELERWINDOW_H +#define MAINMODELERWINDOW_H + +#include "modeler_global.h" + +#include + +namespace paysages { +namespace modeler { + +class MainModelerWindow: public QQuickView +{ + Q_OBJECT +public: + MainModelerWindow(); + virtual ~MainModelerWindow(); + + inline OpenGLRenderer *getRenderer() const {return renderer;} + +private: + OpenGLRenderer *renderer; + Scenery *scenery; +}; + +} +} + +#endif // MAINMODELERWINDOW_H diff --git a/src/interface/modeler/quickapp/OpenGLView.cpp b/src/interface/modeler/quickapp/OpenGLView.cpp index a9953df..23f0211 100644 --- a/src/interface/modeler/quickapp/OpenGLView.cpp +++ b/src/interface/modeler/quickapp/OpenGLView.cpp @@ -2,27 +2,22 @@ #include #include - -// TEMP +#include "MainModelerWindow.h" +#include "CameraDefinition.h" #include "OpenGLRenderer.h" #include "Scenery.h" -#include "CameraDefinition.h" -static OpenGLRenderer renderer; -static Scenery scenery; OpenGLView::OpenGLView(QQuickItem *parent) : QQuickItem(parent) { initialized = false; window = NULL; + renderer = NULL; setAcceptedMouseButtons(Qt::AllButtons); setAcceptHoverEvents(true); setKeepMouseGrab(true); - scenery.autoPreset(); - renderer.setScenery(&scenery); - connect(this, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(handleWindowChanged(QQuickWindow*))); startTimer(250); } @@ -31,13 +26,17 @@ void OpenGLView::handleWindowChanged(QQuickWindow *win) { if (win) { - window = win; + window = qobject_cast(win); + if (window) + { + renderer = window->getRenderer(); - connect(window, SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection); + connect(win, SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection); - win->setClearBeforeRendering(false); + win->setClearBeforeRendering(false); - initialized = false; + initialized = false; + } } } @@ -45,13 +44,13 @@ void OpenGLView::paint() { if (not initialized) { - renderer.initialize(); + renderer->initialize(); initialized = true; } - renderer.resize(width(), height()); - renderer.prepareOpenGLState(); - renderer.paint(); + renderer->resize(width(), height()); + renderer->prepareOpenGLState(); + renderer->paint(); if (window) { @@ -61,18 +60,23 @@ void OpenGLView::paint() void OpenGLView::hoverMoveEvent(QHoverEvent *event) { + if (!renderer) + { + return; + } + CameraDefinition camera; - renderer.getScenery()->getCamera(&camera); + renderer->getScenery()->getCamera(&camera); QPointF diff = event->posF() - event->oldPosF(); camera.strafeRight(diff.x() * 0.1); camera.strafeUp(diff.y() * 0.1); camera.validate(); - camera.copy(renderer.render_camera); - renderer.getScenery()->setCamera(&camera); - renderer.getScenery()->getCamera(&camera); - renderer.cameraChangeEvent(&camera); + camera.copy(renderer->render_camera); + renderer->getScenery()->setCamera(&camera); + renderer->getScenery()->getCamera(&camera); + renderer->cameraChangeEvent(&camera); if (window) { window->update(); diff --git a/src/interface/modeler/quickapp/OpenGLView.h b/src/interface/modeler/quickapp/OpenGLView.h index 5675818..e59c379 100644 --- a/src/interface/modeler/quickapp/OpenGLView.h +++ b/src/interface/modeler/quickapp/OpenGLView.h @@ -24,7 +24,8 @@ protected: private: bool initialized; - QQuickWindow *window; + MainModelerWindow *window; + OpenGLRenderer *renderer; }; } diff --git a/src/interface/modeler/quickapp/main.cpp b/src/interface/modeler/quickapp/main.cpp index ad89df8..3d9237a 100644 --- a/src/interface/modeler/quickapp/main.cpp +++ b/src/interface/modeler/quickapp/main.cpp @@ -1,19 +1,12 @@ #include -#include -#include -#include "OpenGLView.h" +#include "MainModelerWindow.h" int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - qmlRegisterType("Paysages", 1, 0, "OpenGLView"); - - QQuickView view; - view.setTitle(QObject::tr("Paysages 3D")); - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl("qrc:///main.qml")); + MainModelerWindow view; view.show(); return app.exec(); diff --git a/src/interface/modeler/quickapp/modeler_global.h b/src/interface/modeler/quickapp/modeler_global.h index 39ab8cb..f8088b8 100644 --- a/src/interface/modeler/quickapp/modeler_global.h +++ b/src/interface/modeler/quickapp/modeler_global.h @@ -7,7 +7,8 @@ namespace paysages { namespace modeler { - class ItemOpenGLView; + class MainModelerWindow; + class OpenGLView; } } diff --git a/src/interface/modeler/quickapp/qml/BasePanel.qml b/src/interface/modeler/quickapp/qml/BasePanel.qml new file mode 100644 index 0000000..82872d6 --- /dev/null +++ b/src/interface/modeler/quickapp/qml/BasePanel.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +Rectangle { + property ToolbarButton tool + id: panel + + width: 200 + height: parent.height - 100 + color: "red" + enabled: visible + + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + + states: [ + State { + name: "Active" + when: tool.selected + + PropertyChanges { + target: panel + visible: true + } + } + + ] +} diff --git a/src/interface/modeler/quickapp/qml/PanelWaterLevel.qml b/src/interface/modeler/quickapp/qml/PanelWaterLevel.qml new file mode 100644 index 0000000..e84bd6e --- /dev/null +++ b/src/interface/modeler/quickapp/qml/PanelWaterLevel.qml @@ -0,0 +1,11 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.2 + +BasePanel { + width: 20 + + Slider { + orientation: Qt.Vertical + anchors.fill: parent + } +} diff --git a/src/interface/modeler/quickapp/qml/Toolbar.qml b/src/interface/modeler/quickapp/qml/Toolbar.qml index 46838d6..b8a1424 100644 --- a/src/interface/modeler/quickapp/qml/Toolbar.qml +++ b/src/interface/modeler/quickapp/qml/Toolbar.qml @@ -5,7 +5,8 @@ Rectangle { default property alias children : inner_space.children width: 70 height: parent.height - color: "#50000000" + color: "#50888888" + enabled: opacity > 0 Column { id: inner_space diff --git a/src/interface/modeler/quickapp/qml/ToolbarButton.qml b/src/interface/modeler/quickapp/qml/ToolbarButton.qml index 23c8edb..727c408 100644 --- a/src/interface/modeler/quickapp/qml/ToolbarButton.qml +++ b/src/interface/modeler/quickapp/qml/ToolbarButton.qml @@ -1,4 +1,5 @@ import QtQuick 2.0 +import QtGraphicalEffects 1.0 Item { property string picture @@ -13,7 +14,7 @@ Item { Rectangle { id: glow anchors.fill: parent - color: "white" + color: "#cccccc" radius: 8 opacity: parent.selected ? 1.0 : (parent.hovered ? 0.5 : 0.0) @@ -22,6 +23,13 @@ Item { duration: 200 } } + RectangularGlow { + anchors.fill: glow + glowRadius: 8 + spread: 0.2 + color: "white" + cornerRadius: glow.radius + glowRadius + } } Image { @@ -30,6 +38,16 @@ Item { anchors.centerIn: parent width: 32 height: 32 + antialiasing: true + } + DropShadow { + anchors.fill: image + horizontalOffset: 2 + verticalOffset: 2 + radius: 4.0 + samples: 16 + color: "#80000000" + source: image } MouseArea { diff --git a/src/interface/modeler/quickapp/qml/app.qrc b/src/interface/modeler/quickapp/qml/app.qrc index aa09ee8..a216b39 100644 --- a/src/interface/modeler/quickapp/qml/app.qrc +++ b/src/interface/modeler/quickapp/qml/app.qrc @@ -13,5 +13,9 @@ images/display_topdown.png images/help.png Tooltip.qml + images/icon_water.png + images/icon_water_level.png + BasePanel.qml + PanelWaterLevel.qml diff --git a/src/interface/modeler/quickapp/qml/images/icon_water.png b/src/interface/modeler/quickapp/qml/images/icon_water.png new file mode 100644 index 0000000..b87e23c Binary files /dev/null and b/src/interface/modeler/quickapp/qml/images/icon_water.png differ diff --git a/src/interface/modeler/quickapp/qml/images/icon_water_level.png b/src/interface/modeler/quickapp/qml/images/icon_water_level.png new file mode 100644 index 0000000..0fab5ea Binary files /dev/null and b/src/interface/modeler/quickapp/qml/images/icon_water_level.png differ diff --git a/src/interface/modeler/quickapp/qml/main.qml b/src/interface/modeler/quickapp/qml/main.qml index ceee3b9..66dc103 100644 --- a/src/interface/modeler/quickapp/qml/main.qml +++ b/src/interface/modeler/quickapp/qml/main.qml @@ -17,7 +17,7 @@ OpenGLView { Toolbar { id: primary_toolbar - color: "#90000000" + color: "#90888888" anchors.left: parent.left @@ -36,7 +36,8 @@ OpenGLView { } ToolbarButton { id: tool_water - picture: "images/tab_water.png" + picture: "images/icon_water.png" + hovertext: "Water tools" } ToolbarButton { id: tool_atmosphere @@ -65,6 +66,24 @@ OpenGLView { } } + Toolbar { + id: water_toolbar + opacity: 0 + anchors.left: primary_toolbar.right + + ToolbarButton { + id: tool_water_level + picture: "images/icon_water_level.png" + hovertext: qsTr("Change the water altitude") + } + } + + PanelWaterLevel { + id: panel_water_level + visible: false + tool: tool_water_level + } + states: [ State { name: "Display Mode" @@ -74,6 +93,15 @@ OpenGLView { target: display_toolbar opacity: 1 } + }, + State { + name: "Water Mode" + when: tool_water.selected + + PropertyChanges { + target: water_toolbar + opacity: 1 + } } ] diff --git a/src/interface/modeler/quickapp/quickapp.pro b/src/interface/modeler/quickapp/quickapp.pro index 0416b57..ec7c6dc 100644 --- a/src/interface/modeler/quickapp/quickapp.pro +++ b/src/interface/modeler/quickapp/quickapp.pro @@ -5,7 +5,8 @@ QT += qml quick widgets include(../../../common.pri) SOURCES += main.cpp \ - OpenGLView.cpp + OpenGLView.cpp \ + MainModelerWindow.cpp RESOURCES += \ qml/app.qrc @@ -20,7 +21,8 @@ include(deployment.pri) HEADERS += \ OpenGLView.h \ - modeler_global.h + modeler_global.h \ + MainModelerWindow.h win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../../system/release/ -lpaysages_system else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../../system/debug/ -lpaysages_system @@ -57,4 +59,6 @@ OTHER_FILES += \ qml/ToolbarButton.qml \ qml/OpenGLView.qml \ qml/Toolbar.qml \ - qml/Tooltip.qml + qml/Tooltip.qml \ + qml/BasePanel.qml \ + qml/PanelWaterLevel.qml