|
@@ -78,24 +78,30 @@ ApplicationWindow {
|
|
|
property color strokeStyle: Qt.darker(fillStyle, 1.2)
|
|
property color strokeStyle: Qt.darker(fillStyle, 1.2)
|
|
|
property color fillStyle: "#6400aa"
|
|
property color fillStyle: "#6400aa"
|
|
|
property string curColor: "#ff0000"
|
|
property string curColor: "#ff0000"
|
|
|
|
|
+ property int count: 0
|
|
|
|
|
|
|
|
property real px: width / 2
|
|
property real px: width / 2
|
|
|
property real py: height / 2 + 10
|
|
property real py: height / 2 + 10
|
|
|
property real alpha: 1.0
|
|
property real alpha: 1.0
|
|
|
property variant points_array: []
|
|
property variant points_array: []
|
|
|
property string curImageUrl: "https://plataforma.especificosba.com.ar/diapo/EBA/1.png"
|
|
property string curImageUrl: "https://plataforma.especificosba.com.ar/diapo/EBA/1.png"
|
|
|
|
|
+ property var ctx: canvas.getContext("2d")
|
|
|
width: parent.width
|
|
width: parent.width
|
|
|
height: parent.height
|
|
height: parent.height
|
|
|
|
|
|
|
|
onPaint: paint_canvas()
|
|
onPaint: paint_canvas()
|
|
|
onImageLoaded: {
|
|
onImageLoaded: {
|
|
|
clean_path()
|
|
clean_path()
|
|
|
|
|
+ ctx.lineCap = 'square'
|
|
|
|
|
+ ctx.lineWidth = 4
|
|
|
|
|
+ ctx.strokeStyle = "#000000"
|
|
|
requestPaint()
|
|
requestPaint()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function clean_path() {
|
|
function clean_path() {
|
|
|
points_array = []
|
|
points_array = []
|
|
|
requestPaint()
|
|
requestPaint()
|
|
|
|
|
+ canvas.count = 0
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function start_path() {
|
|
function start_path() {
|
|
@@ -109,8 +115,9 @@ ApplicationWindow {
|
|
|
points_array[points_array.length - 1].points = Simplify.simplify(
|
|
points_array[points_array.length - 1].points = Simplify.simplify(
|
|
|
points_array[points_array.length - 1].points,
|
|
points_array[points_array.length - 1].points,
|
|
|
2.2)
|
|
2.2)
|
|
|
- requestPaint()
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //requestPaint()
|
|
|
|
|
+ if (points_array[points_array.length - 1].points.length <=1)
|
|
|
|
|
+ return;
|
|
|
//normalized to 800x600
|
|
//normalized to 800x600
|
|
|
var ar = points_array[points_array.length - 1].points.map(
|
|
var ar = points_array[points_array.length - 1].points.map(
|
|
|
function (el) {
|
|
function (el) {
|
|
@@ -121,10 +128,13 @@ ApplicationWindow {
|
|
|
el.y * 600 / canvas.height)
|
|
el.y * 600 / canvas.height)
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
- while (ar.length > 30) {
|
|
|
|
|
- socket.send_drawing(ar.splice(0, 29))
|
|
|
|
|
|
|
+
|
|
|
|
|
+ console.log(ar.length);
|
|
|
|
|
+ var MAX_ELEMS=65;
|
|
|
|
|
+ while (ar.length > MAX_ELEMS) {
|
|
|
|
|
+ socket.send_drawing(ar.splice(0, MAX_ELEMS-1));
|
|
|
}
|
|
}
|
|
|
- socket.send_drawing(ar)
|
|
|
|
|
|
|
+ socket.send_drawing(ar);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function change_image(pdf, number) {
|
|
function change_image(pdf, number) {
|
|
@@ -136,41 +146,41 @@ ApplicationWindow {
|
|
|
function add_point(p) {
|
|
function add_point(p) {
|
|
|
var pts = points_array[points_array.length - 1].points
|
|
var pts = points_array[points_array.length - 1].points
|
|
|
pts.push(p)
|
|
pts.push(p)
|
|
|
- if (pts.length > 60) {
|
|
|
|
|
|
|
+ if (pts.length > 80) {
|
|
|
//FIXME
|
|
//FIXME
|
|
|
finish_path()
|
|
finish_path()
|
|
|
start_path()
|
|
start_path()
|
|
|
pts.push(p)
|
|
pts.push(p)
|
|
|
- } else {
|
|
|
|
|
- requestPaint()
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ requestPaint()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ function stroke(points, color) {
|
|
|
|
|
+ ctx.strokeStyle = color;
|
|
|
|
|
+ ctx.beginPath()
|
|
|
|
|
+ ctx.moveTo(points[0].x, points[0].y)
|
|
|
|
|
+ var i = 0;
|
|
|
|
|
+ for (i = 0; i < points.length - 1; i++) {
|
|
|
|
|
+ ctx.moveTo(points[i].x, points[i].y)
|
|
|
|
|
+ ctx.lineTo(points[i + 1].x, points[i + 1].y)
|
|
|
|
|
+ }
|
|
|
|
|
+ ctx.stroke()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function paint_canvas() {
|
|
function paint_canvas() {
|
|
|
- var ctx = canvas.getContext("2d")
|
|
|
|
|
canvas.loadImage(curImageUrl)
|
|
canvas.loadImage(curImageUrl)
|
|
|
if (canvas.isImageLoaded(curImageUrl)) {
|
|
if (canvas.isImageLoaded(curImageUrl)) {
|
|
|
ctx.drawImage(curImageUrl, 0, 0, canvas.width,
|
|
ctx.drawImage(curImageUrl, 0, 0, canvas.width,
|
|
|
canvas.height)
|
|
canvas.height)
|
|
|
}
|
|
}
|
|
|
- ctx.lineCap = 'square'
|
|
|
|
|
- ctx.lineWidth = 4
|
|
|
|
|
- ctx.strokeStyle = "#000000"
|
|
|
|
|
-
|
|
|
|
|
- var i = 0, j = 0
|
|
|
|
|
|
|
+ var j = 0
|
|
|
for (j = 0; j < points_array.length; j++) {
|
|
for (j = 0; j < points_array.length; j++) {
|
|
|
- var points = points_array[j].points
|
|
|
|
|
-
|
|
|
|
|
- if (points.length === 0)
|
|
|
|
|
|
|
+ if (points_array[j].points.length <= 1)
|
|
|
continue
|
|
continue
|
|
|
- ctx.strokeStyle = points_array[j].color
|
|
|
|
|
- ctx.beginPath()
|
|
|
|
|
- ctx.moveTo(points[0].x, points[0].y)
|
|
|
|
|
- for (i = 0; i < points.length - 1; i++) {
|
|
|
|
|
- ctx.moveTo(points[i].x, points[i].y)
|
|
|
|
|
- ctx.lineTo(points[i + 1].x, points[i + 1].y)
|
|
|
|
|
- }
|
|
|
|
|
- ctx.stroke()
|
|
|
|
|
|
|
+ //setTimeout( function() { }, 0);
|
|
|
|
|
+ stroke(points_array[j].points,points_array[j].color);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -181,24 +191,35 @@ ApplicationWindow {
|
|
|
y: 0
|
|
y: 0
|
|
|
width: canvas.width
|
|
width: canvas.width
|
|
|
height: canvas.height
|
|
height: canvas.height
|
|
|
|
|
+ property var last_point;
|
|
|
|
|
+
|
|
|
onPressed: {
|
|
onPressed: {
|
|
|
- if (!socket.isOpen())
|
|
|
|
|
|
|
+ if (!socket.isOpen)
|
|
|
return
|
|
return
|
|
|
canvas.start_path()
|
|
canvas.start_path()
|
|
|
|
|
+ last_point = { x: mouse.x, y: mouse.y }
|
|
|
|
|
+ canvas.add_point(last_point)
|
|
|
}
|
|
}
|
|
|
onPositionChanged: {
|
|
onPositionChanged: {
|
|
|
- if (!socket.isOpen())
|
|
|
|
|
|
|
+ if (!socket.isOpen)
|
|
|
return
|
|
return
|
|
|
-
|
|
|
|
|
- canvas.add_point({
|
|
|
|
|
- x: mouse.x,
|
|
|
|
|
- y: mouse.y
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ var point = { x: mouse.x, y: mouse.y }
|
|
|
|
|
+ if (distance(last_point, point) <= 81) //distance returns squared dsitance
|
|
|
|
|
+ return;
|
|
|
|
|
+ last_point = point
|
|
|
|
|
+ canvas.add_point(point)
|
|
|
|
|
+ canvas.count++
|
|
|
|
|
+ /*console.log(canvas.count)
|
|
|
|
|
+ console.log(canvas.points_array[canvas.points_array.length-1].length)*/
|
|
|
}
|
|
}
|
|
|
onReleased: {
|
|
onReleased: {
|
|
|
- if (!socket.isOpen())
|
|
|
|
|
|
|
+ if (!socket.isOpen)
|
|
|
return
|
|
return
|
|
|
canvas.finish_path()
|
|
canvas.finish_path()
|
|
|
|
|
+ canvas.requestPaint()
|
|
|
|
|
+ }
|
|
|
|
|
+ function distance(p1,p2){
|
|
|
|
|
+ return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -227,7 +248,7 @@ ApplicationWindow {
|
|
|
fillMode: Image.PreserveAspectFit
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
- enabled: socket.isOpen() && (item1.curImage > 1)
|
|
|
|
|
|
|
+ enabled: socket.isOpen && (item1.curImage > 1)
|
|
|
onClicked : socket.prev_diapo()
|
|
onClicked : socket.prev_diapo()
|
|
|
}
|
|
}
|
|
|
MouseArea {
|
|
MouseArea {
|
|
@@ -239,7 +260,7 @@ ApplicationWindow {
|
|
|
source: "qrc:///images/fwd.png"
|
|
source: "qrc:///images/fwd.png"
|
|
|
fillMode: Image.PreserveAspectFit
|
|
fillMode: Image.PreserveAspectFit
|
|
|
}
|
|
}
|
|
|
- enabled: socket.isOpen() && (item1.curImage < t_slides)
|
|
|
|
|
|
|
+ enabled: socket.isOpen && (item1.curImage < t_slides)
|
|
|
onClicked: socket.next_diapo()
|
|
onClicked: socket.next_diapo()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -270,10 +291,6 @@ ApplicationWindow {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Column {
|
|
Column {
|
|
@@ -372,18 +389,21 @@ ApplicationWindow {
|
|
|
width: parent.width
|
|
width: parent.width
|
|
|
id: button3
|
|
id: button3
|
|
|
text: qsTr("Limpiar")
|
|
text: qsTr("Limpiar")
|
|
|
- enabled: socket.isOpen()
|
|
|
|
|
- onClicked: socket.clear_path()
|
|
|
|
|
|
|
+ enabled: socket.isOpen
|
|
|
|
|
+ onClicked: {
|
|
|
|
|
+ socket.clear_path();
|
|
|
|
|
+ canvas.clean_path();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
Text {
|
|
|
id: wsStatus
|
|
id: wsStatus
|
|
|
- text: qsTr("WS")
|
|
|
|
|
|
|
+ text: qsTr("WS Status")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
Text {
|
|
|
id: diapoStatus
|
|
id: diapoStatus
|
|
|
- text: qsTr("test123")
|
|
|
|
|
|
|
+ text: qsTr("Diapo status")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|