-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
398 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
julia 0.4 | ||
BinDeps | ||
CxxWrap 0.1.4 | ||
CxxWrap 0.1.6+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include <functions.hpp> | ||
|
||
#include "glvisualize_viewport.hpp" | ||
#include "julia_api.hpp" | ||
|
||
#include <QOpenGLContext> | ||
#include <QQuickWindow> | ||
|
||
namespace qmlwrap | ||
{ | ||
|
||
GLVisualizeViewport::GLVisualizeViewport(QQuickItem *parent) : OpenGLViewport(parent) | ||
{ | ||
QObject::connect(this, &QQuickItem::windowChanged, [this] (QQuickWindow* w) | ||
{ | ||
if(w == nullptr && m_state != nullptr) | ||
{ | ||
cxx_wrap::julia_call(cxx_wrap::julia_function("on_window_close", "QML"), m_state); | ||
} | ||
|
||
if(w == nullptr) | ||
{ | ||
return; | ||
} | ||
|
||
connect(w, &QQuickWindow::openglContextCreated, [this] (QOpenGLContext* context) | ||
{ | ||
connect(context, &QOpenGLContext::aboutToBeDestroyed, [] () | ||
{ | ||
jl_function_t* on_context_destroy = cxx_wrap::julia_function("on_context_destroy", "QML"); | ||
cxx_wrap::julia_call(on_context_destroy); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
GLVisualizeViewport::~GLVisualizeViewport() | ||
{ | ||
if(m_state != nullptr) | ||
{ | ||
cxx_wrap::unprotect_from_gc(m_state); | ||
} | ||
} | ||
|
||
void GLVisualizeViewport::componentComplete() | ||
{ | ||
OpenGLViewport::componentComplete(); | ||
jl_function_t* sigs_ctor = cxx_wrap::julia_function("initialize_signals", "QML"); | ||
assert(sigs_ctor != nullptr); | ||
m_state = cxx_wrap::julia_call(sigs_ctor); | ||
cxx_wrap::protect_from_gc(m_state); | ||
assert(m_state != nullptr); | ||
|
||
auto win_size_changed = [this] () { cxx_wrap::julia_call(cxx_wrap::julia_function("on_window_size_change", "QML"), m_state, width(), height()); }; | ||
QObject::connect(this, &QQuickItem::widthChanged, win_size_changed); | ||
QObject::connect(this, &QQuickItem::heightChanged, win_size_changed); | ||
} | ||
|
||
void GLVisualizeViewport::setup_buffer(GLuint handle, int width, int height) | ||
{ | ||
cxx_wrap::julia_call(cxx_wrap::julia_function("on_framebuffer_setup", "QML"), m_state, handle, static_cast<int64_t>(width), static_cast<int64_t>(height)); | ||
} | ||
|
||
void GLVisualizeViewport::post_render() | ||
{ | ||
cxx_wrap::julia_call(cxx_wrap::julia_function("render_glvisualize_scene", "QML"), m_state); | ||
} | ||
|
||
} // namespace qmlwrap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef QML_glvisualize_viewport_H | ||
#define QML_glvisualize_viewport_H | ||
|
||
#include <cxx_wrap.hpp> | ||
|
||
#include "opengl_viewport.hpp" | ||
|
||
namespace qmlwrap | ||
{ | ||
|
||
/// Multimedia display for Julia | ||
class GLVisualizeViewport : public OpenGLViewport | ||
{ | ||
Q_OBJECT | ||
public: | ||
GLVisualizeViewport(QQuickItem* parent = 0); | ||
virtual ~GLVisualizeViewport(); | ||
virtual void componentComplete(); | ||
|
||
private: | ||
// Julia type holding the signals and other state needed for GLVisualize. Manipulated from within Julia callbacks | ||
jl_value_t* m_state = nullptr; | ||
virtual void setup_buffer(GLuint handle, int width, int height); | ||
virtual void post_render(); | ||
}; | ||
|
||
} // namespace qmlwrap | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
using QML | ||
|
||
@qmlfunction println | ||
@qmlapp joinpath(dirname(@__FILE__), "qml", "drag.qml") | ||
exec() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import QtQuick 2.0 | ||
import QtQuick.Controls 1.0 | ||
import QtQuick.Layouts 1.0 | ||
import org.julialang 1.0 | ||
|
||
ApplicationWindow { | ||
title: "My Application" | ||
width: 800 | ||
height: 600 | ||
visible: true | ||
|
||
Rectangle { | ||
id: container | ||
width: 800; height: 600 | ||
|
||
SystemPalette { id: pal; colorGroup: SystemPalette.Active } | ||
|
||
Canvas { | ||
id: paths | ||
anchors.fill: parent | ||
contextType: "2d" | ||
|
||
Path { | ||
id: myPath | ||
startX: 0; startY: 100 | ||
|
||
PathCurve { x: 75; y: 75 } | ||
PathCurve { x: 200; y: 150 } | ||
PathCurve { x: 325; y: 25 } | ||
PathCurve { x: rect.x; y: rect.y } | ||
} | ||
|
||
onPaint: { | ||
context.fillStyle = pal.window; | ||
context.fillRect(0, 0, width, height); | ||
context.strokeStyle = Qt.rgba(.4,.6,.8); | ||
context.path = myPath; | ||
context.stroke(); | ||
} | ||
} | ||
|
||
Rectangle { | ||
id: rect | ||
width: 50; height: 50 | ||
color: "red" | ||
|
||
onXChanged: paths.requestPaint() | ||
|
||
MouseArea { | ||
anchors.fill: parent | ||
drag.target: rect | ||
} | ||
|
||
Rectangle { | ||
id: conn | ||
y: 10 | ||
width: 10; height: 5 | ||
color: "yellow" | ||
|
||
MouseArea { | ||
anchors.fill: parent | ||
onClicked: console.log(rect.x, ", ", rect.y) | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.