2020-12-22 00:01:36 +00:00
|
|
|
/**
|
|
|
|
* Logarithm Graph Creator - Create graphs with logarithm scales.
|
|
|
|
* Copyright (C) 2020 Ad5001
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick 2.12
|
2020-12-22 17:22:38 +00:00
|
|
|
import "js/utils.js" as Utils
|
2020-12-22 00:01:36 +00:00
|
|
|
|
|
|
|
Grid {
|
2020-12-22 15:47:48 +00:00
|
|
|
id: settings
|
2020-12-22 00:01:36 +00:00
|
|
|
height: 30*Math.max(1, Math.ceil(7 / columns))
|
|
|
|
columns: Math.floor(width / settingWidth)
|
|
|
|
spacing: 10
|
|
|
|
|
|
|
|
signal changed()
|
|
|
|
|
|
|
|
property int settingWidth: 135
|
|
|
|
|
|
|
|
property int xzoom: 100
|
|
|
|
property int yzoom: 10
|
|
|
|
property double xmin: 5/10
|
|
|
|
property double ymax: 25
|
|
|
|
property int yaxisstep: 4
|
|
|
|
property string xaxislabel: "ω (rad/s)"
|
2020-12-22 15:47:48 +00:00
|
|
|
property string yaxislabel: "G (dB)"
|
2020-12-22 00:01:36 +00:00
|
|
|
property string saveFilename: ""
|
|
|
|
|
|
|
|
FileDialog {
|
|
|
|
id: fdiag
|
|
|
|
onAccepted: {
|
|
|
|
var filePath = fileUrl.toString().substr(7)
|
2020-12-22 15:47:48 +00:00
|
|
|
settings.saveFilename = filePath
|
2020-12-22 00:01:36 +00:00
|
|
|
if(exportMode) {
|
|
|
|
root.saveDiagram(filePath)
|
|
|
|
} else {
|
|
|
|
root.loadDiagram(filePath)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line 1
|
|
|
|
// Zoom
|
|
|
|
TextSetting {
|
|
|
|
id: zoomX
|
|
|
|
height: 30
|
|
|
|
isInt: true
|
|
|
|
label: "X Zoom"
|
|
|
|
min: 1
|
2020-12-22 15:47:48 +00:00
|
|
|
width: settings.settingWidth
|
|
|
|
defValue: settings.xzoom
|
2020-12-22 00:01:36 +00:00
|
|
|
onChanged: function(newValue) {
|
2020-12-22 15:47:48 +00:00
|
|
|
settings.xzoom = newValue
|
|
|
|
settings.changed()
|
2020-12-22 00:01:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
TextSetting {
|
|
|
|
id: zoomY
|
|
|
|
height: 30
|
|
|
|
isInt: true
|
|
|
|
label: "Y Zoom"
|
2020-12-22 15:47:48 +00:00
|
|
|
width: settings.settingWidth
|
|
|
|
defValue: settings.yzoom
|
2020-12-22 00:01:36 +00:00
|
|
|
onChanged: function(newValue) {
|
2020-12-22 15:47:48 +00:00
|
|
|
settings.yzoom = newValue
|
|
|
|
settings.changed()
|
2020-12-22 00:01:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// Positioning the graph
|
|
|
|
TextSetting {
|
|
|
|
id: minX
|
|
|
|
height: 30
|
|
|
|
isDouble: true
|
|
|
|
min: 0
|
|
|
|
label: "Min X"
|
2020-12-22 15:47:48 +00:00
|
|
|
width: settings.settingWidth
|
|
|
|
defValue: settings.xmin
|
2020-12-22 00:01:36 +00:00
|
|
|
onChanged: function(newValue) {
|
2020-12-22 15:47:48 +00:00
|
|
|
settings.xmin = newValue
|
|
|
|
settings.changed()
|
2020-12-22 00:01:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
TextSetting {
|
|
|
|
id: maxY
|
|
|
|
height: 30
|
|
|
|
isDouble: true
|
|
|
|
label: "Max Y"
|
2020-12-22 15:47:48 +00:00
|
|
|
width: settings.settingWidth
|
|
|
|
defValue: settings.ymax
|
2020-12-22 00:01:36 +00:00
|
|
|
onChanged: function(newValue) {
|
2020-12-22 15:47:48 +00:00
|
|
|
settings.ymax = newValue
|
|
|
|
settings.changed()
|
2020-12-22 00:01:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
TextSetting {
|
|
|
|
id: yAxisStep
|
|
|
|
height: 30
|
|
|
|
isInt: true
|
|
|
|
label: "Y Axis Step"
|
2020-12-22 15:47:48 +00:00
|
|
|
width: settings.settingWidth
|
|
|
|
defValue: settings.yaxisstep
|
2020-12-22 00:01:36 +00:00
|
|
|
onChanged: function(newValue) {
|
2020-12-22 15:47:48 +00:00
|
|
|
settings.yaxisstep = newValue
|
|
|
|
settings.changed()
|
2020-12-22 00:01:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
id: copyToClipboard
|
|
|
|
height: 30
|
2020-12-22 15:47:48 +00:00
|
|
|
width: settings.settingWidth
|
2020-12-22 00:01:36 +00:00
|
|
|
text: "Copy to clipboard"
|
|
|
|
icon.name: 'editcopy'
|
2020-12-22 15:47:48 +00:00
|
|
|
onClicked: root.copyDiagramToClipboard()
|
2020-12-22 00:01:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TextSetting {
|
|
|
|
id: xAxisLabel
|
|
|
|
height: 30
|
|
|
|
label: "X Label"
|
2020-12-22 15:47:48 +00:00
|
|
|
width: settings.settingWidth
|
|
|
|
defValue: settings.xaxislabel
|
2020-12-22 00:01:36 +00:00
|
|
|
onChanged: function(newValue) {
|
2020-12-22 17:22:38 +00:00
|
|
|
settings.xaxislabel = Utils.parseName(newValue, false)
|
2020-12-22 15:47:48 +00:00
|
|
|
settings.changed()
|
2020-12-22 00:01:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TextSetting {
|
|
|
|
id: yAxisLabel
|
|
|
|
height: 30
|
|
|
|
label: "Y Label"
|
2020-12-22 15:47:48 +00:00
|
|
|
width: settings.settingWidth
|
|
|
|
defValue: settings.yaxislabel
|
2020-12-22 00:01:36 +00:00
|
|
|
onChanged: function(newValue) {
|
2020-12-22 17:22:38 +00:00
|
|
|
settings.yaxislabel = Utils.parseName(newValue, false)
|
2020-12-22 15:47:48 +00:00
|
|
|
settings.changed()
|
2020-12-22 00:01:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
id: saveDiagram
|
|
|
|
height: 30
|
2020-12-22 15:47:48 +00:00
|
|
|
width: settings.settingWidth
|
2020-12-22 00:01:36 +00:00
|
|
|
text: "Save diagram"
|
|
|
|
icon.name: 'filesave'
|
|
|
|
onClicked: save()
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
id: saveDiagramAs
|
|
|
|
height: 30
|
2020-12-22 15:47:48 +00:00
|
|
|
width: settings.settingWidth
|
2020-12-22 00:01:36 +00:00
|
|
|
text: "Save diagram as"
|
|
|
|
icon.name: 'filesaveas'
|
|
|
|
onClicked: saveAs()
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
id: loadDiagram
|
|
|
|
height: 30
|
2020-12-22 15:47:48 +00:00
|
|
|
width: settings.settingWidth
|
2020-12-22 00:01:36 +00:00
|
|
|
text: "Load diagram"
|
|
|
|
icon.name: 'fileopen'
|
|
|
|
onClicked: load()
|
|
|
|
}
|
|
|
|
|
|
|
|
function save() {
|
2020-12-22 15:47:48 +00:00
|
|
|
if(settings.saveFilename == "") {
|
2020-12-22 00:01:36 +00:00
|
|
|
fdiag.exportMode = true
|
|
|
|
fdiag.open()
|
|
|
|
} else {
|
2020-12-22 15:47:48 +00:00
|
|
|
root.saveDiagram(settings.saveFilename)
|
2020-12-22 00:01:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function saveAs() {
|
|
|
|
fdiag.exportMode = true
|
|
|
|
fdiag.open()
|
|
|
|
}
|
|
|
|
|
|
|
|
function load() {
|
|
|
|
fdiag.exportMode = false
|
|
|
|
fdiag.open()
|
|
|
|
}
|
|
|
|
}
|