Explorar el Código

merge in form

David hace 10 años
padre
commit
aaee7a9ceb
Se han modificado 4 ficheros con 134 adiciones y 225 borrados
  1. 3 54
      CanvasController.pro.user
  2. 0 93
      MainForm.ui.qml
  3. 131 77
      main.qml
  4. 0 1
      qml.qrc

+ 3 - 54
CanvasController.pro.user

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.0.3, 2016-08-11T09:37:37. -->
+<!-- Written by QtCreator 4.0.3, 2016-08-11T09:53:34. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>
@@ -649,7 +649,7 @@
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{adf126d9-d8b7-4993-bb9f-0f17f134f6d3}</value>
    <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
    <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
-   <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
+   <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">-1</value>
    <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
     <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/david/build-CanvasController-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Debug</value>
     <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
@@ -905,58 +905,7 @@
    <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings">
     <value type="QString" key="AndroidDeviceSerialNumber">193b6404</value>
    </valuemap>
-   <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
-    <value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
-    <value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
-    <value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
-    <value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
-    <value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
-    <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
-    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
-    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
-    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
-    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
-    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
-    <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
-    <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
-    <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
-    <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
-    <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
-    <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
-    <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
-    <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
-    <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
-    <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
-    <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
-    <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
-     <value type="int">0</value>
-     <value type="int">1</value>
-     <value type="int">2</value>
-     <value type="int">3</value>
-     <value type="int">4</value>
-     <value type="int">5</value>
-     <value type="int">6</value>
-     <value type="int">7</value>
-     <value type="int">8</value>
-     <value type="int">9</value>
-     <value type="int">10</value>
-     <value type="int">11</value>
-     <value type="int">12</value>
-     <value type="int">13</value>
-     <value type="int">14</value>
-    </valuelist>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">CanvasController</value>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.AndroidRunConfiguration:/home/david/CanvasController/CanvasController.pro</value>
-    <value type="QString" key="QMakeProjectManager.QmakeAndroidRunConfiguration.ProFile">CanvasController.pro</value>
-    <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
-    <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
-    <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
-    <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
-    <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
-    <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
-   </valuemap>
-   <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
+   <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">0</value>
   </valuemap>
  </data>
  <data>

+ 0 - 93
MainForm.ui.qml

@@ -1,93 +0,0 @@
-import QtQuick 2.5
-import QtQuick.Controls 1.4
-import QtQuick.Layouts 1.2
-
-Item {
-    id: item1
-    width: 640
-    height: 480
-    property alias gridLayout1: gridLayout1
-    property alias button4: button4
-    property alias mouseArea1: mouseArea1
-    property alias button2: button2
-    property alias button3: button3
-    property alias button1: button1
-
-    GridLayout {
-        id: gridLayout1
-        y: 0
-        height: 480
-        anchors.leftMargin: 337
-        transformOrigin: Item.Center
-        anchors.verticalCenter: parent.verticalCenter
-        anchors.top: parent.top
-        anchors.right: parent.right
-        anchors.left: parent.left
-        rows: 3
-        columns: 8
-        columnSpacing: 5
-
-        ColumnLayout {
-            id: columnLayout1
-            width: 100
-            height: 100
-            Layout.fillHeight: true
-            Layout.columnSpan: 1
-            Layout.alignment: Qt.AlignRight | Qt.AlignTop
-            Layout.maximumWidth: 5000
-
-            Button {
-                id: button2
-                text: qsTr("Anterior")
-                Layout.fillWidth: true
-            }
-
-            Button {
-                id: button1
-                text: qsTr("Siguiente")
-                Layout.fillWidth: true
-            }
-
-
-
-            Button {
-                id: button4
-                x: 133
-                y: 75
-                text: qsTr("Limpiar")
-                Layout.fillWidth: true
-            }
-
-        }
-
-    }
-
-    MouseArea {
-        id: mouseArea1
-        x: 0
-        y: 0
-        width: 320
-        height: 250
-    }
-
-    ColumnLayout {
-        id: columnLayout2
-        x: 337
-        y: 108
-        width: 100
-        height: 100
-        Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
-
-        Button {
-            id: button3
-            text: qsTr("Break")
-            isDefault: false
-            checkable: false
-            Layout.fillHeight: false
-            Layout.rowSpan: 11
-            Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
-            Layout.fillWidth: true
-        }
-    }
-
-}

