tools/hhtracer/Main.qml
author unC0Rr
Sun, 12 Jan 2025 22:48:47 +0100
changeset 16085 9ad74696ddec
parent 16084 2d65bd46c92f
permissions -rw-r--r--
Add some progress on hhtracer
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16084
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
     1
import QtQuick
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
     2
import QtQuick.Controls
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
     3
import QtQuick.Dialogs
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
     4
import QtQuick.Layouts
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
     5
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
     6
ApplicationWindow {
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
     7
  height: 900
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
     8
  title: qsTr("Tracer")
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
     9
  visible: true
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    10
  width: 1200
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    11
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    12
  header: ToolBar {
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    13
    RowLayout {
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    14
      Button {
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    15
        text: qsTr("Choose Image...")
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    16
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    17
        onClicked: fileDialog.open()
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    18
      }
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    19
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    20
      Button {
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    21
        text: qsTr("Start")
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    22
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    23
        onClicked: {
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    24
          stepTimer.start();
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    25
        }
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    26
      }
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    27
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    28
      Button {
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    29
        text: qsTr("Stop")
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    30
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    31
        onClicked: {
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    32
          stepTimer.stop();
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    33
        }
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    34
      }
16085
9ad74696ddec Add some progress on hhtracer
unC0Rr
parents: 16084
diff changeset
    35
9ad74696ddec Add some progress on hhtracer
unC0Rr
parents: 16084
diff changeset
    36
      Label {
9ad74696ddec Add some progress on hhtracer
unC0Rr
parents: 16084
diff changeset
    37
        text: "Best: %1".arg(tracer.bestSolution)
9ad74696ddec Add some progress on hhtracer
unC0Rr
parents: 16084
diff changeset
    38
      }
16084
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    39
    }
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    40
  }
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    41
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    42
  FileDialog {
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    43
    id: fileDialog
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    44
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    45
    nameFilters: ["Hedgehog images (*.png)"]
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    46
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    47
    onAccepted: {
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    48
      console.log("Hello")
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    49
      baseImage.source = selectedFile;
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    50
      tracer.start(fileDialog.selectedFile);
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    51
    }
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    52
  }
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    53
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    54
  Tracer {
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    55
    id: tracer
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    56
  }
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    57
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    58
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    59
  Timer {
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    60
    id: stepTimer
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    61
16085
9ad74696ddec Add some progress on hhtracer
unC0Rr
parents: 16084
diff changeset
    62
    interval: 120
16084
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    63
    repeat: true
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    64
    running: false
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    65
    triggeredOnStart: true
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    66
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    67
    onTriggered: tracer.step()
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    68
  }
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    69
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    70
  ColumnLayout {
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    71
    anchors.fill: parent
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    72
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    73
    Image {
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    74
      id: baseImage
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    75
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    76
      Layout.fillWidth: true
16085
9ad74696ddec Add some progress on hhtracer
unC0Rr
parents: 16084
diff changeset
    77
      Layout.preferredHeight: 32
16084
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    78
      fillMode: Image.PreserveAspectFit
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    79
    }
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    80
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    81
    GridLayout {
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    82
      Layout.fillWidth: true
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    83
      Layout.fillHeight: true
16085
9ad74696ddec Add some progress on hhtracer
unC0Rr
parents: 16084
diff changeset
    84
      columns: 50
16084
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    85
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    86
      Repeater {
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    87
        model: tracer.solutions
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    88
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    89
        Image {
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    90
          width: 32
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    91
          height: 32
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    92
          source: "file://" + modelData
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    93
          fillMode: Image.PreserveAspectFit
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    94
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    95
          Rectangle {
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    96
            border.width: 1
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    97
            border.color: "black"
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    98
            color: "transparent"
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
    99
            anchors.fill: parent
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
   100
          }
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
   101
        }
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
   102
      }
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
   103
    }
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
   104
  }
2d65bd46c92f Start work on hedgehog tracer
unC0Rr
parents:
diff changeset
   105
}