Skip to content

Commit

Permalink
Initial attempt to load any dataset from file
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSazonov committed May 3, 2024
1 parent c648dc3 commit 6ec4e16
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 10 deletions.
45 changes: 35 additions & 10 deletions EasyTextureApp/Gui/Charts/Plotly1D.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import QtQuick
import QtQuick.Controls
import QtWebEngine

import EasyApp.Gui.Logic as EaLogic
import EasyApp.Gui.Style as EaStyle

import Gui.Globals as Globals

WebEngineView {
id: chartView
Expand All @@ -23,6 +25,8 @@ WebEngineView {

property bool useWebGL: false

property string currentRawFile: Globals.Proxies.main.rawData.currentRawFile

width: parent.width
height: parent.height

Expand All @@ -32,18 +36,18 @@ WebEngineView {

onLoadSucceededStatusChanged: {
if (loadSucceededStatus) {
toggleUseWebGL()
//toggleUseWebGL()

setChartSizes()
setChartColors()
//setChartSizes()
//setChartColors()

setXAxisTitle()
setYAxisTitle()
//setXAxisTitle()
//setYAxisTitle()

emptyData()
setXData()
setMeasuredYData()
setCalculatedYData()
//emptyData()
//setXData()
//setMeasuredYData()
//setCalculatedYData()

visible = true
}
Expand Down Expand Up @@ -104,6 +108,13 @@ WebEngineView {
}
}

onCurrentRawFileChanged: {
if (loadSucceededStatus) {
setData()
redrawPlot()
}
}

// Logic

function setChartSizes() {
Expand Down Expand Up @@ -167,7 +178,7 @@ WebEngineView {
}

function setXData() {
//print(`setXData is started: ${xData.length} points`)
print(`setXData is started: ${xData.length} points`)
runJavaScript(`setXData(${JSON.stringify(xData)})`,
function(result) { print(result) })
}
Expand All @@ -181,4 +192,18 @@ WebEngineView {
runJavaScript(`setCalculatedYData(${JSON.stringify(calculatedYData)})`)
}

function setData() {
const path = EaLogic.Utils.urlToLocalFile(currentRawFile)
print(`setData started: ${path}`)
runJavaScript(`setData(${JSON.stringify(path)})`,
function(result) { print(result) })
}

function setData_() {
print(`setData started: ${currentRawFile}`)
runJavaScript('qwe()',
function(result) { print(result) })
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Column {
"name": getFilename(selectedFile.toString()),
"fullpath": selectedFile.toString()
})
Globals.Proxies.main.rawData.currentRawFile = selectedFile.toString()
Globals.Proxies.main.rawData.isCreated = true //trigger refresh
//Globals.Proxies.main.rawData.loadData()
}
Expand Down
1 change: 1 addition & 0 deletions EasyTextureApp/Gui/Globals/Proxies.qml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ QtObject { // If "Unknown component. (M300) in QtCreator", try: "Tools > QML/JS
property bool is3DtabSelected: true

property var rawFiles: []
property string currentRawFile: ''
property real twoTheta: 45.5
property real thetaRingsMinTT: 50.1

Expand Down
22 changes: 22 additions & 0 deletions EasyTextureApp/Gui/Html/RawDataView/Plotly1dRaw.html
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,28 @@
/////////////////////////////////////////
// Functionality to be accesable from QML
/////////////////////////////////////////

function setData(path) {
// NEED refactoring the whoal javascript section to have
// simple functions for loading data, updating datasets

let request = new XMLHttpRequest()
request.open("GET", path, false)
request.send(null)
data1D = JSON.parse(request1D.responseText)

twoTheta1D = Object.values(data1D["two_theta [deg]"])
gamma1D = Object.values(data1D["user gamma [deg]"])
projCount1D = Object.values(data1D["proj_count"])

// ... updating datasets ...

Plotly.redraw('plotDiv')

return(`setData finished: ${path}`)
}


/*
// need to be called before setChartColors to init axis.titlefont
function setChartSizes(sizes) {
Expand Down

0 comments on commit 6ec4e16

Please sign in to comment.