+ 131 - 77
main.qml

@@ -10,129 +10,183 @@ ApplicationWindow {
     height: 480
     title: qsTr("Hello World")
 
-
     WebSocket {
         id: socket
         url: "wss://ws.especificosba.com.ar"
         onTextMessageReceived: {
-           console.log("\nReceived message: " + message);
+            console.log("\nReceived message: " + message)
         }
         onStatusChanged: if (socket.status == WebSocket.Error) {
                              console.log("Error: " + socket.errorString)
                          } else if (socket.status == WebSocket.Open) {
                              socket.sendTextMessage("Hello World")
                          } else if (socket.status == WebSocket.Closed) {
-                             console.log("\nSocket closed");
+                             console.log("\nSocket closed")
                          }
-        active: false
+        active: true
     }
 
-    MainForm {
-        property int curImage:1
+    Item {
+        id: item1
+        width: 640
+        height: 480
+        //property alias gridLayout1: gridLayout1
+        property alias button4: button4
+        property alias mouseArea1: mouseArea1
+        property alias button2: button2
+        property alias button3: button3
+        property alias button1: button1
+        property int curImage: 1
         anchors.fill: parent
-        button1.enabled: socket.active
-        button2.enabled: socket.active
-        button3.enabled: socket.active
-        button4.enabled: socket.active
 
-        button1.onClicked: {
-            curImage=Math.min(curImage+1,5);
-        }
-        button2.onClicked: {
-            curImage=Math.max(curImage-1,1);
-        }
         onCurImageChanged: {
-            canvas.change_image("EBA",curImage);
+            canvas.change_image("EBA", curImage)
         }
 
-        button3.onClicked: {
-            canvas.paint_canvas();
-        }
-
-        mouseArea1.onPressed: {
-            if (!socket.active)
-                return;
-            canvas.start_path();
-        }
+        Column {
+            id: canvasCol
+            spacing: 6
+            anchors.fill: parent
+            anchors.topMargin: 12
+            width: 400
 
-        mouseArea1.onPositionChanged: {
-            if (!socket.active)
-                return;
-            canvas.add_point({x:mouse.x,y:mouse.y});
-        }
-        mouseArea1.onReleased: {
-            if (!socket.active)
-                return;
-            canvas.finish_path();
-        }
-
-        Canvas {
+            Canvas {
             id: canvas
-            width: parent.width
-            height: parent.width*3/4
             antialiasing: true
+            renderTarget: Canvas.Image
 
             property color strokeStyle: Qt.darker(fillStyle, 1.2)
             property color fillStyle: "#6400aa"
 
             property int lineWidth: 2
-            property real px: width/2
-            property real py: height/2 + 10
+            property real px: width / 2
+            property real py: height / 2 + 10
             property real alpha: 1.0
-            property variant points_array: [ ]
-            property string curImageUrl: "https://plataforma.especificosba.com.ar/diapo/EBA/1.png";
+            property variant points_array: []
+            property string curImageUrl: "https://plataforma.especificosba.com.ar/diapo/EBA/1.png"
+            width: 300
+            height: 300
 
-            onPaint: paint_canvas();
-            onLineWidthChanged: requestPaint();
-            onImageLoaded: requestPaint();
+            onPaint: paint_canvas()
+            onLineWidthChanged: requestPaint()
+            onImageLoaded: requestPaint()
 
-            function start_path(){
-                points_array.push([]);
+            function start_path() {
+                points_array.push([])
             }
 
-            function finish_path(){
-                points_array[points_array.length-1]=Simplify.simplify(points_array[points_array.length-1],3);
-                requestPaint();
+            function finish_path() {
+                points_array[points_array.length - 1] = Simplify.simplify(
+                            points_array[points_array.length - 1], 3)
+                requestPaint()
                 //ws.send()..
             }
 
-            function change_image(pdf,number){
-                curImageUrl="https://plataforma.especificosba.com.ar/diapo/"+pdf+"/"+number+".png";
-                requestPaint();
+            function change_image(pdf, number) {
+                curImageUrl = "https://plataforma.especificosba.com.ar/diapo/"
+                        + pdf + "/" + number + ".png"
+                requestPaint()
             }
 
             function add_point(p) {
-                points_array[points_array.length-1].push(p);
-                requestPaint();
+                points_array[points_array.length - 1].push(p)
+                requestPaint()
             }
 
-            function paint_canvas(){
-                var curColor= '#ff0000';
-                var ctx = canvas.getContext("2d");
-                canvas.loadImage(curImageUrl);
-                if (canvas.isImageLoaded(curImageUrl)){
-                    ctx.drawImage(curImageUrl,0,0,canvas.width,canvas.height);
+            function paint_canvas() {
+                var curColor = '#ff0000'
+                var ctx = canvas.getContext("2d")
+                canvas.loadImage(curImageUrl)
+                if (canvas.isImageLoaded(curImageUrl)) {
+                    ctx.drawImage(curImageUrl, 0, 0, canvas.width,
+                                  canvas.height)
                 }
-                ctx.lineCap = 'square';
-                ctx.lineWidth = 2;
-                ctx.strokeStyle = curColor;
-
-                ctx.beginPath();
-                var i=0,j=0;
-                for(j=0;j<points_array.length;j++){
-                    var points = points_array[j];
-                    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.lineCap = 'square'
+                ctx.lineWidth = 2
+                ctx.strokeStyle = curColor
+
+                ctx.beginPath()
+                var i = 0, j = 0
+                for (j = 0; j < points_array.length; j++) {
+                    var points = points_array[j]
+                    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();
+                ctx.stroke()
             }
+        }
 
+            MouseArea {
+            id: mouseArea1
+            x: 0
+            y: 0
+            width: canvas.width
+            height: canvas.height
+            onPressed: {
+                if (!socket.active)
+                    return
+                canvas.start_path()
+            }
+            onPositionChanged: {
+                if (!socket.active)
+                    return
+
+                canvas.add_point({
+                                     x: mouse.x,
+                                     y: mouse.y
+                                 })
+            }
+            onReleased: {
+                if (!socket.active)
+                    return
+                canvas.finish_path()
+            }
+        }
         }
+        Column {
+            id: columnLayout1
+            spacing: 6
+            anchors.fill: parent
+            anchors.leftMargin: canvasCol.right
+
+            Button {
+                id: button2
+                text: qsTr("Anterior")
+                enabled: socket.active
+                onClicked: item1.curImage = Math.max(item1.curImage - 1, 1)
+            }
 
-    }
+            Button {
+                id: button1
+                text: qsTr("Siguiente")
+                enabled: socket.active
+                onClicked: item1.curImage = Math.min(item1.curImage + 1, 5)
+            }
 
+            Button {
+                id: button4
+                text: qsTr("Limpiar")
+                enabled: socket.active
+            }
+        }
 
+        Column {
+            id: columnLayout2
+            x: 337
+            y: 108
+            width: 100
+            height: 100
+
+            Button {
+                id: button3
+                text: qsTr("Break")
+                isDefault: false
+                checkable: false
+                onClicked: canvas.paint_canvas()
+            }
+        }
+    }
 }

+ 0 - 1
qml.qrc

@@ -1,7 +1,6 @@
 <RCC>
     <qresource prefix="/">
         <file>main.qml</file>
-        <file>MainForm.ui.qml</file>
         <file>simplify.js</file>
     </qresource>
 </RCC>