|
@@ -72,13 +72,18 @@ ApplicationWindow {
|
|
|
|
|
|
|
|
Canvas {
|
|
Canvas {
|
|
|
id: canvas
|
|
id: canvas
|
|
|
- antialiasing: true
|
|
|
|
|
|
|
+ antialiasing: false
|
|
|
renderTarget: Canvas.Image
|
|
renderTarget: Canvas.Image
|
|
|
|
|
+ renderStrategy: Canvas.Immediate
|
|
|
|
|
+ //defaults
|
|
|
|
|
+ //renderStrategy: Canvas.Cooperative
|
|
|
|
|
+
|
|
|
|
|
+ //renderTarget: Canvas.FramebufferObject
|
|
|
|
|
+ //renderStrategy
|
|
|
|
|
|
|
|
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
|
|
@@ -95,13 +100,14 @@ ApplicationWindow {
|
|
|
ctx.lineCap = 'square'
|
|
ctx.lineCap = 'square'
|
|
|
ctx.lineWidth = 4
|
|
ctx.lineWidth = 4
|
|
|
ctx.strokeStyle = "#000000"
|
|
ctx.strokeStyle = "#000000"
|
|
|
- requestPaint()
|
|
|
|
|
|
|
+ full_repaint()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function clean_path() {
|
|
function clean_path() {
|
|
|
- points_array = []
|
|
|
|
|
- requestPaint()
|
|
|
|
|
- canvas.count = 0
|
|
|
|
|
|
|
+ //points_array = []
|
|
|
|
|
+ points_array.length=0
|
|
|
|
|
+ console.log("clean")
|
|
|
|
|
+ full_repaint()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function start_path() {
|
|
function start_path() {
|
|
@@ -115,7 +121,7 @@ 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()
|
|
|
|
|
|
|
+
|
|
|
if (points_array[points_array.length - 1].points.length <=1)
|
|
if (points_array[points_array.length - 1].points.length <=1)
|
|
|
return;
|
|
return;
|
|
|
//normalized to 800x600
|
|
//normalized to 800x600
|
|
@@ -129,7 +135,6 @@ ApplicationWindow {
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- console.log(ar.length);
|
|
|
|
|
var MAX_ELEMS=65;
|
|
var MAX_ELEMS=65;
|
|
|
while (ar.length > MAX_ELEMS) {
|
|
while (ar.length > MAX_ELEMS) {
|
|
|
socket.send_drawing(ar.splice(0, MAX_ELEMS-1));
|
|
socket.send_drawing(ar.splice(0, MAX_ELEMS-1));
|
|
@@ -140,25 +145,34 @@ ApplicationWindow {
|
|
|
function change_image(pdf, number) {
|
|
function change_image(pdf, number) {
|
|
|
curImageUrl = "https://plataforma.especificosba.com.ar/diapo/"
|
|
curImageUrl = "https://plataforma.especificosba.com.ar/diapo/"
|
|
|
+ pdf + "/" + number + ".png"
|
|
+ pdf + "/" + number + ".png"
|
|
|
- requestPaint()
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
+ var lastpoint;
|
|
|
|
|
+ if (pts.length>1)
|
|
|
|
|
+ lastpoint = pts[pts.length-1];
|
|
|
|
|
+
|
|
|
pts.push(p)
|
|
pts.push(p)
|
|
|
- if (pts.length > 80) {
|
|
|
|
|
|
|
+ if (pts.length > 150) {
|
|
|
//FIXME
|
|
//FIXME
|
|
|
finish_path()
|
|
finish_path()
|
|
|
start_path()
|
|
start_path()
|
|
|
pts.push(p)
|
|
pts.push(p)
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- requestPaint()
|
|
|
|
|
|
|
+ if (lastpoint)
|
|
|
|
|
+ markDirty(Qt.rect(Math.min(p.x,lastpoint.x),Math.min(p.y,lastpoint.y), Math.abs(p.x-lastpoint.x)+4, Math.abs(p.y-lastpoint.y)+1))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
function stroke(points, color) {
|
|
function stroke(points, color) {
|
|
|
- ctx.strokeStyle = color;
|
|
|
|
|
|
|
+ if (points.length===0)
|
|
|
|
|
+ return;
|
|
|
|
|
+ if (ctx.strokeStyle !== color){
|
|
|
|
|
+ ctx.strokeStyle = color;
|
|
|
|
|
+ console.log("Changing colors");
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log(points.length)
|
|
|
ctx.beginPath()
|
|
ctx.beginPath()
|
|
|
ctx.moveTo(points[0].x, points[0].y)
|
|
ctx.moveTo(points[0].x, points[0].y)
|
|
|
var i = 0;
|
|
var i = 0;
|
|
@@ -169,7 +183,8 @@ ApplicationWindow {
|
|
|
ctx.stroke()
|
|
ctx.stroke()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function paint_canvas() {
|
|
|
|
|
|
|
+ function full_repaint(){
|
|
|
|
|
+ //console.log("Fullpaint")
|
|
|
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,
|
|
@@ -179,16 +194,26 @@ ApplicationWindow {
|
|
|
for (j = 0; j < points_array.length; j++) {
|
|
for (j = 0; j < points_array.length; j++) {
|
|
|
if (points_array[j].points.length <= 1)
|
|
if (points_array[j].points.length <= 1)
|
|
|
continue
|
|
continue
|
|
|
- //setTimeout( function() { }, 0);
|
|
|
|
|
stroke(points_array[j].points,points_array[j].color);
|
|
stroke(points_array[j].points,points_array[j].color);
|
|
|
}
|
|
}
|
|
|
|
|
+ requestPaint()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function paint_canvas() {
|
|
|
|
|
+ //full_repaint();
|
|
|
|
|
+ //return;
|
|
|
|
|
+ if (points_array.length==0)
|
|
|
|
|
+ return;
|
|
|
|
|
+ var ar = points_array[points_array.length -1];
|
|
|
|
|
+ stroke(ar.points,ar.color);
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
MouseArea {
|
|
|
id: mouseArea1
|
|
id: mouseArea1
|
|
|
x: 0
|
|
x: 0
|
|
|
- y: 0
|
|
|
|
|
|
|
+ y:0
|
|
|
width: canvas.width
|
|
width: canvas.width
|
|
|
height: canvas.height
|
|
height: canvas.height
|
|
|
property var last_point;
|
|
property var last_point;
|
|
@@ -208,15 +233,11 @@ ApplicationWindow {
|
|
|
return;
|
|
return;
|
|
|
last_point = point
|
|
last_point = point
|
|
|
canvas.add_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){
|
|
function distance(p1,p2){
|
|
|
return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)
|
|
return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)
|
|
@@ -243,6 +264,7 @@ ApplicationWindow {
|
|
|
width: parent.width/2
|
|
width: parent.width/2
|
|
|
height: 70
|
|
height: 70
|
|
|
Image {
|
|
Image {
|
|
|
|
|
+ anchors.centerIn: parent.Center
|
|
|
source: "qrc:///images/back.png"
|
|
source: "qrc:///images/back.png"
|
|
|
height: parent.height
|
|
height: parent.height
|
|
|
fillMode: Image.PreserveAspectFit
|
|
fillMode: Image.PreserveAspectFit
|
|
@@ -256,6 +278,7 @@ ApplicationWindow {
|
|
|
width: parent.width/2
|
|
width: parent.width/2
|
|
|
height: 70
|
|
height: 70
|
|
|
Image {
|
|
Image {
|
|
|
|
|
+ anchors.centerIn: parent.Center
|
|
|
height: parent.height
|
|
height: parent.height
|
|
|
source: "qrc:///images/fwd.png"
|
|
source: "qrc:///images/fwd.png"
|
|
|
fillMode: Image.PreserveAspectFit
|
|
fillMode: Image.PreserveAspectFit
|
|
@@ -318,7 +341,7 @@ ApplicationWindow {
|
|
|
background: Rectangle {
|
|
background: Rectangle {
|
|
|
implicitWidth: 100
|
|
implicitWidth: 100
|
|
|
implicitHeight: 25
|
|
implicitHeight: 25
|
|
|
- border.width: 2
|
|
|
|
|
|
|
+ border.width: 3
|
|
|
border.color: color3.checked?"#000":"#FFF"
|
|
border.color: color3.checked?"#000":"#FFF"
|
|
|
radius: 8
|
|
radius: 8
|
|
|
gradient: Gradient {
|
|
gradient: Gradient {
|
|
@@ -344,7 +367,7 @@ ApplicationWindow {
|
|
|
background: Rectangle {
|
|
background: Rectangle {
|
|
|
implicitWidth: 100
|
|
implicitWidth: 100
|
|
|
implicitHeight: 25
|
|
implicitHeight: 25
|
|
|
- border.width: 2
|
|
|
|
|
|
|
+ border.width: 3
|
|
|
border.color: color2.checked?"#000":"#FFF"
|
|
border.color: color2.checked?"#000":"#FFF"
|
|
|
radius: 8
|
|
radius: 8
|
|
|
gradient: Gradient {
|
|
gradient: Gradient {
|
|
@@ -371,7 +394,7 @@ ApplicationWindow {
|
|
|
background: Rectangle {
|
|
background: Rectangle {
|
|
|
implicitWidth: 100
|
|
implicitWidth: 100
|
|
|
implicitHeight: 25
|
|
implicitHeight: 25
|
|
|
- border.width: 2
|
|
|
|
|
|
|
+ border.width: 3
|
|
|
border.color: color1.checked?"#000":"#FFF"
|
|
border.color: color1.checked?"#000":"#FFF"
|
|
|
radius: 8
|
|
radius: 8
|
|
|
gradient: Gradient {
|
|
gradient: Gradient {
|
|
@@ -391,8 +414,8 @@ ApplicationWindow {
|
|
|
text: qsTr("Limpiar")
|
|
text: qsTr("Limpiar")
|
|
|
enabled: socket.isOpen
|
|
enabled: socket.isOpen
|
|
|
onClicked: {
|
|
onClicked: {
|
|
|
- socket.clear_path();
|
|
|
|
|
canvas.clean_path();
|
|
canvas.clean_path();
|
|
|
|
|
+ socket.clear_path();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|